web stats
Purpose of Data Types - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2016, 09:56 AM
JHess JHess is offline
What's HL7?
 
Join Date: Feb 2016
Posts: 2
JHess is on a distinguished road
Default Purpose of Data Types

Using MC 3.3.

I stumbled across Mirth a few days ago. I thought maybe this was something I could use to transform an HL7 file into JSON (I already have a parser). I set the outbound data type for the destination to JSON. I was hoping I could just write it to a file. Appears that is not the case which leads me to my question. What is the purpose of the data types? Is this just for use in the transformation, or is there a way I can have the original source transformed into JSON similar to what MC does when it converts to XML, and then export it?
Reply With Quote
  #2  
Old 02-12-2016, 10:06 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 255
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

The data types are used for Mirth to determine if it should convert them (internally) to XML for parsing. Raw and JSON are NOT parsed in this method, HL7 is. Sounds like what you want to do is to create a channel, setting the Inbound type to HL7, and the Outbound type to JSON. Then, in the Destination transformer, place an example HL7 in the Inbound Message Template, then in Outbound Message Template, place the framework of your JSON message. From there, you can drag from the HL7 to the JSON to "build" your message.

Let us know if you need help! Feel free to post an exported channel if you get stuck.
__________________

-= 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 02-12-2016, 10:07 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

The data types tell your channels/connectors/transformers what format to expect. For transformers, the inbound data type is used to serialize the incoming data into a JavaScript object (usually an E4X XML object, in the case of JSON just a JavaScript Object) which you can easily traverse and modify in JavaScript (or via drag-and-drop with the message trees). The outbound data type tells the transformer how to take the serialized data and convert it back out.

It seems like you think of "HL7 to JSON" as something that just happens automagically. In reality, it doesn't make sense by itself. JSON is just a data format; its structure is entirely dependent on the user. HL7 v2.x messages vary widely from system to system too, even though it's supposed to be a "standard".

That's why you need a transformer to tell Mirth Connect "this place in the HL7 message maps to this place in the JSON document" and so on. You can't just set the data types and expect everything to work.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #4  
Old 02-12-2016, 10:20 AM
JHess JHess is offline
What's HL7?
 
Join Date: Feb 2016
Posts: 2
JHess is on a distinguished road
Default

Appreciate the response. I know HL7 to JSON does not just happen. However, MC does convert the HL7 to XML with generic tags (e.g. <SCH.1.1>, <PID.5.1>). I was hoping they did the same thing with JSON something like this:

{
"HL7Message": {
"MSH": {
"MSH.1": "|",
"MSH.2": "^~\\&",
"MSH.3": { "MSH.3.1": "MYPROG_APPT" },
"MSH.4": { "MSH.4.1": "MYPROG" },
"MSH.6": { "MSH.6.1": "TYPE" },
"MSH.7": { "MSH.7.1": "20160210081021" },
"MSH.9": {
"MSH.9.1": "SIU",
"MSH.9.2": "S12"
...
Reply With Quote
  #5  
Old 02-12-2016, 10:24 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Something like this certainly is on our roadmap! MIRTH-2758

In the meantime it's still easy to do... here are a couple of examples:

http://www.mirthcorp.com/community/f...ad.php?t=12835
http://www.mirthcorp.com/community/f...ead.php?t=7743
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #6  
Old 02-12-2016, 10:35 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 255
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Mirth *does* do referencing with JSON similar to the E4X that is uses for HL7 and XML. Take a look at the channel.


Code:
// Copying HL7 MSH 9.2. to JSON MSH 9.2
tmp['HL7Message']['MSH']['MSH.9']['MSH.9.2'] = msg['MSH']['MSH.9']['MSH.9.2'].toString()
Attached Files
File Type: xml HL7 to JSON Sample.xml (47.8 KB, 23 views)
__________________

-= 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
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 09:59 PM.


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