Ringholm-Logo Ringholm
 Whitepaper
Ringholm page header
Training    Services   |   Whitepapers    Blog    Events    Links   |   About us    Partners    Clients    Contact

HL7 Message examples: version 2 and FHIR

The contents of this whitepaper are published under the Creative Commons Attribution-Share Alike license.
See http://www.ringholm.com/docs/04350_mapping_HL7v2_FHIR.htm for the latest version of this document.
Editor: René Spronk - Sr.Consultant, Ringholm bv
Document status: Draft, version 1.3 (2015-05-03)   
Please sent questions and comments to Rene.Spronk@Ringholm.com


Summary

This whitepaper contains 2 HL7 version 2 to FHIR mapping scenarios. The first scenario is based on a FHIR server that supports the messaging interoperability paradigm, whereby the v2 message should be mapped to a FHIR message. The second scenario is based on a FHIR server that only supports a REST API (i.e. it doesn't support messaging). Each scenario details the HL7 v2.x message, and its functional equivalent in FHIR. The whitepaper aims to show some the differences as well as similarities between example v2.x and FHIR resource instances.

1. Introduction

This whitepaper has the aim to illustrate how v2 message strcutures are present in FHIR. As you're probably aware of, FHIR is not backwards compatible with the v2.x standard although some of the message constructs (e.g. data types) are similar in nature. Please note that it is not the intent of this whitepaper to discuss migration issues from v2.x to FHIR, nor to discuss the circumstances where using FHIR may be more appropriate than v2.x as a messaging standard. It merely attempts to show some of the similarities between v2.x and FHIR using message examples.

2. FHIR Server - with support for messaging

The first scenario is based on a FHIR server that supports the messaging interoperability paradigm, whereby the v2 message should be mapped to a FHIR message. This section contains an example business use case related to a laboratory results message, as well as a V2.4 and a FHIR message examples. The FHIR message is based upon the DSTU R2 FHIR specification (May 2015). The use case is the completion of a serum glucose laboratory result of 182 mg/dL authored by Howard H. Hippocrates. The laboratory test was ordered by Patricia Primary for patient Eve E. Everywoman. The use case takes place in the US Realm.

2.1 The V2.4 Message

The V2.4 representation of the use-case is a ORU^R01 message. The syntax encoding is based on the classic HL7 v2 syntax, commonly referred to as the vertical-bar syntax. The MSH (Message Header) segment contains the message type, in this case, ORU^R01, which identifies the message type and the trigger event. The sender is the GHH Lab in ELAB-3. The receiving application is the GHH OE system located in BLDG4. The message was sent on 2002-02-15 at 09:30. The MSH segment is the initial segment of the message structure.
 MSH|^~\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4<cr>
 PID|||555-44-4444||EVERYWOMAN^EVE^E^^^^L|JONES|19620320|F|||153 FERNWOOD DR.^
 ^STATESVILLE^OH^35292||(206)3345232|(206)752-121||||AC555444444||67-A4335^OH^20030520<cr>
 OBR|1|845439^GHH OE|1045813^GHH LAB|1554-5^GLUCOSE|||200202150730|||||||||
 555-55-5555^PRIMARY^PATRICIA P^^^^MD^^|||||||||F||||||444-44-4444^HIPPOCRATES^HOWARD H^^^^MD<cr>
 OBX|1|SN|1554-5^GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN||^182|mg/dl|70_105|H|||F<cr>
The PID (Patient Identification) segment contains the demographic information of the patient. Eve E. Everywoman was born on 1962-03-20 and lives in Statesville OH. Her patient ID number (presumably assigned to her by the Good Health Hospital) is 555-44-4444.

The OBR (Observation Request) segment identifies the observation as it was originally ordered: 15545^GLUCOSE. The observation was ordered by Particia Primary MD and performed by Howard Hippocrates MD.

The OBX (Observation) segment contains the results of the observation: 182 mg/dl.

2.2 The FHIR Message

The FHIR Message consists of a bundle or resources, starting with the MessageHeader resource. The overall structure is depicted below.

FHIR message structure in terms of resource

The DiagnosticReport resource (the equivalent of ORC/OBR) references the DiagnosticOrder (with details such as the Lab test being ordered, the order filler number and the ordering person) and has a 0..* relationship with the Observation resource (the equivalent of OBX). The Patient, Practitioners and organizations are represented as individual resources, representing the 'leaf-nodes' in the overall model.

2.2.1 The FHIR Message - Bundle and MessageHeader

The FHIR representation of the use case is a Bundle of resources representing a message (Bundle.type=message) of type observation-provide (MessageHeader.event.code=onservation-provide, the equivalent of the R01 trigger event). In FHIR the addressing of the sender and/or receiver would be typically done using an IP address and a port number, the use of named addressing (e.g. GHH-LAB system) is however still supported.
 <Bundle xmlns="http://hl7.org/fhir">
  <id value="b5be9983-c913-4d54-b2bb-8e848056662a"/>
  <type value="message"/>
  <entry>
    <resource>
      <MessageHeader>
        <id value="CNTRL-3456"/> <!-- ControlID of the v2 message -->
        <meta>
          <tag>
            <system value="urn:oid:2.16.840.1.113883.5.100"/>
            <code value="P"/>
            <display value="Production"/>
          </tag>
        </meta>
        <identifier value="CNTRL-3456"/>
        <timestamp value="2002-02-15T09:30:00-04:00"/>
        <event>
          <system value="http://hl7.org/fhir/message-type"/>
          <code value="observation-provide"/>
        </event>
        <source>
          <name value="GHH LAB"/>
          <endpoint value="urn:GHH-LAB"/>
        </source>
        <destination>
          <name value="GHH OE"/>
          <endpoint value="urn:GHH-OE"/>
        </destination>
        <data> <!--   The payload, the resource that this observation-provide concerns   -->
          <reference value="DiagnosticReport/1045813"/> <!-- Filler order number -->
        </data>
      </MessageHeader>
    </resource>
  </entry>
 
  ... other bundle entries with resources (see below) ...

 </Bundle>

2.2.2 The FHIR Message - Observation resources

The DiagnosticReport resource contains a contained resource: observation. Observation doesn't have a reliable identifier in HL7 v2.4. It's tempting to use the code (1554-5) as an identifier, but given that some orders may have a 1..* relationship with a particular test (the only difference being the point in time when the sample was obtained or when the test was performed) we can't reliably construct an ID. The observed value is 182 mg/dL.
<entry>
    <resource>
      <DiagnosticReport>
        <id value="1045813"/> <!-- Filler Order Number -->
        <contained>

          <Observation>
            <id value="observation-1"/>
            <code>
              <coding>
                <system value="http://loinc.org"/>
                <code value="1554-5"/>
                <display value="GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN"/>
              </coding>
            </code>
            <valueQuantity>
              <value value="182"/>
              <units value="mg/dL"/>
              <system value="http://unitsofmeasure.org"/>
              <code value="mg/dL"/>
            </valueQuantity>
            <interpretation>
              <coding>
                <system value="http://hl7.org/fhir/v2/0078"/>
                <code value="N"/>
                <display value="normal"/>
              </coding>
            </interpretation>
            <issued value="2002-02-15T07:30:00-04:00"/>
            <status value="final"/> 
            <reliability value="ok"/> 
            <subject>
              <reference value="Patient/555-44-4444"/>
              <display value="Eve E. Everywoman"/>
            </subject>
            <performer>
              <reference value="Practitioner/444-44-4444"/>
              <display value="Harold H. Hippocrates"/>
            </performer>
            <referenceRange>
              <low>
                <value value="70"/>
                <units value="mg/dL"/>
                <system value="http://unitsofmeasure.org"/>
                <code value="mg/dL"/>
              </low>
              <high>
                <value value="105"/>
                <units value="mg/dL"/>
                <system value="http://unitsofmeasure.org"/>
                <code value="mg/dL"/>
              </high>
            </referenceRange>
          </Observation>

        </contained>
        <name>
          <coding>
            <system value="http://loinc.org"/>
            <code value="1554-5"/>
            <display value="GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN"/>
          </coding>
          <text value="Glucose Post 12H"/>
        </name>
        <status value="final"/><!--   all this report is final   -->
        <issued value="2002-02-15T07:30:00-04:00"/>
        <subject>
          <reference value="Patient/555-44-4444"/>
          <display value="Eve E. Everywoman"/>
        </subject>
        <performer>
          <reference value="Practitioner/444-44-4444"/>
          <display value="Harold H. Hippocrates"/>
        </performer>
        <identifier>
          <system value="http://ghh.org/lab/reports"/>
          <value value="1045813"/>
        </identifier>
        <requestDetail>
          <reference value="DiagnosticOrder/845439"/> <!-- Placer order number -->
        </requestDetail>
        <diagnosticDateTime value="2002-02-15T07:30:00-04:00"/>
        <!--   now the atomic results   -->
        <result>
          <reference value="#observation-1"/>
        </result>
      </DiagnosticReport>
    </resource>
  </entry>  
 

2.2.3 The FHIR Message - Reference to the order

The DiagnosticReport resource references the DiagnosticOrder resource, which contains the placer order number, the ordering party as well as the ordered service (LOINC 1554-5).
  <entry>
    <resource>
      <DiagnosticOrder>
        <id value="845439"/>
        <subject>
          <reference value="Patient/555-44-4444"/>
          <display value="Eve E. Everywoman"/>
        </subject>
        <orderer>
          <reference value="Practitioner/555-55-5555"/>
          <display value="Patricia Primary MD"/>
        </orderer>
        <identifier>
          <system value="http://ghh.org/oe/placerorder"/>
          <value value="845439"/>
        </identifier>
        <status value="completed"/>
        <event>
          <status value="completed"/>
          <dateTime value="2002-02-15T07:30:00"/>
        </event>
        <item>
          <code>
            <coding>
              <system value="http://loinc.org"/>
              <code value="1554-5"/>
              <display value="GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN"/>
            </coding>
          </code>
          <status value="completed"/>
        </item>
      </DiagnosticOrder>
    </resource>
  </entry>  

2.2.4 The FHIR Message - Patient

The patient resource contains the demographic details of the patient.
  <entry>
    <resource>
      <Patient>
        <id value="555-44-4444"/>
        <extension url="http://ihe.net/ITI-78/Profile/pdqm#mothersMaidenName">
          <valueHumanName>
            <family value="Jones"/>
          </valueHumanName>
        </extension>
        <identifier>
          <use value="official"/>
          <system value="http://ghh.org/patient"/>
          <value value="555-44-4444"/>
        </identifier>
        <identifier>
          <use value="official"/>
          <system value="http://www.ohio.gov/dmv/driverslicence"/>
          <value value="67-A4335"/>
          <period>
            <end value="2003-05-20"/>
          </period>
        </identifier>
        <name>
          <use value="official"/>
          <family value="Everywoman"/>
          <given value="Eve E."/>
        </name>
        <telecom>
          <system value="phone"/>
          <value value="(206)3345232"/>
          <use value="home"/>
        </telecom>
        <telecom>
          <system value="phone"/>
          <value value="(206)752-121"/>
          <use value="work"/>
        </telecom>
        <gender value="female"/>
        <birthDate value="1962-03-20"/>
        <address>
          <line value="153 Fernwood Dr."/>
          <city value="Statesville"/>
          <state value="OH"/>
          <postalCode value="35292"/>
        </address>
        <managingOrganization>
          <reference value="Organization/GHH"/>
          <display value="Good Health Hospital"/>
        </managingOrganization>
        <active value="true"/>
      </Patient>
    </resource>
  </entry>

2.2.5 The FHIR Message - Other persons, organizations

These resources act as 'leaf nodes' (they are referenced, but don't reference any other resources): the GHH hospital, the GHH-LAB department, Patricia Primary and Howard Hippocrates (both healthcare providers).
  <entry>
    <resource>
      <Organization> 
        <id value="GHH"/>
        <identifier>
          <!-- Identifier for the GHH hospital -->
          <use value="official"/>
          <system value="http://ghh.org/department"/>
          <value value="GHH"/>
        </identifier>
        <name value="Good Health Hospital"/>
        <type>
          <!-- GHH is a Hospital -->
          <coding>
            <system value="http://snomed.info/sct"/>
            <code value="22232009"/>
            <display value="Hospital"/>
          </coding>
        </type>
        <active value="true"/>
      </Organization>
    </resource>
  </entry>

  <entry>
    <resource>
      <Organization>
        <id value="GHH-LAB"/>
        <identifier>
          <!-- Identifier for the GHH Laboratory -->
          <use value="official"/>
          <system value="http://ghh.org/department"/>
          <value value="GHH LAB"/>
        </identifier>
        <name value="Laboratory of the Good Health Hospital"/>
        <type>
          <!-- GHH Lab is a Laboratory within the GHH Hospital -->
          <coding>
            <system value="http://snomed.info/sct"/>
            <code value="73588009"/>
            <display value="Hospital-based laboratory facility"/>
          </coding>
        </type>
        <active value="true"/>
      </Organization>
    </resource>
  </entry>

  <entry>
    <resource>
      <Practitioner>
        <id value="555-55-5555"/>
        <!-- 555-55-5555^PRIMARY^PATRICIA P^^^^MD^^ -->
        <identifier>
          <use value="official"/>
          <system value="http://ghh.org/practitioner"/>
          <value value="555-55-5555"/>
        </identifier>
        <name>
          <use value="official"/>
          <family value="Patricia"/>
          <given value="Primary"/>
          <suffix value="MD"/>
        </name>
      </Practitioner>
    </resource>
  </entry>

  <entry>
    <resource>
      <Practitioner>
        <id value="444-44-4444"/>
        <!-- 444-44-4444^HIPPOCRATES^HOWARD H^^^^MD -->
        <identifier>
          <use value="official"/>
          <system value="http://ghh.org/practitioner"/>
          <value value="444-44-4444"/>
        </identifier>
        <name>
          <use value="official"/>
          <family value="Hippocrates"/>
          <given value="Howard H"/>
          <suffix value="MD"/>
        </name>
        <practitionerRole>
          <managingOrganization>
            <reference value="Organization/GHH-LAB"/>
            <display value="GHH Laboratory"/>
          </managingOrganization>
        </practitionerRole>
      </Practitioner>
    </resource>
  </entry>

3. FHIR Server - REST API

The second scenario is based on a FHIR server that only supports a REST API (i.e. it doesn't support messaging). The use case is the completion of a serum glucose laboratory result of 182 mg/dL authored by Howard H. Hippocrates. The laboratory test was ordered by Patricia Primary for patient Eve E. Everywoman. The use case takes place in the US Realm. See section 2.1 for the details of the HL7 v2 message.

3.1 FHIR resources

The content of the HL7v2 message is expressed as a set of FHIR resources and their references. The overall structure is depicted below.

FHIR resource references

The DiagnosticReport resource (the equivalent of ORC/OBR) references the DiagnosticOrder (with details such as the Lab test being ordered, the order filler number and the ordering person) and has a 0..* relationship with the Observation resource (the equivalent of OBX). The Patient, Practitioners and organizations are represented as individual resources, representing the 'leaf-nodes' in the overall model. The Provenance resource links to all other resources shown in the diagram.

3.2 About Logical IDs

All resources available on any FHIR server have a Resource.id (a logical identifier), to identify the resource in the context of that particular FHIR server.

In principle the Id of a resource is assigned by the FHIR server at the time of its creation. Once assigned, the identity is never changed, though copies of the same resource made elsewhere may not retain the same identity.

FHIR re-identification process
Figure showing the FHIR bundle as submited by a client on the left, and the resulting re-identified resources on the right.

The above example shows the re-identification process for newly submitted resources.

  • The bundle (containing two new resources) on the left is submitted to a FHIR server. The logical Ids are based on the business identifier, which is probably the easiest mechanism when processing HL7v2 segments. The Resource.Id values (shown as fully qualified URLs, they could have been relative URLs as well, e.g. /Patient/1) are assigned in the context of the sending application. Encounter/5 has a reference to Patient/1.
  • Upon receipt the FHIR server will assign its own unique Ids to the newly created resources. The references are also re-identified, Encounter/ef833 references Patient/eb17. (see last section of the FHIR Transactions specification for details).

Note that the Business Identifier (Resource.Identifier) hasn't changed.

In order to get hold of the details of the patient with business identifier 1 (i.e. PV1-3 = 1) we have to use the following query:

 GET http://fhirserver.net/Patient?identifier=http://ghh.org/patient|1
.. which would return Patient/ab17 (assuming there's only one Patient resource that has business identifier http://ghh.org/patient|1, if there were to be multiple such Patient resources they would all be returned) .

Updating a resource can also be based on its business identifier using the conditional update feature of FHIR.

 PUT http://fhirserver.net/Patient?identifier=http://ghh.org/patient|1
.. which would update resource Patient/ab17 (if that was the sole resource that matches the http://ghh.org/patient|1 business identifier. Should there be multiple matches an error will be returned).

Alternatively the client (ghh.org in our example) could maintain a database table showing the relationship between the business identifiers and the FHIR Server URL, in which case the client could directly use the following URL to update the resource:

 PUT http://fhirserver.net/Patient/ab17

Please note that there are some FHIR servers that will allow a client to specify the Resource.Id as it is to be used by the FHIR server upon creation of a new resource. Using our example above, http://ghh.org/Patient/1 would be stored as http://fhirserver.net/Patient/1 - retaining the same relative URL (Patient/1). In general one shouldn't expect such behaviour, and instead rely on the business identifier to identify a resource.

3.3 Processing rules

A special set of processing rules will apply in this scenario:
  1. We'd like to avoid using contained resources - which means we need some special handling of the observation resource (OBX) which doesn't have a unique identifier in the HL7v2 message.
  2. The provenance resource is used to identify the fact that resources were taken from a messaging context.
  3. Given that the Lab system doesn't consider itself to be the 'master source' of practitioners, organizations or patients, those resources will only be created should there be no existing resources that match the business identifier as used by the Lab system. Should there be a single matching resource, then that existing resource will be referenced, no attempt will be made to update these resource types.

3.3.1 Observation.identifier

Ideally all resources are 'identified' so they can be queried/used by all applications. However, one can't always uniquely identify an OBX segment (this is why we used a contained resource in the FHIR Message as discussed in section 2.2.2). We'd like to avoid using contained resources they mess up the RESTful way of retreiving data from a FHIR server. There are a number of options to uniquely identify an OBX segment:
  • The field OBX-21 (if populated) acts as a unique identifier. This field was introduced in HL7 v2.7 (?) and hasn't been implemented by most Laboratory systems. However, if it is supported this is the functional equivalent of Observation.identifier.
  • In some implementations the concatenation of OBR-4 + OBX-3 + OBX-4 should be unique and reliable, but whether this can be used or not requires system and site specific analysis.
  • One can make use of the 'snapshot' nature of HL7v2 as a kind of 'implicit identifier'. HL7v2 messages are based on the transfer of a 'snapshot'. The full set of OBXs associated with paricular OBR is sent in each and every message which contains the OBR. Assuming a scenario where a preliminary result (message1) is replaced at a later point in time by a final result (message2), one could perform the following actions when processing message2:
    1. use the value of message2.OBR-4 (filler order number) to fetch the corresponding DiagnosticReport resource from the server (which already exists, it was created as a result of message1).
    2. delete all Observation resources that are referenced in the DiagnosticReport resource
    3. update DiagnosticReport based on the message2.OBR segment
    4. create a new Observation resource for each OBX segment, assigning unique observation.identifier values, e.g. GUIDs.

In this whitepaper we'll use the "snapshot" method. First we get hold of a bundle of observations included in a particular DiagnosticReport:

 GET http://fhirserver.net/DiagnosticReport?identifier=http://ghh.org/lab/reports|1045813&_include=DiagnosticReport:result 
This returns one single Observation resource (Observation/11327773-2397-495f-9449-cbb8dbaa1eeb) - a resource related to the old snapshot (from a prior ORU message), so we'll have to delete it. We'll use the data in the OBX segment of our example HL7v2 ORU message to create a new Observation resource (representing the new snapshot).
        <Observation>
            <id value="94c1b108-b329-42ce-b792-c7de9f1fb264"/>
            <text>
                <status value="generated"/>
                <div xmlns="http://www.w3.org/1999/xhtml">
                  Observation on 2002-02-15 by H. Hippocrates, for Patient E. Everywoman:<br/> 
                  Glucose Post 12h      182 mg/dL   N  (70-105)
                </div>
            </text>
            <code>
              <coding>
                <system value="http://loinc.org"/>
                <code value="1554-5"/>
                <display value="GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN"/>
              </coding>
            </code>
            <valueQuantity>
              <value value="182"/>
              <units value="mg/dL"/>
              <system value="http://unitsofmeasure.org"/>
              <code value="mg/dL"/>
            </valueQuantity>
            <interpretation>
              <coding>
                <system value="http://hl7.org/fhir/v2/0078"/>
                <code value="N"/>
                <display value="normal"/>
              </coding>
            </interpretation>
            <issued value="2002-02-15T07:30:00-04:00"/>
            <status value="final"/> 
            <reliability value="ok"/> 
            <identifier>
              <use value="temp"/>
              <system value="http://ghh.org/lab/observation"/>
              <value value="94c1b108-b329-42ce-b792-c7de9f1fb264"/>
            </identifier>
            <subject>
              <reference value="Patient/555-44-4444"/>
              <display value="Eve E. Everywoman"/>
            </subject>
            <performer>
              <reference value="Practitioner/444-44-4444"/>
              <display value="Harold H. Hippocrates"/>
            </performer>
            <referenceRange>
              <low>
                <value value="70"/>
                <units value="mg/dL"/>
                <system value="http://unitsofmeasure.org"/>
                <code value="mg/dL"/>
              </low>
              <high>
                <value value="105"/>
                <units value="mg/dL"/>
                <system value="http://unitsofmeasure.org"/>
                <code value="mg/dL"/>
              </high>
            </referenceRange>
          </Observation>
We'll also have to update the DiagnosticReport with data from the OBR segment, and it should now reference the new Observation resource:
<entry>
    <resource>
      <DiagnosticReport>
        <id value="1045813"/> <!-- Filler Order Number -->
        <text>
            <status value="generated"/>
            <div xmlns="http://www.w3.org/1999/xhtml">
              Final results on 2002-02-15 by H. Hippocrates, for Patient E. Everywoman:<br/> 
              Glucose Post 12h      182 mg/dL       (70-105)
            </div>
        </text>
        <name>
          <coding>
            <system value="http://loinc.org"/>
            <code value="1554-5"/>
            <display value="GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN"/>
          </coding>
          <text value="Glucose Post 12H"/>
        </name>
        <status value="final"/><!--   all this report is final   -->
        <issued value="2002-02-15T07:30:00-04:00"/>
        <subject>
          <reference value="Patient/555-44-4444"/>
          <display value="Eve E. Everywoman"/>
        </subject>
        <performer>
          <reference value="Practitioner/444-44-4444"/>
          <display value="Harold H. Hippocrates"/>
        </performer>
        <identifier>
          <system value="http://ghh.org/lab/reports"/>
          <value value="1045813"/>
        </identifier>
        <requestDetail>
          <reference value="DiagnosticOrder/845439"/> <!-- Placer order number -->
        </requestDetail>
        <diagnosticDateTime value="2002-02-15T07:30:00-04:00"/>
        <!--   now the atomic results   -->
        <result>
          <reference value="Observation/94c1b108-b329-42ce-b792-c7de9f1fb264"/>
        </result>
      </DiagnosticReport>
    </resource>
  </entry>  
 

3.3.2 Use of the provenance resource

Extracting partial information from a HL7v2 message, breaking it up into resources, and using them as independent information units, may have (clinical safety) risks associated with it. We'll somehow have to persist the information that certain resources were derived from a HL7 v2 message. (See this blogpost about another use-case where one would have to do this).

The Provenance resource is the most generic mechanism in FHIR to capture provenance data. (Note: the MessageHeader resource only contains partial provenance information).

The provenance resource (shown below) contains the following information:

  • A list of resources that the provenance resource is associated with (a Practitioner, DiagnosticOrder, DiagnosticReport, Observation)
  • The author of the content of those resources (GHH-LAB, modeled as an 'author'agent)
  • The performer of the transformation process from HL7v2 to FHIR (TransformationAgent v.123, modeled as a 'performer' agent)
  • The message type and identity of the original HL7v2 message (modeled as an entity derivation)
<Provenance>
  <id value="fafac90e-22a1-46e0-afb5-3fd7489df062"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml">Authored on 15-Feb 2002 by GHH Laboratory. 
      Transformed by TransformationAgent v.123 from the original GHH-LAB HL7v2 message with ControlID CNTRL-3456.</div>
  </text>
  <target>
    <!-- unversioned, part of a transaction -->
    <reference value="DiagnosticReport/1045813"/>
  </target>
 <target>
    <!-- unversioned, part of a transaction -->
    <reference value="DiagnosticOrder/845439"/>
  </target>
 <target>
    <!-- unversioned, part of a transaction -->
    <reference value="Observation/94c1b108-b329-42ce-b792-c7de9f1fb264"/>
  </target>
  <recorded value="2002-02-15T09:30:00-04:00"/>
  <reason>
    <text value="Transformation of a HL7v2 ORU^R01 message"/>
  </reason>
  <agent>
    <role>
      <system value="http://hl7.org/fhir/provenance-participant-role"/>
      <code value="author"/>
    </role>
    <type>
      <system value="http://hl7.org/fhir/provenance-participant-type"/>
      <code value="organization"/>
    </type>
    <referenceReference>
      <reference value="Organization/GHH-LAB"/>
      <display value="GHH Laboratory"/>
    </referenceReference>
    <display value="GHH Lab"/>
  </agent>
  <agent>
    <role>
      <system value="http://hl7.org/fhir/provenance-participant-role"/>
      <code value="performer"/>
    </role>
    <type>
      <system value="http://hl7.org/fhir/provenance-participant-type"/>
      <code value="software"/>
    </type>
    <referenceUri value="http://www.transformationagent.com/version123"/>
    <display value="TransformationAgent v.123"/>
  </agent>
  <entity>
    <role value="derivation"/>
    <type>
      <system value="http://hl7.org/version2/trigger-event"/>
      <code value="ORU^R01"/>
    </type>
    <!-- URI for the orginal v2 message, entity that is the source of the derivation -->
    <reference value="urn:version2-message:GHH-LAB:CNTRL-3456"/>
    <display>GHH-LAB HL7v2 message with ControlID CNTRL-3456</display>
    <!-- link to the agent that performed the derivation -->
    <agent>
      <role>
        <system value="http://hl7.org/fhir/provenance-participant-role"/>
        <code value="performer"/>
      </role>
      <type>
        <system value="http://hl7.org/fhir/provenance-participant-type"/>
        <code value="software"/>
      </type>
      <referenceUri value="http://www.transformationagent.com/version123"/>
      <display value="TransformationAgent v.123"/>
    </agent>
  </entity>
</Provenance>

The provenance resource would allow for queries such as:

 GET http://fhirserver.net/Provenance?entity=urn:version2-message:GHH-LAB:CNTRL-3456&_include=Provenance:target
.. which returns all resources derived from the HL7v2 message with the specified URI (which includes originator and ControlID).

 GET http://fhirserver.net/Provenance?party=Organization/GHH-LAB&start=>=2002-02-01&end=<=2002-02-28
.. which returns all provenance resources related to message content created by GHH-LAB in february of 2002.

The FHIR Specifaction, section 6.5.4.2 states the following with regard to the use of the Povenance resource: on a RESTful system, the target resource reference [i.e. Provenance.target] should be version specific, but this requires special care: For new resources that need to have a corresponding Provenance resource, the version-specific reference is often not knowable until after the target resource has been updated. This can create an integrity problem for the system - what if the provenance resource cannot be created after the target resource has been updated? To avoid any such integrity problems, the target resource and the provenance resources should be submitted as a pair using a transaction.

Therefore we'll need to use a transaction bundle to send the Provenance resource as well as the resources derived from the HL7v2 message.

3.3.3 Updating the DiagnosticOrder resource

In the context of our HL7v2-message to FHIR use case we have to assume that prior to the ORU message (shown in section 2.1) the contents of the prior HL7v2 order message (ORM) were already processed. As such the DiagnosticOrder resource already exists, we'll just have to update it, mainly to change its status to "completed".

Given the update semantics of HL7 v2 segments (where SEG|1|||E updated by SEG||5||E in a subsequent message effectively would lead to the receiver storing SEG|1|5||E) we would have to fetch the current DiagnosticOrder, and update it with data as available in the OBR segment of the v2 ORU message.

      <DiagnosticOrder>
        <id value="845439"/>
        <text>
          <status value="generated"/>
          <div xmlns="http://www.w3.org/1999/xhtml">Glucose post 12h order for Eve Everywoman, completed on 2002-02-15T07:30:00.</div>
        </text>
        <subject>
          <reference value="Patient/555-44-4444"/>
          <display value="Eve E. Everywoman"/>
        </subject>
        <orderer>
          <reference value="Practitioner/555-55-5555"/>
          <display value="Patricia Primary MD"/>
        </orderer>
        <identifier>
          <system value="http://ghh.org/oe/placerorder"/>
          <value value="845439"/>
        </identifier>
        <status value="completed"/>
        <event>
          <status value="completed"/>
          <dateTime value="2002-02-15T07:30:00"/>
        </event>
        <item>
          <code>
            <coding>
              <system value="http://loinc.org"/>
              <code value="1554-5"/>
              <display value="GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN"/>
            </coding>
          </code>
          <status value="completed"/>
        </item>
      </DiagnosticOrder>

3.3.4 Generating human readable content

Given that the HL7 version 2 message doesn't have human readable content (Lab results could have human readable content in the form of NTE segments) we'll have to create a human readable version of the content of each resource. The mapping in section 2 (from v2 message to FHIR message) doesn't populate Resource.text - it is unlikely to be of importance in the context of the message event processing.

The mapping in this section (v2 message to REST resources) allows for the reuse of resources in all kinds of contexts. Therefore we SHOULD populate Resource.text for those use cases where a set of resources will be displayed to a human reader.

3.4 FHIR Transaction

As noted before the Lab system doesn't consider itself to be the 'master source' of practitioners, organizations or patients. Should there already be existing resources of these types the Lab doesn't wish to update them with potentially less rich/reliable data.
  • This kind of functionality is supported in the form of a conditional create. If the resource already exists, don't don't do anything. If it doesn't exist, create it. This is applicable when it comes to Patient, Practitioner and Department resources.
The Lab system does consider itself to be an authoritive source when it comes to DiagnosticReport, DiagnosticOrder, Observation and Provenance resources. Some of those may not yet exist on the server (so the should be created), others may already exist (and may need an udpate transaction).
  • This kind of functionality is supported in the form of a conditional update. If the resource exists, update it. If it doesn't exist, create it.

FHIR resource references

The FHIR Transaction therefore consists of:

  • Create - Provenance
    POST http://fhirserver.net
  • Create - Observation (new snapshot, see section 3.3.1)
    POST http://fhirserver.net
  • Delete - Observation (old snapshot, see section 3.3.1)
    DELETE http://fhirserver.net/Observation/11327773-2397-495f-9449-cbb8dbaa1eeb
  • Conditional Update - DiagnosticReport
    PUT http://fhirserver.net/DiagnosticReport/?identifier=http://ghh.org/lab/reports|1045813
  • Conditional Update - DiagnosticOrder
    PUT http://fhirserver.net/DiagnosticOrder/?identifier=http://ghh.org/oe/placerorder|845439
  • Conditional create - Practitioner
    POST http://fhirserver.net, with Bundle.entry.transaction.ifNoneExist set to "identifier=http://ghh.org/practitioner|555-55-5555"
  • Conditional create - Practitioner
    POST http://fhirserver.net, with Bundle.entry.transaction.ifNoneExist set to "identifier=http://ghh.org/practitioner|444-44-4444"
  • Conditional create - Organization
    POST http://fhirserver.net, with Bundle.entry.transaction.ifNoneExist set to "identifier=http://ghh.org/department|GHH"
  • Conditional create - Organization
    POST http://fhirserver.net, with Bundle.entry.transaction.ifNoneExist set to "identifier=http://ghh.org/department|GHH%20LAB"
  • Conditional create - Patient
    POST http://fhirserver.net, with Bundle.entry.transaction.ifNoneExist set to "identifier=http://ghh.org/patient|555-44-4444"

3.5 Summary

In general one should map a HL7v2 message to a FHIR transaction, using 'conditional updates' for resources that correspond with those parts of the HL7v2 message that the sender considers itself to be the (co-)owner of, and using 'conditional create' for those resources that correspond with those parts of the HL7v2 message that the sender considers itself NOT to be an owner of.

The use of the Provenance resource is desirable to have a record that the resources were created/updated based on information from a HL7v2 message. Note that one SHOULD NOT include a reference from the Provenance resource to any resources created using a 'conditional create' within the same transaction - those resources may already exist, leading to a false provenance statement.

The snapshot nature of H7v2 ORU messages leads to a requirement to delete resources for which we neither know the Id nor the Identifier (we only know they are referenced by some other resource, or that they reference some other resource themselves), which means we'll have to use a GET to get hold of the Ids prior to executing the transaction. It would be desirable to include this kind of deletion within the transaction; FHIR currently doesn't support this kind of DELETE however.


About Ringholm bv

Ringholm bv is a group of European experts in the field of messaging standards and systems integration in healthcare IT. We provide the industry's most advanced training courses and consulting on healthcare information exchange standards.
See http://www.ringholm.com or call +31 33 7 630 636 for additional information.