Merge branch 'migration' of https://github.com/dikstub-rssa/simrs-be into feat/vehicle-src-75

# Conflicts:
#	internal/domain/main-entities/person/entity.go
This commit is contained in:
vanilia
2025-10-17 09:36:51 +07:00
15 changed files with 248 additions and 44 deletions
@@ -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");
@@ -0,0 +1,54 @@
-- Create "AmbulanceTransportReq" table
CREATE TABLE "public"."AmbulanceTransportReq" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Patient_Id" bigint NULL,
"Diagnoses" character varying(1024) NULL,
"RequestData" timestamptz NULL,
"UsageDate" timestamptz NULL,
"Address" character varying(100) NULL,
"RtRw" character varying(10) NULL,
"Province_Code" character varying(2) NULL,
"Regency_Code" character varying(4) NULL,
"District_Code" character varying(6) NULL,
"Village_Code" character varying(10) NULL,
"Facility_Code" character varying(10) NULL,
"Needs_Code" character varying(10) NULL,
"Contact_Name" character varying(100) NULL,
"Contact_Relationship_Code" character varying(10) NULL,
"Contact_PhoneNumber" character varying(20) NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_AmbulanceTransportReq_District" FOREIGN KEY ("District_Code") REFERENCES "public"."District" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_AmbulanceTransportReq_Patient" FOREIGN KEY ("Patient_Id") REFERENCES "public"."Patient" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_AmbulanceTransportReq_Province" FOREIGN KEY ("Province_Code") REFERENCES "public"."Province" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_AmbulanceTransportReq_Regency" FOREIGN KEY ("Regency_Code") REFERENCES "public"."Regency" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_AmbulanceTransportReq_Village" FOREIGN KEY ("Village_Code") REFERENCES "public"."Village" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "Vehicle" table
CREATE TABLE "public"."Vehicle" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Type_Code" text NULL,
"PoliceNumber" text NULL,
"FrameNumber" text NULL,
"RegNumber" text NULL,
"AvailableStatus" boolean NULL,
PRIMARY KEY ("Id")
);
-- Create "VehicleHist" table
CREATE TABLE "public"."VehicleHist" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Vehicle_Id" bigint NULL,
"Date" timestamptz NULL,
"Data" text NULL,
"Crud_Code" text NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_VehicleHist_Vehicle" FOREIGN KEY ("Vehicle_Id") REFERENCES "public"."Vehicle" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
+5 -2
View File
@@ -1,4 +1,4 @@
h1:Y15nC3Bp3DWNym7hAvXkF9zFwkHh8nQDpxcNrxQgYhE=
h1:5BOKtrJDl7mHDO/coJzV0ot0hVU9OVg5eP5Wg+zsIGo=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -43,4 +43,7 @@ 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:4BncQdDOasRZJkzVJrSJJA7091A9VPNVx/faUCUPhBM=
20251016011023.sql h1:9JB9eFZKURK5RoCVDKR6glSvdJ8NTXrN7K/4q51zkz4=
20251016062912.sql h1:v21euwdu/4JCN3E2LFO4Iav4d7FEiAVH0dyEltmIeMw=
@@ -0,0 +1,45 @@
package ambulance_transport_req
import (
ecore "simrs-vx/internal/domain/base-entities/core"
eds "simrs-vx/internal/domain/main-entities/district"
ept "simrs-vx/internal/domain/main-entities/patient"
epr "simrs-vx/internal/domain/main-entities/province"
erg "simrs-vx/internal/domain/main-entities/regency"
evl "simrs-vx/internal/domain/main-entities/village"
"time"
eren "simrs-vx/internal/domain/references/encounter"
erp "simrs-vx/internal/domain/references/person"
)
type AmbulanceTransportReq struct {
ecore.Main
Patient_Id *uint `json:"patient_id"`
Patient *ept.Patient `json:"patient,omitempty" gorm:"foreignKey:Patient_Id;references:Id"`
Diagnoses *string `json:"diagnoses" gorm:"size:1024"`
RequestData *time.Time `json:"requestData"`
UsageDate *time.Time `json:"usageDate"`
Address *string `json:"address" gorm:"size:100"`
RtRw *string `json:"rtRw" gorm:"size:10"`
Province_Code *string `json:"province_code" gorm:"size:2"`
Province *epr.Province `json:"province,omitempty" gorm:"foreignKey:Province_Code;references:Code"`
Regency_Code *string `json:"regency_code" gorm:"size:4"`
Regency *erg.Regency `json:"regency,omitempty" gorm:"foreignKey:Regency_Code;references:Code"`
District_Code *string `json:"district_code" gorm:"size:6"`
District *eds.District `json:"district,omitempty" gorm:"foreignKey:District_Code;references:Code"`
Village_Code *string `json:"village_code" gorm:"size:10"`
Village *evl.Village `json:"village,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
Facility_Code *eren.AmbulanceFacilityCode `json:"facility_code" gorm:"size:10"`
Needs_Code *eren.AmbulanceNeedsCode `json:"needs_code" gorm:"size:10"`
Contact_Name *string `json:"contact_name" gorm:"size:100"`
Contact_Relationship_Code *erp.RelationshipCode `json:"contact_relationship_code" gorm:"size:10"`
Contact_PhoneNumber *string `json:"contact_phoneNumber" gorm:"size:20"`
}
@@ -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"`
@@ -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 {
@@ -0,0 +1,17 @@
package vehicle_hist
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ev "simrs-vx/internal/domain/main-entities/vehicle"
erc "simrs-vx/internal/domain/references/common"
"time"
)
type VehicleHist struct {
ecore.Main // adjust this according to the needs
Vehicle_Id *uint `json:"vehicle_id"`
Vehicle *ev.Vehicle `json:"vehicle,omitempty" gorm:"foreignKey:Vehicle_Id;references:Id"`
Date *time.Time `json:"date"`
Data *string `json:"data"`
Crud_Code *erc.CrudCode `json:"crud_code"`
}
@@ -0,0 +1,15 @@
package vehicle
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ercl "simrs-vx/internal/domain/references/clinical"
)
type Vehicle struct {
ecore.Main // adjust this according to the needs
Type_Code *ercl.VehicleTypeCode `json:"type_code"`
PoliceNumber *string `json:"policeNumber"`
FrameNumber *string `json:"frameNumber"`
RegNumber *string `json:"regNumber"`
AvailableStatus bool `json:"availableStatus"`
}
@@ -10,6 +10,8 @@ type (
HeadToToeCode string
McuUrgencyLevelCode string
SoapiTypeCode string
MedicalAction string
VehicleTypeCode string
)
const (
@@ -101,6 +103,16 @@ const (
STCEarlyRehab SoapiTypeCode = "early-rehab" // Kajian Awal Rehab Medik
STCFunc SoapiTypeCode = "function" // Assessment Fungsi
STCProgress SoapiTypeCode = "progress" // CPPT
MAChemo MedicalAction = "chemo"
MAHemo MedicalAction = "hemo"
MAThalasemia MedicalAction = "thalasemia"
MAEchocardio MedicalAction = "echocardio"
MASpirometry MedicalAction = "spirometry"
VTCAmbulance VehicleTypeCode = "ambulance" // Ambulans
VTCTransport VehicleTypeCode = "transport" // Transport
VTCHearse VehicleTypeCode = "hearse" // Jenazah
)
type Soapi struct {
@@ -14,6 +14,7 @@ type (
PaymentMethodCode string
DataAvailabilityCode string
DataVerifiedCode string
CrudCode string
)
const (
@@ -91,6 +92,10 @@ const (
PMCInsurance PaymentMethodCode = "insurance" // Asuransi
PMCMembership PaymentMethodCode = "membership" // Member
CCCreate CrudCode = "c" // Create
CCRead CrudCode = "r" // Read
CCUpdate CrudCode = "u" // Update
CCDelete CrudCode = "d" // Delete
)
func GetDayCodes() map[DayCode]string {
@@ -1,18 +1,20 @@
package encounter
type (
EncounterClassCode string
QueueStatusCode string
DischargeMethodCode string
TransportationCode string
PersonConditionCode string
EmergencyClassCode string
OutpatientClassCode string
CheckupScopeCode string
AmbulatoryClassCode string
InpatientClassCode string
UploadCode string
ChemoClassCode string
EncounterClassCode string
QueueStatusCode string
DischargeMethodCode string
TransportationCode string
PersonConditionCode string
EmergencyClassCode string
OutpatientClassCode string
CheckupScopeCode string
AmbulatoryClassCode string
InpatientClassCode string
UploadCode string
ChemoClassCode string
AmbulanceFacilityCode string
AmbulanceNeedsCode string
)
const (
@@ -82,6 +84,12 @@ const (
CCCAdm ChemoClassCode = "adm" // Administrasi
CCCAct ChemoClassCode = "act" // Tindakan
AFCStd AmbulanceFacilityCode = "std" // Standar
AFCIcu AmbulanceFacilityCode = "icu" // ICU
ANCAssist AmbulanceNeedsCode = "assist" // Dengan Pendampingan
ANCNonassist AmbulanceNeedsCode = "non-assist" // Tanpa Pendampingan
)
func (ec EncounterClassCode) Code() string {
@@ -2,6 +2,7 @@ package migration
import (
adime "simrs-vx/internal/domain/main-entities/adime"
ambulancetransportreq "simrs-vx/internal/domain/main-entities/ambulance-transport-req"
ambulatory "simrs-vx/internal/domain/main-entities/ambulatory"
appointment "simrs-vx/internal/domain/main-entities/appointment"
chemo "simrs-vx/internal/domain/main-entities/chemo"
@@ -55,6 +56,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"
@@ -74,6 +76,8 @@ import (
unit "simrs-vx/internal/domain/main-entities/unit"
uom "simrs-vx/internal/domain/main-entities/uom"
user "simrs-vx/internal/domain/main-entities/user"
vehicle "simrs-vx/internal/domain/main-entities/vehicle"
vehiclehist "simrs-vx/internal/domain/main-entities/vehicle-hist"
village "simrs-vx/internal/domain/main-entities/village"
///BPJS
@@ -96,6 +100,7 @@ func getMainEntities() []any {
&person.Person{},
&personaddress.PersonAddress{},
&personcontact.PersonContact{},
&personinsurance.PersonInsurance{},
&pharmacycompany.PharmacyCompany{},
&diagnosesrc.DiagnoseSrc{},
&proceduresrc.ProcedureSrc{},
@@ -161,5 +166,8 @@ func getMainEntities() []any {
&internalreference.InternalReference{},
&vclaimsephist.VclaimSepHist{},
&vclaimsepprint.VclaimSepPrint{},
&vehicle.Vehicle{},
&vehiclehist.VehicleHist{},
&ambulancetransportreq.AmbulanceTransportReq{},
}
}