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