New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fhir

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fhir

Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries

  • 1.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.7K
decreased by-23.41%
Maintainers
1
Weekly downloads
 
Created
Source

FHIR.js

Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries

Dependencies

  • q 1.4.1
  • xml2js 0.4.9
  • xmlbuilder 2.6.4

Installation

npm install fhir

Documentation

ctor(version)

Indicate which version of FHIR the module should work with. Only DSTU1 is currently supported. If no version is specified, defaults to DSTU1.

var FHIR = require('fhir');
var fhir = new FHIR(FHIR.DSTU1);

ObjectToXml

Converts a JS object to FHIR XML.

var FHIR = require('fhir');
var myPatient = {
  resourceType: 'Patient',
  ...
};
var fhir = new FHIR(FHIR.DSTU1);
var xml = fhir.ObjectToXml(myPatient);

JsonToXml

Converts JSON to FHIR XML.

var FHIR = require('fhir');
var myPatient = {
  resourceType: 'Patient',
  ...
};
var myPatientJson = JSON.stringify(myPatient);
var fhir = new FHIR(FHIR.DSTU1);
var xml = fhir.JsonToXml(myPatientJson);

XmlToJson

Converts FHIR XML to JSON. Wrapper for XmlToObject that parses JSON into an object and returns the object

var FHIR = require('fhir');
var myPatientXml = '<Patient xmlns="http://hl7.org/fhir"><name><use value="official"/><family value="Chalmers"/><given value="Peter"/><given value="James"/></name></Patient>';
var fhir = new FHIR(FHIR.DSTU1);
fhir.XmlToJson(myPatientXml)
    .then(function(myPatientJson) {
        // Do something with myPatientJson
    })
    .catch(function(err) {
        // Do something with err
    });

XmlToObject

Converts FHIR XML to JS object

var FHIR = require('fhir');
var myPatientXml = '<Patient xmlns="http://hl7.org/fhir"><name><use value="official"/><family value="Chalmers"/><given value="Peter"/><given value="James"/></name></Patient>';
var fhir = new FHIR(FHIR.DSTU1);
fhir.XmlToObject(myPatientXml)
    .then(function(myPatient) {
        // Do something with myPatient
    })
    .catch(function(err) {
        // Do something with err
    });

Implementation Notes

  • FHIR DSTU2 is not yet supported
  • Feeds and resources are both supported. There is no need to do anything different for converting feeds vs. resources. The library will automatically detect what should be produced based on the resourceType of the JS object passed, or based on the root element of the XML.
  • Unit tests use samples pulled from the FHIR standard. Mocha is used to execute the unit tests. Either execute "mocha test" or "npm test" to run the unit tests
  • xml2js is used to parse XML and create JS
  • xmlbuilder is used to create XML from JS
  • FHIR profiles (within the "profiles" directory) are used to determine whether properties should be arrays. The profiles are loaded into memory whenever an instance of the FHIR module is created. This could be improved to reduce I/O operations...

FAQs

Package last updated on 14 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc