Skip to main content
Documents map to the FHIR R4 Composition resource — structured clinical documents with multiple titled sections. Use documents for discharge summaries, referral letters, care plans, and operative reports: any clinical document that needs distinct sections with headings. For single-block narrative (progress notes, SOAP notes), use Notes instead.

Create a document

const { data: doc } = await clinik.documents.create({
  status: 'final',
  type: 'discharge-summary',
  patientId: 'pt_abc123',
  encounterId: 'enc_xyz789',
  practitionerId: 'prac_def456',
  title: 'Discharge Summary - Jane Doe - Jan 15, 2025',
  date: '2025-01-15',
  confidentiality: 'N',
  sections: [
    {
      title: 'Chief Complaint',
      code: 'chief-complaint',
      text: 'Patient admitted for evaluation of acute chest pain.',
    },
    {
      title: 'History of Present Illness',
      code: 'hpi',
      text:
        'Patient is a 55-year-old female presenting with substernal chest pain '
        + 'radiating to the left arm, onset 3 hours prior to admission. '
        + 'Associated with diaphoresis and shortness of breath.',
    },
    {
      title: 'Hospital Course',
      code: 'hospital-course',
      text:
        'Troponin levels negative x3. ECG showed no ST changes. '
        + 'Stress test negative for ischemia. Cardiac catheterization not indicated. '
        + 'Pain attributed to musculoskeletal cause.',
    },
    {
      title: 'Discharge Medications',
      code: 'medications',
      text:
        'Continue aspirin 81mg daily, atorvastatin 20mg daily. '
        + 'New: naproxen 500mg twice daily as needed for chest wall pain.',
      resourceIds: ['rx_aspirin', 'rx_statin', 'rx_naproxen'],
    },
    {
      title: 'Discharge Instructions',
      code: 'instructions',
      text:
        'Return to ER if chest pain recurs, worsens, or is associated with '
        + 'shortness of breath, dizziness, or syncope. '
        + 'Follow up with PCP in 1 week. Cardiology follow-up in 4 weeks.',
    },
    {
      title: 'Follow-up',
      code: 'follow-up',
      text: 'PCP: 1 week. Cardiology: 4 weeks. Repeat lipid panel in 3 months.',
    },
  ],
});

Document types

TypeDescription
discharge-summaryHospital discharge documentation
referral-letterReferral to another provider
care-planPatient care plan
operative-reportSurgical operation report
transfer-summaryPatient transfer documentation
consultation-reportSpecialist consultation report

Confidentiality levels

CodeLevelDescription
NNormalStandard clinical document
RRestrictedLimited access
VVery RestrictedHighly sensitive (e.g. mental health, substance abuse)

Sections with resource references

Sections can reference other FHIR resources by ID. This links the section narrative to the underlying structured data:
{
  title: 'Relevant Lab Results',
  code: 'lab-results',
  text: 'CMP and CBC within normal limits. See attached reports.',
  resourceIds: ['lab_cmp_001', 'lab_cbc_001'],
}

Read a document

const { data: document } = await clinik.documents.read('doc_abc123');

Update a document

Add an addendum or correct the document by setting status: 'amended':
await clinik.documents.update('doc_abc123', {
  status: 'amended',
  sections: [
    {
      title: 'Addendum',
      code: 'addendum',
      text:
        'Patient called post-discharge reporting mild nausea with naproxen. '
        + 'Advised to take with food. If persists, switch to acetaminophen.',
    },
  ],
});

Delete a document

await clinik.documents.delete('doc_abc123');

Search documents

const { data } = await clinik.documents.search({
  patientId: 'pt_abc123',
  type: 'discharge-summary',
  status: 'final',
  sort: '-date',
});

Documents vs notes

ResourceFHIR typeStructureUse case
NoteDocumentReferenceSingle content blockProgress notes, SOAP notes
DocumentCompositionMultiple titled sectionsDischarge summaries, care plans
Use Notes for single-block narrative documentation. Use documents when you need structured sections with distinct headings and the ability to reference related resources from each section.