fix: only count missed doses scheduled after medication update (#79)
When medication intake times change, dose IDs change (they include timestamps). Previously, this caused all past doses to appear as 'missed' because the old 'taken' markers no longer matched. Now doses are only counted as 'missed' if they were scheduled AFTER the medication's last update (updatedAt). This means: - Legitimately missed doses still show as missed (e.g., yesterday's dose not taken) - Doses from before a schedule change are NOT counted as missed (they were from a previous schedule configuration) Changes: - AppContext: Add isDoseFromPreviousSchedule helper - SchedulePage: Use context's missedPastDoseIds instead of local calc - Update tests to include missedPastDoseIds in mocks
This commit is contained in:
@@ -101,6 +101,7 @@ const createMockContext = (overrides = {}) => ({
|
||||
manuallyExpandedDays: new Set(),
|
||||
toggleDayCollapse: vi.fn(),
|
||||
openUserFilter: vi.fn(),
|
||||
missedPastDoseIds: [],
|
||||
...overrides,
|
||||
});
|
||||
|
||||
@@ -436,6 +437,7 @@ describe("SchedulePage with past days", () => {
|
||||
futureDays: mockFutureDays,
|
||||
coverageByMed: mockCoverageByMed,
|
||||
showPastDays: false,
|
||||
missedPastDoseIds: [`1-0-${Date.now() - 86400000}-John`], // One missed dose
|
||||
});
|
||||
});
|
||||
|
||||
@@ -467,6 +469,7 @@ describe("SchedulePage with past days", () => {
|
||||
pastDays: mockPastDays,
|
||||
showPastDays: false,
|
||||
setShowPastDays,
|
||||
missedPastDoseIds: [],
|
||||
});
|
||||
|
||||
render(
|
||||
|
||||
Reference in New Issue
Block a user