Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

http://localhost:29221/alexanderwilms_7788/

Introduction

RED medical offers a FHIR interface for third-party data providers/consumers. This interface is based on the German regulatory standards §291 (Verordnungssoftware - Schnittstelle / VOS) and §371 (Archiv- und Wechselschnittstelle / AWS) SGB V. These interfaces are based on the international FHIR-Standard with local extensions e.g. for statutory billing purposes.

RED Interchange interchange API provides a third-party system with functions

  • to send data to RED for processing and storage. This allows a third-party system e.g. to send data of patients that have been registered to RED. Patient data will be validated in RED as if entered manually and stored in the RED database using the RED end-to-end encryption. 
  • to query data from RED. The third-party system may send query requests to RED (e.g. for patients, patient records or documents) and RED will return data retrieved from its database
  • to execute transactions with the Telematik-Infrastruktur such as basic Konnektor operations (e.g. PIN verification) or complex transactions (e.g. dispensing an electronic prescription)


The RED Interchange interchange API uses the XML-based FHIR format for data exchange. Data to be sent to RED must be separated and packaged into FHIR bundles, and data queried from RED will be returned in FHIR bundles. RED uses the FHIR bundles defined by Kassenärztliche Bundesvereinigung in their AWS project.

In order to ensure the secrecy of person-related data (as required by German criminal law) RED uses end-to-end encryption of all person-related data stored in its data-centers. In order to access data in RED Users must authenticate during login and obtain the cryptographic keys necessary to decrypt and encrypt data. Therefore the RED Interchange interchange API cannot be a server interface, as encryption keys are in the possession of the users only, and data cannot be encrypted or decrypted server-side. By requirement the RED Interchange interchange API expects to communicate with an application installed on the local machine or a locally installed server reachable via localhost.

After a user has logged in successfully and obtained his cryptographic keys a local FHIR server is started by RED on the users machine. If the FHIR server is running RED will act as recipient and listen to POST and GET requests from the sending third-party application.

Setup in RED

In order to To use the RED Interchange API you will need an account in RED. Please contact us for an offer and help. 

If you have a RED account open RED in your web browser https://redclient.redmedical.de/redclient/index.html and log in using your user credentials. If you log in on a machine for the first time you will be prompted to install RED commander. RED commander is a local application enabling RED to access the local resources and to execute the FHIR server. Download and install the RED commander using the installation wizard. RED commander - Technische InformationenRED commander - Installation

The FHIR interface is disable by default. If it is to be used the FHIR server must be enabled for each machine. Log in as an administrator user and navigate to management of terminals (search for #b arbeits and select ArbeitsplätzeSelect your current terminal (marked by ICH) and navigate down to the Schnittstelle FHIR section. 

Image Removed

RED shows a list of all FHIR interfaces defined for this terminal. A FHIR interface may be active or paused. Active FHIR interfaces are marked by Aktiv. Click on FHIR-Schnittstelle hinzufügen to create a new FHIR interface or FHIR-Schnittstelle bearbeiten to modify an existing definition.

Image Removed

Schnittstelle verwenden: allows to activate and deactivate the interface (e.g. for testing purposes)

Bezeichnung: name of this interface

Typ der Schnittstelle: for RED Interchange API select the option “FHIR-Schnittstelle”

Sichere Verbindung: if set to “Nein” a http-connection is used, if set to “Ja”, https is used

Anwendungsadresse: path to the application that is to be opened by RED

Erweiterte Optionen: options string to send to the application when opened (not required)

Save the setting with the orange Speichern button. The interface is set up and FHIR server will be started automatically during the next login.

For testing purposes on a local environment the interface can be reached at: http://localhost:29221/{tenantID}. The tenantID is the internal ID of the RED instance. You will find your tenant ID by clicking on the user name (next to the house icon) in the top panel. The tenant ID is shown as ID.

Image Removed

Receiving data from RED - Search and Get

interchange API it must be set up for each RED terminal (Arbeitsplatz)For development and testing the tool Postman (https://www.postman.com/downloads/) can be used as sending application. Please contact us to receive a Postman collection with sample requests. 

To query for data items stored in the RED database GET requests are sent to RED. A search requests uses GET and contains 

  • address of the system (base url)
  • RED tenant ID
  • type of data to fetch (e.g Patient) with attributes
  • page set to restrict amount of data to fetch. 

Search requests will return all data items matching the given search criteria. Please note that search for patients is available on request only.

Code Block
titleExample for a SEARCH request to search for a patients diagnoses
http://localhost:29221/alexanderwilms_7788/Condition?page=1&subject=Patient/6006

A successful search request will be responded with a FHIR-Bundle. In this example two diagnoses are found for the given patient. The FHIR bundle has a wrapper with two entries. For description of entries see below.

Code Block
titleExample for the SEARCH result FHIR bundle wrapper
<Bundle xmlns="http://hl7.org/fhir">
    <id value="3548c21b-28e2-b29e-1f83-9a9658909dd6"/>
    <meta>
        <lastUpdated value="2022-06-24T19:39:11+00:00"/> // date-timestamp of request
    </meta>
    <type value="searchset"/>
    <total value="2"/> // number of results found and returned as <entry>
    <entry>
        <fullUrl value="/Condition/IEG6VfAE0uw0AuYyzQtx2oIsXLFbUslA"/>
        <resource>
            <Condition xmlns="http://hl7.org/fhir">
                <id value="IEG6VfAE0uw0AuYyzQtx2oIsXLFbUslA"/>         
				...
		 	</Condition>
        </resource>
    </entry>
    <entry>
        <fullUrl value="/Condition/ROAG8t8Bz7MO8yHXAZOA5y2Tc5zVR8RA"/>
        <resource>
            <Condition xmlns="http://hl7.org/fhir">
                <id value="ROAG8t8Bz7MO8yHXAZOA5y2Tc5zVR8RA"/>
				...
			</Condition>
		</resource>
    </entry>
</Bundle>

Search is used to query if a certain data item or data items of a given type have been stored in RED. Search can be applied to

  • Encounters (Visits or consultations) and Chargecodes
  • Diagnoses
  • Medication (orders and overviews)
  • History items documented in patient record
  • Document references, including stored files (e.g PDF files from scanner or imaging results, printouts of forms created (e.g. Muster, Rezepte) or letters written
  • Practitioners and Organizations (users and user groups)

Read

In order to fetch a specific identifiable data item a Read request is used. A read requests uses GET and contains 

  • address of the system (base url)
  • RED tenant ID
  • type of data to fetch (e.g Patient)
  • identifier of the specific data item. The identifier may be an external identifier sent by the third-party system when the data item was created in RED or may have been retrieved by search
Code Block
titleExample for a READ request for a specific condition
http://localhost:29221/alexanderwilms_7788/Condition/IEG6VfAE0uw0AuYyzQtx2oIsXLFbUslA

A read request for a specific data item will be answered with a single FHIR item of the reqested type.

Code Block
titleExample for an entry in the FHIR bundle
<Condition xmlns="http://hl7.org/fhir">
    <id value="IEG6VfAE0uw0AuYyzQtx2oIsXLFbUslA"/>
    <meta>
        <versionId value="1"/>
        <lastUpdated value="2022-04-27T00:00:00+00:00"/>. // date of creation / last update in RED
        <profile value="https://fhir.kbv.de/StructureDefinition/KBV_PR_AW_Diagnose|1.2.0"/>
    </meta>
    <text> // text contains a human-readable description of its content
        <status value="extensions"/>
        <div xmlns="http://www.w3.org/1999/xhtml">Diagnose von Patient Luca Fink</div>
    </text>
    <extension url="https://fhir.kbv.de/StructureDefinition/KBV_EX_AW_Diagnose_istDauerdiagnose">
        <valueBoolean value="true"/>
    </extension>
    <extension url="https://fhir.kbv.de/StructureDefinition/KBV_EX_AW_istAbrechnungsrelevant">
        <valueBoolean value="false"/>
    </extension
    <clinicalStatus>
        <coding>
            <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
            <code value="active"/>
        </coding>
    </clinicalStatus>
    <verificationStatus>
        <coding>
            <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"/>
            <code value="confirmed"/>
        </coding>
    </verificationStatus>
    <code>
        <coding>
            <system value="http://fhir.de/CodeSystem/dimdi/icd-10-gm"/>
            <version value="2017"/>
            <code value="I20.9"/>
            <display value="Angina pectoris"/>
        </coding>
    </code>
    <subject>
        <reference value="Patient/6tVbNJZq1buNwKmp6UKpd8CpLceNDlRF/_history/1"/>
    </subject>
    <encounter>
        <reference value="Encounter/P2U6P2J9K53tahcsGALfMyXA1wEAAroy/_history/1"/>
    </encounter>
    <recordedDate value="2022-04-27"/>
</Condition>

Practitioners

Practitioners are physicians defined in RED as users/user LANRs. Practitioners can be searched using a search request.  Search returns a bundle of one or more FHIR items of type KBV_PR_AW_Behandelnder.

Code Block
titleSEARCH request for all practitioners
{{baseURL}}/{{tenant}}/Practitioner?page=1

Data of a specific practitioner may be fetched using a read request with the identifier of the specific practitioner. The request returns a FHIR item of type KBV_PR_AW_Behandelnder

Code Block
titleREAD request for a specific practitioner
{{baseURL}}/{{tenant}}/Practitioner/wK7hhpbEIG1qkSdvRCCd3AEA3W4lBfDB

Postman Examples

SEARCH All Practitioner 

> GET http://localhost:29221/{tenant}/Practitioner?page=1

SEARCH All Organizations will return a FHIR bundle containing all user groups/practice definitions defined in RED. Returns a bundle of one or more FHIR items of type Organization

Search can also be used to search for items assigned to a patient by adding the patient identifier to the search request.

SEARCH DocumentReference 

This request will return a FHIR bundle containing all documents stored for a given patient. Returns a bundle of one or more FHIR items of type DocumentReference.

> GET http://localhost:29221/{tenant}/DocumentReference?subject=Patient/{id}

For each document found the FHIR bundle includes the base64-encoded document content. To avoid long loading time the request can be modified with the summary option to fetch the document metadata without the actual document content. 

> GET http://localhost:29221/{tenant}/DocumentReference?subject=Patient/{id}&_summary=true

SEARCH Conditions

This request will return a FHIR bundle containing all conditions (diagnoses) stored for a given patient. Returns a bundle of one or more FHIR items of type condition.

> GET http://localhost:29221/{tenant}/Condition?subject=Patient/{id}

Get data items

While search retrieves all data matching the given search criteria (e.g. a patient) specific items can be retrieved by adding their identification to the GET request.

A GET request to retrieve a specific item contains

  • address of the system, 
  • RED tenant ID
  • type of data to fetch
  • identifier of the data item

> GET http://localhost:29221/{tenant}/Patient/1

A GET request containing an identifier always returns a single data item

<Patient xmlns="http://hl7.org/fhir">
  <id value="1"/>
  ...
</Patient>

GET patient

This request will return a FHIR bundle containing the patient FHIR item of a given patient. Patients are identified by their user-readable Patient ID.

> GET http://localhost:29221/{tenant}/Patient/{id}

The Patient ID is displayed for each patient in the patient header. If a patient was created from external data using the FHIR interface the given external patient ID will be used.

GET Document

The base-64 encoded content of a document stored in RED can be accessed by requesting the document by its ID. 

> GET http://localhost:29221/{tenant}/DocumentReference/eR4LDh4fJtmzlwTa

...

> GET http://localhost:29221/{tenant}/DocumentReference?subject=Patient/{id}&_summary=true

This request returns a FHIR bundle with DocumentReferences. Each DocumentReference has its own unique ID.

<entry>

       <fullUrl value="/DocumentReference/egMHGB0DlhuKsLzN"/>

       <resource>

           <DocumentReference xmlns="http://hl7.org/fhir">

               <id value="egMHGB0DlhuKsLzN"/>

               <meta>

                   <versionId value="1"/>

                   <lastUpdated value="2022-02-03T00:00:00+00:00"/>

                   <profile value="https://fhir.kbv.de/StructureDefinition/KBV_PR_AW_Anlage|1.2.0"/>

               </meta>

Using this ID the full document content can be retrieved using a second GET request.

> GET http://localhost:29221/{tenant}/DocumentReference/egMHGB0DlhuKsLzN

Create data items

POST requests can be used to send data to and create new data items in RED. Data to be created and stored must be packaged in FHIR bundles. A FHIR bundle contains all data necessary to create the new data item. 

Example: the bundle of a new patient may contain (see Postman example Create Patient)

  • the patient including address and contact information
  • an encounter item stating the date of patient consultation
  • a claim containing insurance data
  • a document reference with file data to store for the new patient
  • the practitioner who has created the data, including name, address and contact information
  • the organization on which behalf the data is created, including address and contact information
  • a practitioner role joining practitioner and organization
  • a provenance item for EVERY data item in the bundle. Provenances specify the context of user and user group in RED. These are required, e.g. to control and limit access to the data item in RED.

> POST http://localhost:29221/{tenant}/Bundle

Request Header should set the content-type to

...

Request body (see Postman examples)

<Bundle xmlns="http://hl7.org/fhir">
  <id value="10000"/>
  <meta>
    <versionId value="1"/>
    <lastUpdated value="2020-09-24T12:52:00+00:00"/>
    <profile value="https://fhir.kbv.de/StructureDefinition/KBV_PR_AW_Bundle_Patientenakte|1.2.0"/>
  </meta>
  <type value="history"/>
  <entry>
  ...
  </entry>
  <entry>
  ...
  </entry>
</Bundle>

 

Receiving data from RED - Search and Read

RED interchange API - Search/Read Practitioners

RED interchange API - Search/Read PractitionerRoles

RED interchange API - Search/Read Organizations

RED interchange API - Search/Read Claims

RED interchange API - Search/Read Encounters

RED interchange API - Search/Read Observations

RED interchange API - Search/Read Coverages

RED interchange API - Search/Read DocumentReferences

RED Interchange API - Search/Read Medication



 

Delete Items from RED

> DELETE http://localhost:29221/{tenant}/Bundle/10000

Deletes a stored bundle in RED medical application.

Request an electronic prescription 

The RED interchange API may also be used to communicate with gematik Fachdienst to retrieve stored electronic prescriptions and to send dispense requests.

Request prescription

A prescription is identified by its PrescriptionID and the AccessCode. PrescriptionID and AccessCode are represented by the barcode on the prescription form. The barcode contains a string containing an array of urls. Each url is represented by a string with this format:

Task/<Prescription ID>/$accept?ac=<AccessCode>

{"urls":["Task/160.000.111.065.827.98/$accept?ac=b8d9e513cd11cfe0a1d829b96a503e9df5b17803bbdbc4036f32858494539f28"]}

In this example the prescriptionID is 160.000.111.065.827.98 and AccessCode is b8d9e513cd11cfe0a1d829b96a503e9df5b17803bbdbc4036f32858494539f28.

To get the prescription data for this prescription a GET request is sent:

> GET http://localhost:29221/{tenant}/Task?action=$accept&prescriptionid={PrescriptionID}&accesscode={AccessCode}

Example

http://localhost:29221/{tenant}/Task?action=$accept&prescriptionid=160.000.111.065.827.98&accesscode=b8d9e513cd11cfe0a1d829b96a503e9df5b17803bbdbc4036f32858494539f28

This request returns a FHIR bundle with several items.

  • Composition: contains summary information and references to all items in the bundle
  • MedicationRequest: refers to Medication, patient, requester and insurance. Includes administrative information such as copayment, emergencyFee, substitution (aut-idem) or payer (BVG). Also contains the dosage and quantity
  • Medication: contains data of prescribed product (e.g. PZN ID, flag vaccine, Normgröße, form and amount)
  • Patient: person the prescription was created for, including insurance ID, name and address
  • Practitioner: physician who created and signed the prescription, including LANR, name and qualification
  • Organization: practice which created the prescription, including BSNR, address and contact
  • Coverage: payer and insurance information, including insurance status, WOP, person group, copayment status, payer identification

This GET request can be used for the initial fetch of prescription data as well as further requests to fetch the same data later. When the FHIR bundle is returned from Fachdienst a second access code (“secret”) is added. All further requests to Fachdienst (in order to retrieve prescription data again, cancel or dispense the prescription) must include this secret to prove the requesters authorization to access the data. RED stores the secret in its database and adds it automatically for every further processing action of this request.

Return a prescription

After a pharmacy has requested an electronic prescription from Fachdienst and received the FHIR bundle the Fachdienst locks the prescription. If the pharmacy is not able to deliver the prescribed products the prescription can be returned. If a prescription is returned it is released on Fachdienst and may be requested by someone else.

To return a prescription a GET request is sent. In addition to PrescriptionID and AccessCode RED automatically includes the secret.

> GET http://localhost:29221/{tenant}/Task?action=$reject&prescriptionid={PrescriptionID}&accesscode={AccessCode}

Example

http://localhost:29221/{tenant}/Task?action=$reject&prescriptionid=160.000.111.065.827.98&accesscode=b8d9e513cd11cfe0a1d829b96a503e9df5b17803bbdbc4036f32858494539f28

Dispense a prescription

After a pharmacy has delivered the prescription a dispense request is created. The dispense request contains a FHIR bundle of type MedicationDispense. 

The bundle is sent to RED using POST

> POST http://localhost:29221/{tenant}/Bundle