Small update:
Right now the message gets to the servlet where it is parsed using the
technique outlined by James. It is then inspected by:
msg.getName().toString() to decide what type of message to cast it as.
>From there, it uses the message specific method to pull desirable
information from the messages.
Garrett
On Thu, Nov 17, 2011 at 3:09 PM, Garrett McTear <[email protected]>wrote:
> Combining what James and Jure did, I was able to get an instance of
> ADT_A08 like I wanted.
>
> The messages I am dealing with are part of a conformations packet. What
> would you suggest doing if you are expecting messages like this that may
> need some adjustment to flow through properly. I was looking at the
> examples including with HAPI and seems it would be simple enough to do
> something similar to this:
>
> theMessage = theMessage.replace("\rPI|", "\rPID|");
>
> And use this technique to allow for conformance to those that do not quite
> conform to HL7 standards.
>
> I am open to suggestions too regarding this.
>
> My over all goal is to have a servlet or multiple servlets (maybe one for
> each v2.x) to handle HL7 messages. Right now I have servlets that handle
> v2.3.1 and v2.5.1 and most of the example messages that I received form the
> two companies in their conformance packages do work. It is ones like the
> one being cited in this thread that I am worried about how to handle. I
> would like to be able to create an instance of each class of each type of
> message so it can go down the line and have the information easily
> extracted from the message fields.
>
> I really appreciate the help. I have been playing catch up with this
> project to get up to speed on where it had been left off.
>
> Thanks,
> Garrett
>
>
> On Wed, Nov 16, 2011 at 11:39 PM, Jure Grom <[email protected]> wrote:
>
>> If you look at the MSH-8 (ADT^A08), there is no message structure
>> component (3rd component of field). Therefore PipeParser looks up into
>> ca.uhn.hl7v2.parser.eventmap.2.3.1.properties for appropriate message
>> structure for ADT A08 event. There is mapping ADT_A08 => ADT_A01. That's
>> why you get instance of ADT_A01 message. It's OK, you'll get all fields
>> from your message.****
>>
>> ** **
>>
>> If you like to get instance of ADT_A08 class, then your MSH should be
>> like this:****
>>
>> MSH|^~\\&|RAMSOFT|SENDING FACILITY|RAMSOFT|RECEIVING
>> FACILITY|20101223202939-0400||ADT^A08^ADT_A08|101|P|2.3.1****
>>
>> ** **
>>
>> Regards,****
>>
>> Jure****
>>
>> ** **
>>
>> ** **
>>
>> *From:* James Agnew [mailto:[email protected]]
>> *Sent:* Wednesday, November 16, 2011 10:50 PM
>> *To:* Garrett McTear
>> *Cc:* [email protected]
>> *Subject:* Re: [HAPI-devel] This Parser and Library are Great! Quick
>> (hopefully) Question Though!****
>>
>> ** **
>>
>> To that would suggest that your code may be reading a different message.
>> The one you provided looked like a valid A08 to me, so presumably it would
>> parse as such.
>>
>> Perhaps try:
>>
>> Message msg = .... (however you are parsing)
>> System.out.println(msg.encode().replace('\r', '\n');
>>
>> Just to see if the message actually matches the one you are expecting.
>>
>> Cheers,
>> James
>>
>> ****
>>
>> On Wed, Nov 16, 2011 at 2:01 PM, Garrett McTear <[email protected]>
>> wrote:****
>>
>> Specifically, when I do this:
>> ADT_A08 msg = (ADT_A08)msg;
>>
>> I get this error:
>> java.lang.ClassCastException: ca.uhn.hl7v2.model.v231.message.ADT_A01
>> cannot be cast to ca.uhn.hl7v2.model.v231.message.ADT_A08****
>>
>>
>>
>>
>> ****
>>
>> On Wed, Nov 16, 2011 at 9:35 AM, Garrett McTear <[email protected]>
>> wrote:****
>>
>> James,
>> Switching operating systems and rebuilding took up a lot more time than I
>> had expected. I am up and running now.
>>
>> I am still getting the issue with that particular message being
>> identified as an ADT_A01 message.
>>
>> I will be working on this all day (and for a good while now that I have
>> my work station up and running again).
>>
>> Any ideas would be appreciated.
>>
>> Thanks,
>> Garrett****
>>
>> ** **
>>
>> On Fri, Nov 11, 2011 at 8:46 AM, Garrett McTear <[email protected]>
>> wrote:****
>>
>> James,
>>
>> I think what you said at the end might be the problem. I do have the
>> latest version of HAPI, but I was using a test txt file to throw messages
>> in.
>>
>> I am switching my operating system today, and may be out of commission
>> most of the day if things do not go smoothly. As soon as I get up and
>> running I will try and confirm what the issue is.
>>
>> At the end of the day yesterday, I did almost exactly what you have above
>> there, minus the:
>>
>> parser.setValidationContext(new NoValidation());
>>
>> But when I used the getVersion() method, it was saying that the message
>> was an ADT_A01 message.
>>
>> Thanks and I will update ASAP!
>>
>> Garrett****
>>
>> ** **
>>
>> On Fri, Nov 11, 2011 at 6:04 AM, James Agnew <[email protected]> wrote:
>> ****
>>
>> Hi Garrett,
>>
>> Hi Garrett,
>>
>> Strange, I put your message into your code and it seems to work for me.
>> The following:
>>
>> String msgString = "MSH|^~\\&|RAMSOFT|SENDING FACILITY|RAMSOFT|RECEIVING
>> FACILITY|20101223202939-0400||ADT^A08|101|P|2.3.1||||||||\r" +
>> "EVN|A08|20101223202939-0400||||\r" +
>>
>> "PID||P12345^^^ISSUER|P12345^^^ISSUER||PATIENT^TEST^M^^^^||19741018|M|||10808
>> FOOTHILL BLVD^^RANCHO CUCAMONGA^CA^91730^US||(909)481-5872^^^
>> [email protected]|(909)481-5800x1||M||12345|286-50-9510|||\r" +
>>
>> "PV1||O||||||||||||||||||||||||||||||||||||||||||||||||||\r" +
>> "AL1|1||^PORK^|\r" +
>> "AL1|2||^PENICILLIN^|";
>>
>> GenericParser parser = new GenericParser();
>> parser.setValidationContext(new NoValidation());
>> Message msg = parser.parse(msgString);
>> System.out.println(msg.getClass().getName());
>>
>> ..parses correctly. Are you using the latest version of HAPI? Is it
>> possible you are reading from a file and getting the wrong line endings or
>> charset or something?
>>
>> James****
>>
>> ** **
>>
>> On Thu, Nov 10, 2011 at 6:00 PM, Garrett McTear <[email protected]>
>> wrote:****
>>
>> Code Section:****
>>
>> ** **
>>
>> Parser p = new GenericParser();****
>>
>> Message hapiMsg; ****
>>
>> try {****
>>
>> hapiMsg = p.parse(out.toString());****
>>
>> logger.info( "doPost() : HL7 successfully parsed" );****
>>
>> } ****
>>
>> catch (EncodingNotSupportedException e) {****
>>
>> logger.info(e.getMessage());****
>>
>> } ****
>>
>> catch (HL7Exception e) {****
>>
>> logger.info(e.getMessage());****
>>
>> }****
>>
>> ** **
>>
>> HL7 v2.3.1 ADT_A08 message that is not working:****
>>
>> ** **
>>
>> MSH|^~\&|RAMSOFT|SENDING FACILITY|RAMSOFT|RECEIVING
>> FACILITY|20101223202939-0400||ADT^A08|101|P|2.3.1||||||||****
>>
>> EVN|A08|20101223202939-0400||||****
>>
>> PID||P12345^^^ISSUER|P12345^^^ISSUER||PATIENT^TEST^M^^^^||19741018|M|||10808
>> FOOTHILL BLVD^^RANCHO****
>>
>> CUCAMONGA^CA^91730^US||(909)481-5872^^^[email protected]|(909)481-5800x1
>> ||M||12345|286-50-9510|||****
>>
>> PV1||O||||||||||||||||||||||||||||||||||||||||||||||||||****
>>
>> AL1|1||^PORK^|****
>>
>> AL1|2||^PENICILLIN^|****
>>
>> ** **
>>
>> Error received:****
>>
>> ** **
>>
>> "Can't parse message beginning MSH|^~\&|RAMSOFT|SENDING
>> FACILITY|RAMSOFT|RECEIVIN"****
>>
>> ** **
>>
>> Let me know if there is anything else I can provide.****
>>
>> ** **
>>
>> Thanks,****
>>
>> Garrett****
>>
>> ** **
>>
>> On Thu, Nov 10, 2011 at 3:50 PM, James Agnew <[email protected]> wrote:
>> ****
>>
>> Hi Garrett,
>>
>> Can you post a code snippet showing the issue you are facing?
>>
>> James
>>
>> ****
>>
>> On Thu, Nov 10, 2011 at 5:20 PM, Garrett McTear <[email protected]>
>> wrote:****
>>
>> I started taking on an HL7 project about two weeks ago. The project
>> was left by the original programmer with very little documentation. Most
>> of my time has been spent doing research. I have successfully used HAPI to
>> parse messages from all of the version 2.x variants. ****
>>
>> ** **
>>
>> The problem I ran into, however, is what happens when someone has taken
>> the liberty to append a "custom extension" to a message. In particular, I
>> am having issues with a modified v2.3.1 ADT_A08 message that cannot be
>> processed by the same HAPI program that can process any other v2.3.1
>> message I throw at it.****
>>
>> ** **
>>
>> I downloaded the HAPI source code and have been digging, but I figured I
>> would shoot an email to the mailing list and see if any of you had any tips
>> on this type of issue. ****
>>
>> ** **
>>
>> Specifics about my issue:****
>>
>> I do get an error:****
>>
>> EncodingNotSupportedException****
>>
>> When using the GenericParser****
>>
>> This same program handles other HL7 v2.3.1 files smoothly. But this
>> modified ADT_A08 is the troublesome file.****
>>
>> ** **
>>
>> Thanks!****
>>
>> Garrett****
>>
>> ** **
>>
>>
>> ------------------------------------------------------------------------------
>> RSA(R) Conference 2012
>> Save $700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Hl7api-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/hl7api-devel****
>>
>> ** **
>>
>> ** **
>>
>> ** **
>>
>> ** **
>>
>> ** **
>>
>> ** **
>>
>> ** **
>>
>
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel