Skip to content

Commit

Permalink
Pivotal story #188742640, need to mark_next_outgoing() AFTER changi…
Browse files Browse the repository at this point in the history
…ng status of communication request.
  • Loading branch information
pbugni committed Jan 7, 2025
1 parent c511224 commit cc8ba93
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions isacc_messaging/api/isacc_record_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,7 @@ def execute_requests(self) -> Tuple[List[dict], List[dict]]:
sent = 0
for cr_json in next_in_bundle(result):
cr = CommunicationRequest(cr_json)
# as that message was likely the next-outgoing for the patient,
# update the extension used to track next-outgoing-message time
patient = resolve_reference(cr.recipient[0].reference)
patient.mark_next_outgoing()

# Do not interact with CR if the patient is inactive or sending date is past the cutoff
if not patient.active or cr.occurrenceDateTime.date < cutoff:
Expand All @@ -358,6 +355,7 @@ def execute_requests(self) -> Tuple[List[dict], List[dict]]:
revoked_reason = "Past the cutoff"
cr.report_cr_status(status_reason=revoked_reason)
errors.append({'id': cr.id, 'error': revoked_reason})
patient.mark_next_outgoing() # update given state change
continue

# Otherwise, create a communication
Expand All @@ -384,6 +382,7 @@ def execute_requests(self) -> Tuple[List[dict], List[dict]]:
extra={"Updated Communication": stopped_comm},
level='debug'
)
patient.mark_next_outgoing() # update given state change
continue

# Otherwise, update according to the feedback from the dispatch
Expand Down Expand Up @@ -419,6 +418,7 @@ def execute_requests(self) -> Tuple[List[dict], List[dict]]:
extra={"resource": f"Communication/{comm.id}", "statusReason": e},
level='exception'
)
patient.mark_next_outgoing() # update given state change

# Flooding system on occasions such as a holiday message to all,
# leads to an overwhelmed system. Restrict the flood by processing
Expand Down

0 comments on commit cc8ba93

Please sign in to comment.