Hi JOnathan,

1. HL7 Message structures are used for grouping messages with the same
internal structure (i.e. groups and segments). HAPI classes model message
structures rather than messages. As ADT_A08 is defined to have a message
structure called ADT_A01, the instantiated HAPI class is ADT_A01. 

2. Segments can be nested in groups. The problem is that groups are not
visible in pipe-encoded messages, so one has to look at the HL7
specification or simply at the instantiated message structure class -
ca.uhn.hl7v2.model.v25.message.ADT_A01 contains a group ADT_A01_INSURANCE
which contains the IN1 segments you are looking for.

3. For nested search of segments, have a look at
ca.uhn.hl7v2.util.SegmentFinder or one of the Iterator classes in the same
package.

cheers 
Christian


Jonathan Bartels-2 wrote:
> 
> I have an application that is focused on processing messages segment by
> segment, it  is largely agnostic to the type of message. For example if we
> get a message with an IN1 segment, the application will capture insurance
> data.
> 
> 
> 
> I am trying to do this with:
> 
> protected int getSegmentCount(String segment) {
> 
>         try {
> 
>             return getMessage().getAll(segment).length;
> 
>         } catch (HL7Exception e) {
> 
>             log.warning("Found no segments for:" + segment, e);
> 
>             return 0;
> 
>         }
> 
>     }
> 
> 
> 
> However if I send an ADT_A08 message I get:
> 
> ca.uhn.hl7v2.HL7Exception: The structure IN1 does not exist in the group
> ca.uhn.hl7v2.model.v25.message.ADT_A01
> 
>                 at
> ca.uhn.hl7v2.model.AbstractGroup.getAll(AbstractGroup.java:335)
> 
> 
> 
> This is odd for two reasons, it’s not an ADT_A01 and despite its message
> type this particular sample has two IN1 segments.
> 
> 
> 
> Is there a better way to count the number of segments in a message?
> 
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Hl7api-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Counting-or-iterating-over-segments-for-an-unkown-or-generic-message-type-tp29957804p29960699.html
Sent from the hl7api-devel mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to