Skip to content

Commit

Permalink
fix patient prescription with no segment
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloarocha committed Feb 22, 2025
1 parent 226fc79 commit 5497b98
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions services/prescription_agg_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ def create_agg_prescription_by_date(
id_prescription=agg_p.id, user_context=user_context
)

# force reload prescription to get updated data from trigger
db.session.expire(agg_p)
agg_p = db.session.query(Prescription).filter(Prescription.id == p_id).first()

if not agg_p.idSegment:
# fix segment issue caused by trigger
agg_p.idSegment = last_prescription.idSegment

features = prescriptionutils.getFeatures(
result=agg_data, agg_date=agg_p.date, intervals_for_agg_date=True
)
Expand All @@ -240,6 +248,7 @@ def create_agg_prescription_by_date(
agg_p.aggDrugs = agg_p.features["drugIDs"]
agg_p.aggDeps = agg_p.features["departmentList"]
agg_p.update = datetime.today()
db.session.flush()

internal_prescription_ids = internal_prescription_ids = (
prescriptionutils.get_internal_prescription_ids(result=agg_data)
Expand Down

0 comments on commit 5497b98

Please sign in to comment.