Skip to content

Commit

Permalink
results section in template
Browse files Browse the repository at this point in the history
  • Loading branch information
au2 committed Oct 11, 2014
1 parent b41476c commit 4b5e13e
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 123 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var gen = function (data, CCD, xmlDoc, section_name) {
} else if (section_name === "procedures") {
js2xml.fillUsingTemplate(xmlDoc, data, sectionLevel.proceduresSectionEntriesRequired);
} else if (section_name === "results") {
return require('./lib/results.js')(data, codeSystems, CCD, xmlDoc);
js2xml.fillUsingTemplate(xmlDoc, data, sectionLevel.resultsSectionEntriesRequired);
} else if (section_name === "social_history") {
return require('./lib/social_history.js')(data, codeSystems, CCD, xmlDoc);
} else if (section_name === "vitals") {
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] === 'vitals') || (sectionNames[i] === 'payers') || (sectionNames[i] === 'plan_of_care') || (sectionNames[i] === 'procedures') || (sectionNames[i] === 'encounters') || (sectionNames[i] === 'allergies') || (sectionNames[i] === 'medications') || (sectionNames[i] === 'immunizations') || (sectionNames[i] === 'problems')) {
if ((sectionNames[i] === 'results') || (sectionNames[i] === 'vitals') || (sectionNames[i] === 'payers') || (sectionNames[i] === 'plan_of_care') || (sectionNames[i] === 'procedures') || (sectionNames[i] === 'encounters') || (sectionNames[i] === 'allergies') || (sectionNames[i] === 'medications') || (sectionNames[i] === 'immunizations') || (sectionNames[i] === 'problems')) {
gen(data, true, sb, sectionNames[i]);
} else {
gen(data[sectionNames[i]], true, sb, sectionNames[i]);
Expand Down
120 changes: 0 additions & 120 deletions lib/results.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/templates/condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports.keyExists = function (key) {
return function (input) {
return input[key];
return input.hasOwnProperty(key);
};
};

Expand Down
95 changes: 95 additions & 0 deletions lib/templates/entryLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1400,3 +1400,98 @@ exports.vitalSignsOrganizer = {
}
]
};

var resultObservation = exports.resultObservation = {
key: "observation",
attributes: {
classCode: "OBS",
moodCode: "EVN"
},
content: [
common.templateId("2.16.840.1.113883.10.20.22.4.2"),
fieldLevel.id, {
key: "code",
attributes: attrLevel.code,
dataKey: "result"
},
common.completed,
fieldLevel.effectiveTime(), {
key: "value",
attributes: {
"xsi:type": "PQ",
value: attrLevel.data("value"),
unit: attrLevel.data("unit")
},
existsWhen: condition.keyExists("value")
}, {
key: "interpretationCode",
attributes: {
code: function (input) {
return input.substr(0, 1);
},
codeSystem: "2.16.840.1.113883.5.83",
displayName: attrLevel.input,
codeSystemName: "ObservationInterpretation"
},
dataKey: "interpretations"
}, {
key: "referenceRange",
content: {
key: "observationRange",
content: [{
key: "text",
text: attrLevel.input,
dataKey: "range"
}, {
key: "value",
attributes: {
"xsi:type": "IVL_PQ"
},
content: [{
key: "low",
attributes: {
value: attrLevel.data("low"),
unit: attrLevel.data("unit")
},
existsWhen: condition.keyExists("low")
}, {
key: "high",
attributes: {
value: attrLevel.data("high"),
unit: attrLevel.data("unit")
},
existsWhen: condition.keyExists("high")
}],
existsWhen: condition.eitherKeyExists("low", "high")
}]
},
dataKey: "reference_range"
}
]
};

exports.resultOrganizer = {
key: "organizer",
attributes: {
classCode: "BATTERY",
moodCode: "EVN"
},
content: [
common.templateId("2.16.840.1.113883.10.20.22.4.1"),
fieldLevel.id, {
key: "code",
attributes: attrLevel.code,
content: {
key: "translation",
attributes: attrLevel.code,
dataKey: "translations"
},
dataKey: "result_set"
},
common.completed, {
key: "component",
content: resultObservation,
dataKey: "results"
}
]
};
23 changes: 23 additions & 0 deletions lib/templates/sectionLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,26 @@ exports.vitalsSectionEntriesRequired = {
]
}]
};

exports.resultsSectionEntriesRequired = {
key: "component",
content: [{
key: "section",
content: [
common.templateId("2.16.840.1.113883.10.20.22.2.3"),
common.templateId("2.16.840.1.113883.10.20.22.2.3.1"),
common.templateCode("ResultsSection"),
common.templateTitle("ResultsSection"), {
key: "text",
text: ""
}, {
key: "entry",
attributes: {
typeCode: "DRIV"
},
content: entryLevel.resultOrganizer,
dataKey: "results"
}
]
}]
};
8 changes: 8 additions & 0 deletions test/xmlmods/ccd1Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ module.exports = [{
xpath: "h:title",
comment: "titles may differ"
}]
}, {
xpath: "2.16.840.1.113883.10.20.22.2.3.1",
description: "Results 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 @@ -70,4 +70,12 @@ module.exports = [{
xpath: "h:title",
comment: "titles may differ"
}]
}, {
xpath: "2.16.840.1.113883.10.20.22.2.3.1",
description: "Results Section (entries required)",
type: "rootTemplate",
childxpaths: [{
xpath: "h:title",
comment: "titles may differ"
}]
}];

0 comments on commit 4b5e13e

Please sign in to comment.