|
#1
|
|||
|
|||
|
Hi all,
I noticed in some posts that when people for showing how to iterate over multiple segments, they used this (msg..OBX) as part of their code. I'm still very new to Mirth and HL7 so I was wondering why that format and not (msg.OBX)? Also I am still trying to understand the hierarchy that Mirth uses for HL7. Is this correct: messageObject is the whole message which Mirth uses msg as the global; so I could use "for each (segment in msg.children)" but could I use "for each (field in msg.children.child)"? I know that the hierarchy is segment/field/component/subcomponent but what comes after msg.children.child or is that even legal code? Well it must be legal because I'm not getting errors. My brain is starting to smoke so I will go now ![]() Thanks for any help. |
|
#2
|
|||
|
|||
|
Quote:
Code:
<message> <result>test0</result> <level1> <result>test1</result> <level2> <result>test2</result> <level3> <result>test3</result> </level3> </level2> </level1> </message> Code:
<result>test0</result> Code:
<result>test0</result> <result>test1</result> <result>test2</result> <result>test3</result> In most cases here on the forums, people work with HL7 2.x and no strict parser. So, both "msg.OBX" and "msg..OBX" do exactly the same thing, since all segments of an HL7 message are direct children of the root node. However, if you use the strict parser, then all segments are not direct children of the root node, so that descendants syntax may come into play, depending on what you're trying to do. Quote:
The variable msg is an E4X XML object representation of the raw data of a connector. So, all E4X properties and methods apply. You can use "for each (seg in msg.children())" to iterate through each child of the root node. The child(index) method returns the child of a node at a specified index. So technically, instead of msg.MSH or msg['MSH'], you could also use msg.child(0). If you want to reference a field of a segment, realize that now you're just going another level deeper, that's all. So to get all instances of PID.3 (assuming you have field repetition parsing turned on), you would do "for each (field in msg.PID['PID.3'])". |
![]() |
| Tags |
| global map, hl7 messages, msg, multiple segments |
| Thread Tools | |
| Display Modes | |
|
|