Skip to content

Commit

Permalink
procedure fields in template
Browse files Browse the repository at this point in the history
  • Loading branch information
au2 committed Oct 10, 2014
1 parent 37e09cd commit cdd34bf
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 43 deletions.
91 changes: 48 additions & 43 deletions lib/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var libCCDAGen = require("../lib/templating_functions.js");
var bbm = require("blue-button-meta");
var sec_entries_codes = bbm.CCDA.sections_entries_codes["codes"];

var js2xml = require('./templates/js2xml');
var entryLevel = require('./templates/entryLevel');

var procTypeToAttr = function (procType) {
var len = (procType === "procedure" ? 4 : 3);
return {
Expand Down Expand Up @@ -37,54 +40,56 @@ module.exports = function (data, codeSystems, isCCD, CCDxml) {
var typeAttr = procTypeToAttr(procType);
var t = e.node(procType).attr(typeAttr);

t.node('templateId').attr({
root: templateIds[procType]
});
//t.node('templateId').attr({
// root: templateIds[procType]
//});

libCCDAGen.id(t, data[i].identifiers);
//libCCDAGen.id(t, data[i].identifiers);

var p = libCCDAGen.code(t, data[i].procedure);
p.node('originalText').node('reference').attr({
value: "#Proc_" + (i + 1)
});
//var p = libCCDAGen.code(t, data[i].procedure);
//p.node('originalText').node('reference').attr({
// value: "#Proc_" + (i + 1)
//});

if (data[i].status) {
var statusCodeObject = libCCDAGen.reverseTable("2.16.840.1.113883.11.20.9.22", data[i].status);
libCCDAGen.code(t, statusCodeObject, 'statusCode');
}
//if (data[i].status) {
// var statusCodeObject = libCCDAGen.reverseTable("2.16.840.1.113883.11.20.9.22", data[i].status);
// libCCDAGen.code(t, statusCodeObject, 'statusCode');
//}

libCCDAGen.effectiveTime(t, data[i].date_time);
js2xml.update(t, data[i], entryLevel.procedureActivity);

libCCDAGen.code(t, data[i].priority, 'priorityCode');
if (procType === "observation") {
t.node("value").attr({
"xsi:type": "CD"
});
}
if (procType !== "act") {
t.node('methodCode').attr({
nullFlavor: "UNK"
});
}
if (data[i].body_sites) {
libCCDAGen.code(t, data[i].body_sites[0], 'targetSiteCode');
}
if ((procType === "procedure") && data[i].specimen) {
var sp = t.node('specimen').attr({
typeCode: "SPC"
});
var sr = sp.node('specimenRole').attr({
classCode: "SPEC"
});
libCCDAGen.id(sr, data[i].specimen.identifiers);
var spe = sr.node('specimenPlayingEntity');
libCCDAGen.code(spe, data[i].specimen.code);
}
var dPerformer = data[i].performer;
if (dPerformer) {
libCCDAGen.performerRevised(t, dPerformer[0]);
}
libCCDAGen.participant(t, data[i].locations);
//libCCDAGen.effectiveTime(t, data[i].date_time);

//libCCDAGen.code(t, data[i].priority, 'priorityCode');
//if (procType === "observation") {
// t.node("value").attr({
// "xsi:type": "CD"
// });
//}
//if (procType !== "act") {
// t.node('methodCode').attr({
// nullFlavor: "UNK"
// });
//}
//if (data[i].body_sites) {
// libCCDAGen.code(t, data[i].body_sites[0], 'targetSiteCode');
//}
// if ((procType === "procedure") && data[i].specimen) {
// var sp = t.node('specimen').attr({
// typeCode: "SPC"
// });
// var sr = sp.node('specimenRole').attr({
// classCode: "SPEC"
// });
// libCCDAGen.id(sr, data[i].specimen.identifiers);
// var spe = sr.node('specimenPlayingEntity');
// libCCDAGen.code(spe, data[i].specimen.code);
// }
//var dPerformer = data[i].performer;
//if (dPerformer) {
// libCCDAGen.performerRevised(t, dPerformer[0]);
//}
//libCCDAGen.participant(t, data[i].locations);
}
}
xmlDoc = xmlDoc.parent() // end section
Expand Down
86 changes: 86 additions & 0 deletions lib/templates/entryLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,3 +909,89 @@ exports.encounterActivities = {
}
]
};

exports.procedureActivity = [{
key: "templateId",
attributes: {
"root": "2.16.840.1.113883.10.20.22.4.12"
},
existsWhen: function (input) {
return input.procedure_type === "act";
}
}, {
key: "templateId",
attributes: {
"root": "2.16.840.1.113883.10.20.22.4.13"
},
existsWhen: function (input) {
return input.procedure_type === "observation";
}
}, {
key: "templateId",
attributes: {
"root": "2.16.840.1.113883.10.20.22.4.14"
},
existsWhen: function (input) {
return input.procedure_type === "procedure";
}
}, fieldLevel.id, {
key: "code",
attributes: attrLevel.code,
dataKey: "procedure"
}, {
key: "value",
attributes: {
"xsi:type": "CD"
},
existsWhen: function (input) {
return input.procedure_type === "observation";
}
}, {
key: "priorityCode",
attributes: attrLevel.code,
dataKey: "priority"
}, {
key: "statusCode",
attributes: attrLevel.codeName("2.16.840.1.113883.11.20.9.22"),
dataKey: "status"
}, {
key: "targetSiteCode",
attributes: attrLevel.code,
dataKey: "body_sites"
}, {
key: "performer",
content: common.assignedEntity,
dataKey: "performer"
}, {
key: "participant",
attributes: {
typeCode: "LOC"
},
content: serviceDeliveryLocation,
dataKey: "locations"
},
fieldLevel.effectiveTime(), {
key: "specimen",
attributes: {
typeCode: "SPC"
},
content: {
key: "specimenRole",
attributes: {
classCode: "SPEC"
},
content: [
fieldLevel.id, {
key: "specimenPlayingEntity",
content: {
key: "code",
attributes: attrLevel.code,
dataKey: "code"
},
existsWhen: condition.keyExists("code")
}
]
},
dataKey: "specimen"
}
];

0 comments on commit cdd34bf

Please sign in to comment.