Ok, so I've implemented a custom ORU_R01 v2.3 message and a custom Z-segment (called ZDS) using the HAPI library (version 1.2).
They seem to be working well. However, when I have a message with multiple ZDS segments, I find I'm unable to get them all. I call the 'getAll("ZDS");' method, thinking it will return an array of segments with id ZDS. However, it will only ever return an array of either length 0 or 1 (returns length 1 even if there are multiple ZDS segments).
Here's my code in my custom ORU_R01 message that tries to get an array of ZDS segments:
public ZDS[] getZDSList() throws HL7Exception {
System.out.println("NUM REPS: " + currentReps("ZDS"));
Structure[] list = getAll("ZDS");
ZDS[] zdsSegments = new ZDS[list.length];
for (int i=0; i < list.length; i++)
zdsSegments[i] = (ZDS) list[i];
return zdsSegments;
}
The output for currentReps("ZDS") is always either 0 or 1.
I'm learning, but I'm hitting some road blocks. I'd appreciate any help you guys can offer!!
Cheers
Jarrett
Ok, turns out, when I add the ZDS segment to my custom ORU_R01, I needed to set the segment to be repeating. i.e.:
this.add(ZDS.class, false, false);
needs to be changed to
this.add(ZDS.class, false, true);
and then it works!
Thanks to everyone who checked this out.
Cheers
Jarrett