Deterministic clinical workflow generation for structured hospital scenarios.
This illustrates code generation for adverse event handling. M123, M124, etc. represent fictitious medications
def handle_event(event):
actions = []
# Scenario: M123 - Hypersensitivity Pattern
if event["allergy_history"]:
actions.append({"type": "update_record", "target": "patient_chart", "message": "Flag hypersensitivity history for active review."})
actions.append({"type": "assign_task", "target": "care_team", "message": "Perform allergy reconciliation before medication administration."})
else:
actions.append({"type": "notify", "target": "triage_nurse", "message": "Confirm hypersensitivity history with patient."})
if event["severity"] in {"high", "critical"}:
actions.append({"type": "escalate", "target": "attending_physician", "message": "High-severity hypersensitivity pattern requires immediate assessment."})
return actions
sample_event = {
"scenario_id": 'M123',
"severity": 'high',
"locations": ['ER'],
"allergy_history": True,
"age_group": 'adult',
"lab_risk_flag": False,
}