HL7 V2.x to JSON

1,614 views
Skip to first unread message

rdejo...@gmail.com

unread,
May 2, 2016, 5:42:43 PM5/2/16
to HAPI FHIR
Hi I have a need to convert HL7 2.X from HAPI to JSON.  I can get the message into the class, but GSON croaks with an error.


The code is here:  (i tried the commented out portion as describe in this SO message http://stackoverflow.com/questions/10209959/gson-tojson-throws-stackoverflowerror

         msg = (ca.uhn.hl7v2.model.v25.message.ORU_R01) parser.parse(hl7message);
  Gson gson = new Gson();
//         Gson gson = new GsonBuilder()
//                 .registerTypeAdapter(ORU_R01.class, new MyTypeAdapter<ORU_R01>())
//                 .create();
   
         String json = gson.toJson(msg);



The error is a repeated loop:

at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:219)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:96)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:60)


Any help? 

contactde...@gmail.com

unread,
Jul 18, 2017, 2:54:07 PM7/18/17
to HAPI FHIR, rdejo...@gmail.com
Were you able to find a solution for HAPI to JSON ?

James Agnew

unread,
Jul 18, 2017, 2:57:36 PM7/18/17
to contactde...@gmail.com, HAPI FHIR, rdejo...@gmail.com
Hi,

Unfortunately the conversion from HL7v2 to HL7 FHIR is not as simple as just pumping one data model into the other, or running it through GSON or anything like that.

The two specifications have fairly different data models, you will unfortunately have to write code that copies data from HAPI's HL7v2 classes (e.g. ADT_A01.java) into the corresponding HAPI FHIR classes (e.g. Patient.java, Encounter.java, Practitioner.java, etc.)

Cheers,
James

On Tue, Jul 18, 2017 at 2:54 PM, <contactde...@gmail.com> wrote:
Were you able to find a solution for HAPI to JSON ?

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/e0a37949-083b-4a19-ae4b-c2d9c64ad978%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Kevin Mayfield

unread,
Jul 18, 2017, 3:01:51 PM7/18/17
to James Agnew, contactde...@gmail.com, HAPI FHIR, rdejo...@gmail.com
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Boone, Keith W (GE Healthcare)

unread,
Jul 18, 2017, 3:12:16 PM7/18/17
to Kevin Mayfield, James Agnew, contactde...@gmail.com, HAPI FHIR, rdejo...@gmail.com, Rene....@ringholm.com

Rene Spronk did some mapping work from V2 messages to FHIR.  FHIR Resources also include mapping information from V2 to FHIR in the mappings tab.

 

                Keith

 

From: hapi...@googlegroups.com [mailto:hapi...@googlegroups.com] On Behalf Of Kevin Mayfield
Sent: Tuesday, July 18, 2017 3:02 PM
To: James Agnew <james...@gmail.com>
Cc: contactde...@gmail.com; HAPI FHIR <hapi...@googlegroups.com>; rdejo...@gmail.com
Subject: EXT: Re: HL7 V2.x to JSON

 

This is a work in progress but HAPI HL7v2 to HAPI FHIR

 


On 18 Jul 2017, at 19:57, James Agnew <james...@gmail.com> wrote:

Hi,

 

Unfortunately the conversion from HL7v2 to HL7 FHIR is not as simple as just pumping one data model into the other, or running it through GSON or anything like that.

 

The two specifications have fairly different data models, you will unfortunately have to write code that copies data from HAPI's HL7v2 classes (e.g. ADT_A01.java) into the corresponding HAPI FHIR classes (e.g. Patient.java, Encounter.java, Practitioner.java, etc.)

 

Cheers,

James

On Tue, Jul 18, 2017 at 2:54 PM, <contactde...@gmail.com> wrote:

Were you able to find a solution for HAPI to JSON ?

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/e0a37949-083b-4a19-ae4b-c2d9c64ad978%40googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/CAKowd8nQa4qtp42jjC6YNUdJqNkU6x6THkXeVXf23pO6APkH7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

Rene Spronk (Ringholm)

unread,
Jul 19, 2017, 2:33:10 AM7/19/17
to Boone, Keith W (GE Healthcare), Kevin Mayfield, James Agnew, contactde...@gmail.com, HAPI FHIR, rdejo...@gmail.com
http://ringholm.com/docs/04350_mapping_HL7v2_FHIR.htm discusses some of
the v2 to FHIR mapping challenges.

cht.fhir.org has a separate channel related to v2-to-FHIR mapping, see
https://chat.fhir.org/#narrow/stream/v2.20to.20FHIR

-Rene


Op 18-7-2017 om 21:12 schreef Boone, Keith W (GE Healthcare):
>
> Rene Spronk did some mapping work from V2 messages to FHIR. FHIR
> Resources also include mapping information from V2 to FHIR in the
> mappings tab.
>
> Keith
>
> *From:*hapi...@googlegroups.com [mailto:hapi...@googlegroups.com]
> *On Behalf Of *Kevin Mayfield
> *Sent:* Tuesday, July 18, 2017 3:02 PM
> *To:* James Agnew <james...@gmail.com>
> *Cc:* contactde...@gmail.com; HAPI FHIR
> <hapi...@googlegroups.com>; rdejo...@gmail.com
> *Subject:* EXT: Re: HL7 V2.x to JSON
>
> This is a work in progress but HAPI HL7v2 to HAPI FHIR
>
> https://github.com/nhsconnect/careconnect-java-examples/blob/master/UHSH7v2Diagnostics/src/main/java/uk/nhs/careconnect/examples/App/UHSDiagnotics.java
>
> Sent from my iPhone
>
>
> On 18 Jul 2017, at 19:57, James Agnew <james...@gmail.com
> <mailto:james...@gmail.com>> wrote:
>
> Hi,
>
> Unfortunately the conversion from HL7v2 to HL7 FHIR is not as
> simple as just pumping one data model into the other, or running
> it through GSON or anything like that.
>
> The two specifications have fairly different data models, you will
> unfortunately have to write code that copies data from HAPI's
> HL7v2 classes (e.g. ADT_A01.java) into the corresponding HAPI FHIR
> classes (e.g. Patient.java, Encounter.java, Practitioner.java, etc.)
>
> Cheers,
>
> James
>
> On Tue, Jul 18, 2017 at 2:54 PM, <contactde...@gmail.com
> <mailto:contactde...@gmail.com>> wrote:
>
> Were you able to find a solution for HAPI to JSON ?
>
> --
> You received this message because you are subscribed to the
> Google Groups "HAPI FHIR" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to hapi-fhir+...@googlegroups.com
> <mailto:hapi-fhir+...@googlegroups.com>.
> To post to this group, send email to
> hapi...@googlegroups.com <mailto:hapi...@googlegroups.com>.
> <https://groups.google.com/d/msgid/hapi-fhir/e0a37949-083b-4a19-ae4b-c2d9c64ad978%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "HAPI FHIR" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to hapi-fhir+...@googlegroups.com
> <mailto:hapi-fhir+...@googlegroups.com>.
> To post to this group, send email to hapi...@googlegroups.com
> <mailto:hapi...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hapi-fhir/CAKowd8nQa4qtp42jjC6YNUdJqNkU6x6THkXeVXf23pO6APkH7w%40mail.gmail.com
> <https://groups.google.com/d/msgid/hapi-fhir/CAKowd8nQa4qtp42jjC6YNUdJqNkU6x6THkXeVXf23pO6APkH7w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "HAPI FHIR" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hapi-fhir+...@googlegroups.com
> <mailto:hapi-fhir+...@googlegroups.com>.
> To post to this group, send email to hapi...@googlegroups.com
> <mailto:hapi...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hapi-fhir/9FA8C21A-DB8A-432D-82F1-0FA7A66FD4CC%40gmail.com
> <https://groups.google.com/d/msgid/hapi-fhir/9FA8C21A-DB8A-432D-82F1-0FA7A66FD4CC%40gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>

--
------------------------------------------------------------
Rene Spronk Cell: +31 (0)655 363 446
Tutor/Senior Consultant Office: +31 (0)33 7 630 636
Ringholm bv The Netherlands
http://www.ringholm.com mailto:Rene....@ringholm.com
twitter:@Ringholm skype:rene_ringholm
Ringholm is registered at the Amsterdam KvK reg.# 30155695
------------------------------------------------------------
Learn * Share * Connect

frank...@gmail.com

unread,
Jan 2, 2018, 12:14:06 PM1/2/18
to HAPI FHIR
Did this end up going anywhere? The link seems to be dead. As mentioned each resource has a mappings page ex) https://www.hl7.org/fhir/patient-mappings.html



On Tuesday, July 18, 2017 at 1:01:51 PM UTC-6, Kevin Mayfield wrote:
This is a work in progress but HAPI HL7v2 to HAPI FHIR


On 18 Jul 2017, at 19:57, James Agnew <james...@gmail.com> wrote:

Hi,

Unfortunately the conversion from HL7v2 to HL7 FHIR is not as simple as just pumping one data model into the other, or running it through GSON or anything like that.

The two specifications have fairly different data models, you will unfortunately have to write code that copies data from HAPI's HL7v2 classes (e.g. ADT_A01.java) into the corresponding HAPI FHIR classes (e.g. Patient.java, Encounter.java, Practitioner.java, etc.)

Cheers,
James
On Tue, Jul 18, 2017 at 2:54 PM, <contactde...@gmail.com> wrote:
Were you able to find a solution for HAPI to JSON ?

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

M Pais

unread,
Nov 29, 2018, 6:56:57 PM11/29/18
to HAPI FHIR
Greetings,

About the HL7/v2 to HL7/FHIR Mapping,

When you said:

  Unfortunately the conversion from HL7v2 to HL7 FHIR is not as 
>     simple as just pumping one data model into the other, or running 
>     it through GSON or anything like that. 

>     The two specifications have fairly different data models, you will 
>     unfortunately have to write code that copies data from HAPI's 
>     HL7v2 classes (e.g. ADT_A01.java) into the corresponding HAPI FHIR 
>     classes (e.g. Patient.java, Encounter.java, Practitioner.java, etc.) 
 
 
Is there anyway to know about what are the correspondences for example of all ADT_A** message  in HL7.v2 to FHIR Resource?
 I mean is there already any tables with that information?

And do you think is it feasible to create an message converter framework, were for each HL7.v2 we match an pattern to map to its correspondent of FHIR?


Best Regards,

Keith Boone

unread,
Nov 29, 2018, 7:25:09 PM11/29/18
to M Pais, HAPI FHIR
Not only do I think it is feasible, I’m building one.

   Keith

Sent from my iPhone
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

M Pais

unread,
Nov 30, 2018, 5:23:10 PM11/30/18
to kbo...@ainq.com, hapi...@googlegroups.com
Greetings,

Iam writing my master thesis precisely about that.
Is it possible to give me some advice?

The abstraction level of the HL7.v2x messages should is something like this: Class ADT_AXX ? 
And in the FHIR side how do we know to what Resource this class should point to?



Cumprimentos / Best regards
Marcos Pais


To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

Keith Boone

unread,
Nov 30, 2018, 5:24:27 PM11/30/18
to M Pais, hapi...@googlegroups.com

Look at the Mapping tab on the FHIR Resource.

 

                Keith

M Pais

unread,
Nov 30, 2018, 5:59:53 PM11/30/18
to kbo...@ainq.com, hapi...@googlegroups.com
Only know I start to understand.


image.png

And the PID-3 have its correspondent match in the HL7 v2 table (Chapter 3 for the v2.5) 

image.png

And as we can see under SEQ 3 is also Patient identifier.

So i must investigate the mapping from HL7.v2 segment to FHIR Resource, instead from HL7.v2 message type.



Cumprimentos / Best regards
Marcos Pais

Reply all
Reply to author
Forward
0 new messages