Skip to content

Commit

Permalink
Merge pull request #377 from noharm-ai/develop
Browse files Browse the repository at this point in the history
v3.32-beta
  • Loading branch information
marceloarocha committed Sep 16, 2024
2 parents 6d2028a + a3231f3 commit d3a91e4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

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


if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions models/prescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ def getPatients(

if len(segments) > 0:
q = q.filter(Prescription.idSegment.in_(idSegmentList))
else:
q = q.filter(Prescription.idSegment != None)

if len(idDept) > 0:
idDept = list(map(int, idDept))
Expand Down
8 changes: 6 additions & 2 deletions services/admin/admin_relation_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy import func
from sqlalchemy import func, or_
from datetime import datetime

from models.main import db, Substance, User, Relation
Expand Down Expand Up @@ -34,7 +34,11 @@ def get_relations(
)

if len(id_origin_list) > 0:
q = q.filter(Relation.sctida.in_(id_origin_list))
q = q.filter(
or_(
Relation.sctida.in_(id_origin_list), Relation.sctidb.in_(id_origin_list)
)
)

if len(id_destination_list) > 0:
q = q.filter(Relation.sctidb.in_(id_destination_list))
Expand Down
41 changes: 40 additions & 1 deletion services/intervention_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,38 @@ def _get_outcome_data_query():


def get_outcome_data(id_intervention, user: User, edit=False):
InterventionReasonParent = db.aliased(InterventionReason)
reason_column = case(
(
InterventionReasonParent.description != None,
func.concat(
InterventionReasonParent.description,
" - ",
InterventionReason.description,
),
),
else_=InterventionReason.description,
)

reason = (
db.session.query(reason_column)
.select_from(InterventionReason)
.outerjoin(
InterventionReasonParent,
InterventionReasonParent.id == InterventionReason.mamy,
)
.filter(InterventionReason.id == func.any(Intervention.idInterventionReason))
.as_scalar()
)

record = (
db.session.query(Intervention, PrescriptionDrug, Drug, User)
db.session.query(
Intervention,
PrescriptionDrug,
Drug,
User,
func.array(reason).label("reason"),
)
.outerjoin(PrescriptionDrug, PrescriptionDrug.id == Intervention.id)
.outerjoin(Drug, PrescriptionDrug.idDrug == Drug.id)
.outerjoin(User, Intervention.outcome_by == User.id)
Expand All @@ -841,6 +871,7 @@ def get_outcome_data(id_intervention, user: User, edit=False):
prescription_drug: PrescriptionDrug = record[1]
readonly = intervention.status != InterventionStatusEnum.PENDING.value and not edit
economy_type = intervention.economy_type
outcome_user: User = record[3]

# custom economy gets a simpler response
if economy_type == InterventionEconomyTypeEnum.CUSTOM.value:
Expand All @@ -867,6 +898,13 @@ def get_outcome_data(id_intervention, user: User, edit=False):
"status": intervention.status,
"readonly": readonly,
"date": intervention.date.isoformat(),
"interventionReason": record.reason,
"outcomeAt": (
intervention.outcome_at.isoformat()
if intervention.outcome_at != None
else None
),
"outcomeUser": (outcome_user.name if outcome_user != None else None),
},
}

Expand Down Expand Up @@ -978,6 +1016,7 @@ def _get_outcome_dict(
if intervention.date_end_economy != None
else None
),
"interventionReason": outcome_data.reason,
},
}

Expand Down

0 comments on commit d3a91e4

Please sign in to comment.