adjust and add tables for mcu orders

This commit is contained in:
dpurbosakti
2025-09-18 14:38:18 +07:00
parent ab9cda65af
commit 3b601c4d76
15 changed files with 299 additions and 26 deletions
@@ -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;
@@ -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");
+4 -2
View File
@@ -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=
@@ -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"`
}
@@ -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
}
@@ -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"`
}
@@ -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"`
}
+10 -5
View File
@@ -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
}
@@ -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"`
}
@@ -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
}
@@ -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"`
}
@@ -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 {
@@ -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"`
}
@@ -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"
)
@@ -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{},
}
}