ClassMethod Transform Count Number of OBX's Under OBR
Is there a class Method that will return the number of OBX segments under the OBR segments? I see method ChildCountGet and ChildCountGet is that the correct method any any examples how to use it?
Really should have been an answer ... moved
Thanks Jeff, is there anyway to do it without defining the doctype?
A bit counter-intuitive, but GetValueAt() works for this, using the same segment path identifiers that you use in DTL:
HICG > set msg=##class(EnsLib.HL7.Message).ImportFromFile("C:\interface\ensemble\LabResult.hl7")
HICG > set msg.DocType = "2.3.1:ORU_R01"
HICG > w msg.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp(*)")
191
If you're working with messages coming in from an HL7 service, the doctype will likely already be set. I only set it in my example because I used the ImportFromFile() method, which does not automatically select a schema and DocType category.
The DocType essentially defines the message object's rules use for parsing the message, so without one, you won't really be able to do much with them.
You could do some basic parsing/counting with $PIECE and some loop constructs against the raw message, but that doesn't sound like a lot of fun ...
It is a bit confusing when it comes to ORCgrp for XML Path. I have tried this one and it works well for OBR segment. Probably you can apply the similar path to OBX iteration to get what you want.
...
...
}
}
If you need more references for this XMLPath, try this one which I found the most useful:
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...