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’svalueString. A missing or out-of-rangenotereturns a 422OperationOutcome(see below).patient(optional): a reference to an existingPatientresource, e.g.{"name": "patient", "valueReference": {"reference": "Patient/123"}}._extract_parameteralso accepts it as a barevalueString(a literal reference string) — whichever form is present, it becomes thepatient_referencepassed intobuild_analysis_bundle. Whenpatientis omitted, the Bundle synthesizes a new, emptyPatientresource instead (see below).Anything with
resourceTypeother than"Parameters"is rejected before pipeline execution with a 422OperationOutcome.
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):
Composition— the document’s index. Always first.Patient(conditional) — present only when the request did not supply apatientreference; the Bundle then synthesizes an emptyPatientwith a fresh id in that case. When the request did supplypatient, noPatiententry is added and every resource’ssubject/authorinstead references the caller-supplied string directly.Device— a single synthetic resource representing the orchestrator itself (deviceName: [{"name": "Clinical Diagnostic Assistant Orchestrator", "type": "manufacturer-name"}]). Referenced as theauthorof theComposition, theperformerof theDiagnosticReport, and theagent.whoof theProvenance.Entity resources — one per entry in
response.entities_normalized(see “Entities” below).Diagnosis
Conditionresources — one per entry inresponse.diagnoses.Diagnosis
RiskAssessmentresources — one per diagnosis, each referencing its ownConditionviacondition.DiagnosticReport— a single resource summarizing the whole analysis.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’stext.divis the note text, HTML-escaped and wrapped one<p>per line, withtext.status: "generated".A
Findingssection (only if there are entity resources), whoseentrylists every entity resource — Observation, Condition, or Procedure alike — so the Composition indexes all of them, not just the Observations.A
Diagnosessection (only if there are diagnoses), whoseentrylists the diagnosisConditions, theirRiskAssessments, and theDiagnosticReport— 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:
|
FHIR resource |
Notes |
|---|---|---|
|
|
|
|
|
|
|
|
|
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
Conditionhascategory: encounter-diagnosis,verificationStatus: differential,clinicalStatus: active, a SNOMED-codedcodewhen the diagnosis has acui, anevidencearray (oneConditionEvidenceper string inDiagnosis.evidence, present only when non-empty), and thesupporting-knowledge-graphcustom extension (see below) wheneverDiagnosis.supporting_subgraphis notNone.The paired
RiskAssessmentreferences itsConditionviacondition, and carries exactly onepredictionentry:probabilityDecimal(fromDiagnosis.confidence) andrationale(fromDiagnosis.reasoning, omitted when absent). IfDiagnosis.consistency_noteis set, it becomes anoteannotation on theRiskAssessment.
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 |
|---|---|---|
|
string |
The entity’s NER label (e.g. |
|
integer |
How many times this canonical entity was mentioned in the note |
|
string |
Which |
|
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 |
|---|---|---|
|
string |
The raw mention’s surface text |
|
string |
Its NER label |
|
integer |
Character offset (start) in the (preprocessed) note |
|
integer |
Character offset (end) |
|
string |
Which NER model found it ( |
|
boolean |
Whether negation detection flagged this mention |
|
CodeableConcept |
SNOMED coding, when the raw entity has a |
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 |
|---|---|---|
|
boolean |
Whether this diagnosis’s |
|
nested ( |
A neighboring concept found by the graph traversal. |
|
nested ( |
A relationship traversed. |
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_urlis a computed field (_snomed_cui_url), not stored data — the same helper used to computecui_urlonRawEntity,NormalizedEntity, andDiagnosiswherever those internal schemas expose acui.
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"}