Message Refiner (3.0.0)

Download OpenAPI specification:Download

Getting Started with the DIBBs Message Refiner Service

Introduction

The DIBBs Message Refiner service offers a REST API to pare down an incoming message to only the user-specified elements.

Running the Message Refiner

You can run the Message Refiner run using Docker, any other OCI container runtime (e.g., Podman), or directly from the Python source code.

To run the Message Refiner with Docker, follow these steps.

  1. Confirm that you have Docker installed by running docker -v. If you don't see a response similar to what's shown below, follow these instructions to install Docker.

  2. Download a copy of the Docker image from the PHDI repository by running docker pull ghcr.io/cdcgov/dibbs-ecr-viewer/message-refiner:latest

  3. Run the service with docker run -p 8080:8080 message-refiner:latest.

Congratulations, the Message Refiner should now be running on localhost:8080!

Running from Python Source Code

We recommend running the Message Refiner from a container, but if that isn't feasible for a given use -case, you can also run the service directly from Python using the steps below.

  1. Ensure that both Git and Python 3.13 or higher are installed.
  2. Clone the PHDI repository with git clone https://github.com/CDCgov/dibbs-ecr-viewer.
  3. Navigate to /dibbs-ecr-viewer/containers/message-refiner/.
  4. Make a fresh virtual environment with python -m venv .venv.
  5. Activate the virtual environment with source .venv/bin/activate (MacOS and Linux), venv\Scripts\activate (Windows Command Prompt), or .venv\Scripts\Activate.ps1 (Windows Power Shell).
  6. Install all of the Python dependencies for the Message Refiner with pip install -r requirements.txt into your virtual environment.
  7. Run the Message Refiner on localhost:8080 with python -m uvicorn app.main:app --host 0.0.0.0 --port 8080.

Building the Docker Image

To build the Docker image for the Message Refiner from source instead of downloading it from the PHDI repository follow these steps.

  1. Ensure that both Git and Docker are installed.
  2. Clone the PHDI repository with git clone https://github.com/CDCgov/dibbs-ecr-viewer.
  3. Navigate to /dibbs-ecr-viewer/containers/message-refiner/.
  4. Run docker build -t message-refiner ..

The API

When viewing these docs from the /redoc endpoint on a running instance of the Message Refiner or the DIBBs website, detailed documentation on the API will be available below.

Architecture Diagram

flowchart LR

subgraph requests["Requests"]
direction TB
subgraph GET["fas:fa-download <code>GET</code>"]
hc["<code>/</code>\n(health check)"]
end
subgraph PUT["fas:fa-upload <code>PUT</code>"]
ecr["<code>/ecr</code>\n(refine eICR)"]
end
end

subgraph service[REST API Service]
direction TB
subgraph mr["fab:fa-docker container"]
refiner["fab:fa-python <code>message-refiner<br>HTTP:8080/</code>"]
end
subgraph tcr["fab:fa-docker container"]
tcr-service["fab:fa-python <code>trigger-code-reference<br>HTTP:8081/</code>"] <==> db["fas:fa-database SQLite DB"]
end
mr <==> |<code>/get-value-sets</code>| tcr
end

subgraph response["Responses"]
subgraph JSON["fa:fa-file-alt <code>JSON</code>"]
rsp-hc["fa:fa-file-code <code>OK</code> fa:fa-thumbs-up"]
end
subgraph XML["fas:fa-chevron-left fas:fa-chevron-right <code>XML</code>"]
rsp-ecr["fas:fa-file-code Refined eICR"]
end
end

hc -.-> mr -.-> rsp-hc
ecr ===> mr ===> rsp-ecr

Additional notes on eICR Refinement

For further details on <section>, <entry>, and <templateId> elements, please see eICR-Notes.md for an explanation of trigger code <templateId>s, which sections they're in, and the <observation> data that should be returned in the refined eICR output.


Health Check

This endpoint checks service status. If an HTTP 200 status code is returned along with {"status": "OK"}' then the Message Refiner is available and running properly.

Responses

Response samples

Content type
application/json
null

Refine eCR

This endpoint refines an incoming XML eCR message based on sections to include and/or trigger code conditions to include, based on the parameters included in the endpoint.

The return will be a formatted, refined XML, limited to just the data specified.

Inputs and Outputs

  • :param refiner_input: The request object containing the XML input.
  • :param sections_to_include: The fields to include in the refined message.
  • :param conditions_to_include: The SNOMED condition codes to use to search for relevant clinical services in the eCR.
  • :return: The RefineeCRResponse, the refined XML as a string.
query Parameters
Sections To Include (string) or Sections To Include (null) (Sections To Include)

The sections of an ECR to include in the refined message. Multiples can be delimited by a comma. Valid LOINC codes for sections are:

        46240-8: Encounters--Hospitalizations+outpatient visits narrative

        10164-2: History of present illness

        11369-6: History of immunizations

        29549-3: Medications administered

        18776-5: Plan of treatment: Care plan

        11450-4: Problem--Reported list

        29299-5: Reason for visit

        30954-2: Results--Diagnostic tests/laboratory data narrative

        29762-2: Social history--Narrative

        
Conditions To Include (string) or Conditions To Include (null) (Conditions To Include)

The SNOMED condition codes to use to search for relevant clinical services in the ECR. Multiples can be delimited by a comma.

Responses

Response samples

Content type
application/json
"<ClinicalDocument xmlns=\"urn:hl7-org:v3\">...</ClinicalDocument>"