I have tested this and it does seem to be a bug. Comparing the original parsed string with the encoded result shows that the encoded result contains an extra carriage return, but otherwise equal.
The first calls to rde_o11.getORDER(0).getRXCReps() and rde_o11.getPATIENT().getAL1Reps() will create new empty reps because that group is marked as "repeating" (see AbstractGroup.get(String name, int rep) where rep == list.size() which is empty). I am not familiar enough to understand whether this is a bug but it seems like one - you should maybe post this into the issue tracker? Christopher > Hi, > > I have found a wierd case where calling .encode() on a Hapi message can end > up changing the number of reps returned by the Message object > > This code shoudl print out the same console output before and after the > .encode call. > > Unfortunately calling .encode() causes some of the reps to indicate that > they have values when in fact they are empty..... > > I suspect this is not limited to RDE_O11 either...... > > final RDE_O11 rde_o11 = new RDE_O11(); > rde_o11.parse("MSH|^~\\&|MSH3|MSH4|MSH5|MSH6|20161221133021||RDE^O11|MSH10|P|2.5"); > System.out.println(rde_o11.getORDER(0).getRXCReps()); > System.out.println(rde_o11.getORDERReps()); > System.out.println(rde_o11.getPATIENT().getAL1Reps()); > rde_o11.encode(); > System.out.println(rde_o11.getORDER(0).getRXCReps()); > System.out.println(rde_o11.getORDERReps()); > System.out.println(rde_o11.getPATIENT().getAL1Reps()); > > This prints out 0, 1, 0 before the encode. > > But prints out 1, 1,1 after the encode. > > This definitely seems like a bug. > > -Mike ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Hl7api-devel mailing list Hl7api-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hl7api-devel