discharge wip
This commit is contained in:
No files matched your search
@@ -13,23 +13,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CreateDto struct {
|
type CreateDto struct {
|
||||||
Patient_Id *uint `json:"patient_id"`
|
Patient_Id *uint `json:"patient_id"`
|
||||||
Patient *ep.Patient `json:"patient,omitempty"`
|
Patient *ep.Patient `json:"patient,omitempty"`
|
||||||
RegisteredAt *time.Time `json:"registeredAt"`
|
RegisteredAt *time.Time `json:"registeredAt"`
|
||||||
Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"`
|
Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"`
|
||||||
Unit_Id *uint `json:"unit_id"`
|
SubClass_Code *string `json:"subClass_code" validate:"maxLength=10"` // for sub
|
||||||
Specialist_Id *uint16 `json:"specialist_id"`
|
Infra_Id *uint16 `json:"infra_id"` // for inpatient
|
||||||
Subspecialist_Id *uint16 `json:"subspecialist_id"`
|
Unit_Id *uint `json:"unit_id"`
|
||||||
VisitDate time.Time `json:"visitDate"`
|
Specialist_Id *uint16 `json:"specialist_id"`
|
||||||
Appointment_Doctor_Id *uint `json:"appointment_doctor_id"`
|
Subspecialist_Id *uint16 `json:"subspecialist_id"`
|
||||||
Responsible_Doctor_Id *uint `json:"responsible_doctor_id"`
|
VisitDate time.Time `json:"visitDate"`
|
||||||
DischardeMethod_Code ere.DischargeMethodCode `json:"dischardeMethod_code" validate:"maxLength=10"`
|
Appointment_Doctor_Id *uint `json:"appointment_doctor_id"`
|
||||||
RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"`
|
Responsible_Doctor_Id *uint `json:"responsible_doctor_id"`
|
||||||
Appointment_Id *uint `json:"appointment_id"`
|
RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"`
|
||||||
EarlyEducation *string `json:"earlyEducation"`
|
Appointment_Id *uint `json:"appointment_id"`
|
||||||
MedicalDischargeEducation *string `json:"medicalDischargeEducation"`
|
|
||||||
AdmDischargeEducation *string `json:"admDischargeEducation"`
|
|
||||||
DischargeReason *string `json:"dischargeReason"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadListDto struct {
|
type ReadListDto struct {
|
||||||
@@ -80,6 +77,14 @@ type MetaDto struct {
|
|||||||
PageSize int `json:"page_size"`
|
PageSize int `json:"page_size"`
|
||||||
Count int `json:"count"`
|
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 {
|
type ResponseDto struct {
|
||||||
ecore.Main
|
ecore.Main
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
package encounter
|
package encounter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/encounter"
|
"errors"
|
||||||
"strconv"
|
"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"
|
dg "github.com/karincake/apem/db-gorm-pg"
|
||||||
d "github.com/karincake/dodol"
|
d "github.com/karincake/dodol"
|
||||||
|
|
||||||
@@ -40,6 +51,54 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
|||||||
data = *resData
|
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)
|
mwRunner.setMwType(pu.MWTPost)
|
||||||
// Run post-middleware
|
// Run post-middleware
|
||||||
if err := mwRunner.RunCreateMiddleware(createPostMw, &input, &data); err != nil {
|
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.VisitDate = inputSrc.VisitDate
|
||||||
data.Appointment_Doctor_Id = inputSrc.Appointment_Doctor_Id
|
data.Appointment_Doctor_Id = inputSrc.Appointment_Doctor_Id
|
||||||
data.Responsible_Doctor_Id = inputSrc.Responsible_Doctor_Id
|
data.Responsible_Doctor_Id = inputSrc.Responsible_Doctor_Id
|
||||||
data.DischardeMethod_Code = inputSrc.DischardeMethod_Code
|
|
||||||
data.RefSource_Name = inputSrc.RefSource_Name
|
data.RefSource_Name = inputSrc.RefSource_Name
|
||||||
data.Appointment_Id = inputSrc.Appointment_Id
|
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