From: Christian O. <chr...@gm...> - 2013-10-31 14:03:21
|
hi, do you rely on working on an untyped message (i.e. AbstractMessage)? In this case, adding a segment (repetition) can be ambiguous as it is not clear where in the message the segment should actually be added. Messages of different types and versions usually have a dedicated structure definition, which can change even for the same message type in different versions. My experience is that when you create or modify a message using the HAPI API, you should work on typed messages (like ca.uhn.hl7v2.model.v25.message.ADT_A01). And here the API provides you with methods like insertNK1(int rep):NK1. cheers Christian 2013/10/31 Andrew Bowden <And...@rc...> > 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 > Hl7...@li... > https://lists.sourceforge.net/lists/listinfo/hl7api-devel > > |