# fhir-extension-helpers

> FHIR Extension helper methods

Latest version **0.3.0** (published 2022-01-29) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install fhir-extension-helpers
pnpm add fhir-extension-helpers
yarn add fhir-extension-helpers
bun add fhir-extension-helpers
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2022-01-29 |
| First published | 2022-01-25 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 60.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Brian Postlethwaite |
| Maintainers | brianpos |
| Keywords | fhir, extensions |

## Links

- npm: https://www.npmjs.com/package/fhir-extension-helpers
- Repository: https://github.com/brianpos/fhir-extension-helpers
- Homepage: https://github.com/brianpos/fhir-extension-helpers#readme
- Issues: https://github.com/brianpos/fhir-extension-helpers/issues
- npm.io page: https://npm.io/package/fhir-extension-helpers

## Recent versions

- 0.3.0 (latest) — 2022-01-29
- 0.2.0 — 2022-01-27
- 0.1.0 — 2022-01-25

## 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][r4-spec]:

* 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.
``` javascript
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))
``` javascript
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)
``` javascript
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)
``` javascript
let result = exHelpers.getExtensionStringValue(sample, 'https://example.org/exturl');
```

Retrieving the collection of untyped extension values
``` javascript
let result = exHelpers.getExtensions(sample, 'https://example.org/exturl');
```

Removing all extensions with a specific URL
``` javascript
exHelpers.clearExtension(sample, 'https://example.org/exturl');
```

Setting an extension on a primitive property
``` javascript
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][javascript-zulip].

## Contributing ##
I'm welcoming contributors from the FHIR community!

[javascript-zulip]: https://chat.fhir.org/#narrow/stream/179169-javascript
[r4-spec]: http://www.hl7.org/fhir/r4

---
_Source: https://npm.io/package/fhir-extension-helpers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
