JSPM

fhir-extension-helpers

0.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1112
  • Score
    100M100P100Q104754F
  • License BSD-3-Clause

FHIR Extension helper methods

Package Exports

  • fhir-extension-helpers
  • fhir-extension-helpers/dist/extensions.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fhir-extension-helpers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

FHIR Extension Helpers

Introduction

This is an unofficial set of helper functions to ease working with FHIR Extensions in Javascript and TypeScript.

This library provides for FHIR R4:

  • getExtension & getExtensions
  • setExtension & addExtension
  • getExtesion[Value type]Value
  • clearExtensions
  • hasExtension, hasExtensionAny

IMPORTANT Once things settle in, it will be deployed to the public npm registry

Example Usage

Setting a specific extension value (complex datatype properties/elements) Note: Will remove any other extensions with this extension URL too.

import exHelpers from 'fhir-extension-helpers';

let sample = { system: 'system', code: 'c', display: 'blah' };
exHelpers.setExtension(sample, { url: 'https://example.org/exturl', valueBoolean: true });

Adding an extension (will append to the extensions, not replace existing one(s))

exHelpers.addExtension(sample, { url: 'https://example.org/exturl', valueString: "test" });

Retrieving a specific untyped extension value (as first only - no warning if there are multiple values)

let result = exHelpers.getExtension(sample, 'https://example.org/exturl');

Retrieving a specific typed extension value (as first only - no warning if there are multiple values)

let result = exHelpers.getExtensionStringValue(sample, 'https://example.org/exturl');

Retrieving the collection of untyped extension values

let result = exHelpers.getExtensions(sample, 'https://example.org/exturl');

Removing all extensions with a specific URL

exHelpers.clearExtension(sample, 'https://example.org/exturl');

Setting an extension on a primitive property

let patient = { resourceType: 'Patient', birthDate: '1974-12-25' };
exHelpers.setExtension(patient._birthDate, 
    {
        url: 'http://hl7.org/fhir/StructureDefinition/patient-birthTime', 
        valueDateTime: '1974-12-25T14:35:45-05:00'
    },
    () => { return patient._birthDate = {} });

Support

TBD - there's not really much here... For questions and broader discussions, use the FHIR Implementers chat on Zulip.

Contributing

I'm welcoming contributors from the FHIR community!