From 6b8f84efac8be32f9db72acfd4ce8cc324e3cf8f Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Wed, 17 Sep 2025 11:08:38 +0700 Subject: [PATCH 1/7] adjust on several order tables --- cmd/main-migration/migrations/20250917040616.sql | 8 ++++++++ cmd/main-migration/migrations/20250917040751.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 6 ++++-- .../main-entities/medication-item/entity.go | 2 ++ .../domain/main-entities/medicine-mix/entity.go | 5 +++-- .../main-entities/prescription-item/entity.go | 1 + .../domain/main-entities/prescription/entity.go | 16 ++++++++++------ 7 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 cmd/main-migration/migrations/20250917040616.sql create mode 100644 cmd/main-migration/migrations/20250917040751.sql 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/atlas.sum b/cmd/main-migration/migrations/atlas.sum index fcc26fdd..559bbade 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:lwrJz1Vor7muHsLHihYT704fcsjyX/JmBfRLfg+4PjI= +h1:1QSYLfLrRojOO3SUOR0bOUsv7hWGJxR4mfzv6/P540k= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -7,4 +7,6 @@ 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:QFuMvZUCmZPWsjHTdIFOT8P0fzCv3/xP0jGsfVms0aA= +20250917040751.sql h1:/0YgGP0VLK/WGTVi1KUuPQsx7i9O9Em8u/Ec1luYPDo= 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/entity.go b/internal/domain/main-entities/medicine-mix/entity.go index 3670c6d6..2445bde2 100644 --- a/internal/domain/main-entities/medicine-mix/entity.go +++ b/internal/domain/main-entities/medicine-mix/entity.go @@ -5,6 +5,7 @@ import ( ) 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"` + Note *string `json:"note" gom:"size:1024"` } 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..da0554a9 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"` } From 282cc93c140959a9a8c2c23d7f7f414c057d9251 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Wed, 17 Sep 2025 11:53:04 +0700 Subject: [PATCH 2/7] change fk, put fk on medmix and remove fk from medmixitem --- cmd/main-migration/migrations/20250917045138.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 7 ++++--- .../domain/main-entities/medicine-mix-item/dto.go | 11 ++++------- .../domain/main-entities/medicine-mix-item/entity.go | 12 +++++------- internal/domain/main-entities/medicine-mix/dto.go | 8 ++++++-- internal/domain/main-entities/medicine-mix/entity.go | 8 +++++--- 6 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 cmd/main-migration/migrations/20250917045138.sql 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/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 559bbade..947c21ed 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:1QSYLfLrRojOO3SUOR0bOUsv7hWGJxR4mfzv6/P540k= +h1:QeWON016g64FziEzikpibQnksdHm3nulYh4SE5Wrpek= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -8,5 +8,6 @@ h1:1QSYLfLrRojOO3SUOR0bOUsv7hWGJxR4mfzv6/P540k= 20250910055902.sql h1:5xwjAV6QbtZT9empTJKfhyAjdknbHzb15B0Ku5dzqtQ= 20250915123412.sql h1:D83xaU2YlDEd21HLup/YQpQ2easMToYCyy/oK6AFgQs= 20250916043819.sql h1:ekoTJsBqQZ8G8n0qJ03d13+eoNoc7sAUEQGA5D/CCxk= -20250917040616.sql h1:QFuMvZUCmZPWsjHTdIFOT8P0fzCv3/xP0jGsfVms0aA= -20250917040751.sql h1:/0YgGP0VLK/WGTVi1KUuPQsx7i9O9Em8u/Ec1luYPDo= +20250917040616.sql h1:zoCnmcXuM7AVv85SmN7RmFglCgJnoDmpRWExH0LAc9Q= +20250917040751.sql h1:J1xyRrh32y1+lezwAyNwPcUQ6ABBSgbvzNLva4SVdQU= +20250917045138.sql h1:7yGxD9Rxn89d9Z7bJQQo0kS++ZE6c1w1iURemEDeo/U= 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..cbfdc7ed 100644 --- a/internal/domain/main-entities/medicine-mix-item/entity.go +++ b/internal/domain/main-entities/medicine-mix-item/entity.go @@ -3,14 +3,12 @@ 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"` } 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 2445bde2..8c609579 100644 --- a/internal/domain/main-entities/medicine-mix/entity.go +++ b/internal/domain/main-entities/medicine-mix/entity.go @@ -2,10 +2,12 @@ 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"` - Note *string `json:"note" gom:"size:1024"` + ecore.Main // adjust this according to the needs + Name string `json:"name" gorm:"size:50"` + Note *string `json:"note" gom:"size:1024"` + MixItems []*emmi.MedicineMixItem `json:"mixItems" gorm:"foreignKey:MedicineMix_Id;references:Id"` } From ab9cda65af3d786ca545055caf38b765081935f5 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Wed, 17 Sep 2025 16:37:17 +0700 Subject: [PATCH 3/7] remove note from medmix, add note for medmixitem --- cmd/main-migration/migrations/20250917093645.sql | 4 ++++ cmd/main-migration/migrations/atlas.sum | 5 +++-- internal/domain/main-entities/medicine-mix-item/entity.go | 1 + internal/domain/main-entities/medicine-mix/entity.go | 1 - 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 cmd/main-migration/migrations/20250917093645.sql 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/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 947c21ed..bef5214a 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:QeWON016g64FziEzikpibQnksdHm3nulYh4SE5Wrpek= +h1:MYP+zDQNT6gqYsXaJnhbXwwAogZIHtCYOfAs8/dvsQs= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -10,4 +10,5 @@ h1:QeWON016g64FziEzikpibQnksdHm3nulYh4SE5Wrpek= 20250916043819.sql h1:ekoTJsBqQZ8G8n0qJ03d13+eoNoc7sAUEQGA5D/CCxk= 20250917040616.sql h1:zoCnmcXuM7AVv85SmN7RmFglCgJnoDmpRWExH0LAc9Q= 20250917040751.sql h1:J1xyRrh32y1+lezwAyNwPcUQ6ABBSgbvzNLva4SVdQU= -20250917045138.sql h1:7yGxD9Rxn89d9Z7bJQQo0kS++ZE6c1w1iURemEDeo/U= +20250917045138.sql h1:jKe1Z0uOLG4SGBYM+S/3P+/zMPztmgoderD5swnMuCg= +20250917093645.sql h1:Ap/l0AV/iazV6g88JbBEnnDdb/QUAt3j0DAGsNonswY= diff --git a/internal/domain/main-entities/medicine-mix-item/entity.go b/internal/domain/main-entities/medicine-mix-item/entity.go index cbfdc7ed..a642fce0 100644 --- a/internal/domain/main-entities/medicine-mix-item/entity.go +++ b/internal/domain/main-entities/medicine-mix-item/entity.go @@ -11,4 +11,5 @@ type MedicineMixItem struct { 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/entity.go b/internal/domain/main-entities/medicine-mix/entity.go index 8c609579..6575d703 100644 --- a/internal/domain/main-entities/medicine-mix/entity.go +++ b/internal/domain/main-entities/medicine-mix/entity.go @@ -8,6 +8,5 @@ import ( type MedicineMix struct { ecore.Main // adjust this according to the needs Name string `json:"name" gorm:"size:50"` - Note *string `json:"note" gom:"size:1024"` MixItems []*emmi.MedicineMixItem `json:"mixItems" gorm:"foreignKey:MedicineMix_Id;references:Id"` } From 3b601c4d7666dc4271f3d17f8eb4701e71523ca6 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Thu, 18 Sep 2025 14:38:18 +0700 Subject: [PATCH 4/7] adjust and add tables for mcu orders --- .../migrations/20250918073552.sql | 10 +++ .../migrations/20250918073742.sql | 31 +++++++ cmd/main-migration/migrations/atlas.sum | 6 +- .../main-entities/mcu-order-item/entity.go | 16 ++-- .../main-entities/mcu-order-sub-item/dto.go | 81 +++++++++++++++++++ .../mcu-order-sub-item/entity.go | 19 +++++ .../domain/main-entities/mcu-order/entity.go | 19 +++-- internal/domain/main-entities/mcu-src/dto.go | 15 ++-- .../domain/main-entities/mcu-src/entity.go | 5 +- .../domain/main-entities/mcu-sub-src/dto.go | 80 ++++++++++++++++++ .../main-entities/mcu-sub-src/entity.go | 17 ++++ .../main-entities/person-relative/dto.go | 3 + .../main-entities/person-relative/entity.go | 1 + .../domain/references/clinical/clinical.go | 18 +++-- internal/interface/migration/main-entities.go | 4 + 15 files changed, 299 insertions(+), 26 deletions(-) create mode 100644 cmd/main-migration/migrations/20250918073552.sql create mode 100644 cmd/main-migration/migrations/20250918073742.sql create mode 100644 internal/domain/main-entities/mcu-order-sub-item/dto.go create mode 100644 internal/domain/main-entities/mcu-order-sub-item/entity.go create mode 100644 internal/domain/main-entities/mcu-sub-src/dto.go create mode 100644 internal/domain/main-entities/mcu-sub-src/entity.go 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/atlas.sum b/cmd/main-migration/migrations/atlas.sum index bef5214a..8331a224 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:MYP+zDQNT6gqYsXaJnhbXwwAogZIHtCYOfAs8/dvsQs= +h1:/1wrpFNiVjqgLh9gO/ylCCpvvZ/DLYioH4r0cbc+F7Y= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -11,4 +11,6 @@ h1:MYP+zDQNT6gqYsXaJnhbXwwAogZIHtCYOfAs8/dvsQs= 20250917040616.sql h1:zoCnmcXuM7AVv85SmN7RmFglCgJnoDmpRWExH0LAc9Q= 20250917040751.sql h1:J1xyRrh32y1+lezwAyNwPcUQ6ABBSgbvzNLva4SVdQU= 20250917045138.sql h1:jKe1Z0uOLG4SGBYM+S/3P+/zMPztmgoderD5swnMuCg= -20250917093645.sql h1:Ap/l0AV/iazV6g88JbBEnnDdb/QUAt3j0DAGsNonswY= +20250917093645.sql h1:cNI3Pbz1R3LxvIXLuexafJFCXUXrmuFCgXXJ2sG+FW0= +20250918073552.sql h1:QyqEw1qSiM43O0+6eDfbEh6bp/a/AzDjKAKKO9fyvgg= +20250918073742.sql h1:8pwPLtUk7WRL2yTeZUMz8VnqZeoxTcUc2DtMcL8GH9Q= 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..e02fdcc2 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:10"` } 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/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/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index e5c85682..d76770fe 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,4 +40,11 @@ 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" ) diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 4e544a59..6bfde570 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -31,8 +31,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 +141,7 @@ func getMainEntities() []any { &materialorderitem.MaterialOrderItem{}, &mcuorder.McuOrder{}, &mcuorderitem.McuOrderItem{}, + &mcusubsrc.McuSubSrc{}, + &mcuordersubitem.McuOrderSubItem{}, } } From 28a8fff219fd571b995c8b99a6ebc57ce87a103a Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Thu, 18 Sep 2025 14:48:07 +0700 Subject: [PATCH 5/7] change size mcu urgency level code --- cmd/main-migration/migrations/20250918074745.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 7 ++++--- internal/domain/main-entities/mcu-order/entity.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 cmd/main-migration/migrations/20250918074745.sql 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/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 8331a224..6d4d0688 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:/1wrpFNiVjqgLh9gO/ylCCpvvZ/DLYioH4r0cbc+F7Y= +h1:5jNo0I155phYhWoHR1fzLdCLVByy/lPwGz5IS1aslTc= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -12,5 +12,6 @@ h1:/1wrpFNiVjqgLh9gO/ylCCpvvZ/DLYioH4r0cbc+F7Y= 20250917040751.sql h1:J1xyRrh32y1+lezwAyNwPcUQ6ABBSgbvzNLva4SVdQU= 20250917045138.sql h1:jKe1Z0uOLG4SGBYM+S/3P+/zMPztmgoderD5swnMuCg= 20250917093645.sql h1:cNI3Pbz1R3LxvIXLuexafJFCXUXrmuFCgXXJ2sG+FW0= -20250918073552.sql h1:QyqEw1qSiM43O0+6eDfbEh6bp/a/AzDjKAKKO9fyvgg= -20250918073742.sql h1:8pwPLtUk7WRL2yTeZUMz8VnqZeoxTcUc2DtMcL8GH9Q= +20250918073552.sql h1:RJ1SvMzP6aeWnoPVD3eVAmIQOkcp6Php8z3QRri6v4g= +20250918073742.sql h1:+cEsnJTJFybe2fR69ZoOiX2R6c6iITl4m6WTZ1hjyzY= +20250918074745.sql h1:Nl0Z6QghF2/iUk5AtslyA4Jo7YzQSfrGoH2gZuXVXK8= diff --git a/internal/domain/main-entities/mcu-order/entity.go b/internal/domain/main-entities/mcu-order/entity.go index e02fdcc2..134485e5 100644 --- a/internal/domain/main-entities/mcu-order/entity.go +++ b/internal/domain/main-entities/mcu-order/entity.go @@ -21,5 +21,5 @@ type McuOrder struct { ExaminationDate *time.Time `json:"examinationDate"` Number uint8 `json:"number"` Temperature float64 `json:"temperature"` - McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code" gorm:"not null;size:10"` + McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code" gorm:"not null;size:15"` } From 5810c2cb2b6a7d806291171b75eace8f376d11ee Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 22 Sep 2025 13:03:31 +0700 Subject: [PATCH 6/7] change datatype prescription's status code --- cmd/main-migration/migrations/atlas.sum | 4 ++-- .../domain/main-entities/prescription/entity.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 6d4d0688..59829316 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:5jNo0I155phYhWoHR1fzLdCLVByy/lPwGz5IS1aslTc= +h1:ZD6tpr1oc81DWrZLIE3ZVmvnBpU7r6Nlet5N489jJVk= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -14,4 +14,4 @@ h1:5jNo0I155phYhWoHR1fzLdCLVByy/lPwGz5IS1aslTc= 20250917093645.sql h1:cNI3Pbz1R3LxvIXLuexafJFCXUXrmuFCgXXJ2sG+FW0= 20250918073552.sql h1:RJ1SvMzP6aeWnoPVD3eVAmIQOkcp6Php8z3QRri6v4g= 20250918073742.sql h1:+cEsnJTJFybe2fR69ZoOiX2R6c6iITl4m6WTZ1hjyzY= -20250918074745.sql h1:Nl0Z6QghF2/iUk5AtslyA4Jo7YzQSfrGoH2gZuXVXK8= +20250918074745.sql h1:2hNVQCXF/dVYXAh+T/7oBFgERGWxzVb2FXJjwkFWGCI= diff --git a/internal/domain/main-entities/prescription/entity.go b/internal/domain/main-entities/prescription/entity.go index da0554a9..20386bf4 100644 --- a/internal/domain/main-entities/prescription/entity.go +++ b/internal/domain/main-entities/prescription/entity.go @@ -11,11 +11,11 @@ import ( ) 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"` - Status_Code *erc.DataStatusCode `json:"status_code"` + 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"` } From d851989df2d972d06a01557e775665b45bd029f7 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 23 Sep 2025 09:51:55 +0700 Subject: [PATCH 7/7] add consultation --- .../migrations/20250923025134.sql | 17 ++++ cmd/main-migration/migrations/atlas.sum | 3 +- .../domain/main-entities/consultation/dto.go | 87 +++++++++++++++++++ .../main-entities/consultation/entity.go | 23 +++++ internal/interface/migration/main-entities.go | 2 + 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 cmd/main-migration/migrations/20250923025134.sql create mode 100644 internal/domain/main-entities/consultation/dto.go create mode 100644 internal/domain/main-entities/consultation/entity.go 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 59829316..e61e9880 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:ZD6tpr1oc81DWrZLIE3ZVmvnBpU7r6Nlet5N489jJVk= +h1:0Hvo3AS2yMsS60eDIKnU5B2qvjDhNWHSDHcMxKKYJTk= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -15,3 +15,4 @@ h1:ZD6tpr1oc81DWrZLIE3ZVmvnBpU7r6Nlet5N489jJVk= 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/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 6bfde570..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" @@ -143,5 +144,6 @@ func getMainEntities() []any { &mcuorderitem.McuOrderItem{}, &mcusubsrc.McuSubSrc{}, &mcuordersubitem.McuOrderSubItem{}, + &consultation.Consultation{}, } }