refactor/unit-dropping: done
This commit is contained in:
No files matched your search
@@ -704,13 +704,13 @@ func CheckIn(input e.CheckinDto) (*d.Data, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
func RequestSwitchSpecialist(input e.SwitchSpecialistDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: input.Id, Includes: "Responsible_Nurse.Employee.User,Responsible_Doctor.Employee"}
|
||||
var data *e.Encounter
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "RequestSwitchUnit",
|
||||
Feature: "RequestSwitchSpecialist",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
@@ -720,8 +720,8 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
unitCodes := make(map[string]struct{})
|
||||
doctorCodes := make(map[string]struct{})
|
||||
for _, ref := range *input.InternalReferences {
|
||||
if ref.Unit_Code != nil {
|
||||
unitCodes[*ref.Unit_Code] = struct{}{}
|
||||
if ref.Specialist_Code != nil {
|
||||
unitCodes[*ref.Specialist_Code] = struct{}{}
|
||||
}
|
||||
if ref.Doctor_Code != nil {
|
||||
doctorCodes[*ref.Doctor_Code] = struct{}{}
|
||||
@@ -729,7 +729,7 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
// validate unit
|
||||
if err = validateUnitCodes(unitCodes, &event); err != nil {
|
||||
if err = validateSpecialistCodes(unitCodes, &event); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -796,7 +796,7 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunRequestSwitchUnitMiddleware(requestSwitchEncounter, dataEncounter); err != nil {
|
||||
if err := mwRunner.RunRequestSwitchSpecialistMiddleware(requestSwitchEncounter, dataEncounter); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -812,13 +812,13 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "requestSwitchUnit",
|
||||
"status": "requestSwitchSpecialist",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ApproveSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
func ApproveSwitchSpecialist(input e.ApproveCancelSpecialistDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: input.Id, Includes: "Responsible_Doctor.Employee"}
|
||||
var (
|
||||
data *e.Encounter
|
||||
@@ -826,12 +826,12 @@ func ApproveSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
)
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "ApproveSwitchUnit",
|
||||
Feature: "ApproveSwitchSpecialist",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "approveSwitchUnit")
|
||||
pl.SetLogInfo(&event, input, "started", "approveSwitchSpecialist")
|
||||
|
||||
roleAllowed := []string{string(erg.EPCNur)}
|
||||
err = validateAuth(input.AuthInfo, roleAllowed, "request-switch-poly", &event)
|
||||
@@ -904,13 +904,13 @@ func ApproveSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
// update encounter
|
||||
if err = updateEncounterApproveSwitchUnit(input, &event, tx); err != nil {
|
||||
if err = updateEncounterApproveSwitchSpecialist(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunApproveSwitchUnitMiddleware(approveSwitchEncounter, &input); err != nil {
|
||||
if err := mwRunner.RunApproveSwitchSpecialistMiddleware(approveSwitchEncounter, &input); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -933,7 +933,7 @@ func ApproveSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
|
||||
}
|
||||
|
||||
func CancelSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
func CancelSwitchSpecialist(input e.ApproveCancelSpecialistDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: input.Id}
|
||||
var (
|
||||
data *e.Encounter
|
||||
@@ -941,12 +941,12 @@ func CancelSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
)
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "CancelSwitchUnit",
|
||||
Feature: "CancelSwitchSpecialist",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "cancelSwitchUnit")
|
||||
pl.SetLogInfo(&event, input, "started", "cancelSwitchSpecialist")
|
||||
|
||||
roleAllowed := []string{string(erg.EPCNur)}
|
||||
err = validateAuth(input.AuthInfo, roleAllowed, "request-switch-poly", &event)
|
||||
@@ -1000,7 +1000,7 @@ func CancelSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunCancelSwitchUnitMiddleware(cancelSwitchEncounter, &input); err != nil {
|
||||
if err := mwRunner.RunCancelSwitchSpecialistMiddleware(cancelSwitchEncounter, &input); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -44,7 +44,7 @@ import (
|
||||
er "simrs-vx/internal/domain/main-entities/rehab"
|
||||
erdh "simrs-vx/internal/domain/main-entities/responsible-doctor-hist"
|
||||
es "simrs-vx/internal/domain/main-entities/soapi"
|
||||
eu "simrs-vx/internal/domain/main-entities/unit"
|
||||
esp "simrs-vx/internal/domain/main-entities/specialist"
|
||||
|
||||
// udo "simrs-vx/internal/use-case/main-use-case/device-order"
|
||||
uaeh "simrs-vx/internal/use-case/main-use-case/adm-employee-hist"
|
||||
@@ -69,7 +69,7 @@ func setDataCreate(input *e.CreateDto, data *e.Encounter) {
|
||||
data.Patient_Id = input.Patient_Id
|
||||
data.RegisteredAt = input.RegisteredAt
|
||||
data.Class_Code = input.Class_Code
|
||||
data.Unit_Code = input.Unit_Code
|
||||
data.Specialist_Code = input.Specialist_Code
|
||||
data.Specialist_Code = input.Specialist_Code
|
||||
data.Subspecialist_Code = input.Subspecialist_Code
|
||||
data.VisitDate = input.VisitDate
|
||||
@@ -88,7 +88,7 @@ func setDataCreate(input *e.CreateDto, data *e.Encounter) {
|
||||
}
|
||||
|
||||
func setDataUpdate(src e.UpdateDto, dst *e.Encounter) {
|
||||
dst.Unit_Code = src.Unit_Code
|
||||
dst.Specialist_Code = src.Specialist_Code
|
||||
dst.Specialist_Code = src.Specialist_Code
|
||||
dst.Subspecialist_Code = src.Subspecialist_Code
|
||||
dst.VisitDate = src.VisitDate
|
||||
@@ -104,7 +104,7 @@ func setDataUpdate(src e.UpdateDto, dst *e.Encounter) {
|
||||
func setDataUpdateFromSource(input *e.UpdateDto, data *e.Encounter) {
|
||||
data.Patient_Id = input.Patient_Id
|
||||
data.RegisteredAt = input.RegisteredAt
|
||||
data.Unit_Code = input.Unit_Code
|
||||
data.Specialist_Code = input.Specialist_Code
|
||||
data.Specialist_Code = input.Specialist_Code
|
||||
data.Subspecialist_Code = input.Subspecialist_Code
|
||||
data.VisitDate = input.VisitDate
|
||||
@@ -853,9 +853,9 @@ func insertDataSubClassAmbulatory(input e.CreateDto, soapiData []es.CreateDto, e
|
||||
switch {
|
||||
case subCode == ere.ACCChemo:
|
||||
chemoCreate := ec.CreateDto{
|
||||
Encounter_Id: &input.Id,
|
||||
Status_Code: erc.DVCNew,
|
||||
SrcUnit_Code: input.Unit_Code,
|
||||
Encounter_Id: &input.Id,
|
||||
Status_Code: erc.DVCNew,
|
||||
Specialist_Code: input.Specialist_Code,
|
||||
}
|
||||
|
||||
// create data chemo
|
||||
@@ -977,9 +977,9 @@ func setDBError(event *pl.Event, err error, ctx any) error {
|
||||
return pl.SetLogError(event, ctx)
|
||||
}
|
||||
|
||||
func getUnits(unitIds []string, event *pl.Event) ([]eu.Unit, error) {
|
||||
pl.SetLogInfo(event, nil, "started", "getUnits")
|
||||
var units []eu.Unit
|
||||
func getSpecialists(unitIds []string, event *pl.Event) ([]esp.Specialist, error) {
|
||||
pl.SetLogInfo(event, nil, "started", "getSpecialists")
|
||||
var units []esp.Specialist
|
||||
err := dg.I.Where("\"Code\" IN ?", unitIds).Find(&units).Error
|
||||
if err != nil {
|
||||
event.Status = "failed"
|
||||
@@ -1009,14 +1009,14 @@ func getDoctors(doctorIds []string, event *pl.Event) ([]ed.Doctor, error) {
|
||||
return doctors, nil
|
||||
}
|
||||
|
||||
func validateUnitCodes(unitCodes map[string]struct{}, event *pl.Event) error {
|
||||
func validateSpecialistCodes(unitCodes map[string]struct{}, event *pl.Event) error {
|
||||
if len(unitCodes) > 0 {
|
||||
var codes []string
|
||||
for code := range unitCodes {
|
||||
codes = append(codes, code)
|
||||
}
|
||||
|
||||
units, err := getUnits(codes, event)
|
||||
units, err := getSpecialists(codes, event)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to fetch units: %w", err)
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.En
|
||||
tx = tx.Where("\"Encounter\".\"Status_Code\" = ?", *input.Status_Code)
|
||||
}
|
||||
|
||||
if input.Unit_Code != nil {
|
||||
tx = tx.Where("\"Encounter\".\"Unit_Code\" = ?", *input.Unit_Code)
|
||||
if input.Specialist_Code != nil {
|
||||
tx = tx.Where("\"Encounter\".\"Specialist_Code\" = ?", *input.Specialist_Code)
|
||||
}
|
||||
|
||||
if input.PaymentMethod_Code != nil {
|
||||
@@ -268,7 +268,7 @@ func UpdateStatusData(input e.UpdateStatusDto, event *pl.Event, dbx ...*gorm.DB)
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateDischargeMethod(input e.SwitchUnitDto, event *pl.Event, dbx ...*gorm.DB) error {
|
||||
func UpdateDischargeMethod(input e.SwitchSpecialistDto, event *pl.Event, dbx ...*gorm.DB) error {
|
||||
pl.SetLogInfo(event, input, "started", "DBUpdateDischargeMethod")
|
||||
dischargeCode := setDischargeMethodCode(*input.PolySwitchCode)
|
||||
|
||||
@@ -382,7 +382,7 @@ func verifyAllocatedVisitCount(i e.CreateDto, event *pl.Event) (e.Encounter, boo
|
||||
return recentEncounterAdm, valid, nil
|
||||
}
|
||||
|
||||
func updateEncounterApproveSwitchUnit(input e.ApproveCancelUnitDto, event *pl.Event, dbx ...*gorm.DB) (err error) {
|
||||
func updateEncounterApproveSwitchSpecialist(input e.ApproveCancelSpecialistDto, event *pl.Event, dbx ...*gorm.DB) (err error) {
|
||||
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
||||
|
||||
var tx *gorm.DB
|
||||
|
||||
@@ -202,7 +202,7 @@ func (me *middlewareRunner) RunUpdateStatusMiddleware(middlewares []updateStatus
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunRequestSwitchUnitMiddleware(middleware requestSwitchUnitMw, input *e.Encounter) error {
|
||||
func (me *middlewareRunner) RunRequestSwitchSpecialistMiddleware(middleware requestSwitchSpecialistMw, input *e.Encounter) error {
|
||||
if !me.SyncOn {
|
||||
return nil
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func (me *middlewareRunner) RunRequestSwitchUnitMiddleware(middleware requestSwi
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunApproveSwitchUnitMiddleware(middleware approveSwitchUnitMw, input *e.ApproveCancelUnitDto) error {
|
||||
func (me *middlewareRunner) RunApproveSwitchSpecialistMiddleware(middleware approveSwitchSpecialistMw, input *e.ApproveCancelSpecialistDto) error {
|
||||
if !me.SyncOn {
|
||||
return nil
|
||||
}
|
||||
@@ -238,7 +238,7 @@ func (me *middlewareRunner) RunApproveSwitchUnitMiddleware(middleware approveSwi
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunCancelSwitchUnitMiddleware(middleware cancelSwitchUnitMw, input *e.ApproveCancelUnitDto) error {
|
||||
func (me *middlewareRunner) RunCancelSwitchSpecialistMiddleware(middleware cancelSwitchSpecialistMw, input *e.ApproveCancelSpecialistDto) error {
|
||||
if !me.SyncOn {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func init() {
|
||||
updatestatusEncounter = append(updatestatusEncounter,
|
||||
updateStatusMw{Name: "sync-update-status-encounter", Func: plugin.UpdateStatus})
|
||||
|
||||
requestSwitchEncounter = requestSwitchUnitMw{Name: "sync-request-switch-unit-encounter", Func: plugin.RequestSwitchUnit}
|
||||
approveSwitchEncounter = approveSwitchUnitMw{Name: "sync-approve-switch-unit-encounter", Func: plugin.ApproveSwitchUnit}
|
||||
cancelSwitchEncounter = cancelSwitchUnitMw{Name: "sync-cancel-switch-unit-encounter", Func: plugin.CancelSwitchUnit}
|
||||
requestSwitchEncounter = requestSwitchSpecialistMw{Name: "sync-request-switch-unit-encounter", Func: plugin.RequestSwitchSpecialist}
|
||||
approveSwitchEncounter = approveSwitchSpecialistMw{Name: "sync-approve-switch-unit-encounter", Func: plugin.ApproveSwitchSpecialist}
|
||||
cancelSwitchEncounter = cancelSwitchSpecialistMw{Name: "sync-cancel-switch-unit-encounter", Func: plugin.CancelSwitchSpecialist}
|
||||
}
|
||||
@@ -59,19 +59,19 @@ type updateStatusMw struct {
|
||||
Func func(input *e.Encounter) error
|
||||
}
|
||||
|
||||
type requestSwitchUnitMw struct {
|
||||
type requestSwitchSpecialistMw struct {
|
||||
Name string
|
||||
Func func(input *e.Encounter) error
|
||||
}
|
||||
|
||||
type approveSwitchUnitMw struct {
|
||||
type approveSwitchSpecialistMw struct {
|
||||
Name string
|
||||
Func func(input *e.ApproveCancelUnitDto) error
|
||||
Func func(input *e.ApproveCancelSpecialistDto) error
|
||||
}
|
||||
|
||||
type cancelSwitchUnitMw struct {
|
||||
type cancelSwitchSpecialistMw struct {
|
||||
Name string
|
||||
Func func(input *e.ApproveCancelUnitDto) error
|
||||
Func func(input *e.ApproveCancelSpecialistDto) error
|
||||
}
|
||||
|
||||
type createWithPatientMw struct {
|
||||
@@ -96,8 +96,8 @@ var deletePostMw []readDetailMw
|
||||
var checkinEncounterMw checkinMw
|
||||
var checkoutEncounter checkoutMw
|
||||
var updatestatusEncounter []updateStatusMw
|
||||
var requestSwitchEncounter requestSwitchUnitMw
|
||||
var approveSwitchEncounter approveSwitchUnitMw
|
||||
var cancelSwitchEncounter cancelSwitchUnitMw
|
||||
var requestSwitchEncounter requestSwitchSpecialistMw
|
||||
var approveSwitchEncounter approveSwitchSpecialistMw
|
||||
var cancelSwitchEncounter cancelSwitchSpecialistMw
|
||||
var createWithPatientPreMw []createWithPatientMw
|
||||
var createWithPatientPostMw []createWithPatientMw
|
||||
Reference in New Issue
Block a user