Send a document to the EHR

Introduction

The EHR (Electronic Health Record - DPI in french - Dossier Patient Informatisé) is a software gathering medical data of all the patients of a healthcare facility.
EHR providers usually support HPRIM, HL7, but they each have specific implementations which can make it difficult to integrate documents into it. After years of document exchange with many EHR providers, Lifen provides a reliable matching parser giving you the opportunity to easily integrate medical documents into the EHR of any hospital.

Access Control

You need to have the SEND_TO_EHR scope to access the Patient/Encounter Platform service. This functional scope will give you access to the following technical scopes : ORGANIZATION_READ , ORGANIZATION_READ, BINARY_CREATE, COMMUNICATIONREQUEST_CREATE, DOCUMENTREFERENCE_CREATE.

You need a Machine To Machine Communications to use this API.

How does integrating a document into EHRs work ?

Step 1 : search for the patient that is concerned by the document. To do this, refer to page Access Patient Information which allows you to retrieve the FHIR reference of the patient.

Step 2 : search for the encounter that you want to link the document to. To do this, refer to page Access Encounter Information which allows you to retrieve the FHIR reference of the encounter.

Step 3 : Upload & send the document into the EHR

That's it on your side. On our side, this will trigger several operations :

  • Gather all data about the patient (through the FHIR Patient resource),
  • Transform all FHIR information in HL7-ORU or HPRIM-ORU format,
  • Post the document on a dedicated server,
  • Create a Communication.

Upload and send the document

Send a POST

  • production environment : https://api.lifen.fr/fhir/v3/CommunicationRequest/$send-to-ehr
  • test environment : https://api.post-prod.lifen.fr/fhir/v3/CommunicationRequest/$send-to-ehr

Example :

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "subject",
      "valueReference": "Patient/{{id}}"
    },
    {
      "name": "context",
      "valueReference": "Encounter/{{id}}"
    },
    {
      "name": "content-type",
      "valueCode": "application/pdf"
    },
    {
      "name": "document-type",
      "valueCode": "11488-4"
    },
    {
      "name": "payload",
      "valueString": "{{document in base 64}}"
    }
  ]
}

Take care of the following attributes :

  • subject: the value of the ID for the previously search Patient resource
  • context: the value of the ID for the previously search Encounter resource
  • document-type (optional): the LOINC code to describe the type of the document (authorized codes are available on this link). By default, the chosen LOINC code is "11488-4" (= consultation note)
  • content-type (optional): the possible values are : application/pdf, image/jpeg, image/png, application/txt. By default, the content-type is application/pdf.
  • payload: the PDF document translated into base64 format

Response of the service

Check if the document has been successfully sent by Lifen

After sending the document, if you get a status 200, you will also get a Parameters resource with a tracking-url to follow your sending if all the requirements are valid.

Example :

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "tracking-url",
      "valueString": "api.lifen.fr/fhir/v3/Communication?based-on=CommunicationRequest/{{id}}&_elements=status,notDoneReason"
    }
  ]
}

To know if your document has been successfully integrated, call the tracking-url on a GET request.

If the request body is not valid (status 4xx and 5xx), the service will respond with an OperationOutcome resource

Example :

422 : 
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "ERROR",
      "code": "PROCESSING",
      "diagnostics": "Resource contains reference to Patient/{{id}} but this resource is not valid"
    }
  ]
}

If the request body is valid, the service will respond with a Communication resource. The status field on the Communication tells you if the integration is successful or not.

Example :

{
  "resourceType": "Communication",
  "status": "entered-in-error",
  "notDone": true,
  "notDoneReason": {
    "coding": [
      {
        "system": "http://lifen.fr/fhir/ValueSet/communication-status-reason",
        "code": "missing-info",
        "display": "Informations manquantes pour la génération du document."
      }
    ]
  },
  ...
}

The possible values for the status field are :

  • preparation, in-progress, suspended : the document is being processed.
  • completed : shipment successfully completed on Lifen's side. The document can still be in progress on the recipient or integration side.
    Check the extension delivery-status (http://lifen.fr/fhir/internal/StructureDefinition/communication-delivery-status see details below) to know if it is successful on the recipient side
  • entered-in-error : an error happened during the flow. Check the notDoneReason field to know the detailed reason of the failure (notDoneReason documentation)

Please find more details about the possible statuses here.

Check if the document has been successfully processed by the EHR

To check if the document has been successfully processed by the recipient, check the communication-delivery-status of the Communication. It is the value of the extension with the system http://lifen.fr/fhir/internal/StructureDefinition/communication-delivery-status.

Example :

{
  "resourceType": "Communication",
  "extension": [
    {
      "url": "http://lifen.fr/fhir/internal/StructureDefinition/communication-delivery-status",
      "valueString": "in_transit"
    },
    ...
  ],
  ...
}

The possible delivery statuses are :

  • in_transit : the message left Lifen and is waiting for feedback from the healthcare organization (HL7 ACK message usually)
  • delivered : the message was successfully integrated into the EHR
  • error : the message was not well integrated into the EHR

Integrate the document

EHR can automatically integrate the document into the patient record by processing the information (subject/patient_id, context/encounter_id, document's type, document's content and application's name) sent by the application and transmitted by the Lifen Platform using HL7v2 messages.