How to access repeating fields using the generic Message type

View: New views
16 Messages — Rating Filter:   Alert me  

How to access repeating fields using the generic Message type

by Kamp, Daniel (GE Healthcare) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good afternoon,
I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.
 
For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).
 
Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:
    ca.uhn.hl7v2.model.Message
    ca.uhn.hl7v2.util.Terser
to parse the message.
 
I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.
 
I realize if we used
     ca.uhn.hl7v2.model.v25.message
it would be easier to do this, but we need to remain version agnostic.
 
Can anyone assist me in a simple way to extract a repeating field as mentioned above?
 
Thank you in advance,
Dan
 
Dan Kamp
GE Healthcare
Information Technologies - Global Engineering
Shared Asset Solutions
T (847) 277- 4327
D *567-4327
 

------------------------------------------------------------------------------

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

Re: How to access repeating fields using the generic Message type

by rahul somasunderam-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Most of the times you’re fine converting a message to the highest supported version.

We use the terser and convert any message to a 2.5 message. Then we apply the logic that would apply for a 2.5 message.

I understand there are some message types, some data types, and some segments which get dropped as you progress across versions, but we haven’t lost  much data because of that.

 

Regards,

rahul

 

From: Kamp, Daniel (GE Healthcare) [mailto:Daniel.Kamp@...]
Sent: Thursday, July 23, 2009 11:36 AM
To: hl7api-devel@...
Subject: [HAPI-devel] How to access repeating fields using the generic Message type

 

Good afternoon,

I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.

 

For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).

 

Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:

    ca.uhn.hl7v2.model.Message

    ca.uhn.hl7v2.util.Terser

to parse the message.

 

I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.

 

I realize if we used

     ca.uhn.hl7v2.model.v25.message

it would be easier to do this, but we need to remain version agnostic.

 

Can anyone assist me in a simple way to extract a repeating field as mentioned above?

 

Thank you in advance,

Dan

 

Dan Kamp

GE Healthcare

Information Technologies - Global Engineering

Shared Asset Solutions

T (847) 277- 4327
D *567-4327

 

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.20/2250 - Release Date: 07/23/09 06:02:00


------------------------------------------------------------------------------

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

Re: How to access repeating fields using the genericMessage type

by nksharma0624 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Dan,

 

What do you mean by local graph?

 

If you are just trying to extract and put it into another object than Terser until makes life much more easier.

I can see following options:

1.       Get Message parsed using Generic Parser

2.       Create the empty Object for your target object

3.       Get the Segments from parsed messages

4.       Use Terser to get the values

 

Hope this helps.

 

Thanks.

 

Regards

-Niranjan.

 

 

From: Kamp, Daniel (GE Healthcare)
Sent: Thursday, July 23, 2009 12:36 PM
To: hl7api-devel@...
Subject: [HAPI-devel] How to access repeating fields using the genericMessage type

 

Good afternoon,

I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.

 

For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).

 

Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:

    ca.uhn.hl7v2.model.Message

    ca.uhn.hl7v2.util.Terser

to parse the message.

 

I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.

 

I realize if we used

     ca.uhn.hl7v2.model.v25.message

it would be easier to do this, but we need to remain version agnostic.

 

Can anyone assist me in a simple way to extract a repeating field as mentioned above?

 

Thank you in advance,

Dan

 

Dan Kamp

GE Healthcare

Information Technologies - Global Engineering

Shared Asset Solutions

T (847) 277- 4327
D *567-4327

 


------------------------------------------------------------------------------

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

Re: How to access repeating fields using the generic Message type

by Michael Litherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Dan,

I write a lot of code that deals with many varieties of HL7 and especially with invalid HL7.  I ended up creating a library that just doesn't care what's in the HL7 message as long as it respects the delimiters specified in the MSH seg.  If it'll help you there's information about it here: http://nule.org/wp/?page_id=75 including javadoc and samples.  The license is LGPL and it doesn't require any databases to build.  In your case you could just do a hl7.get("SEG").field(fieldNumber).getRepCount() and .getRep(repNumber).  I need to update the javadoc on the site, but it's not that out of date for that kind of stuff.

Hope that helps,
Mike

On Jul 23, 2009, at 2:36 PM, Kamp, Daniel (GE Healthcare) wrote:

Good afternoon,
I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.
 
For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).
 
Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:
    ca.uhn.hl7v2.model.Message
    ca.uhn.hl7v2.util.Terser
to parse the message.
 
I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.
 
I realize if we used
     ca.uhn.hl7v2.model.v25.message
it would be easier to do this, but we need to remain version agnostic.
 
Can anyone assist me in a simple way to extract a repeating field as mentioned above?
 
Thank you in advance,
Dan
 
Dan Kamp
GE Healthcare
Information Technologies - Global Engineering
Shared Asset Solutions
T (847) 277- 4327
D *567-4327
 
------------------------------------------------------------------------------
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel


------------------------------------------------------------------------------

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

Re: How to access repeating fields using the generic Message type

by James Agnew :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Daniel,

Two obvious solutions jump out at me.

One, using the terser (as you mention) should be fairly easy.

An example from code we use here is to pass it "/.PID-3(0)-1", then "/.PID-3(1)-1", then "/.PID-3(3)-1" to retrieve the various IDs in PID-3.

One other option you might try is to subclass PipeParser and in your subclass, override the parse(String) method to have it replace all of the version strings with the most recent one you need (for instance have it replace the first instance of "2.1", "2.2", etc with "2.6"). That way your message will always be parsed as a 2.6 message. HL7 is designed to be backward compatible, so this should also work.

Actually, thinking about this more (sorry for the rambling email!) an even better solution along the same vein would be to implement a custom ModelClassFactory that always returns 2.6 objects regardless of version and pass that to your pipe parser.

Hopefully this gives you some ideas!

Cheers,
James


On Thu, Jul 23, 2009 at 2:36 PM, Kamp, Daniel (GE Healthcare) <Daniel.Kamp@...> wrote:
Good afternoon,
I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.
 
For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).
 
Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:
    ca.uhn.hl7v2.model.Message
    ca.uhn.hl7v2.util.Terser
to parse the message.
 
I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.
 
I realize if we used
     ca.uhn.hl7v2.model.v25.message
it would be easier to do this, but we need to remain version agnostic.
 
Can anyone assist me in a simple way to extract a repeating field as mentioned above?
 
Thank you in advance,
Dan
 
Dan Kamp
GE Healthcare
Information Technologies - Global Engineering
Shared Asset Solutions
T (847) 277- 4327
D *567-4327
 

------------------------------------------------------------------------------

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



------------------------------------------------------------------------------

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

Re: How to access repeating fields using the generic Message type

by Kamp, Daniel (GE Healthcare) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you to everyone for your quick assistance.  Here is the code snippet I did that worked:
 

     Segment pidSegment = terser.getSegment("PID-5");

     Type[] pid5Type = pidSegment.getField(5);

     for (int indx = 0; indx < pid5Type.length; indx++) {

        String subIndex = "(" + indx + ")";

        terser.get("PID-5" + subIndx + "-1");  // gets familyName

        terser.get("PID-5" + subIndx + "-2");  // gets givenName

     }

A little ugly but it keeps things generic so you do not have to pick an HL7 version number in the domain model.


From: Kamp, Daniel (GE Healthcare)
Sent: Thursday, July 23, 2009 1:36 PM
To: hl7api-devel@...
Subject: How to access repeating fields using the generic Message type

Good afternoon,
I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.
 
For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).
 
Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:
    ca.uhn.hl7v2.model.Message
    ca.uhn.hl7v2.util.Terser
to parse the message.
 
I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.
 
I realize if we used
     ca.uhn.hl7v2.model.v25.message
it would be easier to do this, but we need to remain version agnostic.
 
Can anyone assist me in a simple way to extract a repeating field as mentioned above?
 
Thank you in advance,
Dan
 
Dan Kamp
GE Healthcare
Information Technologies - Global Engineering
Shared Asset Solutions
T (847) 277- 4327
D *567-4327
 

------------------------------------------------------------------------------

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

Re: How to access repeating fields using thegeneric Message type

by nksharma0624 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Rahul,

 

How do you use Terser to convert to V2.5?

 

I think James idea of having a extended ModelClassFactory for V2.6 can serve the purpose?

 

Thoughts?

 

Thanks.

 

Regards

-Niranjan.

 

From: rahul somasunderam [mailto:rsom@...]
Sent: Thursday, July 23, 2009 12:51 PM
To: hl7api-devel@...
Subject: Re: [HAPI-devel] How to access repeating fields using thegeneric Message type

 

Most of the times you’re fine converting a message to the highest supported version.

We use the terser and convert any message to a 2.5 message. Then we apply the logic that would apply for a 2.5 message.

I understand there are some message types, some data types, and some segments which get dropped as you progress across versions, but we haven’t lost  much data because of that.

 

Regards,

rahul

 

From: Kamp, Daniel (GE Healthcare) [mailto:Daniel.Kamp@...]
Sent: Thursday, July 23, 2009 11:36 AM
To: hl7api-devel@...
Subject: [HAPI-devel] How to access repeating fields using the generic Message type

 

Good afternoon,

I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.

 

For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).

 

Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:

    ca.uhn.hl7v2.model.Message

    ca.uhn.hl7v2.util.Terser

to parse the message.

 

I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.

 

I realize if we used

     ca.uhn.hl7v2.model.v25.message

it would be easier to do this, but we need to remain version agnostic.

 

Can anyone assist me in a simple way to extract a repeating field as mentioned above?

 

Thank you in advance,

Dan

 

Dan Kamp

GE Healthcare

Information Technologies - Global Engineering

Shared Asset Solutions

T (847) 277- 4327
D *567-4327

 

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.20/2250 - Release Date: 07/23/09 06:02:00


------------------------------------------------------------------------------

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

Re: How to access repeating fields using thegeneric Message type

by rahul somasunderam-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi Niranjan,

 

                public Message convert(Message message, String version)

                                                throws EncodingNotSupportedException, HL7Exception {

                                String inVersion = message.getVersion();

                                Terser terser = new Terser(message);

                                if (!terser.get("/MSH-12").equals(version)) {

                                                terser.set("/MSH-12", version);

                                                PipeParser pp = new PipeParser();

                                                message = pp.parse(pp.encode(message));

                                                return message;

                                } else {

                                                return message;

                                }

                }

 

Hope that helps. And given that HAPI 0.6 is out, it is a good idea to convert all messages to 2.6 [instead of 2.5 as I am doing], and then process them.

I haven’t tried the ModelClassFactory, but if that does the job in pretty much the same way, please compare the performance of both solutions. I parse the message twice and encode it once, making it slower.

 

If you want to use the Idea James first mentioned, i.e. using XPath like expressions, I would side with Michael’s idea of using LightHl7Lib. I use LightHl7Lib for preprocessing messages before parsing them with HAPI.

LightHl7Lib appears to be faster to me. I haven’t run any metrics though.

 

Regards,

rahul

 

From: Sharma, Niranjan K (GE Healthcare) [mailto:niranjan.sharma@...]
Sent: Thursday, July 23, 2009 3:26 PM
To: rahul somasunderam; hl7api-devel@...
Subject: RE: [HAPI-devel] How to access repeating fields using thegeneric Message type

 

Rahul,

 

How do you use Terser to convert to V2.5?

 

I think James idea of having a extended ModelClassFactory for V2.6 can serve the purpose?

 

Thoughts?

 

Thanks.

 

Regards

-Niranjan.

 

From: rahul somasunderam [mailto:rsom@...]
Sent: Thursday, July 23, 2009 12:51 PM
To: hl7api-devel@...
Subject: Re: [HAPI-devel] How to access repeating fields using thegeneric Message type

 

Most of the times you’re fine converting a message to the highest supported version.

We use the terser and convert any message to a 2.5 message. Then we apply the logic that would apply for a 2.5 message.

I understand there are some message types, some data types, and some segments which get dropped as you progress across versions, but we haven’t lost  much data because of that.

 

Regards,

rahul

 

From: Kamp, Daniel (GE Healthcare) [mailto:Daniel.Kamp@...]
Sent: Thursday, July 23, 2009 11:36 AM
To: hl7api-devel@...
Subject: [HAPI-devel] How to access repeating fields using the generic Message type

 

Good afternoon,

I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.

 

For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).

 

Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:

    ca.uhn.hl7v2.model.Message

    ca.uhn.hl7v2.util.Terser

to parse the message.

 

I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.

 

I realize if we used

     ca.uhn.hl7v2.model.v25.message

it would be easier to do this, but we need to remain version agnostic.

 

Can anyone assist me in a simple way to extract a repeating field as mentioned above?

 

Thank you in advance,

Dan

 

Dan Kamp

GE Healthcare

Information Technologies - Global Engineering

Shared Asset Solutions

T (847) 277- 4327
D *567-4327

 

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.20/2250 - Release Date: 07/23/09 06:02:00

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.20/2250 - Release Date: 07/23/09 06:02:00


------------------------------------------------------------------------------

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

Re: How to access repeating fields usingthegeneric Message type

by nksharma0624 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Thanks Rahul.

 

I will certainly would like to experiment with ModelClassFactory idea as it seems less computing to get on Highest Version Message.

 

Will keep the you posted.

 

Thanks.

 

Regards

-Niranjan.

 

 

From: rahul somasunderam [mailto:rsom@...]
Sent: Thursday, July 23, 2009 4:45 PM
To: hl7api-devel@...
Subject: Re: [HAPI-devel] How to access repeating fields usingthegeneric Message type

 

Hi Niranjan,

 

                public Message convert(Message message, String version)

                                                throws EncodingNotSupportedException, HL7Exception {

                                String inVersion = message.getVersion();

                                Terser terser = new Terser(message);

                                if (!terser.get("/MSH-12").equals(version)) {

                                                terser.set("/MSH-12", version);

                                                PipeParser pp = new PipeParser();

                                                message = pp.parse(pp.encode(message));

                                                return message;

                                } else {

                                                return message;

                                }

                }

 

Hope that helps. And given that HAPI 0.6 is out, it is a good idea to convert all messages to 2.6 [instead of 2.5 as I am doing], and then process them.

I haven’t tried the ModelClassFactory, but if that does the job in pretty much the same way, please compare the performance of both solutions. I parse the message twice and encode it once, making it slower.

 

If you want to use the Idea James first mentioned, i.e. using XPath like expressions, I would side with Michael’s idea of using LightHl7Lib. I use LightHl7Lib for preprocessing messages before parsing them with HAPI.

LightHl7Lib appears to be faster to me. I haven’t run any metrics though.

 

Regards,

rahul

 

From: Sharma, Niranjan K (GE Healthcare) [mailto:niranjan.sharma@...]
Sent: Thursday, July 23, 2009 3:26 PM
To: rahul somasunderam; hl7api-devel@...
Subject: RE: [HAPI-devel] How to access repeating fields using thegeneric Message type

 

Rahul,

 

How do you use Terser to convert to V2.5?

 

I think James idea of having a extended ModelClassFactory for V2.6 can serve the purpose?

 

Thoughts?

 

Thanks.

 

Regards

-Niranjan.

 

From: rahul somasunderam [mailto:rsom@...]
Sent: Thursday, July 23, 2009 12:51 PM
To: hl7api-devel@...
Subject: Re: [HAPI-devel] How to access repeating fields using thegeneric Message type

 

Most of the times you’re fine converting a message to the highest supported version.

We use the terser and convert any message to a 2.5 message. Then we apply the logic that would apply for a 2.5 message.

I understand there are some message types, some data types, and some segments which get dropped as you progress across versions, but we haven’t lost  much data because of that.

 

Regards,

rahul

 

From: Kamp, Daniel (GE Healthcare) [mailto:Daniel.Kamp@...]
Sent: Thursday, July 23, 2009 11:36 AM
To: hl7api-devel@...
Subject: [HAPI-devel] How to access repeating fields using the generic Message type

 

Good afternoon,

I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.

 

For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).

 

Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:

    ca.uhn.hl7v2.model.Message

    ca.uhn.hl7v2.util.Terser

to parse the message.

 

I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.

 

I realize if we used

     ca.uhn.hl7v2.model.v25.message

it would be easier to do this, but we need to remain version agnostic.

 

Can anyone assist me in a simple way to extract a repeating field as mentioned above?

 

Thank you in advance,

Dan

 

Dan Kamp

GE Healthcare

Information Technologies - Global Engineering

Shared Asset Solutions

T (847) 277- 4327
D *567-4327

 

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.20/2250 - Release Date: 07/23/09 06:02:00

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.20/2250 - Release Date: 07/23/09 06:02:00


------------------------------------------------------------------------------

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

Re: How to access repeating fields using the genericMessage type

by nksharma0624 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

James,

 

When one create a custom ModelClassFactory Implementation and return V2.6(lets say) message, will not cause trouble when we send ACK with 2.6 version in it for a sender of V2.3.1 message?

 

Thanks.

 

Regards

-Niranjan.

 

From: James Agnew [mailto:james@...]
Sent: Thursday, July 23, 2009 1:04 PM
To: Kamp, Daniel (GE Healthcare)
Cc: hl7api-devel@...
Subject: Re: [HAPI-devel] How to access repeating fields using the genericMessage type

 

Hi Daniel,

Two obvious solutions jump out at me.

One, using the terser (as you mention) should be fairly easy.

An example from code we use here is to pass it "/.PID-3(0)-1", then "/.PID-3(1)-1", then "/.PID-3(3)-1" to retrieve the various IDs in PID-3.

One other option you might try is to subclass PipeParser and in your subclass, override the parse(String) method to have it replace all of the version strings with the most recent one you need (for instance have it replace the first instance of "2.1", "2.2", etc with "2.6"). That way your message will always be parsed as a 2.6 message. HL7 is designed to be backward compatible, so this should also work.

Actually, thinking about this more (sorry for the rambling email!) an even better solution along the same vein would be to implement a custom ModelClassFactory that always returns 2.6 objects regardless of version and pass that to your pipe parser.

Hopefully this gives you some ideas!

Cheers,
James

On Thu, Jul 23, 2009 at 2:36 PM, Kamp, Daniel (GE Healthcare) <Daniel.Kamp@...> wrote:

Good afternoon,

I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.

 

For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).

 

Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:

    ca.uhn.hl7v2.model.Message

    ca.uhn.hl7v2.util.Terser

to parse the message.

 

I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.

 

I realize if we used

     ca.uhn.hl7v2.model.v25.message

it would be easier to do this, but we need to remain version agnostic.

 

Can anyone assist me in a simple way to extract a repeating field as mentioned above?

 

Thank you in advance,

Dan

 

Dan Kamp

GE Healthcare

Information Technologies - Global Engineering

Shared Asset Solutions

T (847) 277- 4327
D *567-4327

www.gehealthcare.com

 


------------------------------------------------------------------------------

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

 


------------------------------------------------------------------------------

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

Re: How to access repeating fields using the genericMessage type

by James Agnew :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi NIranjan,

It's possible, but it depends on how you are constructing those ACKs. If you are using DefaultApplication.makeAck(Segment), you'll be fine as it uses the version string as opposed to the structure version to figure out what version to create.

In other words, if you have an instance of
ca.uhn.hl7v2.model.v26.message.ACK
with MSH-12 set to "2.3", then a version 2.3 ack will be created.

Whatever method you are using, you can always go back and change MSH-12 back manually anyhow.

Cheers,
James

On Thu, Jul 23, 2009 at 8:29 PM, Sharma, Niranjan K (GE Healthcare) <niranjan.sharma@...> wrote:

James,

 

When one create a custom ModelClassFactory Implementation and return V2.6(lets say) message, will not cause trouble when we send ACK with 2.6 version in it for a sender of V2.3.1 message?

 

Thanks.

 

Regards

-Niranjan.

 

From: James Agnew [mailto:james@...]
Sent: Thursday, July 23, 2009 1:04 PM
To: Kamp, Daniel (GE Healthcare)
Cc: hl7api-devel@...


Subject: Re: [HAPI-devel] How to access repeating fields using the genericMessage type

 

Hi Daniel,



Two obvious solutions jump out at me.

One, using the terser (as you mention) should be fairly easy.

An example from code we use here is to pass it "/.PID-3(0)-1", then "/.PID-3(1)-1", then "/.PID-3(3)-1" to retrieve the various IDs in PID-3.

One other option you might try is to subclass PipeParser and in your subclass, override the parse(String) method to have it replace all of the version strings with the most recent one you need (for instance have it replace the first instance of "2.1", "2.2", etc with "2.6"). That way your message will always be parsed as a 2.6 message. HL7 is designed to be backward compatible, so this should also work.

Actually, thinking about this more (sorry for the rambling email!) an even better solution along the same vein would be to implement a custom ModelClassFactory that always returns 2.6 objects regardless of version and pass that to your pipe parser.

Hopefully this gives you some ideas!

Cheers,
James

On Thu, Jul 23, 2009 at 2:36 PM, Kamp, Daniel (GE Healthcare) <Daniel.Kamp@...> wrote:

Good afternoon,

I am trying to write a transformer which converts an HL7 message to a local object graph.  In doing so, I need to account for repeating fields.

 

For example, PID-5 can have multiple names and we need to parse it out into a List of PatientName objects (each PatientName object contains family name, given name, and name type code).

 

Since we need to support many versions of HL7 we can not use a specific v 2.x model data types.  Instead we are relying on the generic:

    ca.uhn.hl7v2.model.Message

    ca.uhn.hl7v2.util.Terser

to parse the message.

 

I have had a difficult time finding simple examples of parsing repeating fields using these generic classes.

 

I realize if we used

     ca.uhn.hl7v2.model.v25.message

it would be easier to do this, but we need to remain version agnostic.

 

Can anyone assist me in a simple way to extract a repeating field as mentioned above?

 

Thank you in advance,

Dan

 

Dan Kamp

GE Healthcare

Information Technologies - Global Engineering

Shared Asset Solutions

T (847) 277- 4327
D *567-4327

 


------------------------------------------------------------------------------

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

 



------------------------------------------------------------------------------

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

HAPI Threading Model

by nksharma0624 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi James,

 

I have implemented a HL7Server based on HAPI’s HL7 Server implementation.

 

While doing the Threading and Memory analysis, I am realizing that it has a growing Thread model.

Which means HL7Server creates new thread for new message..literally?

 

Can you throw some light on Threading model? Also, some facts from UHN experience.

 

I am pretty Happy with HAPI’s overall performance

 

Please see the attached snapshot for your reference.

 

Best Regards

-Niranjan.



------------------------------------------------------------------------------

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

Screenshot-Java Monitoring & Management Console.png (175K) Download Attachment

Re: HAPI Threading Model

by James Agnew :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Niranjan,

I haven't actually used HL7Server personally in a while, although I know there are a number of other people who do- Hopefully someone else can shed some light on their experience. Here at UHN, we have moved over the last few years towards a model of processing incoming HL7 messages in an EJB MDB being fed directly from a queue on our interface engine.

My recollection (with a quick look over the code) is that ProcessorImpl (the class HL7Server instantiates to handle each new connection to the server) spawns a single thread in it's constructor that is responsible for receiving messages, and then spawns a separate thread for every received message to handle sending back an acknowledgement.

This behaviour does seem a bit odd to me, it would probably make sense to handle sending and receiving in a single thread and just keep using that thread. This wouldn't actually be difficult to implement, you would just need to modify "sendAppResponse(Transportable)" in ProcessorImpl. Maybe HL7Server could be modified to include an option for this.

Alternately, ProcessorImpl has a constructor argument "threaded" which can be set to false. This disables all thread creation in the class, which means that you could use it as is, but you would need to add some other stuff yourself (accepting connections, periodically calling "cycle()" to receive new message, etc). If you are hosting your application in an application server, this is probably the safest option, since EJB looks poorly on creating your own threads at all.

Hopefully this helps, and let me know if I can assist in any way.

Cheers,
James

On Fri, Jul 24, 2009 at 10:48 AM, Sharma, Niranjan K (GE Healthcare) <niranjan.sharma@...> wrote:

Hi James,

 

I have implemented a HL7Server based on HAPI’s HL7 Server implementation.

 

While doing the Threading and Memory analysis, I am realizing that it has a growing Thread model.

Which means HL7Server creates new thread for new message..literally?

 

Can you throw some light on Threading model? Also, some facts from UHN experience.

 

I am pretty Happy with HAPI’s overall performance

 

Please see the attached snapshot for your reference.

 

Best Regards

-Niranjan.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Re: HAPI Threading Model

by nksharma0624 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi James,

 

Thanks for your response.

 

I am essentially trying to create an HL7 Server endpoint which will eventually fed to a Q. Can you describe more on your model of EJB MDB model.

I thought you guys at UHN using HL7 server model. I thought HL7 server model is pretty neat and had lots of upside.

 

We want to stay away from EJB and move towards OSGI environment(pure JAVA). My goal is have this HL7 Server in OSGI platform.

 

Is there a way, we can talk on phone?

 

Thanks.

 

Regards

-Niranjan.

 

 

From: jamesagnew@... [mailto:jamesagnew@...] On Behalf Of James Agnew
Sent: Monday, July 27, 2009 4:33 PM
To: Sharma, Niranjan K (GE Healthcare)
Cc: hl7api-devel@...
Subject: Re: HAPI Threading Model

 

Hi Niranjan,

I haven't actually used HL7Server personally in a while, although I know there are a number of other people who do- Hopefully someone else can shed some light on their experience. Here at UHN, we have moved over the last few years towards a model of processing incoming HL7 messages in an EJB MDB being fed directly from a queue on our interface engine.

My recollection (with a quick look over the code) is that ProcessorImpl (the class HL7Server instantiates to handle each new connection to the server) spawns a single thread in it's constructor that is responsible for receiving messages, and then spawns a separate thread for every received message to handle sending back an acknowledgement.

This behaviour does seem a bit odd to me, it would probably make sense to handle sending and receiving in a single thread and just keep using that thread. This wouldn't actually be difficult to implement, you would just need to modify "sendAppResponse(Transportable)" in ProcessorImpl. Maybe HL7Server could be modified to include an option for this.

Alternately, ProcessorImpl has a constructor argument "threaded" which can be set to false. This disables all thread creation in the class, which means that you could use it as is, but you would need to add some other stuff yourself (accepting connections, periodically calling "cycle()" to receive new message, etc). If you are hosting your application in an application server, this is probably the safest option, since EJB looks poorly on creating your own threads at all.

Hopefully this helps, and let me know if I can assist in any way.

Cheers,
James

On Fri, Jul 24, 2009 at 10:48 AM, Sharma, Niranjan K (GE Healthcare) <niranjan.sharma@...> wrote:

Hi James,

 

I have implemented a HL7Server based on HAPI’s HL7 Server implementation.

 

While doing the Threading and Memory analysis, I am realizing that it has a growing Thread model.

Which means HL7Server creates new thread for new message..literally?

 

Can you throw some light on Threading model? Also, some facts from UHN experience.

 

I am pretty Happy with HAPI’s overall performance

 

Please see the attached snapshot for your reference.

 

Best Regards

-Niranjan.

 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Re: HAPI Threading Model

by rahul somasunderam-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi Niranjan,

 

If you like Spring’s IOC, you can try taking a look at Camel HL7 which is a Spring integration for HAPI using ActiveMQ.

I tried it a long while ago, and wasn’t quite successful at getting it to work. But I remember some discussion on this mailing list about Camel.

 

Regards,

rahul

 

 

From: Sharma, Niranjan K (GE Healthcare) [mailto:niranjan.sharma@...]
Sent: Monday, July 27, 2009 3:42 PM
To: James Agnew
Cc: hl7api-devel@...
Subject: Re: [HAPI-devel] HAPI Threading Model

 

Hi James,

 

Thanks for your response.

 

I am essentially trying to create an HL7 Server endpoint which will eventually fed to a Q. Can you describe more on your model of EJB MDB model.

I thought you guys at UHN using HL7 server model. I thought HL7 server model is pretty neat and had lots of upside.

 

We want to stay away from EJB and move towards OSGI environment(pure JAVA). My goal is have this HL7 Server in OSGI platform.

 

Is there a way, we can talk on phone?

 

Thanks.

 

Regards

-Niranjan.

 

 

From: jamesagnew@... [mailto:jamesagnew@...] On Behalf Of James Agnew
Sent: Monday, July 27, 2009 4:33 PM
To: Sharma, Niranjan K (GE Healthcare)
Cc: hl7api-devel@...
Subject: Re: HAPI Threading Model

 

Hi Niranjan,

I haven't actually used HL7Server personally in a while, although I know there are a number of other people who do- Hopefully someone else can shed some light on their experience. Here at UHN, we have moved over the last few years towards a model of processing incoming HL7 messages in an EJB MDB being fed directly from a queue on our interface engine.

My recollection (with a quick look over the code) is that ProcessorImpl (the class HL7Server instantiates to handle each new connection to the server) spawns a single thread in it's constructor that is responsible for receiving messages, and then spawns a separate thread for every received message to handle sending back an acknowledgement.

This behaviour does seem a bit odd to me, it would probably make sense to handle sending and receiving in a single thread and just keep using that thread. This wouldn't actually be difficult to implement, you would just need to modify "sendAppResponse(Transportable)" in ProcessorImpl. Maybe HL7Server could be modified to include an option for this.

Alternately, ProcessorImpl has a constructor argument "threaded" which can be set to false. This disables all thread creation in the class, which means that you could use it as is, but you would need to add some other stuff yourself (accepting connections, periodically calling "cycle()" to receive new message, etc). If you are hosting your application in an application server, this is probably the safest option, since EJB looks poorly on creating your own threads at all.

Hopefully this helps, and let me know if I can assist in any way.

Cheers,
James

On Fri, Jul 24, 2009 at 10:48 AM, Sharma, Niranjan K (GE Healthcare) <niranjan.sharma@...> wrote:

Hi James,

 

I have implemented a HL7Server based on HAPI’s HL7 Server implementation.

 

While doing the Threading and Memory analysis, I am realizing that it has a growing Thread model.

Which means HL7Server creates new thread for new message..literally?

 

Can you throw some light on Threading model? Also, some facts from UHN experience.

 

I am pretty Happy with HAPI’s overall performance

 

Please see the attached snapshot for your reference.

 

Best Regards

-Niranjan.

 

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.32/2266 - Release Date: 07/27/09 05:58:00


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Re: HAPI Threading Model

by nksharma0624 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi Rahul,

 

I have experimented with CAMEL. It works very fine for the purpose it is..which is integration.

 

HAPI has the entire fundamental you need for a HL7 server, I am trying to see if one can create one.

 

The only area where so far I am getting hit is Threading Model. It is not poor but not the best either.

 

Any experience in this area?

 

Thanks.

 

Regards

-Niranjan.

 

From: rahul somasunderam [mailto:rsom@...]
Sent: Monday, July 27, 2009 5:03 PM
To: hl7api-devel@...
Subject: Re: [HAPI-devel] HAPI Threading Model

 

Hi Niranjan,

 

If you like Spring’s IOC, you can try taking a look at Camel HL7 which is a Spring integration for HAPI using ActiveMQ.

I tried it a long while ago, and wasn’t quite successful at getting it to work. But I remember some discussion on this mailing list about Camel.

 

Regards,

rahul

 

 

From: Sharma, Niranjan K (GE Healthcare) [mailto:niranjan.sharma@...]
Sent: Monday, July 27, 2009 3:42 PM
To: James Agnew
Cc: hl7api-devel@...
Subject: Re: [HAPI-devel] HAPI Threading Model

 

Hi James,

 

Thanks for your response.

 

I am essentially trying to create an HL7 Server endpoint which will eventually fed to a Q. Can you describe more on your model of EJB MDB model.

I thought you guys at UHN using HL7 server model. I thought HL7 server model is pretty neat and had lots of upside.

 

We want to stay away from EJB and move towards OSGI environment(pure JAVA). My goal is have this HL7 Server in OSGI platform.

 

Is there a way, we can talk on phone?

 

Thanks.

 

Regards

-Niranjan.

 

 

From: jamesagnew@... [mailto:jamesagnew@...] On Behalf Of James Agnew
Sent: Monday, July 27, 2009 4:33 PM
To: Sharma, Niranjan K (GE Healthcare)
Cc: hl7api-devel@...
Subject: Re: HAPI Threading Model

 

Hi Niranjan,

I haven't actually used HL7Server personally in a while, although I know there are a number of other people who do- Hopefully someone else can shed some light on their experience. Here at UHN, we have moved over the last few years towards a model of processing incoming HL7 messages in an EJB MDB being fed directly from a queue on our interface engine.

My recollection (with a quick look over the code) is that ProcessorImpl (the class HL7Server instantiates to handle each new connection to the server) spawns a single thread in it's constructor that is responsible for receiving messages, and then spawns a separate thread for every received message to handle sending back an acknowledgement.

This behaviour does seem a bit odd to me, it would probably make sense to handle sending and receiving in a single thread and just keep using that thread. This wouldn't actually be difficult to implement, you would just need to modify "sendAppResponse(Transportable)" in ProcessorImpl. Maybe HL7Server could be modified to include an option for this.

Alternately, ProcessorImpl has a constructor argument "threaded" which can be set to false. This disables all thread creation in the class, which means that you could use it as is, but you would need to add some other stuff yourself (accepting connections, periodically calling "cycle()" to receive new message, etc). If you are hosting your application in an application server, this is probably the safest option, since EJB looks poorly on creating your own threads at all.

Hopefully this helps, and let me know if I can assist in any way.

Cheers,
James

On Fri, Jul 24, 2009 at 10:48 AM, Sharma, Niranjan K (GE Healthcare) <niranjan.sharma@...> wrote:

Hi James,

 

I have implemented a HL7Server based on HAPI’s HL7 Server implementation.

 

While doing the Threading and Memory analysis, I am realizing that it has a growing Thread model.

Which means HL7Server creates new thread for new message..literally?

 

Can you throw some light on Threading model? Also, some facts from UHN experience.

 

I am pretty Happy with HAPI’s overall performance

 

Please see the attached snapshot for your reference.

 

Best Regards

-Niranjan.

 

Checked by AVG - www.avg.com
Version: 8.5.387 / Virus Database: 270.13.32/2266 - Release Date: 07/27/09 05:58:00


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel