Skip to content

Commit 18f4cc1

Browse files
committed
avoid crash for cmd file plan of care
1 parent 9f5043a commit 18f4cc1

File tree

3 files changed

+1014
-15
lines changed

3 files changed

+1014
-15
lines changed

lib/generator/ccda/templates/plan_of_care.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,26 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
2121

2222
// entries loop
2323
for (var i = 0; i < data.length; i++) {
24-
var time = libCCDAGen.getTimes(data[i]["date_time"]);
25-
xmlDoc = xmlDoc.node('entry');
26-
if (data[i]["type"] == "observation") {
27-
xmlDoc = xmlDoc.attr({typeCode: "DRIV"})
24+
var type = data[i].type;
25+
var typeInfo = info[type];
26+
if (typeInfo) {
27+
var time = libCCDAGen.getTimes(data[i]["date_time"]);
28+
xmlDoc = xmlDoc.node('entry');
29+
if (type == "observation") {
30+
xmlDoc = xmlDoc.attr({typeCode: "DRIV"})
31+
}
32+
33+
xmlDoc = xmlDoc.node(type)
34+
.attr({classCode: typeInfo[1] })
35+
.attr({moodCode: typeInfo[2]})
36+
.node('templateId').attr({root: typeInfo[0]}).parent();
37+
xmlDoc = libCCDAGen.id(xmlDoc, data[i]["identifiers"]);
38+
xmlDoc = libCCDAGen.code(xmlDoc, data[i]["plan"]).parent();
39+
xmlDoc = xmlDoc.node('statusCode').attr({code: 'new'}).parent();
40+
xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time);
41+
xmlDoc = xmlDoc.parent()
42+
.parent()
2843
}
29-
30-
xmlDoc = xmlDoc.node(data[i]["type"])
31-
.attr({classCode: info[data[i]["type"]][1] })
32-
.attr({moodCode: info[data[i]["type"]][2]})
33-
.node('templateId').attr({root: info[data[i]["type"]][0]}).parent();
34-
xmlDoc = libCCDAGen.id(xmlDoc, data[i]["identifiers"]);
35-
xmlDoc = libCCDAGen.code(xmlDoc, data[i]["plan"]).parent();
36-
xmlDoc = xmlDoc.node('statusCode').attr({code: 'new'}).parent();
37-
xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time);
38-
xmlDoc = xmlDoc.parent()
39-
.parent()
4044
}
4145
xmlDoc = xmlDoc.parent() // end section
4246
.parent(); // end component

0 commit comments

Comments
 (0)