@smarttracker/blue-button-generate
Version:
Blue Button CCDA Generator.
128 lines (122 loc) • 3.19 kB
JavaScript
;
var fieldLevel = require('../fieldLevel');
var leafLevel = require('../leafLevel');
var condition = require("../condition");
var contentModifier = require("../contentModifier");
var required = contentModifier.required;
var resultObservation = {
key: "observation",
attributes: {
classCode: "OBS",
moodCode: "EVN"
},
content: [
fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.2"),
fieldLevel.id, {
key: "code",
attributes: leafLevel.code,
dataKey: "result",
required: true
},
fieldLevel.text(leafLevel.nextReference("result")),
fieldLevel.statusCodeCompleted, [fieldLevel.effectiveTime, required], {
key: "value",
attributes: {
"xsi:type": function (input) {
return input.text ? "ST" : "PQ";
},
value: leafLevel.inputProperty("value"),
unit: leafLevel.inputProperty("unit")
},
text: leafLevel.inputProperty("text"),
existsWhen: condition.eitherKeyExists("value", "text"),
required: true
}, {
key: "interpretationCode",
attributes: {
code: function (input) {
return input.code;
},
codeSystem: "2.16.840.1.113883.5.83",
displayName: function (input) {
return input.name || input;
},
codeSystemName: "ObservationInterpretation"
},
dataKey: "interpretations"
}, {
key: "referenceRange",
content: {
key: "observationRange",
content: [{
key: "text",
text: leafLevel.input,
dataKey: "range"
}, {
key: "value",
attributes: {
"xsi:type": "IVL_PQ"
},
content: [{
key: "low",
attributes: {
value: leafLevel.inputProperty("low"),
unit: leafLevel.inputProperty("unit")
},
existsWhen: condition.keyExists("low")
}, {
key: "high",
attributes: {
value: leafLevel.inputProperty("high"),
unit: leafLevel.inputProperty("unit")
},
existsWhen: condition.keyExists("high")
}],
existsWhen: condition.eitherKeyExists("low", "high")
}],
required: true
},
dataKey: "reference_range"
}
],
notIplemented: [
"variable statusCode",
"methodCode",
"targetSiteCode",
"author"
]
};
exports.resultOrganizer = {
key: "organizer",
attributes: {
classCode: "BATTERY",
moodCode: "EVN"
},
content: [
fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.1"),
fieldLevel.uniqueId,
fieldLevel.id, {
key: "code",
attributes: leafLevel.code,
content: {
key: "translation",
attributes: leafLevel.code,
dataKey: "translations"
},
dataKey: "result_set",
required: true
},
fieldLevel.statusCodeCompleted, {
key: "component",
content: [
[resultObservation, required]
],
dataKey: "results",
required: true
}
],
notIplemented: [
"variable @classCode",
"variable statusCode"
]
};