From 320ce99b0ee41a30c7818840d0681a2a9b12abf6 Mon Sep 17 00:00:00 2001 From: ari Date: Thu, 4 Dec 2025 13:52:24 +0700 Subject: [PATCH 1/8] update procedure report main api --- .../domain/main-entities/action-report/dto.go | 90 -------------- .../main-entities/action-report/entity.go | 51 -------- .../main-entities/procedure-report/dto.go | 110 ++++++++++++++++++ .../main-entities/procedure-report/entity.go | 68 +++++++++++ .../domain/references/clinical/clinical.go | 39 ++++--- .../interface/main-handler/main-handler.go | 4 +- .../handler.go | 4 +- internal/interface/migration/main-entities.go | 4 +- .../main-use-case/action-report/helper.go | 28 ----- .../case.go | 18 +-- .../main-use-case/procedure-report/helper.go | 39 +++++++ .../lib.go | 22 ++-- .../middleware-runner.go | 14 +-- .../middleware.go | 2 +- .../tycovar.go | 10 +- 15 files changed, 277 insertions(+), 226 deletions(-) delete mode 100644 internal/domain/main-entities/action-report/dto.go delete mode 100644 internal/domain/main-entities/action-report/entity.go create mode 100644 internal/domain/main-entities/procedure-report/dto.go create mode 100644 internal/domain/main-entities/procedure-report/entity.go rename internal/interface/main-handler/{action-report => procedure-report}/handler.go (93%) delete mode 100644 internal/use-case/main-use-case/action-report/helper.go rename internal/use-case/main-use-case/{action-report => procedure-report}/case.go (95%) create mode 100644 internal/use-case/main-use-case/procedure-report/helper.go rename internal/use-case/main-use-case/{action-report => procedure-report}/lib.go (83%) rename internal/use-case/main-use-case/{action-report => procedure-report}/middleware-runner.go (86%) rename internal/use-case/main-use-case/{action-report => procedure-report}/middleware.go (89%) rename internal/use-case/main-use-case/{action-report => procedure-report}/tycovar.go (74%) diff --git a/internal/domain/main-entities/action-report/dto.go b/internal/domain/main-entities/action-report/dto.go deleted file mode 100644 index 45c26d17..00000000 --- a/internal/domain/main-entities/action-report/dto.go +++ /dev/null @@ -1,90 +0,0 @@ -package actionreport - -import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/encounter" - "time" - - pa "simrs-vx/internal/lib/auth" -) - -type CreateDto struct { - Encounter_Id uint64 `json:"encounter_id" validate:"required"` - Date *time.Time `json:"date" validate:"required"` - Doctor_Code string `json:"doctor_code" validate:"required"` - Operator_Employe_Id uint `json:"operator_employe_id" validate:"required"` - Assistant_Employe_Id uint `json:"assistant_employe_id" validate:"required"` - Instrumentor_Employe_Id uint `json:"instrumentor_employe_id" validate:"required"` - Diagnose *string `json:"diagnose"` - Nurse_Code string `json:"nurse_code" validate:"required"` - Value string `json:"value" validate:"required"` - - pa.AuthInfo -} - -type ReadListDto struct { - FilterDto - Includes string `json:"includes"` - Pagination ecore.Pagination -} - -type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` -} - -type ReadDetailDto struct { - Id uint16 `json:"id"` -} - -type UpdateDto struct { - Id uint16 `json:"id"` - CreateDto -} - -type DeleteDto struct { - Id uint16 `json:"id"` -} - -type MetaDto struct { - PageNumber int `json:"page_number"` - PageSize int `json:"page_size"` - Count int `json:"count"` -} - -type ResponseDto struct { - ecore.Main - Encounter_Id uint64 `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty"` - Date *time.Time `json:"date"` - Doctor_Code string `json:"doctor_code"` - Operator_Employe_Id uint `json:"operator_employe_id"` - Assistant_Employe_Id uint `json:"assistant_employe_id"` - Instrumentor_Employe_Id uint `json:"instrumentor_employe_id"` - Diagnose *string `json:"diagnose"` - Nurse_Code string `json:"nurse_code"` - Value *string `json:"value"` -} - -func (d ActionReport) ToResponse() ResponseDto { - resp := ResponseDto{ - Encounter_Id: d.Encounter_Id, - Encounter: d.Encounter, - Date: d.Date, - Doctor_Code: d.Doctor_Code, - Operator_Employe_Id: d.Operator_Employe_Id, - Assistant_Employe_Id: d.Assistant_Employe_Id, - Instrumentor_Employe_Id: d.Instrumentor_Employe_Id, - Nurse_Code: d.Nurse_Code, - Value: &d.Value, - } - resp.Main = d.Main - return resp -} - -func ToResponseList(data []ActionReport) []ResponseDto { - resp := make([]ResponseDto, len(data)) - for i, u := range data { - resp[i] = u.ToResponse() - } - return resp -} diff --git a/internal/domain/main-entities/action-report/entity.go b/internal/domain/main-entities/action-report/entity.go deleted file mode 100644 index 8447a2e5..00000000 --- a/internal/domain/main-entities/action-report/entity.go +++ /dev/null @@ -1,51 +0,0 @@ -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:"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"` - 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"` - // StartAt *string `json:"startAt" gorm:"size:20"` - // EndAt *string `json:"endAt" gorm:"size:20"` - // AnesthesiaStartAt *string `json:"anesthesiaStartAt" gorm:"size:20"` - // AnesthesiaEndAt *string `json:"anesthesiaEndAt" gorm:"size:20"` - // SurgeryType_Code *string `json:"surgeryType_code" gorm:"size:10"` - // SurgeryStage_Code *string `json:"surgeryStage_code" gorm:"size:10"` - // BornMortality_Code *string `json:"bornMortality_code" gorm:"size:10"` - // BornLocation_Code *string `json:"bornLocation_code" gorm:"size:10"` - // Weight *string `json:"weight" gorm:"size:10"` - // BornNotes *string `json:"bornNotes" gorm:"size:1024"` - // Description *string `json:"notes" gorm:"size:1024"` - // BleedingAmount *uint16 `json:"bleedingAmount" gorm:"size:10"` - // BloodInType_Code *string `json:"bloodInType_code" gorm:"size:10"` - // BloodInAmount *uint16 `json:"bloodInAmount" gorm:"size:10"` - // Brand *string `json:"brand" gorm:"size:100"` - // ImplantName *string `json:"implantName" gorm:"size:100"` - // ImplantRegisterNumber *string `json:"implantRegisterNumber" gorm:"size:100"` - // ImplantCompanionName *string `json:"implantCompanionName" gorm:"size:100"` - // SpecimentDest_Code *string `json:"specimentDest" gorm:"size:100"` - // TissueInfo *string `json:"tissueInfo" gorm:"size:100"` -} diff --git a/internal/domain/main-entities/procedure-report/dto.go b/internal/domain/main-entities/procedure-report/dto.go new file mode 100644 index 00000000..9cd400be --- /dev/null +++ b/internal/domain/main-entities/procedure-report/dto.go @@ -0,0 +1,110 @@ +package procedurereport + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/encounter" + "time" + + pa "simrs-vx/internal/lib/auth" +) + +type CreateDto struct { + Encounter_Id uint64 `json:"encounter_id" validate:"required"` + Date *time.Time `json:"date" validate:"required"` + Doctor_Code string `json:"doctor_code" validate:"required"` + Operator_Name string `json:"operator_name" validate:"required"` + Assistant_Name string `json:"assistant_name" validate:"required"` + Instrumentor_Name string `json:"instrumentor_name" validate:"required"` + Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" validate:"required"` + Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name" validate:"required"` + Diagnose *string `json:"diagnose"` + 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"` + + pa.AuthInfo + + // PROPER + // Operator_Employe_Id uint `json:"operator_employe_id" validate:"required"` + // Assistant_Employe_Id uint `json:"assistant_employe_id" validate:"required"` + // Instrumentor_Employe_Id uint `json:"instrumentor_employe_id" validate:"required"` + // Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" validate:"required"` + // Anesthesia_Nurse_Employe_Id uint `json:"anesthesia_nurse_employe_id" validate:"required"` + // Nurse_Code string `json:"nurse_code" validate:"required"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id *uint `json:"encounter-id"` +} + +type ReadDetailDto struct { + Id uint16 `json:"id"` +} + +type UpdateDto struct { + Id uint16 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint16 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.Main + Encounter_Id uint64 `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty"` + Date *time.Time `json:"date"` + Doctor_Code string `json:"doctor_code"` + Operator_Name string `json:"operator_name"` + Assistant_Name string `json:"assistant_name"` + Instrumentor_Name string `json:"instrumentor_name"` + Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code"` + Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + Diagnose *string `json:"diagnose"` + Nurse_Name string `json:"nurse_name"` + ProcedureValue *string `json:"procedure_value"` + ExecutionValue *string `json:"execution_value"` + Type string `json:"type"` +} + +func (d ProcedureReport) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Date: d.Date, + Doctor_Code: d.Doctor_Code, + Operator_Name: d.Operator_Name, + Assistant_Name: d.Assistant_Name, + Instrumentor_Name: d.Instrumentor_Name, + Anesthesia_Doctor_Code: d.Anesthesia_Doctor_Code, + Anesthesia_Nurse_Name: d.Anesthesia_Nurse_Name, + Nurse_Name: d.Nurse_Name, + ProcedureValue: &d.ProcedureValue, + ExecutionValue: &d.ExecutionValue, + Type: d.Type, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []ProcedureReport) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go new file mode 100644 index 00000000..f25bf604 --- /dev/null +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -0,0 +1,68 @@ +package procedurereport + +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" + "time" +) + +type ProcedureReport struct { + ecore.Main // adjust this according to the needs + Encounter_Id uint64 `json:"encounter_id" gorm:"foreignKey"` + 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_Name string `json:"operator_name"` + Assistant_Name string `json:"assistant_name"` + Instrumentor_Name string `json:"instrumentor_name"` + Diagnose *string `json:"diagnose" gorm:"size:1024"` + Nurse_Name string `json:"nurse_code" gorm:"size:10"` + Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" gorm:"size:10"` + Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` + Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + ProcedureValue string `json:"procedure_value"` + ExecutionValue string `json:"execution_value"` + Type string `json:"type"` + + // 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"` + // StartAt *string `json:"startAt" gorm:"size:20"` + // EndAt *string `json:"endAt" gorm:"size:20"` + // AnesthesiaStartAt *string `json:"anesthesiaStartAt" gorm:"size:20"` + // AnesthesiaEndAt *string `json:"anesthesiaEndAt" gorm:"size:20"` + // SurgeryType_Code *string `json:"surgeryType_code" gorm:"size:10"` + // SurgeryStage_Code *string `json:"surgeryStage_code" gorm:"size:10"` + // BornMortality_Code *string `json:"bornMortality_code" gorm:"size:10"` + // BornLocation_Code *string `json:"bornLocation_code" gorm:"size:10"` + // Weight *string `json:"weight" gorm:"size:10"` + // BornNotes *string `json:"bornNotes" gorm:"size:1024"` + // Description *string `json:"notes" gorm:"size:1024"` + // BleedingAmount *uint16 `json:"bleedingAmount" gorm:"size:10"` + // BloodInType_Code *string `json:"bloodInType_code" gorm:"size:10"` + // BloodInAmount *uint16 `json:"bloodInAmount" gorm:"size:10"` + // Brand *string `json:"brand" gorm:"size:100"` + // ImplantName *string `json:"implantName" gorm:"size:100"` + // ImplantRegisterNumber *string `json:"implantRegisterNumber" gorm:"size:100"` + // ImplantCompanionName *string `json:"implantCompanionName" gorm:"size:100"` + // SpecimentDest_Code *string `json:"specimentDest" gorm:"size:100"` + // TissueInfo *string `json:"tissueInfo" gorm:"size:100"` + + //PROPER + // 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"` + // Nurse_Code string `json:"nurse_code" gorm:"size:10"` + // Nurse *en.Nurse `json:"nurse,omitempty" gorm:"foreignKey:Nurse_Code;references:Code"` + // Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" gorm:"size:10"` + // Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` + // Anesthesia_Nurse_Employe_Id uint `json:"anesthesia_nurse_employe_id"` + // Anesthesia_Nurse *eem.Employee `json:"anesthesia_nurse,omitempty" gorm:"foreignKey:Anesthesia_Nurse_Employe_Id;references:Id"` +} diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index a9d3fc2b..3054c130 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -204,26 +204,26 @@ const ( MSCMicroLab McuScopeCode = "micro-lab" MSCApLab McuScopeCode = "ap-lab" - SSCSmall SurgerySizeCode = "" - SSCMedium SurgerySizeCode = "" - SSCLarge SurgerySizeCode = "" - SSCSpecial SurgerySizeCode = "" + SSCSmall SurgerySizeCode = "small" + SSCMedium SurgerySizeCode = "medium" + SSCLarge SurgerySizeCode = "large" + SSCSpecial SurgerySizeCode = "special" - SSyCCito SurgerySystemCode = "" - SSyCUrgent SurgerySystemCode = "" - SSyCEfective SurgerySystemCode = "" - SSyCSpecial SurgerySystemCode = "" + SSyCCito SurgerySystemCode = "cito" + SSyCUrgent SurgerySystemCode = "urgent" + SSyCEfective SurgerySystemCode = "efective" + SSyCSpecial SurgerySystemCode = "special" - STCClean SurgeryTypeCode = "" - STCCleanCtm SurgeryTypeCode = "" - STCUncleanCtm SurgeryTypeCode = "" - STCUnclean SurgeryTypeCode = "" + STCClean SurgeryTypeCode = "clean" + STCCleanCtm SurgeryTypeCode = "clean-ctm" + STCUncleanCtm SurgeryTypeCode = "unclean-ctm" + STCUnclean SurgeryTypeCode = "unclean" - SStCFirst SurgeryStageCode = "" - SStCRepeat SurgeryStageCode = "" + SStCFirst SurgeryStageCode = "first" + SStCRepeat SurgeryStageCode = "repeat" - BMCAlive BornMortalityCode = "" - BMCDead BornMortalityCode = "" + BMCAlive BornMortalityCode = "alive" + BMCDead BornMortalityCode = "dead" BLCExtMiw BornLocationCode = "" BLCExtDoc BornLocationCode = "" @@ -360,8 +360,11 @@ type HeadToToe struct { BodyOthers string `json:"body-others,omitempty"` } -type RecordAction struct { - Procedures []string `json:"procedures"` +type ProcedureRecord struct { + Procedures []CodeWithName `json:"procedures"` +} + +type ProcedureExecution struct { SurgerySize_Code *string `json:"surgerySize_code"` Billing_Code *string `json:"billing_code"` SurgerySystem_Code *string `json:"surgerySystem_code"` diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index d7c482e0..86b0c2aa 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -4,7 +4,6 @@ import ( "net/http" /******************** main / transaction ********************/ - actionreport "simrs-vx/internal/interface/main-handler/action-report" adime "simrs-vx/internal/interface/main-handler/adime" admemployeehist "simrs-vx/internal/interface/main-handler/adm-employee-hist" ambulancetransportrequest "simrs-vx/internal/interface/main-handler/ambulance-transport-req" @@ -34,6 +33,7 @@ import ( practiceschedule "simrs-vx/internal/interface/main-handler/practice-schedule" prescription "simrs-vx/internal/interface/main-handler/prescription" prescriptionitem "simrs-vx/internal/interface/main-handler/prescription-item" + procedurereport "simrs-vx/internal/interface/main-handler/procedure-report" procedureroomorder "simrs-vx/internal/interface/main-handler/procedure-room-order" procedureroomorderitem "simrs-vx/internal/interface/main-handler/procedure-room-order-item" responsibledoctorhist "simrs-vx/internal/interface/main-handler/responsible-doctor-hist" @@ -176,7 +176,7 @@ func SetRoutes() http.Handler { hc.RegCrud(r, "/v1/sbar", auth.GuardMW, sbar.O) hc.RegCrud(r, "/v1/prescription-item", prescriptionitem.O) hc.RegCrud(r, "/v1/device-order-item", deviceorderitem.O) - hc.RegCrud(r, "/v1/action-report", auth.GuardMW, actionreport.O) + hc.RegCrud(r, "/v1/procedure-report", auth.GuardMW, procedurereport.O) hc.RegCrud(r, "/v1/material-order-item", materialorderitem.O) hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{ diff --git a/internal/interface/main-handler/action-report/handler.go b/internal/interface/main-handler/procedure-report/handler.go similarity index 93% rename from internal/interface/main-handler/action-report/handler.go rename to internal/interface/main-handler/procedure-report/handler.go index 0fdd1851..a648463b 100644 --- a/internal/interface/main-handler/action-report/handler.go +++ b/internal/interface/main-handler/procedure-report/handler.go @@ -8,8 +8,8 @@ import ( // ua "github.com/karincake/tumpeng/auth/svc" - e "simrs-vx/internal/domain/main-entities/action-report" - u "simrs-vx/internal/use-case/main-use-case/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" + u "simrs-vx/internal/use-case/main-use-case/procedure-report" pa "simrs-vx/internal/lib/auth" diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 34530d78..8b43f165 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -1,7 +1,6 @@ package migration import ( - actionreport "simrs-vx/internal/domain/main-entities/action-report" adime "simrs-vx/internal/domain/main-entities/adime" admemployeehist "simrs-vx/internal/domain/main-entities/adm-employee-hist" ambulancetransportreq "simrs-vx/internal/domain/main-entities/ambulance-transport-req" @@ -82,6 +81,7 @@ import ( practiceschedule "simrs-vx/internal/domain/main-entities/practice-schedule" prescription "simrs-vx/internal/domain/main-entities/prescription" prescriptionitem "simrs-vx/internal/domain/main-entities/prescription-item" + procedurereport "simrs-vx/internal/domain/main-entities/procedure-report" procedureroom "simrs-vx/internal/domain/main-entities/procedure-room" procedureroomorder "simrs-vx/internal/domain/main-entities/procedure-room-order" procedureroomorderitem "simrs-vx/internal/domain/main-entities/procedure-room-order-item" @@ -234,6 +234,6 @@ func getMainEntities() []any { &resume.Resume{}, &vclaimreference.VclaimReference{}, &screening.Screening{}, - &actionreport.ActionReport{}, + &procedurereport.ProcedureReport{}, } } diff --git a/internal/use-case/main-use-case/action-report/helper.go b/internal/use-case/main-use-case/action-report/helper.go deleted file mode 100644 index efe4532e..00000000 --- a/internal/use-case/main-use-case/action-report/helper.go +++ /dev/null @@ -1,28 +0,0 @@ -/* -DESCRIPTION: -Any functions that are used internally by the use-case -*/ -package actionreport - -import ( - e "simrs-vx/internal/domain/main-entities/action-report" -) - -func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ActionReport) { - var inputSrc *e.CreateDto - if inputT, ok := any(input).(*e.CreateDto); ok { - inputSrc = inputT - } else { - inputTemp := any(input).(*e.UpdateDto) - inputSrc = &inputTemp.CreateDto - } - - data.Encounter_Id = inputSrc.Encounter_Id - data.Date = inputSrc.Date - data.Doctor_Code = inputSrc.Doctor_Code - data.Operator_Employe_Id = inputSrc.Operator_Employe_Id - data.Assistant_Employe_Id = inputSrc.Assistant_Employe_Id - data.Instrumentor_Employe_Id = inputSrc.Instrumentor_Employe_Id - data.Nurse_Code = inputSrc.Nurse_Code - data.Value = inputSrc.Value -} diff --git a/internal/use-case/main-use-case/action-report/case.go b/internal/use-case/main-use-case/procedure-report/case.go similarity index 95% rename from internal/use-case/main-use-case/action-report/case.go rename to internal/use-case/main-use-case/procedure-report/case.go index 2ae0f268..e44cfaee 100644 --- a/internal/use-case/main-use-case/action-report/case.go +++ b/internal/use-case/main-use-case/procedure-report/case.go @@ -1,10 +1,10 @@ -package actionreport +package procedurereport import ( "errors" "strconv" - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" dg "github.com/karincake/apem/db-gorm-pg" d "github.com/karincake/dodol" @@ -15,10 +15,10 @@ import ( "gorm.io/gorm" ) -const source = "action-report" +const source = "procedure-report" func Create(input e.CreateDto) (*d.Data, error) { - data := e.ActionReport{} + data := e.ProcedureReport{} event := pl.Event{ Feature: "Create", @@ -85,8 +85,8 @@ func Create(input e.CreateDto) (*d.Data, error) { } func ReadList(input e.ReadListDto) (*d.Data, error) { - var data *e.ActionReport - var dataList []e.ActionReport + var data *e.ProcedureReport + var dataList []e.ProcedureReport var metaList *e.MetaDto var err error @@ -138,7 +138,7 @@ func ReadList(input e.ReadListDto) (*d.Data, error) { } func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { - var data *e.ActionReport + var data *e.ProcedureReport var err error event := pl.Event{ @@ -186,7 +186,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { func Update(input e.UpdateDto) (*d.Data, error) { rdDto := e.ReadDetailDto{Id: input.Id} - var data *e.ActionReport + var data *e.ProcedureReport var err error event := pl.Event{ @@ -242,7 +242,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { func Delete(input e.DeleteDto) (*d.Data, error) { rdDto := e.ReadDetailDto{Id: input.Id} - var data *e.ActionReport + var data *e.ProcedureReport var err error event := pl.Event{ diff --git a/internal/use-case/main-use-case/procedure-report/helper.go b/internal/use-case/main-use-case/procedure-report/helper.go new file mode 100644 index 00000000..9fb87778 --- /dev/null +++ b/internal/use-case/main-use-case/procedure-report/helper.go @@ -0,0 +1,39 @@ +/* +DESCRIPTION: +Any functions that are used internally by the use-case +*/ +package procedurereport + +import ( + e "simrs-vx/internal/domain/main-entities/procedure-report" +) + +func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ProcedureReport) { + var inputSrc *e.CreateDto + if inputT, ok := any(input).(*e.CreateDto); ok { + inputSrc = inputT + } else { + inputTemp := any(input).(*e.UpdateDto) + inputSrc = &inputTemp.CreateDto + } + + data.Encounter_Id = inputSrc.Encounter_Id + data.Date = inputSrc.Date + data.Doctor_Code = inputSrc.Doctor_Code + data.Operator_Name = inputSrc.Operator_Name + data.Assistant_Name = inputSrc.Assistant_Name + data.Instrumentor_Name = inputSrc.Instrumentor_Name + data.Anesthesia_Doctor_Code = inputSrc.Anesthesia_Doctor_Code + data.Anesthesia_Nurse_Name = inputSrc.Anesthesia_Nurse_Name + data.Diagnose = inputSrc.Diagnose + data.Nurse_Name = inputSrc.Nurse_Name + data.ProcedureValue = inputSrc.ProcedureValue + data.ExecutionValue = inputSrc.ExecutionValue + data.Type = inputSrc.Type + + //PROPER + // data.Operator_Employe_Id = inputSrc.Operator_Employe_Id + // data.Assistant_Employe_Id = inputSrc.Assistant_Employe_Id + // data.Instrumentor_Employe_Id = inputSrc.Instrumentor_Employe_Id + // data.Nurse_Code = inputSrc.Nurse_Code +} diff --git a/internal/use-case/main-use-case/action-report/lib.go b/internal/use-case/main-use-case/procedure-report/lib.go similarity index 83% rename from internal/use-case/main-use-case/action-report/lib.go rename to internal/use-case/main-use-case/procedure-report/lib.go index 5a272cce..0588a944 100644 --- a/internal/use-case/main-use-case/action-report/lib.go +++ b/internal/use-case/main-use-case/procedure-report/lib.go @@ -1,7 +1,7 @@ -package actionreport +package procedurereport import ( - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" plh "simrs-vx/pkg/lib-helper" pl "simrs-vx/pkg/logger" @@ -12,10 +12,10 @@ import ( "gorm.io/gorm" ) -func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.ActionReport, error) { +func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.ProcedureReport, error) { pl.SetLogInfo(event, nil, "started", "DBCreate") - data := e.ActionReport{} + data := e.ProcedureReport{} setData(&input, &data) var tx *gorm.DB @@ -33,9 +33,9 @@ func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.ActionR return &data, nil } -func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.ActionReport, *e.MetaDto, error) { +func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.ProcedureReport, *e.MetaDto, error) { pl.SetLogInfo(event, input, "started", "DBReadList") - data := []e.ActionReport{} + data := []e.ProcedureReport{} pagination := gh.Pagination{} count := int64(0) meta := e.MetaDto{} @@ -48,7 +48,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Ac } tx = tx. - Model(&e.ActionReport{}). + Model(&e.ProcedureReport{}). Scopes(gh.Preload(input.Includes)). Scopes(gh.Filter(input.FilterDto)). Count(&count). @@ -70,9 +70,9 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Ac return data, &meta, nil } -func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e.ActionReport, error) { +func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e.ProcedureReport, error) { pl.SetLogInfo(event, input, "started", "DBReadDetail") - data := e.ActionReport{} + data := e.ProcedureReport{} var tx *gorm.DB if len(dbx) > 0 { @@ -91,7 +91,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e return &data, nil } -func UpdateData(input e.UpdateDto, data *e.ActionReport, event *pl.Event, dbx ...*gorm.DB) error { +func UpdateData(input e.UpdateDto, data *e.ProcedureReport, event *pl.Event, dbx ...*gorm.DB) error { pl.SetLogInfo(event, data, "started", "DBUpdate") setData(&input, data) @@ -116,7 +116,7 @@ func UpdateData(input e.UpdateDto, data *e.ActionReport, event *pl.Event, dbx .. return nil } -func DeleteData(data *e.ActionReport, event *pl.Event, dbx ...*gorm.DB) error { +func DeleteData(data *e.ProcedureReport, event *pl.Event, dbx ...*gorm.DB) error { pl.SetLogInfo(event, data, "started", "DBDelete") var tx *gorm.DB if len(dbx) > 0 { diff --git a/internal/use-case/main-use-case/action-report/middleware-runner.go b/internal/use-case/main-use-case/procedure-report/middleware-runner.go similarity index 86% rename from internal/use-case/main-use-case/action-report/middleware-runner.go rename to internal/use-case/main-use-case/procedure-report/middleware-runner.go index e2544169..c849ef28 100644 --- a/internal/use-case/main-use-case/action-report/middleware-runner.go +++ b/internal/use-case/main-use-case/procedure-report/middleware-runner.go @@ -1,7 +1,7 @@ -package actionreport +package procedurereport import ( - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" pl "simrs-vx/pkg/logger" pu "simrs-vx/pkg/use-case-helper" @@ -23,7 +23,7 @@ func newMiddlewareRunner(event *pl.Event, tx *gorm.DB) *middlewareRunner { } // ExecuteCreateMiddleware executes create middleware -func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e.CreateDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e.CreateDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -38,7 +38,7 @@ func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e return nil } -func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, input *e.ReadListDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, input *e.ReadListDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -53,7 +53,7 @@ func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, inpu return nil } -func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -68,7 +68,7 @@ func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, return nil } -func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -83,7 +83,7 @@ func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, inpu return nil } -func (me *middlewareRunner) RunDeleteMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunDeleteMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) diff --git a/internal/use-case/main-use-case/action-report/middleware.go b/internal/use-case/main-use-case/procedure-report/middleware.go similarity index 89% rename from internal/use-case/main-use-case/action-report/middleware.go rename to internal/use-case/main-use-case/procedure-report/middleware.go index 50254de2..157d4e2e 100644 --- a/internal/use-case/main-use-case/action-report/middleware.go +++ b/internal/use-case/main-use-case/procedure-report/middleware.go @@ -1,4 +1,4 @@ -package actionreport +package procedurereport // example of middleware // func init() { diff --git a/internal/use-case/main-use-case/action-report/tycovar.go b/internal/use-case/main-use-case/procedure-report/tycovar.go similarity index 74% rename from internal/use-case/main-use-case/action-report/tycovar.go rename to internal/use-case/main-use-case/procedure-report/tycovar.go index 9eebfabd..3fb449c3 100644 --- a/internal/use-case/main-use-case/action-report/tycovar.go +++ b/internal/use-case/main-use-case/procedure-report/tycovar.go @@ -6,27 +6,27 @@ In this sample it also provides type and variable regarding the needs of the middleware to separate from main use-case which has the basic CRUD functionality. The purpose of this is to make the code more maintainable. */ -package actionreport +package procedurereport import ( "gorm.io/gorm" - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" ) type createMw struct { Name string - Func func(input *e.CreateDto, data *e.ActionReport, tx *gorm.DB) error + Func func(input *e.CreateDto, data *e.ProcedureReport, tx *gorm.DB) error } type readListMw struct { Name string - Func func(input *e.ReadListDto, data *e.ActionReport, tx *gorm.DB) error + Func func(input *e.ReadListDto, data *e.ProcedureReport, tx *gorm.DB) error } type readDetailMw struct { Name string - Func func(input *e.ReadDetailDto, data *e.ActionReport, tx *gorm.DB) error + Func func(input *e.ReadDetailDto, data *e.ProcedureReport, tx *gorm.DB) error } type UpdateMw = readDetailMw From 9d3a872eba9ccd8b9cd34fabc0d4fab8f0a8078b Mon Sep 17 00:00:00 2001 From: ari Date: Thu, 4 Dec 2025 14:01:57 +0700 Subject: [PATCH 2/8] update migration --- .../migrations/20251201104439.sql | 28 +++++++++++++------ .../migrations/20251201113804.sql | 4 +-- .../migrations/20251201113858.sql | 4 +-- .../migrations/20251201114751.sql | 4 +-- .../migrations/20251201114913.sql | 4 +-- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/cmd/main-migration/migrations/20251201104439.sql b/cmd/main-migration/migrations/20251201104439.sql index 50f60b6b..832d10e2 100644 --- a/cmd/main-migration/migrations/20251201104439.sql +++ b/cmd/main-migration/migrations/20251201104439.sql @@ -1,5 +1,5 @@ --- Create "ActionReport" table -CREATE TABLE "public"."ActionReport" ( +-- Create "ProcedureReport" table +CREATE TABLE "public"."ProcedureReport" ( "Id" bigserial NOT NULL, "CreatedAt" timestamptz NULL, "UpdatedAt" timestamptz NULL, @@ -7,13 +7,23 @@ CREATE TABLE "public"."ActionReport" ( "Encounter_Id" bigint NULL, "Date" character varying(20) NOT NULL, "Doctor_Code" character varying(10) NULL, - "Operator_Employe_Id" bigint NULL, - "Assistant_Employe_Id" bigint NULL, - "Instrumentor_Employe_Id" bigint NULL, + "Operator_Name" character varying(120) NULL, + "Assistant_Name" character varying(120) NULL, + "Instrumentor_Name" character varying(120) NULL, "Diagnose" character varying(1024) NULL, - "Procedures" character varying(10240) NULL, - "Nurse_Code" character varying(10) NULL, - "Value" text NULL, + "Nurse_Name" character varying(120) NULL, + "ProcedureValue" text NULL, + "ExecutionValue" text NULL, + "Type" character varying(10) NULL, PRIMARY KEY ("Id"), - CONSTRAINT "fk_ActionReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") 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 ); + +-- 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 0f5c5123..8cecb5fe 100644 --- a/cmd/main-migration/migrations/20251201113804.sql +++ b/cmd/main-migration/migrations/20251201113804.sql @@ -1,2 +1,2 @@ --- Modify "ActionReport" table -ALTER TABLE "public"."ActionReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; diff --git a/cmd/main-migration/migrations/20251201113858.sql b/cmd/main-migration/migrations/20251201113858.sql index fd6fddc9..bc77d02c 100644 --- a/cmd/main-migration/migrations/20251201113858.sql +++ b/cmd/main-migration/migrations/20251201113858.sql @@ -1,2 +1,2 @@ --- Modify "ActionReport" table -ALTER TABLE "public"."ActionReport" ADD COLUMN "Date" timestamptz NOT NULL; +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" ADD COLUMN "Date" timestamptz NOT NULL; diff --git a/cmd/main-migration/migrations/20251201114751.sql b/cmd/main-migration/migrations/20251201114751.sql index 6611b811..339ee39c 100644 --- a/cmd/main-migration/migrations/20251201114751.sql +++ b/cmd/main-migration/migrations/20251201114751.sql @@ -1,2 +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; +-- 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; diff --git a/cmd/main-migration/migrations/20251201114913.sql b/cmd/main-migration/migrations/20251201114913.sql index 5155ed37..85c0281c 100644 --- a/cmd/main-migration/migrations/20251201114913.sql +++ b/cmd/main-migration/migrations/20251201114913.sql @@ -1,2 +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; +-- 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; From 1a92e4539c161ee7287d326c8e96ff88d8a46455 Mon Sep 17 00:00:00 2001 From: ari Date: Thu, 4 Dec 2025 14:03:41 +0700 Subject: [PATCH 3/8] update query --- cmd/main-migration/migrations/20251201104439.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/main-migration/migrations/20251201104439.sql b/cmd/main-migration/migrations/20251201104439.sql index 832d10e2..6862ccde 100644 --- a/cmd/main-migration/migrations/20251201104439.sql +++ b/cmd/main-migration/migrations/20251201104439.sql @@ -10,6 +10,8 @@ CREATE TABLE "public"."ProcedureReport" ( "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, "Diagnose" character varying(1024) NULL, "Nurse_Name" character varying(120) NULL, "ProcedureValue" text NULL, From dc75980e307a8639df1c549e43282fe2350f7ca2 Mon Sep 17 00:00:00 2001 From: ari Date: Fri, 5 Dec 2025 09:31:13 +0700 Subject: [PATCH 4/8] update const --- .../domain/references/clinical/clinical.go | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index 3054c130..44de34b6 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -30,6 +30,7 @@ type ( BornMortalityCode string BornLocationCode string SpecimentDestCode string + ProcedureReportType string ) const ( @@ -225,16 +226,19 @@ const ( BMCAlive BornMortalityCode = "alive" BMCDead BornMortalityCode = "dead" - BLCExtMiw BornLocationCode = "" - BLCExtDoc BornLocationCode = "" - BLCTradMiw BornLocationCode = "" - BLCLocalMed BornLocationCode = "" - BLCExtParamedic BornLocationCode = "" + BLCExtMiw BornLocationCode = "ext-miw" + BLCExtDoc BornLocationCode = "ext-doc" + BLCTradMiw BornLocationCode = "trad-miw" + BLCLocalMed BornLocationCode = "local-med" + BLCExtParamedic BornLocationCode = "ext-paramedic" - SDCAp SpecimentDestCode = "" - SDCMicro SpecimentDestCode = "" - SDCLab SpecimentDestCode = "" - SDCNone SpecimentDestCode = "" + SDCAp SpecimentDestCode = "ap" + SDCMicro SpecimentDestCode = "micro" + SDCLab SpecimentDestCode = "lab" + SDCNone SpecimentDestCode = "none" + + PRTProcedure ProcedureReportType = "procedure" + PRTSurgery ProcedureReportType = "surgery" ) type Soapi struct { From ff0b7f1fab3617cf0f0fc0252222acd236651222 Mon Sep 17 00:00:00 2001 From: ari Date: Fri, 5 Dec 2025 09:39:30 +0700 Subject: [PATCH 5/8] update non required val --- internal/domain/main-entities/procedure-report/dto.go | 8 ++++---- internal/domain/main-entities/procedure-report/entity.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/domain/main-entities/procedure-report/dto.go b/internal/domain/main-entities/procedure-report/dto.go index 9cd400be..b27191a4 100644 --- a/internal/domain/main-entities/procedure-report/dto.go +++ b/internal/domain/main-entities/procedure-report/dto.go @@ -15,8 +15,8 @@ type CreateDto struct { Operator_Name string `json:"operator_name" validate:"required"` Assistant_Name string `json:"assistant_name" validate:"required"` Instrumentor_Name string `json:"instrumentor_name" validate:"required"` - Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" validate:"required"` - Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name" validate:"required"` + Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code"` + Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` Diagnose *string `json:"diagnose"` Nurse_Name string `json:"nurse_name" validate:"required"` ProcedureValue string `json:"procedure_value" validate:"required"` @@ -72,8 +72,8 @@ type ResponseDto struct { Operator_Name string `json:"operator_name"` Assistant_Name string `json:"assistant_name"` Instrumentor_Name string `json:"instrumentor_name"` - Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code"` - Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code"` + Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` Diagnose *string `json:"diagnose"` Nurse_Name string `json:"nurse_name"` ProcedureValue *string `json:"procedure_value"` diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index f25bf604..82d178f2 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -20,9 +20,9 @@ type ProcedureReport struct { Instrumentor_Name string `json:"instrumentor_name"` Diagnose *string `json:"diagnose" gorm:"size:1024"` Nurse_Name string `json:"nurse_code" gorm:"size:10"` - Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" gorm:"size:10"` + Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code" gorm:"size:10"` Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` - Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` ProcedureValue string `json:"procedure_value"` ExecutionValue string `json:"execution_value"` Type string `json:"type"` From 019a413e9b56b77703e160283103335b775ea95a Mon Sep 17 00:00:00 2001 From: ari Date: Sat, 6 Dec 2025 08:36:05 +0700 Subject: [PATCH 6/8] update --- internal/domain/main-entities/procedure-report/entity.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index 82d178f2..81a888b6 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -3,7 +3,6 @@ package procedurereport 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" "time" ) @@ -19,9 +18,9 @@ type ProcedureReport struct { Assistant_Name string `json:"assistant_name"` Instrumentor_Name string `json:"instrumentor_name"` Diagnose *string `json:"diagnose" gorm:"size:1024"` - Nurse_Name string `json:"nurse_code" gorm:"size:10"` + Nurse_Name string `json:"nurse_name" gorm:"size:10"` Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code" gorm:"size:10"` - Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` + Anesthesia_Doctor *ed.Doctor `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` ProcedureValue string `json:"procedure_value"` ExecutionValue string `json:"execution_value"` From 17403278149789644c6c86b79bda7a33c63d0b3e Mon Sep 17 00:00:00 2001 From: ari Date: Sat, 6 Dec 2025 09:54:05 +0700 Subject: [PATCH 7/8] 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 From 6811ef062390f2e1f11550b7251744ec98d5d4e1 Mon Sep 17 00:00:00 2001 From: ari Date: Tue, 9 Dec 2025 10:13:50 +0700 Subject: [PATCH 8/8] update --- cmd/main-migration/migrations/20251209030538.sql | 2 ++ internal/domain/main-entities/procedure-report/entity.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 cmd/main-migration/migrations/20251209030538.sql diff --git a/cmd/main-migration/migrations/20251209030538.sql b/cmd/main-migration/migrations/20251209030538.sql new file mode 100644 index 00000000..4f0ad77f --- /dev/null +++ b/cmd/main-migration/migrations/20251209030538.sql @@ -0,0 +1,2 @@ +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" ALTER COLUMN "Nurse_Name" TYPE text; diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index 4a8a7032..cf084bd4 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -18,7 +18,7 @@ type ProcedureReport struct { Assistant_Name string `json:"assistant_name"` Instrumentor_Name string `json:"instrumentor_name"` Diagnose *string `json:"diagnose" gorm:"size:1024"` - Nurse_Name string `json:"nurse_name" gorm:"size:10"` + Nurse_Name string `json:"nurse_name"` Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code" gorm:"size:10"` Anesthesia_Doctor *ed.Doctor `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"`