diff --git a/cmd/main-migration/migrations/20251008031337.sql b/cmd/main-migration/migrations/20251008031337.sql new file mode 100644 index 00000000..fd2aff8a --- /dev/null +++ b/cmd/main-migration/migrations/20251008031337.sql @@ -0,0 +1,2 @@ +-- Modify "PersonAddress" table +ALTER TABLE "public"."PersonAddress" ADD COLUMN "PostalCode" character varying(6) NULL; diff --git a/cmd/main-migration/migrations/20251008031554.sql b/cmd/main-migration/migrations/20251008031554.sql new file mode 100644 index 00000000..58cee318 --- /dev/null +++ b/cmd/main-migration/migrations/20251008031554.sql @@ -0,0 +1,12 @@ +-- Create "Midwife" table +CREATE TABLE "public"."Midwife" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Employee_Id" bigint NULL, + "IHS_Number" character varying(20) NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_Midwife_IHS_Number" UNIQUE ("IHS_Number"), + CONSTRAINT "fk_Midwife_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("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 a8dfe2ee..34db99e7 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:4thtC22CJCQMIeVkYLmcFOT5w7S+bUUWy9wHZ21OHi8= +h1:ggc8pOi/e+U1WtE8F5K1QjGB3iuTm2Xr71jLLMn7LJc= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -28,3 +28,5 @@ h1:4thtC22CJCQMIeVkYLmcFOT5w7S+bUUWy9wHZ21OHi8= 20251006045658.sql h1:3FmGCPCzjgMPdWDRodZTsx3KVaodd9zB9ilib69aewk= 20251006045928.sql h1:Z5g31PmnzNwk/OKdODcxZGm8fjJQdMFK32Xfnt3bRHg= 20251007022859.sql h1:FO03zEfaNEk/aXwY81d5Lp3MoBB9kPQuXlXJ4BPiSR8= +20251008031337.sql h1:IYmKye5jNMkepsnEcUzaB0lLWDGzn7dO9zT3dZxIhgY= +20251008031554.sql h1:zqUmpXDFfFgDi7I8I/izxPG6D4SPeF8B3WfpnT6mo4Y= diff --git a/internal/domain/main-entities/midwife/dto.go b/internal/domain/main-entities/midwife/dto.go new file mode 100644 index 00000000..308f0559 --- /dev/null +++ b/internal/domain/main-entities/midwife/dto.go @@ -0,0 +1,69 @@ +package midwife + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type CreateDto struct { + Employee_Id *uint `json:"employee_id"` + IHS_Number *string `json:"ihs_number" validate:"maxLength=20"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Preloads []string `json:"-"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Employee_Id *uint `json:"employee_id"` + IHS_Number *string `json:"ihs_number"` +} + +type ReadDetailDto struct { + Id uint16 `json:"id"` + Employee_Id *uint `json:"employee_id"` + IHS_Number *string `json:"ihs_number"` +} + +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 + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty"` + IHS_Number *string `json:"ihs_number"` +} + +func (d Midwife) ToResponse() ResponseDto { + resp := ResponseDto{ + Employee_Id: d.Employee_Id, + Employee: d.Employee, + IHS_Number: d.IHS_Number, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []Midwife) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/midwife/entity.go b/internal/domain/main-entities/midwife/entity.go new file mode 100644 index 00000000..f98ba553 --- /dev/null +++ b/internal/domain/main-entities/midwife/entity.go @@ -0,0 +1,13 @@ +package midwife + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type Midwife struct { + ecore.Main // adjust this according to the needs + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + IHS_Number *string `json:"ihs_number" gorm:"unique;size:20"` +} diff --git a/internal/domain/main-entities/person-address/entity.go b/internal/domain/main-entities/person-address/entity.go index 960b32a9..eacfd9f0 100644 --- a/internal/domain/main-entities/person-address/entity.go +++ b/internal/domain/main-entities/person-address/entity.go @@ -10,5 +10,6 @@ type PersonAddress struct { Address string `json:"address" gorm:"size:150"` Rt string `json:"rt" gorm:"size:2"` Rw string `json:"rw" gorm:"size:2"` + PostalCode string `json:"postalCode" gorm:"size:6"` Village_Code string `json:"village_code" gorm:"size:10"` } diff --git a/internal/domain/references/organization/organization.go b/internal/domain/references/organization/organization.go index 68edc332..bf11fbd6 100644 --- a/internal/domain/references/organization/organization.go +++ b/internal/domain/references/organization/organization.go @@ -31,12 +31,14 @@ const ( ITGCEmpFee ItemGroupCode = "employee-fee" ITGCDocFee ItemGroupCode = "doctor-fee" - IFGCBuilding InfraGroupCode = "building" // Bangunan - IFGCFloor InfraGroupCode = "floor" // Lantai - IFGCRoom InfraGroupCode = "room" // Ruang - IFGCChamber InfraGroupCode = "chamber" // Kamar - IFGCBed InfraGroupCode = "bed" // Ranjang - IFGCWarehouse InfraGroupCode = "warehouse" // Gudang/Depo + IFGCBuilding InfraGroupCode = "building" // Bangunan + IFGCFloor InfraGroupCode = "floor" // Lantai + IFGCRoom InfraGroupCode = "room" // Ruang + IFGCChamber InfraGroupCode = "chamber" // Kamar + IFGCBed InfraGroupCode = "bed" // Ranjang + IFGCWarehouse InfraGroupCode = "warehouse" // Gudang/Depo + IFGCCounter InfraGroupCode = "counter" // Counter + IFGCPubScreen InfraGroupCode = "public-screen" // Public Screen UTCReg UnitTypeCode = "reg" // Registrasi UTCExa UnitTypeCode = "exa" // Pemeriksaan diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 4d0f79c1..9711c6bd 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -47,6 +47,7 @@ import ( medicinemethod "simrs-vx/internal/domain/main-entities/medicine-method" medicinemix "simrs-vx/internal/domain/main-entities/medicine-mix" medicinemixitem "simrs-vx/internal/domain/main-entities/medicine-mix-item" + midwife "simrs-vx/internal/domain/main-entities/midwife" nurse "simrs-vx/internal/domain/main-entities/nurse" nutritionist "simrs-vx/internal/domain/main-entities/nutritionist" patient "simrs-vx/internal/domain/main-entities/patient" @@ -147,5 +148,6 @@ func getMainEntities() []any { &mcuordersubitem.McuOrderSubItem{}, &consultation.Consultation{}, &chemo.Chemo{}, + &midwife.Midwife{}, } }