web stats
Message_Segments_HL7 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-18-2019, 10:26 AM
Mano Mano is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 8
Mano is on a distinguished road
Default Message_Segments_HL7

Hello,I am trying to do something like this,if anyone has done similar to this your help is appreciated.
I have a message like this:
MSH|^~\&|NIIT|ABCD|System|EFGH|20191011182900||ADT ^A08|777777777|P|2.6
PID|1||99999^^^ABCD^^||GOSAVI^MICHAEL^^^^||1955110 9|Male||3080a7b8-0999-4cae-b839-199886122061^White|888 A AAAAA 10^^PPPPPP^AA^860139999||||a4444406-adf3-890c-8888-6c4b5aaaaa92^English|Married|||119942678|||dd33333 e-1111-4444-b000-099a230ar5b1^Not Hispanic or Latino|||||N|||N

When I extract data for a segment lets say gender PID.8,it should give M in case of Male and F in case of Female or if M,F are there then the same value should be returned.For PID 10(Race) the field PID10.1 or 10.2 which has value like 'White' or 'Asian' should be returned.
Basically I am trying to use conditional statements.If anyone has done then please help.
I am using mirth connect 3.8.1
Reply With Quote
  #2  
Old 11-18-2019, 10:32 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 249
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Mano,

Without using some kind of conversion table, you are bound to what is in the message.

Male > M and Female to F is easy using msg['PID']['PID.8']['PID.8.1'].toString().substring(0,1);

The race you can pull using msg['PID']['PID.10']['PID.10.2'].toString()

Is that what you are looking to do?
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #3  
Old 11-18-2019, 10:58 AM
Mano Mano is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 8
Mano is on a distinguished road
Default

Thank you Jack for the reply.I appreciate it.I want to extract race,language too.Sometimes the value I need is present in 10.1 and sometime 10.2 for race,I am confused to get the value.I think a conditional statement will help.Also sometimes it contains numbers.Your help will be appreciated.
Reply With Quote
  #4  
Old 11-18-2019, 11:44 AM
Mano Mano is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 8
Mano is on a distinguished road
Default

Lets say I have 5 different HL7 messages and I am giving here the PID 10.1,10.2 values here
Message-1 PID.10.1-4171a7b9-0092-4eac-b732-198785162151 PID.10.2-White
Message-2 PID.10.1-WHITE PID.10.2-No value
Message-3 PID.10.1-Unknown PID.10.2-No value
Message-4 PID.10.1-3 PID.10.2-No value
Message-5 PID.10.1-No value PID.10.2-8
I want Race value for these 5 messages.Sometimes its present in 10.1 and sometimes in 10.2.
Reply With Quote
  #5  
Old 11-18-2019, 11:54 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,327
cory_cole is on a distinguished road
Default

I would recommend that you create a race table and additional tables for anything else like this.

var race;
if(msg['PID']['PID10']['PID.10.1'].toSting() in table) //code needed to do this
{
race = msg['PID']['PID10']['PID.10.1'].toSting() ;
}
else if(msg['PID']['PID10']['PID.10.2'].toSting() in table) //code needed to do this
{
race = (msg['PID']['PID10']['PID.10.2'].toSting()
}
else
{
race = '';
}
Reply With Quote
  #6  
Old 11-18-2019, 11:55 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 249
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

If the first spot is always blank when it's NOT what you want to use:

Code:
var race = "unknown";

if (msg['PID']['PID.10']['PID.10.1'].toString() != "")
   race = msg['PID']['PID.10']['PID.10.1'].toString();
else if (msg['PID']['PID.10']['PID.10.2'].toString() != "")
   race = msg['PID']['PID.10']['PID.10.2'].toString();

logger.info("Race: " + race);
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #7  
Old 11-18-2019, 12:04 PM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,327
cory_cole is on a distinguished road
Default

@jackwhaines. The first sample doesn't work...

Message-1 PID.10.1-4171a7b9-0092-4eac-b732-198785162151 PID.10.2-White

There is a value in 10.1 but the value wanted is in 10.2
Reply With Quote
  #8  
Old 11-18-2019, 12:13 PM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 249
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Right... I don't know your logic... What determines whether it's the correct race a bad data? A length < 10 ?

var race = "unknown";

if (msg['PID']['PID.10']['PID.10.1'].toString().length < 10)
race = msg['PID']['PID.10']['PID.10.1'].toString();
else if (msg['PID']['PID.10']['PID.10.2'].toString().length < 10)
race = msg['PID']['PID.10']['PID.10.2'].toString();
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #9  
Old 11-18-2019, 12:39 PM
Mano Mano is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 8
Mano is on a distinguished road
Default

I really appreciate to all of your suggestions.
@Cory can you please explain how to create race table or anything like this and how to use it in code?
I am very new to mirth.Your help will be appreciated.Thank you again.
Reply With Quote
  #10  
Old 11-18-2019, 12:41 PM
Mano Mano is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 8
Mano is on a distinguished road
Default

Thanks for the reply Cory,I appreciate it.Can you please explain how and where to create race table or anything like this and how to use it in code?
I am very new to mirth.Your help will be appreciated.Thank you again.
Reply With Quote
Reply

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 04:06 PM.


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