Skip to content

Commit

Permalink
Merge branch 'main' into rob/2646-align-patient-info-population-betwe…
Browse files Browse the repository at this point in the history
…en-design-and-dev
  • Loading branch information
robertandremitchell authored Oct 11, 2024
2 parents dd21f02 + afe1e0a commit b5940ed
Show file tree
Hide file tree
Showing 29 changed files with 55 additions and 185,083 deletions.
656 changes: 0 additions & 656 deletions containers/ecr-viewer/seed-scripts/baseECR/KY/Patient1/CDA_RR.xml

This file was deleted.

6,291 changes: 0 additions & 6,291 deletions containers/ecr-viewer/seed-scripts/baseECR/KY/Patient1/CDA_eICR.xml

This file was deleted.

651 changes: 0 additions & 651 deletions containers/ecr-viewer/seed-scripts/baseECR/KY/Patient2/CDA_RR.xml

This file was deleted.

20,979 changes: 0 additions & 20,979 deletions containers/ecr-viewer/seed-scripts/baseECR/KY/Patient2/CDA_eICR.xml

This file was deleted.

612 changes: 0 additions & 612 deletions containers/ecr-viewer/seed-scripts/baseECR/ME/Patient1/CDA_RR.xml

This file was deleted.

10,451 changes: 0 additions & 10,451 deletions containers/ecr-viewer/seed-scripts/baseECR/ME/Patient1/CDA_eICR.xml

This file was deleted.

704 changes: 0 additions & 704 deletions containers/ecr-viewer/seed-scripts/baseECR/ME/Patient2/CDA_RR.xml

This file was deleted.

46,666 changes: 0 additions & 46,666 deletions containers/ecr-viewer/seed-scripts/baseECR/ME/Patient2/CDA_eICR.xml

This file was deleted.

795 changes: 0 additions & 795 deletions containers/ecr-viewer/seed-scripts/baseECR/ME/Patient3/CDA_RR.xml

This file was deleted.

18,206 changes: 0 additions & 18,206 deletions containers/ecr-viewer/seed-scripts/baseECR/ME/Patient3/CDA_eICR.xml

This file was deleted.

896 changes: 0 additions & 896 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn1/CDA_RR.xml

This file was deleted.

11,869 changes: 0 additions & 11,869 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn1/CDA_eICR.xml

This file was deleted.

475 changes: 0 additions & 475 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn2/CDA_RR.xml

This file was deleted.

9,017 changes: 0 additions & 9,017 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn2/CDA_eICR.xml

This file was deleted.

532 changes: 0 additions & 532 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn3/CDA_RR.xml

This file was deleted.

11,441 changes: 0 additions & 11,441 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn3/CDA_eICR.xml

This file was deleted.

558 changes: 0 additions & 558 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn4/CDA_RR.xml

This file was deleted.

9,994 changes: 0 additions & 9,994 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn4/CDA_eICR.xml

This file was deleted.

1,009 changes: 0 additions & 1,009 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn5/CDA_RR.xml

This file was deleted.

20,574 changes: 0 additions & 20,574 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn5/CDA_eICR.xml

This file was deleted.

653 changes: 0 additions & 653 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn6/CDA_RR.xml

This file was deleted.

5,926 changes: 0 additions & 5,926 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn6/CDA_eICR.xml

This file was deleted.

668 changes: 0 additions & 668 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn7/CDA_RR.xml

This file was deleted.

5,447 changes: 0 additions & 5,447 deletions containers/ecr-viewer/seed-scripts/baseECR/TN/tn7/CDA_eICR.xml

This file was deleted.

2 changes: 1 addition & 1 deletion containers/ecr-viewer/seed-scripts/create-seed-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def convert_files():
:return: A list of fhir bundles
"""
print("Converting files...")
subfolders = ["LA", "TN", "ME", "KY"]
subfolders = ["LA"]
# Iterate over the subfolders
for subfolder in subfolders:
subfolder_path = os.path.join(BASEDIR, "baseECR", subfolder)
Expand Down
28 changes: 17 additions & 11 deletions containers/tefca-viewer/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
## Getting Started with TEFCA Viewer
## Getting Started with Query Connector

### Introduction

The DIBBs TEFCA Viewer app offers a REST API for searching for a patient and viewng information tied to your case investigation.
The DIBBs Query Connector app offers a REST API for searching for a patient and viewing information tied to your case investigation.

### Running TEFCA Viewer
### Running Query Connector

The TEFCA Viewer app can be run using Docker (or any other OCI container runtime e.g., Podman), or directly from the Node.js source code.
The Query Connector app can be run using Docker (or any other OCI container runtime e.g., Podman), or directly from the Node.js source code.

#### Obtaining an eRSD API Key

Before running the Query Connector locally, you will need to obtain an API key for the electronic Reporting and Surveillance Distribution (eRSD). With the API key, you have access to 200+ pre-built queries for reportable conditions, e.g., chlamydia, influenza, hepatitis A, etc. These queries can be used and modified in the Query Connector app.

To obtain a free API key, please visit https://ersd.aimsplatform.org/#/api-keys and follow the sign up instructions. Add your API key as an environment variable called `ERSD_API_KEY` in an `.env` file that can be accessed when running the Query Connector app.

#### Running with Docker (Recommended)

To run the TEFCA Viewer app with Docker, follow these steps.
To run the Query Connector app 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](https://docs.docker.com/get-docker/) to install Docker.

Expand All @@ -23,21 +29,21 @@ Docker version 20.10.21, build baeda1f
1. If you're using an M1 Mac, you'll need to tell Docker to pull the non-Apple Silicon image using `docker pull --platform linux/amd64 ghcr.io/cdcgov/phdi/tefca-viewer:latest` since we don't have a image for Apple Silicon. If you're using this setup, there might be some issues with architecture incompatability that the team hasn't run into, so please flag if you run into something!
3. Run the service with `docker run -p 3000:3000 tefca-viewer:latest`. If you're on a Windows machine, you may need to run `docker run -p 3000:3000 ghcr.io/cdcgov/phdi/tefca-viewer:latest` instead.

Congratulations, the TEFCA Viewer app should now be running on `localhost:3000/tefca-viewer`!
Congratulations, the Query Connector app should now be running on `localhost:3000/tefca-viewer`!

#### Running from Node.js Source Code

We recommend running the TEFCA Viewer app from a container, but if that is not feasible for a given use-case, it may also be run directly from Node using the steps below.
We recommend running the Query Connector app from a container, but if that is not feasible for a given use-case, it may also be run directly from Node using the steps below.

1. Ensure that both Git and Node 18.x or higher are installed.
2. Clone the PHDI repository with `git clone https://github.com/CDCgov/phdi`.
3. Navigate to `/phdi/containers/tefca-viewer/`.
4. Install all of the Node dependencies for the TEFCA Viewer app with `npm install`.
5. Run the TEFCA Viewer app on `localhost:3000` with `npm run dev`. If you are on a Windows Machine, you may need to run `npm run dev-win` instead.
4. Install all of the Node dependencies for the Query Connector app with `npm install`.
5. Run the Query Connector app on `localhost:3000` with `npm run dev`. If you are on a Windows Machine, you may need to run `npm run dev-win` instead.

### Building the Docker Image

To build the Docker image for the TEFCA Viewer app from source instead of downloading it from the PHDI repository follow these steps.
To build the Docker image for the Query Connector app from source instead of downloading it from the PHDI repository follow these steps.

1. Ensure that both [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker](https://docs.docker.com/get-docker/) are installed.
2. Clone the PHDI repository with `git clone https://github.com/CDCgov/phdi`.
Expand All @@ -46,7 +52,7 @@ To build the Docker image for the TEFCA Viewer app from source instead of downlo

### Running via docker-compose (WIP)

The TEFCA Viewer will eventually require other inputs from other DIBBs services. For now, this is a simplified docker compose file that starts the Node service. This can be run with `docker compose up --build`. See the [Docker Compose documentation](https://docs.docker.com/engine/reference/commandline/compose_up/) for additional information.
The Query Connector will eventually require other inputs from other DIBBs services. For now, this is a simplified docker compose file that starts the Node service. This can be run with `docker compose up --build`. See the [Docker Compose documentation](https://docs.docker.com/engine/reference/commandline/compose_up/) for additional information.

### Developer Documentation

Expand Down
2 changes: 2 additions & 0 deletions containers/tefca-viewer/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
- POSTGRES_DB=tefca_db
# Note: you must have a local .env file with the DATABASE_URL set to the following:
# DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db
# Note: you must have a local .env file with the ERSD_API_KEY set to a key
# obtained from the ERSD API at https://ersd.aimsplatform.org/#/api-keys
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 2s
Expand Down
2 changes: 2 additions & 0 deletions containers/tefca-viewer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ services:
environment:
- NODE_ENV=production
- DATABASE_URL=postgres://postgres:pw@db:5432/tefca_db
# Note: you must have a local .env file with the ERSD_API_KEY set to a key
# obtained from the ERSD API at https://ersd.aimsplatform.org/#/api-keys
depends_on:
db:
condition: service_healthy
34 changes: 33 additions & 1 deletion containers/tefca-viewer/src/app/database-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use server";
import { Pool, PoolConfig, QueryResultRow } from "pg";
// import dotenv from "dotenv";
import { Bundle, OperationOutcome } from "fhir/r4";
import { ValueSetItem, valueSetTypeToClincalServiceTypeMap } from "./constants";

const getQuerybyNameSQL = `
Expand Down Expand Up @@ -87,3 +87,35 @@ export const mapQueryRowsToValueSetItems = async (rows: QueryResultRow[]) => {
});
return vsItems;
};

/*
* The expected return type from the eRSD API.
*/
type ErsdResponse = Bundle | OperationOutcome;

/**
* Fetches the eRSD Specification from the eRSD API. This function requires an API key
* to access the eRSD API. The API key can be obtained at https://ersd.aimsplatform.org/#/api-keys.
* @param eRSDVersion - The version of the eRSD specification to retrieve. Defaults to v2.
* @returns The eRSD Specification as a FHIR Bundle or an OperationOutcome if an error occurs.
*/
export async function getERSD(eRSDVersion: number = 2): Promise<ErsdResponse> {
const ERSD_API_KEY = process.env.ERSD_API_KEY;
const eRSDUrl = `https://ersd.aimsplatform.org/api/ersd/v${eRSDVersion}specification?format=json&api-key=${ERSD_API_KEY}`;
const response = await fetch(eRSDUrl);
if (response.status === 200) {
const data = (await response.json()) as Bundle;
return data;
} else {
return {
resourceType: "OperationOutcome",
issue: [
{
severity: "error",
code: "processing",
diagnostics: `Failed to retrieve data from eRSD: ${response.status} ${response.statusText}`,
},
],
} as OperationOutcome;
}
}

0 comments on commit b5940ed

Please sign in to comment.