approve and switch poly
This commit is contained in:
No files matched your search
@@ -1,7 +1,7 @@
|
||||
package division
|
||||
|
||||
import (
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/division"
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/new/division"
|
||||
)
|
||||
|
||||
// example of middleware
|
||||
|
||||
@@ -515,9 +515,17 @@ func CheckOut(input e.DischargeDto) (*d.Data, error) {
|
||||
}
|
||||
}
|
||||
|
||||
dataEncounter, err := ReadDetailData(e.ReadDetailDto{
|
||||
Id: uint16(data.Id),
|
||||
Includes: "DeathCause"},
|
||||
&event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunCheckoutMiddleware(checkoutEncounter, &input); err != nil {
|
||||
if err := mwRunner.RunCheckoutMiddleware(checkoutEncounter, dataEncounter); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -552,6 +560,7 @@ func UpdateStatusCode(input e.UpdateStatusDto) (*d.Data, error) {
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "update")
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -622,7 +631,13 @@ func UpdateStatusCode(input e.UpdateStatusDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
pl.SetLogInfo(&event, nil, "complete")
|
||||
if input.StatusCode == erc.DSCCancel {
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunUpdateStatusMiddleware(updatestatusEncounter, data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
@@ -829,6 +844,8 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: update status encounter, finishedAt
|
||||
|
||||
pl.SetLogInfo(&event, nil, "complete")
|
||||
return nil
|
||||
})
|
||||
@@ -940,7 +957,7 @@ func ApproveSwitchUnit(input e.ApproveUnitDto) (*d.Data, error) {
|
||||
|
||||
// update data response
|
||||
data.Responsible_Doctor_Code = irData.Doctor_Code
|
||||
data.Unit_Code = irData.Unit_Code //
|
||||
data.Unit_Code = irData.Unit_Code
|
||||
data.Specialist_Code = irData.Doctor.Specialist_Code
|
||||
data.Subspecialist_Code = irData.Doctor.Subspecialist_Code
|
||||
|
||||
|
||||
@@ -333,8 +333,6 @@ func updateEncounterApproveSwitchUnit(input eir.InternalReference, event *pl.Eve
|
||||
Updates(map[string]interface{}{
|
||||
"Responsible_Doctor_Code": input.Doctor_Code,
|
||||
"Unit_Code": input.Unit_Code,
|
||||
"Specialist_Code": input.Doctor.Specialist_Code,
|
||||
"Subspecialist_Code": input.Doctor.Subspecialist_Code,
|
||||
}).Error; err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
|
||||
@@ -161,7 +161,7 @@ func (me *middlewareRunner) RunCheckinMiddleware(middleware checkinMw, input *e.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunCheckoutMiddleware(middleware checkoutMw, input *e.DischargeDto) error {
|
||||
func (me *middlewareRunner) RunCheckoutMiddleware(middleware checkoutMw, input *e.Encounter) error {
|
||||
if !me.SyncOn {
|
||||
return nil
|
||||
}
|
||||
@@ -179,6 +179,26 @@ func (me *middlewareRunner) RunCheckoutMiddleware(middleware checkoutMw, input *
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunUpdateStatusMiddleware(middlewares []updateStatusMw, input *e.Encounter) error {
|
||||
if !me.SyncOn {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, middleware := range middlewares {
|
||||
logData := pu.GetLogData(input, nil)
|
||||
|
||||
pl.SetLogInfo(me.Event, logData, "started", middleware.Name)
|
||||
|
||||
if err := middleware.Func(input); err != nil {
|
||||
return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err)
|
||||
}
|
||||
}
|
||||
|
||||
pl.SetLogInfo(me.Event, nil, "complete")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) setMwType(mwType pu.MWType) {
|
||||
me.MwType = mwType
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package encounter
|
||||
|
||||
import plugin "simrs-vx/internal/use-case/simgos-sync-plugin/encounter"
|
||||
import (
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/new/encounter"
|
||||
)
|
||||
|
||||
func init() {
|
||||
createPreMw = append(createPreMw,
|
||||
@@ -10,8 +12,14 @@ func init() {
|
||||
createLogMw{Name: "create-sync-log", Func: plugin.CreateLog})
|
||||
|
||||
updatePreMw = append(updatePreMw,
|
||||
updateMw{Name: "sync-update-patient", Func: plugin.Update})
|
||||
updateMw{Name: "sync-update-encounter", Func: plugin.Update})
|
||||
|
||||
deletePreMw = append(deletePreMw,
|
||||
deleteMw{Name: "sync-delete-patient", Func: plugin.Delete})
|
||||
deleteMw{Name: "sync-delete-encounter", Func: plugin.Delete})
|
||||
|
||||
checkinEncounterMw = checkinMw{Name: "sync-checkin-encounter", Func: plugin.Checkin}
|
||||
checkoutEncounter = checkoutMw{Name: "sync-checkout-encounter", Func: plugin.Checkout}
|
||||
|
||||
updatestatusEncounter = append(updatestatusEncounter,
|
||||
updateStatusMw{Name: "sync-update-status-encounter", Func: plugin.Cancel})
|
||||
}
|
||||
@@ -51,7 +51,12 @@ type checkinMw struct {
|
||||
|
||||
type checkoutMw struct {
|
||||
Name string
|
||||
Func func(input *e.DischargeDto) error
|
||||
Func func(input *e.Encounter) error
|
||||
}
|
||||
|
||||
type updateStatusMw struct {
|
||||
Name string
|
||||
Func func(input *e.Encounter) error
|
||||
}
|
||||
|
||||
type UpdateMw = updateMw
|
||||
@@ -70,3 +75,4 @@ var deletePreMw []deleteMw
|
||||
var deletePostMw []readDetailMw
|
||||
var checkinEncounterMw checkinMw
|
||||
var checkoutEncounter checkoutMw
|
||||
var updatestatusEncounter []updateStatusMw
|
||||
@@ -1,7 +1,7 @@
|
||||
package installation
|
||||
|
||||
import (
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/installation"
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/new/installation"
|
||||
)
|
||||
|
||||
// example of middleware
|
||||
|
||||
@@ -19,6 +19,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Patient) error {
|
||||
var inputSrc *e.CreateDto
|
||||
if inputT, ok := any(input).(*e.CreateDto); ok {
|
||||
inputSrc = inputT
|
||||
data.RegisteredBy_User_Name = inputSrc.RegisteredBy_User_Name
|
||||
} else {
|
||||
inputTemp := any(input).(*e.UpdateDto)
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
|
||||
@@ -5,12 +5,11 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/new/patient"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/patient"
|
||||
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/patient"
|
||||
)
|
||||
|
||||
// example of middleware
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package specialist
|
||||
|
||||
import (
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/specialist"
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/new/specialist"
|
||||
)
|
||||
|
||||
// example of middleware
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/unit"
|
||||
plugin "simrs-vx/internal/use-case/simgos-sync-plugin/new/unit"
|
||||
)
|
||||
|
||||
// example of middleware
|
||||
|
||||
Reference in New Issue
Block a user