Christian Ohr - 2020-03-09

This is because PR1 is not repeatable, but the surrounding PROCEDURE group is.

        String msg = "MSH|^~\\&|||||20200301114708.448+0530||ADT^A01^ADT_A01|106701|P|2.5\r" +
                "PR1|654^^^654~^^^654||^^^^^654^654|^^^^^^654\r" +
                "PR1|1\r" +
                "PR1|2\r" +
                "PR1|3";

        Message a01 = new PipeParser().parse(msg);
        Terser terser = new Terser(a01);

        terser.set("/.PROCEDURE(1)/PR1-1-4", "234");
        terser.set("/.PROCEDURE(2)/PR1-1-4", "345");

        System.out.println(a01.toString().replace('\r', '\n'));

and the output will be

MSH|^~\&|||||20200301114708.448+0530||ADT^A01^ADT_A01|106701|P|2.5
PR1|654^^^654~^^^654||^^^^^654^654|^^^^^^654
PR1|1^^^234
PR1|2^^^345
PR1|3