Merge pull request #124 from dikstub-rssa/feat/control-letter-121

Feat/control letter 121
This commit is contained in:
Dwi Atmoko Purbo Sakti
2025-11-04 15:14:26 +07:00
committed by GitHub
22 changed files with 102 additions and 31 deletions
@@ -0,0 +1,2 @@
-- Modify "Chemo" table
ALTER TABLE "public"."Chemo" DROP COLUMN "Class_Code", ADD COLUMN "Bed" character varying(1024) NULL, ADD COLUMN "Needs" character varying(2048) NULL;
@@ -0,0 +1,19 @@
-- Modify "Ambulatory" table
ALTER TABLE "public"."Ambulatory" DROP CONSTRAINT "fk_Ambulatory_Encounter", ADD COLUMN "VisitMode_Code" text NULL, ADD CONSTRAINT "fk_Encounter_Ambulatory" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "Emergency" table
ALTER TABLE "public"."Emergency" DROP CONSTRAINT "fk_Emergency_Encounter", ADD CONSTRAINT "fk_Encounter_Emergency" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "Inpatient" table
ALTER TABLE "public"."Inpatient" DROP CONSTRAINT "fk_Inpatient_Encounter", ADD CONSTRAINT "fk_Encounter_Inpatient" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Create "Rehab" table
CREATE TABLE "public"."Rehab" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Encounter_Id" bigint NULL,
"Doctor_Id" bigint NULL,
"AllocatedVisitCount" bigint NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_Rehab_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_Rehab_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
@@ -0,0 +1,2 @@
-- Modify "ControlLetter" table
ALTER TABLE "public"."ControlLetter" ADD COLUMN "Doctor_Id" bigint NULL, ADD CONSTRAINT "fk_ControlLetter_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
+5 -2
View File
@@ -1,4 +1,4 @@
h1:zJVjtCkiWEF41JV7lzbRtI5mPZGz5bC8FaVruh3fmkY=
h1:2J5umJFoWClM/F8kKNyZFoDqrV1aL8PimwTG6Mx6syo=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -64,4 +64,7 @@ h1:zJVjtCkiWEF41JV7lzbRtI5mPZGz5bC8FaVruh3fmkY=
20251027091406.sql h1:eCZGtUkxAzEAqpC9UsGpP8Df9mS0DEOqSl885LgqpvM=
20251102002037.sql h1:lFJbuoZ2LMQnUNGdcwHVY3Xlfslgzu9t2WByT8yfOZI=
20251102091932.sql h1:rmdhb5m+P+fU8jROBZNyeYgZKuQvucsuljXv4ZVzvks=
20251103081637.sql h1:jqpMnygFceOJn0rI30GYWI2CKbOu6RzVqw2/Pji2Ka8=
20251103081637.sql h1:tf3BcwTeIw+oxMEisKDDfyKnBfalTLs8b0PJA8JWYxY=
20251104042334.sql h1:7PDMWOhmJywolAPKFZ14XaDBeMvcxShaXFN2IemNtzk=
20251104043530.sql h1:qvYVp3ysPf27f1BcoRNCFGovxuVE12lg9d6Xzda6zWU=
20251104080952.sql h1:+SMRSBPjP0qeLlaiIdff7hUnW2+1l1GJOWjP7fWPiGA=
@@ -2,7 +2,6 @@ package ambulatory
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ere "simrs-vx/internal/domain/references/encounter"
)
@@ -44,7 +43,6 @@ type MetaDto struct {
type ResponseDto struct {
ecore.Main
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty"`
Class_Code ere.AmbulatoryClassCode `json:"class_code"`
}
@@ -2,14 +2,12 @@ package ambulatory
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ere "simrs-vx/internal/domain/references/encounter"
)
type Ambulatory struct {
ecore.Main // adjust this according to the needs
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
Class_Code ere.AmbulatoryClassCode `json:"class_code" gorm:"size:10"`
ecore.Main // adjust this according to the needs
Encounter_Id *uint `json:"encounter_id"`
Class_Code ere.AmbulatoryClassCode `json:"class_code" gorm:"size:10"`
VisitMode_Code ere.VisitModeCode `json:"visitMode_code"`
}
@@ -9,7 +9,6 @@ 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 {
@@ -22,5 +21,6 @@ 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"`
Class_Code ere.ChemoClassCode `json:"class_code"`
Bed *string `json:"bed" gorm:"size:1024"`
Needs *string `json:"needs" gorm:"size:2048"`
}
@@ -12,6 +12,7 @@ import (
// internal - domain - main-entities
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
es "simrs-vx/internal/domain/main-entities/specialist"
ess "simrs-vx/internal/domain/main-entities/subspecialist"
@@ -23,6 +24,7 @@ type CreateDto struct {
Unit_Id *uint `json:"unit_id"`
Specialist_Id *uint `json:"specialist_id"`
Subspecialist_Id *uint `json:"subspecialist_id"`
Doctor_Id *uint `json:"doctor_id"`
Date *time.Time `json:"date"`
}
@@ -37,6 +39,7 @@ type FilterDto struct {
Unit_Id *uint `json:"unit-id"`
Specialist_Id *uint `json:"specialist-id"`
Subspecialist_Id *uint `json:"subspecialist-id"`
Doctor_Id *uint `json:"doctor-id"`
Date *time.Time `json:"date"`
}
@@ -77,6 +80,8 @@ type ResponseDto struct {
Specialist *es.Specialist `json:"specialist,omitempty"`
Subspecialist_Id *uint `json:"subspecialist_id"`
Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"`
Doctor_Id *uint `json:"doctor_id"`
Doctor *ed.Doctor `json:"doctor,omitempty"`
Date *time.Time `json:"date"`
}
@@ -90,6 +95,8 @@ func (d ControlLetter) ToResponse() ResponseDto {
Specialist: d.Specialist,
Subspecialist_Id: d.Subspecialist_Id,
Subspecialist: d.Subspecialist,
Doctor_Id: d.Doctor_Id,
Doctor: d.Doctor,
Date: d.Date,
}
resp.Main = d.Main
@@ -4,6 +4,7 @@ import (
"time"
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
es "simrs-vx/internal/domain/main-entities/specialist"
ess "simrs-vx/internal/domain/main-entities/subspecialist"
@@ -20,5 +21,7 @@ type ControlLetter struct {
Specialist *es.Specialist `json:"specialist" gorm:"foreignKey:Specialist_Id;references:Id"`
Subspecialist_Id *uint `json:"subspecialist_id"`
Subspecialist *ess.Subspecialist `json:"subspecialist" gorm:"foreignKey:Subspecialist_Id;references:Id"`
Doctor_Id *uint `json:"doctor_id"`
Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Id;references:Id"`
Date *time.Time `json:"date"`
}
@@ -2,7 +2,6 @@ package emergency
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ere "simrs-vx/internal/domain/references/encounter"
)
@@ -44,12 +43,14 @@ type MetaDto struct {
type ResponseDto struct {
ecore.Main
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty"`
Class_Code ere.EmergencyClassCode `json:"class_code"`
}
func (d Emergency) ToResponse() ResponseDto {
resp := ResponseDto{}
resp := ResponseDto{
Encounter_Id: d.Encounter_Id,
Class_Code: d.Class_Code,
}
resp.Main = d.Main
return resp
}
@@ -2,14 +2,11 @@ package emergency
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ere "simrs-vx/internal/domain/references/encounter"
)
type Emergency struct {
ecore.Main // adjust this according to the needs
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
Class_Code ere.EmergencyClassCode `json:"class_code" gorm:"size:10"`
}
@@ -3,13 +3,17 @@ package encounter
import (
ecore "simrs-vx/internal/domain/base-entities/core"
evs "simrs-vx/internal/domain/bpjs-entities/vclaim-sep"
eam "simrs-vx/internal/domain/main-entities/ambulatory"
ea "simrs-vx/internal/domain/main-entities/appointment"
edc "simrs-vx/internal/domain/main-entities/death-cause"
ed "simrs-vx/internal/domain/main-entities/doctor"
eem "simrs-vx/internal/domain/main-entities/emergency"
ee "simrs-vx/internal/domain/main-entities/employee"
eip "simrs-vx/internal/domain/main-entities/inpatient"
ei "simrs-vx/internal/domain/main-entities/insurance-company"
eir "simrs-vx/internal/domain/main-entities/internal-reference"
ep "simrs-vx/internal/domain/main-entities/patient"
er "simrs-vx/internal/domain/main-entities/rehab/base"
es "simrs-vx/internal/domain/main-entities/specialist"
ess "simrs-vx/internal/domain/main-entities/subspecialist"
eu "simrs-vx/internal/domain/main-entities/unit"
@@ -61,6 +65,10 @@ type Encounter struct {
InternalReferences *[]eir.InternalReference `json:"internalReferences,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
DeathCause *edc.DeathCause `json:"deathCause,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
NewStatus bool `json:"newStatus"`
Ambulatory *eam.Ambulatory `json:"ambulatory,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
Emergency *eem.Emergency `json:"emergency,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
Inpatient *eip.Inpatient `json:"inpatient,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
Rehab *er.Basic `json:"rehab,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
}
func (d Encounter) IsDone() bool {
@@ -2,7 +2,6 @@ package inpatient
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ei "simrs-vx/internal/domain/main-entities/infra"
ere "simrs-vx/internal/domain/references/encounter"
@@ -48,7 +47,6 @@ type MetaDto struct {
type ResponseDto struct {
ecore.Main
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty"`
Class_Code ere.InpatientClassCode `json:"class_code"`
Infra_Id *uint16 `json:"infra_id"`
Infra *ei.Infra `json:"infra,omitempty"`
@@ -57,7 +55,6 @@ type ResponseDto struct {
func (d Inpatient) ToResponse() ResponseDto {
resp := ResponseDto{
Encounter_Id: d.Encounter_Id,
Encounter: d.Encounter,
Class_Code: d.Class_Code,
Infra_Id: d.Infra_Id,
Infra: d.Infra,
@@ -2,16 +2,13 @@ package inpatient
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ei "simrs-vx/internal/domain/main-entities/infra"
ere "simrs-vx/internal/domain/references/encounter"
)
type Inpatient struct {
ecore.Main // adjust this according to the needs
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
Class_Code ere.InpatientClassCode `json:"class_code" gorm:"size:10"`
Infra_Id *uint16 `json:"infra_id"`
Infra *ei.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"`
@@ -0,0 +1,18 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
)
type Basic struct {
ecore.Main // adjust this according to the needs
Encounter_Id *uint `json:"encounter_id"`
Doctor_Id *uint `json:"doctor_id"`
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"`
AllocatedVisitCount *int `json:"allocatedVisitCount"`
}
func (Basic) TableName() string {
return "Rehab"
}
@@ -0,0 +1,11 @@
package rehab
import (
ee "simrs-vx/internal/domain/main-entities/encounter"
eb "simrs-vx/internal/domain/main-entities/rehab/base"
)
type Rehab struct {
eb.Basic
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
}
@@ -113,11 +113,12 @@ const (
MULCPF McuUrgencyLevelCode = "priority-form" // Form Prioritas
MULCRT McuUrgencyLevelCode = "routine" // Pemeriksaan Rutin
STCEarlyNurse SoapiTypeCode = "early-nurse" // Kajian Awal Medis
//STCEarlyNurse SoapiTypeCode = "early-nurse" // Kajian Awal Medis
STCEEarlyMedic SoapiTypeCode = "early-medic" // Kajian Awal Rehab Medis
STCEarlyRehab SoapiTypeCode = "early-rehab" // Kajian Awal Rehab Medik
STCFunc SoapiTypeCode = "function" // Assessment Fungsi
STCProgress SoapiTypeCode = "progress" // CPPT
STCDevRecord SoapiTypeCode = "dev-record" // Catatan Perkembangan
MAChemo MedicalAction = "chemo"
MAHemo MedicalAction = "hemo"
@@ -18,6 +18,7 @@ type (
RefTypeCode string
AllPaymentMethodCode string
SEPRefTypeCode string
VisitModeCode string
)
const (
@@ -69,10 +70,12 @@ const (
CSCPLab CheckupScopeCode = "pa-lab" // Patology Anatomy Laboratorium
CSCRad CheckupScopeCode = "radiology" // Radiology
ACCReg AmbulatoryClassCode = "reg" // Regular
ACCRme AmbulatoryClassCode = "rme" // Rehab Medik
ACCCad AmbulatoryClassCode = "chemo-adm" // Chemotherapy
ACCCac AmbulatoryClassCode = "chemo-act" // Chemotherapy
ACCReg AmbulatoryClassCode = "reg" // Regular
// ACCRehab ACCRme AmbulatoryClassCode = "rme" // Rehab Medik
// ACCCad AmbulatoryClassCode = "chemo-adm" // Chemotherapy
// ACCCac AmbulatoryClassCode = "chemo-act" // Chemotherapy
ACCRehab AmbulatoryClassCode = "rehab" // Rehab Medik
ACCChemo AmbulatoryClassCode = "chemo" // Rehab Medik
ICCIp InpatientClassCode = "ip" // Regular Rawat Inap
ICCICU InpatientClassCode = "icu" // ICU
@@ -106,6 +109,9 @@ const (
SRTCInternal SEPRefTypeCode = "internal" // Rujukan Internal
SRTCExternal SEPRefTypeCode = "external" // Faskes Lain
VMCAdm VisitModeCode = "adm"
VMCSeries VisitModeCode = "series"
)
func (ec EncounterClassCode) Code() string {
@@ -74,6 +74,7 @@ import (
proceduresrc "simrs-vx/internal/domain/main-entities/procedure-src"
province "simrs-vx/internal/domain/main-entities/province"
regency "simrs-vx/internal/domain/main-entities/regency"
rehab "simrs-vx/internal/domain/main-entities/rehab"
responsibledoctorhist "simrs-vx/internal/domain/main-entities/responsible-doctor-hist"
room "simrs-vx/internal/domain/main-entities/room"
sbar "simrs-vx/internal/domain/main-entities/sbar"
@@ -195,5 +196,6 @@ func getMainEntities() []any {
&admemployeehist.AdmEmployeeHist{},
&vclaimmember.VclaimMember{},
&controlletter.ControlLetter{},
&rehab.Rehab{},
}
}
@@ -28,7 +28,7 @@ func CheckClassCode(input *string) (ere.AmbulatoryClassCode, error) {
if input != nil {
subCode := ere.AmbulatoryClassCode(*input)
switch subCode {
case ere.ACCReg, ere.ACCRme, ere.ACCCad, ere.ACCCac:
case ere.ACCReg, ere.ACCRehab, ere.ACCChemo:
return subCode, nil
default:
return "", errors.New("unknown sub class code")
@@ -21,5 +21,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ControlLetter) {
data.Unit_Id = inputSrc.Unit_Id
data.Specialist_Id = inputSrc.Specialist_Id
data.Subspecialist_Id = inputSrc.Subspecialist_Id
data.Doctor_Id = inputSrc.Doctor_Id
data.Date = inputSrc.Date
}
@@ -104,7 +104,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
return err
}
if subCode == ere.ACCCac || subCode == ere.ACCCad {
if subCode == ere.ACCChemo {
chemoCreate := ec.CreateDto{
Encounter_Id: &data.Id,
Status_Code: erc.DVCNew,