Skip to content

Commit

Permalink
Add Chlamydia support to test card (#8389)
Browse files Browse the repository at this point in the history
* Add chlamydiaEnabled feature flag

* Add test card support for chlamydia

* Move chlamydia consts
  • Loading branch information
mpbrown authored Jan 10, 2025
1 parent 61ec02e commit 0f28f34
Show file tree
Hide file tree
Showing 14 changed files with 1,730 additions and 114 deletions.
2 changes: 2 additions & 0 deletions frontend/src/app/commonComponents/TestResultsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const diseaseResultTitlePxpMap: Record<MULTIPLEX_DISEASES, string> = {
[MULTIPLEX_DISEASES.SYPHILIS]: "constants.diseaseResultTitle.SYPHILIS",
[MULTIPLEX_DISEASES.HEPATITIS_C]: "constants.diseaseResultTitle.HEPATITIS_C",
[MULTIPLEX_DISEASES.GONORRHEA]: "constants.diseaseResultTitle.GONORRHEA",
[MULTIPLEX_DISEASES.CHLAMYDIA]: "constants.diseaseResultTitle.CHLAMYDIA",
};

const diseaseResultReportingAppMap: Record<MULTIPLEX_DISEASES, string> = {
Expand All @@ -45,6 +46,7 @@ const diseaseResultReportingAppMap: Record<MULTIPLEX_DISEASES, string> = {
[MULTIPLEX_DISEASES.SYPHILIS]: "constants.disease.SYPHILIS",
[MULTIPLEX_DISEASES.HEPATITIS_C]: "constants.disease.HEPATITIS_C",
[MULTIPLEX_DISEASES.GONORRHEA]: "constants.disease.GONORRHEA",
[MULTIPLEX_DISEASES.CHLAMYDIA]: "constants.disease.CHLAMYDIA",
};

const setResult = (result: string, t: translateFn) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const mockSupportedDiseaseTestPerformedChlamydia = [
{
supportedDisease: {
internalId: "6517fcbd-e094-4384-9eef-a5c7f373a015",
loinc: "LP14298-1",
name: "Chlamydia",
},
testPerformedLoincCode: "80124-8",
equipmentUid: "ChlamydiaEquipmentUid123",
testkitNameId: "ChlamydiaTestkitNameId123",
testOrderedLoincCode: "80124-8",
},
];

export default mockSupportedDiseaseTestPerformedChlamydia;
263 changes: 151 additions & 112 deletions frontend/src/app/testQueue/TestCard/TestCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
within,
} from "@testing-library/react";
import moment from "moment";
import userEvent from "@testing-library/user-event";
import userEvent, { UserEvent } from "@testing-library/user-event";
import * as flaggedMock from "flagged";

import { getAppInsights } from "../../TelemetryService";
Expand Down Expand Up @@ -71,6 +71,8 @@ import {
baseStiAoeUpdateMock,
device10Id,
device10Name,
chlamydiaDeviceId,
chlamydiaDeviceName,
} from "../testCardTestConstants";
import { QueriedFacility } from "../TestCardForm/types";
import mockSupportedDiseaseMultiplex, {
Expand All @@ -81,6 +83,7 @@ import mockSupportedDiseaseTestPerformedSyphilis from "../../supportAdmin/Device
import { UpdateTestOrderTimerStartedAtDocument } from "../../../generated/graphql";
import mockSupportedDiseaseTestPerformedHepatitisC from "../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedHepatitisC";
import mockSupportedDiseaseTestPerformedGonorrhea from "../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedGonorrhea";
import mockSupportedDiseaseTestPerformedChlamydia from "../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedChlamydia";

import { TestCard, TestCardProps } from "./TestCard";

Expand Down Expand Up @@ -295,6 +298,21 @@ const facilityInfo: QueriedFacility = {
},
],
},
{
internalId: chlamydiaDeviceId,
name: chlamydiaDeviceName,
testLength: 15,
supportedDiseaseTestPerformed: [
...mockSupportedDiseaseTestPerformedChlamydia,
],
swabTypes: [
{
name: specimen3Name,
internalId: specimen3Id,
typeCode: "122555007",
},
],
},
],
};
export const devicesMap = new Map();
Expand Down Expand Up @@ -328,6 +346,49 @@ describe("TestCard", () => {
});
};

const expectRequiredAOEQuestionsForPositiveGenericSTI = async (
user: UserEvent
) => {
await user.click(
screen.getByLabelText("Positive", {
exact: false,
})
);

expect(screen.getByText("Is the patient pregnant?")).toBeInTheDocument();
expect(
screen.getByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).toBeInTheDocument();
expect(
screen.getByText("What is the gender of their sexual partners?")
).toBeInTheDocument();

const symptomFieldSet = screen.getByTestId(
`has-any-symptoms-${sharedTestOrderInfo.internalId}`
);
await user.click(within(symptomFieldSet).getByLabelText("Yes"));

expect(
screen.getByText("Select any symptoms the patient is experiencing")
).toBeInTheDocument();
};

const expectHiddenAOEQuestionsForNonPositiveGenericSTI = () => {
expect(
screen.queryByText("Is the patient pregnant?")
).not.toBeInTheDocument();
expect(
screen.queryByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).not.toBeInTheDocument();
expect(
screen.queryByText("What is the gender of their sexual partners?")
).not.toBeInTheDocument();
};

const devicesMap = new Map();
facilityInfo.deviceTypes.map((d) => devicesMap.set(d.internalId, d));

Expand Down Expand Up @@ -1295,17 +1356,9 @@ describe("TestCard", () => {

await user.selectOptions(deviceDropdown, device8Name);
expect(screen.getByText("Syphilis result")).toBeInTheDocument();
expect(
screen.queryByText("Is the patient pregnant?")
).not.toBeInTheDocument();
expect(
screen.queryByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).not.toBeInTheDocument();
expect(
screen.queryByText("What is the gender of their sexual partners?")
).not.toBeInTheDocument();

expectHiddenAOEQuestionsForNonPositiveGenericSTI();

expect(
screen.queryByText(
"Has the patient been told they have syphilis before?"
Expand All @@ -1317,17 +1370,9 @@ describe("TestCard", () => {
exact: false,
})
);
expect(
screen.queryByText("Is the patient pregnant?")
).not.toBeInTheDocument();
expect(
screen.queryByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).not.toBeInTheDocument();
expect(
screen.queryByText("What is the gender of their sexual partners?")
).not.toBeInTheDocument();

expectHiddenAOEQuestionsForNonPositiveGenericSTI();

expect(
screen.queryByText(
"Has the patient been told they have syphilis before?"
Expand Down Expand Up @@ -1381,30 +1426,7 @@ describe("TestCard", () => {
await user.selectOptions(deviceDropdown, device9Name);
expect(screen.getByText("Hepatitis C result")).toBeInTheDocument();

await user.click(
screen.getByLabelText("Positive", {
exact: false,
})
);

expect(screen.getByText("Is the patient pregnant?")).toBeInTheDocument();
expect(
screen.getByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).toBeInTheDocument();
expect(
screen.getByText("What is the gender of their sexual partners?")
).toBeInTheDocument();

const symptomFieldSet = screen.getByTestId(
`has-any-symptoms-${sharedTestOrderInfo.internalId}`
);
await user.click(within(symptomFieldSet).getByLabelText("Yes"));

expect(
screen.getByText("Select any symptoms the patient is experiencing")
).toBeInTheDocument();
await expectRequiredAOEQuestionsForPositiveGenericSTI(user);
});

it("hides AOE questions when there is no positive Hepatitis C result", async function () {
Expand All @@ -1423,34 +1445,16 @@ describe("TestCard", () => {

await user.selectOptions(deviceDropdown, device9Name);
expect(screen.getByText("Hepatitis C result")).toBeInTheDocument();
expect(
screen.queryByText("Is the patient pregnant?")
).not.toBeInTheDocument();
expect(
screen.queryByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).not.toBeInTheDocument();
expect(
screen.queryByText("What is the gender of their sexual partners?")
).not.toBeInTheDocument();

expectHiddenAOEQuestionsForNonPositiveGenericSTI();

await user.click(
screen.getByLabelText("Inconclusive", {
exact: false,
})
);
expect(
screen.queryByText("Is the patient pregnant?")
).not.toBeInTheDocument();
expect(
screen.queryByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).not.toBeInTheDocument();
expect(
screen.queryByText("What is the gender of their sexual partners?")
).not.toBeInTheDocument();

expectHiddenAOEQuestionsForNonPositiveGenericSTI();
});

it("checks that Hep C submission only works if AOE questions are valid", async function () {
Expand Down Expand Up @@ -1550,38 +1554,91 @@ describe("TestCard", () => {
await user.selectOptions(deviceDropdown, device10Name);
expect(screen.getByText("Gonorrhea result")).toBeInTheDocument();

await expectRequiredAOEQuestionsForPositiveGenericSTI(user);
});

it("hides AOE questions when there is no positive Gonorrhea result", async function () {
mockDiseaseEnabledFlag("gonorrhea");

const mocks = [
generateEditQueueMock(
MULTIPLEX_DISEASES.GONORRHEA,
TEST_RESULTS.POSITIVE
),
blankUpdateAoeEventMock,
];

const { user } = await renderQueueItem({ mocks });
const deviceDropdown = await getDeviceTypeDropdown();

await user.selectOptions(deviceDropdown, device10Name);
expect(screen.getByText("Gonorrhea result")).toBeInTheDocument();
expectHiddenAOEQuestionsForNonPositiveGenericSTI();

await user.click(
screen.getByLabelText("Positive", {
screen.getByLabelText("Inconclusive", {
exact: false,
})
);

expect(screen.getByText("Is the patient pregnant?")).toBeInTheDocument();
expect(
screen.getByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).toBeInTheDocument();
expect(
screen.getByText("What is the gender of their sexual partners?")
).toBeInTheDocument();
expectHiddenAOEQuestionsForNonPositiveGenericSTI();
});

const symptomFieldSet = screen.getByTestId(
`has-any-symptoms-${sharedTestOrderInfo.internalId}`
it("shows radio buttons for Chlamydia when a Chlamydia device is chosen", async function () {
mockDiseaseEnabledFlag("chlamydia");

const mocks = [
generateEditQueueMock(
MULTIPLEX_DISEASES.CHLAMYDIA,
TEST_RESULTS.POSITIVE
),
blankUpdateAoeEventMock,
];

const { user } = await renderQueueItem({ mocks });
expect(screen.queryByText("Chlamydia result")).not.toBeInTheDocument();

const deviceDropdown = await getDeviceTypeDropdown();

await user.selectOptions(deviceDropdown, chlamydiaDeviceName);
expect(screen.getByText("Chlamydia result")).toBeInTheDocument();
});

it("shows required Chlamydia AOE questions when a positive Chlamydia result is present", async function () {
mockDiseaseEnabledFlag("chlamydia");

const mocks = [
generateEditQueueMock(
MULTIPLEX_DISEASES.CHLAMYDIA,
TEST_RESULTS.POSITIVE
),
blankUpdateAoeEventMock,
{
...baseStiAoeUpdateMock({
...NO_SYMPTOMS_FALSE_OVERRIDE,
}),
...mutationResponse,
},
];

const { user } = await renderQueueItem({ mocks });
const deviceDropdown = await getDeviceTypeDropdown();
expect(deviceDropdown.options.length).toEqual(
DEFAULT_DEVICE_OPTIONS_LENGTH + 1
);
await user.click(within(symptomFieldSet).getByLabelText("Yes"));

expect(
screen.getByText("Select any symptoms the patient is experiencing")
).toBeInTheDocument();
await user.selectOptions(deviceDropdown, chlamydiaDeviceName);
expect(screen.getByText("Chlamydia result")).toBeInTheDocument();

await expectRequiredAOEQuestionsForPositiveGenericSTI(user);
});

it("hides AOE questions when there is no positive Gonorrhea result", async function () {
mockDiseaseEnabledFlag("gonorrhea");
it("hides AOE questions when there is no positive Chlamydia result", async function () {
mockDiseaseEnabledFlag("chlamydia");

const mocks = [
generateEditQueueMock(
MULTIPLEX_DISEASES.GONORRHEA,
MULTIPLEX_DISEASES.CHLAMYDIA,
TEST_RESULTS.POSITIVE
),
blankUpdateAoeEventMock,
Expand All @@ -1590,36 +1647,18 @@ describe("TestCard", () => {
const { user } = await renderQueueItem({ mocks });
const deviceDropdown = await getDeviceTypeDropdown();

await user.selectOptions(deviceDropdown, device10Name);
expect(screen.getByText("Gonorrhea result")).toBeInTheDocument();
expect(
screen.queryByText("Is the patient pregnant?")
).not.toBeInTheDocument();
expect(
screen.queryByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).not.toBeInTheDocument();
expect(
screen.queryByText("What is the gender of their sexual partners?")
).not.toBeInTheDocument();
await user.selectOptions(deviceDropdown, chlamydiaDeviceName);
expect(screen.getByText("Chlamydia result")).toBeInTheDocument();

expectHiddenAOEQuestionsForNonPositiveGenericSTI();

await user.click(
screen.getByLabelText("Inconclusive", {
exact: false,
})
);
expect(
screen.queryByText("Is the patient pregnant?")
).not.toBeInTheDocument();
expect(
screen.queryByText(
"Is the patient currently experiencing or showing signs of symptoms?"
)
).not.toBeInTheDocument();
expect(
screen.queryByText("What is the gender of their sexual partners?")
).not.toBeInTheDocument();

expectHiddenAOEQuestionsForNonPositiveGenericSTI();
});

it("checks that submission only works if AOE questions are valid", async function () {
Expand Down
Loading

0 comments on commit 0f28f34

Please sign in to comment.