Sidebar

How can I combine like FT1 Segments

0 votes
475 views
asked Oct 14, 2016 by brandon-w-8204 (33,270 points)
edited Oct 14, 2016 by brandon-w-8204
I have duplicate FT1 and need to combine them by putting the count in FT1-10 to the correct number. How can I do this in qvera.
 
Source:
MSH|^~\&|TxM|CLINIC1-3030||06ce9316-1262-40a3-884d-8b7a003197de|20161012190013||DFT^P03|201610121900132021|P|2.3
EVN|P03|20161012190013|||||
PID|1|781055|781055||TEST^MIKE||19991002|M
PV1|1||ABC||||TESTDOCTOR^TEST^Doctor|TESTDOCTOR^TEST^Doctor||||||||||U|11501174|||||||||||||||||||||||||00010101000000||||||11501174
FT1|1|||20161012000000|20161012190013|CG|J9000|J9000 DOXOrubicin 10 mg||5|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||J9000||||
FT1|4|||20161012000000|20161012190013|CG|96367|Sequential intravenous infusion for therapy, prophylaxis, or diagnosis, up to 1 hour||1|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||96367
FT1|5|||20161012000000|20161012190013|CG|J2469|J2469 palonosetron 25 mcg||10|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||jTESTDOCTOR^TEST^Doctor||11501174||J2469||||
FT1|6|||20161012000000|20161012190013|CG|96367|Sequential intravenous infusion for therapy, prophylaxis, or diagnosis, up to 1 hour||1|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||96367
FT1|7|||20161012000000|20161012190013|CG|J7030|J7030 0.9% sodium chloride 1000 mL||1|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||J7030||||
FT1|8|||20161012000000|20161012190013|CG|96361|Intravenous infusion, hydration, each hour up to 8 hours||1|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||96361
FT1|9|||20161012000000|20161012190013|CG|J7030|J7030 0.9% sodium chloride 1000 mL||1|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||J7030||||
FT1|10|||20161012000000|20161012190013|CG|96361|Intravenous infusion, hydration, each hour up to 8 hours||1|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||96361
ZFT|1|3||
 
Would become:
MSH|^~\&|TxM|CLINIC1-3030||06ce9316-1262-40a3-884d-8b7a003197de|20161012190013||DFT^P03|201610121900132021|P|2.3
EVN|P03|20161012190013|||||
PID|1|781055|781055||TEST^MIKE||19991002|M
PV1|1||ABC||||TESTDOCTOR^TEST^Doctor|TESTDOCTOR^TEST^Doctor||||||||||U|11501174|||||||||||||||||||||||||00010101000000||||||11501174
FT1|1|||20161012000000|20161012190013|CG|J9000|J9000 DOXOrubicin 10 mg||5|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||J9000||||
FT1|2|||20161012000000|20161012190013|CG|96413|Initial chemotherapy admin, intravenous infusion, up to 1 hour||1|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||96413
FT1|3|||20161012000000|20161012190013|CG|J1100|J1100 dexamethasone 1 mg||12|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||J1100||||
FT1|4|||20161012000000|20161012190013|CG|96367|Sequential intravenous infusion for therapy, prophylaxis, or diagnosis, up to 1 hour||2|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||96367
FT1|5|||20161012000000|20161012190013|CG|J2469|J2469 palonosetron 25 mcg||10|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||J2469||||
FT1|6|||20161012000000|20161012190013|CG|J7030|J7030 0.9% sodium chloride 1000 mL||2|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor|11501174||J7030||||
FT1|7|||20161012000000|20161012190013|CG|96361|Intravenous infusion, hydration, each hour up to 8 hours||2|||303|||OF|||C49.21^Malignant neoplasm of connective and soft tissue of right lower limb, including hip^ICD-10~D70.1^Agranulocytosis secondary to cancer chemotherapy^ICD-10||TESTDOCTOR^TEST^Doctor||11501174||96361
ZFT|1|3||

1 Answer

0 votes

Here is the code to remove the duplicates and increment the FT1-10 count:

var ft1Segs = message.getAllNodes('FT1');
var ft1ParameterMap = qie.newParameterMap();
 
message.removeAllNodes('FT1');
for (var i = 0; i < ft1Segs.length; i++) {
   var ft1Seg = qie.parseHL7String(ft1Segs[i]);
   var mapKey = '' + ft1Seg.getNode('FT1-4') + '-' + ft1Seg.getNode('FT1-7');
   qie.debug('mapKey: ' + mapKey + ' value: ' + ft1ParameterMap.get(mapKey));
   if (ft1ParameterMap.get(mapKey) === null) {
      ft1ParameterMap.put(mapKey, ft1Seg);
      message.addChild('/', 'FT1', ft1Seg);
   } else {
      var storedFt1Seg = qie.parseHL7String(ft1ParameterMap.get(mapKey));
      var count = message.getNode('FT1[@7=' + ft1Seg.getNode('FT1-7') +']-10') * 1;
      message.setNode('FT1[@7=' + ft1Seg.getNode('FT1-7') +']-10', count + 1);
      ft1ParameterMap.put(mapKey, storedFt1Seg);
   }
}
 
var ft1Count = message.getCount('FT1');
for (var j = 1; j <= ft1Count; j++) {
   message.setNode('FT1-1', ''+j, j);
}
answered Oct 14, 2016 by brandon-w-8204 (33,270 points)
...