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 API 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 the format the hospital expects (HL7-ORU or HPRIM-ORU or proprietary JSON),
  • Post the document on a dedicated server.

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": {
        "reference":"Patient/{{id}}"
      }
    },
    {
      "name": "context",
      "valueReference": {
        "reference":"Encounter/{{id}}"
      }
    },
    {
      "name": "content-type",
      "valueCode": "application/pdf"
    },
    {
      "name": "document-type",
      "valueCode": "11488-4"
    },
    {
     "name": "document-title",
     "valueString": "Consentement à l'intervention"
    },
    {
      "name": "sender-identifier",
      "valueString": "12345678910"
    },
    {
      "name": "payload",
      "valueString": "{{document in base 64}}"
    }
  ]
}

Take care of the following attributes :

  • subject: the value of the ID of the previously searched Patient resource
  • context: the value of the ID of the previously searched 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.
  • document-title(optional): free text field. If you don't fill this field, the document title will follow this nomenclature last_name_first_name_birthdate_document_type_identifier.
  • sender-identifier(optional): identifier of the healthcare professional that sends the document into the EHR. The most common is the RPPS number (11 characters) so we support only this one. The by-default sender is the name of your application.
  • 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": "https://api.lifen.fr/fhir/v3/CommunicationRequest/$tracking?transaction-id=ifad1343e-496f-11ed-b878-0242ac120002"
        },
        {
            "name": "transaction-id",
            "valueString": "fad1343e-496f-11ed-b878-0242ac120002"
        }
    ]
}

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

📘

The url available in the tracking-url field is usable directly to call our API and get the delivery status of the document(s) you sent

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"
    }
  ]
}

After you've sent the medical document(s), Lifen processes it. This process can take up to 5 minutes. After this delay, you can follow the delivery status through the following endpoint :

GET  https://api.lifen.fr/fhir/v3/CommunicationRequest/$tracking?transaction-id=ifad1343e-496f-11ed-b878-0242ac120002

🚧

After two months, the delivery status will no longer be available.

Example :

{
    "resourceType": "Bundle",
		"type": "collection",
    "total": 1,
	  "entry": [
    {
      "resource" : {
				"resourceType": "Communication",
				"status": "completed", // see status code available below
				"sent": "2019-03-07T13:07:23.000+00:00", // only if status = completed
			}
    }
  ]
}

Resource status

StatusDescription
preparationThe document has arrived to the Lifen Platform and will be processed soon
in-progressThe document is being processed by the Lifen Platform
completedThe document has been processed by the Lifen Platform
entered-in-errorThe document has not been sent, there has been an error on Lifen side
unknownThe document has not been sent, there has been an error on Lifen side

Integrate the document

EHRs 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, HPRIM or other required formats (JSON).