Merge branch 'migration-vanilia' of https://github.com/dikstub-rssa/simrs-be into feat/encounter-adjustment-142
This commit is contained in:
@@ -6,8 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type Ambulatory struct {
|
||||
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"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Class_Code ere.AmbulatoryClassCode `json:"class_code" gorm:"size:10"`
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ type Encounter struct {
|
||||
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"`
|
||||
Rehab_Adm *er.Basic `json:"rehab_adm,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Rehab_Series *[]er.Basic `json:"rehab_series,omitempty" gorm:"foreignKey:Parent_Encounter_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d Encounter) IsDone() bool {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package internal_reference
|
||||
|
||||
import (
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
eu "simrs-vx/internal/domain/main-entities/unit"
|
||||
@@ -8,9 +10,10 @@ import (
|
||||
|
||||
type InternalReference struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Unit_Id *uint16 `json:"unit_id"`
|
||||
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Unit_Id *uint16 `json:"unit_id"`
|
||||
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"`
|
||||
Status_Code *erc.DataApprovalCode `json:"status_code"`
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
"time"
|
||||
|
||||
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"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Parent_Encounter_Id *uint `json:"parent_encounter_id"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
AllocatedVisitCount *int `json:"allocatedVisitCount"`
|
||||
ExpiredAt *time.Time `json:"expiredAt"`
|
||||
VisitMode_Code *ere.VisitModeCode `json:"visitMode_code"`
|
||||
Status_Code *erc.DataStatusCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (Basic) TableName() string {
|
||||
|
||||
@@ -15,6 +15,7 @@ type (
|
||||
DataAvailabilityCode string
|
||||
DataVerifiedCode string
|
||||
CrudCode string
|
||||
DataApprovalCode string
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -96,6 +97,10 @@ const (
|
||||
CCRead CrudCode = "r" // Read
|
||||
CCUpdate CrudCode = "u" // Update
|
||||
CCDelete CrudCode = "d" // Delete
|
||||
|
||||
DACNew DataApprovalCode = "new"
|
||||
DACApproved DataApprovalCode = "approved"
|
||||
DACRejected DataApprovalCode = "rejected"
|
||||
)
|
||||
|
||||
func GetDayCodes() map[DayCode]string {
|
||||
|
||||
@@ -19,6 +19,7 @@ type (
|
||||
AllPaymentMethodCode string
|
||||
SEPRefTypeCode string
|
||||
VisitModeCode string
|
||||
PolySwitchCode string
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,18 +33,18 @@ const (
|
||||
QSCCancel QueueStatusCode = "cancel" // Dibatalkan
|
||||
QSCSkip QueueStatusCode = "skip" // Dilewati
|
||||
|
||||
DMCHome DischargeMethodCode = "home" // Pulang
|
||||
DMCHomeReq DischargeMethodCode = "home-request" // Pulang Atas Permintaan Sendiri
|
||||
DMCConsulBack DischargeMethodCode = "consul-back" // Konsultasi Balik / Lanjutan
|
||||
DMCConsulPoly DischargeMethodCode = "consul-poly" // Konsultasi Poliklinik Lain
|
||||
DMCConsulExecutive DischargeMethodCode = "consul-executive" // Konsultasi Antar Dokter Eksekutif
|
||||
DMCConsulChDay DischargeMethodCode = "consul-ch-day" // Konsultasi Hari Lain
|
||||
DMCEmergency DischargeMethodCode = "emergency" // Rujuk IGD
|
||||
DMCEmergencyCovid DischargeMethodCode = "emergency-covid" // Rujuk IGD Covid
|
||||
DMCInpatient DischargeMethodCode = "inpatient" // Rujuk Rawat Inap
|
||||
DMCExtRef DischargeMethodCode = "external" // Rujuk Faskes Lain
|
||||
DMCDeath DischargeMethodCode = "death" // Meninggal
|
||||
DMCDeathOnArrival DischargeMethodCode = "death-on-arrival" // Meninggal Saat Tiba
|
||||
DMCHome DischargeMethodCode = "home" // Pulang
|
||||
DMCHomeReq DischargeMethodCode = "home-request" // Pulang Atas Permintaan Sendiri
|
||||
DMCConsulBack DischargeMethodCode = "consul-back" // Konsultasi Balik / Lanjutan
|
||||
//DMCConsulPoly DischargeMethodCode = "consul-poly" // Konsultasi Poliklinik Lain
|
||||
//DMCConsulExecutive DischargeMethodCode = "consul-executive" // Konsultasi Antar Dokter Eksekutif
|
||||
DMCConsulChDay DischargeMethodCode = "consul-ch-day" // Konsultasi Hari Lain
|
||||
DMCEmergency DischargeMethodCode = "emergency" // Rujuk IGD
|
||||
DMCEmergencyCovid DischargeMethodCode = "emergency-covid" // Rujuk IGD Covid
|
||||
DMCInpatient DischargeMethodCode = "inpatient" // Rujuk Rawat Inap
|
||||
DMCExtRef DischargeMethodCode = "external" // Rujuk Faskes Lain
|
||||
DMCDeath DischargeMethodCode = "death" // Meninggal
|
||||
DMCDeathOnArrival DischargeMethodCode = "death-on-arrival" // Meninggal Saat Tiba
|
||||
|
||||
TCAmbulance TransportationCode = "ambulance" // Ambulans
|
||||
TCCar TransportationCode = "car" // Mobil
|
||||
@@ -112,6 +113,9 @@ const (
|
||||
|
||||
VMCAdm VisitModeCode = "adm"
|
||||
VMCSeries VisitModeCode = "series"
|
||||
|
||||
PSCConsulPoly PolySwitchCode = "consul-poly" // Konsultasi Poliklinik Lain
|
||||
PSCConsulExecutive PolySwitchCode = "consul-executive" // Konsultasi Antar Dokter Eksekutif
|
||||
)
|
||||
|
||||
func (ec EncounterClassCode) Code() string {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package encounter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
e "simrs-vx/internal/domain/main-entities/encounter"
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
@@ -13,42 +12,41 @@ import (
|
||||
const dataValidationFail = "data-validation-fail"
|
||||
|
||||
func validateRequestCheckout(w http.ResponseWriter, i e.DischargeDto) (valid bool) {
|
||||
switch *i.Discharge_Method_Code {
|
||||
case ere.DMCDeath:
|
||||
if i.DeathCause == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationFail,
|
||||
Message: "deathCause required if discharge_method_code is death",
|
||||
})
|
||||
return
|
||||
}
|
||||
case ere.DMCConsulPoly, ere.DMCConsulExecutive:
|
||||
if i.InternalReferences == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationFail,
|
||||
Message: fmt.Sprintf("internalReferences required if discharge_method_code is %s", *i.Discharge_Method_Code),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range *i.InternalReferences {
|
||||
if v.Unit_Id == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationFail,
|
||||
Message: "internalReferences.unit_id required",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if v.Doctor_Id == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationFail,
|
||||
Message: "internalReferences.doctor_id required",
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
if *i.Discharge_Method_Code == ere.DMCDeath && i.DeathCause == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationFail,
|
||||
Message: "deathCause required if discharge_method_code is death",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//case ere.DMCConsulPoly, ere.DMCConsulExecutive:
|
||||
// if i.InternalReferences == nil {
|
||||
// rw.DataResponse(w, nil, d.FieldError{
|
||||
// Code: dataValidationFail,
|
||||
// Message: fmt.Sprintf("internalReferences required if discharge_method_code is %s", *i.Discharge_Method_Code),
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// for _, v := range *i.InternalReferences {
|
||||
// if v.Unit_Id == nil {
|
||||
// rw.DataResponse(w, nil, d.FieldError{
|
||||
// Code: dataValidationFail,
|
||||
// Message: "internalReferences.unit_id required",
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if v.Doctor_Id == nil {
|
||||
// rw.DataResponse(w, nil, d.FieldError{
|
||||
// Code: dataValidationFail,
|
||||
// Message: "internalReferences.doctor_id required",
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -506,19 +506,18 @@ func CheckOut(input e.DischargeDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
switch *input.Discharge_Method_Code {
|
||||
case ere.DMCDeath:
|
||||
if *input.Discharge_Method_Code == ere.DMCDeath {
|
||||
// insert data death-cause
|
||||
if _, err = udc.CreateData(edc.CreateDto{Encounter_Id: &input.Id, Value: input.DeathCause}, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
case ere.DMCConsulPoly, ere.DMCConsulExecutive:
|
||||
// bulk insert internal-references
|
||||
if err = createInternalReferences(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
//// bulk insert internal-references
|
||||
//if err = createInternalReferences(input, &event, tx); err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
pl.SetLogInfo(&event, nil, "complete")
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user