FHIRKit Client

1.9.2 · active · verified Tue Apr 21

fhir-kit-client is a robust Node.js FHIR client library designed to facilitate interaction with FHIR servers. Currently at version 1.9.2, it maintains an active release cycle, frequently updating its 1.x.x branch to incorporate new features and fixes. This library supports a wide range of FHIR versions, including R4, STU3, and DSTU2, ensuring broad compatibility with various healthcare systems. It offers comprehensive support for all FHIR REST actions, operations, and advanced features like pagination, batch/transaction processing, and handling of absolute, in-bundle, and contained references. A key differentiator is its emphasis on modern JavaScript practices, utilizing a contemporary async/await structure and ES6 Classes, while also providing full TypeScript support. It includes features like metadata caching, SMART security integration, and capability-checking based on server statements. The library is built with minimal dependencies, aiming for efficiency and ease of integration into existing projects.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the FHIR client, retrieves SMART authentication metadata, reads a specific patient resource, and demonstrates searching with pagination using async/await syntax.

const Client = require('fhir-kit-client');
const fhirClient = new Client({
  baseUrl: 'https://sb-fhir-stu3.smarthealthit.org/smartstu3/open'
});

async function asyncExamples() {
  // Get SMART URLs for OAuth
  let response = await fhirClient.smartAuthMetadata();
  console.log('SMART Auth Metadata:', response);

  // Read a patient
  response = await fhirClient.read({
    resourceType: 'Patient',
    id: '2e27c71e-30c8-4ceb-8c1c-5641e066c0a4'
  });
  console.log('Read Patient:', response);

  // Search for patients with pagination
  response = await fhirClient.search({ resourceType: 'Patient', searchParams: { _count: '1', gender: 'female' } });
  console.log('Search Results (Page 1):', response);

  if (response.link && response.link.find(l => l.relation === 'next')) {
    const nextPageResponse = await fhirClient.nextPage(response);
    console.log('Search Results (Next Page):', nextPageResponse);
  }
}

asyncExamples().catch(console.error);

view raw JSON →