cda-fhir
v2.0.0
Published
Blue Button CDA Parser
Downloads
414
Keywords
Readme
cda-fhir
Consolidated CDA (C-CDA) to FHIR converter
Convert C-CDA xml to FHIR bundle
Consolidated CDA (C-CDA)
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/chb/sample_ccdas/master/Vitera/Vitera_CCDA_SMART_Sample.xml');
istream
.pipe(new bbcms.CcdaParserStream("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