Skip to main content

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',
  },
]
ModeDescription
personalAttested by the individual
professionalAttested in a professional capacity
legalLegally attested
officialOfficially 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

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

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

ResourceFHIR TypeStructureUse Case
NoteDocumentReferenceSingle content blockProgress notes, SOAP notes
DocumentCompositionMultiple titled sectionsDischarge summaries, care plans