These docs are for v2. Click to read the latest docs for v3.

Send a document to the EHR v2

The EHR (DPI in french) is a software gathering the medical data of all patients of a healthcare facility. EHR providers usually support HPRIM, HL7, but they each have some specificities which can make it difficult to integrate documents into it. After years of 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 have to use the Access Token of an authenticated user with the SEND_TO_EHR permissions in the scope to access the FHIR API.

How does EHR integration work ?

First, make sure you have previously search a FHIR Patient. (see paragraph below for more information)

Next, you have to upload the document on the FHIR API.

Posting your CommunicationRequest will trigger several operations :

  • Gather all data about the patient (through the FHIR Patient resource)
  • Transform all FHIR information in HL7-ORU or HPRIM format
  • Post the document on a dedicated server
  • Create a Communication.
    The communication can have 2 status (see paragraph below for more information):
    - success: the document has been integrated into the DPI
    - entered-in-error: an error occurred during the integration.

Find the Patient corresponding to your sending

In order to send a document to a patient's EHR, you must mention which patient it is. To do this, refer to page Access Patient Information v2 which allows you to retrieve the FHIR reference of the patient concerned by the sending. You can search by
IPP, last name, first name, DDN or other field explain in the section.

Find the Encounter corresponding to your sending

In order to send a document to a patient's EHR, you must mention which encounter it is. To do this, refer to page Access Encounter Information v2 which allows you to retrieve the FHIR reference of the encounter concerned by the sending. You can search by
the Patient FHIR Reference, the start/end date or other field explain in the section.

Create a CommunicationRequest resource

Send a POST

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

with a JSON body referencing the previously search Patient into the subject

Example :

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

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 translate into base64 format

After that, the CommunicationRequest will be integrated into Lifen's sending flow to add other information and eventually send the document to the EHR.

Response of the service

After posting the CommunicationRequest, Lifen respond with a status 200 and the Parameters resource with a tracking-url to follow your sending if
all the requirement are valid.

Example :

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

To know if your sending is successful, call the tracking-url on a GET request

The service can respond with an OperationOutcome if the request body is not valid (status 4xx and 5xx)

Example :

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

1. Check the status field on the Communication (status documentation) to know if the integration is successful.

Lifen status :

  • preparation, in-progress, suspended : the sending is being processed in the Lifen flow
  • completed : shipment successfully completed on Lifen's side. The sending 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 the sending is successful in the recipient side
  • entered-in-error : an error appeared during the sending flow. Check the notDoneReason field to know the detailed reason of the failure (
    notDoneReason documentation)

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

2. Check the delivery-status of message sent to DPI in the value of the extension with system http://lifen.fr/fhir/internal/StructureDefinition/communication-delivery-status

Lifen delivery status :

  • in_transit : the message left Lifen and wait for feedback from healthcare organization
  • delivered : the message was successful integrate into DPI
  • error : the message was not well integrated into the DPI

Example :

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