Skip to content

Commit

Permalink
Handle invalid inputs for MRN search (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
qu8n authored Nov 29, 2023
1 parent 5ce0926 commit a7f0d5c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/pages/patients/PatientsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const UNAUTHORIZED_WARNING = {
const NO_PHI_SEARCH_RESULTS = {
title: "No results found",
content:
"No results were found for your search. Your patient ID search term does not exists in either the SMILE or CRDB databases.",
"No results were found for your search. No patient IDs in your search exist in either the SMILE or CRDB databases.",
};

export default function PatientsPage({
Expand Down Expand Up @@ -161,10 +161,11 @@ export default function PatientsPage({
}

const data: PatientIdsTriplet[] = await response.json();
setPatientIdsTriplets(data);
const validData = data.filter((d) => Boolean(d));
setPatientIdsTriplets(validData);

if (data.length > 0) {
return data.map((d) => addCDashToCMOId(d.CMO_ID));
if (validData.length > 0) {
return validData.map((d) => addCDashToCMOId(d.CMO_ID));
} else {
return [];
}
Expand All @@ -188,6 +189,7 @@ export default function PatientsPage({
show: true,
...NO_PHI_SEARCH_RESULTS,
});
setSearchVal([]);
}
} else {
setSearchVal(uniqueQueries);
Expand Down

0 comments on commit a7f0d5c

Please sign in to comment.