Clinic Decision Support Skill
Produce protocol-bound clinical decision-support responses by querying a synthetic clinic runtime API and returning a single structured JSON object conforming to a supplied answer template.
When to use
Invoke this skill when the task involves:
- A clinic case identifier (e.g.,
CASE-*-NNN) in the prompt
- A structured answer template (
answer_template.json) in the task payloads
- A clinic runtime environment described in a separate environment-access file
- A requirement to return exactly one JSON object with controlled vocabulary
Operating rules
Phase 1: Load environment configuration
Read the environment-access file provided alongside the task. It contains:
base_url — the clinic runtime API root (referenced in prompts as <TASK_ENV_BASE_URL>)
credentials — authentication headers or tokens (e.g., X-Clinic-Token)
allowed_endpoints — the exact set of HTTP method + path patterns available for this run
Only call endpoints listed in allowed_endpoints. Use the provided credential on every request.
Phase 2: Understand the task
Read the prompt (prompt.txt) to identify:
- The target case identifier (e.g.,
CASE-RESP-102)
- The clinical domain (respiratory, head injury, electrolyte, care management, lab window, etc.)
- Any domain-specific instructions or constraints
Read the answer template (payloads/answer_template.json) to understand:
- Every required top-level key and its type
- All enum constraints — every field that takes controlled values lists them explicitly
- Nullable fields — which keys permit
null and under what conditions
- Numeric precision rules — decimal places, integer-only fields, units
- Output rules — no extra keys, no markdown, no prose outside the JSON object
- Ordering rules — most list fields specify that evaluators normalize as sets (order is not meaningful)
Phase 3: Gather clinical data from the API
Follow this general sequence, adapting to the domain and available endpoints:
Fetch the case — GET /api/cases/{case_id}. Extract the patient_id and any case-level metadata.
Fetch the patient — GET /api/patients/{patient_id}. Note demographics and relevant history.
Fetch domain-relevant clinical resources. Based on the clinical domain, pull from:
GET /api/observations — lab results, vitals, clinical measurements. Filter by patient, code, date range, and status (final vs preliminary).
GET /api/medications — active and historical medication orders.
GET /api/allergies — documented allergies and intolerances. Cross-reference against any medication plan.
GET /api/imaging — imaging studies and reports (e.g., CXR for respiratory cases).
GET /api/problems — active problem list / diagnoses.
GET /api/care-registry — care management enrollment, risk scores, program eligibility.
GET /api/sdoh — social determinants of health (transportation, financial, food barriers).
GET /api/protocols — list available clinical protocols; filter by domain.
GET /api/protocols/{protocol_id} — retrieve the full text of a relevant protocol for decision thresholds.
POST /api/query — submit structured or parameterized queries when the GET endpoints lack sufficient filter granularity.
Validate data completeness. Before synthesizing, confirm:
- The case and patient records were retrieved successfully
- All clinical data needed to populate the template's required fields is available
- Observation values include
effective_time for temporal reasoning
- Allergy records have been checked against any planned medication
Phase 4: Synthesize the response
Apply clinical reasoning within the exact vocabulary of the answer template:
- Match findings to enum values — never invent values outside the template's
allowed_values lists. If the clinical picture doesn't perfectly match any allowed value, choose the closest match rather than creating a new term.
- Cross-reference allergies with medications — populate
avoid_allergens or equivalent fields by checking the medication plan against documented allergies. Set safety-check booleans as required by the template.
- Apply protocol thresholds — use protocol documents to determine risk tiers, replacement requirements, imaging recommendations, and disposition. When a protocol provides a numeric threshold (e.g., potassium ≤ 3.3 mmol/L → replace), apply it precisely.
- Handle temporal windows — when the task specifies a date window (e.g., "March 2026"), compute the ISO-8601 range, filter observations by
effective_time within that window, and distinguish final from non-final statuses.
- Distinguish matched from excluded observations — when the template requires both
matched_observation_ids and excluded_observation_ids, exclude observations that fail on code, date window, or status, and explain exclusions only through the structured fields.
- Populate evidence traceability — include identifiers for every clinical resource that informed the decision (case, observation, imaging, medication, protocol IDs) in the
evidence_ids or source_provenance fields. Use the case identifier first, then clinical source identifiers in descending relevance.
Phase 5: Validate and emit
Before returning the response, verify:
- Every required key is present — check against the template's
required_top_level_keys and any nested required_keys.
- No extra keys — the output must not include keys beyond those the template defines.
- All enum fields use only allowed values — scan every field against its
allowed_values list.
- Numeric precision matches — decimal fields have the correct number of decimal places; integer fields are whole numbers.
- Null is used only where permitted — the template's type declarations (e.g.,
["string", "null"] or "nullable": true) define where nulls are valid.
- Safety checks are self-consistent — e.g., a medication plan that avoids penicillin must have
no_penicillin_or_sulfa: true; a claim of normal CXR must be reflected in the corresponding safety boolean.
- Output is exactly one JSON object — no markdown fences, no leading/trailing prose, no comments.
Return the validated JSON object as the sole response.
Reusable patterns
API navigation
Always start from the case endpoint and walk outward. The case provides the patient ID; the patient provides context for filtering observations, medications, and other resources. Use the POST /api/query endpoint as a fallback when GET parameter filtering is insufficient — it accepts a JSON body with filter criteria.
Template conformance
The answer template is the authoritative schema. When in doubt between a clinical judgment and the template's vocabulary, the template wins. If no allowed value captures the clinical picture precisely, select the closest allowed value rather than defaulting to null or fabricating a value.
Allergy-aware medication planning
Before finalizing any medication field:
- Retrieve the patient's allergy list
- Check every medication name, class, and cross-reactivity group against documented allergies
- Populate
avoid_allergens with the specific allergen classes that are documented
- If the template has a
no_penicillin_or_sulfa (or equivalent) safety check, set it to true only when neither penicillin nor sulfonamide appears in the medication plan AND the patient has no documented allergy to either class
Temporal range filtering
When the task specifies a month or date range:
- Compute the inclusive start (
from) and exclusive end (to) as ISO-8601 UTC timestamps
- Filter observations by
effective_time falling within [from, to)
- Only count observations with
status: "final" unless the template explicitly permits other statuses
- Sort matched results by
effective_time ascending, then by observation_id ascending for deterministic output
- Place observations that are relevant but excluded (wrong date, code, or status) in
excluded_observation_ids
Red flag identification
When the template has a red_flags field (or equivalent):
- Red flags are clinical findings present in the case that indicate elevated risk
- Select only from the template's
allowed_values list
- Do not list a red flag that is absent — use
absent_red_flags or an equivalent field if the template provides one
- No semantic ordering — evaluators normalize as a set
Safety checks
Safety-check booleans act as assertions about what was NOT found. They are typically phrased as no_* or no_false_*:
- Set to
true to assert the finding is absent or the claim is not supported
- Set to
false to indicate the finding IS present or the claim IS supported
- Never set a safety boolean to
true if the corresponding finding actually exists in the clinical data
Reference files
references/api-surface.md — expected clinic API endpoints and their response shapes
references/template-format.md — how answer templates are structured and interpreted
1---2name: self-attempt-01-553description: Clinic Decision Support Skill4---5# Clinic Decision Support Skill67Produce protocol-bound clinical decision-support responses by querying a synthetic clinic runtime API and returning a single structured JSON object conforming to a supplied answer template.89## When to use1011Invoke this skill when the task involves:12- A clinic case identifier (e.g., `CASE-*-NNN`) in the prompt13- A structured answer template (`answer_template.json`) in the task payloads14- A clinic runtime environment described in a separate environment-access file15- A requirement to return exactly one JSON object with controlled vocabulary1617## Operating rules1819### Phase 1: Load environment configuration2021Read the environment-access file provided alongside the task. It contains:2223- `base_url` — the clinic runtime API root (referenced in prompts as `<TASK_ENV_BASE_URL>`)24- `credentials` — authentication headers or tokens (e.g., `X-Clinic-Token`)25- `allowed_endpoints` — the exact set of HTTP method + path patterns available for this run2627Only call endpoints listed in `allowed_endpoints`. Use the provided credential on every request.2829### Phase 2: Understand the task3031Read the prompt (`prompt.txt`) to identify:32- The target **case identifier** (e.g., `CASE-RESP-102`)33- The **clinical domain** (respiratory, head injury, electrolyte, care management, lab window, etc.)34- Any domain-specific instructions or constraints3536Read the answer template (`payloads/answer_template.json`) to understand:37- Every **required top-level key** and its type38- All **enum constraints** — every field that takes controlled values lists them explicitly39- **Nullable fields** — which keys permit `null` and under what conditions40- **Numeric precision rules** — decimal places, integer-only fields, units41- **Output rules** — no extra keys, no markdown, no prose outside the JSON object42- **Ordering rules** — most list fields specify that evaluators normalize as sets (order is not meaningful)4344### Phase 3: Gather clinical data from the API4546Follow this general sequence, adapting to the domain and available endpoints:47481. **Fetch the case** — `GET /api/cases/{case_id}`. Extract the `patient_id` and any case-level metadata.492. **Fetch the patient** — `GET /api/patients/{patient_id}`. Note demographics and relevant history.503. **Fetch domain-relevant clinical resources**. Based on the clinical domain, pull from:51 - `GET /api/observations` — lab results, vitals, clinical measurements. Filter by patient, code, date range, and status (`final` vs `preliminary`).52 - `GET /api/medications` — active and historical medication orders.53 - `GET /api/allergies` — documented allergies and intolerances. Cross-reference against any medication plan.54 - `GET /api/imaging` — imaging studies and reports (e.g., CXR for respiratory cases).55 - `GET /api/problems` — active problem list / diagnoses.56 - `GET /api/care-registry` — care management enrollment, risk scores, program eligibility.57 - `GET /api/sdoh` — social determinants of health (transportation, financial, food barriers).58 - `GET /api/protocols` — list available clinical protocols; filter by domain.59 - `GET /api/protocols/{protocol_id}` — retrieve the full text of a relevant protocol for decision thresholds.60 - `POST /api/query` — submit structured or parameterized queries when the GET endpoints lack sufficient filter granularity.61624. **Validate data completeness**. Before synthesizing, confirm:63 - The case and patient records were retrieved successfully64 - All clinical data needed to populate the template's required fields is available65 - Observation values include `effective_time` for temporal reasoning66 - Allergy records have been checked against any planned medication6768### Phase 4: Synthesize the response6970Apply clinical reasoning within the **exact** vocabulary of the answer template:7172- **Match findings to enum values** — never invent values outside the template's `allowed_values` lists. If the clinical picture doesn't perfectly match any allowed value, choose the closest match rather than creating a new term.73- **Cross-reference allergies with medications** — populate `avoid_allergens` or equivalent fields by checking the medication plan against documented allergies. Set safety-check booleans as required by the template.74- **Apply protocol thresholds** — use protocol documents to determine risk tiers, replacement requirements, imaging recommendations, and disposition. When a protocol provides a numeric threshold (e.g., potassium ≤ 3.3 mmol/L → replace), apply it precisely.75- **Handle temporal windows** — when the task specifies a date window (e.g., "March 2026"), compute the ISO-8601 range, filter observations by `effective_time` within that window, and distinguish `final` from non-final statuses.76- **Distinguish matched from excluded observations** — when the template requires both `matched_observation_ids` and `excluded_observation_ids`, exclude observations that fail on code, date window, or status, and explain exclusions only through the structured fields.77- **Populate evidence traceability** — include identifiers for every clinical resource that informed the decision (case, observation, imaging, medication, protocol IDs) in the `evidence_ids` or `source_provenance` fields. Use the case identifier first, then clinical source identifiers in descending relevance.7879### Phase 5: Validate and emit8081Before returning the response, verify:82831. **Every required key is present** — check against the template's `required_top_level_keys` and any nested `required_keys`.842. **No extra keys** — the output must not include keys beyond those the template defines.853. **All enum fields use only allowed values** — scan every field against its `allowed_values` list.864. **Numeric precision matches** — decimal fields have the correct number of decimal places; integer fields are whole numbers.875. **Null is used only where permitted** — the template's type declarations (e.g., `["string", "null"]` or `"nullable": true`) define where nulls are valid.886. **Safety checks are self-consistent** — e.g., a medication plan that avoids penicillin must have `no_penicillin_or_sulfa: true`; a claim of normal CXR must be reflected in the corresponding safety boolean.897. **Output is exactly one JSON object** — no markdown fences, no leading/trailing prose, no comments.9091Return the validated JSON object as the sole response.9293## Reusable patterns9495### API navigation9697Always start from the case endpoint and walk outward. The case provides the patient ID; the patient provides context for filtering observations, medications, and other resources. Use the `POST /api/query` endpoint as a fallback when GET parameter filtering is insufficient — it accepts a JSON body with filter criteria.9899### Template conformance100101The answer template is the authoritative schema. When in doubt between a clinical judgment and the template's vocabulary, the template wins. If no allowed value captures the clinical picture precisely, select the **closest** allowed value rather than defaulting to null or fabricating a value.102103### Allergy-aware medication planning104105Before finalizing any medication field:1061. Retrieve the patient's allergy list1072. Check every medication name, class, and cross-reactivity group against documented allergies1083. Populate `avoid_allergens` with the specific allergen classes that are documented1094. If the template has a `no_penicillin_or_sulfa` (or equivalent) safety check, set it to `true` only when neither penicillin nor sulfonamide appears in the medication plan AND the patient has no documented allergy to either class110111### Temporal range filtering112113When the task specifies a month or date range:114- Compute the inclusive start (`from`) and exclusive end (`to`) as ISO-8601 UTC timestamps115- Filter observations by `effective_time` falling within `[from, to)`116- Only count observations with `status: "final"` unless the template explicitly permits other statuses117- Sort matched results by `effective_time` ascending, then by `observation_id` ascending for deterministic output118- Place observations that are relevant but excluded (wrong date, code, or status) in `excluded_observation_ids`119120### Red flag identification121122When the template has a `red_flags` field (or equivalent):123- Red flags are clinical findings present in the case that indicate elevated risk124- Select only from the template's `allowed_values` list125- Do not list a red flag that is absent — use `absent_red_flags` or an equivalent field if the template provides one126- No semantic ordering — evaluators normalize as a set127128### Safety checks129130Safety-check booleans act as assertions about what was NOT found. They are typically phrased as `no_*` or `no_false_*`:131- Set to `true` to assert the finding is absent or the claim is not supported132- Set to `false` to indicate the finding IS present or the claim IS supported133- Never set a safety boolean to `true` if the corresponding finding actually exists in the clinical data134135## Reference files136137- `references/api-surface.md` — expected clinic API endpoints and their response shapes138- `references/template-format.md` — how answer templates are structured and interpreted