FHIR API Reference#

This page is published from the blueprint’s source repository. Code paths mentioned here refer to files in that repository — see Clinical Diagnostic Assistant on GitHub to browse them.

The orchestrator’s POST /Composition/$analyze-note operation returns a FHIR Bundle (type: "document"). This is a walkthrough of that shape and its custom extensions, for anyone integrating with a deployed Clinical Diagnostic Assistant instance.

On the examples below: every JSON example in this document was generated by executing the orchestrator’s own Bundle-building code against the same checked-in fixture its test suite uses, rather than hand-written. IDs (urn:uuid:...) and timestamps differ on every real invocation; the shape, field names, and extension structure do not.

Request#

$analyze-note is a FHIR “Operation” (the $-prefixed name is FHIR’s convention for an operation rather than a plain resource create). The request body must be a FHIR Parameters resource with a required note string parameter and an optional patient reference:

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "note",
      "valueString": "Patient presents with SOB and CP. BP 158/96. ECG shows ST elevation. History of HTN and DM. Rule out PE."
    }
  ]
}
  • note (required): the raw clinical note text, 1–50,000 characters. Read from the named parameter’s valueString. A missing or out-of-range note returns a 422 OperationOutcome (see below).

  • patient (optional): a reference to an existing Patient resource, e.g. {"name": "patient", "valueReference": {"reference": "Patient/123"}}. _extract_parameter also accepts it as a bare valueString (a literal reference string) — whichever form is present, it becomes the patient_reference passed into build_analysis_bundle. When patient is omitted, the Bundle synthesizes a new, empty Patient resource instead (see below).

  • Anything with resourceType other than "Parameters" is rejected before pipeline execution with a 422 OperationOutcome.

An optional X-Trace-Environment request header (unrelated to the FHIR shape itself) tags this request’s Langfuse traces with a specific environment — used by the evaluation harness.

Response: success (a Bundle)#

On success, the handler builds the document Bundle — the only place in the orchestrator that assembles a Bundle — and returns it as HTTP 200 with content type application/fhir+json. The Bundle is type: "document" and carries a top-level identifier (system/value, required by FHIR’s bdl-9 invariant for document Bundles) and a timestamp.

Its entry array is built in a fixed order, and every resource in it is referenced from somewhere else in the same Bundle via urn:uuid: fullUrls (never FHIR’s .contained mechanism, since e.g. the same Patient and Device are referenced by many sibling resources):

  1. Composition — the document’s index. Always first.

  2. Patient (conditional) — present only when the request did not supply a patient reference; the Bundle then synthesizes an empty Patient with a fresh id in that case. When the request did supply patient, no Patient entry is added and every resource’s subject/author instead references the caller-supplied string directly.

  3. Device — a single synthetic resource representing the orchestrator itself (deviceName: [{"name": "Clinical Diagnostic Assistant Orchestrator", "type": "manufacturer-name"}]). Referenced as the author of the Composition, the performer of the DiagnosticReport, and the agent.who of the Provenance.

  4. Entity resources — one per entry in response.entities_normalized (see “Entities” below).

  5. Diagnosis Condition resources — one per entry in response.diagnoses.

  6. Diagnosis RiskAssessment resources — one per diagnosis, each referencing its own Condition via condition.

  7. DiagnosticReport — a single resource summarizing the whole analysis.

  8. Provenance — a single resource closing out the Bundle.

Composition#

Its type is a fixed LOINC code (11506-3, “Progress note”) and its section array mixes narrative and structured sections:

  • One narrative section per populated field of response.section_map (Subjective, Objective, Assessment, Plan, Unclassified — the Step 1 preprocessing split, unchanged). Each section’s text.div is the note text, HTML-escaped and wrapped one <p> per line, with text.status: "generated".

  • A Findings section (only if there are entity resources), whose entry lists every entity resource — Observation, Condition, or Procedure alike — so the Composition indexes all of them, not just the Observations.

  • A Diagnoses section (only if there are diagnoses), whose entry lists the diagnosis Conditions, their RiskAssessments, and the DiagnosticReport — again so every one of those resources is reachable from the document.

The Composition also carries the raw-entity-mention custom extension (see below), one instance per entry in response.entities_raw — the pre-normalization NER hits, distinct from the normalized entity resources in the Findings section.

Real excerpt (from the executed fixture; Findings/Diagnoses entries omitted here for brevity — each is a flat list of {"reference": "urn:uuid:..."} objects, one per resource of that kind):

{
  "resourceType": "Composition",
  "status": "final",
  "type": {
    "coding": [{"system": "http://loinc.org", "code": "11506-3", "display": "Progress note"}],
    "text": "Clinical Note"
  },
  "subject": {"reference": "urn:uuid:aa919f69-762e-45d5-924f-80f567443003"},
  "author": [{"reference": "urn:uuid:e184ef21-11bf-4682-a2f2-3cd8ee75c87b"}],
  "title": "Clinical Note Analysis",
  "section": [
    {
      "title": "Subjective",
      "text": {
        "status": "generated",
        "div": "<div xmlns='http://www.w3.org/1999/xhtml'><p>Patient reports fever and rash.</p></div>"
      }
    },
    {"title": "Findings", "entry": ["... one reference per entity resource ..."]},
    {"title": "Diagnoses", "entry": ["... Condition + RiskAssessment + DiagnosticReport refs ..."]}
  ]
}

Patient (conditional)#

When synthesized (no patient supplied on the request), it is an empty resource carrying only an id — the pipeline has no demographic data of its own to populate it with:

{"resourceType": "Patient", "id": "aa919f69-762e-45d5-924f-80f567443003"}

Device#

{
  "resourceType": "Device",
  "id": "e184ef21-11bf-4682-a2f2-3cd8ee75c87b",
  "deviceName": [{"name": "Clinical Diagnostic Assistant Orchestrator", "type": "manufacturer-name"}]
}

Entity resources (Observation / Condition / Procedure)#

Each normalized entity maps onto the FHIR resource type FHIR actually intends for that kind of clinical fact, based on which bucket of response.categorized_entities (Step 5’s LLM categorization) the entity’s canonical name falls into:

categorized_entities bucket

FHIR resource

Notes

diseases

Condition

category: problem-list-item; verificationStatus is refuted if negated, else unconfirmed — an NER hit means the term appeared in the note, not that the diagnosis was clinically confirmed.

procedures

Procedure

status is not-done if negated, else unknown — the pipeline only knows the procedure was mentioned, not that it was actually carried out.

symptoms, findings, other, or none of the above

Observation

interpretation: NEG (v3-ObservationInterpretation system) is added when the entity is negated.

Every entity resource carries a code (a CodeableConcept: SNOMED coding if the entity has a cui, otherwise just text) and the entity-nlp-metadata custom extension (see below). An entity that fails to match any of categorized_entities’ five buckets (diseases, procedures, symptoms, findings, other) falls back to Observation with an internal "uncategorized" bucket label in its metadata extension — a defensive path for a Step 5 categorization gap, kept distinct from the genuine "other" bucket.

Real Observation example (a negated symptom):

{
  "resourceType": "Observation",
  "status": "final",
  "code": {"text": "Chest pain"},
  "subject": {"reference": "urn:uuid:aa919f69-762e-45d5-924f-80f567443003"},
  "interpretation": [
    {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", "code": "NEG"}]}
  ],
  "extension": [{"url": "http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/entity-nlp-metadata", "extension": ["... see below ..."]}]
}

Real Condition example (a coded, non-negated disease entity):

{
  "resourceType": "Condition",
  "verificationStatus": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/condition-ver-status", "code": "unconfirmed"}]},
  "category": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/condition-category", "code": "problem-list-item"}]}],
  "code": {
    "coding": [{"system": "http://snomed.info/sct", "code": "200936003", "display": "Erythema migrans"}],
    "text": "Erythema migrans"
  },
  "subject": {"reference": "urn:uuid:aa919f69-762e-45d5-924f-80f567443003"}
}

Real Procedure example (a negated procedure):

{
  "resourceType": "Procedure",
  "status": "not-done",
  "code": {"text": "Lumbar puncture"},
  "subject": {"reference": "urn:uuid:aa919f69-762e-45d5-924f-80f567443003"}
}

Diagnosis resources (Condition + RiskAssessment)#

Each diagnosis maps onto one differential Condition plus one RiskAssessment carrying its confidence and reasoning:

  • The Condition has category: encounter-diagnosis, verificationStatus: differential, clinicalStatus: active, a SNOMED-coded code when the diagnosis has a cui, an evidence array (one ConditionEvidence per string in Diagnosis.evidence, present only when non-empty), and the supporting-knowledge-graph custom extension (see below) whenever Diagnosis.supporting_subgraph is not None.

  • The paired RiskAssessment references its Condition via condition, and carries exactly one prediction entry: probabilityDecimal (from Diagnosis.confidence) and rationale (from Diagnosis.reasoning, omitted when absent). If Diagnosis.consistency_note is set, it becomes a note annotation on the RiskAssessment.

Real example pair (top-ranked diagnosis, in-graph, with knowledge-graph support — the extension body is elided here and shown in full under “Custom extensions” below):

{
  "resourceType": "Condition",
  "clinicalStatus": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/condition-clinical", "code": "active"}]},
  "verificationStatus": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/condition-ver-status", "code": "differential"}]},
  "category": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/condition-category", "code": "encounter-diagnosis"}]}],
  "code": {
    "coding": [{"system": "http://snomed.info/sct", "code": "23502006", "display": "Lyme disease"}],
    "text": "Lyme disease"
  },
  "subject": {"reference": "urn:uuid:aa919f69-762e-45d5-924f-80f567443003"},
  "evidence": [{"code": [{"text": "erythema migrans"}]}, {"code": [{"text": "elevated ESR"}]}],
  "extension": ["... supporting-knowledge-graph, see below ..."]
}
{
  "resourceType": "RiskAssessment",
  "status": "final",
  "subject": {"reference": "urn:uuid:aa919f69-762e-45d5-924f-80f567443003"},
  "condition": {"reference": "urn:uuid:dd6f27e2-71bd-44cb-bbfc-05da6813b18d"},
  "prediction": [{"probabilityDecimal": 0.8, "rationale": "Classic presentation."}]
}

DiagnosticReport#

A single resource summarizing the analysis: status: final, code.text: "Differential diagnosis analysis", performer referencing the Device, and result referencing every Observation entity resource (DiagnosticReport.result may only reference Observations per FHIR — Condition and Procedure entity resources are reachable via the Composition’s Findings section instead, not via result). When there is at least one diagnosis, conclusion is set to "Most likely: {top diagnosis name}" (the first entry in response.diagnoses, i.e. the highest-ranked one) and conclusionCode echoes that name as a CodeableConcept.

{
  "resourceType": "DiagnosticReport",
  "status": "final",
  "code": {"text": "Differential diagnosis analysis"},
  "subject": {"reference": "urn:uuid:aa919f69-762e-45d5-924f-80f567443003"},
  "performer": [{"reference": "urn:uuid:e184ef21-11bf-4682-a2f2-3cd8ee75c87b"}],
  "result": ["... urn:uuid references to Observation entity resources only ..."],
  "conclusion": "Most likely: Lyme disease",
  "conclusionCode": [{"text": "Lyme disease"}]
}

Provenance#

Closes the Bundle: target references both the Composition and the DiagnosticReport, recorded is the same timestamp used everywhere else in the Bundle, and its single agent names the Device as author (via the standard provenance-participant-type CodeSystem):

{
  "resourceType": "Provenance",
  "target": [
    {"reference": "urn:uuid:038537a6-0e2d-4e54-b985-be75b7cff099"},
    {"reference": "urn:uuid:9bd70756-514d-4bbf-abc5-03ef99769df4"}
  ],
  "recorded": "2026-08-27T23:09:57.789009Z",
  "agent": [
    {
      "type": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/provenance-participant-type", "code": "author"}]},
      "who": {"reference": "urn:uuid:e184ef21-11bf-4682-a2f2-3cd8ee75c87b"}
    }
  ]
}

Custom extensions#

All four custom extension URLs share the base http://aimsb-clinical-diagnostic-assistant.example/fhir — a stable identifier for extension/CodeSystem identity, not a resolvable endpoint. The .example domain is deliberate: RFC 2606 reserves it for exactly this purpose, so the URIs cannot collide with a real registry or imply a published Implementation Guide.

entity-nlp-metadata#

http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/entity-nlp-metadata

Appears on every entity resource (Observation/Condition/Procedure). Children:

Child

Type

Meaning

label

string

The entity’s NER label (e.g. SYMPTOM, DISEASE, PROCEDURE, FINDING)

mentionCount

integer

How many times this canonical entity was mentioned in the note

bucket

string

Which categorized_entities bucket it fell into (diseases, procedures, symptoms, findings, other, or the defensive uncategorized fallback)

variant (repeated)

string

Each surface-text variant that normalized to this canonical entity

Real example (from the fixture’s “Fever” Observation):

{
  "url": "http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/entity-nlp-metadata",
  "extension": [
    {"url": "label", "valueString": "SYMPTOM"},
    {"url": "mentionCount", "valueInteger": 1},
    {"url": "bucket", "valueString": "symptoms"},
    {"url": "variant", "valueString": "fever"}
  ]
}

raw-entity-mention#

http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/raw-entity-mention

Appears (repeated) on the Composition, one per entry in response.entities_raw — the pre-normalization NER hits, before Step 3’s aggregation and Step 4’s semantic normalization collapse duplicates. Children:

Child

Type

Meaning

text

string

The raw mention’s surface text

label

string

Its NER label

start

integer

Character offset (start) in the (preprocessed) note

end

integer

Character offset (end)

source

string

Which NER model found it (gliner-biomed or medcat)

negated

boolean

Whether negation detection flagged this mention

concept (present only when coded)

CodeableConcept

SNOMED coding, when the raw entity has a cui (medcat-sourced only)

Real example, one coded and one uncoded mention:

{
  "url": "http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/raw-entity-mention",
  "extension": [
    {"url": "text", "valueString": "fever"},
    {"url": "label", "valueString": "SYMPTOM"},
    {"url": "start", "valueInteger": 0},
    {"url": "end", "valueInteger": 5},
    {"url": "source", "valueString": "gliner-biomed"},
    {"url": "negated", "valueBoolean": false}
  ]
}
{
  "url": "http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/raw-entity-mention",
  "extension": [
    {"url": "text", "valueString": "erythema migrans"},
    {"url": "label", "valueString": "DISEASE"},
    {"url": "start", "valueInteger": 10},
    {"url": "end", "valueInteger": 27},
    {"url": "source", "valueString": "gliner-biomed"},
    {"url": "negated", "valueBoolean": false},
    {
      "url": "concept",
      "valueCodeableConcept": {
        "coding": [{"system": "http://snomed.info/sct", "code": "200936003", "display": "erythema migrans"}]
      }
    }
  ]
}

supporting-knowledge-graph#

http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/supporting-knowledge-graph

Appears on diagnosis Condition resources whenever Diagnosis.supporting_subgraph is not None (i.e. the graph feature is enabled and the diagnosis had a cui to look up — None means “not attempted”, never encoded as this extension at all). Children:

Child

Type

Meaning

inGraph

boolean

Whether this diagnosis’s cui exists as a node in the curated knowledge graph at all. The single source of truth for “in graph” — not inferred from whether node/edge children are present, since a diagnosis can be inGraph: true with zero neighbors returned.

node (repeated)

nested (concept + layer)

A neighboring concept found by the graph traversal. concept is a CodeableConcept (SNOMED coding); layer is an integer (1 = direct neighbor of the diagnosis, 2 = neighbor of a layer-1 neighbor). The diagnosis’s own node (always layer1_nodes[0] internally, per step13_diagnosis_subgraph.py) is never re-encoded here — the frontend already has that CUI/name from the Condition’s own code.

edge (repeated)

nested (sourceCui, targetCui, relationshipType, hop)

A relationship traversed. sourceCui/targetCui are plain strings; relationshipType is a Coding (not a plain string) against the custom kg-relationship-type CodeSystem — the same 9 relationship types used throughout the system (load_graph.py, the UI’s diagnoses.ts); hop is 1 for a diagnosis→layer-1 edge or 2 for a layer-1→layer-2 edge.

Real example (Lyme disease’s subgraph — one 1-hop node/edge, one 2-hop node/edge):

{
  "url": "http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/supporting-knowledge-graph",
  "extension": [
    {"url": "inGraph", "valueBoolean": true},
    {
      "url": "node",
      "extension": [
        {"url": "concept", "valueCodeableConcept": {"coding": [{"system": "http://snomed.info/sct", "code": "200936003", "display": "erythema migrans"}]}},
        {"url": "layer", "valueInteger": 1}
      ]
    },
    {
      "url": "node",
      "extension": [
        {"url": "concept", "valueCodeableConcept": {"coding": [{"system": "http://snomed.info/sct", "code": "56717001", "display": "Borrelia burgdorferi"}]}},
        {"url": "layer", "valueInteger": 2}
      ]
    },
    {
      "url": "edge",
      "extension": [
        {"url": "sourceCui", "valueString": "23502006"},
        {"url": "targetCui", "valueString": "200936003"},
        {"url": "relationshipType", "valueCoding": {"system": "http://aimsb-clinical-diagnostic-assistant.example/fhir/CodeSystem/kg-relationship-type", "code": "ASSOCIATED_WITH"}},
        {"url": "hop", "valueInteger": 1}
      ]
    },
    {
      "url": "edge",
      "extension": [
        {"url": "sourceCui", "valueString": "200936003"},
        {"url": "targetCui", "valueString": "56717001"},
        {"url": "relationshipType", "valueCoding": {"system": "http://aimsb-clinical-diagnostic-assistant.example/fhir/CodeSystem/kg-relationship-type", "code": "CAUSATIVE_AGENT"}},
        {"url": "hop", "valueInteger": 2}
      ]
    }
  ]
}

A diagnosis whose cui isn’t in the curated graph at all produces the minimal form (no node/edge children, inGraph: false):

{
  "url": "http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/supporting-knowledge-graph",
  "extension": [{"url": "inGraph", "valueBoolean": false}]
}

intake-gate-verdict#

http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/intake-gate-verdict

Appears only on the single issue of an OperationOutcome when Step 0’s intake gate rejects a note (see “Response: rejected input” below). Its value is the gate’s verdict code as a plain valueCode — one of insufficient or off_topic (the intake gate’s own verdict values; there is no verdict code for acceptance, since an accepted note simply proceeds to a normal Bundle response instead of ever reaching this extension).

Response: rejected input (an OperationOutcome)#

Before the 14-step pipeline runs, Step 0 (the intake sufficiency gate, an LLM call) may reject the note as insufficient or off-topic. A rejection is represented as response.intake_gate being signalled internally by the intake gate; the handler detects this and returns an OperationOutcome instead of a Bundle — still HTTP 200, never a Bundle, and never conflated with a real error (see next paragraph). The outcome’s single issue has severity: "information" and code: "informational" (a rejection is an expected, non-exceptional pipeline outcome, not a fault) and carries the intake-gate-verdict extension described above.

Real example (generated by executing build_intake_gate_outcome directly):

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "extension": [
        {
          "url": "http://aimsb-clinical-diagnostic-assistant.example/fhir/StructureDefinition/intake-gate-verdict",
          "valueCode": "insufficient"
        }
      ],
      "severity": "information",
      "code": "informational",
      "details": {
        "text": "The note lacks enough clinical detail to analyze (no symptoms, history, or findings mentioned)."
      }
    }
  ]
}

Separately, a general-purpose OperationOutcome builder (severity, code, text) produces the OperationOutcome shape used for real errors (severity: "error", no intake-gate-verdict extension) — used for a malformed request body (422, code invalid), an uninitialized orchestrator (503, code transient), and an unhandled pipeline exception (500, code exception). For example, a request missing the required note parameter:

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {"text": "The 'note' parameter is required and must be 1-50000 characters."}
    }
  ]
}

Every response from $analyze-note — Bundle or OperationOutcome alike — is serialized with content type application/fhir+json, through each resource’s own FHIR serializer (so FHIR-typed values like Bundle.timestamp reach the wire correctly rather than as unencodable Python datetime objects).

GET /concepts/{cui}#

A plain (non-FHIR-wrapped) lookup endpoint for a single concept’s metadata in the curated knowledge graph, keyed by its UMLS/SNOMED CUI (the same cui values that appear throughout the Bundle’s code.coding and knowledge-graph extension fields above).

Request: GET /concepts/{cui} — no body, cui is a path parameter.

Response (200), ConceptMetadata. This endpoint reads from Neo4j, so unlike every other example in this document the field values below are illustrative rather than generated; the field set (cui, preferred_name, synonyms, cui_url) is exact:

{
  "cui": "23502006",
  "preferred_name": "Lyme disease",
  "synonyms": ["example synonym one", "example synonym two"],
  "cui_url": "http://purl.bioontology.org/ontology/SNOMEDCT/23502006"
}
  • cui_url is a computed field (_snomed_cui_url), not stored data — the same helper used to compute cui_url on RawEntity, NormalizedEntity, and Diagnosis wherever those internal schemas expose a cui.

Non-2xx responses use a plain error shape (error, optional stage, optional detail) — not OperationOutcome — since this endpoint sits outside the FHIR operation surface:

  • 503 (knowledge graph disabled/unavailable): {"error": "Knowledge graph is disabled or unavailable.", "stage": "concepts"}

  • 404 (CUI not found in the curated graph): {"error": "Concept {cui} not found in the curated graph.", "stage": "concepts"}

  • 500 (lookup error): {"error": "<exception message>", "stage": "concepts"}