From 289b32c60c46787592040ed8c0f4c18dbdaff0a1 Mon Sep 17 00:00:00 2001 From: Amy Chen Date: Thu, 19 Oct 2023 16:58:28 -0700 Subject: [PATCH] Next Message column - do not display dates in past --- .../src/js/context/PatientListContextProvider.js | 5 +++++ patientsearch/src/js/helpers/utility.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/patientsearch/src/js/context/PatientListContextProvider.js b/patientsearch/src/js/context/PatientListContextProvider.js index 0c658bb5..c8018d23 100644 --- a/patientsearch/src/js/context/PatientListContextProvider.js +++ b/patientsearch/src/js/context/PatientListContextProvider.js @@ -16,6 +16,7 @@ import { getClientsByRequiredRoles, getPatientIdsByCareTeamParticipant, getTimeAgoDisplay, + isInPast, isString, putPatientData, getUrlParameter, @@ -406,12 +407,16 @@ export default function PatientListContextProvider({ children }) { } let value = nodes && nodes.length ? nodes[nodes.length - 1].value : null; + if (dataType === "date") { value = value ? getLocalDateTimeString(value) : "--"; } if (dataType === "timeago" && value) { value = value ? getTimeAgoDisplay(new Date(value)) : "--"; } + if (dataType === "nextscheduleddate") { + value = isInPast(value) ? "--": getLocalDateTimeString(value); + } if (col.field) rowData[col.field] = value; }); return rowData; diff --git a/patientsearch/src/js/helpers/utility.js b/patientsearch/src/js/helpers/utility.js index 50558ec6..9b6a13d2 100644 --- a/patientsearch/src/js/helpers/utility.js +++ b/patientsearch/src/js/helpers/utility.js @@ -455,6 +455,18 @@ export function addMamotoTracking(siteId, userId) { headElement.appendChild(g); } +/* + * @param dateString of type String + * @returns true if supplied dateString is determined to be less than today's date otherwise false + */ +export function isInPast(dateString) { + if (!dateString) return false; + const today = new Date(); + const targetDate = new Date(dateString); + if (!isValid(targetDate)) return false; + return targetDate < today; +} + /* * @param objDate of type Date object * @returns text display of time ago as string e.g. < 50 seconds, < 1 hour, 1 day 2 hours, 3 hours, 3 days