Merge branch 'dev' of github.com:dikstub-rssa/simrs-be into fix/anything-moko
This commit is contained in:
@@ -51,7 +51,7 @@ type MetaDto struct {
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Unit_Code *string `json:"unit_id"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Unit *eu.Unit `json:"unit,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
|
||||
@@ -53,7 +53,7 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.SmallMain
|
||||
Subspecialist_Code *string `json:"subspecialist_id"`
|
||||
Subspecialist_Code *string `json:"subspecialist_code"`
|
||||
Subspecialist *es.Subspecialist `json:"subspecialist,omitempty"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -573,7 +573,7 @@ func CheckIn(input e.CheckinDto) (*d.Data, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Upsert responsible_doctor_hist if responsible_doctor_id has changed
|
||||
// Upsert responsible_doctor_hist if responsible_doctor_code has changed
|
||||
if data.Responsible_Doctor_Code == nil || *input.Responsible_Doctor_Code != *data.Responsible_Doctor_Code {
|
||||
// upsert responsibleDoctorHist
|
||||
if err = upsertResponsibleDoctorHist(erdh.CreateDto{
|
||||
@@ -801,7 +801,7 @@ func ApproveSwitchUnit(input e.ApproveUnitDto) (*d.Data, error) {
|
||||
|
||||
// update data response
|
||||
data.Responsible_Doctor_Code = irData.Doctor_Code
|
||||
data.Unit = irData.Unit // TODO: check if this is correct
|
||||
data.Unit_Code = irData.Unit_Code //
|
||||
data.Specialist_Code = irData.Doctor.Specialist_Code
|
||||
data.Subspecialist_Code = irData.Doctor.Subspecialist_Code
|
||||
|
||||
|
||||
@@ -559,7 +559,6 @@ func getSoapiByResponsibleDoctor(enc e.Encounter, event *pl.Event) (data []es.So
|
||||
}
|
||||
|
||||
err = dg.I.
|
||||
Debug().
|
||||
Model(&es.Soapi{}).
|
||||
Joins("JOIN \"Employee\" ON \"Employee\".\"Id\" = \"Soapi\".\"Employee_Id\"").
|
||||
Where("\"Encounter_Id\" = ?", enc.Id).
|
||||
@@ -723,16 +722,26 @@ func determineVisitMode(recentRehabData *er.Rehab, input e.CreateDto, event *pl.
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
if !isQuotaValid || recentRehabData.ExpiredAt.Before(*pu.GetTimeNow()) {
|
||||
if !isQuotaValid {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "visit-limit-exceeded",
|
||||
Detail: "Encounter has exceeded the allowed number of visits or expired",
|
||||
Detail: "Encounter has exceeded the allowed number of visits",
|
||||
Raw: errors.New("visit count exceeds allowed limit"),
|
||||
}
|
||||
return "", nil, pl.SetLogError(event, input)
|
||||
}
|
||||
|
||||
if recentRehabData.ExpiredAt != nil && recentRehabData.ExpiredAt.Before(*pu.GetTimeNow()) {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "visit-limit-exceeded",
|
||||
Detail: "Encounter period has expired",
|
||||
Raw: errors.New("encounter expired"),
|
||||
}
|
||||
return "", nil, pl.SetLogError(event, input)
|
||||
}
|
||||
|
||||
case erc.DSCDone:
|
||||
visitModeCode = ere.VMCAdm
|
||||
|
||||
@@ -903,7 +912,7 @@ func validateForeignKey(input e.CheckinDto) error {
|
||||
}
|
||||
}
|
||||
|
||||
// validate doctor_id
|
||||
// validate doctor_Code
|
||||
if input.Responsible_Doctor_Code != nil {
|
||||
if _, err := ud.ReadDetail(ed.ReadDetailDto{Code: input.Responsible_Doctor_Code}); err != nil {
|
||||
return err
|
||||
@@ -951,7 +960,7 @@ func getUnits(unitIds []string, event *pl.Event) ([]eu.Unit, error) {
|
||||
func getDoctors(doctorIds []string, event *pl.Event) ([]ed.Doctor, error) {
|
||||
pl.SetLogInfo(event, nil, "started", "getDoctors")
|
||||
var doctors []ed.Doctor
|
||||
err := dg.I.Where("\"Id\" Code ?", doctorIds).Find(&doctors).Error
|
||||
err := dg.I.Where("\"Code\" IN ?", doctorIds).Find(&doctors).Error
|
||||
if err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
@@ -979,7 +988,7 @@ func validateUnitCodes(unitCodes map[string]struct{}, event *pl.Event) error {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-validation-fail",
|
||||
Detail: "unit_id not found",
|
||||
Detail: "unit_code not found",
|
||||
}
|
||||
return pl.SetLogError(event, nil)
|
||||
}
|
||||
@@ -1003,7 +1012,7 @@ func validateDoctorCodes(doctorCodes map[string]struct{}, event *pl.Event) error
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-validation-fail",
|
||||
Detail: "doctor_id not found",
|
||||
Detail: "doctor_code not found",
|
||||
}
|
||||
return pl.SetLogError(event, nil)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.En
|
||||
tx = tx.Model(&e.Encounter{})
|
||||
|
||||
if input.AuthInfo.Doctor_Code != nil {
|
||||
tx.Where("\"Responsible_Doctor_Id\" = ?", *input.AuthInfo.Doctor_Code) // TODO: fix this
|
||||
tx.Where("\"Responsible_Doctor_Code\" = ?", *input.AuthInfo.Doctor_Code) //
|
||||
}
|
||||
|
||||
tx.Scopes(gh.Preload(input.Includes)).
|
||||
@@ -312,7 +312,7 @@ func verifyAllocatedVisitCount(i e.CreateDto, event *pl.Event) (e.Encounter, boo
|
||||
}
|
||||
|
||||
// validate count rehab children
|
||||
if recentEncounterAdm.RehabChildren != nil {
|
||||
if recentEncounterAdm.RehabChildren != nil && len(*recentEncounterAdm.RehabChildren) > 0 {
|
||||
valid = len(*recentEncounterAdm.RehabChildren) < *recentEncounterAdm.Rehab.AllocatedVisitCount
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user