Skip to content

Commit

Permalink
add other symptom
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhao99 committed May 17, 2024
1 parent 6cf5600 commit 4ca79cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion frontend/src/patientApp/timeOfTest/constants.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { alphabetizeSymptomKeysFromMapValues } from "./constants";
import {
alphabetizeSymptomKeysFromMapValues,
OTHER_SYMPTOM_NOT_LISTED_LITERAL,
} from "./constants";

describe("utils", () => {
it("alphabetizeSymptomKeysFromMapValues produces an alphabetized list of keys based on values when given a map", () => {
Expand All @@ -11,6 +14,7 @@ describe("utils", () => {
"91554004": "e",
"15188001": "z",
"246636008": "y",
"100000000": OTHER_SYMPTOM_NOT_LISTED_LITERAL,
} as const;
const symptomOrder = alphabetizeSymptomKeysFromMapValues(testSymptomMap);

Expand All @@ -23,6 +27,8 @@ describe("utils", () => {
"56940005",
"246636008",
"15188001",
// OTHER_SYMPTOM_NOT_LISTED_LITERAL should come last
"100000000",
]);
});
});
8 changes: 7 additions & 1 deletion frontend/src/patientApp/timeOfTest/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const pregnancyOrder: PregnancyCode[] = ["77386006", "60001007", "261665006"];

export const getPregnancyResponses = (): PregnancyResponses =>
pregnancyOrder.map((value) => ({ value, label: pregnancyMap[value] }));
export const OTHER_SYMPTOM_NOT_LISTED_LITERAL = "Other symptom not listed";

export const respiratorySymptomsMap = {
"426000000": "Fever over 100.4F",
Expand All @@ -37,6 +38,7 @@ export const respiratorySymptomsMap = {
"422587007": "Nausea",
"422400008": "Vomiting",
"62315008": "Diarrhea",
"261665006": OTHER_SYMPTOM_NOT_LISTED_LITERAL,
} as const;

export type RespiratorySymptoms = typeof respiratorySymptomsMap;
Expand Down Expand Up @@ -109,7 +111,11 @@ export function alphabetizeSymptomKeysFromMapValues(dict: {
[key: string]: string;
}) {
const values = Object.values(dict);
values.sort((a, b) => a.localeCompare(b));
values.sort((a, b) => {
if (a === OTHER_SYMPTOM_NOT_LISTED_LITERAL) return 1;
if (b === OTHER_SYMPTOM_NOT_LISTED_LITERAL) return -1;
else return a.localeCompare(b);
});
const reversedMap = Object.fromEntries(
Object.entries(dict).map((a) => a.reverse())
);
Expand Down

0 comments on commit 4ca79cc

Please sign in to comment.