PHDI Validation Service (1.2.11)

Download OpenAPI specification:Download

Getting Started with the PHDI Validation Service

Introduction

The PHDI validation service offers a REST API for validating health care messages (e.g., whether health care messages are in the proper format and contain user-defined fields of interest).

Running the Validation Service

The validation service can be run using Docker (or any other OCI container runtime e.g., Podman), or directly from the Python source code.

To run the validation service with Docker follow these steps.

  1. Confirm that you have Docker installed by running docker -v. If you do not see a response similar to what is shown below, follow these instructions to install Docker.
    ❯ docker -v
    Docker version 20.10.21, build baeda1f
    
  2. Download a copy of the Docker image from the PHDI repository by running docker pull ghcr.io/cdcgov/phdi/validation:latest.
  3. Run the service with docker run -p 8080:8080 validation:latest.

Congratulations, the validation service should now be running on localhost:8080!

Running from Python Source Code

We recommend running the validation service from a container, but if that is not feasible for a given use case, it may also be run directly from Python using the steps below.

  1. Ensure that both Git and Python 3.10 or higher are installed.
  2. Clone the PHDI repository with git clone https://github.com/CDCgov/phdi.
  3. Navigate to /phdi/containers/validation/.
  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 PowerShell).
  6. Install all Python dependencies for the validation service with pip install -r requirements.txt into your virtual environment.
  7. Run the FHIR Converter 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 validation service from source code 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/phdi.
  3. Navigate to /phdi/containers/validation/.
  4. Run docker build -t validation ..

The API

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

Health Check

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

Responses

Response samples

Content type
application/json
{
  • "status": "OK"
}

Validate Endpoint

Check if the value presented in the 'message' key is a valid example of the type of message specified in the 'message_type'.

Request Body schema: application/json
message_type
required
string (Message Type)
Enum: "ecr" "elr" "vxu" "fhir"

The type of message to be validated.

include_error_types
required
string (Include Error Types)

A comma separated list of the types of errors that should be included in the return response. Valid types are fatal, errors, warnings, information

message
required
string (Message)

The message to be validated.

rr_data
string (Rr Data)

If validating an eICR message, the accompanying Reportability Response data.

Responses

Request samples

Content type
application/json
{
  • "message_type": "ecr",
  • "include_error_types": "string",
  • "message": "string",
  • "rr_data": "string"
}

Response samples

Content type
application/json
Example
{
  • "message_valid": "True",
  • "validation_results": {
    }
}