From 47d2e427c0d75a4e5f937291e4911194625530ea Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Mon, 1 Dec 2025 18:49:54 +0700 Subject: [PATCH] feat/action-report: adjust table structure --- cmd/main-migration/migrations/20251201114751.sql | 2 ++ cmd/main-migration/migrations/20251201114913.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 8 +++++--- .../domain/main-entities/action-report/entity.go | 12 +++++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 cmd/main-migration/migrations/20251201114751.sql create mode 100644 cmd/main-migration/migrations/20251201114913.sql diff --git a/cmd/main-migration/migrations/20251201114751.sql b/cmd/main-migration/migrations/20251201114751.sql new file mode 100644 index 00000000..6611b811 --- /dev/null +++ b/cmd/main-migration/migrations/20251201114751.sql @@ -0,0 +1,2 @@ +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" ADD CONSTRAINT "fk_ActionReport_Instrumentor_Employe" FOREIGN KEY ("Instrumentor_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ActionReport_Nurse" FOREIGN KEY ("Nurse_Code") REFERENCES "public"."Nurse" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ActionReport_Operator_Employe" FOREIGN KEY ("Operator_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20251201114913.sql b/cmd/main-migration/migrations/20251201114913.sql new file mode 100644 index 00000000..5155ed37 --- /dev/null +++ b/cmd/main-migration/migrations/20251201114913.sql @@ -0,0 +1,2 @@ +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" ADD CONSTRAINT "fk_ActionReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index db6de529..51161909 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:EpEYOCY46tEg91o5Y4scmFj3/yIyR311HaP95Ts3vus= +h1:bYhAmgY4p8jgE8JpZ6YeJyS1iYCH2LEvDXW2PE+iZpc= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -133,5 +133,7 @@ h1:EpEYOCY46tEg91o5Y4scmFj3/yIyR311HaP95Ts3vus= 20251126064057.sql h1:vAdhz5Nn/gGJy0UKZAEldeXv8HpHtJU/t8ygDVIbTsU= 20251201081333.sql h1:PoC8ADRdwDuohDTB74yW/DaB42igdYa4B6humbrEJBk= 20251201104439.sql h1:tpqdrOf9d2aGwZshqm62nG6SXnfVaO/g6A7z0efPS14= -20251201113804.sql h1:pR0nbmjJNDLi929vmGm2W9RKxLJ2iECzf2otO+JpKWA= -20251201113858.sql h1:JciS3xbCF94huB0qkGJ24YtS1a+nqV26hxzeKh2AOj0= +20251201113804.sql h1:kIEmVoETJXBkab2Q+b3y/pP84eF8W2BdQ47amHCnc+c= +20251201113858.sql h1:KLXKZO5XTQPoEU0YLHE8Fhg9WPKpSN3wNgYPJ+RGFcg= +20251201114751.sql h1:QMcFLz4vr6lwQ03k0Wthhosce743DW9A3w6WJzfqjoU= +20251201114913.sql h1:GvRLyn62Z5CIckonFhtHOZKbJK43yyoCXUfFiADLiAo= diff --git a/internal/domain/main-entities/action-report/entity.go b/internal/domain/main-entities/action-report/entity.go index b3fc1956..8447a2e5 100644 --- a/internal/domain/main-entities/action-report/entity.go +++ b/internal/domain/main-entities/action-report/entity.go @@ -2,23 +2,29 @@ package actionreport import ( ecore "simrs-vx/internal/domain/base-entities/core" + ed "simrs-vx/internal/domain/main-entities/doctor" + eem "simrs-vx/internal/domain/main-entities/employee" ee "simrs-vx/internal/domain/main-entities/encounter" + en "simrs-vx/internal/domain/main-entities/nurse" "time" ) type ActionReport struct { ecore.Main // adjust this according to the needs Encounter_Id uint64 `json:"encounter_id" gorm:"foreignKey"` - Encounter *ee.Encounter `json:"doctor,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` Date *time.Time `json:"date" gorm:"not null;size:20"` Doctor_Code string `json:"doctor_code" gorm:"size:10"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` Operator_Employe_Id uint `json:"operator_employe_id"` + Operator_Employe *eem.Employee `json:"operator_employe,omitempty" gorm:"foreignKey:Operator_Employe_Id;references:Id"` Assistant_Employe_Id uint `json:"assistant_employe_id"` Instrumentor_Employe_Id uint `json:"instrumentor_employe_id"` + Instrumentor_Employe *eem.Employee `json:"instrumentor_employe,omitempty" gorm:"foreignKey:Instrumentor_Employe_Id;references:Id"` Diagnose *string `json:"diagnose" gorm:"size:1024"` Nurse_Code string `json:"nurse_code" gorm:"size:10"` - - Value string `json:"value"` + Nurse *en.Nurse `json:"nurse,omitempty" gorm:"foreignKey:Nurse_Code;references:Code"` + Value string `json:"value"` // SurgerySize_Code *string `json:"surgerySize_code" gorm:"size:10"` // Billing_Code *string `json:"billing_code" gorm:"size:10"` // SurgerySystem_Code *string `json:"surgerySystem_code" gorm:"size:10"`