Skip to content

Commit

Permalink
Results page and PXP support for Hepatitis C (#8249)
Browse files Browse the repository at this point in the history
* Add Hep C result guidance and details

* Show Hep C guidance for non-positive results too

* Refactor disease result keys for sonar reduced complexity

* Fix Hep C guidance copy text

* Remove lowercasing in feature flag mock
  • Loading branch information
mpbrown authored Nov 4, 2024
1 parent 87711d4 commit 15e0171
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { render, screen } from "@testing-library/react";

import "../../../i18n";

import HepatitisCResultGuidance from "./HepatitisCResultGuidance";

describe("HepatitisCResultGuidance", () => {
it("displays guidance for a Hepatitis-C result", () => {
const { container } = render(<HepatitisCResultGuidance />);
expect(screen.getByText("For Hepatitis-C:")).toBeInTheDocument();
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";
import { Trans, useTranslation } from "react-i18next";

const HepatitisCResultGuidance = () => {
const { t } = useTranslation();

return (
<>
<p className="text-bold sr-guidance-heading">
{t("testResult.hepatitisCNotes.h1")}
</p>
<p>{t("testResult.hepatitisCNotes.positive.p0")}</p>
<Trans
parent="p"
i18nKey="testResult.hepatitisCNotes.positive.p1"
components={[
<a
href={t("testResult.hepatitisCNotes.positive.treatmentLink")}
target="_blank"
rel="noopener noreferrer"
key="hepatitis-c-treatment-link"
>
hepatitis-c treatment link
</a>,
]}
/>
</>
);
};

export default HepatitisCResultGuidance;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HepatitisCResultGuidance displays guidance for a Hepatitis-C result 1`] = `
<div>
<p
class="text-bold sr-guidance-heading"
>
For Hepatitis-C:
</p>
<p>
If you have a positive result, you will need a follow-up test to confirm your results. The organization that provided your test should be able to answer questions and provide referrals for follow-up testing.
</p>
<p>
<a
href="https://www.cdc.gov/hepatitis-c/testing/index.html#cdc_testing_results-testing-results"
rel="noopener noreferrer"
target="_blank"
>
Visit the CDC website to learn more about a positive Hepatitis-C result
</a>
(cdc.gov/hepatitis-c/testing/index.html#cdc_testing_results-testing-results).
</p>
</div>
`;
64 changes: 27 additions & 37 deletions frontend/src/app/commonComponents/TestResultsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,41 @@ interface TestResultsListProps {
results: MultiplexResults;
isPatientApp: boolean;
}

const setDiseaseResultTitle = (
diseaseName: MultiplexDisease,
diseaseName: MULTIPLEX_DISEASES,
t: translateFn,
isPxp: boolean
) => {
const translationKey = setDiseaseResultKey(diseaseName, isPxp);
const translationKey = isPxp
? diseaseResultTitlePxpMap[diseaseName]
: diseaseResultReportingAppMap[diseaseName];
if (translationKey) {
return t(translationKey);
}
return "";
};

const setDiseaseResultKey = (diseaseName: MultiplexDisease, isPxp: boolean) => {
switch (diseaseName) {
case MULTIPLEX_DISEASES.COVID_19:
return isPxp
? "constants.diseaseResultTitle.COVID19"
: "constants.disease.COVID19";
case MULTIPLEX_DISEASES.FLU_A:
return isPxp
? "constants.diseaseResultTitle.FLUA"
: "constants.disease.FLUA";
case MULTIPLEX_DISEASES.FLU_B:
return isPxp
? "constants.diseaseResultTitle.FLUB"
: "constants.disease.FLUB";
case MULTIPLEX_DISEASES.FLU_A_AND_B:
return isPxp
? "constants.diseaseResultTitle.FLUAB"
: "constants.disease.FLUAB";
case MULTIPLEX_DISEASES.HIV:
return isPxp
? "constants.diseaseResultTitle.HIV"
: "constants.disease.HIV";
case MULTIPLEX_DISEASES.RSV:
return isPxp
? "constants.diseaseResultTitle.RSV"
: "constants.disease.RSV";
case MULTIPLEX_DISEASES.SYPHILIS:
return isPxp
? "constants.diseaseResultTitle.SYPHILIS"
: "constants.disease.SYPHILIS";
default:
return null;
}
const diseaseResultTitlePxpMap: Record<MULTIPLEX_DISEASES, string> = {
[MULTIPLEX_DISEASES.COVID_19]: "constants.diseaseResultTitle.COVID19",
[MULTIPLEX_DISEASES.FLU_A]: "constants.diseaseResultTitle.FLUA",
[MULTIPLEX_DISEASES.FLU_B]: "constants.diseaseResultTitle.FLUB",
[MULTIPLEX_DISEASES.FLU_A_AND_B]: "constants.diseaseResultTitle.FLUAB",
[MULTIPLEX_DISEASES.HIV]: "constants.diseaseResultTitle.HIV",
[MULTIPLEX_DISEASES.RSV]: "constants.diseaseResultTitle.RSV",
[MULTIPLEX_DISEASES.SYPHILIS]: "constants.diseaseResultTitle.SYPHILIS",
[MULTIPLEX_DISEASES.HEPATITIS_C]: "constants.diseaseResultTitle.HEPATITIS_C",
};

const diseaseResultReportingAppMap: Record<MULTIPLEX_DISEASES, string> = {
[MULTIPLEX_DISEASES.COVID_19]: "constants.disease.COVID19",
[MULTIPLEX_DISEASES.FLU_A]: "constants.disease.FLUA",
[MULTIPLEX_DISEASES.FLU_B]: "constants.disease.FLUB",
[MULTIPLEX_DISEASES.FLU_A_AND_B]: "constants.disease.FLUAB",
[MULTIPLEX_DISEASES.HIV]: "constants.disease.HIV",
[MULTIPLEX_DISEASES.RSV]: "constants.disease.RSV",
[MULTIPLEX_DISEASES.SYPHILIS]: "constants.disease.SYPHILIS",
[MULTIPLEX_DISEASES.HEPATITIS_C]: "constants.disease.HEPATITIS_C",
};

const setResult = (result: string, t: translateFn) => {
Expand All @@ -78,7 +68,7 @@ const setResultSymbol = (result: string, t: translateFn) => {
};

const reportingAppResultListItem = (
diseaseName: MultiplexDisease,
diseaseName: MULTIPLEX_DISEASES,
result: TestResult,
t: translateFn
) => {
Expand All @@ -99,7 +89,7 @@ const reportingAppResultListItem = (
};

const pxpAppResultListItem = (
diseaseName: MultiplexDisease,
diseaseName: MULTIPLEX_DISEASES,
result: TestResult,
t: translateFn
) => {
Expand Down
35 changes: 14 additions & 21 deletions frontend/src/app/testQueue/TestCard/TestCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,11 @@ jest.mock("../../TelemetryService", () => ({
getAppInsights: jest.fn(),
}));

const mockDiseaseEnabledFlag = (
diseaseName: string,
skipLowercase: boolean = false
) =>
const mockDiseaseEnabledFlag = (diseaseName: string) =>
jest
.spyOn(flaggedMock, "useFeature")
.mockImplementation((flagName: string) => {
// to handle casing of Hepatitis-C as hepatitisC
if (skipLowercase) {
return flagName === `${diseaseName}Enabled`;
}
return flagName === `${diseaseName.toLowerCase()}Enabled`;
return flagName === `${diseaseName}Enabled`;
});

const mockNavigate = jest.fn();
Expand Down Expand Up @@ -1132,7 +1125,7 @@ describe("TestCard", () => {
});

it("shows radio buttons for HIV when an HIV device is chosen", async function () {
mockDiseaseEnabledFlag("HIV");
mockDiseaseEnabledFlag("hiv");

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.POSITIVE),
Expand All @@ -1152,7 +1145,7 @@ describe("TestCard", () => {
});

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

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.POSITIVE),
Expand Down Expand Up @@ -1182,7 +1175,7 @@ describe("TestCard", () => {
});

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

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.UNKNOWN),
Expand All @@ -1209,7 +1202,7 @@ describe("TestCard", () => {
});

it("shows radio buttons for Syphilis when a syphilis device is chosen", async function () {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");

const mocks = [
generateEditQueueMock(
Expand All @@ -1229,7 +1222,7 @@ describe("TestCard", () => {
});

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

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1269,7 +1262,7 @@ describe("TestCard", () => {
});

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

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1325,7 +1318,7 @@ describe("TestCard", () => {
});

it("shows radio buttons for Hepatitis C when a hepatitis c device is chosen", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const mocks = [
generateEditQueueMock(
Expand All @@ -1345,7 +1338,7 @@ describe("TestCard", () => {
});

it("shows required Hepatitis-C AOE questions when a positive Hepatitis-C result is present", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1397,7 +1390,7 @@ describe("TestCard", () => {
});

it("hides AOE questions when there is no positive Hepatitis-C result", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1443,7 +1436,7 @@ describe("TestCard", () => {
});

it("checks that Hep C submission only works if AOE questions are valid", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const { user } = await renderQueueItem({ mocks: updateHepCAoeMocks });
const deviceDropdown = await getDeviceTypeDropdown();
Expand Down Expand Up @@ -1494,7 +1487,7 @@ describe("TestCard", () => {
});

it("checks that submission only works if AOE questions are valid", async function () {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");

const { user } = await renderQueueItem({ mocks: updateSyphilisAoeMocks });
const deviceDropdown = await getDeviceTypeDropdown();
Expand Down Expand Up @@ -1556,7 +1549,7 @@ describe("TestCard", () => {
});

it("checks that checking has symptom requires onset date and selection", async () => {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");
const mocks = [...updateSyphilisAoeMocks];

const { user } = await renderQueueItem({ mocks });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export const DetachedTestResultDetailsModal = ({
data?.testResult.results,
MULTIPLEX_DISEASES.SYPHILIS
);
const isHepatitisCResult = !!getResultForDisease(
data?.testResult.results,
MULTIPLEX_DISEASES.HEPATITIS_C
);
const showGenderOfSexualPartners =
isHIVResult || isSyphilisResult || isHepatitisCResult;

const dateTested = data?.testResult.dateTested;

Expand Down Expand Up @@ -188,7 +194,7 @@ export const DetachedTestResultDetailsModal = ({
removed={removed}
aria-describedby="result-detail-title"
/>
{(isHIVResult || isSyphilisResult) && (
{showGenderOfSexualPartners && (
<DetailsRow
label="Gender of sexual partners"
value={formatGenderOfSexualPartnersForDisplay(
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/app/utils/testResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import FluResultGuidance from "../commonComponents/TestResultGuidance/FluResultG
import HivResultGuidance from "../commonComponents/TestResultGuidance/HivResultGuidance";
import RsvResultGuidance from "../commonComponents/TestResultGuidance/RsvResultGuidance";
import SyphilisResultGuidance from "../commonComponents/TestResultGuidance/SyphilisResultGuidance";
import HepatitisCResultGuidance from "../commonComponents/TestResultGuidance/HepatitisCResultGuidance";

export function getResultByDiseaseName(
results: MultiplexResults,
Expand Down Expand Up @@ -100,5 +101,10 @@ export const getGuidanceForResults = (
guidance.push(<SyphilisResultGuidance result={match} />);
}

match = getResultForDisease(results, MULTIPLEX_DISEASES.HEPATITIS_C);
if (match) {
guidance.push(<HepatitisCResultGuidance />);
}

return guidance;
};
11 changes: 11 additions & 0 deletions frontend/src/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const en = {
RSV: "RSV",
HIV: "HIV",
SYPHILIS: "Syphilis",
HEPATITIS_C: "Hepatitis-C",
},
diseaseResultTitle: {
COVID19: "COVID-19 result",
Expand All @@ -49,6 +50,7 @@ export const en = {
RSV: "RSV result",
HIV: "HIV result",
SYPHILIS: "Syphilis result",
HEPATITIS_C: "Hepatitis-C result",
},
role: {
STAFF: "Staff",
Expand Down Expand Up @@ -420,6 +422,15 @@ export const en = {
"https://www.cdc.gov/std/treatment-guidelines/syphilis.htm",
},
},
hepatitisCNotes: {
h1: "For Hepatitis-C:",
positive: {
p0: "If you have a positive result, you will need a follow-up test to confirm your results. The organization that provided your test should be able to answer questions and provide referrals for follow-up testing.",
p1: "<0>Visit the CDC website to learn more about a positive Hepatitis-C result</0> (cdc.gov/hepatitis-c/testing/index.html#cdc_testing_results-testing-results).",
treatmentLink:
"https://www.cdc.gov/hepatitis-c/testing/index.html#cdc_testing_results-testing-results",
},
},
tos: {
header: "Terms of service",
title: "Terms of service",
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/lang/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const es: LanguageConfig = {
RSV: "VRS",
HIV: "VIH",
SYPHILIS: "Sífilis",
HEPATITIS_C: "Hepatitis C",
},
diseaseResultTitle: {
COVID19: "COVID-19 resultado",
Expand All @@ -52,6 +53,7 @@ export const es: LanguageConfig = {
RSV: "RSV resultado",
HIV: "Resultado de la prueba del VIH",
SYPHILIS: "Sífilis resultado",
HEPATITIS_C: "Hepatitis-C resultado",
},
role: {
STAFF: "Personal",
Expand Down Expand Up @@ -443,6 +445,15 @@ export const es: LanguageConfig = {
"https://www.cdc.gov/std/treatment-guidelines/syphilis.htm",
},
},
hepatitisCNotes: {
h1: "Para Hepatitis-C:",
positive: {
p0: "Si obtiene un resultado positivo, deberá hacerse una prueba de seguimiento para confirmarlo. La organización que realizó su prueba debería poder contestar las preguntas que tenga y proporcionarle remisiones para una prueba de seguimiento.",
p1: "<0>Visite el sitio web de los CDC para obtener más información sobre un resultado positivo en la prueba del hepatitis C.</0> (cdc.gov/hepatitis-c/testing/index.html#cdc_testing_results-testing-results).",
treatmentLink:
"https://www.cdc.gov/hepatitis-c/testing/index.html#cdc_testing_results-testing-results",
},
},
tos: {
header: "Condiciones del servicio",
title: "Condiciones del servicio",
Expand Down

0 comments on commit 15e0171

Please sign in to comment.