Synthetic Clinic Protocol Decision Support Skill
Purpose
This skill produces a structured, protocol-bound clinical decision-support JSON response for a synthetic clinic case. It retrieves clinical data from a read-only clinic runtime REST API, cross-references that data with applicable protocol materials, and returns a single JSON object that conforms exactly to the supplied answer template schema.
Input Files
Before making any API calls, read these three input files in the task directory:
input/prompt.txt — Identifies the target case ID, the clinical domain (respiratory, head injury, electrolyte replacement, care management, lab-window retrieval, etc.), and any domain-specific requirements. It also names the answer template to use.
input/payloads/answer_template.json — The output schema. It defines:
- Required top-level keys
- Allowed enum values for every controlled field
- Numeric precision rules
- Object shapes with required sub-keys
- Safety-check boolean fields
- Evidence ID list rules
- The output rule: "Return exactly one JSON object … Do not include markdown, comments, or explanatory prose."
environment_access.md (provided at the workspace root or alongside the task) — Contains:
base_url: the clinic runtime base URL
credentials: HTTP headers (e.g., X-Clinic-Token)
allowed_endpoints: the exact set of METHOD /api/path routes available
Constraint: You may only call endpoints listed in allowed_endpoints. Do not mutate the runtime environment — all operations are read-only.
Clinic Runtime API
Authentication
Include the credentials header from environment_access.md in every request:
X-Clinic-Token: <value>
Core Endpoints
The clinic runtime typically exposes these read-only endpoints. Confirm the exact list from environment_access.md on each run; assume nothing beyond what is listed.
| Method |
Path |
Returns |
| GET |
/api/patients |
List of all patients |
| GET |
/api/patients/{patient_id} |
Single patient record |
| GET |
/api/cases |
List of all cases |
| GET |
/api/cases/{case_id} |
Single case record (links to patient, encounters, protocol references) |
| GET |
/api/observations |
List of all observations (lab results, vitals, clinical scores) |
| GET |
/api/medications |
List of all medication records |
| GET |
/api/allergies |
List of allergy/intolerance records |
| GET |
/api/problems |
List of problem-list / diagnosis records |
| GET |
/api/imaging |
List of imaging study records |
| GET |
/api/care-registry |
Care-management registry data (risk scores, utilization) |
| GET |
/api/sdoh |
Social determinants of health data |
| GET |
/api/protocols |
List of all clinical protocols |
| GET |
/api/protocols/{protocol_id} |
Single protocol definition |
| POST |
/api/query |
Parameterized cross-resource query (see below) |
POST /api/query
When you need to filter observations by patient, code, date range, or status, or to search across resources efficiently, use POST /api/query. The request body accepts parameters such as:
resource — the FHIR-adjacent resource type (e.g., "Observation")
patient — patient ID
code — LOINC or internal observation code (e.g., "K" for potassium)
status — observation status (e.g., "final", "preliminary")
date — date range filter with from and to (ISO-8601)
category — observation category
Adapt the query parameters to what the endpoint actually accepts; the runtime returns matching resources.
Data Retrieval Workflow
Follow this sequence for every task:
Step 1: Retrieve the Target Case
GET /api/cases/{case_id}
The case record provides:
patient_id — the patient to look up
encounter_ids or embedded encounter references
protocol_id or protocol references
- Case-level metadata (status, dates, reason codes)
Step 2: Retrieve the Patient
GET /api/patients/{patient_id}
The patient record provides demographics and may surface linked problems, allergies, or care-registry entries.
Step 3: Retrieve Protocol Material
If the case references a protocol (by ID or by category), fetch it:
GET /api/protocols/{protocol_id}
If the task domain is clear but no specific protocol ID is embedded in the case, list all protocols and locate the relevant one by name or category:
GET /api/protocols
The protocol defines decision thresholds, risk tiers, recommended actions, medication strategies, follow-up timing, and escalation rules.
Step 4: Retrieve Clinical Data
Based on the clinical domain and the fields required by the answer template, fetch the relevant resources. Typical data needs:
- Observations — lab results (potassium, eGFR, HbA1c, phosphorus), vital signs (SpO2, blood pressure, GCS), clinical scores. Filter with
POST /api/query by patient, code, date window, and status.
- Imaging — CXR, CT reports. Use
GET /api/imaging and filter by patient or case.
- Medications — Active medication list for polypharmacy assessment or allergy cross-reference. Use
GET /api/medications.
- Allergies — Intolerance records for medication-plan safety checks. Use
GET /api/allergies.
- Problems — Active problem list / diagnoses. Use
GET /api/problems.
- Care Registry — Risk scores, utilization history, care-management eligibility. Use
GET /api/care-registry.
- SDOH — Social-determinant barriers (transportation, financial, food). Use
GET /api/sdoh.
Step 5: Cross-Reference Data Against the Protocol
Apply the protocol's decision rules to the retrieved clinical data:
- Risk tiering: Map observation values (e.g., SpO2, potassium level, GCS, risk score) to the protocol's risk thresholds.
- Red flags: Identify which protocol-defined red flags are present and which are absent. Use the exact enum values from the answer template.
- Disposition: Determine the appropriate care setting from the protocol's disposition logic.
- Medication plan: Select medication, dose, route, frequency, and duration per protocol guidance, while cross-referencing the patient's allergy list. Populate
avoid_allergens from known allergies.
- Follow-up: Derive timeframe and route from the protocol's follow-up rules.
- Referrals / escalation: Map clinical and social findings to referral codes and escalation conditions.
Step 6: Assemble Evidence IDs
Collect stable identifiers from the resources actually used to form the clinical decision. Include the case ID when the template expects it. Order by descending relevance: case → primary observation(s) → supporting observations → imaging → protocol.
Use the resource's native ID field (e.g., id, observation_id, case_id). Never invent identifiers.
Step 7: Populate Safety Checks
The answer template includes boolean safety-check fields. These guard against unsupported claims:
- Set to
true when the corresponding unsafe claim is absent from the data (i.e., the claim was not made).
- Set to
false when data actually supports the claim.
Match each safety-check field to its clinical meaning and verify against the retrieved data before setting.
Response Construction Rules
Strict Schema Compliance
- Return exactly the top-level keys listed in
answer_template.json — no extra keys.
- Use only the exact enum values defined in the template. Do not paraphrase, abbreviate, or invent new values.
- Where a field is typed
string_or_null or enum_or_null, use null (JSON null) when the clinical context does not require a value — but never substitute an empty string "" for null.
- Match numeric precision: one decimal place for mmol/L values, integer hours for follow-up timeframes, integer days for medication duration, two decimal places for risk scores.
- All ISO-8601 timestamps must include seconds and the trailing
Z (UTC).
Lists
- Where the template says ordering is not meaningful, use any stable order (sorted alphabetically by enum value is a safe default).
- Where the template specifies an ordering rule (e.g., ascending by
effective_time), follow it exactly.
- Omit duplicates — each value appears at most once per list.
Evidence IDs
- Use stable, resource-level identifiers as they appear in API responses.
- Order as the template specifies (typically by descending relevance or as "case first, then clinical sources").
Safety Checks
- Each boolean field encodes a "no false X" or "no Y claim" guard.
- Map the field name to the corresponding clinical claim, search the retrieved data for evidence of that claim, and set
true if the claim is unsupported (safe) or false if data actually supports it.
General Constraints
- No narrative text. Return only the JSON object. Do not wrap it in markdown fences. Do not include comments, explanations, or preamble.
- Read-only. Do not attempt to create, update, or delete resources. All API calls must use GET or the read-only POST /api/query endpoint.
- Use only listed endpoints. The
allowed_endpoints in environment_access.md is authoritative. If an endpoint you need is not listed, work with what is available.
- Controlled vocabulary. Every scored/status/action field must use the exact enum strings from the answer template. Never substitute free-text prose for a controlled value.
- Evidence-backed. Every clinical assertion (assessment, risk tier, red flags, medication strategy) must be traceable to specific retrieved resources. Include those resource IDs in
evidence_ids.
- Allergy-aware. Before recommending a medication, check the patient's allergy list. Populate
avoid_allergens and confirm the chosen medication does not conflict.
1---2name: fewshot-attempt-01-433description: Synthetic Clinic Protocol Decision Support Skill4---5# Synthetic Clinic Protocol Decision Support Skill67## Purpose89This skill produces a structured, protocol-bound clinical decision-support JSON response for a synthetic clinic case. It retrieves clinical data from a read-only clinic runtime REST API, cross-references that data with applicable protocol materials, and returns a single JSON object that conforms exactly to the supplied answer template schema.1011## Input Files1213Before making any API calls, read these three input files in the task directory:14151. **`input/prompt.txt`** — Identifies the target case ID, the clinical domain (respiratory, head injury, electrolyte replacement, care management, lab-window retrieval, etc.), and any domain-specific requirements. It also names the answer template to use.16172. **`input/payloads/answer_template.json`** — The output schema. It defines:18 - Required top-level keys19 - Allowed enum values for every controlled field20 - Numeric precision rules21 - Object shapes with required sub-keys22 - Safety-check boolean fields23 - Evidence ID list rules24 - The output rule: "Return exactly one JSON object … Do not include markdown, comments, or explanatory prose."25263. **`environment_access.md`** (provided at the workspace root or alongside the task) — Contains:27 - `base_url`: the clinic runtime base URL28 - `credentials`: HTTP headers (e.g., `X-Clinic-Token`)29 - `allowed_endpoints`: the exact set of `METHOD /api/path` routes available3031**Constraint**: You may only call endpoints listed in `allowed_endpoints`. Do not mutate the runtime environment — all operations are read-only.3233## Clinic Runtime API3435### Authentication3637Include the credentials header from `environment_access.md` in every request:3839```40X-Clinic-Token: <value>41```4243### Core Endpoints4445The clinic runtime typically exposes these read-only endpoints. Confirm the exact list from `environment_access.md` on each run; assume nothing beyond what is listed.4647| Method | Path | Returns |48|--------|------|---------|49| GET | `/api/patients` | List of all patients |50| GET | `/api/patients/{patient_id}` | Single patient record |51| GET | `/api/cases` | List of all cases |52| GET | `/api/cases/{case_id}` | Single case record (links to patient, encounters, protocol references) |53| GET | `/api/observations` | List of all observations (lab results, vitals, clinical scores) |54| GET | `/api/medications` | List of all medication records |55| GET | `/api/allergies` | List of allergy/intolerance records |56| GET | `/api/problems` | List of problem-list / diagnosis records |57| GET | `/api/imaging` | List of imaging study records |58| GET | `/api/care-registry` | Care-management registry data (risk scores, utilization) |59| GET | `/api/sdoh` | Social determinants of health data |60| GET | `/api/protocols` | List of all clinical protocols |61| GET | `/api/protocols/{protocol_id}` | Single protocol definition |62| POST | `/api/query` | Parameterized cross-resource query (see below) |6364### POST /api/query6566When you need to filter observations by patient, code, date range, or status, or to search across resources efficiently, use `POST /api/query`. The request body accepts parameters such as:6768- `resource` — the FHIR-adjacent resource type (e.g., `"Observation"`)69- `patient` — patient ID70- `code` — LOINC or internal observation code (e.g., `"K"` for potassium)71- `status` — observation status (e.g., `"final"`, `"preliminary"`)72- `date` — date range filter with `from` and `to` (ISO-8601)73- `category` — observation category7475Adapt the query parameters to what the endpoint actually accepts; the runtime returns matching resources.7677## Data Retrieval Workflow7879Follow this sequence for every task:8081### Step 1: Retrieve the Target Case8283```84GET /api/cases/{case_id}85```8687The case record provides:88- `patient_id` — the patient to look up89- `encounter_ids` or embedded encounter references90- `protocol_id` or protocol references91- Case-level metadata (status, dates, reason codes)9293### Step 2: Retrieve the Patient9495```96GET /api/patients/{patient_id}97```9899The patient record provides demographics and may surface linked problems, allergies, or care-registry entries.100101### Step 3: Retrieve Protocol Material102103If the case references a protocol (by ID or by category), fetch it:104105```106GET /api/protocols/{protocol_id}107```108109If the task domain is clear but no specific protocol ID is embedded in the case, list all protocols and locate the relevant one by name or category:110111```112GET /api/protocols113```114115The protocol defines decision thresholds, risk tiers, recommended actions, medication strategies, follow-up timing, and escalation rules.116117### Step 4: Retrieve Clinical Data118119Based on the clinical domain and the fields required by the answer template, fetch the relevant resources. Typical data needs:120121- **Observations** — lab results (potassium, eGFR, HbA1c, phosphorus), vital signs (SpO2, blood pressure, GCS), clinical scores. Filter with `POST /api/query` by patient, code, date window, and status.122- **Imaging** — CXR, CT reports. Use `GET /api/imaging` and filter by patient or case.123- **Medications** — Active medication list for polypharmacy assessment or allergy cross-reference. Use `GET /api/medications`.124- **Allergies** — Intolerance records for medication-plan safety checks. Use `GET /api/allergies`.125- **Problems** — Active problem list / diagnoses. Use `GET /api/problems`.126- **Care Registry** — Risk scores, utilization history, care-management eligibility. Use `GET /api/care-registry`.127- **SDOH** — Social-determinant barriers (transportation, financial, food). Use `GET /api/sdoh`.128129### Step 5: Cross-Reference Data Against the Protocol130131Apply the protocol's decision rules to the retrieved clinical data:132133- **Risk tiering**: Map observation values (e.g., SpO2, potassium level, GCS, risk score) to the protocol's risk thresholds.134- **Red flags**: Identify which protocol-defined red flags are present and which are absent. Use the exact enum values from the answer template.135- **Disposition**: Determine the appropriate care setting from the protocol's disposition logic.136- **Medication plan**: Select medication, dose, route, frequency, and duration per protocol guidance, while cross-referencing the patient's allergy list. Populate `avoid_allergens` from known allergies.137- **Follow-up**: Derive timeframe and route from the protocol's follow-up rules.138- **Referrals / escalation**: Map clinical and social findings to referral codes and escalation conditions.139140### Step 6: Assemble Evidence IDs141142Collect stable identifiers from the resources actually used to form the clinical decision. Include the case ID when the template expects it. Order by descending relevance: case → primary observation(s) → supporting observations → imaging → protocol.143144Use the resource's native ID field (e.g., `id`, `observation_id`, `case_id`). Never invent identifiers.145146### Step 7: Populate Safety Checks147148The answer template includes boolean safety-check fields. These guard against unsupported claims:149- Set to `true` when the corresponding unsafe claim is **absent** from the data (i.e., the claim was not made).150- Set to `false` when data actually supports the claim.151152Match each safety-check field to its clinical meaning and verify against the retrieved data before setting.153154## Response Construction Rules155156### Strict Schema Compliance157158- Return **exactly** the top-level keys listed in `answer_template.json` — no extra keys.159- Use only the **exact enum values** defined in the template. Do not paraphrase, abbreviate, or invent new values.160- Where a field is typed `string_or_null` or `enum_or_null`, use `null` (JSON null) when the clinical context does not require a value — but never substitute an empty string `""` for null.161- Match **numeric precision**: one decimal place for mmol/L values, integer hours for follow-up timeframes, integer days for medication duration, two decimal places for risk scores.162- All ISO-8601 timestamps must include seconds and the trailing `Z` (UTC).163164### Lists165166- Where the template says ordering is not meaningful, use any stable order (sorted alphabetically by enum value is a safe default).167- Where the template specifies an ordering rule (e.g., ascending by `effective_time`), follow it exactly.168- Omit duplicates — each value appears at most once per list.169170### Evidence IDs171172- Use stable, resource-level identifiers as they appear in API responses.173- Order as the template specifies (typically by descending relevance or as "case first, then clinical sources").174175### Safety Checks176177- Each boolean field encodes a "no false X" or "no Y claim" guard.178- Map the field name to the corresponding clinical claim, search the retrieved data for evidence of that claim, and set `true` if the claim is unsupported (safe) or `false` if data actually supports it.179180## General Constraints1811821. **No narrative text.** Return only the JSON object. Do not wrap it in markdown fences. Do not include comments, explanations, or preamble.1832. **Read-only.** Do not attempt to create, update, or delete resources. All API calls must use GET or the read-only POST /api/query endpoint.1843. **Use only listed endpoints.** The `allowed_endpoints` in `environment_access.md` is authoritative. If an endpoint you need is not listed, work with what is available.1854. **Controlled vocabulary.** Every scored/status/action field must use the exact enum strings from the answer template. Never substitute free-text prose for a controlled value.1865. **Evidence-backed.** Every clinical assertion (assessment, risk tier, red flags, medication strategy) must be traceable to specific retrieved resources. Include those resource IDs in `evidence_ids`.1876. **Allergy-aware.** Before recommending a medication, check the patient's allergy list. Populate `avoid_allergens` and confirm the chosen medication does not conflict.