Documents
Documents (FHIR Composition) are structured clinical documents with titled sections. They’re used for discharge summaries, referral letters, care plans, and other multi-section clinical documents.Create a Document
const { data: doc } = await clinik.documents.create({
status: 'final',
type: 'discharge-summary',
category: ['clinical', 'inpatient'],
patientId: 'pt_abc123',
encounterId: 'enc_xyz789',
practitionerId: 'prac_def456',
title: 'Discharge Summary - Jane Doe - Jan 15, 2025',
date: '2025-01-15',
confidentiality: 'N',
attester: [{
mode: 'professional',
time: '2025-01-15T16:00:00Z',
partyId: 'prac_attending',
}],
custodianId: 'org_hospital',
event: [{
code: [{ code: 'inpatient-stay', display: 'Inpatient Stay' }],
period: { start: '2025-01-12', end: '2025-01-15' },
}],
sections: [
{
title: 'Chief Complaint',
code: 'chief-complaint',
text: 'Patient admitted for evaluation of acute chest pain.',
},
{
title: 'Hospital Course',
code: 'hospital-course',
text: 'Cardiac workup negative. Discharged in stable condition.',
authorId: 'prac_resident', // Resident wrote this section
},
{
title: 'Discharge Medications',
code: 'medications',
text: 'Continue aspirin 81mg daily, atorvastatin 20mg daily.',
resourceIds: ['rx_aspirin', 'rx_statin'],
},
{
title: 'Follow-up',
code: 'follow-up',
text: 'PCP: 1 week. Cardiology: 4 weeks.',
},
],
});
Nested Sections
Sections can contain sub-sections for complex documents:sections: [
{
title: 'Physical Examination',
code: 'physical-exam',
text: 'General examination findings.',
sections: [
{
title: 'Cardiovascular',
code: 'cardiovascular',
text: 'Regular rate and rhythm. No murmurs, gallops, or rubs.',
},
{
title: 'Respiratory',
code: 'respiratory',
text: 'Clear to auscultation bilaterally. No wheezes or crackles.',
},
{
title: 'Neurological',
code: 'neurological',
text: 'Alert and oriented x3. Cranial nerves II-XII intact.',
},
],
},
]
Document Attestation
Track who attested to the document’s accuracy:attester: [
{
mode: 'professional',
time: '2025-01-15T16:00:00Z',
partyId: 'prac_attending',
},
{
mode: 'legal',
time: '2025-01-15T17:00:00Z',
partyId: 'prac_chief_medical_officer',
},
]
| Mode | Description |
|---|---|
personal | Attested by the individual |
professional | Attested in a professional capacity |
legal | Legally attested |
official | Officially attested |
Document Relationships
Link documents to other compositions they replace or append:// Create an amended version
const { data } = await clinik.documents.create({
status: 'amended',
type: 'discharge-summary',
patientId: 'pt_abc123',
practitionerId: 'prac_def456',
title: 'Discharge Summary - Amended',
relatesTo: [{
code: 'replaces',
targetId: 'doc_original_001',
}],
sections: [/* ... */],
});
Clinical Events
Document the clinical services being described:event: [
{
code: [{ code: 'surgical-procedure', display: 'Surgical Procedure' }],
period: { start: '2025-01-14T08:00:00Z', end: '2025-01-14T11:30:00Z' },
detailIds: ['proc_knee_replacement'],
},
]
Document Types
| Type | Description |
|---|---|
discharge-summary | Hospital discharge documentation |
referral-letter | Referral to another provider |
care-plan | Patient care plan |
operative-report | Surgical operation report |
transfer-summary | Patient transfer documentation |
consultation-report | Specialist consultation report |
Confidentiality Levels
| Code | Level | Description |
|---|---|---|
N | Normal | Standard clinical document |
R | Restricted | Limited access |
V | Very Restricted | Highly sensitive |
Update a Document
await clinik.documents.update('doc_abc123', {
status: 'amended',
attester: [{
mode: 'professional',
time: new Date().toISOString(),
partyId: 'prac_attending',
}],
sections: [
{
title: 'Addendum',
code: 'addendum',
text: 'Patient called post-discharge reporting mild nausea.',
},
],
});
Search Documents
const { data } = await clinik.documents.search({
patientId: 'pt_abc123',
type: 'discharge-summary',
status: 'final',
sort: '-date',
});
Documents vs Notes
| Resource | FHIR Type | Structure | Use Case |
|---|---|---|---|
| Note | DocumentReference | Single content block | Progress notes, SOAP notes |
| Document | Composition | Multiple titled sections | Discharge summaries, care plans |