Skip to content

Commit

Permalink
Immunizations is fully in template
Browse files Browse the repository at this point in the history
  • Loading branch information
au2 committed Oct 9, 2014
1 parent a087a6b commit f822308
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 150 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var gen = function (data, CCD, xmlDoc, section_name) {
} else if (section_name === "encounters") {
return require('./lib/encounters.js')(data, codeSystems, CCD, xmlDoc);
} else if (section_name === "immunizations") {
return require('./lib/immunizations.js')(data, codeSystems, CCD, xmlDoc);
js2xml.fillUsingTemplate(xmlDoc, data, sectionLevel.immunizationsSectionEntriesRequired);
} else if (section_name === "medications") {
js2xml.fillUsingTemplate(xmlDoc, data, sectionLevel.medicationsSectionEntriesRequired);
} else if (section_name === "payers") {
Expand Down Expand Up @@ -162,7 +162,7 @@ var genWholeCCDA = function (data) {
var sb = xmlDoc.node('component').node('structuredBody');
// loop over all the sections and generate each one, adding them iteratively to each other
for (var i = 2; i < Object.keys(sectionNames).length; i++) {
if ((sectionNames[i] === 'allergies') || (sectionNames[i] === 'medications')) {
if ((sectionNames[i] === 'allergies') || (sectionNames[i] === 'medications') || (sectionNames[i] === 'immunizations')) {
gen(data, true, sb, sectionNames[i]);
} else {
gen(data[sectionNames[i]], true, sb, sectionNames[i]);
Expand Down
97 changes: 0 additions & 97 deletions lib/immunizations.js

This file was deleted.

24 changes: 24 additions & 0 deletions lib/templates/attrLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,27 @@ exports.code = translate.code;
exports.codeName = translate.codeName;

exports.time = translate.time;

exports.immunizationActivityAttributes = function (input) {
if (input.status) {
if (input.status === "refused") {
return {
moodCode: "EVN",
negationInd: "true"
};
}
if (input.status === "pending") {
return {
moodCode: "INT",
negationInd: "false"
};
}
if (input.status === "complete") {
return {
moodCode: "EVN",
negationInd: "false"
};
}
}
return null;
};
108 changes: 57 additions & 51 deletions lib/templates/entryLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,55 +604,61 @@ var immunizationRefusalReason = {
]
};

exports.immunizationActivity = [
common.templateId("2.16.840.1.113883.10.20.22.4.52"),
fieldLevel.id,
common.completed,
fieldLevel.effectiveTime(), {
key: "repeatNumber",
attributes: {
value: attrLevel.data("sequence_number")
},
existsWhen: function (input) {
return input.sequence_number || (input.sequence_number === "");
exports.immunizationActivity = {
key: "substanceAdministration",
attributes: [{
classCode: "SBADM"
}, attrLevel.immunizationActivityAttributes],
content: [
common.templateId("2.16.840.1.113883.10.20.22.4.52"),
fieldLevel.id,
common.completed,
fieldLevel.effectiveTime(), {
key: "repeatNumber",
attributes: {
value: attrLevel.data("sequence_number")
},
existsWhen: function (input) {
return input.sequence_number || (input.sequence_number === "");
}
}, {
key: "routeCode",
attributes: attrLevel.code,
dataKey: "administration.route"
}, {
key: "approachSiteCode",
attributes: attrLevel.code,
dataKey: "administration.body_site"
}, {
key: "doseQuantity",
attributes: {
value: attrLevel.data("value"),
unit: attrLevel.data("unit")
},
dataKey: "administration.dose"
}, {
key: "consumable",
content: immunizationMedicationInformation,
dataKey: "product"
}, {
key: "performer",
content: common.assignedEntity,
existsWhen: condition.keyExists("performer")
}, {
key: "entryRelationship",
attributes: {
typeCode: "SUBJ",
inversionInd: "true"
},
content: instructions,
dataKey: "instructions"
}, {
key: "entryRelationship",
attributes: {
typeCode: "RSON"
},
content: immunizationRefusalReason,
dataKey: "refusal_reason"
}
}, {
key: "routeCode",
attributes: attrLevel.code,
dataKey: "administration.route"
}, {
key: "approachSiteCode",
attributes: attrLevel.code,
dataKey: "administration.body_site"
}, {
key: "doseQuantity",
attributes: {
value: attrLevel.data("value"),
unit: attrLevel.data("unit")
},
dataKey: "administration.dose"
}, {
key: "consumable",
content: immunizationMedicationInformation,
dataKey: "product"
}, {
key: "performer",
content: common.assignedEntity,
existsWhen: condition.keyExists("performer")
}, {
key: "entryRelationship",
attributes: {
typeCode: "SUBJ",
inversionInd: "true"
},
content: instructions,
dataKey: "instructions"
}, {
key: "entryRelationship",
attributes: {
typeCode: "RSON"
},
content: immunizationRefusalReason,
dataKey: "refusal_reason"
}
];
]
};
25 changes: 25 additions & 0 deletions lib/templates/sectionLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,28 @@ exports.medicationsSectionEntriesRequired = {
]
}]
};

exports.immunizationsSectionEntriesRequired = {
key: "component",
content: [{
key: "section",
content: [
common.templateId("2.16.840.1.113883.10.20.22.2.2"),
common.templateId("2.16.840.1.113883.10.20.22.2.2.1"),
common.templateCode("ImmunizationsSection"),
common.templateTitle("ImmunizationsSection"), {
key: "text",
text: ""
}, {
key: "entry",
attributes: {
"typeCode": "DRIV"
},
content: [
entryLevel.immunizationActivity
],
dataKey: "immunizations"
}
]
}]
};
8 changes: 8 additions & 0 deletions test/xmlmods/ccd1Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ module.exports = [{
xpath: "h:title",
comment: "titles may differ"
}]
}, {
xpath: "2.16.840.1.113883.10.20.22.2.2.1",
description: "Immunizations Section (entries required)",
type: "rootTemplate",
childxpaths: [{
xpath: "h:title",
comment: "titles may differ"
}]
}];
8 changes: 8 additions & 0 deletions test/xmlmods/ccd1Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ module.exports = [{
xpath: "h:title",
comment: "titles may differ"
}]
}, {
xpath: "2.16.840.1.113883.10.20.22.2.2.1",
description: "Immunizations Section (entries required)",
type: "rootTemplate",
childxpaths: [{
xpath: "h:title",
comment: "titles may differ"
}]
}];

0 comments on commit f822308

Please sign in to comment.