From ec08939fa81068c761430e39508992762eaa57fe Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 14 Oct 2025 13:03:26 +0700 Subject: [PATCH] add sever table for vclaim, update encounter --- cmd/bpjs-api/config.yml-example | 66 +++++++++++++++++++ cmd/bpjs-api/main.go | 14 ++++ .../migrations/20251014060047.sql | 36 ++++++++++ cmd/main-migration/migrations/atlas.sum | 5 +- .../bpjs-entities/vclaim-sep-hist/dto.go | 1 + .../bpjs-entities/vclaim-sep-hist/entitiy.go | 12 ++++ .../bpjs-entities/vclaim-sep-print/dto.go | 1 + .../bpjs-entities/vclaim-sep-print/entity.go | 13 ++++ .../domain/bpjs-entities/vclaim-sep/dto.go | 1 + .../bpjs-entities/vclaim-sep/entitiy.go | 11 ++++ .../domain/main-entities/encounter/entity.go | 13 ++++ .../interface/bpjs-handler/bpjs-handler.go | 52 +++++++++++++++ internal/interface/migration/main-entities.go | 8 +++ 13 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 cmd/bpjs-api/config.yml-example create mode 100644 cmd/bpjs-api/main.go create mode 100644 cmd/main-migration/migrations/20251014060047.sql create mode 100644 internal/domain/bpjs-entities/vclaim-sep-hist/dto.go create mode 100644 internal/domain/bpjs-entities/vclaim-sep-hist/entitiy.go create mode 100644 internal/domain/bpjs-entities/vclaim-sep-print/dto.go create mode 100644 internal/domain/bpjs-entities/vclaim-sep-print/entity.go create mode 100644 internal/domain/bpjs-entities/vclaim-sep/dto.go create mode 100644 internal/domain/bpjs-entities/vclaim-sep/entitiy.go create mode 100644 internal/interface/bpjs-handler/bpjs-handler.go diff --git a/cmd/bpjs-api/config.yml-example b/cmd/bpjs-api/config.yml-example new file mode 100644 index 00000000..f131a725 --- /dev/null +++ b/cmd/bpjs-api/config.yml-example @@ -0,0 +1,66 @@ +appCfg: + fullName: BPJS Bridge + codeName: simrs-vx + version: 0.1.0 + env: development + lang: en + +httpCfg: + host: + port: + +dbCfg: + dsn: + maxOpenConns: 5 + maxIdleConns: 5 + maxIdleTime: 100 + +multiDbCfg: + - dbs : + name: + dsn: + maxOpenConns: + maxIdleConns: + maxIdleTime: + - bpjs + name: bpjs + dsn: + maxOpenConns: + maxIdleConns: + maxIdleTime: + +loggerCfg: + hideTime: + hideLevel: + +msCfg: + dsn: + +langCfg: + active: + path: + fileName: + +minioCfg: + endpoint: + region: + accessKey: + secretKey: + useSsl: + bucketName: + - patient + +corsCfg: + allowedOrigin: + allowedMethod: + +satuSehatCfg: + host: localhost:8200 + +bpjsCfg: + host: localhost:8200 + +corsCfg: + allowedOrigins: + - http://example.com + allowedMethod: \ No newline at end of file diff --git a/cmd/bpjs-api/main.go b/cmd/bpjs-api/main.go new file mode 100644 index 00000000..74be3afd --- /dev/null +++ b/cmd/bpjs-api/main.go @@ -0,0 +1,14 @@ +package main + +import ( + a "github.com/karincake/apem" + d "github.com/karincake/apem/db-gorm-pg" + l "github.com/karincake/apem/logger-zerolog" + m "github.com/karincake/apem/ms-redis" + + h "simrs-vx/internal/interface/main-handler" +) + +func main() { + a.Run(h.SetRoutes(), &l.O, &m.O, &d.O) +} diff --git a/cmd/main-migration/migrations/20251014060047.sql b/cmd/main-migration/migrations/20251014060047.sql new file mode 100644 index 00000000..1d13853a --- /dev/null +++ b/cmd/main-migration/migrations/20251014060047.sql @@ -0,0 +1,36 @@ +-- Create "VClaimSepHist" table +CREATE TABLE "public"."VClaimSepHist" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "RequestPayload" text NULL, + "ResponseBody" text NULL, + "Message" text NULL, + PRIMARY KEY ("Id") +); +-- Modify "Encounter" table +ALTER TABLE "public"."Encounter" ADD COLUMN "PaymentMethod_Code" character varying(10) NULL, ADD COLUMN "InsuranceCompany_Id" bigint NULL, ADD COLUMN "Member_Number" character varying(20) NULL, ADD COLUMN "Ref_Number" character varying(20) NULL, ADD COLUMN "Trx_Number" character varying(20) NULL, ADD COLUMN "Adm_Employee_Id" bigint NULL, ADD CONSTRAINT "uni_Encounter_Member_Number" UNIQUE ("Member_Number"), ADD CONSTRAINT "uni_Encounter_Ref_Number" UNIQUE ("Ref_Number"), ADD CONSTRAINT "uni_Encounter_Trx_Number" UNIQUE ("Trx_Number"), ADD CONSTRAINT "fk_Encounter_Adm_Employee" FOREIGN KEY ("Adm_Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Encounter_InsuranceCompany" FOREIGN KEY ("InsuranceCompany_Id") REFERENCES "public"."InsuranceCompany" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Create "VClaimSep" table +CREATE TABLE "public"."VClaimSep" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Number" character varying(19) NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_VClaimSep_Number" UNIQUE ("Number"), + CONSTRAINT "fk_Encounter_VclaimSep" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "VClaimSepPrint" table +CREATE TABLE "public"."VClaimSepPrint" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "VclaimSep_Number" character varying(19) NULL, + "Counter" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_VClaimSepPrint_VclaimSep" FOREIGN KEY ("VclaimSep_Number") REFERENCES "public"."VClaimSep" ("Number") 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 4d946518..5b2a1d8a 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:oj0SGm9EAjoGuXcWbue8k9Uqy/W1N7iFjPky7Cg7G6s= +h1:awmI0os0fmaoSemyQuKI5+2Xb4eCH+Jgqm8dZIsXskw= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -39,4 +39,5 @@ h1:oj0SGm9EAjoGuXcWbue8k9Uqy/W1N7iFjPky7Cg7G6s= 20251010072711.sql h1:ZJNqR2piyu8xJhBvVABSlnGEoKSKae3wuEs+wshPe4k= 20251013044536.sql h1:0Xjw8fNILiT8nnfrJDZgQnPf3dntmIoilbapnih8AE4= 20251013051438.sql h1:lfSuw5mgJnePBJamvhZ81osFIouXeiIEiSZ/evdwo48= -20251013081808.sql h1:AqNqfPWEI8fgozZ+EhIT1pKsbN+0R8njTTu++rF6dKA= +20251013081808.sql h1:ijgjNX08G6GBjA/ks8EKtb7P7Y7Cg7zbhqEOruGnv6M= +20251014060047.sql h1:sX9aIpf35MbyclzP4+ULVabPTMV8E9G+6caCsg4WWbQ= diff --git a/internal/domain/bpjs-entities/vclaim-sep-hist/dto.go b/internal/domain/bpjs-entities/vclaim-sep-hist/dto.go new file mode 100644 index 00000000..778154cb --- /dev/null +++ b/internal/domain/bpjs-entities/vclaim-sep-hist/dto.go @@ -0,0 +1 @@ +package vclaimsephist diff --git a/internal/domain/bpjs-entities/vclaim-sep-hist/entitiy.go b/internal/domain/bpjs-entities/vclaim-sep-hist/entitiy.go new file mode 100644 index 00000000..a5a22da3 --- /dev/null +++ b/internal/domain/bpjs-entities/vclaim-sep-hist/entitiy.go @@ -0,0 +1,12 @@ +package vclaimsephist + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type VClaimSepHist struct { + ecore.Main + RequestPayload *string `json:"requestPayload"` + ResponseBody *string `json:"responseBody"` + Message *string `json:"message"` +} diff --git a/internal/domain/bpjs-entities/vclaim-sep-print/dto.go b/internal/domain/bpjs-entities/vclaim-sep-print/dto.go new file mode 100644 index 00000000..b975dd96 --- /dev/null +++ b/internal/domain/bpjs-entities/vclaim-sep-print/dto.go @@ -0,0 +1 @@ +package vclaimsepprint diff --git a/internal/domain/bpjs-entities/vclaim-sep-print/entity.go b/internal/domain/bpjs-entities/vclaim-sep-print/entity.go new file mode 100644 index 00000000..d1a0a156 --- /dev/null +++ b/internal/domain/bpjs-entities/vclaim-sep-print/entity.go @@ -0,0 +1,13 @@ +package vclaimsepprint + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + evs "simrs-vx/internal/domain/bpjs-entities/vclaim-sep" +) + +type VClaimSepPrint struct { + ecore.Main + VclaimSep_Number *string `json:"vclaimSep_number"` + VclaimSep *evs.VClaimSep `json:"vclaimSep,omitempty" gorm:"foreignKey:VclaimSep_Number;references:Number"` + Counter *uint `json:"counter"` +} diff --git a/internal/domain/bpjs-entities/vclaim-sep/dto.go b/internal/domain/bpjs-entities/vclaim-sep/dto.go new file mode 100644 index 00000000..ce4c6f55 --- /dev/null +++ b/internal/domain/bpjs-entities/vclaim-sep/dto.go @@ -0,0 +1 @@ +package vclaimsep diff --git a/internal/domain/bpjs-entities/vclaim-sep/entitiy.go b/internal/domain/bpjs-entities/vclaim-sep/entitiy.go new file mode 100644 index 00000000..8cbdfce6 --- /dev/null +++ b/internal/domain/bpjs-entities/vclaim-sep/entitiy.go @@ -0,0 +1,11 @@ +package vclaimsep + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type VClaimSep struct { + ecore.Main + Encounter_Id *uint `json:"encounter_id"` + Number *string `json:"number" gorm:"unique;size:19"` +} diff --git a/internal/domain/main-entities/encounter/entity.go b/internal/domain/main-entities/encounter/entity.go index 87833b37..321e838f 100644 --- a/internal/domain/main-entities/encounter/entity.go +++ b/internal/domain/main-entities/encounter/entity.go @@ -2,12 +2,16 @@ package encounter import ( ecore "simrs-vx/internal/domain/base-entities/core" + evs "simrs-vx/internal/domain/bpjs-entities/vclaim-sep" ea "simrs-vx/internal/domain/main-entities/appointment" ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/employee" + ei "simrs-vx/internal/domain/main-entities/insurance-company" ep "simrs-vx/internal/domain/main-entities/patient" es "simrs-vx/internal/domain/main-entities/specialist" ess "simrs-vx/internal/domain/main-entities/subspecialist" eu "simrs-vx/internal/domain/main-entities/unit" + erc "simrs-vx/internal/domain/references/common" ere "simrs-vx/internal/domain/references/encounter" "time" @@ -26,8 +30,16 @@ type Encounter struct { Subspecialist_Id *uint16 `json:"subspecialist_id"` Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"` VisitDate time.Time `json:"visitDate"` + PaymentMethod_Code erc.PaymentMethodCode `json:"paymentMethod_code" gorm:"size:10"` + InsuranceCompany_Id *uint `json:"insuranceCompany_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"` + Adm_Employee *ee.Employee `json:"admEmployee,omitempty" gorm:"foreignKey:Adm_Employee_Id;references:Id"` Responsible_Doctor_Id *uint `json:"responsible_doctor_id"` Responsible_Doctor *ed.Doctor `json:"responsible_doctor,omitempty" gorm:"foreignKey:Responsible_Doctor_Id;references:Id"` DischargeMethod_Code *ere.DischargeMethodCode `json:"dischargeMethod_code" gorm:"size:16"` @@ -39,6 +51,7 @@ type Encounter struct { AdmDischargeEducation *string `json:"admDischargeEducation"` DischargeReason *string `json:"dischargeReason"` Status_Code erc.DataStatusCode `json:"status_code" gorm:"size:10"` + VclaimSep *evs.VClaimSep `json:"vclaimSep,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` } func (d Encounter) IsDone() bool { diff --git a/internal/interface/bpjs-handler/bpjs-handler.go b/internal/interface/bpjs-handler/bpjs-handler.go new file mode 100644 index 00000000..a3d86116 --- /dev/null +++ b/internal/interface/bpjs-handler/bpjs-handler.go @@ -0,0 +1,52 @@ +package bpjshandler + +import ( + "net/http" + + /******************** main / transaction ********************/ + + /******************** actor ********************/ + + /******************** external ********************/ + a "github.com/karincake/apem" + + /******************** infra ********************/ + gs "simrs-vx/internal/infra/gorm-setting" + minio "simrs-vx/internal/infra/minio" + ssdb "simrs-vx/internal/infra/ss-db" + + /******************** pkg ********************/ + cmw "simrs-vx/pkg/cors-manager-mw" + lh "simrs-vx/pkg/lang-helper" + handlerlogger "simrs-vx/pkg/middleware/handler-logger" + mh "simrs-vx/pkg/minio-helper" + zlc "simrs-vx/pkg/zerolog-ctx" + + /******************** sources ********************/ + ///// Internal + validation "simrs-vx/internal/interface/main-handler/helper/validation" + "simrs-vx/internal/interface/main-handler/home" +) + +// One place route to relatively easier to manage, ESPECIALLY in tracking +func SetRoutes() http.Handler { + ///// + a.RegisterExtCall(gs.Adjust) + a.RegisterExtCall(zlc.Adjust) + a.RegisterExtCall(ssdb.SetInstance) + a.RegisterExtCall(lh.Populate) + a.RegisterExtCall(minio.Connect) + a.RegisterExtCall(mh.I.SetClient) + a.RegisterExtCall(validation.RegisterValidation) + + r := http.NewServeMux() + + /******************** Main ********************/ + r.HandleFunc("/", home.Home) + + /******************** actor ********************/ + + /******************** sources ********************/ + + return cmw.SetCors(handlerlogger.SetLog(r)) +} diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 41bb18db..82b14f23 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -75,6 +75,11 @@ import ( uom "simrs-vx/internal/domain/main-entities/uom" user "simrs-vx/internal/domain/main-entities/user" village "simrs-vx/internal/domain/main-entities/village" + + ///BPJS + vclaimsep "simrs-vx/internal/domain/bpjs-entities/vclaim-sep" + vclaimsephist "simrs-vx/internal/domain/bpjs-entities/vclaim-sep-hist" + vclaimsepprint "simrs-vx/internal/domain/bpjs-entities/vclaim-sep-print" ) func getMainEntities() []any { @@ -123,6 +128,7 @@ func getMainEntities() []any { &personrelative.PersonRelative{}, &patient.Patient{}, &appointment.Appointment{}, + &vclaimsep.VClaimSep{}, &encounter.Encounter{}, &laborant.Laborant{}, &specialist.Specialist{}, @@ -153,5 +159,7 @@ func getMainEntities() []any { &midwife.Midwife{}, &postalregion.PostalRegion{}, &internalreference.InternalReference{}, + &vclaimsephist.VClaimSepHist{}, + &vclaimsepprint.VClaimSepPrint{}, } }