web stats
Looping XML Diagnosis to HL7 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 05-08-2017, 09:28 AM
mmonisky mmonisky is offline
OBX.1 Kenobi
Join Date: Aug 2015
Posts: 38
mmonisky is on a distinguished road
Default Looping XML Diagnosis to HL7

I need some guidance on looping the diagnosis field in an FT1 segment.
XML may contain several diagnosis that needs to be iterated through the HL7 message on FT1.19.1/FT1.19.2/FT1.19.3 so on
Converting XML to HL7.

Snippet from XML:

Originally I wrote it as:
tmp['FT1']['FT1.19'][0]['FT1.19.1'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][0]['Code'].toString(), '', new Array());
tmp['FT1']['FT1.19'][0]['FT1.19.2'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][0]['SuperBillDiagnosisCodeID'].toString().toString(), '', new Array());
tmp['FT1']['FT1.19'][0]['FT1.19.3'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][0]['CodeTypeName'].toString(), '', new Array());
tmp['FT1']['FT1.19'][1]['FT1.19.1'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][1]['Code'].toString(), '', new Array());
tmp['FT1']['FT1.19'][1]['FT1.19.2'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][1]['SuperBillDiagnosisCodeID'].toString().toString(), '', new Array());
tmp['FT1']['FT1.19'][1]['FT1.19.3'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][1]['CodeTypeName'].toString(), '', new Array());

And this worked if we only expect 2 Diagnosis, but there could be more than 2 in each message,

Created the 'for each' and 'logger.info' statement to pull out the codes:

for each (seg in msg['Charges']['Charge']['Diagnoses'].children()) {
//if (seg.name().toString() == "SEG") {
var icd = seg['Code'].toString();
var spID = seg['SuperBillDiagnosisCodeID'].toString();
var icdT = seg['CodeTypeName'].toString();


And the logger populates all of the fields:
Example - [2017-05-08 13:24:19,429] INFO (transformer:?): 787.03

How do I take those variables and populate them into their respective FT1.19 fields?

Thank you.

Update 5/9/17 found my fix thank you

Last edited by mmonisky; 05-09-2017 at 09:33 AM.
Reply With Quote
Old 05-15-2017, 10:30 AM
mmonisky mmonisky is offline
OBX.1 Kenobi
Join Date: Aug 2015
Posts: 38
mmonisky is on a distinguished road

Was able to fix it.
Reply With Quote
Old 05-15-2017, 10:58 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
Join Date: Sep 2014
Location: Michigan
Posts: 613
kirbykn2 is on a distinguished road

what was the fix?


Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.11.4
Mirth Connect Version 3.8.0
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_151-b15
Java 8 (64 bit) Version 1.8.0_181-b13
PostgreSQL Version 9.6.8
Reply With Quote
Old 05-17-2017, 07:09 AM
mmonisky mmonisky is offline
OBX.1 Kenobi
Join Date: Aug 2015
Posts: 38
mmonisky is on a distinguished road

This did the trick for me.

var countFT1 = 0;
var countICD = 0;

//how many FT1 segments do we need?
for each (seg in msg['Superbill']['Charges']['Charge']) //maps to FT1 segment
//create FT1 segment
createSegment('FT1', tmp, countFT1);
tmp['FT1'][countFT1]['FT1.1']['FT1.1.1'] = countFT1 + 1;
tmp['FT1'][countFT1]['FT1.2']['FT1.2.1'] = seg['SuperBillDetailId'].toString();
tmp['FT1'][countFT1]['FT1.4']['FT1.4.1'] = msg['Superbill']['BeginEventDate'].toString();
tmp['FT1'][countFT1]['FT1.6']['FT1.6.1'] = msg['Superbill']['CompletedStatus']['SuperBillStatusID'].toString();
tmp['FT1'][countFT1]['FT1.7']['FT1.7.1'] = seg['Procedure']['CodeTypeId'].toString();
tmp['FT1'][countFT1]['FT1.7']['FT1.7.2'] = seg['Procedure']['Code'].toString();
tmp['FT1'][countFT1]['FT1.7']['FT1.7.3'] = seg['Procedure']['CodeTypeName'].toString();
tmp['FT1'][countFT1]['FT1.16']['FT1.16.1'] = msg['Superbill']['Location']['POSCode'].toString();
tmp['FT1'][countFT1]['FT1.16']['FT1.16.4'] = msg['Superbill']['Location']['FacilityId'].toString();
tmp['FT1'][countFT1]['FT1.16']['FT1.16.5'] = msg['Superbill']['Location']['LocationType'].toString();
tmp['FT1'][countFT1]['FT1.16']['FT1.16.8'] = msg['Superbill']['Location']['LocationDescription'].toString();

//how many diagnosis do we need?
for each (seg in msg['Superbill']['Charges']['Charge']['Diagnoses'].children())
tmp['FT1'][countFT1]['FT1.19'][countICD] = seg['Code'].toString() + "^^" + seg['CodeTypeName'].toString();

var spID = seg['SuperBillDiagnosisCodeID'].toString();
var icdT = seg['CodeTypeName'].toString();


//logger.info("Diagnosis : " + seg);
//logger.info("Diagnosis COUNT: " + countICD);

//increment FT1 segment counter
logger.debug("countFT1: " + countFT1);

Reply With Quote

dft message, ft segment, loop segments repeating, xml child segments

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 12:44 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation