c32-fhir
v2.0.0
Published
Blue Button C32 Parser
Downloads
1
Keywords
Readme
c32-fhir
C32 to FHIR parser/converter
Convert C32 xml to FHIR bundle
This library provides the following functionality
- Parse XML document using sax js parser
- Generate set of resources conformant to FHIR DSTU2
Usage example:
'use strict';
var _ = require('lodash');
var bbcms = require('./index');
// Make it transactional bundle
var makeTransactionalBundle = function (bundle, base, patientId) {
_.each(bundle.entry, function (value) {
value.request = {
'method': (value.resource.resourceType === 'Patient') ? 'PUT' : 'POST',
'url': (value.resource.resourceType === 'Patient') ? 'Patient/' + patientId : value.resource.resourceType
};
value.base = base;
});
bundle.type = 'transaction';
return bundle;
};
var request = require('request');
// Get sample file from GitHub
var istream = request.get('https://raw.githubusercontent.com/amida-tech/blue-button/master/test/fixtures/parser-c32/VA_CCD_Sample_File_Version_12_5_1.xml');
istream
.pipe(new bbcms.C32ParserStream("test" /* PatientId */))
.on('data', function (data) {
var bundle = JSON.stringify(makeTransactionalBundle(data), null, ' ');
console.log(bundle); // Result bundle
})
.on('error', function (error) {
console.log(error);
});
License
Licensed under Apache 2.0