Skip to content

Commit

Permalink
updating immunizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Young committed Aug 14, 2014
1 parent 3026401 commit faf686c
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 76 deletions.
13 changes: 8 additions & 5 deletions lib/generator/ccda/lib/templating_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ var consumable = function (xmlDoc, product, ref) {

// part of the consumable template function.
var manufacturedProduct = function (xmlDoc, product, ref, sec) {
xmlDoc = xmlDoc.node('manufacturedProduct').attr({classCode: "MANU"}) // medication information
.node('templateId').attr({root: '2.16.840.1.113883.10.20.22.4.23'}).parent();
xmlDoc = xmlDoc.node('manufacturedProduct').attr({classCode: "MANU"}) // medication information / immunization medication information
.node('templateId').attr({root: ref.indexOf("immi") > -1 ? "2.16.840.1.113883.10.20.22.4.54" : '2.16.840.1.113883.10.20.22.4.23'}).parent();
if (product && product["product"]) {
xmlDoc = id(xmlDoc, product["identifiers"]);
xmlDoc = xmlDoc.node('manufacturedMaterial');
Expand Down Expand Up @@ -417,16 +417,16 @@ var manufacturedProduct = function (xmlDoc, product, ref, sec) {
return xmlDoc;
}

var entryRelationship = function (xmlDoc, data, type, typeCode) {
var entryRelationship = function (xmlDoc, data, type, typeCode, ref) {
if (data) {
xmlDoc = xmlDoc.node('entryRelationship').attr({typeCode: typeCode})
.attr({inversionInd: "true"})
.node(type).attr({classCode: "ACT"}).attr({moodCode: "INT"})
.node('templateId').attr({root: "2.16.840.1.113883.10.20.22.4.20"}).parent();
xmlDoc = code(xmlDoc, data["code"]).parent();
xmlDoc = xmlDoc.node('text', 'label in spanish')
xmlDoc = xmlDoc.node('text', data["freeText"])
.node('reference')
.attr({value: "#MedSec_1"}).parent()
.attr({value: ref}).parent()
.parent()
.node('statusCode').attr({code: "completed"}).parent()
// if (data[i]["reaction"]) {
Expand Down Expand Up @@ -880,6 +880,9 @@ module.exports.id = id;
module.exports.code = code;
module.exports.name = name;
module.exports.value = value;
module.exports.routeCode = routeCode;
module.exports.doseQuantity = doseQuantity;

module.exports.maritalStatusCode = maritalStatusCode;
module.exports.guardianPerson = guardianPerson;
module.exports.languageCommunication = languageCommunication;
Expand Down
41 changes: 22 additions & 19 deletions lib/generator/ccda/templates/immunizations.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
var libxmljs = require("libxmljs");
var libCCDAGen = require("../lib/templating_functions.js");
var bbm = require("blue-button-meta");
var sec_entries_codes = bbm.CCDA.sections_entries_codes["codes"];

module.exports = function (data, codeSystems, isCCD, CCDxml) {
// determining the number of entries
var entries = libCCDAGen.getNumEntries(data);
var keys = Object.keys(entries[1]);
var sum = 0;
for (var i = 0; i < keys.length; i++) {
sum += entries[1][keys[i]];
}

var doc = new libxmljs.Document();
xmlDoc = libCCDAGen.header(!isCCD ? doc : CCDxml, "2.16.840.1.113883.10.20.22.2.2",
"2.16.840.1.113883.10.20.22.2.2.1", "11369-6", "2.16.840.1.113883.6.1",
"LOINC", "History of immunizations", "IMMUNIZATIONS", isCCD);
xmlDoc = libCCDAGen.header_v2(!isCCD ? doc : CCDxml, "2.16.840.1.113883.10.20.22.2.2",
"2.16.840.1.113883.10.20.22.2.2.1", sec_entries_codes["ImmunizationsSection"],"IMMUNIZATIONS", isCCD);

// entries loop
for (var i = 0; i < sum; i++) {
xmlDoc = xmlDoc.node('entry')
.attr({typeCode: "DRIV"});
for (var i = 0; i < data.length; i++) {
var time = libCCDAGen.getTimes(data[i]["date_time"]);

xmlDoc = libCCDAGen.substanceAdministration(xmlDoc, data, i,
"#immun" + (i + 1), "#immi" + (i + 1),
"2.16.840.1.113883.10.20.22.4.52", "2.16.840.1.113883.10.20.22.4.54");
xmlDoc = xmlDoc.node('entry').attr({typeCode: "DRIV"});
xmlDoc = xmlDoc.node('substanceAdministration').attr({classCode: "SBADM"})
.attr({moodCode: "EVN"}).attr({negationInd: "false"})
.node('templateId').attr({root: "2.16.840.1.113883.10.20.22.4.52"}).parent();
xmlDoc = libCCDAGen.id(xmlDoc, data[i]["identifiers"]);
xmlDoc = xmlDoc.node('text')
.node('reference').attr({value: "#immun" + (i+1)}).parent()
.parent()
.node('statusCode').attr({code: 'completed'}).parent();
xmlDoc = libCCDAGen.effectiveTime(xmlDoc, time, undefined,'IVL_TS');
xmlDoc = libCCDAGen.routeCode(xmlDoc, data[i]["administration"]);
xmlDoc = libCCDAGen.doseQuantity(xmlDoc, data[i]["administration"]);
xmlDoc = libCCDAGen.consumable(xmlDoc, data[i]["product"], "#immi" + (i + 1));
xmlDoc = libCCDAGen.performerRevised(xmlDoc, data[i]["performer"], {});

xmlDoc = libCCDAGen.entryRelationship(xmlDoc, data,
data[i]["refusal_reason"] ? 'observation' : 'act', i);
xmlDoc = libCCDAGen.entryRelationship(xmlDoc, data[i]["instructions"],
data[i]["refusal_reason"] ? 'observation' : 'act', 'SUBJ', '#immunSect');
xmlDoc = xmlDoc.parent() // end substanceAdministration
.parent() // end entry
}
Expand Down
4 changes: 2 additions & 2 deletions lib/generator/ccda/templates/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ var sec_entries_codes = bbm.CCDA.sections_entries_codes["codes"];

module.exports = function (data, codeSystems, isCCD, CCDxml) {
var doc = new libxmljs.Document();
var xmlDoc = libCCDAGen.header(!isCCD ? doc : CCDxml, "2.16.840.1.113883.10.20.22.2.7", "2.16.840.1.113883.10.20.22.2.7.1", "47519-4",
"2.16.840.1.113883.6.1", "LOINC", "HISTORY OF PROCEDURES", "PROCEDURES", isCCD);
var xmlDoc = libCCDAGen.header_v2(!isCCD ? doc : CCDxml, "2.16.840.1.113883.10.20.22.2.7", "2.16.840.1.113883.10.20.22.2.7.1",
sec_entries_codes["ProceduresSection"], "PROCEDURES", isCCD);

var templateIds = {
"act": "2.16.840.1.113883.10.20.22.4.12",
Expand Down
7 changes: 7 additions & 0 deletions lib/parser/ccda/sections/immunizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ var exportImmunizationsSection = function (version) {
["form", "0..1", "h:administrationUnitCode", shared.ConceptDescriptor]
]);

var ImmunizationInstructions = component.define("MedicationInstructions")
.fields([
["code", "0..1", "h:code", shared.ConceptDescriptor],
["freeText", "0..1", "h:text", shared.TextWithReference]
]);

var immunizationActivityProduct = component.define('immunizationActivityProduct')
.fields([
["product", "1..1", "h:manufacturedMaterial/h:code", shared.ConceptDescriptor],
Expand All @@ -58,6 +64,7 @@ var exportImmunizationsSection = function (version) {
["product", "0..1", "h:consumable/h:manufacturedProduct", immunizationActivityProduct],
["administration", "0..1", "./../h:substanceAdministration", ImmunizationAdministration],
["performer", "0..1", "h:performer/h:assignedEntity", shared.assignedEntity],
["instructions", "0..1", "h:entryRelationship[@typeCode='SUBJ']/h:act", ImmunizationInstructions],
["refusal_reason", "0..1", "h:entryRelationship/h:observation/h:code/@code", shared.SimpleCode("2.16.840.1.113883.5.8")],
]);

Expand Down
78 changes: 29 additions & 49 deletions test/fixtures/file-snippets/generated/CCD_1_Immunizations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<section>
<templateId root="2.16.840.1.113883.10.20.22.2.2"/>
<templateId root="2.16.840.1.113883.10.20.22.2.2.1"/>
<code code="11369-6" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="History of immunizations"/>
<code code="11369-6" displayName="Immunizations" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>IMMUNIZATIONS</title>
<text/>
<entry typeCode="DRIV">
Expand All @@ -14,21 +14,21 @@
<reference value="#immun1"/>
</text>
<statusCode code="completed"/>
<effectiveTime xsi:type="IVL_TS" value="undefined"/>
<effectiveTime xsi:type="IVL_TS" value="19991101"/>
<routeCode code="C28161" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="Medication Route FDA" displayName="Intramuscular injection"/>
<doseQuantity value="50" unit="mcg"/>
<consumable>
<manufacturedProduct classCode="MANU">
<templateId root="2.16.840.1.113883.10.20.22.4.23"/>
<templateId root="2.16.840.1.113883.10.20.22.4.54"/>
<id nullFlavor="UNK"/>
<manufacturedMaterial>
<code code="88" displayName="Influenza virus vaccine" codeSystem="2" codeSystemName="CVX">
<code code="88" displayName="Influenza virus vaccine" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX">
<originalText>
<reference value="#immi1"/>
</originalText>
<translation code="141" codeSystem="2.16.840.1.113883.5.4" displayName="Influenza, seasonal, injectable" codeSystemName="CVX"/>
<translation code="141" displayName="Influenza, seasonal, injectable" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX"/>
</code>
<lotNumberText>1</lotNumberText>
<lotNumberText/>
</manufacturedMaterial>
<manufacturerOrganization>
<name>Health LS - Immuno Inc.</name>
Expand All @@ -54,7 +54,7 @@
</assignedPerson>
<representedOrganization>
<id root="2.16.840.1.113883.19.5.9999.1394"/>
<name/>
<name>Good Health Clinic</name>
<telecom nullFlavor="UNK"/>
<addr nullFlavor="UNK"/>
</representedOrganization>
Expand All @@ -63,8 +63,8 @@
<entryRelationship typeCode="SUBJ" inversionInd="true">
<act classCode="ACT" moodCode="INT">
<templateId root="2.16.840.1.113883.10.20.22.4.20"/>
<code code="171044003" codeSystem="2.16.840.1.113883.6.96" displayName="immunization education"/>
<text>label in spanish<reference value="#MedSec_1"/></text>
<code code="171044003" displayName="immunization education" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"/>
<text>Possible flu-like symptoms for three days.<reference value="#immunSect"/></text>
<statusCode code="completed"/>
</act>
</entryRelationship>
Expand All @@ -78,21 +78,21 @@
<reference value="#immun2"/>
</text>
<statusCode code="completed"/>
<effectiveTime xsi:type="IVL_TS" value="undefined"/>
<effectiveTime xsi:type="IVL_TS" value="19981215"/>
<routeCode code="C28161" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="Medication Route FDA" displayName="Intramuscular injection"/>
<doseQuantity value="50" unit="mcg"/>
<consumable>
<manufacturedProduct classCode="MANU">
<templateId root="2.16.840.1.113883.10.20.22.4.23"/>
<templateId root="2.16.840.1.113883.10.20.22.4.54"/>
<id nullFlavor="UNK"/>
<manufacturedMaterial>
<code code="88" displayName="Influenza virus vaccine" codeSystem="2" codeSystemName="CVX">
<code code="88" displayName="Influenza virus vaccine" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX">
<originalText>
<reference value="#immi2"/>
</originalText>
<translation code="141" codeSystem="2.16.840.1.113883.5.4" displayName="Influenza, seasonal, injectable" codeSystemName="CVX"/>
<translation code="141" displayName="Influenza, seasonal, injectable" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX"/>
</code>
<lotNumberText>1</lotNumberText>
<lotNumberText/>
</manufacturedMaterial>
<manufacturerOrganization>
<name>Health LS - Immuno Inc.</name>
Expand All @@ -118,7 +118,7 @@
</assignedPerson>
<representedOrganization>
<id root="2.16.840.1.113883.19.5.9999.1394"/>
<name/>
<name>Good Health Clinic</name>
<telecom nullFlavor="UNK"/>
<addr nullFlavor="UNK"/>
</representedOrganization>
Expand All @@ -127,8 +127,8 @@
<entryRelationship typeCode="SUBJ" inversionInd="true">
<act classCode="ACT" moodCode="INT">
<templateId root="2.16.840.1.113883.10.20.22.4.20"/>
<code code="171044003" codeSystem="2.16.840.1.113883.6.96" displayName="immunization education"/>
<text>label in spanish<reference value="#MedSec_1"/></text>
<code code="171044003" displayName="immunization education" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"/>
<text>Possible flu-like symptoms for three days.<reference value="#immunSect"/></text>
<statusCode code="completed"/>
</act>
</entryRelationship>
Expand All @@ -142,21 +142,21 @@
<reference value="#immun3"/>
</text>
<statusCode code="completed"/>
<effectiveTime xsi:type="IVL_TS" value="undefined"/>
<effectiveTime xsi:type="IVL_TS" value="19981215"/>
<routeCode code="C28161" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="Medication Route FDA" displayName="Intramuscular injection"/>
<doseQuantity value="50" unit="mcg"/>
<consumable>
<manufacturedProduct classCode="MANU">
<templateId root="2.16.840.1.113883.10.20.22.4.23"/>
<templateId root="2.16.840.1.113883.10.20.22.4.54"/>
<id nullFlavor="UNK"/>
<manufacturedMaterial>
<code code="33" displayName="Pneumococcal polysaccharide vaccine" codeSystem="2" codeSystemName="CVX">
<code code="33" displayName="Pneumococcal polysaccharide vaccine" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX">
<originalText>
<reference value="#immi3"/>
</originalText>
<translation code="109" codeSystem="2.16.840.1.113883.5.4" displayName="Pneumococcal NOS" codeSystemName="CVX"/>
<translation code="109" displayName="Pneumococcal NOS" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX"/>
</code>
<lotNumberText>1</lotNumberText>
<lotNumberText/>
</manufacturedMaterial>
<manufacturerOrganization>
<name>Health LS - Immuno Inc.</name>
Expand All @@ -182,20 +182,12 @@
</assignedPerson>
<representedOrganization>
<id root="2.16.840.1.113883.19.5.9999.1394"/>
<name/>
<name>Good Health Clinic</name>
<telecom nullFlavor="UNK"/>
<addr nullFlavor="UNK"/>
</representedOrganization>
</assignedEntity>
</performer>
<entryRelationship typeCode="SUBJ" inversionInd="true">
<act classCode="ACT" moodCode="INT">
<templateId root="2.16.840.1.113883.10.20.22.4.20"/>
<code code="171044003" codeSystem="2.16.840.1.113883.6.96" displayName="immunization education"/>
<text>label in spanish<reference value="#MedSec_1"/></text>
<statusCode code="completed"/>
</act>
</entryRelationship>
</substanceAdministration>
</entry>
<entry typeCode="DRIV">
Expand All @@ -206,21 +198,21 @@
<reference value="#immun4"/>
</text>
<statusCode code="completed"/>
<effectiveTime xsi:type="IVL_TS" value="undefined"/>
<effectiveTime xsi:type="IVL_TS" value="19981215"/>
<routeCode code="C28161" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="Medication Route FDA" displayName="Intramuscular injection"/>
<doseQuantity value="50" unit="mcg"/>
<consumable>
<manufacturedProduct classCode="MANU">
<templateId root="2.16.840.1.113883.10.20.22.4.23"/>
<templateId root="2.16.840.1.113883.10.20.22.4.54"/>
<id nullFlavor="UNK"/>
<manufacturedMaterial>
<code code="103" displayName="Tetanus and diphtheria toxoids - preservative free" codeSystem="2" codeSystemName="CVX">
<code code="103" displayName="Tetanus and diphtheria toxoids - preservative free" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX">
<originalText>
<reference value="#immi4"/>
</originalText>
<translation code="09" codeSystem="2.16.840.1.113883.5.4" displayName="Tetanus and diphtheria toxoids - preservative free" codeSystemName="CVX"/>
<translation code="09" displayName="Tetanus and diphtheria toxoids - preservative free" codeSystem="2.16.840.1.113883.12.292" codeSystemName="CVX"/>
</code>
<lotNumberText>1</lotNumberText>
<lotNumberText/>
</manufacturedMaterial>
<manufacturerOrganization>
<name>Health LS - Immuno Inc.</name>
Expand All @@ -246,24 +238,12 @@
</assignedPerson>
<representedOrganization>
<id root="2.16.840.1.113883.19.5.9999.1394"/>
<name/>
<name>Good Health Clinic</name>
<telecom nullFlavor="UNK"/>
<addr nullFlavor="UNK"/>
</representedOrganization>
</assignedEntity>
</performer>
<entryRelationship typeCode="SUBJ" inversionInd="true">
<observation classCode="OBS" moodCode="EVN">
<templateId root="2.16.840.1.113883.10.20.22.4.8"/>
<code code="SEV" displayName="Severity Observation" codeSystem="2.16.840.1.113883.5.4" codeSystemName="ActCode"/>
<text>
<reference value="#severity3"/>
</text>
<statusCode code="completed"/>
<value xsi:type="CD" code="undefined" displayName="UNK" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"/>
<interpretationCode code="N" displayName="Normal" codeSystem="2.16.840.1.113883.1.11.78" codeSystemName="Observation Interpretation"/>
</observation>
</entryRelationship>
</substanceAdministration>
</entry>
</section>
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/file-snippets/generatedJSON/CCD_1_Immunizations.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
]
}
]
},
"instructions": {
"code": {
"name": "immunization education",
"code": "171044003",
"code_system_name": "SNOMED CT"
},
"freeText": "Possible flu-like symptoms for three days."
}
},
{
Expand Down Expand Up @@ -154,6 +162,14 @@
]
}
]
},
"instructions": {
"code": {
"name": "immunization education",
"code": "171044003",
"code_system_name": "SNOMED CT"
},
"freeText": "Possible flu-like symptoms for three days."
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion test/test-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if (TEST_SECTIONS) {
describe('sections', function () {
it('should match respective sections', function () {
Object.keys(supportedComponents).forEach(function (section) {
if (section === "procedures") { // add section === "[section]" for specific section
if (section === "immunizations") { // add section === "[section]" for specific section
var XMLDOMs = test.generateXMLDOM(section);

assert.ok(test.isIdentical(XMLDOMs[0].documentElement, XMLDOMs[1].documentElement));
Expand Down

0 comments on commit faf686c

Please sign in to comment.