I am trying to create an HL7 message using code similar to the following:
Message message = new DefaultModelClassFactory().getMessageClass("ADT_A01", "2.3", false).newInstance();
Terser terser = new Terser(message);
terser.set("FHS-1-1","|");
... similar terser.set calls for other FHS fields
terser.set("BHS-1-1","|");
... similar terser.set calls for other BHS fields
terser.set("MSH-1-1","|");
... similar terser.set calls for other MSH fields
and what I need is that the generated message would have the segments in the order: FHS BHS MSH
while the actual result is: FHS MSH BHS
so my question is, is there a way to control the order of the generated segments when using HAPI terser? or is there a way to force the terser to generate the segments in the same order as they are created using the set method?