Skip to content

Commit

Permalink
Merge c8a2205 into 0b00f40
Browse files Browse the repository at this point in the history
  • Loading branch information
mmccall committed Sep 2, 2014
2 parents 0b00f40 + c8a2205 commit 59c90fe
Show file tree
Hide file tree
Showing 24 changed files with 25,202 additions and 15,288 deletions.
14 changes: 9 additions & 5 deletions lib/generator/ccda/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ var genWholeCCDA = function (data) {
.node('setId').attr({extension: "sTT988"}).attr({root: "2.16.840.1.113883.19.5.99999.19"}).parent()
.node('versionNumber').attr({value: "1"}).parent()
.node('recordTarget')
.node('patientRole')
.node('id').attr({extension: data["demographics"]["identifiers"][0]["extension"]})
.attr({root: data["demographics"]["identifiers"][0]["identifier"]}).parent()
.node('id').attr({extension: data["demographics"]["identifiers"][1]["extension"]})
.attr({root: data["demographics"]["identifiers"][1]["identifier"]}).parent();
.node('patientRole');

if (data["demographics"]["identifiers"]) {
xmlDoc.node('id').attr({extension: data["demographics"]["identifiers"][0]["extension"]})
.attr({root: data["demographics"]["identifiers"][0]["identifier"]}).parent()
.node('id').attr({extension: data["demographics"]["identifiers"][1]["extension"]})
.attr({root: data["demographics"]["identifiers"][1]["identifier"]}).parent();
}


// generate demographics section
xmlDoc = gen(data[sectionNames[1]], true, xmlDoc, sectionNames[1]);
Expand Down
36 changes: 31 additions & 5 deletions lib/generator/ccda/templates/allergies.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
xmlDoc = libCCDAgen.code(xmlDoc, undefined,
sec_entries_codes["AllergiesSection"]).parent();
xmlDoc = xmlDoc.node('statusCode').attr({code: 'active'}).parent();
xmlDoc = libCCDAgen.effectiveTime(xmlDoc, libCCDAgen.getTimes(data[i].date_time));

if (data[i].date_time) {
xmlDoc = libCCDAgen.effectiveTime(xmlDoc, libCCDAgen.getTimes(data[i].date_time));
}


xmlDoc = xmlDoc.node('entryRelationship') // allergy observation
.attr({typeCode: "SUBJ"})
Expand All @@ -93,12 +97,28 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {

xmlDoc = xmlDoc.node('templateId')
.attr({root: "2.16.840.1.113883.10.20.22.4.7"}).parent(); // allergy intolerance observation
xmlDoc = libCCDAgen.id(xmlDoc, data[i].observation.identifiers);
if (data[i].observation) {
if (data[i].observation.identifiers) {
xmlDoc = libCCDAgen.id(xmlDoc, data[i].observation.identifiers);
}
}

xmlDoc = libCCDAgen.code(xmlDoc, undefined,
sec_entries_codes["AllergyObservation"]).parent();
xmlDoc = xmlDoc.node('statusCode').attr({code: 'completed'}).parent();
xmlDoc = libCCDAgen.effectiveTime(xmlDoc, libCCDAgen.getTimes(data[i].observation.date_time));
xmlDoc = libCCDAgen.value(xmlDoc, data[i]["observation"]["intolerance"], "CD", (i + 1));
if (data[i].observation) {
if (data[i].observation.date_time) {
xmlDoc = libCCDAgen.effectiveTime(xmlDoc, libCCDAgen.getTimes(data[i].observation.date_time));
}

}

if (data[i].observation) {
if (data[i].observation.intolerance) {
xmlDoc = libCCDAgen.value(xmlDoc, data[i]["observation"]["intolerance"], "CD", (i + 1));
}
}


if (data[i].observation && data[i].observation.allergen) {
xmlDoc = xmlDoc.node('participant')
Expand Down Expand Up @@ -127,11 +147,17 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
sec_entries_codes["AllergyStatusObservation"]).parent();
xmlDoc = xmlDoc.node('statusCode')
.attr({code: 'completed'}).parent();
xmlDoc = libCCDAgen.value(xmlDoc, data[i].observation.status, "CE");
if (data[i].observation) {
if (data[i].observation.status) {
xmlDoc = libCCDAgen.value(xmlDoc, data[i].observation.status, "CE");
}

}
xmlDoc = xmlDoc.parent()
.parent();

updateReactions(xmlDoc, data[i]);

xmlDoc = xmlDoc.node('entryRelationship').attr({typeCode: "SUBJ"}) // severity observation
.attr({inversionInd: "true"})
.node('observation').attr({classCode: "OBS"}).attr({moodCode: "EVN"})
Expand Down
11 changes: 9 additions & 2 deletions lib/generator/ccda/templates/demographics.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ module.exports = function (data, codeSystems, isCCD, xmlDoc) {
.attr({"xmlns:cda": "urn:hl7-org:v3"})

.attr({"xmlns:sdtc": "urn:hl7-org:sdtc"});
xmlDoc = libCCDAGen.id(xmlDoc, data["identifiers"]);
xmlDoc = xmlDoc.node('id')
if (data["identifiers"]) {
xmlDoc = libCCDAGen.id(xmlDoc, data["identifiers"]);
xmlDoc = xmlDoc.node('id')
.attr({extension: data["identifiers"][1]["extension"]})
.attr({root: data["identifiers"][1]["identifier"]}).parent();
}
}

xmlDoc = libCCDAGen.addr(xmlDoc, data["addresses"]);
xmlDoc = libCCDAGen.tel(xmlDoc, data["phone"]);
xmlDoc = xmlDoc.node('patient');
xmlDoc = libCCDAGen.name(xmlDoc, data["name"], "L");

if (data["gender"]) {
xmlDoc = xmlDoc.node('administrativeGenderCode')
.attr({code: data["gender"].substring(0, 1)})
.attr({codeSystem: "2.16.840.1.113883.5.1"})
.attr({displayName: data["gender"]}).parent();

}

xmlDoc = libCCDAGen.effectiveTime(xmlDoc, dob, 'birthTime');
xmlDoc = libCCDAGen.maritalStatusCode(xmlDoc, data["marital_status"]);

Expand Down
2 changes: 2 additions & 0 deletions lib/generator/ccda/templates/encounters.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
.node('encounter')
.attr({classCode: "ENC"})
.attr({moodCode: "EVN"}); // encounter activities

xmlDoc = xmlDoc.node('templateId')
.attr({root: "2.16.840.1.113883.10.20.22.4.49"}).parent();
xmlDoc = libCCDAGen.id(xmlDoc, data[i]["identifiers"]);
Expand Down Expand Up @@ -49,6 +50,7 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
}, {});
xmlDoc = libCCDAGen.indicationConstraint(xmlDoc, data[i]["findings"], libCCDAGen.getTimes(data[i]["findings"] ? data[i]["findings"][0]["date_time"] : undefined));
xmlDoc = xmlDoc.parent().parent();

}
xmlDoc = xmlDoc.parent() // end section
.parent(); // end clinicalDocument
Expand Down
5 changes: 4 additions & 1 deletion lib/generator/ccda/templates/immunizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
xmlDoc = xmlDoc.attr({moodCode: "EVN"}).attr({negationInd: "false"})
}
xmlDoc = xmlDoc.node('templateId').attr({root: "2.16.840.1.113883.10.20.22.4.52"}).parent();
xmlDoc = libCCDAGen.id(xmlDoc, data[i]["identifiers"]);

xmlDoc = libCCDAGen.id(xmlDoc, data[i]["identifiers"]);


xmlDoc = xmlDoc.node('text')
.node('reference').attr({value: "#immun" + (i+1)}).parent()
.parent()
Expand Down
13 changes: 12 additions & 1 deletion lib/generator/ccda/templates/medications.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,17 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
xmlDoc = xmlDoc.parent()
}
xmlDoc = libCCDAGen.medication_administration(xmlDoc, data[i]["administration"]);
xmlDoc = libCCDAGen.consumable(xmlDoc, data[i].product, data[i].product.unencoded_name);

if (data[i].product.unencoded_name) {

xmlDoc = libCCDAGen.consumable(xmlDoc, data[i].product, data[i].product.unencoded_name);
} else {
xmlDoc = libCCDAGen.consumable(xmlDoc, data[i].product, "");
}


xmlDoc = libCCDAGen.performerRevised(xmlDoc, data[i].performer, {});


xmlDoc = xmlDoc.node('participant').attr({typeCode: "CSM"})
.node('participantRole').attr({classCode: "MANU"}) // drug vehicle
Expand Down Expand Up @@ -122,9 +131,11 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
.node('telecom').attr({nullFlavor: "UNK"}).parent()
.node('assignedPerson');

if (data[i].supply) {
if (data[i].supply.author && data[i].supply.author.name) {
xmlDoc = libCCDAGen.name(xmlDoc, data[i].supply.author.name);
}
}
xmlDoc = xmlDoc.parent()
.parent()
.parent()
Expand Down
8 changes: 7 additions & 1 deletion lib/generator/ccda/templates/problems.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,15 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
.parent()
.node('statusCode').attr({code: "completed"}).parent();
xmlDoc = libCCDAGen.effectiveTime(xmlDoc, libCCDAGen.getTimes(data[i]["status"] ? data[i]["status"]["date_time"] : time));

if (data[i].status) {
xmlDoc = libCCDAGen.value(xmlDoc,
libCCDAGen.reverseTable("2.16.840.1.113883.3.88.12.80.68",
data[i].status.name), "CD");
data[i].status.name), "CD");
}



xmlDoc = xmlDoc.parent()
.parent();

Expand Down
32 changes: 31 additions & 1 deletion lib/generator/ccda/templates/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ var updateEntry = function(xmlDoc, entry) {
.node('statusCode').attr({code: 'completed'}).parent();
xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time);

xmlDoc = xmlDoc.node('value').attr(resultsValueAttrs(entry.results[j])).parent()



if (results["interpretations"]) {
if (results["interpretations"][0] !== undefined) {
xmlDoc = xmlDoc.node('value').attr(resultsValueAttrs(entry.results[j])).parent()
//.attr({"xsi:type": "PQ"})
//.attr({value: entry["results"][j]["value"]})
//.attr({unit: entry["results"][j]["unit"]}).parent()
Expand All @@ -50,6 +55,30 @@ var updateEntry = function(xmlDoc, entry) {
.attr({codeSystem: "2.16.840.1.113883.5.83"}).parent()
.node('referenceRange')
.node('observationRange');




}

} else {

xmlDoc = xmlDoc.node('value').attr(resultsValueAttrs(entry.results[j])).parent()
//.attr({"xsi:type": "PQ"})
//.attr({value: entry["results"][j]["value"]})
//.attr({unit: entry["results"][j]["unit"]}).parent()

.node('referenceRange')
.node('observationRange');




}




if (entry["results"][j]["reference_range"] && entry["results"][j]["reference_range"]["range"]) {
xmlDoc = xmlDoc.node('text', entry["results"][j]["reference_range"]["range"]).parent()
} else if (entry["results"][j]["reference_range"]) {
Expand Down Expand Up @@ -80,6 +109,7 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
updateEntry(xmlDoc, data[i]);
}


xmlDoc = xmlDoc.parent(); // end clinicalDocument
return isCCD ? xmlDoc : doc;
}
136 changes: 100 additions & 36 deletions lib/generator/ccda/templates/vitals.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,114 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
for (entry in entries[1]) {
sum += entries[1][entry];
}

// entries loop
var curr_sum = 0;
for (var i = 0; i < entries[0].length; i++) {
var time = libCCDAGen.getTimes(data[curr_sum]["date_time"]);
curr_sum += entries[1][entries[0][i]];

var xmlDoc = xmlDoc.node('entry').attr({typeCode: "DRIV"})
.node('organizer').attr({classCode: "CLUSTER"}).attr({moodCode: "EVN"})
.node('templateId').attr({root: "2.16.840.1.113883.10.20.22.4.26"}).parent();
xmlDoc = libCCDAGen.id(xmlDoc, data[0]["identifiers"]);
xmlDoc = libCCDAGen.code(xmlDoc, undefined, sec_entries_codes["VitalSignsOrganizer"]).parent();
xmlDoc = xmlDoc.node('statusCode')
.attr({code: data[0]['status']}).parent();
xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time);

// components loop
for (var j = 0; j < entries[1][entries[0][i]]; j++) {
var idx = ((j + (i + 1)) + j * (entries[0].length - 1));
count++;
xmlDoc = xmlDoc.node('component')
.node('observation').attr({classCode: "OBS"}).attr({moodCode: "EVN"})
.node('templateId').attr({root: "2.16.840.1.113883.10.20.22.4.27"}).parent();
xmlDoc = libCCDAGen.id(xmlDoc, data[j]["identifiers"]);
xmlDoc = libCCDAGen.code(xmlDoc, data[j]["vital"]).parent();
xmlDoc = xmlDoc.node('text')
.node('reference').attr({value: "#vit" + idx }).parent()
.parent()
.node('statusCode').attr({code: data[j]['status']}).parent();
xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time);
xmlDoc = xmlDoc.node('value')
.attr({"xsi:type": "PQ"})
.attr({value: data[j + (i == 0 ? 0 : entries[1][entries[0][i-1]])]["value"]})
.attr({unit: data[j]["unit"]}).parent()
.node('interpretationCode')
.attr({code: "N"})
.attr({codeSystem: "2.16.840.1.113883.5.83"}).parent()
.parent()
var xmlDoc = xmlDoc.node('entry').attr({
typeCode: "DRIV"
})
.node('organizer').attr({
classCode: "CLUSTER"
}).attr({
moodCode: "EVN"
})
.node('templateId').attr({
root: "2.16.840.1.113883.10.20.22.4.26"
}).parent();

xmlDoc = libCCDAGen.id(xmlDoc, data[0]["identifiers"]);

xmlDoc = libCCDAGen.code(xmlDoc, undefined, sec_entries_codes["VitalSignsOrganizer"]).parent();

if (data[0].status) {
xmlDoc = xmlDoc.node('statusCode')
.attr({
code: data[0]['status']
}).parent();
}

xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time);

// components loop
for (var j = 0; j < entries[1][entries[0][i]]; j++) {
var idx = ((j + (i + 1)) + j * (entries[0].length - 1));
count++;
xmlDoc = xmlDoc.node('component')
.node('observation').attr({
classCode: "OBS"
}).attr({
moodCode: "EVN"
})
.node('templateId').attr({
root: "2.16.840.1.113883.10.20.22.4.27"
}).parent();

xmlDoc = libCCDAGen.id(xmlDoc, data[j]["identifiers"]);

xmlDoc = libCCDAGen.code(xmlDoc, data[j]["vital"]).parent();

if (data[j].status) {
xmlDoc = xmlDoc.node('text')
.node('reference').attr({
value: "#vit" + idx
}).parent()
.parent()
}
xmlDoc = xmlDoc.parent()
.parent()
.node('statusCode').attr({
code: data[j]['status']
}).parent();
}

xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time);

if (data[j]["unit"]) {
xmlDoc = xmlDoc.node('value')
.attr({
"xsi:type": "PQ"
})
.attr({
value: data[j + (i == 0 ? 0 : entries[1][entries[0][i - 1]])]["value"]
})
.attr({
unit: data[j]["unit"]
}).parent()
.node('interpretationCode')
.attr({
code: "N"
})
.attr({
codeSystem: "2.16.840.1.113883.5.83"
}).parent()
.parent()
.parent()

} else {
xmlDoc = xmlDoc.node('value')
.attr({
"xsi:type": "PQ"
})
.attr({
value: data[j + (i == 0 ? 0 : entries[1][entries[0][i - 1]])]["value"]
})
.node('interpretationCode')
.attr({
code: "N"
})
.attr({
codeSystem: "2.16.840.1.113883.5.83"
}).parent()
.parent()
.parent()
}

}
xmlDoc = xmlDoc.parent()
.parent()
}
xmlDoc = xmlDoc.parent() // end section
.parent(); // end clinicalDocument
return isCCD ? xmlDoc : doc;
}
}
Loading

0 comments on commit 59c90fe

Please sign in to comment.