discharge wip
This commit is contained in:
@@ -13,23 +13,20 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Patient_Id *uint `json:"patient_id"`
|
||||
Patient *ep.Patient `json:"patient,omitempty"`
|
||||
RegisteredAt *time.Time `json:"registeredAt"`
|
||||
Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"`
|
||||
Unit_Id *uint `json:"unit_id"`
|
||||
Specialist_Id *uint16 `json:"specialist_id"`
|
||||
Subspecialist_Id *uint16 `json:"subspecialist_id"`
|
||||
VisitDate time.Time `json:"visitDate"`
|
||||
Appointment_Doctor_Id *uint `json:"appointment_doctor_id"`
|
||||
Responsible_Doctor_Id *uint `json:"responsible_doctor_id"`
|
||||
DischardeMethod_Code ere.DischargeMethodCode `json:"dischardeMethod_code" validate:"maxLength=10"`
|
||||
RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"`
|
||||
Appointment_Id *uint `json:"appointment_id"`
|
||||
EarlyEducation *string `json:"earlyEducation"`
|
||||
MedicalDischargeEducation *string `json:"medicalDischargeEducation"`
|
||||
AdmDischargeEducation *string `json:"admDischargeEducation"`
|
||||
DischargeReason *string `json:"dischargeReason"`
|
||||
Patient_Id *uint `json:"patient_id"`
|
||||
Patient *ep.Patient `json:"patient,omitempty"`
|
||||
RegisteredAt *time.Time `json:"registeredAt"`
|
||||
Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"`
|
||||
SubClass_Code *string `json:"subClass_code" validate:"maxLength=10"` // for sub
|
||||
Infra_Id *uint16 `json:"infra_id"` // for inpatient
|
||||
Unit_Id *uint `json:"unit_id"`
|
||||
Specialist_Id *uint16 `json:"specialist_id"`
|
||||
Subspecialist_Id *uint16 `json:"subspecialist_id"`
|
||||
VisitDate time.Time `json:"visitDate"`
|
||||
Appointment_Doctor_Id *uint `json:"appointment_doctor_id"`
|
||||
Responsible_Doctor_Id *uint `json:"responsible_doctor_id"`
|
||||
RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"`
|
||||
Appointment_Id *uint `json:"appointment_id"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -80,6 +77,14 @@ type MetaDto struct {
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
type DischargeDto struct {
|
||||
Id uint `json:"id"`
|
||||
DischardeMethod_Code *ere.DischargeMethodCode `json:"dischardeMethod_code" validate:"maxLength=10"`
|
||||
EarlyEducation *string `json:"earlyEducation"`
|
||||
MedicalDischargeEducation *string `json:"medicalDischargeEducation"`
|
||||
AdmDischargeEducation *string `json:"admDischargeEducation"`
|
||||
DischargeReason *string `json:"dischargeReason"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package encounter
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/encounter"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
ea "simrs-vx/internal/domain/main-entities/ambulatory"
|
||||
ee "simrs-vx/internal/domain/main-entities/emergency"
|
||||
e "simrs-vx/internal/domain/main-entities/encounter"
|
||||
ei "simrs-vx/internal/domain/main-entities/inpatient"
|
||||
|
||||
ua "simrs-vx/internal/use-case/main-use-case/ambulatory"
|
||||
ue "simrs-vx/internal/use-case/main-use-case/emergency"
|
||||
ui "simrs-vx/internal/use-case/main-use-case/inpatient"
|
||||
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
@@ -40,6 +51,54 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
data = *resData
|
||||
}
|
||||
|
||||
switch input.Class_Code {
|
||||
case ere.ECAmbulatory:
|
||||
ambCreate := ea.CreateDto{
|
||||
Encounter_Id: &data.Id,
|
||||
Class_Code: func() ere.AmbulatoryClassCode {
|
||||
if input.SubClass_Code != nil {
|
||||
return ere.AmbulatoryClassCode(*input.SubClass_Code)
|
||||
}
|
||||
return ""
|
||||
}(),
|
||||
}
|
||||
_, err := ua.CreateData(ambCreate, &event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case ere.ECEmergency:
|
||||
emerCreate := ee.CreateDto{
|
||||
Encounter_Id: &data.Id,
|
||||
Class_Code: func() ere.EmergencyClassCode {
|
||||
if input.SubClass_Code != nil {
|
||||
return ere.EmergencyClassCode(*input.SubClass_Code)
|
||||
}
|
||||
return ""
|
||||
}(),
|
||||
}
|
||||
_, err := ue.CreateData(emerCreate, &event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case ere.ECInpatient:
|
||||
inpCreate := ei.CreateDto{
|
||||
Encounter_Id: &data.Id,
|
||||
Class_Code: func() ere.InpatientClassCode {
|
||||
if input.SubClass_Code != nil {
|
||||
return ere.InpatientClassCode(*input.SubClass_Code)
|
||||
}
|
||||
return ""
|
||||
}(),
|
||||
Infra_Id: input.Infra_Id,
|
||||
}
|
||||
_, err := ui.CreateData(inpCreate, &event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return errors.New("invalid encounter class code")
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunCreateMiddleware(createPostMw, &input, &data); err != nil {
|
||||
|
||||
@@ -25,11 +25,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Encounter) {
|
||||
data.VisitDate = inputSrc.VisitDate
|
||||
data.Appointment_Doctor_Id = inputSrc.Appointment_Doctor_Id
|
||||
data.Responsible_Doctor_Id = inputSrc.Responsible_Doctor_Id
|
||||
data.DischardeMethod_Code = inputSrc.DischardeMethod_Code
|
||||
data.RefSource_Name = inputSrc.RefSource_Name
|
||||
data.Appointment_Id = inputSrc.Appointment_Id
|
||||
data.EarlyEducation = inputSrc.EarlyEducation
|
||||
data.MedicalDischargeEducation = inputSrc.MedicalDischargeEducation
|
||||
data.AdmDischargeEducation = inputSrc.AdmDischargeEducation
|
||||
data.DischargeReason = inputSrc.DischargeReason
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user