Fix the release gate for dose suggestions
Your task
Your clinical decision support tool suggests medication doses, and an AI agent wrote the dosing logic. Its tests pass, but they encode the agent's own idea of the rules. So a suggestion reaches staff only through a gate: the dose must sit inside an independent clinical reference range, and a clinician must have signed off the dosing rules.
An assistant wrote screen_dose_suggestions(case_ids, suggested_mg, reference_low_mg, reference_high_mg, clinician_signed_off), the gate. It is in the editor. It has a bug. Find it and fix it.
Input and output:
- Five lists, one entry per case at the same index: the case id, the suggested dose in mg, the low and high ends of the reference range in mg, and whether a clinician signed off.
- Return one verdict per case, in order, written
<case id>|<result>.
Rules the tests check:
- If the lists differ in length, use only the first n cases, where n is the length of the shortest list.
- Check in this order and use the first result that applies:
- The low end is greater than the high end:
hold:bad_reference_range. - The dose is outside the range:
hold:out_of_range. The range includes both ends, with a slack of 0.000000001 mg: the dose is outside only when it is below low minus that slack or above high plus it. - No clinician sign-off:
hold:no_clinician_signoff. - Otherwise:
release.
- The low end is greater than the high end:
Examples
screen_dose_suggestions(case_ids: list[str], suggested_mg: list[float], reference_low_mg: list[float], reference_high_mg: list[float], clinician_signed_off: list[bool]) -> list[str]Example 1
Input
screen_dose_suggestions(["case-1", "case-2"], [250, 900], [125, 250], [500, 500], [True, True])Output
["case-1|release", "case-2|hold:out_of_range"]Example 2
Input
screen_dose_suggestions(["case-3"], [300], [125], [500], [False])Output
["case-3|hold:no_clinician_signoff"]