// Pure derivation for the practitioner-recommendation callout: fold the funnel's per-schedule // data into one `BookablePractitioner` per distinct practitioner-role that offers the chosen service - // ORG-WIDE, across every location. Location is NEVER used to prune here (that's the whole point: location // frames the manual list but must never narrow the specialty ranker). It is used only to CHOOSE which // site to display for a role that serves the service at more than one - via `preferLocationId`, the same // tie-break handleScheduleChange uses (prefer the selected site, else the first). Kept pure + unit-tested // so this non-trivial fold isn't buried in the stateful booking component. import type { CodeableConcept, Reference } from 'fhir/r4'; import type { BookablePractitioner } from './matchPractitionerSuggestions'; // One booking "block" as the component already holds it (a service-matched Schedule resolved to its role, // practitioner display, and the site(s) it serves that service at). Plain data - no FHIR traversal here. export interface BookablePractitionerCandidate { // The org-scoped PractitionerRole id - the dedup + selection key. Candidates without one are skipped // (there is nothing stable to recommend or select). practitionerRoleId?: string; // The practitioner's display name - the SAME source the manual practitioner