Skip to content

Commit

Permalink
replace respiratory bools too
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhao99 committed May 16, 2024
1 parent 70cd66f commit 6fc16cc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
10 changes: 7 additions & 3 deletions frontend/src/app/testQueue/TestCardForm/TestCardForm.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SomeoneWithName,
} from "../constants";
import { showError, showSuccess } from "../../utils/srToast";
import { respiratorySymptomDefinitions } from "../../../patientApp/timeOfTest/constants";

import { TestFormState } from "./TestCardFormReducer";
import {
Expand All @@ -19,7 +20,9 @@ import {
QueriedFacility,
QueriedTestOrder,
} from "./types";
import { mapRespiratorySymptomBoolLiteralsToBool } from "./diseaseSpecificComponents/aoeUtils";
import {
mapSymptomBoolLiteralsToBool,
} from "./diseaseSpecificComponents/aoeUtils";

/** Add more options as other disease AOEs are needed */
export enum AOEFormOption {
Expand Down Expand Up @@ -235,8 +238,9 @@ export const areAOEAnswersComplete = (
const isPregnancyAnswered = !!formState.aoeResponses.pregnancy;
const hasNoSymptoms = formState.aoeResponses.noSymptoms;
if (formState.aoeResponses.noSymptoms === false) {
const symptoms = mapRespiratorySymptomBoolLiteralsToBool(
formState.aoeResponses.symptoms
const symptoms = mapSymptomBoolLiteralsToBool(
formState.aoeResponses.symptoms,
respiratorySymptomDefinitions
);
const areSymptomsFilledIn = Object.values(symptoms).some((x) =>
x?.valueOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { QueriedTestOrder } from "../types";
import {
generateAoeListenerHooks,
generateSymptomAoeConstants,
mapRespiratorySymptomBoolLiteralsToBool,
mapSymptomBoolLiteralsToBool,
} from "./aoeUtils";

export interface CovidAoEFormProps {
Expand All @@ -34,9 +34,10 @@ const CovidAoEForm = ({
onResponseChange,
hasAttemptedSubmit,
}: CovidAoEFormProps) => {
const symptoms: Record<string, boolean> =
mapRespiratorySymptomBoolLiteralsToBool(responses.symptoms);

const symptoms: Record<string, boolean> = mapSymptomBoolLiteralsToBool(
responses.symptoms,
respiratorySymptomDefinitions
);
const {
onPregnancyChange,
onHasAnySymptomsChange,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { respiratorySymptomOrder } from "../../../../patientApp/timeOfTest/constants";
import {
respiratorySymptomDefinitions,
respiratorySymptomOrder,
} from "../../../../patientApp/timeOfTest/constants";

import { mapRespiratorySymptomBoolLiteralsToBool } from "./aoeUtils";
import {
mapSymptomBoolLiteralsToBool,
} from "./aoeUtils";

describe("mapRespiratorySymptomBoolLiteralsToBool", () => {
describe("mapSymptomBoolLiteralsToBool", () => {
it("takes a JSON payload of {'Respiratory symptom SNOMEDS' : boolean strings} and parses the strings into booleans", () => {
const covidSymptomPayload =
'{"25064002":false,"36955009":false,"43724002":false,"44169009":false,"49727002":false,"62315008":false,"64531003":false,"68235000":false,"68962001":false,"84229001":false,"103001002":false,"162397003":false,"230145002":false,"267036007":false,"422400008":false,"422587007":false,"426000000":false}\n';
const parsedPayload =
mapRespiratorySymptomBoolLiteralsToBool(covidSymptomPayload);
const parsedPayload = mapSymptomBoolLiteralsToBool(
covidSymptomPayload,
respiratorySymptomDefinitions
);
respiratorySymptomOrder.forEach((symptomKey) => {
expect(parsedPayload[symptomKey]).toEqual(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,6 @@ export function mapSpecifiedSymptomBoolLiteralsToBool(
};
}

export const mapRespiratorySymptomBoolLiteralsToBool = (
symptomsJsonString: string | null | undefined
) => {
return mapSymptomBoolLiteralsToBool(
symptomsJsonString,
respiratorySymptomDefinitions
);
};

export const mapSymptomBoolLiteralsToBool = (
symptomsJsonString: string | null | undefined,
symptomSelectionMap: SymptomDefinitionMap[]
Expand Down

0 comments on commit 6fc16cc

Please sign in to comment.