web stats
TypeError:Cannot read property - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 05-27-2019, 02:00 AM
MarcLipshitz MarcLipshitz is offline
What's HL7?
Join Date: Jul 2018
Posts: 3
MarcLipshitz is on a distinguished road
Default TypeError:Cannot read property

Hi all

I have an HL7 message I am converting to XML but it keeps giving me an error of "TypeError: Cannot read property "2" from undefined.

The message is:
MSH|^~\&|medavis RIS|MEDAVIS|Mirth|Mirth|20190218123501||DFT^P03^DFT_P03|304928|P|2.5|||AL|NE||8859/1
PID|1|16^^^MEDAVIS^PI|||TEST G4M Nachname^TEST 2^T^^MISS~NameOfBirth^^^^^^B|00MemberCode|19921106|M|||MANNING ROAD^Ext.Add.Line^DURBAN^^4001^ZA||0313017352~072363395^^CP~^NET^Internet^TEST@GMAIL.COM|0313017352~072363395^^CP~^NET^Internet^TEST@GMAIL.COM|||||123456PatDepCode|||||||ZA||||N
PV1|1|O||||||0020222^MAHOMED^N^N^^DR^^^MEDAVIS~N MAHOMED^MAHOMED^N^N^^^^^SEAL^^^^DN|||||||||||16766^^^MEDAVIS^VN|||||PRIVATE
FT1|1|53||20190218123400||2|100884001^STENT PERIPHERAL VASCULAR E LU^med-mat|||1||piece
OBR|1|||00110^X-ray skeletal survey under five years^MEDAVIS^00110^X-ray skeletal survey under five years^MEDAVIS|||20190218123400|20190218123400||||||||125^MAHOMED^N^N^^DR||U-ID24523|Bone Densitometer|||||US|I||1^once^^20190218123400^20190218123400^1|||WALK||2&medavis&GmbH&&&&&&MEDAVIS|2&medavis&GmbH&&&&&&MEDAVIS|2&medavis&GmbH&&&&&&MEDAVIS||20190218230500||||||N|^^^^Bone Dens
IN1|1||S3189^^^^NII~^^^^NIIP||||||Patient||||||02|TEST5^TEST5||19871005|MANNING ROAD||||||||||||||||||^TP||||||||||||920516
ZF1||||20190218123300|||Krankheit|||||||||||||||1|||||||^N MAHOMED||1^^^^^^^^^^,  , 
and the code parsing this section is:
for (var i=0;i<msg['PID']['PID.13'].length();i++)
     	var commtype = msg['PID']['PID.13'][i]['PID.13.3'].toString()
     	if ( commtype=='CP')
     		tmp['Patient']['CellPhone'] = msg['PID']['PID.13'][i]['PID.13.1'].toString();
     	if ( commtype=='')
     		tmp['Patient']['TelephoneNumber'] = msg['PID']['PID.13'][i]['PID.13.1'].toString();
     	if ( commtype=='Internet')
     		tmp['Patient']['EMailAddress'] = ['PID']['PID.13'][i]['PID.13.4'].toString();
I have used this message for the template, so the both the template and messagetree contain the segment. I just cannot find why it is not working
Reply With Quote
Old 05-27-2019, 04:13 AM
MarcLipshitz MarcLipshitz is offline
What's HL7?
Join Date: Jul 2018
Posts: 3
MarcLipshitz is on a distinguished road
Default Problem solved...

Sigh, just an idiotic typing error that I left msg off in front of the field...
Reply With Quote
Old 05-28-2019, 07:00 AM
cory_cole cory_cole is offline
Mirth Guru
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road

Those are the hardest to catch because it looks correct.
Reply With Quote

hl7, java javascript

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 01:28 PM.

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