From b42dca81a5e90b8b8a589df23e1a8d2fba47bb9c Mon Sep 17 00:00:00 2001 From: vanilia Date: Wed, 15 Oct 2025 11:57:12 +0700 Subject: [PATCH 1/3] add column in chemo table --- cmd/main-migration/migrations/20251015045455.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 7 ++++--- internal/domain/main-entities/chemo/entity.go | 2 ++ internal/domain/references/encounter/encounter.go | 4 ++++ 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 cmd/main-migration/migrations/20251015045455.sql diff --git a/cmd/main-migration/migrations/20251015045455.sql b/cmd/main-migration/migrations/20251015045455.sql new file mode 100644 index 00000000..f2b6be7a --- /dev/null +++ b/cmd/main-migration/migrations/20251015045455.sql @@ -0,0 +1,2 @@ +-- Modify "Chemo" table +ALTER TABLE "public"."Chemo" ADD COLUMN "ClassCode" text NULL; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 77b5524c..e3172704 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:u4hCgNdaO4s4HQqAyPwS2ejbRhJtLvpU/wUJGtGrxsI= +h1:Y15nC3Bp3DWNym7hAvXkF9zFwkHh8nQDpxcNrxQgYhE= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -41,5 +41,6 @@ h1:u4hCgNdaO4s4HQqAyPwS2ejbRhJtLvpU/wUJGtGrxsI= 20251013051438.sql h1:lfSuw5mgJnePBJamvhZ81osFIouXeiIEiSZ/evdwo48= 20251013081808.sql h1:ijgjNX08G6GBjA/ks8EKtb7P7Y7Cg7zbhqEOruGnv6M= 20251014060047.sql h1:0jqj49WTtneEIMQDBoo4c095ZGi8sCrA8NnHBrPU6D8= -20251014063537.sql h1:H9ZLr86pgDcDpRJmTwy8TIOVot9QcN7+i3HwT4Vmi5s= -20251014063720.sql h1:eiHNzJIdBpuazPI5MAgtc3yI83u4SvYyr7dJd3Ptxdo= +20251014063537.sql h1:VZLXol0PTsTW21Epg6vBPsztWkDtcxup9F/z88EGgIg= +20251014063720.sql h1:2HVUyCV0ud3BJJDH2GEKZN/+IWLFPCsN1KqhP6csO14= +20251015045455.sql h1:v120CzYYiFWmW81VmKWsjmjRiBIv5aFnPZXwQaQxqes= diff --git a/internal/domain/main-entities/chemo/entity.go b/internal/domain/main-entities/chemo/entity.go index 2ba83990..f838c27d 100644 --- a/internal/domain/main-entities/chemo/entity.go +++ b/internal/domain/main-entities/chemo/entity.go @@ -9,6 +9,7 @@ import ( eus "simrs-vx/internal/domain/main-entities/user" erc "simrs-vx/internal/domain/references/common" + ere "simrs-vx/internal/domain/references/encounter" ) type Chemo struct { @@ -21,4 +22,5 @@ type Chemo struct { VerifiedBy *eus.User `json:"verifiedBy,omitempty" gorm:"foreignKey:VerifiedBy_User_Id;references:Id"` SrcUnit_Id *uint `json:"src_unit_id"` SrcUnit *eun.Unit `json:"src_unit,omitempty" gorm:"foreignKey:SrcUnit_Id;references:Id"` + ClassCode ere.ChemoClassCode `json:"class_code"` } diff --git a/internal/domain/references/encounter/encounter.go b/internal/domain/references/encounter/encounter.go index 7e6bcf8c..93c49a33 100644 --- a/internal/domain/references/encounter/encounter.go +++ b/internal/domain/references/encounter/encounter.go @@ -12,6 +12,7 @@ type ( AmbulatoryClassCode string InpatientClassCode string UploadCode string + ChemoClassCode string ) const ( @@ -78,6 +79,9 @@ const ( UCPP UploadCode = "person-passport" // Person Passport UCPFC UploadCode = "person-family-card" // Person Family Card UCMIR UploadCode = "mcu-item-result" // Mcu Item Result + + CCCAdm ChemoClassCode = "adm" // Administrasi + CCCAct ChemoClassCode = "act" // Tindakan ) func (ec EncounterClassCode) Code() string { From 0b864d8cd71c2a22f586c93860ce2c7c8bc46eb7 Mon Sep 17 00:00:00 2001 From: vanilia Date: Wed, 15 Oct 2025 12:11:11 +0700 Subject: [PATCH 2/3] resolve typo name class code --- internal/domain/main-entities/chemo/entity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/domain/main-entities/chemo/entity.go b/internal/domain/main-entities/chemo/entity.go index f838c27d..4052ea72 100644 --- a/internal/domain/main-entities/chemo/entity.go +++ b/internal/domain/main-entities/chemo/entity.go @@ -22,5 +22,5 @@ type Chemo struct { VerifiedBy *eus.User `json:"verifiedBy,omitempty" gorm:"foreignKey:VerifiedBy_User_Id;references:Id"` SrcUnit_Id *uint `json:"src_unit_id"` SrcUnit *eun.Unit `json:"src_unit,omitempty" gorm:"foreignKey:SrcUnit_Id;references:Id"` - ClassCode ere.ChemoClassCode `json:"class_code"` + Class_Code ere.ChemoClassCode `json:"class_code"` } From a8e41f055c746a32100248f22d09b461e44a1f87 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Thu, 16 Oct 2025 08:12:54 +0700 Subject: [PATCH 3/3] add person-insurance, adjust person --- .../migrations/20251016010845.sql | 2 + .../migrations/20251016011023.sql | 17 ++++++ cmd/main-migration/migrations/atlas.sum | 6 +- .../domain/main-entities/encounter/entity.go | 2 +- .../main-entities/person-insurance/dto.go | 1 + .../main-entities/person-insurance/entity.go | 15 +++++ .../domain/main-entities/person/entity.go | 60 ++++++++++--------- internal/interface/migration/main-entities.go | 2 + 8 files changed, 73 insertions(+), 32 deletions(-) create mode 100644 cmd/main-migration/migrations/20251016010845.sql create mode 100644 cmd/main-migration/migrations/20251016011023.sql create mode 100644 internal/domain/main-entities/person-insurance/dto.go create mode 100644 internal/domain/main-entities/person-insurance/entity.go diff --git a/cmd/main-migration/migrations/20251016010845.sql b/cmd/main-migration/migrations/20251016010845.sql new file mode 100644 index 00000000..edbbb414 --- /dev/null +++ b/cmd/main-migration/migrations/20251016010845.sql @@ -0,0 +1,2 @@ +-- Rename a column from "ClassCode" to "Class_Code" +ALTER TABLE "public"."Chemo" RENAME COLUMN "ClassCode" TO "Class_Code"; diff --git a/cmd/main-migration/migrations/20251016011023.sql b/cmd/main-migration/migrations/20251016011023.sql new file mode 100644 index 00000000..12e51e7d --- /dev/null +++ b/cmd/main-migration/migrations/20251016011023.sql @@ -0,0 +1,17 @@ +-- Create "PersonInsurance" table +CREATE TABLE "public"."PersonInsurance" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Person_Id" bigint NULL, + "InsuranceCompany_Id" bigint NULL, + "Ref_Number" character varying(20) NULL, + "DefaultStatus" boolean NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_PersonInsurance_Ref_Number" UNIQUE ("Ref_Number"), + CONSTRAINT "fk_PersonInsurance_InsuranceCompany" FOREIGN KEY ("InsuranceCompany_Id") REFERENCES "public"."InsuranceCompany" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_Person_Insurances" FOREIGN KEY ("Person_Id") REFERENCES "public"."Person" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create index "idx_person_insurance" to table: "PersonInsurance" +CREATE UNIQUE INDEX "idx_person_insurance" ON "public"."PersonInsurance" ("Person_Id", "DefaultStatus"); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index e3172704..05c66cea 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:Y15nC3Bp3DWNym7hAvXkF9zFwkHh8nQDpxcNrxQgYhE= +h1:qfP77w9XYWpAFDON1lo+vpqIYCSiPkVEyHXcYFC52Hk= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -43,4 +43,6 @@ h1:Y15nC3Bp3DWNym7hAvXkF9zFwkHh8nQDpxcNrxQgYhE= 20251014060047.sql h1:0jqj49WTtneEIMQDBoo4c095ZGi8sCrA8NnHBrPU6D8= 20251014063537.sql h1:VZLXol0PTsTW21Epg6vBPsztWkDtcxup9F/z88EGgIg= 20251014063720.sql h1:2HVUyCV0ud3BJJDH2GEKZN/+IWLFPCsN1KqhP6csO14= -20251015045455.sql h1:v120CzYYiFWmW81VmKWsjmjRiBIv5aFnPZXwQaQxqes= +20251015045455.sql h1:MeLWmMhAOAz8b15Dd7IAQnt6JxjSml02XCXK22C0Lpg= +20251016010845.sql h1:MSUh26glEDyZ5BFiteYOm9mUCWw7aG9vv5TxYY+EidU= +20251016011023.sql h1:8oUBzIpzAYTo03yex+wLKacv32YjXmn4MsXtBFiQtzY= diff --git a/internal/domain/main-entities/encounter/entity.go b/internal/domain/main-entities/encounter/entity.go index c9f81712..3e888356 100644 --- a/internal/domain/main-entities/encounter/entity.go +++ b/internal/domain/main-entities/encounter/entity.go @@ -32,10 +32,10 @@ type Encounter struct { VisitDate time.Time `json:"visitDate"` PaymentMethod_Code erc.PaymentMethodCode `json:"paymentMethod_code" gorm:"size:10"` InsuranceCompany_Id *uint `json:"insuranceCompany_id"` + InsuranceCompany *ei.InsuranceCompany `json:"insuranceCompany,omitempty" gorm:"foreignKey:InsuranceCompany_Id;references:Id"` Member_Number *string `json:"memberNumber" gorm:"unique;size:20"` Ref_Number *string `json:"refNumber" gorm:"unique;size:20"` Trx_Number *string `json:"trxNumber" gorm:"unique;size:20"` - InsuranceCompany *ei.InsuranceCompany `json:"insuranceCompany,omitempty" gorm:"foreignKey:InsuranceCompany_Id;references:Id"` Appointment_Doctor_Id *uint `json:"appointment_doctor_id"` Appointment_Doctor *ed.Doctor `json:"appointment_doctor,omitempty" gorm:"foreignKey:Appointment_Doctor_Id;references:Id"` Adm_Employee_Id *uint `json:"admEmployee_id"` diff --git a/internal/domain/main-entities/person-insurance/dto.go b/internal/domain/main-entities/person-insurance/dto.go new file mode 100644 index 00000000..5a2ee2a1 --- /dev/null +++ b/internal/domain/main-entities/person-insurance/dto.go @@ -0,0 +1 @@ +package personinsurance diff --git a/internal/domain/main-entities/person-insurance/entity.go b/internal/domain/main-entities/person-insurance/entity.go new file mode 100644 index 00000000..64057835 --- /dev/null +++ b/internal/domain/main-entities/person-insurance/entity.go @@ -0,0 +1,15 @@ +package personinsurance + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ei "simrs-vx/internal/domain/main-entities/insurance-company" +) + +type PersonInsurance struct { + ecore.Main + Person_Id *uint `json:"person_id" gorm:"uniqueIndex:idx_person_insurance"` + InsuranceCompany_Id *uint `json:"insurance_id"` + InsuranceCompany *ei.InsuranceCompany `json:"insurance,omitempty" gorm:"foreignKey:InsuranceCompany_Id;references:Id"` + Ref_Number *string `json:"ref_number" gorm:"unique;size:20"` + DefaultStatus *bool `json:"default_status" gorm:"uniqueIndex:idx_person_insurance"` +} diff --git a/internal/domain/main-entities/person/entity.go b/internal/domain/main-entities/person/entity.go index 8639df25..8932ca1b 100644 --- a/internal/domain/main-entities/person/entity.go +++ b/internal/domain/main-entities/person/entity.go @@ -6,6 +6,7 @@ import ( el "simrs-vx/internal/domain/main-entities/language" epa "simrs-vx/internal/domain/main-entities/person-address" epc "simrs-vx/internal/domain/main-entities/person-contact" + epi "simrs-vx/internal/domain/main-entities/person-insurance" epr "simrs-vx/internal/domain/main-entities/person-relative" er "simrs-vx/internal/domain/main-entities/regency" @@ -15,35 +16,36 @@ import ( ) type Person struct { - ecore.Main // adjust this according to the needs - Name string `json:"name" gorm:"not null;size:150"` - FrontTitle *string `json:"frontTitle" gorm:"size:50"` - EndTitle *string `json:"endTitle" gorm:"size:50"` - BirthDate *time.Time `json:"birthDate,omitempty"` - BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"` - BirthRegency *er.Regency `json:"birthRegency,omitempty" gorm:"foreignKey:BirthRegency_Code;references:Code"` - Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"` - ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"unique;size:16"` - PassportNumber *string `json:"passportNumber" gorm:"unique;size:20"` - DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"unique;size:20"` - Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"` - Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"` - Ocupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:15"` - Ocupation_Name *string `json:"occupation_name" gorm:"size:50"` - Nationality *string `json:"nationality": gorm:"size:50"` - Ethnic_Code *string `json:"ethnic_code" gorm:"size:20"` - Ethnic *ee.Ethnic `json:"ethnic,omitempty" gorm:"foreignKey:Ethnic_Code;references:Code"` - Addresses *[]epa.PersonAddress `json:"addresses" gorm:"foreignKey:Person_Id"` - Contacts *[]epc.PersonContact `json:"contacts" gorm:"foreignKey:Person_Id"` - Relatives *[]epr.PersonRelative `json:"relatives" gorm:"foreignKey:Person_Id"` - Language_Code *string `json:"language_code" gorm:"size:10"` - Language *el.Language `json:"language,omitempty" gorm:"foreignKey:Language_Code;references:Code"` - CommunicationIssueStatus bool `json:"communicationIssueStatus"` - Disability *string `json:"disability" gorm:"size:100"` - ResidentIdentityFileUrl *string `json:"residentIdentityFileUrl" gorm:"size:1024"` - PassportFileUrl *string `json:"passportFileUrl" gorm:"size:1024"` - DrivingLicenseFileUrl *string `json:"drivingLicenseFileUrl" gorm:"size:1024"` - FamilyIdentityFileUrl *string `json:"familyIdentityFileUrl" gorm:"size:1024"` + ecore.Main // adjust this according to the needs + Name string `json:"name" gorm:"not null;size:150"` + FrontTitle *string `json:"frontTitle" gorm:"size:50"` + EndTitle *string `json:"endTitle" gorm:"size:50"` + BirthDate *time.Time `json:"birthDate,omitempty"` + BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"` + BirthRegency *er.Regency `json:"birthRegency,omitempty" gorm:"foreignKey:BirthRegency_Code;references:Code"` + Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"` + ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"unique;size:16"` + PassportNumber *string `json:"passportNumber" gorm:"unique;size:20"` + DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"unique;size:20"` + Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"` + Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"` + Ocupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:15"` + Ocupation_Name *string `json:"occupation_name" gorm:"size:50"` + Nationality *string `json:"nationality": gorm:"size:50"` + Ethnic_Code *string `json:"ethnic_code" gorm:"size:20"` + Ethnic *ee.Ethnic `json:"ethnic,omitempty" gorm:"foreignKey:Ethnic_Code;references:Code"` + Language_Code *string `json:"language_code" gorm:"size:10"` + Language *el.Language `json:"language,omitempty" gorm:"foreignKey:Language_Code;references:Code"` + CommunicationIssueStatus bool `json:"communicationIssueStatus"` + Disability *string `json:"disability" gorm:"size:100"` + ResidentIdentityFileUrl *string `json:"residentIdentityFileUrl" gorm:"size:1024"` + PassportFileUrl *string `json:"passportFileUrl" gorm:"size:1024"` + DrivingLicenseFileUrl *string `json:"drivingLicenseFileUrl" gorm:"size:1024"` + FamilyIdentityFileUrl *string `json:"familyIdentityFileUrl" gorm:"size:1024"` + Addresses *[]epa.PersonAddress `json:"addresses" gorm:"foreignKey:Person_Id"` + Contacts *[]epc.PersonContact `json:"contacts" gorm:"foreignKey:Person_Id"` + Relatives *[]epr.PersonRelative `json:"relatives" gorm:"foreignKey:Person_Id"` + Insurances *[]epi.PersonInsurance `json:"insurances" gorm:"foreignKey:Person_Id"` } func (d Person) IsSameResidentIdentityNumber(input *string) bool { diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 034495c3..ea8ec1c0 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -55,6 +55,7 @@ import ( person "simrs-vx/internal/domain/main-entities/person" personaddress "simrs-vx/internal/domain/main-entities/person-address" personcontact "simrs-vx/internal/domain/main-entities/person-contact" + personinsurance "simrs-vx/internal/domain/main-entities/person-insurance" personrelative "simrs-vx/internal/domain/main-entities/person-relative" pharmacist "simrs-vx/internal/domain/main-entities/pharmacist" pharmacycompany "simrs-vx/internal/domain/main-entities/pharmacy-company" @@ -96,6 +97,7 @@ func getMainEntities() []any { &person.Person{}, &personaddress.PersonAddress{}, &personcontact.PersonContact{}, + &personinsurance.PersonInsurance{}, &pharmacycompany.PharmacyCompany{}, &diagnosesrc.DiagnoseSrc{}, &proceduresrc.ProcedureSrc{},