-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (52 loc) · 1.93 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"use strict";
/*
This script converts CCDA data in JSON format (originally generated from a Continuity of Care Document (CCD) in
standard XML/CCDA format) back to XML/CCDA format.
*/
var bbu = require("blue-button-util");
var engine = require('./lib/engine');
var documentLevel = require('./lib/documentLevel');
var bbuo = bbu.object;
var html_renderer = require('./lib/htmlHeaders');
var createContext = (function () {
var base = {
nextReference: function (referenceKey) {
var index = this.references[referenceKey] || 0;
++index;
this.references[referenceKey] = index;
return "#" + referenceKey + index;
},
sameReference: function (referenceKey) {
var index = this.references[referenceKey] || 0;
return "#" + referenceKey + index;
}
};
return function (options) {
var result = Object.create(base);
result.references = {};
if (options.meta && options.addUniqueIds) {
result.rootId = bbuo.deepValue(options.meta, 'identifiers.0.identifier');
} else {
result.rootId = null;
}
result.preventNullFlavor = options.preventNullFlavor;
return result;
};
})();
var generate = exports.generate = function (template, input, options) {
if (!options.html_renderer) {
options.html_renderer = html_renderer;
}
var context = createContext(options);
return engine.create(documentLevel.ccd2(options.html_renderer), input, context);
};
exports.generateCCD = function (input, options) {
options = options || {};
options.meta = input.meta;
return generate(documentLevel.ccd, input, options);
};
exports.fieldLevel = require("./lib/fieldLevel");
exports.entryLevel = require("./lib/entryLevel");
exports.leafLevel = require('./lib/leafLevel');
exports.contentModifier = require("./lib/contentModifier");
exports.condition = require('./lib/condition');