Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const RecentInteraction: FunctionComponent = observer(() => {
<GridTextField
sm={12}
label="Patient Interaction Date"
value={currentPatient.mostRecentPatientInteractionDate}
value={currentPatient.recentInteractionCutoffDateTime}
/>
<GridTextField
sm={3}
Expand Down
45 changes: 25 additions & 20 deletions web_registry/src/stores/PatientStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { differenceInYears } from "date-fns";
import {
differenceInYears,
subDays
} from "date-fns";
import { action, computed, makeAutoObservable, toJS } from "mobx";
import {
behavioralActivationChecklistValues,
Expand Down Expand Up @@ -55,7 +58,7 @@ export interface IPatientStore extends IPatient {
readonly recordId: string;

// Recent patient interaction properties
readonly mostRecentPatientInteractionDate: Date;
readonly recentInteractionCutoffDateTime: Date;
readonly recentActivities: IActivity[] | undefined;
readonly recentActivityLogs: IActivityLog[] | undefined;
readonly recentActivitySchedules: IActivitySchedule[] | undefined;
Expand Down Expand Up @@ -379,13 +382,6 @@ export class PatientStore implements IPatientStore {
return undefined;
}

@computed get mostRecentPatientInteractionDate() {
// Initially, stub the function to return now minus a week.
let mostRecentDate = new Date();
mostRecentDate.setDate(mostRecentDate.getDate() - 7);
return mostRecentDate;
}

@computed get profile() {
return (
this.loadProfileQuery.value || {
Expand All @@ -395,45 +391,54 @@ export class PatientStore implements IPatientStore {
);
}

@computed get recentInteractionCutoffDateTime() {
// Initially, stub the function to return now minus two weeks.
// Eventually, this will be calculated based on when a social worker marks a patient as reviewed.
let cutoffDateTime = new Date();
cutoffDateTime = subDays(cutoffDateTime, 14)

return cutoffDateTime;
}

@computed get recordId() {
return this.identity.patientId;
}

@computed get recentActivities() {
return this.activities.filter((a) => {
return a.editedDateTime >= this.mostRecentPatientInteractionDate;
return a.editedDateTime >= this.recentInteractionCutoffDateTime;
});
}

@computed get recentActivityLogs() {
return this.activityLogs.filter((a) => {
return a.recordedDateTime >= this.mostRecentPatientInteractionDate;
return a.recordedDateTime >= this.recentInteractionCutoffDateTime;
});
}

@computed get recentActivitySchedules() {
return this.activitySchedules.filter((a) => {
return a.editedDateTime >= this.mostRecentPatientInteractionDate;
return a.editedDateTime >= this.recentInteractionCutoffDateTime;
});
}

@computed get recentAssessmentLogs() {
return this.assessmentLogs.filter((a) => {
return a.recordedDateTime >= this.mostRecentPatientInteractionDate;
return a.recordedDateTime >= this.recentInteractionCutoffDateTime;
});
}

@computed get recentMoodLogs() {
return this.moodLogs.filter((a) => {
return a.recordedDateTime >= this.mostRecentPatientInteractionDate;
return a.recordedDateTime >= this.recentInteractionCutoffDateTime;
});
}

@computed get recentSafetyPlan() {
if (
!!this.safetyPlan.lastUpdatedDateTime &&
this.safetyPlan.lastUpdatedDateTime >=
this.mostRecentPatientInteractionDate
this.recentInteractionCutoffDateTime
) {
return this.safetyPlan;
}
Expand All @@ -442,7 +447,7 @@ export class PatientStore implements IPatientStore {

@computed get recentValues() {
return this.values.filter((a) => {
return a.editedDateTime >= this.mostRecentPatientInteractionDate;
return a.editedDateTime >= this.recentInteractionCutoffDateTime;
});
}

Expand Down Expand Up @@ -936,10 +941,10 @@ export class PatientStore implements IPatientStore {
),
primaryCareManager: patientProfile.primaryCareManager
? {
name: patientProfile.primaryCareManager?.name,
providerId: patientProfile.primaryCareManager?.providerId,
role: patientProfile.primaryCareManager?.role,
}
name: patientProfile.primaryCareManager?.name,
providerId: patientProfile.primaryCareManager?.providerId,
role: patientProfile.primaryCareManager?.role,
}
: undefined,
});

Expand Down