Operational FHIR Encounter plus Patient and ITK HL7v2

(Kev Mayfield) #1

On UK systems Encounter management is mainly done using HL7v2. An example is shown below

MSH|^~&|PatientCentre|RR8|ROUTE|ROUTE|20190429115837||ADT^A08|lt190429105838455588|T|2.4||||||ASCII|EN
EVN|A01|20190429115837||AD02
PID|||000031920^^^RR8^PI~0031740^^^RR8^MR|GH5236^^^RR8^AN|TEST^LYNNEA^^^^^L||20030501|2|||^^^^^^^^|||||U^^NHS|U^UNKNOWN^RR8|||||99^^NHS||||||||0||3
PV1||I|ZZZ^^^RR813|21||^^^^^^^^|||PHS^^^^^^^^RR8~C0735492^^^^^^^^NHS|101^^^^^^^^NHS||||19|||||000000001^^^RR8^VN|||||||||||||||||||||||||201904291157||||||000520726^^^RR8^VN
PV2||||||||||000||~|xxx||||||||||||||||||||
ZU1||1|||||||||||^^^|||||||||||
ZU5||10^NHS - NOT DETAINED^RR8

It may be an old standard but it still does the job. The equivalent in FHIR is FHIR Messaging and is similar to the DCH event messages mentioned in a previous post Operational FHIR Encounter example

By rearranging the DCH message we have the following core structure, the first three letters on each line are the segment type

  • MessageHeader
  • Encounter
  • Patient

This structure is also in the HL7v2 message above

  • MSH Message Header
  • EVN Event Header
  • PID Patient Information
  • PV1 Patient visit
  • PV2 Patient visit continued

We can now see a rough map between HL7 v2 and FHIR, PID is Patient, PV1 and PV2 is Encounter, etc.

Encounter / PV1

I’m just going to on building on from this post Operational FHIR Encounter example and start adding other elements. Looking at the PV1.2 segment, the type is I which stands for inpatient (for a breakdown of the PV1 segment use HL7 PV1 (Patient Visit Information) Segment - Corepoint Health or download the ITK HL7v2 specification from TRUD)

PV1||I|ZZZ^^^RR813|21||^^^^^^^^|||PHS^^^^^^^^RR8~C0735492^^^^^^^^NHS|101^^^^^^^^NHS||||19|||||000000001^^^RR8^VN|||||||||||||||||||||||||201904291157||||||000520726^^^RR8^VN

This gives in FHIR

<class>
    <system value="http://hl7.org/fhir/v3/ActCode"/>
    <code value="IMP"/>
    <display value="inpatient encounter"/>
</class>

Next we will add extract the type which is located at PV1.10

PV1||I|ZZZ^^^RR813|21||^^^^^^^^|||PHS^^^^^^^^RR8~C0735492^^^^^^^^NHS|101^^^^^^^^NHS||||19|||||000000001^^^RR8^VN|||||||||||||||||||||||||201904291157||||||000520726^^^RR8^VN

and in FHIR

 <type>
    <coding>
        <system value="https://fhir.nhs.uk/STU3/CodeSystem/DCH-Specialty-1"/>
        <code value="101"/>
        <display value="UROLOGY"/>
    </coding>
</type>

We need a status for the encounter, this is mandatory. The message type in the MSH segment at MSH.9, for Encounter messages, ADT^A01 indicates the patient has arrived, ADT^A03 means the patient has been discharged, ADT^A02 shows a patient transfer and ADT^A08 an amendment. In our example the patient is being admitted, so the status becomes

<status value="arrived"/>

As the patient has arrived we will have a start time for the Encounter and this is located at PV1.44

PV1||I|ZZZ^^^RR813|21||^^^^^^^^|||PHS^^^^^^^^RR8~C0735492^^^^^^^^NHS|101^^^^^^^^NHS||||19|||||000000001^^^RR8^VN|||||||||||||||||||||||||201904291157||||||000520726^^^RR8^VN

<period>
    <start value="2019-04-29T11:57:00.000+01:00"/>
</period>

We also have a practitioner which is located at PV1.17

PV1||I|ZZZ^^^RR813|21||^^^^^^^^|||PHS^^^^^^^^RR8~C0735492^^^^^^^^NHS|101^^^^^^^^NHS||||19|||||000000001^^^RR8^VN|||||||||||||||||||||||||201904291157||||||000520726^^^RR8^VN

I’m going to ignore the PHS code and just concentrate on the SDS/ODS code for the Practitioner. In the last post we had a discussion about using identifier references but here we have no choice, we only know the consultant by their code, so this gives (I’ve set a participation type but this is optional):

<participant>
    <type>
        <coding>
            <system value="http://hl7.org/fhir/v3/ParticipationType"/>
            <code value="PART"/>
        </coding>
    </type>
    <individual>
        <identifier>
            <system value="https://fhir.nhs.uk/Id/sds-user-id"/>
            <value value="C0735492"/>
        </identifier>
    </individual>
</participant>

Note: I’m doing a quick conversion at the moment, it may be desirable to use a full reference and include Practitioner in the message Bundle.

Identifiers

HL7v2 normally carries two:

PV1.19 Visit Number
PV1.50 Alternate Visit Number.

PV1||I|ZZZ^^^RR813|21||^^^^^^^^|||PHS^^^^^^^^RR8~C0735492^^^^^^^^NHS|101^^^^^^^^NHS||||19|||||000000001^^^RR8^VN|||||||||||||||||||||||||201904291157||||||000520726^^^RR8^VN

For this LeedsTH we can ignore the second number but as we want a unique identifier for our Encounters (000000001 in unlikely to be unique) we concatenate this with the internal patient number taken from the PID segment.

PID|||000031920^^^RR8^PI~0031740^^^RR8^MR|GH5236^^^RR8^AN|TEST^LYNNEA^^^^^L||20030501|2|||^^^^^^^^|||||U^^NHS|U^UNKNOWN^RR8|||||99^^NHS||||||||0||3

Giving a encounter number of 000031920-000000001 for the system value we have chosen to use
https://fhir.leedsth.nhs.uk/Id/Encounter/episode-number (the use of the term episode may be confusing but this is the name the PAS system uses).

In theory we should also create a NamingSystem to be recorded in a registries to describe and define the url
e.g. Leeds Teaching Trust Episode Number https://fhir.leedsth.nhs.uk/Id/Encounter/episode-number This shows who owns the url and links to other interop systems, we will come back to this.

We also add in a serviceProvider and put a name for the patient giving this Encounter resource

<Encounter>
<id value="12779557-9033-4213-876f-69a670cdf35d"/>
<meta>
    <profile value="https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Encounter-1"/>
</meta>
  <identifier>
            <system value="https://fhir.leedsth.nhs.uk/Id/Encounter/episode-number"/>
            <value value="000031920-000000001"/>
        </identifier>
<status value="arrived"/>
<class>
    <system value="http://hl7.org/fhir/v3/ActCode"/>
    <code value="IMP"/>
    <display value="inpatient encounter"/>
</class>
<type>
    <coding>
        <system value="https://fhir.nhs.uk/STU3/CodeSystem/DCH-Specialty-1"/>
        <code value="101"/>
        <display value="UROLOGY"/>
    </coding>
</type>
<subject>
    <reference value="urn:uuid: TODO "/>
    <display value="TEST, LYNNEA"/>
</subject>
<participant>
    <type>
        <coding>
            <system value="http://hl7.org/fhir/v3/ParticipationType"/>
            <code value="PART"/>
        </coding>
    </type>
    <individual>
        <identifier>
            <system value="https://fhir.nhs.uk/Id/sds-user-id"/>
            <value value="C0735492"/>
        </identifier>
    </individual>
</participant>
<period>
    <start value="2019-04-29T11:57:00.000+01:00"/>
</period>
<location>
    <location>
        <reference value="urn:uuid:e3177167-40fc-4f1a-80f2-a2f17f18fde7"/>
        <display value="ACCIDENT &amp; EMERGENCY LGI"/>
    </location>
</location>
<serviceProvider>
    <identifier>
        <system value="https://fhir.nhs.uk/Id/ods-organization-code"/>
        <value value="RR8"/>
    </identifier>
    <display value="LEEDS TEACHING HOSPITALS NHS TRUST"/>
</serviceProvider>
</Encounter>

Patient/PID

Patient demographics will be supplied on the PID and PD1 (if present) segment. Taking the identifiers first, we don’t have a NHS number so that can’t be included but we do have a LeedsTH PAS Number and Internal Patient number.

PID|||000031920^^^RR8^PI~0031740^^^RR8^MR|GH5236^^^RR8^AN|TEST^LYNNEA^^^^^L||20030501|2|||^^^^^^^^|||||U^^NHS|U^UNKNOWN^RR8|||||99^^NHS||||||||0||3

This gives:

 <identifier>
    <system value="https://fhir.leedsth.nhs.uk/Id/internal-patient-number"/>
    <value value="000031920"/>
</identifier>
<identifier>
    <system value="https://fhir.leedsth.nhs.uk/Id/pas-number"/>
    <value value="0031740"/>
</identifier>

As with the LeedsTH Encounter identifiers I’ve also created NamingSystems but this time they have entries for HL7 v2 and FHIR e.g. for PAS Number we have:

<NamingSystem xmlns="http://hl7.org/fhir">
<id value="470"/>
<name value="LTHT PAS Number"/>
<status value="active"/>
<kind value="identifier"/>
<date value="2019-04-11T11:00:01+00:00"/>
<publisher value="Leeds Teaching Hospitals NHS Trust"/>
<description value="Known within the trust as the PAS Number, also known as District Number"/>
<uniqueId>
    <type value="other"/>
    <value value="RR8-MR"/>
</uniqueId>
<uniqueId>
    <type value="uri"/>
    <value value="https://fhir.leedsth.nhs.uk/Id/pas-number"/>
    <preferred value="true"/>
</uniqueId>
</NamingSystem>

The CCRI Server renders this a little better FHIR Explorer

The name and date of birth is straight forward.

 <name>
    <use value="official"/>
    <family value="Test"/>
    <given value="Lynnea"/>
</name>
<birthDate value="2003-05-01"/>

The gender value 2 needs to be converted to a value in this valueSet https://fhir.hl7.org.uk/STU3/ValueSet/CareConnect-AdministrativeGender-1 If you follow the link you will see it has an embedded ConceptMap which shows 2 = female.

<gender value="female"/>

Like before we add in the profile in the meta section giving:

<Patient xmlns="http://hl7.org/fhir">
<meta>
    <lastUpdated value="2019-04-29T13:50:47.181+00:00"/>
    <profile value="https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Patient-1"/>
</meta>
<identifier>
    <system value="https://fhir.leedsth.nhs.uk/Id/pas-number"/>
    <value value="0031740"/>
</identifier>
<identifier>
    <system value="https://fhir.leedsth.nhs.uk/Id/internal-patient-number"/>
    <value value="000031920"/>
</identifier>
<name>
    <use value="official"/>
    <family value="Test"/>
    <given value="Lynnea"/>
</name>
<gender value="female"/>
<birthDate value="2003-05-01"/>
</Patient>

Pasting this example into the CCRI validation tool shows no errors. As a final test you may wish to POST this resource to the CCRI (set the ContentType header to and POST the resource to https://data.developer.nhs.uk/ccri-fhir/STU3/Patient)

You could also try POST the Encounter resource, however the server uses FHIR RESTful and doesn’t know how to process the identifier references.

We’ve only scratched the surface on converting from v2 to FHIR, we’ve not covered the MessageHeader or how to deal additional data not covered by the Care Connect FHIR profiles (extensions).

FHIR ADT^A01, MessageDefinition and GraphDefinition