From 17403278149789644c6c86b79bda7a33c63d0b3e Mon Sep 17 00:00:00 2001 From: ari Date: Sat, 6 Dec 2025 09:54:05 +0700 Subject: [PATCH] update migration issue --- .../migrations/20251201104439.sql | 30 ++++++------------- .../migrations/20251201113804.sql | 4 +-- .../migrations/20251201113858.sql | 4 +-- .../migrations/20251201114751.sql | 4 +-- .../migrations/20251201114913.sql | 4 +-- .../migrations/20251206021053.sql | 26 ++++++++++++++++ .../main-entities/procedure-report/dto.go | 9 +++--- .../main-entities/procedure-report/entity.go | 2 +- .../main-use-case/procedure-report/helper.go | 2 +- 9 files changed, 50 insertions(+), 35 deletions(-) create mode 100644 cmd/main-migration/migrations/20251206021053.sql diff --git a/cmd/main-migration/migrations/20251201104439.sql b/cmd/main-migration/migrations/20251201104439.sql index 6862ccde..50f60b6b 100644 --- a/cmd/main-migration/migrations/20251201104439.sql +++ b/cmd/main-migration/migrations/20251201104439.sql @@ -1,5 +1,5 @@ --- Create "ProcedureReport" table -CREATE TABLE "public"."ProcedureReport" ( +-- Create "ActionReport" table +CREATE TABLE "public"."ActionReport" ( "Id" bigserial NOT NULL, "CreatedAt" timestamptz NULL, "UpdatedAt" timestamptz NULL, @@ -7,25 +7,13 @@ CREATE TABLE "public"."ProcedureReport" ( "Encounter_Id" bigint NULL, "Date" character varying(20) NOT NULL, "Doctor_Code" character varying(10) NULL, - "Operator_Name" character varying(120) NULL, - "Assistant_Name" character varying(120) NULL, - "Instrumentor_Name" character varying(120) NULL, - "Anesthesia_Doctor_Code" character varying(10) NULL, - "Anesthesia_Nurse_Name" character varying(120) NULL, + "Operator_Employe_Id" bigint NULL, + "Assistant_Employe_Id" bigint NULL, + "Instrumentor_Employe_Id" bigint NULL, "Diagnose" character varying(1024) NULL, - "Nurse_Name" character varying(120) NULL, - "ProcedureValue" text NULL, - "ExecutionValue" text NULL, - "Type" character varying(10) NULL, + "Procedures" character varying(10240) NULL, + "Nurse_Code" character varying(10) NULL, + "Value" text NULL, PRIMARY KEY ("Id"), - CONSTRAINT "fk_ProcedureReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION + CONSTRAINT "fk_ActionReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION ); - --- PROPER - -- "Operator_Employe_Id" bigint NULL, - -- "Assistant_Employe_Id" bigint NULL, - -- "Instrumentor_Employe_Id" bigint NULL, - -- "Diagnose" character varying(1024) NULL, - -- "Procedures" character varying(10240) NULL, - -- "Nurse_Code" character varying(10) NULL, - diff --git a/cmd/main-migration/migrations/20251201113804.sql b/cmd/main-migration/migrations/20251201113804.sql index 8cecb5fe..0f5c5123 100644 --- a/cmd/main-migration/migrations/20251201113804.sql +++ b/cmd/main-migration/migrations/20251201113804.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; diff --git a/cmd/main-migration/migrations/20251201113858.sql b/cmd/main-migration/migrations/20251201113858.sql index bc77d02c..fd6fddc9 100644 --- a/cmd/main-migration/migrations/20251201113858.sql +++ b/cmd/main-migration/migrations/20251201113858.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" ADD COLUMN "Date" timestamptz NOT NULL; +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" ADD COLUMN "Date" timestamptz NOT NULL; diff --git a/cmd/main-migration/migrations/20251201114751.sql b/cmd/main-migration/migrations/20251201114751.sql index 339ee39c..6611b811 100644 --- a/cmd/main-migration/migrations/20251201114751.sql +++ b/cmd/main-migration/migrations/20251201114751.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" ADD CONSTRAINT "fk_ProcedureReport_Instrumentor_Employe" FOREIGN KEY ("Instrumentor_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ProcedureReport_Nurse" FOREIGN KEY ("Nurse_Code") REFERENCES "public"."Nurse" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ProcedureReport_Operator_Employe" FOREIGN KEY ("Operator_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- 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 index 85c0281c..5155ed37 100644 --- a/cmd/main-migration/migrations/20251201114913.sql +++ b/cmd/main-migration/migrations/20251201114913.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" ADD CONSTRAINT "fk_ProcedureReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- 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/20251206021053.sql b/cmd/main-migration/migrations/20251206021053.sql new file mode 100644 index 00000000..03ab3bfb --- /dev/null +++ b/cmd/main-migration/migrations/20251206021053.sql @@ -0,0 +1,26 @@ +-- Create "ProcedureReport" table +CREATE TABLE "public"."ProcedureReport" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Date" timestamptz NOT NULL, + "Doctor_Code" character varying(10) NULL, + "Operator_Name" text NULL, + "Assistant_Name" text NULL, + "Instrumentor_Name" text NULL, + "Diagnose" character varying(1024) NULL, + "Nurse_Name" character varying(10) NULL, + "Anesthesia_Doctor_Code" character varying(10) NULL, + "Anesthesia_Nurse_Name" text NULL, + "ProcedureValue" text NULL, + "ExecutionValue" text NULL, + "Type_Code" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_ProcedureReport_Anesthesia_Doctor" FOREIGN KEY ("Anesthesia_Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_ProcedureReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_ProcedureReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Drop "ActionReport" table +DROP TABLE "public"."ActionReport"; diff --git a/internal/domain/main-entities/procedure-report/dto.go b/internal/domain/main-entities/procedure-report/dto.go index b27191a4..ec815b43 100644 --- a/internal/domain/main-entities/procedure-report/dto.go +++ b/internal/domain/main-entities/procedure-report/dto.go @@ -21,7 +21,7 @@ type CreateDto struct { Nurse_Name string `json:"nurse_name" validate:"required"` ProcedureValue string `json:"procedure_value" validate:"required"` ExecutionValue string `json:"execution_value" validate:"required"` - Type string `json:"type" validate:"required"` + Type_Code string `json:"type_code" validate:"required"` pa.AuthInfo @@ -41,7 +41,8 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` + Encounter_Id *uint `json:"encounter-id"` + Type_Code string `json:"type-code"` } type ReadDetailDto struct { @@ -78,7 +79,7 @@ type ResponseDto struct { Nurse_Name string `json:"nurse_name"` ProcedureValue *string `json:"procedure_value"` ExecutionValue *string `json:"execution_value"` - Type string `json:"type"` + Type_Code string `json:"type_code"` } func (d ProcedureReport) ToResponse() ResponseDto { @@ -95,7 +96,7 @@ func (d ProcedureReport) ToResponse() ResponseDto { Nurse_Name: d.Nurse_Name, ProcedureValue: &d.ProcedureValue, ExecutionValue: &d.ExecutionValue, - Type: d.Type, + Type_Code: d.Type_Code, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index 81a888b6..4a8a7032 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -24,7 +24,7 @@ type ProcedureReport struct { Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` ProcedureValue string `json:"procedure_value"` ExecutionValue string `json:"execution_value"` - Type string `json:"type"` + Type_Code string `json:"type_code"` // SurgerySize_Code *string `json:"surgerySize_code" gorm:"size:10"` // Billing_Code *string `json:"billing_code" gorm:"size:10"` diff --git a/internal/use-case/main-use-case/procedure-report/helper.go b/internal/use-case/main-use-case/procedure-report/helper.go index 9fb87778..e16711e5 100644 --- a/internal/use-case/main-use-case/procedure-report/helper.go +++ b/internal/use-case/main-use-case/procedure-report/helper.go @@ -29,7 +29,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ProcedureReport) { data.Nurse_Name = inputSrc.Nurse_Name data.ProcedureValue = inputSrc.ProcedureValue data.ExecutionValue = inputSrc.ExecutionValue - data.Type = inputSrc.Type + data.Type_Code = inputSrc.Type_Code //PROPER // data.Operator_Employe_Id = inputSrc.Operator_Employe_Id