Merge branch 'migration' of github.com:dikstub-rssa/simrs-be into feat/bpjs-api-70

This commit is contained in:
dpurbosakti
2025-10-16 08:15:02 +07:00
10 changed files with 84 additions and 34 deletions
@@ -0,0 +1,2 @@
-- Modify "Chemo" table
ALTER TABLE "public"."Chemo" ADD COLUMN "ClassCode" text NULL;
@@ -0,0 +1,2 @@
-- Rename a column from "ClassCode" to "Class_Code"
ALTER TABLE "public"."Chemo" RENAME COLUMN "ClassCode" TO "Class_Code";
@@ -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");
+6 -3
View File
@@ -1,4 +1,4 @@
h1:u4hCgNdaO4s4HQqAyPwS2ejbRhJtLvpU/wUJGtGrxsI=
h1:qfP77w9XYWpAFDON1lo+vpqIYCSiPkVEyHXcYFC52Hk=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -41,5 +41,8 @@ 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:MeLWmMhAOAz8b15Dd7IAQnt6JxjSml02XCXK22C0Lpg=
20251016010845.sql h1:MSUh26glEDyZ5BFiteYOm9mUCWw7aG9vv5TxYY+EidU=
20251016011023.sql h1:8oUBzIpzAYTo03yex+wLKacv32YjXmn4MsXtBFiQtzY=
@@ -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 {
@@ -19,6 +20,7 @@ type Chemo struct {
VerifiedAt *time.Time `json:"verifiedAt"`
VerifiedBy_User_Id *uint `json:"verifiedBy_user_id"`
VerifiedBy *eus.User `json:"verifiedBy,omitempty" gorm:"foreignKey:VerifiedBy_User_Id;references:Id"`
SrcUnit_Id *uint `json:"srcUnit_id"`
SrcUnit *eun.Unit `json:"srcUnit,omitempty" gorm:"foreignKey:SrcUnit_Id;references:Id"`
SrcUnit_Id *uint `json:"src_unit_id"`
SrcUnit *eun.Unit `json:"src_unit,omitempty" gorm:"foreignKey:SrcUnit_Id;references:Id"`
Class_Code ere.ChemoClassCode `json:"class_code"`
}
@@ -0,0 +1 @@
package personinsurance
@@ -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"`
}
+31 -29
View File
@@ -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"`
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"`
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 {
@@ -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 {
@@ -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{},