From f7edee1ac5fb011bf1c9b40c5422a3b0a938c3d4 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 29 Sep 2025 10:45:16 +0700 Subject: [PATCH 1/2] add soapiTypeCode, adjust soapi --- .../migrations/20250929034321.sql | 2 ++ .../migrations/20250929034428.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 6 ++++-- internal/domain/main-entities/soapi/entity.go | 20 +++++++++++-------- .../domain/references/clinical/clinical.go | 9 +++++++-- .../references/organization/organization.go | 2 ++ 6 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 cmd/main-migration/migrations/20250929034321.sql create mode 100644 cmd/main-migration/migrations/20250929034428.sql diff --git a/cmd/main-migration/migrations/20250929034321.sql b/cmd/main-migration/migrations/20250929034321.sql new file mode 100644 index 00000000..bfdc5021 --- /dev/null +++ b/cmd/main-migration/migrations/20250929034321.sql @@ -0,0 +1,2 @@ +-- Modify "Soapi" table +ALTER TABLE "public"."Soapi" ADD COLUMN "TypeCode" text NULL; diff --git a/cmd/main-migration/migrations/20250929034428.sql b/cmd/main-migration/migrations/20250929034428.sql new file mode 100644 index 00000000..84a214a5 --- /dev/null +++ b/cmd/main-migration/migrations/20250929034428.sql @@ -0,0 +1,2 @@ +-- Modify "Soapi" table +ALTER TABLE "public"."Soapi" ALTER COLUMN "TypeCode" TYPE character varying(11); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index b33a1e5c..9bdd6275 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:n2YbCQPYchOWsVSLUNPCl29Xx3RMTi7vdulwPRHXL4E= +h1:xkdKsHk/4s72juNsRgWubyMR4XEXjEQ38+XI4m/e/jM= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -16,4 +16,6 @@ h1:n2YbCQPYchOWsVSLUNPCl29Xx3RMTi7vdulwPRHXL4E= 20250918073742.sql h1:+cEsnJTJFybe2fR69ZoOiX2R6c6iITl4m6WTZ1hjyzY= 20250918074745.sql h1:2hNVQCXF/dVYXAh+T/7oBFgERGWxzVb2FXJjwkFWGCI= 20250923025134.sql h1:Ykz/qpHiGDXPsCsWTjydQFVSibZP2D+h2fIeb2h2JGA= -20250924051317.sql h1:vbbuylW434V23raIl6Y6Ima6aZVItLrdIpk+xehVsJc= +20250924051317.sql h1:yQuW6SwJxIOM5fcxeAaie5lSm1oLysU/C2hH2xNCVoQ= +20250929034321.sql h1:Pjs8W2zK7Q6Nwta/xpYE7YdfT+JfIMHjgWfDK2hnaEI= +20250929034428.sql h1:w3JomY0HxQJIdHA6Pq7mixJNi1YcO8NpQMjIfhNw+oA= diff --git a/internal/domain/main-entities/soapi/entity.go b/internal/domain/main-entities/soapi/entity.go index f6c6b5e9..7e457ca9 100644 --- a/internal/domain/main-entities/soapi/entity.go +++ b/internal/domain/main-entities/soapi/entity.go @@ -1,18 +1,22 @@ package soapi import ( + "time" + ecore "simrs-vx/internal/domain/base-entities/core" eem "simrs-vx/internal/domain/main-entities/employee" ee "simrs-vx/internal/domain/main-entities/encounter" - "time" + + erc "simrs-vx/internal/domain/references/clinical" ) type Soapi 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"` - Employee_Id *uint `json:"employee_id"` - Employee *eem.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` - Time *time.Time `json:"time"` - Value *string `json:"value"` + 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"` + Employee_Id *uint `json:"employee_id"` + Employee *eem.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + Time *time.Time `json:"time"` + TypeCode erc.SoapiTypeCode `json:"type_code" gorm:"size:11"` + Value *string `json:"value"` } diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index d76770fe..505298af 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -8,11 +8,12 @@ type ( PlanCode string InstructionCode string McuUrgencyLevelCode string + SoapiTypeCode string ) const ( - SCPrimaryComplaint SubjectCode = "pri-compl" // Keluhan Utama - SCSecComplaint SubjectCode = "sec-compl" // Secondary Complaint + SCPrimaryComplaint SubjectCode = "pri-complain" // Keluhan Utama + SCSecComplaint SubjectCode = "sec-complain" // Secondary Complaint SCCurrentDiseaseHistory SubjectCode = "cur-disea-hist" // Current Disease History SCPastDiseaseHistory SubjectCode = "pas-disea-hist" // Past Disease History SCFamilyDiseaseHistory SubjectCode = "fam-disea-hist" // Family Disease History @@ -47,4 +48,8 @@ const ( MULCBG McuUrgencyLevelCode = "blood-gas" MULCPF McuUrgencyLevelCode = "priority-form" MULCRT McuUrgencyLevelCode = "routine" + + STCEarly SoapiTypeCode = "early" // Kajian Awal Medis + STCERehab SoapiTypeCode = "early-rehab" // Kajian Awal Rehab Medik + STCFunc SoapiTypeCode = "function" // Assessment Fungsi ) diff --git a/internal/domain/references/organization/organization.go b/internal/domain/references/organization/organization.go index 30aa25b5..894257c8 100644 --- a/internal/domain/references/organization/organization.go +++ b/internal/domain/references/organization/organization.go @@ -15,6 +15,8 @@ const ( UPCLab UserPosisitionCode = "laborant" // Laboran UPCPha UserPosisitionCode = "pharmacy" // Farmasi UPCPay UserPosisitionCode = "payment" // Pembayaran + UPCHur UserPosisitionCode = "human-resource" // Sumber Daya Manusia + UPCGea UserPosisitionCode = "general-affair" // Bagian Umu UPCPav UserPosisitionCode = "payment-verificator" // Konfirmasi pembayaran UPCMan UserPosisitionCode = "management" // Manajemen UPCInt UserPosisitionCode = "specialist-intern" // PPDS From 7fd8bca3f893c3082d49ca4a2cff8fbe95a1f27b Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 30 Sep 2025 09:56:25 +0700 Subject: [PATCH 2/2] adjust for prescription item, medicinemix, medication item --- .../migrations/20250930025550.sql | 6 +++++ cmd/main-migration/migrations/atlas.sum | 7 +++--- .../main-entities/medication-item/dto.go | 7 ++++-- .../main-entities/medication-item/entity.go | 4 ++- .../main-entities/medicine-mix/entity.go | 3 +++ .../main-entities/prescription-item/dto.go | 25 +++++++++++++------ .../main-entities/prescription-item/entity.go | 4 ++- 7 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 cmd/main-migration/migrations/20250930025550.sql diff --git a/cmd/main-migration/migrations/20250930025550.sql b/cmd/main-migration/migrations/20250930025550.sql new file mode 100644 index 00000000..cb24b7fc --- /dev/null +++ b/cmd/main-migration/migrations/20250930025550.sql @@ -0,0 +1,6 @@ +-- Modify "MedicationItem" table +ALTER TABLE "public"."MedicationItem" ALTER COLUMN "Usage" TYPE character varying(255), ADD COLUMN "Frequency" integer NULL, ADD COLUMN "Dose" numeric NULL; +-- Modify "PrescriptionItem" table +ALTER TABLE "public"."PrescriptionItem" ALTER COLUMN "Usage" TYPE character varying(255), ADD COLUMN "Frequency" integer NULL, ADD COLUMN "Dose" numeric NULL; +-- Modify "MedicineMix" table +ALTER TABLE "public"."MedicineMix" ADD COLUMN "Uom_Code" character varying(10) NULL, ADD CONSTRAINT "fk_MedicineMix_Uom" FOREIGN KEY ("Uom_Code") REFERENCES "public"."Uom" ("Code") 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 9bdd6275..553c25ea 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:xkdKsHk/4s72juNsRgWubyMR4XEXjEQ38+XI4m/e/jM= +h1:Q2e6TNVbdE4yvg1W/bZvcNzYuBjy1kIT2z0QVbyWDYY= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -17,5 +17,6 @@ h1:xkdKsHk/4s72juNsRgWubyMR4XEXjEQ38+XI4m/e/jM= 20250918074745.sql h1:2hNVQCXF/dVYXAh+T/7oBFgERGWxzVb2FXJjwkFWGCI= 20250923025134.sql h1:Ykz/qpHiGDXPsCsWTjydQFVSibZP2D+h2fIeb2h2JGA= 20250924051317.sql h1:yQuW6SwJxIOM5fcxeAaie5lSm1oLysU/C2hH2xNCVoQ= -20250929034321.sql h1:Pjs8W2zK7Q6Nwta/xpYE7YdfT+JfIMHjgWfDK2hnaEI= -20250929034428.sql h1:w3JomY0HxQJIdHA6Pq7mixJNi1YcO8NpQMjIfhNw+oA= +20250929034321.sql h1:101FJ8VH12mrZWlt/X1gvKUGOhoiF8tFbjiapAjnHzg= +20250929034428.sql h1:i+pROD9p+g5dOmmZma6WF/0Hw5g3Ha28NN85iTo1K34= +20250930025550.sql h1:cUvQcYn+4BoID3BGn2JriESuD7WactMf/fp48EFwtAA= diff --git a/internal/domain/main-entities/medication-item/dto.go b/internal/domain/main-entities/medication-item/dto.go index 00edb045..8267fde5 100644 --- a/internal/domain/main-entities/medication-item/dto.go +++ b/internal/domain/main-entities/medication-item/dto.go @@ -13,10 +13,13 @@ type CreateDto struct { IsMix bool `json:"isMix"` Medicine_Id *uint `json:"medicine_id"` MedicineMix_Id *uint `json:"medicineMix_id"` - Usage float64 `json:"usage"` + Frequency *uint16 `json:"frequency"` + Dose float64 `json:"dose"` + Usage string `json:"usage"` Interval uint8 `json:"interval"` IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` IsRedeemed bool `json:"isRedeemed"` + Quantity float64 `json:"quantity"` } type ReadListDto struct { @@ -67,7 +70,7 @@ type ResponseDto struct { Medicine *em.Medicine `json:"medicine,omitempty"` MedicineMix_Id *uint `json:"medicineMix_id"` MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty"` - Usage float64 `json:"usage"` + Usage string `json:"usage"` Interval uint8 `json:"interval"` IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` IsRedeemed bool `json:"isRedeemed"` diff --git a/internal/domain/main-entities/medication-item/entity.go b/internal/domain/main-entities/medication-item/entity.go index e778cb50..ffef0761 100644 --- a/internal/domain/main-entities/medication-item/entity.go +++ b/internal/domain/main-entities/medication-item/entity.go @@ -18,7 +18,9 @@ type MedicationItem struct { Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Id;references:Id"` MedicineMix_Id *uint `json:"medicineMix_id"` MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty" gorm:"foreignKey:MedicineMix_Id;references:Id"` - Usage float64 `json:"usage"` + Frequency *uint16 `json:"frequency"` + Dose float64 `json:"dose"` + Usage string `json:"usage" gorm:"size:255"` Interval uint8 `json:"interval"` IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` IsRedeemed bool `json:"isRedeemed"` diff --git a/internal/domain/main-entities/medicine-mix/entity.go b/internal/domain/main-entities/medicine-mix/entity.go index 6575d703..1b9edd4f 100644 --- a/internal/domain/main-entities/medicine-mix/entity.go +++ b/internal/domain/main-entities/medicine-mix/entity.go @@ -3,10 +3,13 @@ package medicinemix import ( ecore "simrs-vx/internal/domain/base-entities/core" emmi "simrs-vx/internal/domain/main-entities/medicine-mix-item" + eu "simrs-vx/internal/domain/main-entities/uom" ) type MedicineMix struct { ecore.Main // adjust this according to the needs Name string `json:"name" gorm:"size:50"` + Uom_Code *string `json:"uom_code" gorm:"size:10"` + Uom *eu.Uom `json:"uom" gorm:"foreignKey:Uom_Code;references:Code"` MixItems []*emmi.MedicineMixItem `json:"mixItems" gorm:"foreignKey:MedicineMix_Id;references:Id"` } diff --git a/internal/domain/main-entities/prescription-item/dto.go b/internal/domain/main-entities/prescription-item/dto.go index f23a6610..1926853d 100644 --- a/internal/domain/main-entities/prescription-item/dto.go +++ b/internal/domain/main-entities/prescription-item/dto.go @@ -9,13 +9,16 @@ import ( ) type CreateDto struct { - Prescription_Id *uint `json:"prescription_id"` - IsMix bool `json:"isMix"` - Medicine_Id *uint `json:"medicine_id"` - MedicineMix_Id *uint `json:"medicineMix_id"` - Usage float64 `json:"usage"` - Interval uint8 `json:"interval"` - IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` + Prescription_Id *uint `json:"prescription_id"` + IsMix bool `json:"isMix"` + Medicine_Id *uint `json:"medicine_id"` + MedicineMix_Id *uint `json:"medicineMix_id"` + Frequency *uint16 `json:"frequency"` + Dose float64 `json:"dose"` + Usage float64 `json:"usage"` + Interval uint8 `json:"interval"` + IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` + IntervalMultiplier *uint16 `json:"intervalMultiplier"` } type ReadListDto struct { @@ -65,9 +68,12 @@ type ResponseDto struct { Medicine *em.Medicine `json:"medicine,omitempty"` MedicineMix_Id *uint `json:"medicineMix_id"` MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty"` - Usage float64 `json:"usage"` + Frequency *uint16 `json:"frequency"` + Dose float64 `json:"dose"` + Usage string `json:"usage"` Interval uint8 `json:"interval"` IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` + Quantity float64 `json:"quantity"` } func (d PrescriptionItem) ToResponse() ResponseDto { @@ -79,9 +85,12 @@ func (d PrescriptionItem) ToResponse() ResponseDto { Medicine: d.Medicine, MedicineMix_Id: d.MedicineMix_Id, MedicineMix: d.MedicineMix, + Frequency: d.Frequency, + Dose: d.Dose, Usage: d.Usage, Interval: d.Interval, IntervalUnit_Code: d.IntervalUnit_Code, + Quantity: d.Quantity, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/prescription-item/entity.go b/internal/domain/main-entities/prescription-item/entity.go index 6ccf3ae4..33696385 100644 --- a/internal/domain/main-entities/prescription-item/entity.go +++ b/internal/domain/main-entities/prescription-item/entity.go @@ -18,7 +18,9 @@ type PrescriptionItem struct { Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Id;references:Id"` MedicineMix_Id *uint `json:"medicineMix_id"` MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty" gorm:"foreignKey:MedicineMix_Id;references:Id"` - Usage float64 `json:"usage"` + Frequency *uint16 `json:"frequency"` + Dose float64 `json:"dose"` + Usage string `json:"usage" gorm:"size:255"` Interval uint8 `json:"interval"` IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"` Quantity float64 `json:"quantity"`