diff --git a/cmd/main-migration/migrations/20250917040616.sql b/cmd/main-migration/migrations/20250917040616.sql new file mode 100644 index 00000000..71fc13e7 --- /dev/null +++ b/cmd/main-migration/migrations/20250917040616.sql @@ -0,0 +1,8 @@ +-- Modify "MedicationItem" table +ALTER TABLE "public"."MedicationItem" ADD COLUMN "Quantity" numeric NULL; +-- Modify "MedicineMix" table +ALTER TABLE "public"."MedicineMix" ADD COLUMN "Note" text NULL; +-- Modify "Prescription" table +ALTER TABLE "public"."Prescription" ADD COLUMN "Status_Code" text NULL; +-- Modify "PrescriptionItem" table +ALTER TABLE "public"."PrescriptionItem" ADD COLUMN "Quantity" numeric NULL; diff --git a/cmd/main-migration/migrations/20250917040751.sql b/cmd/main-migration/migrations/20250917040751.sql new file mode 100644 index 00000000..0b8f243b --- /dev/null +++ b/cmd/main-migration/migrations/20250917040751.sql @@ -0,0 +1,2 @@ +-- Modify "MedicationItem" table +ALTER TABLE "public"."MedicationItem" ADD COLUMN "Note" character varying(1024) NULL; diff --git a/cmd/main-migration/migrations/20250917045138.sql b/cmd/main-migration/migrations/20250917045138.sql new file mode 100644 index 00000000..b40ade76 --- /dev/null +++ b/cmd/main-migration/migrations/20250917045138.sql @@ -0,0 +1,2 @@ +-- Modify "MedicineMixItem" table +ALTER TABLE "public"."MedicineMixItem" DROP CONSTRAINT "fk_MedicineMixItem_MedicineMix", ADD CONSTRAINT "fk_MedicineMix_MixItems" FOREIGN KEY ("MedicineMix_Id") REFERENCES "public"."MedicineMix" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20250917093645.sql b/cmd/main-migration/migrations/20250917093645.sql new file mode 100644 index 00000000..b0922c6a --- /dev/null +++ b/cmd/main-migration/migrations/20250917093645.sql @@ -0,0 +1,4 @@ +-- Modify "MedicineMix" table +ALTER TABLE "public"."MedicineMix" DROP COLUMN "Note"; +-- Modify "MedicineMixItem" table +ALTER TABLE "public"."MedicineMixItem" ADD COLUMN "Note" text NULL; diff --git a/cmd/main-migration/migrations/20250918073552.sql b/cmd/main-migration/migrations/20250918073552.sql new file mode 100644 index 00000000..1b45e5d4 --- /dev/null +++ b/cmd/main-migration/migrations/20250918073552.sql @@ -0,0 +1,10 @@ +-- Modify "McuOrder" table +ALTER TABLE "public"."McuOrder" ADD COLUMN "SpecimenPickTime" timestamptz NULL, ADD COLUMN "ExaminationDate" timestamptz NULL, ADD COLUMN "Number" smallint NULL, ADD COLUMN "Temperature" numeric NULL, ADD COLUMN "McuUrgencyLevel_Code" character varying(10) NOT NULL; +-- Modify "McuOrderItem" table +ALTER TABLE "public"."McuOrderItem" ADD COLUMN "ExaminationDate" timestamptz NULL; +-- Create index "idx_order_src" to table: "McuOrderItem" +CREATE UNIQUE INDEX "idx_order_src" ON "public"."McuOrderItem" ("McuOrder_Id", "McuSrc_Id"); +-- Modify "PersonRelative" table +ALTER TABLE "public"."PersonRelative" ADD COLUMN "Responsible" boolean NULL; +-- Modify "McuSrc" table +ALTER TABLE "public"."McuSrc" ALTER COLUMN "Id" TYPE bigint, ADD COLUMN "Item_Id" bigint NULL, ADD CONSTRAINT "fk_McuSrc_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20250918073742.sql b/cmd/main-migration/migrations/20250918073742.sql new file mode 100644 index 00000000..28611d73 --- /dev/null +++ b/cmd/main-migration/migrations/20250918073742.sql @@ -0,0 +1,31 @@ +-- Create "McuSubSrc" table +CREATE TABLE "public"."McuSubSrc" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Code" character varying(20) NULL, + "Name" character varying(50) NULL, + "McuSrc_Id" bigint NULL, + "Item_Id" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_McuSubSrc_Code" UNIQUE ("Code"), + CONSTRAINT "fk_McuSubSrc_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_McuSubSrc_McuSrc" FOREIGN KEY ("McuSrc_Id") REFERENCES "public"."McuSrc" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "McuOrderSubItem" table +CREATE TABLE "public"."McuOrderSubItem" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "McuSubSrc_Id" bigint NULL, + "McuOrderItem_Id" bigint NULL, + "Result" text NULL, + "Status_Code" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_McuOrderSubItem_McuOrderItem" FOREIGN KEY ("McuOrderItem_Id") REFERENCES "public"."McuOrderItem" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_McuOrderSubItem_McuSubSrc" FOREIGN KEY ("McuSubSrc_Id") REFERENCES "public"."McuSubSrc" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create index "idx_order_sub_src" to table: "McuOrderSubItem" +CREATE UNIQUE INDEX "idx_order_sub_src" ON "public"."McuOrderSubItem" ("McuSubSrc_Id", "McuOrderItem_Id"); diff --git a/cmd/main-migration/migrations/20250918074745.sql b/cmd/main-migration/migrations/20250918074745.sql new file mode 100644 index 00000000..365227cb --- /dev/null +++ b/cmd/main-migration/migrations/20250918074745.sql @@ -0,0 +1,2 @@ +-- Modify "McuOrder" table +ALTER TABLE "public"."McuOrder" ALTER COLUMN "McuUrgencyLevel_Code" TYPE character varying(15); diff --git a/cmd/main-migration/migrations/20250923025134.sql b/cmd/main-migration/migrations/20250923025134.sql new file mode 100644 index 00000000..57a04744 --- /dev/null +++ b/cmd/main-migration/migrations/20250923025134.sql @@ -0,0 +1,17 @@ +-- Create "Consultation" table +CREATE TABLE "public"."Consultation" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Case" character varying(2048) NULL, + "Solution" character varying(2048) NULL, + "Unit_Id" bigint NULL, + "Doctor_Id" bigint NULL, + "RepliedAt" timestamptz NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_Consultation_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_Consultation_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_Consultation_Unit" FOREIGN KEY ("Unit_Id") REFERENCES "public"."Unit" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index fcc26fdd..e61e9880 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:lwrJz1Vor7muHsLHihYT704fcsjyX/JmBfRLfg+4PjI= +h1:0Hvo3AS2yMsS60eDIKnU5B2qvjDhNWHSDHcMxKKYJTk= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -7,4 +7,12 @@ h1:lwrJz1Vor7muHsLHihYT704fcsjyX/JmBfRLfg+4PjI= 20250908073839.sql h1:cPk54xjLdMs26uY8ZHjNWLuyfAMzV7Zb0/9oJQrsw04= 20250910055902.sql h1:5xwjAV6QbtZT9empTJKfhyAjdknbHzb15B0Ku5dzqtQ= 20250915123412.sql h1:D83xaU2YlDEd21HLup/YQpQ2easMToYCyy/oK6AFgQs= -20250916043819.sql h1:qcON0PZq3bYL0dWZdDMHEvK9C7oH4JIMh5Il+RWA3UY= +20250916043819.sql h1:ekoTJsBqQZ8G8n0qJ03d13+eoNoc7sAUEQGA5D/CCxk= +20250917040616.sql h1:zoCnmcXuM7AVv85SmN7RmFglCgJnoDmpRWExH0LAc9Q= +20250917040751.sql h1:J1xyRrh32y1+lezwAyNwPcUQ6ABBSgbvzNLva4SVdQU= +20250917045138.sql h1:jKe1Z0uOLG4SGBYM+S/3P+/zMPztmgoderD5swnMuCg= +20250917093645.sql h1:cNI3Pbz1R3LxvIXLuexafJFCXUXrmuFCgXXJ2sG+FW0= +20250918073552.sql h1:RJ1SvMzP6aeWnoPVD3eVAmIQOkcp6Php8z3QRri6v4g= +20250918073742.sql h1:+cEsnJTJFybe2fR69ZoOiX2R6c6iITl4m6WTZ1hjyzY= +20250918074745.sql h1:2hNVQCXF/dVYXAh+T/7oBFgERGWxzVb2FXJjwkFWGCI= +20250923025134.sql h1:q1bndJguAqjnTjXr6Jpnsrj4d8zMseR2tf02h0h6ArE= diff --git a/internal/domain/main-entities/consultation/dto.go b/internal/domain/main-entities/consultation/dto.go new file mode 100644 index 00000000..7cac88dd --- /dev/null +++ b/internal/domain/main-entities/consultation/dto.go @@ -0,0 +1,87 @@ +package consultation + +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" + eu "simrs-vx/internal/domain/main-entities/unit" + "time" +) + +type CreateDto struct { + Encounter_Id *uint `json:"encounter_id"` + Case *string `json:"case" validate:"maxLength=2048"` + Unit_Id *uint `json:"unit_id"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Preloads []string `json:"-"` +} + +type FilterDto struct { + Encounter_Id *uint `json:"encounter_id"` + Unit_Id *uint `json:"unit_id"` + Doctor_Id *uint `json:"doctor_id"` + + Page int `json:"page"` + PageSize int `json:"page_size"` + NoPagination int `json:"no_pagination"` +} + +type ReadDetailDto struct { + Id uint16 `json:"id"` +} + +type UpdateDto struct { + Id uint `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint `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 *uint `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty"` + Case *string `json:"case"` + Solution *string `json:"solution"` + Unit_Id *uint `json:"unit_id"` + Unit *eu.Unit `json:"unit,omitempty"` + Doctor_Id *uint `json:"doctor_id"` + Doctor *ed.Doctor `json:"doctor,omitempty"` + RepliedAt *time.Time `json:"repliedAt"` +} + +func (d Consultation) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Case: d.Case, + Solution: d.Solution, + Unit_Id: d.Unit_Id, + Unit: d.Unit, + Doctor_Id: d.Doctor_Id, + Doctor: d.Doctor, + RepliedAt: d.RepliedAt, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []Consultation) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/consultation/entity.go b/internal/domain/main-entities/consultation/entity.go new file mode 100644 index 00000000..68ad37f2 --- /dev/null +++ b/internal/domain/main-entities/consultation/entity.go @@ -0,0 +1,23 @@ +package consultation + +import ( + "time" + + ecore "simrs-vx/internal/domain/base-entities/core" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" + eu "simrs-vx/internal/domain/main-entities/unit" +) + +type Consultation struct { + ecore.Main // adjust this according to the needs + Encounter_Id *uint `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter" gorm:"foreignKey:Encounter_Id;references:Id"` + Case *string `json:"case" gorm:"size:2048"` + Solution *string `json:"solution" gorm:"size:2048"` + Unit_Id *uint `json:"unit_id"` + Unit *eu.Unit `json:"unit" gorm:"foreignKey:Unit_Id;references:Id"` + Doctor_Id *uint `json:"doctor_id"` + Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Id;references:Id"` + RepliedAt *time.Time `json:"repliedAt"` +} diff --git a/internal/domain/main-entities/mcu-order-item/entity.go b/internal/domain/main-entities/mcu-order-item/entity.go index 73b56a95..f1ae0cc8 100644 --- a/internal/domain/main-entities/mcu-order-item/entity.go +++ b/internal/domain/main-entities/mcu-order-item/entity.go @@ -4,16 +4,18 @@ import ( ecore "simrs-vx/internal/domain/base-entities/core" emo "simrs-vx/internal/domain/main-entities/mcu-order" ems "simrs-vx/internal/domain/main-entities/mcu-src" + "time" erc "simrs-vx/internal/domain/references/common" ) type McuOrderItem struct { - ecore.Main // adjust this according to the needs - McuOrder_Id *uint `json:"mcuOrder_id"` - McuOrder *emo.McuOrder `json:"mcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` - McuSrc_Id *uint `json:"mcuSrc_id"` - McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Id;references:Id"` - Result *string `json:"result"` - Status_Code erc.DataStatusCode `json:"status_code"` + ecore.Main // adjust this according to the needs + McuOrder_Id *uint `json:"mcuOrder_id" gorm:"uniqueIndex:idx_order_src"` + McuOrder *emo.McuOrder `json:"mcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` + McuSrc_Id *uint `json:"mcuSrc_id" gorm:"uniqueIndex:idx_order_src"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Id;references:Id"` + ExaminationDate *time.Time `json:"examinationDate"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` } diff --git a/internal/domain/main-entities/mcu-order-sub-item/dto.go b/internal/domain/main-entities/mcu-order-sub-item/dto.go new file mode 100644 index 00000000..d59d2ccf --- /dev/null +++ b/internal/domain/main-entities/mcu-order-sub-item/dto.go @@ -0,0 +1,81 @@ +package mcuordersubitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + emoi "simrs-vx/internal/domain/main-entities/mcu-order-item" + emss "simrs-vx/internal/domain/main-entities/mcu-sub-src" + erc "simrs-vx/internal/domain/references/common" +) + +type CreateDto struct { + McuSubSrc_Id *uint `json:"mcuSubSrc_id"` + McuOrderItem_Id *uint `json:"mcuOrderItem_id"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Preloads []string `json:"-"` +} + +type FilterDto struct { + McuOrder_Id *uint `json:"mcuOrder_id"` + McuSrc_Id *uint `json:"mcuSrc_id"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` + + Page int `json:"page"` + PageSize int `json:"page_size"` + NoPagination int `json:"no_pagination"` +} +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 + McuSubSrc_Id *uint `json:"mcuSubSrc_id"` + McuSubSrc *emss.McuSubSrc `json:"mcuSubSrc,omitempty"` + McuOrderItem_Id *uint `json:"mcuOrderItem_id"` + McuOrderItem *emoi.McuOrderItem `json:"mcuOrderItem,omitempty"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} + +func (d McuOrderSubItem) ToResponse() ResponseDto { + resp := ResponseDto{ + McuSubSrc_Id: d.McuSubSrc_Id, + McuSubSrc: d.McuSubSrc, + McuOrderItem_Id: d.McuOrderItem_Id, + McuOrderItem: d.McuOrderItem, + Result: d.Result, + Status_Code: d.Status_Code, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []McuOrderSubItem) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/mcu-order-sub-item/entity.go b/internal/domain/main-entities/mcu-order-sub-item/entity.go new file mode 100644 index 00000000..c3f77361 --- /dev/null +++ b/internal/domain/main-entities/mcu-order-sub-item/entity.go @@ -0,0 +1,19 @@ +package mcuordersubitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + emoi "simrs-vx/internal/domain/main-entities/mcu-order-item" + emss "simrs-vx/internal/domain/main-entities/mcu-sub-src" + + erc "simrs-vx/internal/domain/references/common" +) + +type McuOrderSubItem struct { + ecore.Main // adjust this according to the needs + McuSubSrc_Id *uint `json:"mcuSubSrc_id" gorm:"uniqueIndex:idx_order_sub_src"` + McuSubSrc *emss.McuSubSrc `json:"mcuSubSrc,omitempty" gorm:"foreignKey:McuSubSrc_Id;references:Id"` + McuOrderItem_Id *uint `json:"mcuOrderItem_id" gorm:"uniqueIndex:idx_order_sub_src"` + McuOrderItem *emoi.McuOrderItem `json:"mcuOrderItem,omitempty" gorm:"foreignKey:McuOrderItem_Id;references:Id"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} diff --git a/internal/domain/main-entities/mcu-order/entity.go b/internal/domain/main-entities/mcu-order/entity.go index 326c761f..134485e5 100644 --- a/internal/domain/main-entities/mcu-order/entity.go +++ b/internal/domain/main-entities/mcu-order/entity.go @@ -4,15 +4,22 @@ 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" + "time" + ercl "simrs-vx/internal/domain/references/clinical" erc "simrs-vx/internal/domain/references/common" ) type McuOrder struct { - ecore.Main // adjust this according to the needs - Encounter_Id *uint `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` - Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"` - Doctor_Id *uint `json:"doctor_id"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + ecore.Main // adjust this according to the needs + Encounter_Id *uint `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"` + Doctor_Id *uint `json:"doctor_id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + SpecimenPickTime *time.Time `json:"specimenPickTime"` + ExaminationDate *time.Time `json:"examinationDate"` + Number uint8 `json:"number"` + Temperature float64 `json:"temperature"` + McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code" gorm:"not null;size:15"` } diff --git a/internal/domain/main-entities/mcu-src/dto.go b/internal/domain/main-entities/mcu-src/dto.go index 26d76102..56ab9f57 100644 --- a/internal/domain/main-entities/mcu-src/dto.go +++ b/internal/domain/main-entities/mcu-src/dto.go @@ -2,6 +2,7 @@ package mcusrc import ( ecore "simrs-vx/internal/domain/base-entities/core" + ei "simrs-vx/internal/domain/main-entities/item" ) type CreateDto struct { @@ -47,10 +48,12 @@ type MetaDto struct { } type ResponseDto struct { - ecore.SmallMain - Code string `json:"code"` - Name string `json:"name"` - CheckupCategory_Code *string `json:"checkupCategory_code"` + ecore.Main + Code string `json:"code"` + Name string `json:"name"` + CheckupCategory_Code *string `json:"checkupCategory_code"` + Item_Id *uint `json:"item_id"` + Item *ei.Item `json:"item,omitempty"` } func (d McuSrc) ToResponse() ResponseDto { @@ -58,8 +61,10 @@ func (d McuSrc) ToResponse() ResponseDto { Code: d.Code, Name: d.Name, CheckupCategory_Code: d.CheckupCategory_Code, + Item_Id: d.Item_Id, + Item: d.Item, } - resp.SmallMain = d.SmallMain + resp.Main = d.Main return resp } diff --git a/internal/domain/main-entities/mcu-src/entity.go b/internal/domain/main-entities/mcu-src/entity.go index cdd8356f..fbdb3f54 100644 --- a/internal/domain/main-entities/mcu-src/entity.go +++ b/internal/domain/main-entities/mcu-src/entity.go @@ -2,13 +2,16 @@ package mcusrc import ( ecore "simrs-vx/internal/domain/base-entities/core" + ei "simrs-vx/internal/domain/main-entities/item" emsc "simrs-vx/internal/domain/main-entities/mcu-src-category" ) type McuSrc struct { - ecore.SmallMain // adjust this according to the needs + ecore.Main // adjust this according to the needs Code string `json:"code" gorm:"unique;size:20"` Name string `json:"name" gorm:"size:50"` CheckupCategory_Code *string `json:"checkupCategory_code" gorm:"size:20"` CheckupCategory *emsc.McuSrcCategory `json:"checkupCategory,omitempty" gorm:"foreignKey:CheckupCategory_Code;references:Code"` + Item_Id *uint `json:"item_id"` + Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"` } diff --git a/internal/domain/main-entities/mcu-sub-src/dto.go b/internal/domain/main-entities/mcu-sub-src/dto.go new file mode 100644 index 00000000..eec34ead --- /dev/null +++ b/internal/domain/main-entities/mcu-sub-src/dto.go @@ -0,0 +1,80 @@ +package mcusubsrc + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ei "simrs-vx/internal/domain/main-entities/item" + ems "simrs-vx/internal/domain/main-entities/mcu-src" +) + +type CreateDto struct { + Code string `json:"code" validate:"maxLength=20"` + Name string `json:"name" validate:"maxLength=50"` + McuSrc_Id *uint `json:"mcuSrc_id"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Preloads []string `json:"-"` +} + +type FilterDto struct { + Code string `json:"code"` + Name string `json:"name"` + CheckupCategory_Code *string `json:"checkupCategory_code"` + + Page int `json:"page"` + PageSize int `json:"page_size"` + NoPagination int `json:"no_pagination"` +} + +type ReadDetailDto struct { + Id uint16 `json:"id"` + Code *string `json:"code"` +} + +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 + Code string `json:"code"` + Name string `json:"name"` + McuSrc_Id *uint `json:"mcuSrc_id"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"` + Item_Id *uint `json:"item_id"` + Item *ei.Item `json:"item,omitempty"` +} + +func (d McuSubSrc) ToResponse() ResponseDto { + resp := ResponseDto{ + Code: d.Code, + Name: d.Name, + McuSrc_Id: d.McuSrc_Id, + McuSrc: d.McuSrc, + Item_Id: d.Item_Id, + Item: d.Item, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []McuSubSrc) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/mcu-sub-src/entity.go b/internal/domain/main-entities/mcu-sub-src/entity.go new file mode 100644 index 00000000..02559abb --- /dev/null +++ b/internal/domain/main-entities/mcu-sub-src/entity.go @@ -0,0 +1,17 @@ +package mcusubsrc + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ei "simrs-vx/internal/domain/main-entities/item" + ems "simrs-vx/internal/domain/main-entities/mcu-src" +) + +type McuSubSrc struct { + ecore.Main // adjust this according to the needs + Code string `json:"code" gorm:"unique;size:20"` + Name string `json:"name" gorm:"size:50"` + McuSrc_Id *uint `json:"mcuSrc_id"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Id;references:Id"` + Item_Id *uint `json:"item_id"` + Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"` +} diff --git a/internal/domain/main-entities/medication-item/entity.go b/internal/domain/main-entities/medication-item/entity.go index 671e96b3..e778cb50 100644 --- a/internal/domain/main-entities/medication-item/entity.go +++ b/internal/domain/main-entities/medication-item/entity.go @@ -22,4 +22,6 @@ type MedicationItem struct { Interval uint8 `json:"interval"` IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` IsRedeemed bool `json:"isRedeemed"` + Quantity float64 `json:"quantity"` + Note *string `json:"note" gorm:"size:1024"` } diff --git a/internal/domain/main-entities/medicine-mix-item/dto.go b/internal/domain/main-entities/medicine-mix-item/dto.go index dbcbce21..1be930e1 100644 --- a/internal/domain/main-entities/medicine-mix-item/dto.go +++ b/internal/domain/main-entities/medicine-mix-item/dto.go @@ -3,7 +3,6 @@ package medicinemixitem import ( ecore "simrs-vx/internal/domain/base-entities/core" em "simrs-vx/internal/domain/main-entities/medicine" - emm "simrs-vx/internal/domain/main-entities/medicine-mix" ) type CreateDto struct { @@ -49,17 +48,15 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - MedicineMix_Id *uint `json:"medicineMix_id"` - MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty"` - Medicine_Id *uint `json:"medicine_id"` - Medicine *em.Medicine `json:"medicine,omitempty"` - Dose *uint8 `json:"dose"` + MedicineMix_Id *uint `json:"medicineMix_id"` + Medicine_Id *uint `json:"medicine_id"` + Medicine *em.Medicine `json:"medicine,omitempty"` + Dose *uint8 `json:"dose"` } func (d MedicineMixItem) ToResponse() ResponseDto { resp := ResponseDto{ MedicineMix_Id: d.MedicineMix_Id, - MedicineMix: d.MedicineMix, Medicine_Id: d.Medicine_Id, Medicine: d.Medicine, Dose: d.Dose, diff --git a/internal/domain/main-entities/medicine-mix-item/entity.go b/internal/domain/main-entities/medicine-mix-item/entity.go index 7c456fcb..a642fce0 100644 --- a/internal/domain/main-entities/medicine-mix-item/entity.go +++ b/internal/domain/main-entities/medicine-mix-item/entity.go @@ -3,14 +3,13 @@ package medicinemixitem import ( ecore "simrs-vx/internal/domain/base-entities/core" em "simrs-vx/internal/domain/main-entities/medicine" - emm "simrs-vx/internal/domain/main-entities/medicine-mix" ) type MedicineMixItem struct { - ecore.Main // adjust this according to the needs - MedicineMix_Id *uint `json:"medicineMix_id"` - MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty" gorm:"foreignKey:MedicineMix_Id;references:Id"` - Medicine_Id *uint `json:"medicine_id"` - Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Id;references:Id"` - Dose *uint8 `json:"dose"` + ecore.Main // adjust this according to the needs + MedicineMix_Id *uint `json:"medicineMix_id"` + Medicine_Id *uint `json:"medicine_id"` + Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Id;references:Id"` + Dose *uint8 `json:"dose"` + Note *string `json:"note" gom:"size:1024"` } diff --git a/internal/domain/main-entities/medicine-mix/dto.go b/internal/domain/main-entities/medicine-mix/dto.go index b9fc656e..05b67a06 100644 --- a/internal/domain/main-entities/medicine-mix/dto.go +++ b/internal/domain/main-entities/medicine-mix/dto.go @@ -2,6 +2,8 @@ package medicinemix import ( ecore "simrs-vx/internal/domain/base-entities/core" + + emmi "simrs-vx/internal/domain/main-entities/medicine-mix-item" ) type CreateDto struct { @@ -37,12 +39,14 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Name string `json:"name"` + Name string `json:"name"` + MixItems []*emmi.MedicineMixItem `json:"mixItems"` } func (d MedicineMix) ToResponse() ResponseDto { resp := ResponseDto{ - Name: d.Name, + Name: d.Name, + MixItems: d.MixItems, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/medicine-mix/entity.go b/internal/domain/main-entities/medicine-mix/entity.go index 3670c6d6..6575d703 100644 --- a/internal/domain/main-entities/medicine-mix/entity.go +++ b/internal/domain/main-entities/medicine-mix/entity.go @@ -2,9 +2,11 @@ package medicinemix import ( ecore "simrs-vx/internal/domain/base-entities/core" + emmi "simrs-vx/internal/domain/main-entities/medicine-mix-item" ) type MedicineMix struct { - ecore.Main // adjust this according to the needs - Name string `json:"name" gorm:"size:50"` + ecore.Main // adjust this according to the needs + Name string `json:"name" gorm:"size:50"` + MixItems []*emmi.MedicineMixItem `json:"mixItems" gorm:"foreignKey:MedicineMix_Id;references:Id"` } diff --git a/internal/domain/main-entities/person-relative/dto.go b/internal/domain/main-entities/person-relative/dto.go index 4b870771..4f28cbf8 100644 --- a/internal/domain/main-entities/person-relative/dto.go +++ b/internal/domain/main-entities/person-relative/dto.go @@ -17,6 +17,7 @@ type CreateDto struct { Education_Code *erp.EducationCode `json:"education_code" validate:"maxLength=10"` Occupation_Code *erp.OcupationCode `json:"occupation_code" validate:"maxLength=10"` Occupation_Name *string `json:"occupation_name" validate:"maxLength=50"` + Responsible bool `json:"responsible"` } type ReadListDto struct { @@ -37,6 +38,7 @@ type FilterDto struct { Education_Code *erp.EducationCode `json:"education_code"` Occupation_Code *erp.OcupationCode `json:"occupation_code"` Occupation_Name *string `json:"occupation_name"` + Responsible bool `json:"responsible"` Page int `json:"page"` PageSize int `json:"page_size"` @@ -78,6 +80,7 @@ type ResponseDto struct { Education_Code *erp.EducationCode `json:"education_code"` Occupation_Code *erp.OcupationCode `json:"occupation_code"` Occupation_Name *string `json:"occupation_name"` + Responsible bool `json:"responsible"` } func (d *PersonRelative) ToResponse() ResponseDto { diff --git a/internal/domain/main-entities/person-relative/entity.go b/internal/domain/main-entities/person-relative/entity.go index 9b67bd0b..3f83aa23 100644 --- a/internal/domain/main-entities/person-relative/entity.go +++ b/internal/domain/main-entities/person-relative/entity.go @@ -19,4 +19,5 @@ type PersonRelative struct { Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"` Occupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:10"` Occupation_Name *string `json:"occupation_name" gorm:"size:50"` + Responsible bool `json:"responsible"` } diff --git a/internal/domain/main-entities/prescription-item/entity.go b/internal/domain/main-entities/prescription-item/entity.go index 89537496..6ccf3ae4 100644 --- a/internal/domain/main-entities/prescription-item/entity.go +++ b/internal/domain/main-entities/prescription-item/entity.go @@ -21,4 +21,5 @@ type PrescriptionItem struct { Usage float64 `json:"usage"` Interval uint8 `json:"interval"` IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` + Quantity float64 `json:"quantity"` } diff --git a/internal/domain/main-entities/prescription/entity.go b/internal/domain/main-entities/prescription/entity.go index bf3e7930..20386bf4 100644 --- a/internal/domain/main-entities/prescription/entity.go +++ b/internal/domain/main-entities/prescription/entity.go @@ -4,14 +4,18 @@ 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" + "time" + + erc "simrs-vx/internal/domain/references/common" ) type Prescription struct { - ecore.Main // adjust this according to the needs - Encounter_Id *uint `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` - Doctor_Id *uint `json:"doctor_id"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` - IssuedAt *time.Time `json:"issuedAt"` + ecore.Main // adjust this according to the needs + Encounter_Id *uint `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor_Id *uint `json:"doctor_id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + IssuedAt *time.Time `json:"issuedAt"` + Status_Code erc.DataStatusCode `json:"status_code"` } diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index b7709333..373049f2 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -2,11 +2,12 @@ package clinical type ( - SubjectCode string - ObjectCode string - AssessmentCode string - PlanCode string - InstructionCode string + SubjectCode string + ObjectCode string + AssessmentCode string + PlanCode string + InstructionCode string + McuUrgencyLevelCode string ) const ( @@ -39,6 +40,13 @@ const ( ICMedAct InstructionCode = "med-act" // Tindakan medis ICMedication InstructionCode = "medication" // Obat ICMaterial InstructionCode = "material" // BMHP + + MULCCITO McuUrgencyLevelCode = "cito" + MULCCITOIGD McuUrgencyLevelCode = "cito-igd" + MULCPonek McuUrgencyLevelCode = "ponek" + MULCBG McuUrgencyLevelCode = "blood-gas" + MULCPF McuUrgencyLevelCode = "priority-form" + MULCRT McuUrgencyLevelCode = "routine" ) type Soapi struct { diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 4e544a59..6e582af2 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -4,6 +4,7 @@ import ( adime "simrs-vx/internal/domain/main-entities/adime" ambulatory "simrs-vx/internal/domain/main-entities/ambulatory" appointment "simrs-vx/internal/domain/main-entities/appointment" + consultation "simrs-vx/internal/domain/main-entities/consultation" counter "simrs-vx/internal/domain/main-entities/counter" device "simrs-vx/internal/domain/main-entities/device" deviceorder "simrs-vx/internal/domain/main-entities/device-order" @@ -31,8 +32,10 @@ import ( materialorderitem "simrs-vx/internal/domain/main-entities/material-order-item" mcuorder "simrs-vx/internal/domain/main-entities/mcu-order" mcuorderitem "simrs-vx/internal/domain/main-entities/mcu-order-item" + mcuordersubitem "simrs-vx/internal/domain/main-entities/mcu-order-sub-item" mcusrc "simrs-vx/internal/domain/main-entities/mcu-src" mcusrccategory "simrs-vx/internal/domain/main-entities/mcu-src-category" + mcusubsrc "simrs-vx/internal/domain/main-entities/mcu-sub-src" medicalactionsrc "simrs-vx/internal/domain/main-entities/medical-action-src" medicalactionsrcitem "simrs-vx/internal/domain/main-entities/medical-action-src-item" medication "simrs-vx/internal/domain/main-entities/medication" @@ -139,5 +142,8 @@ func getMainEntities() []any { &materialorderitem.MaterialOrderItem{}, &mcuorder.McuOrder{}, &mcuorderitem.McuOrderItem{}, + &mcusubsrc.McuSubSrc{}, + &mcuordersubitem.McuOrderSubItem{}, + &consultation.Consultation{}, } }