Skip to content

Commit

Permalink
Next Message column - do not display dates in past
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen committed Oct 19, 2023
1 parent ac942d3 commit 289b32c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions patientsearch/src/js/context/PatientListContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getClientsByRequiredRoles,
getPatientIdsByCareTeamParticipant,
getTimeAgoDisplay,
isInPast,
isString,
putPatientData,
getUrlParameter,
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions patientsearch/src/js/helpers/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 289b32c

Please sign in to comment.