Hi, I am trying to add field repetition for PR1 segment using a terser.set but it throws me error:
"Can't create repetition #1 of Structure PR1 - this Structure is non-repeating so only rep 0 may be retrieved"
The below is my HL7 message with 4 PR1 segments and all I want is to insert values to each PR1 segment field's components using terser.
MSH|^~\&#|||||20200301114708.448+0530||ADT^A01^ADT_A01|106701|P|2.8.1
OBX||||||||||||||||^78
OBX||||||||||||||||^78~^800|^908
OBX||^^908
PR1|654^^^654~^^^654||^^^^^654^654|^^^^^^654
PR1|1
PR1|2
PR1|3
In this case, it will insert values to the zeroth PR1 segment using terser.
This works:
terser.set("/.PR1(0)-3-6", "654");
terser.set("/.PR1(0)-3-7", "654");
terser.set("/.PR1(0)-4-7", "654");
terser.set("/.PR1(0)-1-1", "654");
terser.set("/.PR1(0)-1-4", "654");
terser.set("/.PR1(0)-1(1)-4", "654");
but this does not, terser.set("/.PR1(1)-1-4", "654"); Please help me fix this. -----------------------------------
Full CODE:
ADT_A01 adt= new ADT_A01();
adt.initQuickstart("ADT", "A01", "P");
// adt.insertPROCEDURE(1).
for(int i =0; i<4;i++)
{
ca.uhn.hl7v2.model.v281.segment.PR1 obj = adt.getPROCEDURE(i).getPR1();
obj.getPr11_SetIDPR1().setValue(String.valueOf(i));
} HapiContext context = new DefaultHapiContext(); Parser parser = context.getPipeParser(); String encodedMessage = parser.encode(adt); PipeParser pipeParser = new PipeParser(); Message message = parser.parse(encodedMessage); Terser terser = new Terser(message); System.out.println(terser.toString()); terser.set("/.OBX(0)-16-2", "78"); terser.set("/.OBX(1)-16-2", "78"); terser.set("/.OBX(1)-16(1)-2", "800"); terser.set("/.OBX(1)-17-2", "908"); terser.set("/.OBX(2)-2-3", "908"); terser.set("/.PR1(0)-3-6", "654"); terser.set("/.PR1(0)-3-7", "654"); terser.set("/.PR1(0)-4-7", "654"); terser.set("/.PR1(0)-1-1", "654"); terser.set("/.PR1(0)-1-4", "654"); terser.set("/.PR1(0)-1(1)-4", "654"); terser.set("/.PR1(1)-1-4", "654"); System.out.println("Printing ER7 Encoded Message:"); System.out.println(message.encode());
This is because PR1 is not repeatable, but the surrounding PROCEDURE group is.
and the output will be