diff --git a/patientsearch/api.py b/patientsearch/api.py index 285961af..af82f95d 100644 --- a/patientsearch/api.py +++ b/patientsearch/api.py @@ -230,7 +230,6 @@ def bundle_getpages(): return jsonify_abort(status_code=400, message=str(error)) -@api_blueprint.route("/fhir/", methods=["GET"]) @api_blueprint.route("/fhir/", methods=["GET"]) def resource_bundle(resource_type): """Query HAPI for resource_type and return as JSON FHIR Bundle diff --git a/patientsearch/src/js/components/patientList/ReactivatingModal.js b/patientsearch/src/js/components/patientList/ReactivatingModal.js index 31470d64..70fd3c00 100644 --- a/patientsearch/src/js/components/patientList/ReactivatingModal.js +++ b/patientsearch/src/js/components/patientList/ReactivatingModal.js @@ -11,14 +11,14 @@ const useStyles = makeStyles((theme) => ({ container: { backgroundColor: "#FFF", margin: "auto", - padding: theme.spacing(2), + padding: theme.spacing(1), position: "absolute", top: "25%", width: "480px", left: "calc(50% - 240px)", }, buttonsContainer: { - padding: theme.spacing(2), + padding: theme.spacing(2,2,1), display: "flex", justifyContent: "center", alignItems: "center", diff --git a/patientsearch/src/js/context/PatientListContextProvider.js b/patientsearch/src/js/context/PatientListContextProvider.js index af56e8d1..2491e0e5 100644 --- a/patientsearch/src/js/context/PatientListContextProvider.js +++ b/patientsearch/src/js/context/PatientListContextProvider.js @@ -10,6 +10,7 @@ import { useUserContext } from "./UserContextProvider"; import * as constants from "../constants/consts"; import DetailPanel from "../components/patientList/DetailPanel"; import { + capitalizeFirstLetter, fetchData, getAppLaunchURL, getFirstResourceFromFhirBundle, @@ -398,7 +399,21 @@ export default function PatientListContextProvider({ children }) { if (isUpdate && data.id) { return `/fhir/Patient/${data.id}`; } - let url = `/fhir/Patient?given=${fName}&family=${lName}&birthdate=${birthDate}`; + const matchFNames = [ + fName, + fName.toLowerCase(), + fName.toUpperCase(), + capitalizeFirstLetter(fName), + ].join(","); + const matchLNames = [ + lName, + lName.toLowerCase(), + lName.toUpperCase(), + capitalizeFirstLetter(lName), + ].join(","); + // lookup patient with exact match + //e.g., /fhir/Patient?given:exact=Test,test,TEST&family:exact=Bubblegum,bubblegum,BUBBLEGUM&birthdate=2000-01-01 + let url = `/fhir/Patient?given:exact=${matchFNames}&family:exact=${matchLNames}&birthdate=${birthDate}`; if (searchInactive) { url += `&inactive_search=true`; } else { @@ -802,6 +817,7 @@ export default function PatientListContextProvider({ children }) { } const oData = new RowData(rowData); const payload = JSON.stringify(oData.getFhirData(isCreateNew)); + const isUpdate = isReactivate || (!isCreateNew && !!rowData.id); // error message when no result returned const noResultErrorMessage = needExternalAPILookup() @@ -815,12 +831,12 @@ export default function PatientListContextProvider({ children }) { fetchData( _getPatientSearchURL(rowData, { useActiveFlag: !!getAppSettingByKey("ACTIVE_PATIENT_FLAG"), - isUpdate: !isCreateNew && !!rowData.id, + isUpdate: isUpdate, }), { ...searchParams, body: payload, - method: isCreateNew ? "POST" : "PUT", + method: isUpdate ? "PUT" : "POST", }, (e) => handleErrorCallback(e) ) diff --git a/patientsearch/src/js/helpers/utility.js b/patientsearch/src/js/helpers/utility.js index b11b8110..d99257b2 100644 --- a/patientsearch/src/js/helpers/utility.js +++ b/patientsearch/src/js/helpers/utility.js @@ -81,11 +81,10 @@ export async function fetchData(url, params, errorCallback) { }); console.log("response json ", json); } catch (e) { - console.log(`There was error parsing data: ${e}`); + console.log(`There was error parsing data:`, e); json = null; - errorCallback(e); - throw e; } + if (!results || !results.ok) { console.log("no results returned ", results); if (!results.ok) { @@ -619,3 +618,15 @@ export function getErrorDiagnosticTextFromResponse(response) { response.issue.find((item) => item.severity === "error"); return issue && issue.diagnostics ? issue.diagnostics : ""; } + +/* + * return string with first letter capitalized and the rest lower cased + * @param string to be modified + * @return string + */ +export function capitalizeFirstLetter(string) { + if (!string) return ""; + const firstCapLetter = string.charAt(0).toUpperCase(); + const theRest = string.slice(1); + return firstCapLetter + (theRest ? theRest.toLowerCase() : ""); +}