Operational FHIR Encounter example

Problem

In the hospital I’m working at we are looking towards implementing a notification use case for the regional LHCR. Roughly it is:

When patient X presents at an emergency department notify their surgery/GP of the event.

Solution Walkthrough

Pretty straight forward. Traditionally we would have been able to do this in the trust integration engine (TIE), probably intercepting HL7v2 messages from the ED or PAS systems and then sending them onto the GP (it works for some GP suppliers).

Getting a bit more technical now but as most systems follow the NHS Data Dictionary lets apply that to the use case: /

When a patient admitted to Accident and Emergency (Data dictionary code = 180) Encounter, then notify their surgery/GP of the event.

We actually have enough information to start coding this. In HL7v2 we would probably look at intercepting ADT^A01 messages for encounters for with 180 specialty and look at the PID segment to see which practice/GP the patient is with.

We can take a similar approach In FHIR Messaging, I’m not going to go into detail on messaging but the payload would be very similar to Digital Child Health Emergency Care Attendance This approach is correct but we would want something more generic rather than something domain specific. I’m going to use the DCH example and just concentrate on the Encounter resource.

First I’m going to remove elements not likely to be present on a typical PAS/ED system and move the profile over to a the CareConnect Encounter profile.

<Encounter>
<id value="12779557-9033-4213-876f-69a670cdf35d"/>
<meta>
    <profile value="https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Encounter-1"/>
</meta>
<status value="finished"/>
<subject>
    <reference value="urn:uuid:5d5845f3-398f-474b-af59-14882fc7b0ca"/>
    <display value="DAWKINS, Jack"/>
</subject>
<period>
    <start value="2018-03-23"/>
    <end value="2018-03-23"/>
</period>
<location>
    <location>
        <reference value="urn:uuid:e3177167-40fc-4f1a-80f2-a2f17f18fde7"/>
        <display value="ACCIDENT &amp; EMERGENCY LGI"/>
    </location>
</location>
<serviceProvider>
    <reference value="urn:uuid:5a293df7-b22f-41b6-8bf1-44248ea59edb"/>
    <display value="UNIVERSITY HOSPITAL OF NORTH DURHAM"/>
</serviceProvider>

If you copy the xml above and send it to a Care Connect FHIR validator it will validate ok.

The change that swapped over the encounter profile was to amend the meta section. This section states the profile to be used is CareConnect-Encounter-1

<meta>
    <profile value="https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Encounter-1"/>
</meta>

The example is missing our specialty and also doesn’t say it’s an Emergency encounter.

In FHIR the Emergency is contained in the Class element, looking at class in the profile we can see the class should be from the ActEncounterCode valueSet (ActEncounterCode - FHIR v3.0.2)
which gives us:

  <class>
           <system value="http://hl7.org/fhir/v3/ActCode"/>
           <code value="EMER"/>
           <display value="emergency"/>
        </class>

The specialty (or TREATMENT_FUNCTION_CODE) is more difficult, looking at the profile it seems the best place for this is type but that is after a SNOMED code from Care Connect Encounter Type valueSet.

What does http://snomed.info/sct constraint Equals <<185316007 OR <<308467007 OR <<185201007 mean???
In plain(er!) English this means any code that is a child of codes 185316007, 308467007 or 185201007

In theory I should be converting to code 180 to a SNOMED but I’m not seeing an obvious candidate (any help here?) but also as English NHS systems expect to use TFC I should include it in the message.

This is a potential issue, the rules on CareConnect Encounter type only allow one code, so although I can add

To do this I need a system equivalent to TREATMENT_FUNCTION_CODE or ITK HL7v2 table 0069 (they are the same codes).
So we are after a FHIR valueSet which contains these codes, DCH has one DCH-Specialty-1. This gives a type of:

 <type>
    <coding>
        <system value="https://fhir.nhs.uk/STU3/CodeSystem/DCH-Specialty-1"/>
        <code value="180"/>
        <display value="ACCIDENT AND EMERGENCY"/>
    </coding>
</type>

Note: although I used a ValueSet for the System I’ve referred to a CodeSystem.

This is correct for STU3 FHIR, if we were using R4 FHIR we would have used Encounter.serviceType instead.

We have an issue here, it is desirable to use our TFC as its use in the NHS (in England) is quite common, ideally we would include both the SNOMED code and the TFC. This is allowed in the base FHIR Encounter profile but the CareConnect-Encounter-1 profile has limited this to one.

Our example validates cleanly but it has a issue with the serviceProvider, according to the spec serviceProvider should reference Organizations but in our DCH Example it actually refers to a HealthcareService (search on the UUID).
I could add in an Organization to bundle and correct the reference, that’s the correct way of building FHIR messages BUT most systems will understand the ODS/SDS codes. Even if they don’t, the ODS API provides a way of looking them up?
So if I have the code for University Hospital of North Durham RX3, I can call the ODS API and get a FHIR Organization (try it https://directory.spineservices.nhs.uk/STU3/Organization/RX3)
It would make more sense to use identifier references, as this provides enough information to perform a lookup. Doing this removes the UUID and our serviceProvider becomes:

 <serviceProvider>
    <identifier>
        <system value="https://fhir.nhs.uk/Id/ods-organization-code"/>
        <value value="RX3"/>
    </identifier>
    <display value="UNIVERSITY HOSPITAL OF NORTH DURHAM"/>
</serviceProvider>

We could do the same with the Location reference but use of SDS/ODS sites codes. We can do a lookup using the ODS API but that returns an Organization https://directory.spineservices.nhs.uk/STU3/Organization/RX3EP
Its also possible the location goes into more depth and cover wards/rooms/sites not covered by SDS/ODS codes. [We have more questions here: should the service provider point to trust (RX3) or hospital (RX3EP), should location point to hospital/wing/ward/room/bed???]

We could also use identifier references for the subject

<subject>
    <identifier>
        <system value="https://fhir.nhs.uk/Id/nhs-number"/>
        <value value="9912003888"/>
    </identifier>
    <display value="DAWKINS, Jack"/>
</subject>

That could be useful but when using identifier references we need to be confident the endpoint can resolve them. Not all trusts have implemented SMSP/PDS and many trusts won’t internally use the NHS number as the primary identifier, so it’s probably better to not use identifier references for patient’s.

Our amended Encounter resource is below:

<Encounter>
    <id value="12779557-9033-4213-876f-69a670cdf35d"/>
    <meta>
        <profile value="https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Encounter-1"/>
    </meta>
    <status value="finished"/>
    <class>
        <system value="http://hl7.org/fhir/v3/ActCode"/>
        <code value="EMER"/>
        <display value="emergency"/>
    </class>
    <type>
        <coding>
            <system value="https://fhir.nhs.uk/STU3/CodeSystem/DCH-Specialty-1"/>
            <code value="180"/>
            <display value="ACCIDENT AND EMERGENCY"/>
        </coding>
    </type>
    <subject>
        <reference value="urn:uuid:5d5845f3-398f-474b-af59-14882fc7b0ca"/>
        <display value="DAWKINS, Jack"/>
    </subject>
    <period>
        <start value="2018-03-23"/>
        <end value="2018-03-23"/>
    </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="RX3"/>
        </identifier>
        <display value="UNIVERSITY HOSPITAL OF NORTH DURHAM"/>
    </serviceProvider>
</Encounter>
1 Like

This is yet more great stuff @mayfield.g.kev - I’ve awarded you the badge FHIR Genius for this and other contributions!

1 Like