All Projects → lantanagroup → Fhir.js

lantanagroup / Fhir.js

Licence: apache-2.0
Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Fhir.js

Validation
validation api extracted from play
Stars: ✭ 194 (+218.03%)
Mutual labels:  json, xml, validation
Autocser
AutoCSer is a high-performance RPC framework. AutoCSer 是一个以高效率为目标向导的整体开发框架。主要包括 TCP 接口服务框架、TCP 函数服务框架、远程表达式链组件、前后端一体 WEB 视图框架、ORM 内存索引缓存框架、日志流内存数据库缓存组件、消息队列组件、二进制 / JSON / XML 数据序列化 等一系列无缝集成的高性能组件。
Stars: ✭ 140 (+129.51%)
Mutual labels:  json, xml, serialization
Fspickler
A fast multi-format message serializer for .NET
Stars: ✭ 299 (+390.16%)
Mutual labels:  json, xml, serialization
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (+188.52%)
Mutual labels:  json, xml, serialization
Iguana
universal serialization engine
Stars: ✭ 481 (+688.52%)
Mutual labels:  json, xml, serialization
Xml Js
Converter utility between XML text and Javascript object / JSON text.
Stars: ✭ 874 (+1332.79%)
Mutual labels:  json, xml
Treefrog Framework
TreeFrog Framework : High-speed C++ MVC Framework for Web Application
Stars: ✭ 885 (+1350.82%)
Mutual labels:  json, xml
Evreflection
Reflection based (Dictionary, CKRecord, NSManagedObject, Realm, JSON and XML) object mapping with extensions for Alamofire and Moya with RxSwift or ReactiveSwift
Stars: ✭ 954 (+1463.93%)
Mutual labels:  json, xml
Partial.lenses.validation
Partial Lenses Validation is a JavaScript library for validating and transforming data
Stars: ✭ 39 (-36.07%)
Mutual labels:  json, validation
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (+1270.49%)
Mutual labels:  validation, serialization
Eminim
JSON serialization framework for Nim, works from a Stream directly to any type and back. Depends only on stdlib.
Stars: ✭ 32 (-47.54%)
Mutual labels:  json, serialization
Govalid
Data validation library for golang. [MIGRATING TO NEW ADDRESS]
Stars: ✭ 59 (-3.28%)
Mutual labels:  json, validation
Xmlbuilder Js
An XML builder for node.js
Stars: ✭ 843 (+1281.97%)
Mutual labels:  xml, node-js
Cti Stix Validator
OASIS TC Open Repository: Validator for STIX 2.0 JSON normative requirements and best practices
Stars: ✭ 24 (-60.66%)
Mutual labels:  json, validation
Play Json Extra
playframework2 json extra module. provide convenience functions for define Format, Reads, Writes
Stars: ✭ 20 (-67.21%)
Mutual labels:  json, serialization
Ps Webapi
(Migrated from CodePlex) Let PowerShell Script serve or command-line process as WebAPI. PSWebApi is a simple library for building ASP.NET Web APIs (RESTful Services) by PowerShell Scripts or batch/executable files out of the box.
Stars: ✭ 24 (-60.66%)
Mutual labels:  json, xml
Val
golang JSON validation library.
Stars: ✭ 37 (-39.34%)
Mutual labels:  json, validation
Tech1 Benchmarks
Java JMH Benchmarks repository. No Longer Supported.
Stars: ✭ 50 (-18.03%)
Mutual labels:  json, serialization
Ansible Config encoder filters
Ansible role used to deliver the Config Encoder Filters.
Stars: ✭ 48 (-21.31%)
Mutual labels:  json, xml
Schemas
All schemas used for validation that are shared between our projects
Stars: ✭ 51 (-16.39%)
Mutual labels:  json, validation

FHIR.js

Node.JS library for serializing/deserializing FHIR resources between JS and XML, and validating FHIR resources. The library uses technologies that are safe for use in browser-only applications (node.js is not required).

Build Status Build Status

Key features

  • Serialization between XML and JSON
  • Validation against core spec and custom profiles
  • Evaluation of FhirPath
  • Support for multiple FHIR versions (>= STU3)
    • Loading from specific downloadable definitions

Dependencies

  • q 1.4.1
  • underscore 1.8.3
  • path 0.12.7
  • xml-js 1.6.2

Installation

npm install fhir
or
bower install fhir-js

To use in a node.js application, require the "fhir" module.

var Fhir = require('fhir').Fhir;

To use in a browser application, reference dist/bundle.js.

<script type="text/javascript" src="node_modules/fhir/dist/bundle.js"></script>
or
<script type="text/javascript" src="bower_components/fhir-js/dist/bundle.js"></script>

Basic Usage

var resource = {
  resourceType: 'Patient',
  ...
};
var fhir = new Fhir();
var xml = fhir.objToXml(resource);
var json = fhir.xmlToJson(xml);
var obj = fhir.xmlToObj(xml);
var results = fhir.validate(xml, { errorOnUnexpected: true });
results = fhir.validate(obj, {});
fhir.generateSnapshot(SnapshotGenerator.createBundle(sd1, sd2, sd3));

FHIR Version

4.0.0

FHIR.js supports FHIR version 4.0.0 by default.

If your implementation needs to support a specific FHIR version (as long as it is 3.0.1 or newer), you may download the "FHIR Definitions" from the FHIR Downloads page in JSON format and load them into the FHIR.js module.

var ParseConformance = require('fhir').ParseConformance;
var FhirVersions = require('fhir').Versions;
var Fhir = require('fhir').Fhir;

// Get the data
var newValueSets = JSON.parse(fs.readFileSync('..path..to..valuesets.json').toString());
var newTypes = JSON.parse(fs.readFileSync('..path..to..profiles-types.json').toString());
var newResources = JSON.parse(fs.readFileSync('..path..to..profiles-resources.json').toString());

// Create a parser and parse it using the parser
var parser = new ParseConformance(false, FhirVersions.STU3);           // don't load pre-parsed data
parser.parseBundle(newValueSets);
parser.parseBundle(newTypes);
parser.parseResources(newResources);

var fhir = new Fhir(parser);
fhir.xmlToJson(...);
fhir.objToXml(...);
fhir.validate(...);
// etc.

Custom-loading a version like this may not work if the FHIR spec includes changes to the StructureDefinition resource that are not accounted for in this version of the FHIR.js module. For example, recently StructureDefinition.element.binding.valueSetReference#Reference was changed to StructureDefinition.element.binding.valueSet#canonical. The FHIR.js module had to be updated to respect this change before it could properly validate value sets referenced by the StructureDefinition.

Note: For validation to validate a value set referenced by a StructureDefinition, the ValueSet resource must be loaded into the parser before the StructureDefinition is loaded.

Documentation

API documentation can be found at http://lantanagroup.github.io/FHIR.js/

Decimal types

The FHIR specification requires that decimal values have arbitrary precision and be encoded in JSON as numbers. This is problematic since JavaScript numbers are 64-bit floating-point numbers that do lose precision. As a workaround:

  • xmlToObj keeps decimals as JavaScript strings so as to not lose precision
  • xmlToJson converts decimals to JSON numbers, obeying the specification. Consider using it instead of JSON.stringify(fhir.xmlToObj(xml)).
  • When parsing FHIR JSON strings, such as those produced by xmlToJson or other FHIR libraries, consider using an alternative to JSON.parse such as https://github.com/josdejong/lossless-json. This issue is mentioned in the FHIR specification: https://www.hl7.org/fhir/json.html#decimal

Implementation Notes

  • Compatible with FHIR Release 4 Candidate v3.2.0
  • FHIR profiles (within the "profiles" directory) are used to determine whether properties should be arrays, the data type and cardinality of each property, etc.. The profiles are first combined using packageProfiles.js into a single bundle of all profiles. A second pass over the profiles is performed to create a hierarchy (rather than a flat list) of the properties, and only includes information that validation is concerned about. The result of the second pass is stored in profiles/types.json and profiles/valueSets.json.

Test

npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].