Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jan 22, 2025
1 parent f07933a commit 5752e41
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
36 changes: 18 additions & 18 deletions query-connector/e2e/query_workflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ test.describe("querying with the Query Connector", () => {

// Better luck next time, user!
await expect(
page.getByRole("heading", { name: "No Records Found" })
page.getByRole("heading", { name: "No Records Found" }),
).toBeVisible();
await expect(
page.getByText("No records were found for your search")
page.getByText("No records were found for your search"),
).toBeVisible();
await page
.getByRole("link", { name: "Revise your patient search" })
Expand All @@ -47,13 +47,13 @@ test.describe("querying with the Query Connector", () => {
const alert = page.locator(".custom-alert");
await expect(alert).toBeVisible();
await expect(alert).toHaveText(
"This site is for demo purposes only. Please do not enter PII on this website."
"This site is for demo purposes only. Please do not enter PII on this website.",
);
await expect(
page.getByRole("heading", {
name: PAGE_TITLES["search"].title,
exact: true,
})
}),
).toBeVisible();

await page.getByRole("button", { name: "Fill fields" }).click();
Expand All @@ -68,7 +68,7 @@ test.describe("querying with the Query Connector", () => {

await page.getByRole("link", { name: "Select patient" }).click();
await expect(
page.getByRole("heading", { name: "Select a query" })
page.getByRole("heading", { name: "Select a query" }),
).toBeVisible();
await page
.getByTestId("Select")
Expand All @@ -82,10 +82,10 @@ test.describe("querying with the Query Connector", () => {
// dev can have a note to help debug.
await page.getByRole("button", { name: "Customize Query" }).click();
await expect(
page.getByRole("heading", { name: "Customize Query" })
page.getByRole("heading", { name: "Customize Query" }),
).toBeVisible();
await expect(
page.getByText("0 labs found, 0 medications found, 0 conditions found.")
page.getByText("0 labs found, 0 medications found, 0 conditions found."),
).not.toBeVisible();
await page.getByText("Return to Select query").click();

Expand All @@ -95,27 +95,27 @@ test.describe("querying with the Query Connector", () => {
// Make sure we have a results page with a single patient
// Non-interactive 'div' elements in the table should be located by text
await expect(
page.getByRole("heading", { name: "Patient Record" })
page.getByRole("heading", { name: "Patient Record" }),
).toBeVisible();
await expect(page.getByText("Patient Name")).toBeVisible();
await expect(page.getByText(TEST_PATIENT_NAME)).toBeVisible();
await expect(page.getByText("Patient Identifiers")).toBeVisible();
await expect(
page.getByText(`Medical Record Number: ${TEST_PATIENT.MRN}`)
page.getByText(`Medical Record Number: ${TEST_PATIENT.MRN}`),
).toBeVisible();

// Check that the info alert is visible and has updated to the correct text
const alert2 = page.locator(".custom-alert");
await expect(alert2).toBeVisible();
await expect(alert2).toHaveText(
`${CONTACT_US_DISCLAIMER_TEXT} ${CONTACT_US_DISCLAIMER_EMAIL}`
`${CONTACT_US_DISCLAIMER_TEXT} ${CONTACT_US_DISCLAIMER_EMAIL}`,
);

await expect(
page.getByRole("button", { name: "Observations", expanded: true })
page.getByRole("button", { name: "Observations", expanded: true }),
).toBeVisible();
await expect(
page.getByRole("button", { name: "Medication Requests", expanded: true })
page.getByRole("button", { name: "Medication Requests", expanded: true }),
).toBeVisible();

// We can also just directly ask the page to find us the number of rows
Expand All @@ -125,21 +125,21 @@ test.describe("querying with the Query Connector", () => {
page
.getByRole("table")
.filter({ hasText: "Chlamydia trachomatis DNA" })
.getByRole("row")
.getByRole("row"),
).toHaveCount(14);
// Encounters
await expect(
page
.getByRole("table")
.filter({ hasText: "Sexual overexposure" })
.getByRole("row")
.getByRole("row"),
).toHaveCount(5);
// Conditions + Medication Requests (Reason Code)
await expect(
page
.getByRole("table")
.filter({ hasText: "Chlamydial infection, unspecified" })
.getByRole("row")
.getByRole("row"),
).toHaveCount(10);
// Diagnostic Reports
await expect(
Expand All @@ -148,14 +148,14 @@ test.describe("querying with the Query Connector", () => {
.filter({
hasText: "Chlamydia trachomatis and Neisseria gonorrhoeae DNA panel",
})
.getByRole("row")
.getByRole("row"),
).toHaveCount(4);
// Medication Requests
await expect(
page
.getByRole("table")
.filter({ hasText: "azithromycin 1000 MG" })
.getByRole("row")
.getByRole("row"),
).toHaveCount(7);

// Now let's use the return to search to go back to a blank form
Expand All @@ -164,7 +164,7 @@ test.describe("querying with the Query Connector", () => {
page.getByRole("heading", {
name: PAGE_TITLES["search"].title,
exact: true,
})
}),
).toBeVisible();
});
});
24 changes: 12 additions & 12 deletions query-connector/src/app/query-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export type FhirQueryResponse = Awaited<ReturnType<typeof makeFhirQuery>>;
async function queryEncounters(
patientId: string,
fhirClient: FHIRClient,
queryResponse: QueryResponse
queryResponse: QueryResponse,
): Promise<QueryResponse> {
if (queryResponse.Condition && queryResponse.Condition.length > 0) {
const conditionId = queryResponse.Condition[0].id;
Expand All @@ -85,7 +85,7 @@ async function queryEncounters(
async function patientQuery(
request: QueryRequest,
fhirClient: FHIRClient,
queryResponse: QueryResponse
queryResponse: QueryResponse,
): Promise<void> {
// Query for patient
let query = "/Patient?";
Expand Down Expand Up @@ -125,7 +125,7 @@ async function patientQuery(
console.error(
`Patient search failed. Status: ${response.status} \n Body: ${
response.text
} \n Headers: ${JSON.stringify(response.headers.raw())}`
} \n Headers: ${JSON.stringify(response.headers.raw())}`,
);
}
queryResponse = await parseFhirSearch(response, queryResponse);
Expand All @@ -142,7 +142,7 @@ async function patientQuery(
export async function makeFhirQuery(
request: QueryRequest,
queryValueSets: DibbsValueSet[],
queryResponse: QueryResponse = {}
queryResponse: QueryResponse = {},
): Promise<QueryResponse> {
const fhirServerConfigs = await getFhirServerConfigs();
const fhirClient = new FHIRClient(request.fhir_server, fhirServerConfigs);
Expand All @@ -162,7 +162,7 @@ export async function makeFhirQuery(
queryValueSets,
patientId,
fhirClient,
queryResponse
queryResponse,
);

return queryResponse;
Expand All @@ -186,7 +186,7 @@ async function generalizedQuery(
queryValueSets: DibbsValueSet[],
patientId: string,
fhirClient: FHIRClient,
queryResponse: QueryResponse
queryResponse: QueryResponse,
): Promise<QueryResponse> {
const querySpec = await formatValueSetsAsQuerySpec(queryName, queryValueSets);
const builtQuery = new CustomQuery(querySpec, patientId);
Expand Down Expand Up @@ -219,7 +219,7 @@ async function generalizedQuery(
*/
export async function parseFhirSearch(
response: fetch.Response | Array<fetch.Response>,
queryResponse: Record<string, FhirResource[]> = {}
queryResponse: Record<string, FhirResource[]> = {},
): Promise<QueryResponse> {
let resourceArray: FhirResource[] = [];
// let resourceIds: string[] = [];
Expand Down Expand Up @@ -258,7 +258,7 @@ export async function parseFhirSearch(
* @returns - The array of resources from the response.
*/
export async function processFhirResponse(
response: fetch.Response
response: fetch.Response,
): Promise<FhirResource[]> {
let resourceArray: FhirResource[] = [];
let resourceIds: string[] = [];
Expand All @@ -269,7 +269,7 @@ export async function processFhirResponse(
for (const entry of body.entry) {
if (!isFhirResource(entry.resource)) {
console.error(
"Entry in FHIR resource response parsing was of unexpected shape"
"Entry in FHIR resource response parsing was of unexpected shape",
);
}
// Add the resource only if the ID is unique to the resources being returned for the query
Expand All @@ -289,7 +289,7 @@ export async function processFhirResponse(
* @returns - The FHIR Bundle of queried data.
*/
export async function createBundle(
queryResponse: QueryResponse
queryResponse: QueryResponse,
): Promise<APIQueryResponse> {
const bundle: Bundle = {
resourceType: "Bundle",
Expand Down Expand Up @@ -318,7 +318,7 @@ export async function createBundle(
*/
export async function testFhirServerConnection(
url: string,
bearerToken?: string
bearerToken?: string,
) {
try {
const baseUrl = url.replace(/\/$/, "");
Expand Down Expand Up @@ -364,7 +364,7 @@ export async function testFhirServerConnection(
{
resourceType: data.resourceType,
type: data.type,
}
},
);
return {
success: false,
Expand Down

0 comments on commit 5752e41

Please sign in to comment.