Hi all,

What  is the best way to insert a new segment into an existing message.  I need 
to add a repeating NK1 to transform an existing message for compliance, however 
whenever I try to insert a new NK1 segment using a terser, the code throws an 
exception.  I can avoid this by setting the first NK1 again, however this 
doesn't feel like the best way to approach the problem.  I would be interested 
in any thoughts as to the best way to approach the problem.

<code>
private AbstractMessage msg;
public constructor(rawMsg){
                msg = (AbstractMessage)parser.parse(rawMsg);
                Terser t = new Terser(msg);

                hapiTerser.set("/.NK1(2)-1-1", "2");
                // throws HL7 Exception - ca.uhn.hl7v2.HL7Exception: Can't 
return repetition #2 of NK1 - there are currently only 1 repetitions so rep# 
must be between 0 and 1
}
</code>

I have found that if I: hapiTerser.set("/.NK1-1-1", "1");, the problem appears 
to go away, so I can either iterate over each item or deepcopy to get them 
across, however this feels like a hack to get this working.

I appreciate you taking the time to look at this problem and welcome any 
suggestion.

Andrew
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to