1---2name: clinic-protocol-json-33description: Create strict JSON responses for synthetic clinic runtime decision-support tasks. Use when a prompt asks Codex to review a clinic case via runtime endpoints and return a protocol-bound answer template for adult respiratory/CAP assessment, pediatric head injury triage, potassium replacement, care-management routing, or observation-window lab retrieval.4---56# Clinic Protocol JSON78## Workflow9101. Read the user prompt and the provided `input/payloads/answer_template.json` first. Treat the template as the output contract for required keys, constants, enum values, nullability, precision, and ordering.112. Read the runtime access file supplied with the task to get the base URL and allowed endpoints. Use only that runtime for case data. Prefer read-only `GET` endpoints; use `POST /api/query` only as a read-only retrieval helper when needed.123. Fetch the target bundle with `GET /api/cases/{case_id}`. The bundle may contain `case`, `patient`, `findings`, `observations`, `imaging`, `medications`, `allergies`, `problems`, `care_registry`, and `sdoh`.134. Fetch the relevant protocol from `GET /api/protocols` and `GET /api/protocols/{protocol_id}`. Map case types to protocol families:14 - `acute_respiratory`: adult respiratory infection/CAP protocol.15 - `pediatric_head_injury`: pediatric head injury clinic triage protocol.16 - `potassium_repletion`: potassium replacement and escalation protocol.17 - `care_management`: high-risk care-management routing protocol.18 - `observation_window`: observation-window interpretation protocol.195. Derive every output field from the current case bundle, protocol, and answer template. Do not reuse identifiers, selected findings, or numeric answer values from prior examples.2021## Evidence Rules2223- Match the target `case_id` and `patient_id`. Watch for distractor observations with the same case but wrong patient, wrong code, wrong date, or non-final status.24- Use only protocol-authoritative statuses for clinical decisions, usually `status: "final"`. Non-final records can appear in excluded-observation lists when the template asks for them.25- For time-based fields, compare ISO timestamps directly after confirming the window rule. Observation-window tasks use inclusive `from` and exclusive `to` unless the case/protocol says otherwise.26- For latest-lab decisions, sort eligible observations by `effective_time`, then use `observation_id` as the tie-breaker when the template specifies it.27- Use stable source identifiers in `evidence_ids`: observation IDs, imaging IDs, registry/source IDs, and sometimes the case ID when the template or task asks for it. Do not cite a source unless it supports a selected field.2829## Domain Patterns3031### Adult Respiratory/CAP3233- Assess CAP when final imaging or observation text supports focal consolidation with compatible respiratory symptoms; assess viral URI/supportive care only when pneumonia evidence is absent.34- Identify red flags from oxygen saturation, respiratory distress/rate, blood pressure, confusion, chest pain, hemoptysis, persistent fever, worsening dyspnea, and imaging extent according to the protocol and template enums.35- Escalate to ED when protocol thresholds or high-risk red flags are met; otherwise use outpatient close follow-up when the protocol supports it.36- Build allergy-aware medication plans from active allergies. Avoid implicated antibiotic classes and keep `avoid_allergens` aligned to template enum values.37- Set safety booleans to confirm unsupported claims were avoided, such as normal chest x-ray or clear lungs when those facts are not supported.3839### Pediatric Head Injury4041- Use final neurologic observations and visit findings for GCS, loss of consciousness, vomiting count, headache course, seizure, focal weakness/deficit, basilar skull signs, photophobia, and coordination symptoms.42- Urgent or CT/ED routing is driven by protocol triggers such as repeated vomiting, worsening severe headache, seizure, basilar skull signs, focal neurologic deficit, GCS below normal, or prolonged loss of consciousness.43- Mild TBI/concussion routing applies when symptoms are present with no urgent trigger and neurologic exam is normal or near-normal.44- Populate present and absent red flags separately; absence must be explicitly supported by findings or observations.45- Add restrictions for cognitive/physical rest, return-to-learn, high-risk sports, and driving only when compatible with the current symptoms and template enums.4647### Potassium Replacement4849- Use the latest final serum potassium observation with the protocol's serum-potassium code. Exclude preliminary results and non-serum potassium codes from the replacement decision unless the template asks to list them as excluded evidence.50- Screen urgent branch before routine repletion: critically low potassium, ECG abnormality, arrhythmia symptoms, dialysis-dependent ESRD, or severe renal contraindication.51- If urgent branch is false and potassium is below the protocol target, calculate routine oral replacement from the protocol dose rule and round as specified. If urgent branch is true, defer to urgent clinician workflow and do not create routine oral-order details.52- Use current review time from the case findings when the template requires `current_time`.53- Schedule follow-up serum potassium according to the protocol/case timing, and use the protocol's lab code and medication code when the template asks for order-ready details. Never mutate the runtime or place an order.5455### Care-Management Routing5657- Use care-registry fields, active problems, final observations, active medication count, SDOH entries, and call/member-disclosure findings.58- High-risk complex-care routing is supported by high predictive risk plus triggers such as multiple chronic conditions, recent admission, dialysis or advanced CKD, heart failure, and uncontrolled diabetes.59- Identify priority problems from active diagnoses, abnormal observations, registry facts, medication burden, and member-disclosed barriers. Use only template enum codes.60- Add pharmacist referral for polypharmacy, insulin safety, or high-risk diuretic/electrolyte regimens. Add social-work or transportation referrals when SDOH domains and severity meet protocol criteria.61- Use permission-based outreach when the member is reluctant, refusing, or requests control over contact timing.62- Separate chart facts from member-disclosed facts in source provenance.6364### Observation-Window Retrieval6566- Pull target code, patient, and window boundaries from case findings and protocol materials.67- Matched observations must belong to the target patient, have the target code, be final, and fall inside the window.68- Sort matched IDs by `effective_time` ascending, then `observation_id` ascending. Use the same ordering for excluded relevant distractors when requested.69- Excluded observations are relevant records that fail because of date, code, or status. Include wrong-patient records only when the template or prompt explicitly asks for that exclusion class.70- Set `latest_final` to the latest matched final observation, or `null` only if the template allows it and no qualifying lab exists.71- Set protocol-gate and repeat-lab fields from the latest eligible value and protocol thresholds, not from non-final or out-of-window distractors.7273## Output Checks7475- Return one JSON object only. Do not include markdown, comments, explanations, or extra top-level keys unless the template explicitly allows them.76- Preserve required constants from the template and prompt, such as `task_id` and `case_id`.77- Use enum strings exactly as listed in the template; translate protocol wording into template enum values.78- Use `null` only where the template permits it. Use empty arrays for no selected items when lists are required.79- Respect array ordering rules. Treat unordered enum lists as sets with no duplicates.80- Check numeric precision and units before finalizing.81- Re-read the completed JSON against the template: every required key present, no unsupported claims, all identifiers from the current case, and every safety-check boolean logically satisfied.