diff --git a/frontend/src/app/commonComponents/TestResultsList.tsx b/frontend/src/app/commonComponents/TestResultsList.tsx index 8f29a239ae..bff495f2bb 100644 --- a/frontend/src/app/commonComponents/TestResultsList.tsx +++ b/frontend/src/app/commonComponents/TestResultsList.tsx @@ -33,6 +33,7 @@ const diseaseResultTitlePxpMap: Record = { [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 = { @@ -45,6 +46,7 @@ const diseaseResultReportingAppMap: Record = { [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) => { diff --git a/frontend/src/app/supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedChlamydia.ts b/frontend/src/app/supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedChlamydia.ts new file mode 100644 index 0000000000..6bffd238a2 --- /dev/null +++ b/frontend/src/app/supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedChlamydia.ts @@ -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; diff --git a/frontend/src/app/testQueue/TestCard/TestCard.test.tsx b/frontend/src/app/testQueue/TestCard/TestCard.test.tsx index 50a053a838..3b403cde2a 100644 --- a/frontend/src/app/testQueue/TestCard/TestCard.test.tsx +++ b/frontend/src/app/testQueue/TestCard/TestCard.test.tsx @@ -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"; @@ -71,6 +71,8 @@ import { baseStiAoeUpdateMock, device10Id, device10Name, + chlamydiaDeviceId, + chlamydiaDeviceName, } from "../testCardTestConstants"; import { QueriedFacility } from "../TestCardForm/types"; import mockSupportedDiseaseMultiplex, { @@ -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"; @@ -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(); @@ -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)); @@ -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?" @@ -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?" @@ -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 () { @@ -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 () { @@ -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, @@ -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 () { diff --git a/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx b/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx index 0952cb6071..5f960d3f4a 100644 --- a/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx +++ b/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx @@ -5,6 +5,8 @@ import { MockedProvider } from "@apollo/client/testing"; import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../../testResults/constants"; import { asymptomaticTestOrderInfo, + chlamydiaDeviceId, + chlamydiaDeviceName, covidDeviceId, covidDeviceName, devicesMap, @@ -225,6 +227,24 @@ describe("TestCardForm", () => { expect(await renderTestCardForm({ props })).toMatchSnapshot(); }); + + it("matches snapshot for chlamydia device", async () => { + const props = { + ...testProps, + testOrder: { + ...testProps.testOrder, + results: [{ testResult: "POSITIVE", disease: { name: "CHLAMYDIA" } }], + deviceType: { + internalId: chlamydiaDeviceId, + name: chlamydiaDeviceName, + model: chlamydiaDeviceName, + testLength: 15, + }, + }, + }; + + expect(await renderTestCardForm({ props })).toMatchSnapshot(); + }); }); describe("error handling", () => { diff --git a/frontend/src/app/testQueue/TestCardForm/TestCardForm.tsx b/frontend/src/app/testQueue/TestCardForm/TestCardForm.tsx index fa7c10a166..389551b7bd 100644 --- a/frontend/src/app/testQueue/TestCardForm/TestCardForm.tsx +++ b/frontend/src/app/testQueue/TestCardForm/TestCardForm.tsx @@ -27,6 +27,7 @@ import { TestCorrectionReasons, } from "../../testResults/viewResults/actionMenuModals/TestResultCorrectionModal"; import { + chlamydiaSymptomDefinitions, gonorrheaSymptomDefinitions, hepatitisCSymptomDefinitions, PregnancyCode, @@ -640,6 +641,23 @@ const TestCardForm = ({ /> )} + {whichAoeFormOption === AOEFormOption.CHLAMYDIA && ( +
+ { + dispatch({ + type: TestFormActionCase.UPDATE_AOE_RESPONSES, + payload: responses, + }); + }} + diseaseSymptomDefinitions={chlamydiaSymptomDefinitions} + diseaseNameForFormIds={"chlamydia"} + /> +
+ )}
+ + + + + * + + + +
+
+
+
+ + +
+
+ +
+
+
+
+

+ This device doesn't have any supported disease tests configured. Please ask your organization admin to add the correct test. +

+
+
+
+
+
+
+
+
+
+ + + + +
+ + +   + + + + + +
+
+
+ + Selected [object Object] + +
+
+
+
+
+
+
+
+ + Is the patient pregnant? + + + * + + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+
+
+ + Is the patient currently experiencing or showing signs of symptoms? + + + * + + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+ +