HL7 V2.x ADT messages to FHIR conversion

This blog post explains how we convert an HL7 ADT message to FHIR STU3 (3.0.1).

There are 51 different types of HL7 ADT messages, ranging from A01 to A51. Some of the most commonly used ADT messages include:

  • ADT-A01 – patient admit
  • ADT-A02 – patient transfer
  • ADT-A03 – patient discharge
  • ADT-A04 – patient registration
  • ADT-A05 – patient pre-admission
  • ADT-A08 – patient information update
  • ADT-A11 – cancel patient admit
  • ADT-A12 – cancel patient transfer
  • ADT-A13 – cancel patient discharge

The Redix conversion tool supports the conversion of all 51 ADT messages, as well as different versions, i.e., 2.2 to 2.8.

The ADT to FHIR mapping can be found in the FHIR patient resource, http://hl7.org/fhir/stu3/patient-mappings.html. Note that some of the mappings are not a one-to-one relationship between ADT and FHIR patient resource. For example, the patient.organization can be mapped to one of the NK1 element, i.e., NK1-13, NK1-30, NK1-31, NK1-32, NK1-41, etc. This means that if there is a value in the NK1-13 field, then we can map the value to the organization. If not, we should continue checking if there is a value in the NK1-30, NK1-31, NK1-32, or NK1-41 field.

Besides the patient information, ADT can also carry other information, such as allergy intolerance and related person. Below is a table that shows the mappings between an HL7 2.x ADT message and three possible FHIR resources in STU3. Note that the section number can be changed in a different release.

FHIR Resource URL Section in the URL
Patient http://hl7.org/fhir/stu3/patient-mappings.html. 8.1.14.4
AllergyIntolerance http://hl7.org/fhir/stu3/allergyintolerance-mappings.html 9.1.7.2
RelatedPerson http://hl7.org/fhir/stu3/relatedperson-mappings.html 8.2.7.2

 

Some of the notes about this conversion:

  • Validates the input file. Only the file is validated, the file will be converted.
  • Generates FHIR in JSON format
  • Uses “bundle” as an FHIR resourceType
  • Uses “transaction” as type
  • Uses uuid for the “id” in each resource
  • Uses “urn:redix-fhir” for the identifier.system
  • Date conversion for DOB, PID07
  • Code conversion for the gender (PID08), M to male, F to female, U to unknown
  • Code conversion for allergy severity: SV for high, MO for low, MI for low
  • Uses “PUT” method in the “request” collection. To make sure that the patient data is unique in the FHIR data server, “ifNoneExist” method is used.

Web-based Tool

You can test the conversion tool online by going to Redix HIPAA Compliance and Conversion Services, and then enter your file by pressing the “Select File” button. After a file is selected, your file will be automatically converted to an FHIR message, providing the file is a valid HL7 2.x ADT file. Also, you will see the message type and the version number of your HL7 file. In the following example, it is ADT and V2.4, respectively.

In front of each segment, there is a “>” sign. Press it and you will see the definition the segment and its corresponding value of each field. Below is the definition of MSH segment.

Here is the definition of PID segment.

After the conversion, you might want to upload the FHIR JSON message to your FHIR data server. The default FHIR data server is HAPI, http://fhirtest.uhn.ca/. You can press the button “Upload to FHIR Data Server” to upload your FHIR resources to the FHIR data server.

You can, of course, use your own FHIR data server. To do so, you will need to first signup and then define your data server as a default FHIR data server.

Example

Use the following ADT file as an example:

MSH|^~\&|ADT1|MCM|LABADT|MCM|198808181126|SECURITY|ADT^A04|MSG00001|P|2.4
EVN|A01-|198808181123
PID|||PATID1234^5^M11||JONES^WILLIAM^A^III||19610615|M-||2106-3|1200 N ELM STREET^^GREENSBORO^NC^27401-1020|GL|(919)379-1212|(919)271-3434~(919)277-3114||S||PATID12345001^2^M10|123456789|9-87654^NC
NK1|1|JONES^BARBARA^K|SPO|||||20011105
NK1|1|JONES^MICHAEL^A|FTH
PV1|1|I|2000^2012^01||||004777^LEBAUER^SIDNEY^J.|||SUR||-||1|A0-
AL1|1||^PENICILLIN||PRODUCES HIVES~RASH
AL1|2||^CAT DANDER
DG1|001|I9|1550|MAL NEO LIVER, PRIMARY|19880501103005|F||
PR1|2234|M11|111^CODE151|COMMON PROCEDURES|198809081123
ROL|45^RECORDER^ROLE MASTER LIST|AD|CP|KATE^SMITH^ELLEN|199505011201
GT1|1122|1519|BILL^GATES^A
IN1|001|A357|1234|BCMD|||||132987
IN2|ID1551001|SSN12345678
ROL|45^RECORDER^ROLE MASTER LIST|AD|CP|KATE^ELLEN|199505011201

The above ADT message is converted to the following FHIR message in JSON, which includes three resources: Patient, AllergyIntolerance, and RelatedPerson.

{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "resource": {
        "resourceType": "Patient",
        "id": "51B11A01-4125-4042-9358-415228181551",
        "identifier": [
          {
            "system": "urn:redix-fhir",
            "value": "JONES.WILLIAM.male"
          },
          {
            "system": "submit_mrn",
            "value": "PATID1234"
          }
        ],
        "name": [
          {
            "use": "official",
            "family": "JONES",
            "given": [
              "WILLIAM"
            ],
            "prefix": "III"
          }
        ],
        "telecom": [
          {
            "system": "phone",
            "value": "(919)379-1212",
            "use": "home"
          },
          {
            "system": "phone",
            "value": "(919)271-3434",
            "use": "work"
          },
          {
            "system": "phone",
            "value": "(919)277-3114",
            "use": "work"
          }
        ],
        "gender": "male",
        "address": [
          {
            "use": "home",
            "line": "1200 N ELM STREET",
            "city": "GREENSBORO",
            "state": "NC",
            "postalCode": "27401-1020"
          }
        ],
        "contact": [
          {
            "relationship": [
              {
                "coding": [
                  {
                    "system": "http://hl7.org/fhir/patient-contact-relationship",
                    "code": "SPO"
                  }
                ]
              }
            ],
            "name": {
              "family": "JONES",
              "given": [
                "BARBARA"
              ]
            }
          },
          {
            "relationship": [
              {
                "coding": [
                  {
                    "system": "http://hl7.org/fhir/patient-contact-relationship",
                    "code": "FTH"
                  }
                ]
              }
            ],
            "name": {
              "family": "JONES",
              "given": [
                "MICHAEL"
              ]
            }
          }
        ],
        "link": [
          {
            "other": "PATID1234"
          }
        ]
      },
      "request": {
        "method": "PUT",
        "url": "Patient?family=JONES&given=WILLIAM&gender=male",
        "ifNoneExist": "identifier=redix-fhir|JONES.WILLIAM.male"
      }
    },
    {
      "resource": {
        "resourceType": "AllergyIntolerance",
        "id": "B9B06723-C9AB-4485-B276-11194A3A5440",
        "identifier": [
          {
            "system": "urn:redix-fhir",
            "value": "dne.B9B06723-C9AB-4485-B276-11194A3A5440"
          }
        ],
        "verificationStatus": "unconfirmed",
        "patient": {
          "reference": "Patient/51B11A01-4125-4042-9358-415228181551"
        },
        "reaction": [
          {
            "manifestation": [
              {
                "coding": [
                  {
                    "system": "http://snomed.info/sct",
                    "code": "PRODUCES HIVES"
                  }
                ]
              },
              {
                "coding": [
                  {
                    "system": "http://snomed.info/sct",
                    "code": "RASH"
                  }
                ]
              }
            ]
          }
        ]
      },
      "request": {
        "method": "PUT",
        "url": "sectionAllergy?identifier=redix-fhir|dne.B9B06723-C9AB-4485-B276-11194A3A5440",
        "ifNoneExist": "identifier=redix-fhir|dne.B9B06723-C9AB-4485-B276-11194A3A5440"
      }
    },
    {
      "resource": {
        "resourceType": "AllergyIntolerance",
        "id": "B9B06745-C9AB-4485-B276-41494A3A1514",
        "identifier": [
          {
            "system": "urn:redix-fhir",
            "value": "dne.B9B06745-C9AB-4485-B276-41494A3A1514"
          }
        ],
        "verificationStatus": "unconfirmed",
        "patient": {
          "reference": "Patient/51B11A01-4125-4042-9358-415228181551"
        }
      },
      "request": {
        "method": "PUT",
        "url": "sectionAllergy?identifier=redix-fhir|dne.B9B06745-C9AB-4485-B276-41494A3A1514",
        "ifNoneExist": "identifier=redix-fhir|dne.B9B06745-C9AB-4485-B276-41494A3A1514"
      }
    },
    {
      "resource": {
        "resourceType": "RelatedPerson",
        "id": "B9B06767-C9AB-4485-B276-51194A3A0114",
        "identifier": [
          {
            "system": "urn:redix-fhir",
            "value": "JONES,BARBARA,K.unknown"
          }
        ],
        "patient": {
          "reference": "Patient/51B11A01-4125-4042-9358-415228181551"
        },
        "relationship": [
          {
            "coding": [
              {
                "system": "http://hl7.org/fhir/patient-contact-relationship",
                "code": "SPO"
              }
            ]
          }
        ],
        "name": [
          {
            "use": "official",
            "family": "JONES",
            "given": "BARBARA"
          }
        ]
      },
      "request": {
        "method": "PUT",
        "url": "RelatedPerson?name=JONES,BARBARA,K&gender=unknown",
        "ifNoneExist": "identifier=redix-fhir|JONES,BARBARA,K.unknown"
      }
    },
    {
      "resource": {
        "resourceType": "RelatedPerson",
        "id": "E63F1E89-8566-4EAE-BA0D-5415DBCB1144",
        "identifier": [
          {
            "system": "urn:redix-fhir",
            "value": "JONES,MICHAEL,A.unknown"
          }
        ],
        "patient": {
          "reference": "Patient/51B11A01-4125-4042-9358-415228181551"
        },
        "relationship": [
          {
            "coding": [
              {
                "system": "http://hl7.org/fhir/patient-contact-relationship",
                "code": "FTH"
              }
            ]
          }
        ],
        "name": [
          {
            "use": "official",
            "family": "JONES",
            "given": "MICHAEL"
          }
        ]
      },
      "request": {
        "method": "PUT",
        "url": "RelatedPerson?name=JONES,MICHAEL,A&gender=unknown",
        "ifNoneExist": "identifier=redix-fhir|JONES,MICHAEL,A.unknown"
      }
    }
  ]
}