From 9b8110f8fa95375254d49c83af1bf42cef9e96d0 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Wed, 3 Dec 2025 06:06:56 +0700 Subject: [PATCH] feat/order-things: entities adjustment --- .../material-package-item/dto.go | 3 + .../material-package-item/entity.go | 1 + .../procedure-room-order-item/dto.go | 68 +++++++++++++++++++ .../procedure-room-order-item/entity.go | 14 ++++ .../main-entities/procedure-room-order/dto.go | 38 ++++++----- .../procedure-room-order/entity.go | 2 +- 6 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 internal/domain/main-entities/procedure-room-order-item/dto.go create mode 100644 internal/domain/main-entities/procedure-room-order-item/entity.go diff --git a/internal/domain/main-entities/material-package-item/dto.go b/internal/domain/main-entities/material-package-item/dto.go index fd282873..e642a015 100644 --- a/internal/domain/main-entities/material-package-item/dto.go +++ b/internal/domain/main-entities/material-package-item/dto.go @@ -9,6 +9,7 @@ import ( type CreateDto struct { MaterialPackage_Code string `json:"materialPackage_code" validate:"maxLength=20"` Material_Code string `json:"material_code" validate:"maxLength=20"` + Count uint16 `json:"count" validate:"required"` } type ReadListDto struct { @@ -48,6 +49,7 @@ type ResponseDto struct { MaterialPackage *emp.MaterialPackage `json:"materialPackage,omitempty"` Material_Code string `json:"material_code"` Material *em.Material `json:"material,omitempty"` + Count uint16 `json:"count"` } func (d MaterialPackageItem) ToResponse() ResponseDto { @@ -56,6 +58,7 @@ func (d MaterialPackageItem) ToResponse() ResponseDto { MaterialPackage: d.MaterialPackage, Material_Code: d.Material_Code, Material: d.Material, + Count: d.Count, } resp.Id = d.Id return resp diff --git a/internal/domain/main-entities/material-package-item/entity.go b/internal/domain/main-entities/material-package-item/entity.go index 76378dc8..52960935 100644 --- a/internal/domain/main-entities/material-package-item/entity.go +++ b/internal/domain/main-entities/material-package-item/entity.go @@ -12,4 +12,5 @@ type MaterialPackageItem struct { MaterialPackage *emp.MaterialPackage `json:"materialPackage" gorm:"foreignKey:MaterialPackage_Code;references:Code"` Material_Code string `json:"code" gorm:"size:20;not null"` Material *em.Material `json:"material" gorm:"foreignKey:Material_Code;references:Code"` + Count uint16 `json:"count" gorm:"not null"` } diff --git a/internal/domain/main-entities/procedure-room-order-item/dto.go b/internal/domain/main-entities/procedure-room-order-item/dto.go new file mode 100644 index 00000000..4e01fea9 --- /dev/null +++ b/internal/domain/main-entities/procedure-room-order-item/dto.go @@ -0,0 +1,68 @@ +package procedureroomorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + epr "simrs-vx/internal/domain/main-entities/procedure-room" +) + +type CreateDto struct { + Encounter_Id uint64 `json:"encounter_id" validate:"required"` + Infra_Code string `json:"infra_code" validate:"required"` + MaterialPackage_Code string `json:"materialPackage_code" validate:"required"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id uint64 `json:"encounter-id"` +} + +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 + ProcedureRoomOrder_Id uint64 `json:"procedureRoomOrder_id"` + ProcedureRoom_Code string `json:"procedureRoom_code"` + ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty"` + Note string `json:"note"` +} + +func (d ProcedureRoomOrderItem) ToResponse() ResponseDto { + resp := ResponseDto{ + ProcedureRoomOrder_Id: d.ProcedureRoomOrder_Id, + ProcedureRoom_Code: d.ProcedureRoom_Code, + ProcedureRoom: d.ProcedureRoom, + Note: d.Note, + } + resp.Id = d.Id + return resp +} + +func ToResponseList(data []ProcedureRoomOrderItem) []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-room-order-item/entity.go b/internal/domain/main-entities/procedure-room-order-item/entity.go new file mode 100644 index 00000000..4a737048 --- /dev/null +++ b/internal/domain/main-entities/procedure-room-order-item/entity.go @@ -0,0 +1,14 @@ +package procedureroomorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + epr "simrs-vx/internal/domain/main-entities/procedure-room" +) + +type ProcedureRoomOrderItem struct { + ecore.BigMain + ProcedureRoomOrder_Id uint64 `json:"procedureRoomOrder_id"` + ProcedureRoom_Code string `json:"procedureRoom_code" gorm:"size:20"` + ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty" gorm:"foreignKey:ProcedureRoom_Code;references:Code"` + Note string `json:"note" gorm:"size:255"` +} diff --git a/internal/domain/main-entities/procedure-room-order/dto.go b/internal/domain/main-entities/procedure-room-order/dto.go index d202f031..5810e756 100644 --- a/internal/domain/main-entities/procedure-room-order/dto.go +++ b/internal/domain/main-entities/procedure-room-order/dto.go @@ -3,13 +3,15 @@ package procedureroomorder import ( ecore "simrs-vx/internal/domain/base-entities/core" ec "simrs-vx/internal/domain/main-entities/encounter" + emp "simrs-vx/internal/domain/main-entities/material-package" epr "simrs-vx/internal/domain/main-entities/procedure-room" + erc "simrs-vx/internal/domain/references/common" ) type CreateDto struct { - Encounter_Id uint64 `json:"encounter_id"` - Infra_Code string `json:"procedure"` - ProcedureRoom string `json:"procedureRoom"` + Encounter_Id uint64 `json:"encounter_id" validate:"required"` + Infra_Code string `json:"infra_code" validate:"required"` + MaterialPackage_Code string `json:"materialPackage_code" validate:"required"` } type ReadListDto struct { @@ -19,22 +21,20 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id uint64 `json:"encounter-id"` - Infra_Code string `json:"procedure-code"` - ProcedureRoom string `json:"procedure-room"` + Encounter_Id uint64 `json:"encounter-id"` } type ReadDetailDto struct { - Id uint `json:"id"` + Id uint64 `json:"id"` } type UpdateDto struct { - Id uint `json:"id"` + Id uint64 `json:"id"` CreateDto } type DeleteDto struct { - Id uint `json:"id"` + Id uint64 `json:"id"` } type MetaDto struct { @@ -44,18 +44,22 @@ type MetaDto struct { } type ResponseDto struct { - ecore.Main - Encounter_Id uint64 `json:"encounter_id"` - Encounter *ec.Encounter `json:"encounter,omitempty"` - Infra_Code string `json:"procedure"` - ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty"` + ecore.BigMain + Encounter_Id uint64 `json:"encounter_id"` + Encounter *ec.Encounter `json:"encounter,omitempty"` + Infra_Code string `json:"procedure"` + MaterialPackage_Code string `json:"materialPackage_code"` + Status_Code erc.DataStatusCode `json:"status_code"` + ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty"` + MaterialPackage *emp.MaterialPackage `json:"materialPackage,omitempty"` } func (d ProcedureRoomOrder) ToResponse() ResponseDto { resp := ResponseDto{ - Encounter_Id: d.Encounter_Id, - Infra_Code: d.Infra_Code, - // ProcedureRoom: d.ProcedureRoom, + Encounter_Id: d.Encounter_Id, + Infra_Code: d.Infra_Code, + MaterialPackage_Code: d.MaterialPackage_Code, + Status_Code: d.Status_Code, } resp.Id = d.Id return resp diff --git a/internal/domain/main-entities/procedure-room-order/entity.go b/internal/domain/main-entities/procedure-room-order/entity.go index 7cb79120..1ef7c178 100644 --- a/internal/domain/main-entities/procedure-room-order/entity.go +++ b/internal/domain/main-entities/procedure-room-order/entity.go @@ -9,7 +9,7 @@ import ( ) type ProcedureRoomOrder struct { - ecore.Main + ecore.BigMain Encounter_Id uint64 `json:"encounter_id"` Infra_Code string `json:"infra_code" gorm:"size:20"` ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty" gorm:"foreignKey:Infra_Code;references:Code"`