Skip to content

Commit

Permalink
add more generic symptom typing and update function contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbywells52 committed Aug 21, 2024
1 parent 47f0129 commit 920ff94
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
14 changes: 7 additions & 7 deletions frontend/src/app/utils/symptoms.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
respiratorySymptomsMap,
RespiratorySymptomCode,
RespiratorySymptomName,
AllSymptomsCode,
allSymptomsMap,
AllSymptomsName,
} from "../../patientApp/timeOfTest/constants";

export const symptomsStringToArray = (
symptomString: string
): RespiratorySymptomName[] => {
const parsed: { [k in RespiratorySymptomCode]: "true" | "false" } =
): AllSymptomsName[] => {
const parsed: { [k in AllSymptomsCode]: "true" | "false" } =
JSON.parse(symptomString);
return Object.entries(parsed).reduce((acc, [code, symptomatic]) => {
if (symptomatic === "true") {
acc.push(respiratorySymptomsMap[code as RespiratorySymptomCode]);
acc.push(allSymptomsMap[code as AllSymptomsCode]);
}
return acc;
}, [] as RespiratorySymptomName[]);
}, [] as AllSymptomsCode[]);
};

// symptoms should be a JSON string
Expand Down
36 changes: 36 additions & 0 deletions frontend/src/patientApp/timeOfTest/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const syphilisSymptomsMap = {

export type SyphilisSymptoms = typeof syphilisSymptomsMap;
export type SyphilisSymptomCode = keyof SyphilisSymptoms;
export type SyphilisSymptomName = SyphilisSymptoms[SyphilisSymptomCode];

const syphilisSymptomOrder: SyphilisSymptomCode[] =
alphabetizeSymptomKeysFromMapValues(syphilisSymptomsMap);
Expand Down Expand Up @@ -134,3 +135,38 @@ export const syphilisSymptomDefinitions: SymptomDefinitionMap[] =
export const SYMPTOM_SUBQUESTION_ERROR =
"This question is required if the patient has symptoms.";
export const ONSET_DATE_LABEL = "When did the patient's symptoms start?";

export type AllSymptomsCode = keyof RespiratorySymptoms &
keyof SyphilisSymptoms;
export type AllSymptomsName = RespiratorySymptomName & SyphilisSymptomName;
export const allSymptomsMap = {
"724386005": "Genital sore/lesion",
// Anal skin tag (195469007); Anal tag (195469007); Fibrous polyp of anus (195469007)
"195469007": "Anal sore/lesion",
// Ulcer of mouth (26284000); Oral ulcer (26284000); Mouth ulceration (26284000); Ulceration of oral mucosa (26284000); Mouth ulcer (26284000)
"26284000": "Sore(s) in mouth/lips",
"266128007": "Body Rash",
"56940005": "Palmar (hand)/plantar (foot) rash",
"91554004": "Flat white warts",
"15188001": "Hearing loss",
"46636008": "Blurred vision",
"68225006": "Patchy hair loss",
"426000000": "Fever over 100.4F",
"103001002": "Feeling feverish",
"43724002": "Chills",
"49727002": "Cough",
"267036007": "Shortness of breath",
"230145002": "Difficulty breathing",
"84229001": "Fatigue",
"68962001": "Muscle or body aches",
"25064002": "Headache",
"36955009": "New loss of taste",
"44169009": "New loss of smell",
"162397003": "Sore throat",
"68235000": "Nasal congestion",
"64531003": "Runny nose",
"422587007": "Nausea",
"422400008": "Vomiting",
"62315008": "Diarrhea",
"261665006": OTHER_SYMPTOM_NOT_LISTED_LITERAL,
} as const;

0 comments on commit 920ff94

Please sign in to comment.