PRT is not a segment that is defined for the events you mentioned. Therefore you have to use a more generic way: You can add it to the message using addNonStandardSegment("PRT") (optionally with index position) and then obtain it with PRT prt = (PRT)a01.get("PRT")
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...
There is likely no proper HL7 segment separator after the 2.5.1 at the end of the MSH segment, so it treats the beginning of the next line as part of the version number. Segment separator must be a "\r" (corresponding to file saved with Mac linebreaks).
Hapi Terser issue to retrieve HL7 segments
Use version HAPI version 2.3 You need to specify the segments in the order they are defined in the message definition! - your example is completely mixed up Custom Z segments appended to a message can never be in a group - how should the parser know that ZAR and ZSH supposed to form a group? If a segment is not immediately repeating, the second occurence gets a custom segment name (with a number appended to the segment name) to make it unique. Here is a working example (should also work with 2.8.1):...
Please provide details about the MSH segment. The Terser paths depend on the event type and the HL7 version.
For RDE_O25, you use the RDE_O11 structure class
There is ca.uhn.hl7v2.preparser.PreParser.getFields(msg, fields...) that returns the value of fields without parsing it into a structure. Check out the javadocs
There is PreParser.getFields(msg, fields...) that returns the value of fields without parsing it into a structure. Check out the javadocs
True. The DefaultXMLParser did not set himself as parser being responsible for the message being created. Fixed with https://github.com/hapifhir/hapi-hl7v2/commit/f17db02ce8bcfd5df25a894039186719c432df3e
What event type do you build in which HL7 version? addNonstandardSegment is implemented for Groups in general. So, if you want to append a non-standard segment to a repeating group, you have to create/obtain the group repetition and append your segment here instead of at message level. E.g. if you try to construct a ADT_A01 in HL7v2.5: ADT_A01 a01 = new ADT_A01(); // ... // add a repetition ADT_A01_INSURANCE insurance = a01.insertINSURANCE(0); Segment in1 = insurance.getIN1(); // ... populate IN1...
Position of standard Segment for each transaction type and transacrtion genre
Reading javadocs is recommended when looking for library functions. getNames() returns what you want. Note that messages may contain groups that again contain groups or segments, i.e. messages do not just contain a linear structure of segments.
What do try to achieve with 20? First thing I urgently recommend you to get a copy of the HL7 specification (https://www.hl7.org/implement/standards/product_brief.cfm?product_id=185; yes, you need to have an account!). Sometimes, an online tool like http://hl7-definition.caristix.com:9010/ is also sufficient. From the ADT_A01 definition, you can see that PV1 is the 10th segment in the message. As the index is zero-based, message.addNonstandardSegment("ZPV", 10); will add a ZPV segment after PV1....
Did you already try the method message.addNonstandardSegment(String name, int index)? With this method you should be able to insert your custom segment at the "index" position in the message or message group
Can you provide some sample code on how you create this message? Do you need to send it or receive/parse it?
#242: fix tests
#242: credits
#242: improve SegmentFinder performance
Performance problem in SegmentFinder
The set of supported HL7 versions is unordered
The error message is not going to show up anymore: if a structure library is not...
fixed incorrect field numbers for handling MFE-...
HAPI HL7 2.3 will include 2.7 and 2.8 support. About to be released within the next...
Performance improvement SegmentFinder#matches
Duplicate of https://sourceforge.net/p/hl7api/bugs/242/.
PipeParser.getAckID does not work on Windows machines
Performance problem in SegmentFinder
A while ago I committed ca.uhn.hl7v2.model.Unmodifiable, that allows to protect messages...
wrong casing for deserializing
#239: fix parsing Role and Identifier elements
NumberFormatException when generating an ack message
Fixed. Thanks for spotting this.
#241: credits
#241: consistently use longs during message ID ...
fixed in AbstractHL7Exception
ERR segment: Issue with sequence
#240: fix missing segment repetition location i...
#238: fix serialization of TerserMessageRule
TerserMessageRule is not serializable
NPE when working with Conformance Profiles stored on the ClassPath
Now returning null what causes the ProfileValidator to throw a ProfileException
#234:fix NPE with non-existing conformance prof...
NPE when working with Conformance Profiles stored on the ClassPath
The xref is of HAPI v2.1. The example was added with 2.2
I think this is a duplicate of #229
Please send questions like this to the HAPI mailing list (http://hl7api.sourceforge.net/mail-lists.html)....
The set of supported HL7 versions is unordered
CommonTS.getValueAsCalendar problems with positive GMT offsets and DST
Verfied and comitted your fix except that I chose to construct the time zone string...
#229:fix daylight savings issue
Oh cool. I will look into this. The .project files should probably not checked in...
removed unnecessary generics (ambiguities with ...
upgrade to Java 1.6
skip conformance checking for Varies fields
#229: fix positive timezones
CommonTS.getValueAsCalendar problems with positive GMT offsets and DST
There's the hapi-osgi-base library; please check if this is what you expect
add optional validation of primitives (turned o...
Probably a DST issue, see #229. What is your default time zone?
Great input. Obviously, fixing the Timezone string for positive offsets makes most...
Great inut. Obviously, fixing the Timezone string for positive offsets makes most...
HapiContext.close() throws NullPointerException
duplicate of #223
As a workaround, you can subclass ca.uhn.hl7v2.conf.check.DefaultValidator and overwrite...
hapi-osgi-base: Unneeded statically linked slf4j-api throws error
The exclusion still referred to log4j which is not directly used anymore. fixed to...
#226:exclude slf4j from bundle
avoid NPE when caching model classes
Added truncation character support and new proj...
After almost 10 years... Fixing OBX-2/5 has been generalized and extended to MFE-5....
Automatically fix data types in MFE-5 and RDF/RDT
removed message-private validationcontext
include new packages to be exported into bundle
fix test. Rendering an ampersand in a field sho...
Make adding/removing repetitions public. It's d...
document changes
Hopefully it will work out for 2.3
Add support for v2.7
committed the change
.encode causes havoc
#207: fix test. Changes in PipeParser was commi...
uncomment on etest. not sure what the expection is
Seems there is a bug in the timezone conversion somewhere ...
also see https://sourceforge.net/p/hl7api/bugs/221/#c6c9
rollback some code
#91: fix test
#92: allow to wrap messages to make them unmodi...
Allow to make parsed message unmodifiable
#91: use HapiContext message creation in a few ...
remove a few warnings, code cosmetics, migrate ...
Create messages from HapiContext
#91: message creation from within an HapiContext
Create messages from HapiContext
also see #65
TSComponentOne breaks contract of AbstractPrimitive
fix with rev. 957
#224: fix tscomponentone
Some archaeology: This dates to back to 2011, introduced with rev. 335 and the comment...
Cannot reproduce this. Anyway, the assertion will never be true because you're comparing...