In HL7 v2.5 the MSH-9 segment is a datatype with 3 fields. HAPI supports this, 
so it gives you getters and setters for all the components in the datatype.
To set up what you want you can do the following:

mshSegment.getMsh9_MessageType().getMessageCode().getMsg1_MessageCode().setValue("ORR");
mshSegment.getMsh9_MessageType().getMessageCode().getMsg2_TriggerEvent().setValue("O02");

HAPI also knows all about escaping, and does it's level best to make your life 
easy.
If you want to get data escaped in a field, just use the setValue method with 
your string in java.

So to build an ACK with the MSA-3 containing escaped ~ characters you can do 
the following:

        ACK myAck = new ACK();
        myAck.initQuickstart("ACK", "", "P");
        myAck.getMSA().getMsa1_AcknowledgmentCode().setValue("PD");
        myAck.getMSA().getMsa2_MessageControlID().setValue("879-0999-1");
        myAck.getMSA().getMsa3_TextMessage().setValue("Text1~Text2~Text3");
        System.out.println(myAck.getMSA().encode());

The output of which is:

MSA|PD|879-0999-1|Text1\R\Text2\R\Text3

Which is what you have asked for. HAPI does the escaping when you encode your 
result ready for sending.
When you receive a message with escaped delimiter characters and parse it with 
HAPI, a getValue method will un-escape the characters for you, and give you a 
java string result.

HAPI really knows HL7, and does a lot to help you. We have had a lot of success 
using it for many years now.

Hope this helps
Ian Vowles
Department of Health
Queensland
Australia

From: Davies, Brian [mailto:brian.dav...@mckesson.com]
Sent: Thursday, 17 December 2015 7:19 AM
To: hl7api-devel@lists.sourceforge.net
Subject: [HAPI-devel] Escaping Encoded characters

I want to be able to escaped the special encoding characters by using \S\ or 
\R\ but this doesn't seem to work for me.

I also tried the code snippet below but it seems that using the quick start 
init method creates multiple repetitions of the message type, for example:

       ORR_O02 orr002=new ORR_O02();
       MSH mshSegment = orr002.getMSH();
       orr002.initQuickstart("ORR", "002", "P");  results in the message below 
with the message type repeated which is not what I want:


MSH|^~\&|CDB||MCK||20010925202704||ORR^002^ORR_O02|1301|P|2.5

Instead I only want

MSH|^~\&|CDB||MCK||20010925202704||ORR^002 |1301|P|2.5

I tried setting the message code like so:
mshSegment.getMsh9_MessageType().getMessageCode().setValue("ORR\\S\\002"); but 
this produces
MSH - MSH|^~\&|CDB||MCK||20010925202704||ORR\E\S\E\002|||2.5

It's not clear how to accomplish escaping encoding characters. How does one do 
that, since the above does not work?

For example,  I want to escaped the tilde in the message below, can this be 
done and how? I hoped \R\ would work but it didn't.


MSA|PD|879-0999-1|Text1~Text2~Text3

********************************************************************************
This email, including any attachments sent with it, is confidential and for the 
sole use of the intended recipient(s). This confidentiality is not waived or 
lost, if you receive it and you are not the intended recipient(s), or if it is 
transmitted/received in error.
Any unauthorised use, alteration, disclosure, distribution or review of this 
email is strictly prohibited.  The information contained in this email, 
including any attachment sent with it, may be subject to a statutory duty of 
confidentiality if it relates to health service matters.
If you are not the intended recipient(s), or if you have received this email in 
error, you are asked to immediately notify the sender by telephone collect on 
Australia +61 1800 198 175 or by return email.  You should also delete this 
email, and any copies, from your computer system network and destroy any hard 
copies produced.
If not an intended recipient of this email, you must not copy, distribute or 
take any action(s) that relies on it; any form of disclosure, modification, 
distribution and/or publication of this email is also prohibited.
Although Queensland Health takes all reasonable steps to ensure this email does 
not contain malicious software, Queensland Health does not accept 
responsibility for the consequences if any person's computer inadvertently 
suffers any disruption to services, loss of information, harm or is infected 
with a virus, other malicious computer programme or code that may occur as a 
consequence of receiving this email.
Unless stated otherwise, this email represents only the views of the sender and 
not the views of the Queensland Government.
**********************************************************************************

------------------------------------------------------------------------------
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to