From e663fa0451bec53c3366be01110d43d812fead54 Mon Sep 17 00:00:00 2001 From: vanilia Date: Thu, 16 Oct 2025 13:31:51 +0700 Subject: [PATCH] add entity for vehicle, vehicle-hist, ambulancetransportreq --- .../migrations/20251016062912.sql | 54 +++++++++++++++++++ cmd/main-migration/migrations/atlas.sum | 7 +-- .../ambulance-transport-req/entity.go | 45 ++++++++++++++++ .../main-entities/vehicle-hist/entity.go | 17 ++++++ .../domain/main-entities/vehicle/entity.go | 15 ++++++ .../domain/references/clinical/clinical.go | 12 +++++ internal/domain/references/common/common.go | 5 ++ .../domain/references/encounter/encounter.go | 32 ++++++----- internal/interface/migration/main-entities.go | 6 +++ 9 files changed, 178 insertions(+), 15 deletions(-) create mode 100644 cmd/main-migration/migrations/20251016062912.sql create mode 100644 internal/domain/main-entities/ambulance-transport-req/entity.go create mode 100644 internal/domain/main-entities/vehicle-hist/entity.go create mode 100644 internal/domain/main-entities/vehicle/entity.go diff --git a/cmd/main-migration/migrations/20251016062912.sql b/cmd/main-migration/migrations/20251016062912.sql new file mode 100644 index 00000000..b9208471 --- /dev/null +++ b/cmd/main-migration/migrations/20251016062912.sql @@ -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 +); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 05c66cea..bb5cb4b0 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:qfP77w9XYWpAFDON1lo+vpqIYCSiPkVEyHXcYFC52Hk= +h1:5BOKtrJDl7mHDO/coJzV0ot0hVU9OVg5eP5Wg+zsIGo= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -44,5 +44,6 @@ h1:qfP77w9XYWpAFDON1lo+vpqIYCSiPkVEyHXcYFC52Hk= 20251014063537.sql h1:VZLXol0PTsTW21Epg6vBPsztWkDtcxup9F/z88EGgIg= 20251014063720.sql h1:2HVUyCV0ud3BJJDH2GEKZN/+IWLFPCsN1KqhP6csO14= 20251015045455.sql h1:MeLWmMhAOAz8b15Dd7IAQnt6JxjSml02XCXK22C0Lpg= -20251016010845.sql h1:MSUh26glEDyZ5BFiteYOm9mUCWw7aG9vv5TxYY+EidU= -20251016011023.sql h1:8oUBzIpzAYTo03yex+wLKacv32YjXmn4MsXtBFiQtzY= +20251016010845.sql h1:4BncQdDOasRZJkzVJrSJJA7091A9VPNVx/faUCUPhBM= +20251016011023.sql h1:9JB9eFZKURK5RoCVDKR6glSvdJ8NTXrN7K/4q51zkz4= +20251016062912.sql h1:v21euwdu/4JCN3E2LFO4Iav4d7FEiAVH0dyEltmIeMw= diff --git a/internal/domain/main-entities/ambulance-transport-req/entity.go b/internal/domain/main-entities/ambulance-transport-req/entity.go new file mode 100644 index 00000000..4392c4f6 --- /dev/null +++ b/internal/domain/main-entities/ambulance-transport-req/entity.go @@ -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"` +} diff --git a/internal/domain/main-entities/vehicle-hist/entity.go b/internal/domain/main-entities/vehicle-hist/entity.go new file mode 100644 index 00000000..0d91267d --- /dev/null +++ b/internal/domain/main-entities/vehicle-hist/entity.go @@ -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"` +} diff --git a/internal/domain/main-entities/vehicle/entity.go b/internal/domain/main-entities/vehicle/entity.go new file mode 100644 index 00000000..89661781 --- /dev/null +++ b/internal/domain/main-entities/vehicle/entity.go @@ -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"` +} diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index 5a9fc280..47872aa5 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -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 { diff --git a/internal/domain/references/common/common.go b/internal/domain/references/common/common.go index 2970e2a8..9e532b14 100644 --- a/internal/domain/references/common/common.go +++ b/internal/domain/references/common/common.go @@ -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 { diff --git a/internal/domain/references/encounter/encounter.go b/internal/domain/references/encounter/encounter.go index 93c49a33..5b9515ec 100644 --- a/internal/domain/references/encounter/encounter.go +++ b/internal/domain/references/encounter/encounter.go @@ -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 { diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index ea8ec1c0..ae155e9c 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -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" @@ -75,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 @@ -163,5 +166,8 @@ func getMainEntities() []any { &internalreference.InternalReference{}, &vclaimsephist.VclaimSepHist{}, &vclaimsepprint.VclaimSepPrint{}, + &vehicle.Vehicle{}, + &vehiclehist.VehicleHist{}, + &ambulancetransportreq.AmbulanceTransportReq{}, } }