update migration issue

This commit is contained in:
ari
2025-12-06 09:54:05 +07:00
parent 019a413e9b
commit 1740327814
9 changed files with 50 additions and 35 deletions
@@ -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,
@@ -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";
@@ -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;
@@ -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;
@@ -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;
@@ -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";
@@ -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
@@ -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"`
@@ -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