From b9e0d2beb052fd79064055ea48729f965b49c206 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Sun, 7 Dec 2025 18:35:29 +0700 Subject: [PATCH] feat/order-things: seperate mcu-order by scope --- .../main-entities/ap-mcu-order/base/dto.go | 23 +++++ .../main-entities/ap-mcu-order/base/entity.go | 23 +++++ .../domain/main-entities/ap-mcu-order/dto.go | 57 +++++++------ .../main-entities/ap-mcu-order/entity.go | 22 ++--- .../main-entities/cp-mcu-order/base/entity.go | 19 +++++ .../domain/main-entities/cp-mcu-order/dto.go | 80 ++++++++++++++++++ .../main-entities/cp-mcu-order/entity.go | 13 +++ .../micro-mcu-order/base/entity.go | 16 ++++ .../main-entities/micro-mcu-order/dto.go | 82 ++++++++++++++++++ .../main-entities/micro-mcu-order/entity.go | 13 +++ .../radiology-mcu-order/base/entity.go | 15 ++++ .../main-entities/radiology-mcu-order/dto.go | 84 +++++++++++++++++++ .../radiology-mcu-order/entity.go | 15 ++++ .../main-use-case/ap-mcu-order/helper.go | 3 - 14 files changed, 417 insertions(+), 48 deletions(-) create mode 100644 internal/domain/main-entities/ap-mcu-order/base/dto.go create mode 100644 internal/domain/main-entities/ap-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/cp-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/cp-mcu-order/dto.go create mode 100644 internal/domain/main-entities/cp-mcu-order/entity.go create mode 100644 internal/domain/main-entities/micro-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/micro-mcu-order/dto.go create mode 100644 internal/domain/main-entities/micro-mcu-order/entity.go create mode 100644 internal/domain/main-entities/radiology-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/radiology-mcu-order/dto.go create mode 100644 internal/domain/main-entities/radiology-mcu-order/entity.go diff --git a/internal/domain/main-entities/ap-mcu-order/base/dto.go b/internal/domain/main-entities/ap-mcu-order/base/dto.go new file mode 100644 index 00000000..447bc771 --- /dev/null +++ b/internal/domain/main-entities/ap-mcu-order/base/dto.go @@ -0,0 +1,23 @@ +package apmcuorder + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"-"` + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes string `json:"clinicalNotes"` + CurrentHistory string `json:"currentHistory"` + PastHistory string `json:"pastHistory"` + PrevApMcu string `json:"prevApMcu"` + PrevApMcuNotes string `json:"prevApMcuNotes"` + SupportingExams string `json:"supportingExams"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} diff --git a/internal/domain/main-entities/ap-mcu-order/base/entity.go b/internal/domain/main-entities/ap-mcu-order/base/entity.go new file mode 100644 index 00000000..5aa99c20 --- /dev/null +++ b/internal/domain/main-entities/ap-mcu-order/base/entity.go @@ -0,0 +1,23 @@ +package apmcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type ApMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes *string `json:"clinicalNotes"` + CurrentHistory string `json:"currentHistory"` + PastHistory string `json:"pastHistory"` + PrevApMcu *string `json:"prevApMcu"` + PrevApMcuNotes *string `json:"prevApMcuNotes"` + SupportingExams *string `json:"supportingExams"` +} diff --git a/internal/domain/main-entities/ap-mcu-order/dto.go b/internal/domain/main-entities/ap-mcu-order/dto.go index 7fcaa1d3..954efad2 100644 --- a/internal/domain/main-entities/ap-mcu-order/dto.go +++ b/internal/domain/main-entities/ap-mcu-order/dto.go @@ -2,22 +2,13 @@ package apmcuorder import ( ecore "simrs-vx/internal/domain/base-entities/core" - emo "simrs-vx/internal/domain/main-entities/mcu-order" + eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" ) type CreateDto struct { - McuOrder_Id string `json:"mcuOrder_id"` - Substances string `json:"substances"` - Fictations string `json:"fictations"` - Localization string `json:"localization"` - ClinicalDiagnoses string `json:"clinicalDiagnoses"` - Stadium string `json:"stadium"` - ClinicalNotes string `json:"clinicalNotes"` - PastHistory string `json:"pastHistory"` - CurrentHistory string `json:"currentHistory"` - PrevApMcu string `json:"prevApMcu"` - PrevApMcuNotes string `json:"prevApMcuNotes"` - SupportingExams string `json:"supportingExams"` + eamob.CreateDto } type ReadListDto struct { @@ -51,25 +42,32 @@ type MetaDto struct { } type ResponseDto struct { - ecore.Main - McuOrder_Id string `json:"mcuOrder_id"` - McuOrder *emo.McuOrder - Substances string `json:"substances"` - Fictations string `json:"fictations"` - Localization string `json:"localization"` - ClinicalDiagnoses string `json:"clinicalDiagnoses"` - Stadium string `json:"stadium"` - ClinicalNotes string `json:"clinicalNotes"` - PastHistory string `json:"pastHistory"` - CurrentHistory string `json:"currentHistory"` - PrevApMcu string `json:"prevApMcu"` - PrevApMcuNotes string `json:"prevApMcuNotes"` - SupportingExams string `json:"supportingExams"` + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes *string `json:"clinicalNotes"` + PastHistory string `json:"pastHistory"` + CurrentHistory string `json:"currentHistory"` + PrevApMcu *string `json:"prevApMcu"` + PrevApMcuNotes *string `json:"prevApMcuNotes"` + SupportingExams *string `json:"supportingExams"` } func (d ApMcuOrder) ToResponse() ResponseDto { resp := ResponseDto{ - McuOrder_Id: d.McuOrder_Id, + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, Substances: d.Substances, Fictations: d.Fictations, Localization: d.Localization, @@ -80,8 +78,9 @@ func (d ApMcuOrder) ToResponse() ResponseDto { CurrentHistory: d.CurrentHistory, PrevApMcu: d.PrevApMcu, PrevApMcuNotes: d.PrevApMcuNotes, + SupportingExams: d.SupportingExams, } - resp.McuOrder = d.McuOrder + resp.BigMain = d.BigMain return resp } diff --git a/internal/domain/main-entities/ap-mcu-order/entity.go b/internal/domain/main-entities/ap-mcu-order/entity.go index f57e7497..703e9ebb 100644 --- a/internal/domain/main-entities/ap-mcu-order/entity.go +++ b/internal/domain/main-entities/ap-mcu-order/entity.go @@ -1,23 +1,13 @@ package apmcuorder import ( - ecore "simrs-vx/internal/domain/base-entities/core" - emo "simrs-vx/internal/domain/main-entities/mcu-order" + eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" ) type ApMcuOrder struct { - ecore.BigMain - McuOrder_Id string `json:"mcuOrder_id" gorm:"unique;size:10"` - McuOrder *emo.McuOrder `json:"mcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` - Substances string `json:"substances"` - Fictations string `json:"fictations"` - Localization string `json:"localization"` - ClinicalDiagnoses string `json:"clinicalDiagnoses"` - Stadium string `json:"stadium"` - ClinicalNotes string `json:"clinicalNotes"` - PastHistory string `json:"pastHistory"` - CurrentHistory string `json:"currentHistory"` - PrevApMcu string `json:"prevApMcu"` - PrevApMcuNotes string `json:"prevApMcuNotes"` - SupportingExams string `json:"supportingExams"` + eamob.ApMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` } diff --git a/internal/domain/main-entities/cp-mcu-order/base/entity.go b/internal/domain/main-entities/cp-mcu-order/base/entity.go new file mode 100644 index 00000000..883ba0b6 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order/base/entity.go @@ -0,0 +1,19 @@ +package cpmcuorder + +import ( + "time" + + ecore "simrs-vx/internal/domain/base-entities/core" + ercl "simrs-vx/internal/domain/references/clinical" +) + +type CpMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgencyLevel_code" gorm:"not null;size:15"` + OtherNotes *string `json:"otherNotes"` + ExamScheduleDate *time.Time `json:"examinationDate"` + Resume *string `json:"resume"` +} diff --git a/internal/domain/main-entities/cp-mcu-order/dto.go b/internal/domain/main-entities/cp-mcu-order/dto.go new file mode 100644 index 00000000..5cc2e753 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order/dto.go @@ -0,0 +1,80 @@ +package cpmcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" +) + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id" validate:"required"` + Number uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC + UrgencyLevel_Code string `json:"urgencyLevel_code" validate:"required"` + OtherNotes string `json:"otherNotes"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id uint `json:"encounter-id"` + Doctor_Code string `json:"doctor-code"` +} + +type ReadDetailDto struct { + Id uint64 `json:"id"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint64 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + Encounter_Id uint + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + UrgencyLevel_Code string `json:"urgencyLevel_code" gorm:"not null;size:15"` + OtherNotes *string `json:"otherNotes"` + Resume *string `json:"resume"` +} + +func (d CpMcuOrder) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + UrgencyLevel_Code: string(d.UrgencyLevel_Code), + OtherNotes: d.OtherNotes, + Resume: d.Resume, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []CpMcuOrder) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/cp-mcu-order/entity.go b/internal/domain/main-entities/cp-mcu-order/entity.go new file mode 100644 index 00000000..92e20ef5 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order/entity.go @@ -0,0 +1,13 @@ +package cpmcuorder + +import ( + eamob "simrs-vx/internal/domain/main-entities/cp-mcu-order/base" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" +) + +type CpMcuOrder struct { + eamob.CpMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` +} diff --git a/internal/domain/main-entities/micro-mcu-order/base/entity.go b/internal/domain/main-entities/micro-mcu-order/base/entity.go new file mode 100644 index 00000000..2250ca20 --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order/base/entity.go @@ -0,0 +1,16 @@ +package micromcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ercl "simrs-vx/internal/domain/references/clinical" +) + +type MicroMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + Stage_Code ercl.McuOrderStageCode `json:"stage_code" gorm:"not null;size:10"` + AxillaryTemp float64 `json:"axillaryTemp"` + OtherNotes *string `json:"otherNotes"` +} diff --git a/internal/domain/main-entities/micro-mcu-order/dto.go b/internal/domain/main-entities/micro-mcu-order/dto.go new file mode 100644 index 00000000..82f926db --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order/dto.go @@ -0,0 +1,82 @@ +package micromcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" + ercl "simrs-vx/internal/domain/references/clinical" +) + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id" validate:"required"` + Number uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC + OrderStage_Code string `json:"orderStage_code" gorm:"not null;size:10"` + AxillaryTemp float64 `json:"axillaryTemp"` + OtherNotes string `json:"otherNotes"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id uint `json:"encounter-id"` + Doctor_Code string `json:"doctor-code"` +} + +type ReadDetailDto struct { + Id uint64 `json:"id"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint64 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + Encounter_Id uint + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + Stage_Code ercl.McuOrderStageCode `json:"stage_code" gorm:"not null;size:10"` + AxillaryTemp float64 `json:"axillaryTemp"` + OtherNotes *string `json:"otherNotes"` +} + +func (d MicroMcuOrder) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + Stage_Code: d.Stage_Code, + AxillaryTemp: d.AxillaryTemp, + OtherNotes: d.OtherNotes, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []MicroMcuOrder) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/micro-mcu-order/entity.go b/internal/domain/main-entities/micro-mcu-order/entity.go new file mode 100644 index 00000000..1c645040 --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order/entity.go @@ -0,0 +1,13 @@ +package micromcuorder + +import ( + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" + eamob "simrs-vx/internal/domain/main-entities/micro-mcu-order/base" +) + +type MicroMcuOrder struct { + eamob.MicroMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` +} diff --git a/internal/domain/main-entities/radiology-mcu-order/base/entity.go b/internal/domain/main-entities/radiology-mcu-order/base/entity.go new file mode 100644 index 00000000..a771e0a7 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order/base/entity.go @@ -0,0 +1,15 @@ +package radiologymcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type RadiologyMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + ClinicalNotes *string `json:"clinicalNotes"` + OtherNotes *string `json:"otherNotes"` + Resume *string `json:"resume"` +} diff --git a/internal/domain/main-entities/radiology-mcu-order/dto.go b/internal/domain/main-entities/radiology-mcu-order/dto.go new file mode 100644 index 00000000..f24b5668 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order/dto.go @@ -0,0 +1,84 @@ +package radiologymcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" + ermoi "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base" +) + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id"` + Number *uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC + Doctor_Code string `json:"-" validate:"required"` + ClinicalNotes string `json:"clinicalNotes"` + OtherNotes string `json:"otherNotes"` + Items []ermoi.SubCreateDto `json:"items" validate:"required"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id uint `json:"encounter-id"` + Doctor_Code string `json:"doctor-code"` +} + +type ReadDetailDto struct { + Id uint64 `json:"id"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint64 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + ClinicalNotes *string `json:"clinicalNotes"` + OtherNotes *string `json:"otherNotes"` + Resume *string `json:"resume"` + Items []*ermoi.RadiologyMcuOrderItem +} + +func (d RadiologyMcuOrder) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + ClinicalNotes: d.ClinicalNotes, + OtherNotes: d.OtherNotes, + Resume: d.Resume, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []RadiologyMcuOrder) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/radiology-mcu-order/entity.go b/internal/domain/main-entities/radiology-mcu-order/entity.go new file mode 100644 index 00000000..2ff3ec20 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order/entity.go @@ -0,0 +1,15 @@ +package radiologymcuorder + +import ( + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" + ermoi "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base" + eamob "simrs-vx/internal/domain/main-entities/radiology-mcu-order/base" +) + +type RadiologyMcuOrder struct { + eamob.RadiologyMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + Items []*ermoi.RadiologyMcuOrderItem `json:"items" gorm:"foreignKey:RadiologyMcuOrder_Id;references:Id"` +} diff --git a/internal/use-case/main-use-case/ap-mcu-order/helper.go b/internal/use-case/main-use-case/ap-mcu-order/helper.go index 717e6ce6..4b91b7aa 100644 --- a/internal/use-case/main-use-case/ap-mcu-order/helper.go +++ b/internal/use-case/main-use-case/ap-mcu-order/helper.go @@ -17,14 +17,11 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ApMcuOrder) { inputSrc = &inputTemp.CreateDto } - data.McuOrder_Id = inputSrc.McuOrder_Id data.Substances = inputSrc.Substances data.Fictations = inputSrc.Fictations data.Localization = inputSrc.Localization data.ClinicalDiagnoses = inputSrc.ClinicalDiagnoses data.Stadium = inputSrc.Stadium - data.ClinicalNotes = inputSrc.ClinicalNotes data.PastHistory = inputSrc.PastHistory data.CurrentHistory = inputSrc.CurrentHistory - data.PrevApMcu = inputSrc.PrevApMcu }