joi-fhir -- Work in progress
Node.js utility for validating FHIR resources.
Quick start
Prerequisites
- Node.js 6+
- npm
- Publish permission to
joi-fhir
on NPM (Only for deployment)
Installing
npm install --save joi-fhir
Examples
const validateFhir = ;const Encounter = resourceType: 'Encounter' id: 'ENC001' ... // Validate any generic FHIR resource; // Ensure FHIR resource matches a certain type;
API
This module exports a single Function
that accepts a FHIR resource and an options
object. The function validates the FHIR resource matches the spec and returns a promise with either the validated/formatted FHIR resource or an error detailing the malformed data.
Definition
;
Parameters
Parameter | Type | Description |
---|---|---|
resource |
Object |
A FHIR resource |
options
Parameter | Type | Description | Default |
---|---|---|---|
resourceType |
String |
If provided, ensure the resource is of this type. Otherwise, allow any FHIR resource | none |
Examples
Input
encounterA
Data about an encounter.
Invocation
const validateFhir = ; return
Output
validated/formatted Encounter
Development
Install
Clone the source repository, cd
into the joi-fhir
directory, and install dependencies:
git clone git@github.com:agilemd/joi-fhir.gitcd joi-fhirnpm install
Tests
To run the unit tests:
npm test
Changes must not reduce coverage of statements, branches, and functions. To determine unit test coverage:
npm run coverage
Debug
The debug module is used for runtime logging. Omit the DEBUG
environment variable to squelch all logging. Set DEBUG
to the desired level (e.g. DEBUG=@agilemd/joi-fhir:SUBMODULE
) to restrict logging to a desired service. Or, use DEBUG=*
to get all debug output from everywhere, including dependencies.
DEBUG=@agilemd/joi-fhir* npm test
Workflow
- Feature development and bug fixing MUST occur on a non-master branch.
- All changes SHOULD be submitted to master via a Pull Request.
- Pull Requests SHOULD be merged via a merge commit. Local "in-process" commits may be squashed prior to pushing to the remote feature branch.
To enable a git hook that runs npm test
prior to pushing, cd
into the project repo and run:
touch .git/hooks/pre-pushchmod +x .git/hooks/pre-pushecho "npm test" > .git/hooks/pre-push
Build
This project follows semantic versioning. After committing the latest code to GitHub master, update the version:
npm version [major/minor/patch]
Then push the tag to GitHub and publish this package to npm:
git push origin --tagsnpm publish
References
Implementation checklist
This project is a work in progress. Any defined FHIR resource will pass validation; however, only certain resources are fully validated. The table below describes which resources have complete validation and which are in progress
Support legend
Icon | Description |
---|---|
✅ | Completely implemented |
⭕️ | Partially implemented |
🚫 | Not yet implemented |