diff --git a/frontend/src/app/testQueue/TestCard/TestCard.test.tsx b/frontend/src/app/testQueue/TestCard/TestCard.test.tsx index 69682e038d..9cd50cd29c 100644 --- a/frontend/src/app/testQueue/TestCard/TestCard.test.tsx +++ b/frontend/src/app/testQueue/TestCard/TestCard.test.tsx @@ -14,38 +14,64 @@ import * as flaggedMock from "flagged"; import { getAppInsights } from "../../TelemetryService"; import * as srToast from "../../utils/srToast"; -import { PhoneType } from "../../../generated/graphql"; import SRToastContainer from "../../commonComponents/SRToastContainer"; import { TestCorrectionReason } from "../../testResults/viewResults/actionMenuModals/TestResultCorrectionModal"; import mockSupportedDiseaseCovid from "../mocks/mockSupportedDiseaseCovid"; -import mockSupportedDiseaseMultiplex, { - mockSupportedDiseaseFlu, -} from "../mocks/mockSupportedDiseaseMultiplex"; -import mockSupportedDiseaseTestPerformedHIV from "../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedHIV"; -import { QueriedFacility, QueriedTestOrder } from "../TestCardForm/types"; +import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../../testResults/constants"; +import { ONSET_DATE_LABEL } from "../../../patientApp/timeOfTest/constants"; +import { REQUIRED_AOE_QUESTIONS_BY_DISEASE } from "../TestCardForm/TestCardForm.utils"; import { - TEST_CARD_SYMPTOM_ONSET_DATE_STRING, - generateEditQueueMock, - generateEmptyEditQueueMock, + positiveGenerateMockOne, + firstCardSymptomUpdateMock, + secondCardSymptomUpdateMock, + positiveDeviceThreeEditMock, + secondTestOrder, + device3Id, + device3Name, + device1Name, + device2Name, + device4Name, + device5Name, + device6Name, + testOrderInfo, + DEFAULT_DEVICE_OPTIONS_LENGTH, + deletedDeviceId, + deletedDeviceName, + device1Id, + deletedSpecimenId, + device2Id, + specimen1Id, + device4Id, + device5Id, + specimen2Name, + specimen2Id, + device7Name, + device8Name, generateSubmitQueueMock, blankUpdateAoeEventMock, + generateEditQueueMock, + generateEmptyEditQueueMock, falseNoSymptomWithSymptomOnsetUpdateAoeMock, falseNoSymptomAoeMock, + TEST_CARD_SYMPTOM_ONSET_DATE_STRING, updateSyphilisAoeMocks, + sharedTestOrderInfo, BLURRED_VISION_LITERAL, -} from "../TestCardForm/testUtils/submissionMocks"; -import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../../testResults/constants"; -import { ONSET_DATE_LABEL } from "../../../patientApp/timeOfTest/constants"; + specimen1Name, + device6Id, + device7Id, + specimen3Name, + specimen3Id, + device8Id, +} from "../testCardTestConstants"; +import { QueriedFacility } from "../TestCardForm/types"; +import mockSupportedDiseaseMultiplex, { + mockSupportedDiseaseFlu, +} from "../mocks/mockSupportedDiseaseMultiplex"; +import mockSupportedDiseaseTestPerformedHIV from "../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedHIV"; import mockSupportedDiseaseTestPerformedSyphilis from "../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedSyphilis"; -import { sharedTestOrderInfo } from "../TestCardForm/testUtils/testConstants"; -import { REQUIRED_AOE_QUESTIONS_BY_DISEASE } from "../TestCardForm/TestCardForm.utils"; import { TestCard, TestCardProps } from "./TestCard"; -import { - positiveGenerateMockOne, - firstCardSymptomUpdateMock, - secondCardSymptomUpdateMock, -} from "./testMocks"; jest.mock("../../TelemetryService", () => ({ getAppInsights: jest.fn(), @@ -72,39 +98,6 @@ const updatedTimeString = "10:05"; const setStartTestPatientIdMock = jest.fn(); -// 6 instead of 7 because HIV devices are filtered out when HIV feature flag is disabled -const DEFAULT_DEVICE_OPTIONS_LENGTH = 6; - -const device1Name = "LumiraDX"; -const device2Name = "Abbott BinaxNow"; -const device3Name = "BD Veritor"; -const device4Name = "Multiplex"; -const device5Name = "MultiplexAndCovidOnly"; -const device6Name = "FluOnly"; -const device7Name = "HIV device"; -const device8Name = "Syphilis device"; - -const device1Id = "DEVICE-1-ID"; -const device2Id = "DEVICE-2-ID"; -const device3Id = "DEVICE-3-ID"; -const device4Id = "DEVICE-4-ID"; -const device5Id = "DEVICE-5-ID"; -const device6Id = "DEVICE-6-ID"; -const device7Id = "DEVICE-7-ID"; -const device8Id = "DEVICE-8-ID"; - -const deletedDeviceId = "DELETED-DEVICE-ID"; -const deletedDeviceName = "Deleted"; - -const specimen1Name = "Swab of internal nose"; -const specimen1Id = "SPECIMEN-1-ID"; -const specimen2Name = "Nasopharyngeal swab"; -const specimen2Id = "SPECIMEN-2-ID"; -const specimen3Name = "Venous blood specimen"; -const specimen3Id = "SPECIMEN-3-ID"; - -const deletedSpecimenId = "DELETED-SPECIMEN-ID"; - const getDeviceTypeDropdown = async () => (await screen.findByTestId("device-type-dropdown")) as HTMLSelectElement; @@ -114,214 +107,167 @@ async function getSpecimenTypeDropdown() { )) as HTMLSelectElement; } -describe("TestCard", () => { - let nowFn = Date.now; - let store: MockStoreEnhanced; - let alertSpy: jest.SpyInstance; - const mockStore = configureStore([]); - const trackEventMock = jest.fn(); - const removePatientFromQueueMock = jest.fn(); - const trackMetricMock = jest.fn(); - const trackExceptionMock = jest.fn(); - - const testOrderInfo: QueriedTestOrder = { - internalId: "1b02363b-ce71-4f30-a2d6-d82b56a91b39", - dateAdded: "2022-11-08 13:33:07.503", - symptoms: - '{"64531003":"false","103001002":"false","84229001":"false","68235000":"false","426000000":"false","49727002":"false","68962001":"false","422587007":"false","267036007":"false","62315008":"false","43724002":"false","36955009":"false","44169009":"false","422400008":"false","230145002":"false","25064002":"false","162397003":"false"}', - symptomOnset: null, - noSymptoms: true, - deviceType: { +const facilityInfo: QueriedFacility = { + id: "f02cfff5-1921-4293-beff-e2a5d03e1fda", + name: "Testing Site", + deviceTypes: [ + { internalId: device1Id, name: device1Name, - model: "LumiraDx SARS-CoV-2 Ag Test*", testLength: 15, + supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], }, - specimenType: { - internalId: specimen1Id, - name: specimen1Name, - typeCode: "445297001", + { + internalId: device2Id, + name: device2Name, + testLength: 15, + supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + ], + }, + { + internalId: device3Id, + name: device3Name, + testLength: 15, + supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], }, - patient: { - internalId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", - telephone: "(571) 867-5309", - birthDate: "2015-09-20", - firstName: "Althea", - middleName: "Hedda Mclaughlin", - lastName: "Dixon", - gender: "refused", - testResultDelivery: null, - preferredLanguage: null, - email: "sywaporoce@mailinator.com", - emails: ["sywaporoce@mailinator.com"], - phoneNumbers: [ + { + internalId: device4Id, + name: device4Name, + testLength: 15, + supportedDiseaseTestPerformed: mockSupportedDiseaseMultiplex, + swabTypes: [ { - type: PhoneType.Mobile, - number: "(553) 223-0559", + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", }, { - type: PhoneType.Landline, - number: "(669) 789-0799", + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", }, ], }, - results: [], - dateTested: null, - correctionStatus: "ORIGINAL", - reasonForCorrection: null, - }; + { + internalId: device5Id, + name: device5Name, + testLength: 15, + supportedDiseaseTestPerformed: [ + ...mockSupportedDiseaseFlu, + { + supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, + testPerformedLoincCode: "123456", + testOrderedLoincCode: "445566", + }, + { + supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, + testPerformedLoincCode: "123456", + testOrderedLoincCode: "778899", + }, + ], + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], + }, + { + internalId: device6Id, + name: device6Name, + testLength: 15, + supportedDiseaseTestPerformed: [...mockSupportedDiseaseFlu], + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], + }, + { + internalId: device7Id, + name: device7Name, + testLength: 15, + supportedDiseaseTestPerformed: [...mockSupportedDiseaseTestPerformedHIV], + swabTypes: [ + { + name: specimen3Name, + internalId: specimen3Id, + typeCode: "122555007", + }, + ], + }, + { + internalId: device8Id, + name: device8Name, + testLength: 15, + supportedDiseaseTestPerformed: [ + ...mockSupportedDiseaseTestPerformedSyphilis, + ], + swabTypes: [ + { + name: specimen3Name, + internalId: specimen3Id, + typeCode: "122555007", + }, + ], + }, + ], +}; +export const devicesMap = new Map(); +facilityInfo.deviceTypes.map((d) => devicesMap.set(d.internalId, d)); - const facilityInfo: QueriedFacility = { - id: "f02cfff5-1921-4293-beff-e2a5d03e1fda", - name: "Testing Site", - deviceTypes: [ - { - internalId: device1Id, - name: device1Name, - testLength: 15, - supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: device2Id, - name: device2Name, - testLength: 15, - supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - ], - }, - { - internalId: device3Id, - name: device3Name, - testLength: 15, - supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: device4Id, - name: device4Name, - testLength: 15, - supportedDiseaseTestPerformed: mockSupportedDiseaseMultiplex, - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: device5Id, - name: device5Name, - testLength: 15, - supportedDiseaseTestPerformed: [ - ...mockSupportedDiseaseFlu, - { - supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, - testPerformedLoincCode: "123456", - testOrderedLoincCode: "445566", - }, - { - supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, - testPerformedLoincCode: "123456", - testOrderedLoincCode: "778899", - }, - ], - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: device6Id, - name: device6Name, - testLength: 15, - supportedDiseaseTestPerformed: [...mockSupportedDiseaseFlu], - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: device7Id, - name: device7Name, - testLength: 15, - supportedDiseaseTestPerformed: [ - ...mockSupportedDiseaseTestPerformedHIV, - ], - swabTypes: [ - { - name: specimen3Name, - internalId: specimen3Id, - typeCode: "122555007", - }, - ], - }, - { - internalId: device8Id, - name: device8Name, - testLength: 15, - supportedDiseaseTestPerformed: [ - ...mockSupportedDiseaseTestPerformedSyphilis, - ], - swabTypes: [ - { - name: specimen3Name, - internalId: specimen3Id, - typeCode: "122555007", - }, - ], - }, - ], - }; +describe("TestCard", () => { + let nowFn = Date.now; + let store: MockStoreEnhanced; + let alertSpy: jest.SpyInstance; + const mockStore = configureStore([]); + const trackEventMock = jest.fn(); + const removePatientFromQueueMock = jest.fn(); + const trackMetricMock = jest.fn(); + const trackExceptionMock = jest.fn(); const DEFAULT_DEVICE_ORDER = [ device1Name, @@ -362,7 +308,8 @@ describe("TestCard", () => { async function renderQueueItem( { props, mocks }: testRenderProps = { props: testProps, mocks: [] } ) { - props = props || testProps; + const renderProps = props || testProps; + const { container } = render( <> @@ -376,19 +323,20 @@ describe("TestCard", () => { showWarnings={false} > ); + return { container, user: userEvent.setup() }; } @@ -415,9 +363,6 @@ describe("TestCard", () => { jest.spyOn(console, "error").mockRestore(); jest.spyOn(global.Math, "random").mockRestore(); alertSpy.mockRestore(); - }); - - afterAll(() => { jest.restoreAllMocks(); }); @@ -691,7 +636,7 @@ describe("TestCard", () => { const mocks = [ generateEditQueueMock( MULTIPLEX_DISEASES.COVID_19, - TEST_RESULTS.POSITIVE + TEST_RESULTS.UNDETERMINED ), generateSubmitQueueMock( MULTIPLEX_DISEASES.COVID_19, @@ -767,7 +712,11 @@ describe("TestCard", () => { it("updates custom test date/time", async () => { const { user } = await renderQueueItem({ - mocks: [generateEmptyEditQueueMock()], + mocks: [ + generateEmptyEditQueueMock({ + dateTested: new Date().toISOString(), + }), + ], }); const toggle = await screen.findByLabelText("Current date and time"); await user.click(toggle); @@ -907,15 +856,8 @@ describe("TestCard", () => { const mocks = [ generateEditQueueMock( MULTIPLEX_DISEASES.COVID_19, - TEST_RESULTS.POSITIVE, - { - device: { - deviceId: device4Id, - deviceName: device4Name, - }, - } + TEST_RESULTS.UNDETERMINED ), - generateSubmitQueueMock( MULTIPLEX_DISEASES.COVID_19, TEST_RESULTS.UNDETERMINED @@ -1417,60 +1359,9 @@ describe("TestCard", () => { describe("regression test", () => { it("test card checkboxes don't conflict with each other", async () => { // https://github.com/CDCgov/prime-simplereport/issues/7768 - const secondTestOrder: QueriedTestOrder = { - internalId: "01c807c9-d42b-45c7-aa9f-1fd290eb2fdf", - dateAdded: "2024-06-05 22:03:12.205", - symptoms: - '{"64531003":"true","103001002":"false","84229001":"false","68235000":"false","426000000":"false","49727002":"false","68962001":"true","422587007":"true","267036007":"false","62315008":"false","43724002":"false","36955009":"false","44169009":"false","422400008":"false","230145002":"false","25064002":"false","162397003":"false"}', - symptomOnset: null, - noSymptoms: true, - deviceType: { - internalId: device3Id, - name: device3Name, - model: "LumiraDx SARS-CoV-2 Ag Test*", - testLength: 15, - }, - specimenType: { - internalId: specimen1Id, - name: specimen1Name, - typeCode: "445297001", - }, - patient: { - internalId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", - telephone: "(571) 867-5309", - birthDate: "2015-09-20", - firstName: "Althea", - middleName: "Hedda Mclaughlin", - lastName: "Dixon", - gender: "refused", - testResultDelivery: null, - preferredLanguage: null, - email: "sywaporoce@mailinator.com", - emails: ["sywaporoce@mailinator.com"], - phoneNumbers: [ - { - type: PhoneType.Mobile, - number: "(553) 223-0559", - }, - { - type: PhoneType.Landline, - number: "(669) 789-0799", - }, - ], - }, - results: [], - dateTested: null, - correctionStatus: "ORIGINAL", - reasonForCorrection: null, - }; const secondTestProps: TestCardProps = { - refetchQueue: jest.fn().mockReturnValue(null), + ...testProps, testOrder: secondTestOrder, - facility: facilityInfo, - devicesMap: devicesMap, - startTestPatientId: "", - setStartTestPatientId: setStartTestPatientIdMock, - removePatientFromQueue: removePatientFromQueueMock, }; const firstCardMocks = [ @@ -1483,7 +1374,9 @@ describe("TestCard", () => { const secondCardMocks = [ falseNoSymptomAoeMock, secondCardSymptomUpdateMock, + positiveDeviceThreeEditMock, ]; + await renderQueueItem({ props: secondTestProps, mocks: secondCardMocks }); // set up test card one diff --git a/frontend/src/app/testQueue/TestCard/testMocks.ts b/frontend/src/app/testQueue/TestCard/testMocks.ts deleted file mode 100644 index 2ba67ce5bf..0000000000 --- a/frontend/src/app/testQueue/TestCard/testMocks.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { - baseUpdateAoeMutationRequest, - generateEditQueueMock, - mutationResponse, - NO_SYMPTOMS_FALSE_OVERRIDE, -} from "../TestCardForm/testUtils/submissionMocks"; -import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../../testResults/constants"; - -const FIRST_CARD_SYMPTOM_OVERRIDE = { - symptoms: - '{"25064002":false,"36955009":false,"43724002":true,"44169009":false,"49727002":false,"62315008":false,"64531003":false,"68235000":false,"68962001":false,"84229001":false,"103001002":false,"162397003":false,"230145002":false,"261665006":false,"267036007":false,"422400008":false,"422587007":false,"426000000":false}', -}; - -const SECOND_CARD_SYMPTOM_OVERRIDE = { - symptoms: - '{"25064002":false,"36955009":false,"43724002":true,"44169009":false,"49727002":false,"62315008":false,"64531003":true,"68235000":false,"68962001":true,"84229001":false,"103001002":false,"162397003":false,"230145002":false,"261665006":false,"267036007":false,"422400008":false,"422587007":true,"426000000":false}', -}; - -export const firstCardSymptomUpdateMock = { - ...baseUpdateAoeMutationRequest({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...FIRST_CARD_SYMPTOM_OVERRIDE, - }), - ...mutationResponse, -}; - -export const secondCardSymptomUpdateMock = { - ...baseUpdateAoeMutationRequest({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...SECOND_CARD_SYMPTOM_OVERRIDE, - }), - ...mutationResponse, -}; - -export const positiveGenerateMockOne = generateEditQueueMock( - MULTIPLEX_DISEASES.COVID_19, - TEST_RESULTS.POSITIVE -); diff --git a/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx b/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx index 65ff041e3f..5b4a7995b2 100644 --- a/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx +++ b/frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx @@ -3,8 +3,6 @@ import userEvent from "@testing-library/user-event"; import { MockedProvider } from "@apollo/client/testing"; import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../../testResults/constants"; - -import TestCardForm, { TestCardFormProps } from "./TestCardForm"; import { asymptomaticTestOrderInfo, covidDeviceId, @@ -13,14 +11,16 @@ import { facilityInfo, fluDeviceId, fluDeviceName, + generateSubmitQueueMock, hivDeviceId, hivDeviceName, multiplexDeviceId, multiplexDeviceName, syphilisDeviceId, syphilisDeviceName, -} from "./testUtils/testConstants"; -import { generateSubmitQueueMock } from "./testUtils/submissionMocks"; +} from "../testCardTestConstants"; + +import TestCardForm, { TestCardFormProps } from "./TestCardForm"; jest.mock("../../TelemetryService", () => ({ getAppInsights: jest.fn(), @@ -285,42 +285,6 @@ describe("TestCardForm", () => { ).not.toBeInTheDocument(); }); - it("shows where tests results are sent modal", async () => { - const props = { - ...testProps, - testOrder: { - ...testProps.testOrder, - results: [{ testResult: "POSITIVE", disease: { name: "COVID-19" } }], - }, - }; - - const { user } = await renderTestCardForm({ - props, - mocks: [ - generateSubmitQueueMock( - MULTIPLEX_DISEASES.COVID_19, - TEST_RESULTS.POSITIVE, - { - device: { - deviceId: covidDeviceId, - }, - } - ), - ], - }); - - await user.click(screen.getByText("Where results are sent")); - - expect( - screen.getByText("Where are SimpleReport test results sent?") - ).toBeInTheDocument(); - - await user.click(screen.getByText("Got it")); - expect( - screen.queryByText("Where are SimpleReport test results sent?") - ).not.toBeInTheDocument(); - }); - it("shows sensitive topics modal", async () => { const props = { ...testProps, diff --git a/frontend/src/app/testQueue/TestCardForm/TestCardForm.utils.test.tsx b/frontend/src/app/testQueue/TestCardForm/TestCardForm.utils.test.tsx index 8b1eae8002..4cb8947cd7 100644 --- a/frontend/src/app/testQueue/TestCardForm/TestCardForm.utils.test.tsx +++ b/frontend/src/app/testQueue/TestCardForm/TestCardForm.utils.test.tsx @@ -1,10 +1,11 @@ +import { devicesMap } from "../testCardTestConstants"; + import { TestFormState } from "./TestCardFormReducer"; import { AOEFormOption, AoeValidationErrorMessages, generateAoeValidationState, } from "./TestCardForm.utils"; -import { devicesMap } from "./testUtils/testConstants"; describe("TestCardForm.utils", () => { describe("areAOEAnswersComplete", () => { diff --git a/frontend/src/app/testQueue/TestCardForm/testUtils/submissionMocks.ts b/frontend/src/app/testQueue/TestCardForm/testUtils/submissionMocks.ts deleted file mode 100644 index 401a58f372..0000000000 --- a/frontend/src/app/testQueue/TestCardForm/testUtils/submissionMocks.ts +++ /dev/null @@ -1,349 +0,0 @@ -import { - EditQueueItemDocument, - SubmitQueueItemDocument, - SubmitQueueItemMutationVariables, - UpdateAoeDocument, - UpdateAoeMutationVariables, -} from "../../../../generated/graphql"; -import { - MULTIPLEX_DISEASES, - TEST_RESULTS, -} from "../../../testResults/constants"; - -import { - device1Id, - specimen1Id, - sharedTestOrderInfo, - symptomaticTestOrderInfo, -} from "./testConstants"; - -export const BLURRED_VISION_LITERAL = "Blurred vision"; -export const TEST_CARD_SYMPTOM_ONSET_DATE_STRING = "2024-05-14"; - -export const NO_SYMPTOMS_FALSE_OVERRIDE = { noSymptoms: false }; -const NO_SYMPTOMS_TRUE_OVERRIDE = { noSymptoms: true }; - -const PREGNANCY_OVERRIDE = { pregnancy: "77386006" }; -const COUGH_OVERRIDE = { - symptoms: - '{"25064002":false,"36955009":false,"43724002":false,"44169009":false,"49727002":true,"62315008":false,"64531003":false,"68235000":false,"68962001":false,"84229001":false,"103001002":false,"162397003":false,"230145002":false,"267036007":false,"422400008":false,"422587007":false,"426000000":false}', -}; -const SYMPTOM_ONSET_DATE_OVERRIDE = { - symptomOnset: TEST_CARD_SYMPTOM_ONSET_DATE_STRING, -}; -const SYPHILIS_HISTORY_OVERRIDE = { syphilisHistory: "1087151000119108" }; -const GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE = { - genderOfSexualPartners: ["female"], -}; -const BLURRED_VISION_OVERRIDE = { - symptoms: - '{"15188001":false,"26284000":false,"46636008":true,"56940005":false,"68225006":false,"91554004":false,"195469007":false,"266128007":false,"724386005":false}', -}; - -export const baseUpdateAoeMutationRequest = ( - variableOverrides?: Partial -) => { - return { - request: { - query: UpdateAoeDocument, - variables: { - patientId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", - symptoms: "{}", - symptomOnset: null, - genderOfSexualPartners: null, - ...variableOverrides, - }, - }, - }; -}; - -export const mutationResponse = { - result: { - data: { - testResult: { - internalId: "a4581a50-6f00-4bc1-b713-b190f282eabb", - __typename: "Test Result", - }, - deliverySuccess: true, - testEventId: "07c330a2-99b6-4dad-9fef-5c37773847b3", - __typename: "Test Event", - }, - }, -}; - -export const blankUpdateAoeEventMock = { - ...baseUpdateAoeMutationRequest(), - ...mutationResponse, -}; - -export const falseNoSymptomAoeMock = { - ...baseUpdateAoeMutationRequest({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - }), - ...mutationResponse, -}; - -export const falseNoSymptomWithSymptomOnsetUpdateAoeMock = { - ...baseUpdateAoeMutationRequest({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...SYMPTOM_ONSET_DATE_OVERRIDE, - }), - ...mutationResponse, -}; - -const updatePregnancyAoeEventMock = { - ...baseUpdateAoeMutationRequest({ - ...PREGNANCY_OVERRIDE, - }), - ...mutationResponse, -}; - -const updateSymptomAoeEventMock = { - ...baseUpdateAoeMutationRequest({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - }), - ...mutationResponse, -}; -const updateCoughSymptomAoeEventMock = { - ...baseUpdateAoeMutationRequest({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...COUGH_OVERRIDE, - }), - ...mutationResponse, -}; - -const updateOnsetSymptomDateAoeEventMock = { - ...baseUpdateAoeMutationRequest({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...COUGH_OVERRIDE, - ...SYMPTOM_ONSET_DATE_OVERRIDE, - }), - ...mutationResponse, -}; - -export const updateAoeMocks = [ - updatePregnancyAoeEventMock, - updateSymptomAoeEventMock, - updateCoughSymptomAoeEventMock, - updateOnsetSymptomDateAoeEventMock, -]; - -// Syphilis card -const baseSyphilisAoeUpdateMock = ( - variableOverrides?: Partial -) => { - return { - ...baseUpdateAoeMutationRequest({ - genderOfSexualPartners: [], - ...variableOverrides, - }), - ...mutationResponse, - }; -}; -const yesSyphilisHistoryMock = { - ...baseSyphilisAoeUpdateMock({ - ...SYPHILIS_HISTORY_OVERRIDE, - }), -}; - -const yesSyphilisHistoryPregnancyMock = { - ...baseSyphilisAoeUpdateMock({ - ...SYPHILIS_HISTORY_OVERRIDE, - ...PREGNANCY_OVERRIDE, - }), - ...mutationResponse, -}; - -const yesSyphilisHistoryPregnancyFemaleSexPartnerMock = { - ...baseSyphilisAoeUpdateMock({ - ...SYPHILIS_HISTORY_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, - }), - ...mutationResponse, -}; - -const falseNoSymptomOnsetDateBlankSymptomsAndYesSyphilisAoeMock = { - ...baseSyphilisAoeUpdateMock({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...SYPHILIS_HISTORY_OVERRIDE, - ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, - }), - ...mutationResponse, -}; - -const falseNoSymptomBlurredVisionMockAndYesSyphilisAoeMock = { - ...baseSyphilisAoeUpdateMock({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...SYPHILIS_HISTORY_OVERRIDE, - ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, - ...BLURRED_VISION_OVERRIDE, - }), - ...mutationResponse, -}; - -const falseNoSymptomBlurredVisionOnsetDateAndYesSyphilisAoeMock = { - ...baseSyphilisAoeUpdateMock({ - ...NO_SYMPTOMS_FALSE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...SYPHILIS_HISTORY_OVERRIDE, - ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, - ...BLURRED_VISION_OVERRIDE, - ...SYMPTOM_ONSET_DATE_OVERRIDE, - }), - ...mutationResponse, -}; - -const noSymptomsTrueSymptomsBlankSyphilisHistory = { - ...baseSyphilisAoeUpdateMock({ - ...NO_SYMPTOMS_TRUE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...SYPHILIS_HISTORY_OVERRIDE, - }), - ...mutationResponse, -}; - -const noSymptomsTrueSymptomsBlankSyphilisFemaleHistory = { - ...baseSyphilisAoeUpdateMock({ - ...NO_SYMPTOMS_TRUE_OVERRIDE, - ...PREGNANCY_OVERRIDE, - ...SYPHILIS_HISTORY_OVERRIDE, - ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, - }), - ...mutationResponse, -}; - -export const updateSyphilisAoeMocks = [ - blankUpdateAoeEventMock, - generateEditQueueMock(MULTIPLEX_DISEASES.SYPHILIS, TEST_RESULTS.POSITIVE, { - device: { - deviceId: "DEVICE-8-ID", - }, - specimen: { - specimenId: "SPECIMEN-3-ID", - }, - }), - generateSubmitQueueMock(MULTIPLEX_DISEASES.SYPHILIS, TEST_RESULTS.POSITIVE, { - device: { - deviceId: "DEVICE-8-ID", - }, - specimen: { - specimenId: "SPECIMEN-3-ID", - }, - }), - yesSyphilisHistoryMock, - yesSyphilisHistoryPregnancyMock, - yesSyphilisHistoryPregnancyFemaleSexPartnerMock, - falseNoSymptomBlurredVisionMockAndYesSyphilisAoeMock, - falseNoSymptomBlurredVisionOnsetDateAndYesSyphilisAoeMock, - falseNoSymptomOnsetDateBlankSymptomsAndYesSyphilisAoeMock, - noSymptomsTrueSymptomsBlankSyphilisHistory, - noSymptomsTrueSymptomsBlankSyphilisFemaleHistory, -]; - -type EditQueueMockParams = { - diseaseResults?: - | [] - | [{ diseaseName: MULTIPLEX_DISEASES; testResult: TEST_RESULTS }]; - dateTested?: string; - device?: { - deviceName?: string; - deviceId: string; - supportedDiseases?: { - internalId: string; - loinc: string; - name: MULTIPLEX_DISEASES; - }[]; - }; - specimen?: { - specimenName?: string; - specimenId: string; - }; -}; - -export function generateEmptyEditQueueMock() { - // dummy covid unknown submission that's overrided by the empty array - return generateEditQueueMock( - MULTIPLEX_DISEASES.COVID_19, - TEST_RESULTS.UNKNOWN, - { - diseaseResults: [], - } - ); -} - -export function generateEditQueueMock( - disease: MULTIPLEX_DISEASES, - testResult: TEST_RESULTS, - overrideParams?: EditQueueMockParams -) { - return { - request: { - query: EditQueueItemDocument, - variables: { - id: sharedTestOrderInfo?.internalId, - deviceTypeId: overrideParams?.device?.deviceId ?? device1Id, - specimenTypeId: overrideParams?.specimen?.specimenId ?? specimen1Id, - results: overrideParams?.diseaseResults ?? [ - { - diseaseName: disease, - testResult: testResult, - }, - ], - dateTested: overrideParams?.dateTested ?? null, - }, - }, - result: { - data: { - editQueueItem: { - results: overrideParams?.diseaseResults, - }, - dateTested: overrideParams?.dateTested, - deviceType: { - internalId: overrideParams?.device?.deviceId ?? device1Id, - testLength: 15, - }, - }, - }, - }; -} - -type SubmitQueueMockParams = EditQueueMockParams & { - deliverySuccess?: boolean; -}; - -export function generateSubmitQueueMock( - disease: MULTIPLEX_DISEASES, - testResult: TEST_RESULTS, - overrideParams?: SubmitQueueMockParams -) { - return { - request: { - query: SubmitQueueItemDocument, - variables: { - patientId: symptomaticTestOrderInfo?.patient.internalId, - deviceTypeId: overrideParams?.device?.deviceId ?? device1Id, - specimenTypeId: overrideParams?.specimen?.specimenId ?? specimen1Id, - results: overrideParams?.diseaseResults ?? [ - { diseaseName: disease, testResult: testResult }, - ], - dateTested: overrideParams?.dateTested ?? null, - } as SubmitQueueItemMutationVariables, - }, - result: { - data: { - submitQueueItem: { - testResult: { - internalId: symptomaticTestOrderInfo?.internalId, - }, - deliverySuccess: overrideParams?.deliverySuccess ?? true, - }, - }, - }, - }; -} diff --git a/frontend/src/app/testQueue/TestCardForm/testUtils/testConstants.ts b/frontend/src/app/testQueue/TestCardForm/testUtils/testConstants.ts deleted file mode 100644 index 3ec1a12ccf..0000000000 --- a/frontend/src/app/testQueue/TestCardForm/testUtils/testConstants.ts +++ /dev/null @@ -1,214 +0,0 @@ -import { QueriedFacility, QueriedTestOrder } from "../types"; -import mockSupportedDiseaseCovid from "../../mocks/mockSupportedDiseaseCovid"; -import mockSupportedDiseaseMultiplex, { - mockSupportedDiseaseFlu, -} from "../../mocks/mockSupportedDiseaseMultiplex"; -import { PhoneType } from "../../../../generated/graphql"; -import mockSupportedDiseaseTestPerformedSyphilis from "../../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedSyphilis"; -import mockSupportedDiseaseTestPerformedHIV from "../../../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedHIV"; - -import { TEST_CARD_SYMPTOM_ONSET_DATE_STRING } from "./submissionMocks"; - -export const covidDeviceName = "LumiraDX"; -export const multiplexDeviceName = "Multiplex"; -export const multiplexAndCovidOnlyDeviceName = "MultiplexAndCovidOnly"; -export const fluDeviceName = "FLU"; -export const hivDeviceName = "HIV"; - -export const covidDeviceId = "COVID-DEVICE-ID"; -export const multiplexDeviceId = "MULTIPLEX-DEVICE-ID"; -export const multiplexAndCovidOnlyDeviceId = "MULTIPLEX-COVID-DEVICE-ID"; -export const fluDeviceId = "FLU-DEVICE-ID"; -export const hivDeviceId = "HIV-DEVICE-ID"; - -export const device1Name = "LumiraDX"; -export const device1Id = "DEVICE-1-ID"; -export const specimen1Name = "Swab of internal nose"; -export const specimen1Id = "SPECIMEN-1-ID"; -export const specimen2Name = "Nasopharyngeal swab"; -export const specimen2Id = "SPECIMEN-2-ID"; -export const FACILITY_INFO_TEST_ID = "f02cfff5-1921-4293-beff-e2a5d03e1fda"; -export const syphilisDeviceName = "SYPHILIS"; -export const syphilisDeviceId = "SYPHILIS-DEVICE-ID"; - -export const facilityInfo: QueriedFacility = { - id: FACILITY_INFO_TEST_ID, - name: "Testing Site", - deviceTypes: [ - { - internalId: covidDeviceId, - name: covidDeviceName, - testLength: 15, - supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: multiplexDeviceId, - name: multiplexDeviceName, - testLength: 15, - supportedDiseaseTestPerformed: mockSupportedDiseaseMultiplex, - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: fluDeviceId, - name: fluDeviceName, - testLength: 15, - supportedDiseaseTestPerformed: [...mockSupportedDiseaseFlu], - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: multiplexAndCovidOnlyDeviceId, - name: multiplexAndCovidOnlyDeviceName, - testLength: 15, - supportedDiseaseTestPerformed: [ - ...mockSupportedDiseaseFlu, - { - supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, - testPerformedLoincCode: "123456", - testOrderedLoincCode: "445566", - }, - { - supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, - testPerformedLoincCode: "123456", - testOrderedLoincCode: "778899", - }, - ], - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - { - name: specimen2Name, - internalId: specimen2Id, - typeCode: "258500001", - }, - ], - }, - { - internalId: syphilisDeviceId, - name: syphilisDeviceName, - testLength: 15, - supportedDiseaseTestPerformed: [ - ...mockSupportedDiseaseTestPerformedSyphilis, - ], - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - ], - }, - { - internalId: hivDeviceId, - name: hivDeviceName, - testLength: 15, - supportedDiseaseTestPerformed: [...mockSupportedDiseaseTestPerformedHIV], - swabTypes: [ - { - name: specimen1Name, - internalId: specimen1Id, - typeCode: "445297001", - }, - ], - }, - ], -}; - -export const devicesMap = new Map(); -facilityInfo.deviceTypes.map((d) => devicesMap.set(d.internalId, d)); - -export const sharedTestOrderInfo = { - internalId: "1b02363b-ce71-4f30-a2d6-d82b56a91b39", - dateAdded: "2022-11-08 13:33:07.503", - deviceType: { - internalId: covidDeviceId, - name: covidDeviceName, - model: covidDeviceName, - testLength: 15, - }, - specimenType: { - internalId: specimen1Id, - name: specimen1Name, - typeCode: "445297001", - }, - patient: { - internalId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", - telephone: "(571) 867-5309", - birthDate: "2015-09-20", - firstName: "Althea", - middleName: "Hedda Mclaughlin", - lastName: "Dixon", - gender: "refused", - testResultDelivery: null, - preferredLanguage: null, - email: "sywaporoce@mailinator.com", - emails: ["sywaporoce@mailinator.com"], - phoneNumbers: [ - { - type: PhoneType.Mobile, - number: "(553) 223-0559", - }, - { - type: PhoneType.Landline, - number: "(669) 789-0799", - }, - ], - }, - results: [], - dateTested: null, - correctionStatus: "ORIGINAL", - reasonForCorrection: null, -}; - -export const asymptomaticTestOrderPartialInfo = { - symptoms: null, - symptomOnset: null, - noSymptoms: true, -}; -export const asymptomaticTestOrderInfo: QueriedTestOrder = { - ...sharedTestOrderInfo, - ...asymptomaticTestOrderPartialInfo, -}; -export const symptomaticTestOrderInfo: QueriedTestOrder = { - ...sharedTestOrderInfo, - symptoms: - '{"64531003":"false","103001002":"false","84229001":"false","68235000":"false","426000000":"false","49727002":"false","68962001":"false","422587007":"false","267036007":"false","62315008":"false","43724002":"false","36955009":"false","44169009":"false","422400008":"false","230145002":"false","25064002":"false","162397003":"false"}', - symptomOnset: TEST_CARD_SYMPTOM_ONSET_DATE_STRING, - noSymptoms: false, -}; diff --git a/frontend/src/app/testQueue/testCardTestConstants.ts b/frontend/src/app/testQueue/testCardTestConstants.ts new file mode 100644 index 0000000000..21c0a25db6 --- /dev/null +++ b/frontend/src/app/testQueue/testCardTestConstants.ts @@ -0,0 +1,714 @@ +import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../testResults/constants"; +import { + EditQueueItemDocument, + PhoneType, + SubmitQueueItemDocument, + SubmitQueueItemMutationVariables, + UpdateAoeDocument, + UpdateAoeMutationVariables, +} from "../../generated/graphql"; +import mockSupportedDiseaseTestPerformedHIV from "../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedHIV"; +import mockSupportedDiseaseTestPerformedSyphilis from "../supportAdmin/DeviceType/mocks/mockSupportedDiseaseTestPerformedSyphilis"; + +import { QueriedFacility, QueriedTestOrder } from "./TestCardForm/types"; +import mockSupportedDiseaseCovid from "./mocks/mockSupportedDiseaseCovid"; +import mockSupportedDiseaseMultiplex, { + mockSupportedDiseaseFlu, +} from "./mocks/mockSupportedDiseaseMultiplex"; + +export const covidDeviceName = "LumiraDX"; +export const multiplexDeviceName = "Multiplex"; +export const multiplexAndCovidOnlyDeviceName = "MultiplexAndCovidOnly"; +export const fluDeviceName = "FLU"; +export const hivDeviceName = "HIV"; + +export const covidDeviceId = "COVID-DEVICE-ID"; +export const multiplexDeviceId = "MULTIPLEX-DEVICE-ID"; +export const multiplexAndCovidOnlyDeviceId = "MULTIPLEX-COVID-DEVICE-ID"; +export const fluDeviceId = "FLU-DEVICE-ID"; +export const hivDeviceId = "HIV-DEVICE-ID"; +export const FACILITY_INFO_TEST_ID = "f02cfff5-1921-4293-beff-e2a5d03e1fda"; +export const syphilisDeviceName = "SYPHILIS"; +export const syphilisDeviceId = "SYPHILIS-DEVICE-ID"; + +// 6 instead of 7 because HIV devices are filtered out when HIV feature flag is disabled +export const DEFAULT_DEVICE_OPTIONS_LENGTH = 6; +export const device1Name = "LumiraDX"; +export const device2Name = "Abbott BinaxNow"; +export const device3Name = "BD Veritor"; + +export const device4Name = "Multiplex"; +export const device5Name = "MultiplexAndCovidOnly"; +export const device6Name = "FluOnly"; +export const device7Name = "HIV device"; +export const device8Name = "Syphilis device"; + +export const device1Id = "DEVICE-1-ID"; +export const device2Id = "DEVICE-2-ID"; +export const device3Id = "DEVICE-3-ID"; +export const device4Id = "DEVICE-4-ID"; +export const device5Id = "DEVICE-5-ID"; +export const device6Id = "DEVICE-6-ID"; +export const device7Id = "DEVICE-7-ID"; +export const device8Id = "DEVICE-8-ID"; + +export const deletedDeviceId = "DELETED-DEVICE-ID"; +export const deletedDeviceName = "Deleted"; +export const deletedSpecimenId = "DELETED-SPECIMEN-ID"; + +export const specimen1Name = "Swab of internal nose"; +export const specimen1Id = "SPECIMEN-1-ID"; +export const specimen2Name = "Nasopharyngeal swab"; +export const specimen2Id = "SPECIMEN-2-ID"; +export const specimen3Name = "Venous blood specimen"; +export const specimen3Id = "SPECIMEN-3-ID"; + +export const BLURRED_VISION_LITERAL = "Blurred vision"; +export const TEST_CARD_SYMPTOM_ONSET_DATE_STRING = "2024-05-14"; + +export const NO_SYMPTOMS_FALSE_OVERRIDE = { noSymptoms: false }; +const NO_SYMPTOMS_TRUE_OVERRIDE = { noSymptoms: true }; + +const PREGNANCY_OVERRIDE = { pregnancy: "77386006" }; +const COUGH_OVERRIDE = { + symptoms: + '{"25064002":false,"36955009":false,"43724002":false,"44169009":false,"49727002":true,"62315008":false,"64531003":false,"68235000":false,"68962001":false,"84229001":false,"103001002":false,"162397003":false,"230145002":false,"267036007":false,"422400008":false,"422587007":false,"426000000":false}', +}; +const SYMPTOM_ONSET_DATE_OVERRIDE = { + symptomOnset: TEST_CARD_SYMPTOM_ONSET_DATE_STRING, +}; +const SYPHILIS_HISTORY_OVERRIDE = { syphilisHistory: "1087151000119108" }; +const GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE = { + genderOfSexualPartners: ["female"], +}; +const BLURRED_VISION_OVERRIDE = { + symptoms: + '{"15188001":false,"26284000":false,"46636008":true,"56940005":false,"68225006":false,"91554004":false,"195469007":false,"266128007":false,"724386005":false}', +}; + +const FIRST_CARD_SYMPTOM_OVERRIDE = { + symptoms: + '{"25064002":false,"36955009":false,"43724002":true,"44169009":false,"49727002":false,"62315008":false,"64531003":false,"68235000":false,"68962001":false,"84229001":false,"103001002":false,"162397003":false,"230145002":false,"261665006":false,"267036007":false,"422400008":false,"422587007":false,"426000000":false}', +}; + +const SECOND_CARD_SYMPTOM_OVERRIDE = { + symptoms: + '{"25064002":false,"36955009":false,"43724002":true,"44169009":false,"49727002":false,"62315008":false,"64531003":true,"68235000":false,"68962001":true,"84229001":false,"103001002":false,"162397003":false,"230145002":false,"261665006":false,"267036007":false,"422400008":false,"422587007":true,"426000000":false}', +}; +export const testOrderInfo: QueriedTestOrder = { + internalId: "1b02363b-ce71-4f30-a2d6-d82b56a91b39", + dateAdded: "2022-11-08 13:33:07.503", + symptoms: + '{"64531003":"false","103001002":"false","84229001":"false","68235000":"false","426000000":"false","49727002":"false","68962001":"false","422587007":"false","267036007":"false","62315008":"false","43724002":"false","36955009":"false","44169009":"false","422400008":"false","230145002":"false","25064002":"false","162397003":"false"}', + symptomOnset: null, + noSymptoms: true, + deviceType: { + internalId: device1Id, + name: device1Name, + model: "LumiraDx SARS-CoV-2 Ag Test*", + testLength: 15, + }, + specimenType: { + internalId: specimen1Id, + name: specimen1Name, + typeCode: "445297001", + }, + patient: { + internalId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", + telephone: "(571) 867-5309", + birthDate: "2015-09-20", + firstName: "Althea", + middleName: "Hedda Mclaughlin", + lastName: "Dixon", + gender: "refused", + testResultDelivery: null, + preferredLanguage: null, + email: "sywaporoce@mailinator.com", + emails: ["sywaporoce@mailinator.com"], + phoneNumbers: [ + { + type: PhoneType.Mobile, + number: "(553) 223-0559", + }, + { + type: PhoneType.Landline, + number: "(669) 789-0799", + }, + ], + }, + results: [], + dateTested: null, + correctionStatus: "ORIGINAL", + reasonForCorrection: null, +}; +export const secondTestOrder: QueriedTestOrder = { + internalId: "01c807c9-d42b-45c7-aa9f-1fd290eb2fdf", + dateAdded: "2024-06-05 22:03:12.205", + symptoms: + '{"64531003":"true","103001002":"false","84229001":"false","68235000":"false","426000000":"false","49727002":"false","68962001":"true","422587007":"true","267036007":"false","62315008":"false","43724002":"false","36955009":"false","44169009":"false","422400008":"false","230145002":"false","25064002":"false","162397003":"false"}', + symptomOnset: null, + noSymptoms: true, + deviceType: { + internalId: device3Id, + name: device3Name, + model: "LumiraDx SARS-CoV-2 Ag Test*", + testLength: 15, + }, + specimenType: { + internalId: specimen1Id, + name: specimen1Name, + typeCode: "445297001", + }, + patient: { + internalId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", + telephone: "(571) 867-5309", + birthDate: "2015-09-20", + firstName: "Althea", + middleName: "Hedda Mclaughlin", + lastName: "Dixon", + gender: "refused", + testResultDelivery: null, + preferredLanguage: null, + email: "sywaporoce@mailinator.com", + emails: ["sywaporoce@mailinator.com"], + phoneNumbers: [ + { + type: PhoneType.Mobile, + number: "(553) 223-0559", + }, + { + type: PhoneType.Landline, + number: "(669) 789-0799", + }, + ], + }, + results: [], + dateTested: null, + correctionStatus: "ORIGINAL", + reasonForCorrection: null, +}; + +export const sharedTestOrderInfo = { + internalId: "1b02363b-ce71-4f30-a2d6-d82b56a91b39", + dateAdded: "2022-11-08 13:33:07.503", + deviceType: { + internalId: covidDeviceId, + name: covidDeviceName, + model: covidDeviceName, + testLength: 15, + }, + specimenType: { + internalId: specimen1Id, + name: specimen1Name, + typeCode: "445297001", + }, + patient: { + internalId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", + telephone: "(571) 867-5309", + birthDate: "2015-09-20", + firstName: "Althea", + middleName: "Hedda Mclaughlin", + lastName: "Dixon", + gender: "refused", + testResultDelivery: null, + preferredLanguage: null, + email: "sywaporoce@mailinator.com", + emails: ["sywaporoce@mailinator.com"], + phoneNumbers: [ + { + type: PhoneType.Mobile, + number: "(553) 223-0559", + }, + { + type: PhoneType.Landline, + number: "(669) 789-0799", + }, + ], + }, + results: [], + dateTested: null, + correctionStatus: "ORIGINAL", + reasonForCorrection: null, +}; + +export const baseUpdateAoeMutationRequest = ( + variableOverrides?: Partial +) => { + return { + request: { + query: UpdateAoeDocument, + variables: { + patientId: "72b3ce1e-9d5a-4ad2-9ae8-e1099ed1b7e0", + symptoms: "{}", + symptomOnset: null, + genderOfSexualPartners: null, + ...variableOverrides, + }, + }, + }; +}; + +export const mutationResponse = { + result: { + data: { + testResult: { + internalId: "a4581a50-6f00-4bc1-b713-b190f282eabb", + __typename: "Test Result", + }, + deliverySuccess: true, + testEventId: "07c330a2-99b6-4dad-9fef-5c37773847b3", + __typename: "Test Event", + }, + }, +}; + +export const firstCardSymptomUpdateMock = { + ...baseUpdateAoeMutationRequest({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...FIRST_CARD_SYMPTOM_OVERRIDE, + }), + ...mutationResponse, +}; + +export const secondCardSymptomUpdateMock = { + ...baseUpdateAoeMutationRequest({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...SECOND_CARD_SYMPTOM_OVERRIDE, + }), + ...mutationResponse, +}; + +export const positiveGenerateMockOne = generateEditQueueMock( + MULTIPLEX_DISEASES.COVID_19, + TEST_RESULTS.POSITIVE +); +export const positiveDeviceThreeEditMock = generateEditQueueMock( + MULTIPLEX_DISEASES.COVID_19, + TEST_RESULTS.POSITIVE, + { + testOrderId: secondTestOrder.internalId, + device: { + deviceId: device3Id, + }, + } +); + +export const facilityInfo: QueriedFacility = { + id: FACILITY_INFO_TEST_ID, + name: "Testing Site", + deviceTypes: [ + { + internalId: covidDeviceId, + name: covidDeviceName, + testLength: 15, + supportedDiseaseTestPerformed: mockSupportedDiseaseCovid, + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], + }, + { + internalId: multiplexDeviceId, + name: multiplexDeviceName, + testLength: 15, + supportedDiseaseTestPerformed: mockSupportedDiseaseMultiplex, + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], + }, + { + internalId: fluDeviceId, + name: fluDeviceName, + testLength: 15, + supportedDiseaseTestPerformed: [...mockSupportedDiseaseFlu], + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], + }, + { + internalId: multiplexAndCovidOnlyDeviceId, + name: multiplexAndCovidOnlyDeviceName, + testLength: 15, + supportedDiseaseTestPerformed: [ + ...mockSupportedDiseaseFlu, + { + supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, + testPerformedLoincCode: "123456", + testOrderedLoincCode: "445566", + }, + { + supportedDisease: mockSupportedDiseaseCovid[0].supportedDisease, + testPerformedLoincCode: "123456", + testOrderedLoincCode: "778899", + }, + ], + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + { + name: specimen2Name, + internalId: specimen2Id, + typeCode: "258500001", + }, + ], + }, + { + internalId: syphilisDeviceId, + name: syphilisDeviceName, + testLength: 15, + supportedDiseaseTestPerformed: [ + ...mockSupportedDiseaseTestPerformedSyphilis, + ], + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + ], + }, + { + internalId: hivDeviceId, + name: hivDeviceName, + testLength: 15, + supportedDiseaseTestPerformed: [...mockSupportedDiseaseTestPerformedHIV], + swabTypes: [ + { + name: specimen1Name, + internalId: specimen1Id, + typeCode: "445297001", + }, + ], + }, + ], +}; + +export const devicesMap = new Map(); +facilityInfo.deviceTypes.map((d) => devicesMap.set(d.internalId, d)); + +export const asymptomaticTestOrderPartialInfo = { + symptoms: null, + symptomOnset: null, + noSymptoms: true, +}; +export const asymptomaticTestOrderInfo: QueriedTestOrder = { + ...sharedTestOrderInfo, + ...asymptomaticTestOrderPartialInfo, +}; +export const symptomaticTestOrderInfo: QueriedTestOrder = { + ...sharedTestOrderInfo, + symptoms: + '{"64531003":"false","103001002":"false","84229001":"false","68235000":"false","426000000":"false","49727002":"false","68962001":"false","422587007":"false","267036007":"false","62315008":"false","43724002":"false","36955009":"false","44169009":"false","422400008":"false","230145002":"false","25064002":"false","162397003":"false"}', + symptomOnset: TEST_CARD_SYMPTOM_ONSET_DATE_STRING, + noSymptoms: false, +}; + +export const blankUpdateAoeEventMock = { + ...baseUpdateAoeMutationRequest(), + ...mutationResponse, +}; + +export const falseNoSymptomAoeMock = { + ...baseUpdateAoeMutationRequest({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + }), + ...mutationResponse, +}; + +export const falseNoSymptomWithSymptomOnsetUpdateAoeMock = { + ...baseUpdateAoeMutationRequest({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...SYMPTOM_ONSET_DATE_OVERRIDE, + }), + ...mutationResponse, +}; + +const updatePregnancyAoeEventMock = { + ...baseUpdateAoeMutationRequest({ + ...PREGNANCY_OVERRIDE, + }), + ...mutationResponse, +}; + +const updateSymptomAoeEventMock = { + ...baseUpdateAoeMutationRequest({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + }), + ...mutationResponse, +}; +const updateCoughSymptomAoeEventMock = { + ...baseUpdateAoeMutationRequest({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...COUGH_OVERRIDE, + }), + ...mutationResponse, +}; + +const updateOnsetSymptomDateAoeEventMock = { + ...baseUpdateAoeMutationRequest({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...COUGH_OVERRIDE, + ...SYMPTOM_ONSET_DATE_OVERRIDE, + }), + ...mutationResponse, +}; + +export const updateAoeMocks = [ + updatePregnancyAoeEventMock, + updateSymptomAoeEventMock, + updateCoughSymptomAoeEventMock, + updateOnsetSymptomDateAoeEventMock, +]; + +// Syphilis card +const baseSyphilisAoeUpdateMock = ( + variableOverrides?: Partial +) => { + return { + ...baseUpdateAoeMutationRequest({ + genderOfSexualPartners: [], + ...variableOverrides, + }), + ...mutationResponse, + }; +}; +const yesSyphilisHistoryMock = { + ...baseSyphilisAoeUpdateMock({ + ...SYPHILIS_HISTORY_OVERRIDE, + }), +}; + +const yesSyphilisHistoryPregnancyMock = { + ...baseSyphilisAoeUpdateMock({ + ...SYPHILIS_HISTORY_OVERRIDE, + ...PREGNANCY_OVERRIDE, + }), + ...mutationResponse, +}; + +const yesSyphilisHistoryPregnancyFemaleSexPartnerMock = { + ...baseSyphilisAoeUpdateMock({ + ...SYPHILIS_HISTORY_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, + }), + ...mutationResponse, +}; + +const falseNoSymptomOnsetDateBlankSymptomsAndYesSyphilisAoeMock = { + ...baseSyphilisAoeUpdateMock({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...SYPHILIS_HISTORY_OVERRIDE, + ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, + }), + ...mutationResponse, +}; + +const falseNoSymptomBlurredVisionMockAndYesSyphilisAoeMock = { + ...baseSyphilisAoeUpdateMock({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...SYPHILIS_HISTORY_OVERRIDE, + ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, + ...BLURRED_VISION_OVERRIDE, + }), + ...mutationResponse, +}; + +const falseNoSymptomBlurredVisionOnsetDateAndYesSyphilisAoeMock = { + ...baseSyphilisAoeUpdateMock({ + ...NO_SYMPTOMS_FALSE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...SYPHILIS_HISTORY_OVERRIDE, + ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, + ...BLURRED_VISION_OVERRIDE, + ...SYMPTOM_ONSET_DATE_OVERRIDE, + }), + ...mutationResponse, +}; + +const noSymptomsTrueSymptomsBlankSyphilisHistory = { + ...baseSyphilisAoeUpdateMock({ + ...NO_SYMPTOMS_TRUE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...SYPHILIS_HISTORY_OVERRIDE, + }), + ...mutationResponse, +}; + +const noSymptomsTrueSymptomsBlankSyphilisFemaleHistory = { + ...baseSyphilisAoeUpdateMock({ + ...NO_SYMPTOMS_TRUE_OVERRIDE, + ...PREGNANCY_OVERRIDE, + ...SYPHILIS_HISTORY_OVERRIDE, + ...GENDER_SEXUAL_PARTNERS_FEMALE_OVERRIDE, + }), + ...mutationResponse, +}; + +export const updateSyphilisAoeMocks = [ + blankUpdateAoeEventMock, + generateEditQueueMock(MULTIPLEX_DISEASES.SYPHILIS, TEST_RESULTS.POSITIVE, { + device: { + deviceId: "DEVICE-8-ID", + }, + specimen: { + specimenId: "SPECIMEN-3-ID", + }, + }), + generateSubmitQueueMock(MULTIPLEX_DISEASES.SYPHILIS, TEST_RESULTS.POSITIVE, { + device: { + deviceId: "DEVICE-8-ID", + }, + specimen: { + specimenId: "SPECIMEN-3-ID", + }, + }), + yesSyphilisHistoryMock, + yesSyphilisHistoryPregnancyMock, + yesSyphilisHistoryPregnancyFemaleSexPartnerMock, + falseNoSymptomBlurredVisionMockAndYesSyphilisAoeMock, + falseNoSymptomBlurredVisionOnsetDateAndYesSyphilisAoeMock, + falseNoSymptomOnsetDateBlankSymptomsAndYesSyphilisAoeMock, + noSymptomsTrueSymptomsBlankSyphilisHistory, + noSymptomsTrueSymptomsBlankSyphilisFemaleHistory, +]; + +type EditQueueMockParams = { + testOrderId?: string; + diseaseResults?: + | [] + | [{ diseaseName: MULTIPLEX_DISEASES; testResult: TEST_RESULTS }]; + dateTested?: string; + device?: { + deviceName?: string; + deviceId: string; + supportedDiseases?: { + internalId: string; + loinc: string; + name: MULTIPLEX_DISEASES; + }[]; + }; + specimen?: { + specimenName?: string; + specimenId: string; + }; +}; + +export function generateEmptyEditQueueMock( + overrideParams?: EditQueueMockParams +) { + // dummy covid unknown submission that's overrided by the empty array + return generateEditQueueMock( + MULTIPLEX_DISEASES.COVID_19, + TEST_RESULTS.UNKNOWN, + { + diseaseResults: [], + ...overrideParams, + } + ); +} + +export function generateEditQueueMock( + disease: MULTIPLEX_DISEASES, + testResult: TEST_RESULTS, + overrideParams?: EditQueueMockParams +) { + return { + request: { + query: EditQueueItemDocument, + variables: { + id: overrideParams?.testOrderId ?? sharedTestOrderInfo?.internalId, + deviceTypeId: overrideParams?.device?.deviceId ?? device1Id, + specimenTypeId: overrideParams?.specimen?.specimenId ?? specimen1Id, + results: overrideParams?.diseaseResults ?? [ + { + diseaseName: disease, + testResult: testResult, + }, + ], + dateTested: overrideParams?.dateTested ?? null, + }, + }, + result: { + data: { + editQueueItem: { + results: overrideParams?.diseaseResults, + }, + dateTested: overrideParams?.dateTested, + deviceType: { + internalId: overrideParams?.device?.deviceId ?? device1Id, + testLength: 15, + }, + }, + }, + }; +} + +type SubmitQueueMockParams = EditQueueMockParams & { + deliverySuccess?: boolean; +}; + +export function generateSubmitQueueMock( + disease: MULTIPLEX_DISEASES, + testResult: TEST_RESULTS, + overrideParams?: SubmitQueueMockParams +) { + return { + request: { + query: SubmitQueueItemDocument, + variables: { + patientId: symptomaticTestOrderInfo?.patient.internalId, + deviceTypeId: overrideParams?.device?.deviceId ?? device1Id, + specimenTypeId: overrideParams?.specimen?.specimenId ?? specimen1Id, + results: overrideParams?.diseaseResults ?? [ + { diseaseName: disease, testResult: testResult }, + ], + dateTested: overrideParams?.dateTested ?? null, + } as SubmitQueueItemMutationVariables, + }, + result: { + data: { + submitQueueItem: { + testResult: { + internalId: symptomaticTestOrderInfo?.internalId, + }, + deliverySuccess: overrideParams?.deliverySuccess ?? true, + }, + }, + }, + }; +}