not yet finish
This commit is contained in:
@@ -6,9 +6,8 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Class_Code ere.AmbulatoryClassCode `json:"class_code" validate:"maxLength=10"`
|
||||
VisitMode_Code ere.VisitModeCode `json:"visitMode_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Class_Code ere.AmbulatoryClassCode `json:"class_code" validate:"maxLength=10"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -50,9 +49,8 @@ type ResponseDto struct {
|
||||
|
||||
func (d Ambulatory) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Class_Code: d.Class_Code,
|
||||
VisitMode_Code: d.VisitMode_Code,
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Class_Code: d.Class_Code,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
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"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id *uint `json:"-"`
|
||||
Unit_Id *uint16 `json:"unit_id"`
|
||||
Doctor_Id *uint `json:"doctor_Id"`
|
||||
Encounter_Id *uint `json:"-"`
|
||||
Unit_Id *uint16 `json:"unit_id"`
|
||||
Doctor_Id *uint `json:"doctor_Id"`
|
||||
Status_Code erc.DataApprovalCode `json:"status_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -19,9 +22,10 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Unit_Id *uint `json:"unit-id"`
|
||||
Doctor_Id *uint `json:"doctor-id"`
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Unit_Id *uint `json:"unit-id"`
|
||||
Doctor_Id *uint `json:"doctor-id"`
|
||||
Status_Code erc.DataApprovalCode `json:"status-code"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
@@ -46,11 +50,12 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Unit_Id *uint16 `json:"unit_id"`
|
||||
Unit *eu.Unit `json:"unit,omitempty"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Unit_Id *uint16 `json:"unit_id"`
|
||||
Unit *eu.Unit `json:"unit,omitempty"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
Status_Code *erc.DataApprovalCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d InternalReference) ToResponse() ResponseDto {
|
||||
@@ -60,6 +65,7 @@ func (d InternalReference) ToResponse() ResponseDto {
|
||||
Unit: d.Unit,
|
||||
Doctor_Id: d.Doctor_Id,
|
||||
Doctor: d.Doctor,
|
||||
Status_Code: d.Status_Code,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package rehab
|
||||
|
||||
import (
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
AllocatedVisitCount *int `json:"allocatedVisitCount"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Parent_Encounter_Id *uint `json:"parent_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"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -18,8 +24,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Doctor_Id *uint `json:"doctor-id"`
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Parent_Encounter_Id *uint `json:"parent-encounter-id"`
|
||||
VisitMode_Code ere.VisitModeCode `json:"visitMode-code"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
@@ -44,18 +51,22 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
AllocatedVisitCount *int `json:"allocatedVisitCount"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Parent_Encounter_Id *uint `json:"parent_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 (d Rehab) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Doctor_Id: d.Doctor_Id,
|
||||
Doctor: d.Doctor,
|
||||
Parent_Encounter_Id: d.Parent_Encounter_Id,
|
||||
AllocatedVisitCount: d.AllocatedVisitCount,
|
||||
ExpiredAt: d.ExpiredAt,
|
||||
VisitMode_Code: d.VisitMode_Code,
|
||||
Status_Code: d.Status_Code,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -22,7 +22,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Ambulatory) {
|
||||
|
||||
data.Encounter_Id = inputSrc.Encounter_Id
|
||||
data.Class_Code = inputSrc.Class_Code
|
||||
data.VisitMode_Code = inputSrc.VisitMode_Code
|
||||
}
|
||||
|
||||
func CheckClassCode(input *string) (ere.AmbulatoryClassCode, error) {
|
||||
|
||||
@@ -128,9 +128,8 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
case ere.ECAmbulatory:
|
||||
subCodeAmbulatory := subCode.(ere.AmbulatoryClassCode)
|
||||
ambCreate := ea.CreateDto{
|
||||
Encounter_Id: &data.Id,
|
||||
Class_Code: subCodeAmbulatory,
|
||||
VisitMode_Code: *input.VisitMode_Code,
|
||||
Encounter_Id: &data.Id,
|
||||
Class_Code: subCodeAmbulatory,
|
||||
}
|
||||
_, err = ua.CreateData(ambCreate, &event, tx)
|
||||
if err != nil {
|
||||
@@ -153,7 +152,6 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
// create data rehab
|
||||
if _, err = ur.CreateData(er.CreateDto{
|
||||
Encounter_Id: &data.Id,
|
||||
Doctor_Id: input.Appointment_Doctor_Id,
|
||||
AllocatedVisitCount: input.AllocatedVisitCount}, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -441,7 +439,7 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func CheckOut(input e.DischargeDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id), Includes: "Ambulatory"}
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id), Includes: "Ambulatory,Rehab"}
|
||||
var data *e.Encounter
|
||||
var err error
|
||||
|
||||
@@ -682,7 +680,6 @@ func CheckIn(input e.CheckinDto) (*d.Data, error) {
|
||||
if data.Ambulatory.Class_Code == ere.ACCRehab {
|
||||
if err := updateRehabDoctor(er.UpdateDto{CreateDto: er.CreateDto{
|
||||
Encounter_Id: &data.Id,
|
||||
Doctor_Id: input.Responsible_Doctor_Id,
|
||||
}}, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -781,31 +781,31 @@ func setDBError(event *pl.Event, err error, ctx any) error {
|
||||
return pl.SetLogError(event, ctx)
|
||||
}
|
||||
|
||||
func updateRehabDoctor(input er.UpdateDto, event *pl.Event, dbx ...*gorm.DB) error {
|
||||
pl.SetLogInfo(event, "started", "DBUpdate")
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
result := tx.
|
||||
Model(&er.Rehab{}).
|
||||
Where("\"Encounter_Id\" = (?)", input.Encounter_Id).
|
||||
Update("\"Doctor_Id\"", input.Doctor_Id)
|
||||
|
||||
if result.Error != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-update-fail",
|
||||
Detail: "Database update failed",
|
||||
Raw: result.Error,
|
||||
}
|
||||
return pl.SetLogError(event, input)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return nil
|
||||
}
|
||||
//func updateRehabDoctor(input er.UpdateDto, event *pl.Event, dbx ...*gorm.DB) error {
|
||||
// pl.SetLogInfo(event, "started", "DBUpdate")
|
||||
//
|
||||
// var tx *gorm.DB
|
||||
// if len(dbx) > 0 {
|
||||
// tx = dbx[0]
|
||||
// } else {
|
||||
// tx = dg.I
|
||||
// }
|
||||
//
|
||||
// result := tx.
|
||||
// Model(&er.Rehab{}).
|
||||
// Where("\"Encounter_Id\" = (?)", input.Encounter_Id).
|
||||
// Update("\"Doctor_Id\"", input.Doctor_Id)
|
||||
//
|
||||
// if result.Error != nil {
|
||||
// event.Status = "failed"
|
||||
// event.ErrInfo = pl.ErrorInfo{
|
||||
// Code: "data-update-fail",
|
||||
// Detail: "Database update failed",
|
||||
// Raw: result.Error,
|
||||
// }
|
||||
// return pl.SetLogError(event, input)
|
||||
// }
|
||||
//
|
||||
// pl.SetLogInfo(event, nil, "complete")
|
||||
// return nil
|
||||
//}
|
||||
|
||||
@@ -292,5 +292,5 @@ func verifyAllocatedVisitCount(i e.CreateDto, event *pl.Event) (e.Encounter, boo
|
||||
return e.Encounter{}, false, pl.SetLogError(event, i)
|
||||
}
|
||||
|
||||
return recentEncounterAdm, countEncounterSeries < int64(*recentEncounterAdm.Rehab.AllocatedVisitCount), nil
|
||||
return recentEncounterAdm, countEncounterSeries < int64(*recentEncounterAdm.Rehab_Adm.AllocatedVisitCount), nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Rehab) {
|
||||
}
|
||||
|
||||
data.Encounter_Id = inputSrc.Encounter_Id
|
||||
data.Doctor_Id = inputSrc.Doctor_Id
|
||||
data.Parent_Encounter_Id = inputSrc.Parent_Encounter_Id
|
||||
data.AllocatedVisitCount = inputSrc.AllocatedVisitCount
|
||||
data.ExpiredAt = inputSrc.ExpiredAt
|
||||
data.VisitMode_Code = &inputSrc.VisitMode_Code
|
||||
data.Status_Code = &inputSrc.Status_Code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user