/** Whether any bookable window, as a local-ISO start, begins on or after the start of today. */ export const opensFrom = (windows: { start: string }[], todayStart: Date): boolean => windows.some((window) => new Date(window.start) >= todayStart); /** * The schedules the patient picker lists: one per clinician, and only a clinician with an open window. * A clinician with none used to be listed and then answered "not currently available" once chosen. * A schedule naming no clinician is kept, as before. */ export function offerablePractitionerSchedules( matching: S[], practitionerIdOf: (schedule: S) => string | undefined, hasOpenTimes: (practitionerId: string) => boolean, ): S[] { const seen = new Set(); return matching.filter((schedule) => { const practitionerId = practitionerIdOf(schedule); if (!practitionerId) return true; if (seen.has(practitionerId)) return false; seen.add(practitionerId); return hasOpenTimes(practitionerId); }); }