Documents
Composition — Structured Documents
Grouping related FHIR resources into a single structured clinical document
Set up the SDK server client to run the examples using esus. The REST examples use a session token. To run them with the SDK’s API key, send X-API-Key instead of Authorization.
Composition
Composition is the FHIR resource for a structured clinical document — a discharge summary, a referral letter, a care-plan package — made of titled sections that reference the underlying clinical data.
Note: Esus does not implement
DocumentManifest. To group related documents, create aCompositionand reference the relevantDocumentReference,DiagnosticReport,CarePlan, etc. from its sections. Esus stores theCompositionas a regular resource; it does not build FHIRdocumentBundles.
Create a Composition
type, title (max 500 characters) and author (at least one reference) are required. status defaults to final. date is set by the server at creation time — it is not accepted in the body. The patient and encounter are flat ids (subjectId, encounterId).
curl -X POST https://api.esus.health/fhir/Composition \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/fhir+json" \
-d '{
"status": "final",
"type": {
"coding": [{
"system": "http://loinc.org",
"code": "18842-5",
"display": "Discharge summary"
}]
},
"subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"encounterId": "c1a2e3d4-5b6f-7890-abcd-ef1234567890",
"author": [{
"reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
"display": "Dr. Sarah Johnson"
}],
"title": "Discharge summary — April 2026",
"section": [
{
"title": "Hospital course",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Uncomplicated recovery.</div>"
},
"entry": [
{ "reference": "DocumentReference/aa11bb22-cc33-dd44-ee55-ff6677889900" }
]
},
{
"title": "Lab results",
"entry": [
{ "reference": "DiagnosticReport/bb22cc33-dd44-ee55-ff66-778899001122" }
]
},
{
"title": "Follow-up plan",
"entry": [
{ "reference": "CarePlan/cc33dd44-ee55-ff66-7788-990011223344" }
]
}
]
}'
const created = await esus.fhir.create("Composition", {
"status": "final",
"type": {
"coding": [
{
"system": "http://loinc.org",
"code": "18842-5",
"display": "Discharge summary"
}
]
},
"subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"encounterId": "c1a2e3d4-5b6f-7890-abcd-ef1234567890",
"author": [
{
"reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
"display": "Dr. Sarah Johnson"
}
],
"title": "Discharge summary — April 2026",
"section": [
{
"title": "Hospital course",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Uncomplicated recovery.</div>"
},
"entry": [
{
"reference": "DocumentReference/aa11bb22-cc33-dd44-ee55-ff6677889900"
}
]
},
{
"title": "Lab results",
"entry": [
{
"reference": "DiagnosticReport/bb22cc33-dd44-ee55-ff66-778899001122"
}
]
},
{
"title": "Follow-up plan",
"entry": [
{
"reference": "CarePlan/cc33dd44-ee55-ff66-7788-990011223344"
}
]
}
]
});
Section entry references are stored as given; Esus does not check that the referenced resources exist. Other accepted fields: identifier (a single Identifier), category, confidentiality, attester, custodian, relatesTo, event, and nested section[].section.
Composition Status
| Status | Meaning |
|---|---|
preliminary | Draft, not finalized |
final | Complete and authoritative (default) |
amended | Modified after final |
entered-in-error | Should be ignored |
Search
| Parameter | Matching |
|---|---|
patient | Exact patient id |
status | Exact |
type | Substring of the stored type JSON — pass a code, e.g. type=18842-5 |
date | On date. Without a prefix, the same calendar day; supports gt, ge, lt, le, ne (e.g. date=ge2026-04-01). Repeat it for a range (date=ge2026-04-01&date=lt2026-05-01) |
encounter | Exact encounter id |
# All compositions for a patient
curl "https://api.esus.health/fhir/Composition?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6" \
-H "Authorization: Bearer YOUR_TOKEN"
# Discharge summaries only
curl "https://api.esus.health/fhir/Composition?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6&type=18842-5" \
-H "Authorization: Bearer YOUR_TOKEN"