Skip to content

Commit

Permalink
Merge pull request #329 from noharm-ai/develop
Browse files Browse the repository at this point in the history
v3.12-beta
  • Loading branch information
marceloarocha authored Jul 1, 2024
2 parents df3e059 + 7fef9ce commit 5782e5c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 73 deletions.
2 changes: 1 addition & 1 deletion mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

@app.route("/version", methods=["GET"])
def getVersion():
return {"status": "success", "data": "v3.11-beta"}, status.HTTP_200_OK
return {"status": "success", "data": "v3.12-beta"}, status.HTTP_200_OK


@app.route("/exc", methods=["GET"])
Expand Down
6 changes: 3 additions & 3 deletions services/auth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def auth_provider(code, schema):
)
except Exception as error:
raise ValidationError(
"OAUTH provider error:" + str(error),
"OAUTH provider error: decode error",
"errors.unauthorizedUser",
status.HTTP_401_UNAUTHORIZED,
)
Expand All @@ -407,7 +407,7 @@ def auth_provider(code, schema):
)
except Exception as error:
raise ValidationError(
"OAUTH provider error:" + str(error),
"OAUTH provider error: decode error",
"errors.unauthorizedUser",
status.HTTP_401_UNAUTHORIZED,
)
Expand All @@ -421,7 +421,7 @@ def auth_provider(code, schema):
or Config.ENV == NoHarmENV.STAGING.value
):
raise ValidationError(
"OAUTH: email inválido: " + code,
"OAUTH: email inválido",
"errors.unauthorizedUser",
status.HTTP_401_UNAUTHORIZED,
)
Expand Down
145 changes: 76 additions & 69 deletions services/intervention_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ def set_intervention_outcome(
if intervention.economy_type != None:
# intervention v2
if intervention.status != "s":
if economy_day_value == None:
raise ValidationError(
"Economia/Dia inválido",
"errors.businessRule",
status.HTTP_400_BAD_REQUEST,
)

intervention.idPrescriptionDrugDestiny = id_prescription_drug_destiny

intervention.economy_day_value = economy_day_value
Expand Down Expand Up @@ -468,85 +475,85 @@ def save_intervention(
if expended_dose != -1:
i.expended_dose = expended_dose

if memory_service.has_feature(FeatureEnum.INTERVENTION_V2.value):
# define economy
economy_type = None
reasons = (
db.session.query(InterventionReason)
.filter(InterventionReason.id.in_(i.idInterventionReason))
.all()
)
for r in reasons:
if r.suspension:
economy_type = InterventionEconomyTypeEnum.SUSPENSION.value
elif r.substitution:
economy_type = InterventionEconomyTypeEnum.SUBSTITUTION.value
elif r.customEconomy:
economy_type = InterventionEconomyTypeEnum.CUSTOM.value

if (
id_prescription != 0
and economy_type != InterventionEconomyTypeEnum.CUSTOM.value
):
# prescription intv can only have custom economy
economy_type = None
reasons = (
db.session.query(InterventionReason)
.filter(InterventionReason.id.in_(i.idInterventionReason))
.all()
)
for r in reasons:
if r.suspension:
economy_type = InterventionEconomyTypeEnum.SUSPENSION.value
elif r.substitution:
economy_type = InterventionEconomyTypeEnum.SUBSTITUTION.value
elif r.customEconomy:
economy_type = InterventionEconomyTypeEnum.CUSTOM.value

if (
id_prescription != 0
and economy_type != InterventionEconomyTypeEnum.CUSTOM.value
):
# prescription intv can only have custom economy
economy_type = None

i.economy_type = economy_type

# date base economy
if economy_type != None and i.date_base_economy == None:
if permission_service.is_cpoe(user):
if agg_id_prescription == None:
i.date_base_economy = i.date
else:
presc = (
db.session.query(Prescription)
.filter(Prescription.id == agg_id_prescription)
.first()
i.economy_type = economy_type

# date base economy
if economy_type != None and i.date_base_economy == None:
if permission_service.is_cpoe(user):
if agg_id_prescription == None:
i.date_base_economy = i.date
else:
presc = (
db.session.query(Prescription)
.filter(Prescription.id == agg_id_prescription)
.first()
)

if presc == None:
raise ValidationError(
"Registro inválido: data base economia",
"errors.businessRule",
status.HTTP_400_BAD_REQUEST,
)

if presc == None:
raise ValidationError(
"Registro inválido: data base economia",
"errors.businessRule",
status.HTTP_400_BAD_REQUEST,
)
i.date_base_economy = presc.date
else:
if id_prescription != 0:
presc: Prescription = (
db.session.query(Prescription)
.filter(Prescription.id == id_prescription)
.first()
)

i.date_base_economy = presc.date
else:
if id_prescription != 0:
presc: Prescription = (
db.session.query(Prescription)
.filter(Prescription.id == id_prescription)
.first()
if presc == None:
raise ValidationError(
"Registro inválido id_prescription: data base economia",
"errors.invalidRecord",
status.HTTP_400_BAD_REQUEST,
)

if presc == None:
raise ValidationError(
"Registro inválido id_prescription: data base economia",
"errors.invalidRecord",
status.HTTP_400_BAD_REQUEST,
)

i.date_base_economy = presc.date
else:
presc = (
db.session.query(PrescriptionDrug, Prescription)
.join(
Prescription,
PrescriptionDrug.idPrescription == Prescription.id,
)
.filter(PrescriptionDrug.id == id_prescription_drug)
.first()
i.date_base_economy = presc.date
else:
presc = (
db.session.query(PrescriptionDrug, Prescription)
.join(
Prescription,
PrescriptionDrug.idPrescription == Prescription.id,
)
.filter(PrescriptionDrug.id == id_prescription_drug)
.first()
)

if presc == None:
raise ValidationError(
"Registro inválido: data base economia",
"errors.invalidRecord",
status.HTTP_400_BAD_REQUEST,
)
if presc == None:
raise ValidationError(
"Registro inválido: data base economia",
"errors.invalidRecord",
status.HTTP_400_BAD_REQUEST,
)

i.date_base_economy = presc[1].date
i.date_base_economy = presc[1].date

if i.admissionNumber != None and i.idDepartment == None:
currentDepartment = (
Expand Down

0 comments on commit 5782e5c

Please sign in to comment.