Skip to content

Commit

Permalink
Add golden patient data (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertandremitchell authored Oct 15, 2024
2 parents ce6371a + c9a4812 commit 9f49050
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/container-tefca-viewer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ jobs:
- name: Playwright Tests
working-directory: ./containers/${{env.CONTAINER}}
run: npx playwright test e2e --reporter=list --config playwright.config.ts
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-results
path: ./containers/${{env.CONTAINER}}/test-results/
14 changes: 9 additions & 5 deletions containers/tefca-viewer/e2e/query_workflow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// @ts-check

import { test, expect } from "@playwright/test";
import { TEST_URL } from "../playwright-setup";

test.describe("querying with the TryTEFCA viewer", () => {
test.beforeEach(async ({ page }) => {
// Start every test on our main landing page
await page.goto("http://localhost:3000/tefca-viewer");
await page.goto(TEST_URL);
});

test("landing page loads", async ({ page }) => {
Expand Down Expand Up @@ -86,6 +87,7 @@ test.describe("querying with the TryTEFCA viewer", () => {
await page.getByLabel("Medical Record Number").fill("18091");
await page.getByLabel("Phone Number").fill("5555555555");
await page.getByRole("button", { name: "Search for patient" }).click();
await expect(page.getByText("Loading")).toHaveCount(0, { timeout: 10000 });

// Make sure we have a results page with a single patient
// Non-interactive 'div' elements in the table should be located by text
Expand Down Expand Up @@ -136,15 +138,16 @@ test.describe("querying with the TryTEFCA viewer", () => {

// Among verification, make sure phone number is right
await page.getByRole("button", { name: "Search for patient" }).click();
await expect(page.getByText("Loading")).toHaveCount(0, { timeout: 10000 });
await expect(
page.getByRole("heading", { name: "Patient Record" }),
).toBeVisible();
await expect(page.getByText("Patient Name")).toBeVisible();
await expect(page.getByText("Veronica Anne Blackstone")).toBeVisible();
await expect(page.getByText("Hyper A. Unlucky")).toBeVisible();
await expect(page.getByText("Contact")).toBeVisible();
await expect(page.getByText("937-379-3497")).toBeVisible();
await expect(page.getByText("517-425-1398")).toBeVisible();
await expect(page.getByText("Patient Identifiers")).toBeVisible();
await expect(page.getByText("34972316")).toBeVisible();
await expect(page.getByText("8692756")).toBeVisible();
});

test("social determinants query with generalized function", async ({
Expand All @@ -167,8 +170,9 @@ test.describe("querying with the TryTEFCA viewer", () => {
await page.getByRole("button", { name: "Go to the demo" }).click();
await page.getByLabel("Query", { exact: true }).selectOption("chlamydia");
await page.getByRole("button", { name: "Fill fields" }).click();
await page.getByLabel("Phone Number").fill("");
await page.getByRole("button", { name: "Search for patient" }).click();
await expect(page.getByText("Loading")).toHaveCount(0, { timeout: 10000 });

await expect(
page.getByRole("heading", { name: "Patient Record" }),
).toBeVisible();
Expand Down
3 changes: 2 additions & 1 deletion containers/tefca-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "docker compose -f docker-compose-dev.yaml up -d && next dev",
"dev-win": "start docker compose -f docker-compose-dev.yaml up && next dev",
"dev:db": "docker compose -f docker-compose-dev.yaml up",
"dev:next": "dotenv -e ./tefca.env.local -e ./tefca.env -- next dev",
"dev:next": "dotenv -e ./.env -- next dev",
"setup-local-env": "./setup-env.sh",
"build": "next build && cp -r .next/static .next/standalone/.next && cp -r public .next/standalone/",
"start": "NODE_TLS_REJECT_UNAUTHORIZED=0 node .next/standalone/server.js",
Expand All @@ -17,6 +17,7 @@
"test:unit:watch": "jest --watch",
"test:integration": "jest --testPathPattern=tests/integration",
"test:playwright": "docker compose build --no-cache && docker compose up -d && npx playwright test --reporter=list",
"test:playwright:local": "dotenv -e ./.env -- npx playwright test --ui",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
Expand Down
22 changes: 16 additions & 6 deletions containers/tefca-viewer/playwright-setup.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
/**
*
*/

export const TEST_URL =
process.env.TEST_ENV ?? "http://localhost:3000/tefca-viewer";

/**
*
*/
async function globalSetup() {
const url = "http://localhost:3000/tefca-viewer";
const maxRetries = 300; // Maximum number of retries
const delay = 1000; // Delay between retries in milliseconds

for (let attempts = 0; attempts < maxRetries; attempts++) {
try {
const response = await fetch(url); // Fetch the URL
const response = await fetch(TEST_URL); // Fetch the TEST_URL
if (response.status === 200) {
console.log(`Connected to ${url} successfully.`);
console.log(`Connected to ${TEST_URL} successfully.`);
return; // Exit the function if the webpage loads successfully
} else {
console.log(
`Failed to connect to ${url}, status: ${response.status}. Retrying...`,
`Failed to connect to ${TEST_URL}, status: ${response.status}. Retrying...`,
);
// Wait before the next attempt
await new Promise((resolve) => setTimeout(resolve, delay));
}
} catch (error) {
console.log(
`Fetch failed for ${url}: ${(error as Error).message}. Retrying...`,
`Fetch failed for ${TEST_URL}: ${
(error as Error).message
}. Retrying...`,
);
await new Promise((resolve) => setTimeout(resolve, delay));
}
// Wait before the next attempt
await new Promise((resolve) => setTimeout(resolve, delay));
}

throw new Error(`Unable to connect to ${url} after ${maxRetries} attempts.`);
throw new Error(
`Unable to connect to ${TEST_URL} after ${maxRetries} attempts.`,
);
}

export default globalSetup;
1 change: 1 addition & 0 deletions containers/tefca-viewer/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default defineConfig({

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
video: "on-first-retry",
},

/* Configure projects for major browsers */
Expand Down
82 changes: 37 additions & 45 deletions containers/tefca-viewer/src/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const FhirServers = [
"HELIOS Meld: eHealthExchange",
"JMC Meld: Direct",
"JMC Meld: eHealthExchange",
"Public HAPI: eHealthExchange",
"Public HAPI: Direct",
"OpenEpic: eHealthExchange",
"CernerHelios: eHealthExchange",
"OPHDST Meld: Direct",
Expand Down Expand Up @@ -90,37 +90,46 @@ export type PatientType =
| "social-determinants"
| "sti-syphilis-positive";

/*
* Common "Hyper Unlucky" patient data used for all non-newborn screening use cases
*/
const hyperUnluckyPatient: DemoDataFields = {
FirstName: "Hyper",
LastName: "Unlucky",
DOB: "1975-12-06",
MRN: "8692756",
Phone: "517-425-1398",
FhirServer: "Public HAPI: Direct",
UseCase: "cancer", // UseCase will be updated per case
};

/*
Demo patient data used to populate the form fields with each value being a type of DemoDataFields
*/
export const demoData: Record<PatientType, DemoDataFields> = {
cancer: {
FirstName: "Lee",
LastName: "Shaw",
DOB: "1975-12-06",
MRN: "8692756",
Phone: "517-425-1398",
FhirServer: "HELIOS Meld: Direct",
UseCase: "cancer",
},
"sti-chlamydia-positive": {
FirstName: "Chlamydia",
LastName: "JMC",
DOB: "2001-05-07",
MRN: "b50z-wayszq-ofib",
Phone: "",
FhirServer: "JMC Meld: Direct",
UseCase: "chlamydia",
},
"sti-gonorrhea-positive": {
FirstName: "GC",
LastName: "JMC",
DOB: "1998-05-31",
MRN: "JMC-1002",
Phone: "",
FhirServer: "JMC Meld: Direct",
UseCase: "gonorrhea",
cancer: { ...hyperUnluckyPatient, UseCase: "cancer" },
"sti-chlamydia-positive": { ...hyperUnluckyPatient, UseCase: "chlamydia" },
"sti-gonorrhea-positive": { ...hyperUnluckyPatient, UseCase: "gonorrhea" },
"social-determinants": {
...hyperUnluckyPatient,
UseCase: "social-determinants",
},
"sti-syphilis-positive": { ...hyperUnluckyPatient, UseCase: "syphilis" },

// Newborn screening data remains unchanged
// We need to figure how to display specific cases for specific referral, fail, pass
// "newborn-screening-technical-fail": {
// ...hyperUnluckyPatient,
// UseCase: "newborn-screening",
// },
// "newborn-screening-referral": {
// ...hyperUnluckyPatient,
// UseCase: "newborn-screening",
// },
// "newborn-screening-pass": {
// ...hyperUnluckyPatient,
// UseCase: "newborn-screening",
// },
"newborn-screening-technical-fail": {
FirstName: "Mango",
LastName: "Smith",
Expand Down Expand Up @@ -148,26 +157,9 @@ export const demoData: Record<PatientType, DemoDataFields> = {
FhirServer: "CernerHelios: eHealthExchange",
UseCase: "newborn-screening",
},
"social-determinants": {
FirstName: "Veronica",
LastName: "Blackstone",
DOB: "1998-06-18",
MRN: "34972316",
Phone: "937-379-3497",
FhirServer: "HELIOS Meld: Direct",
UseCase: "social-determinants",
},
"sti-syphilis-positive": {
FirstName: "Veronica",
LastName: "Blackstone",
DOB: "1998-06-18",
MRN: "34972316",
Phone: "937-379-3497",
FhirServer: "HELIOS Meld: Direct",
UseCase: "syphilis",
},
};

// Define Option type
type Option = {
value: string;
label: string;
Expand Down
11 changes: 7 additions & 4 deletions containers/tefca-viewer/src/app/fhir-servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ type FHIR_SERVER_CONFIG = {
*/
export const fhirServers: Record<FHIR_SERVERS, FHIR_SERVER_CONFIG> = {
"HELIOS Meld: Direct": {
hostname: "https://gw.interop.community/HeliosConnectathonSa/open/",
hostname: "https://gw.interop.community/HeliosConnectathonSa/open",
init: {} as RequestInit,
},
"HELIOS Meld: eHealthExchange": configureEHX("MeldOpen"),
"JMC Meld: Direct": {
hostname: "https://gw.interop.community/JMCHeliosSTISandbox/open/",
hostname: "https://gw.interop.community/JMCHeliosSTISandbox/open",
init: {} as RequestInit,
},
"JMC Meld: eHealthExchange": configureEHX("JMCHelios"),
"Public HAPI: eHealthExchange": configureEHX("PublicHAPI"),
"Public HAPI: Direct": {
hostname: "https://hapi.fhir.org/baseR4",
init: {} as RequestInit,
},
"OpenEpic: eHealthExchange": configureEHX("OpenEpic"),
"CernerHelios: eHealthExchange": configureEHX("CernerHelios"),
"OPHDST Meld: Direct": {
hostname: "https://gw.interop.community/CDCSepHL7Connectatho/open/",
hostname: "https://gw.interop.community/CDCSepHL7Connectatho/open",
init: {} as RequestInit,
},
};
Expand Down
2 changes: 1 addition & 1 deletion containers/tefca-viewer/src/app/query-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async function patientQuery(
queryResponse: QueryResponse,
): Promise<void> {
// Query for patient
let query = "Patient?";
let query = "/Patient?";
if (request.first_name) {
query += `given=${request.first_name}&`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const SearchForm: React.FC<SearchFormProps> = ({
const [firstName, setFirstName] = useState<string>("");
const [lastName, setLastName] = useState<string>("");
const [fhirServer, setFhirServer] = useState<FHIR_SERVERS>();
// "Public HAPI: Direct",
const [phone, setPhone] = useState<string>("");
const [dob, setDOB] = useState<string>("");
const [mrn, setMRN] = useState<string>("");
Expand Down Expand Up @@ -248,6 +249,7 @@ const SearchForm: React.FC<SearchFormProps> = ({
name="fhir_server"
value={fhirServer}
defaultValue={""}
// defaultValue={"Public HAPI: Direct"}
onChange={(event) => {
setFhirServer(event.target.value as FHIR_SERVERS);
}}
Expand Down

0 comments on commit 9f49050

Please sign in to comment.