@medplum/react-scheduling 5.1.30 → 5.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/cjs/index.d.ts +233 -0
- package/dist/esm/index.d.ts +233 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +4 -4
- package/package.json +14 -10
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,13 +2,65 @@ import type { Appointment } from '@medplum/fhirtypes';
|
|
|
2
2
|
import type { HealthcareService } from '@medplum/fhirtypes';
|
|
3
3
|
import type { HealthcareServiceAvailableTime } from '@medplum/fhirtypes';
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
|
+
import type { Location as Location_2 } from '@medplum/fhirtypes';
|
|
6
|
+
import type { MedplumClient } from '@medplum/core';
|
|
5
7
|
import type { Reference } from '@medplum/fhirtypes';
|
|
8
|
+
import type { Resource } from '@medplum/fhirtypes';
|
|
6
9
|
import type { Schedule } from '@medplum/fhirtypes';
|
|
7
10
|
import type { Slot } from '@medplum/fhirtypes';
|
|
8
11
|
import type { WithId } from '@medplum/core';
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* One way of holding an appointment: a set of actors whose schedules `$find`
|
|
15
|
+
* intersects in a single request. A role contributes as many actors as were
|
|
16
|
+
* chosen for it, since everything chosen attends.
|
|
17
|
+
*/
|
|
18
|
+
export declare interface ActorCombination {
|
|
19
|
+
/** Matches `getActorGroupKey` of the appointments offered for these actors. */
|
|
20
|
+
readonly key: string;
|
|
21
|
+
readonly label: string;
|
|
22
|
+
readonly actors: readonly SchedulingActor[];
|
|
23
|
+
readonly schedules: readonly Reference<Schedule>[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* What an appointment is being asked for: the schedules chosen, per role.
|
|
28
|
+
* Everything named attends.
|
|
29
|
+
*/
|
|
30
|
+
export declare type ActorSelections = Partial<Record<SchedulingRole, readonly ScheduleCandidate[]>>;
|
|
31
|
+
|
|
10
32
|
export declare function addDays(date: Date, days: number): Date;
|
|
11
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Chooses the actors an appointment is held on, for one role.
|
|
36
|
+
*
|
|
37
|
+
* Everything chosen attends: `$find` intersects the schedules behind them,
|
|
38
|
+
* so naming a second actor narrows the times to the ones both are free for.
|
|
39
|
+
*
|
|
40
|
+
* Schedules are searched for as the name is typed (via `AsyncAutocomplete`).
|
|
41
|
+
*
|
|
42
|
+
* @param props - The React props.
|
|
43
|
+
* @returns The field for one role.
|
|
44
|
+
*/
|
|
45
|
+
export declare function AppointmentActorSelect(props: AppointmentActorSelectProps): JSX.Element;
|
|
46
|
+
|
|
47
|
+
export declare interface AppointmentActorSelectProps {
|
|
48
|
+
/** The role being filled. */
|
|
49
|
+
readonly role: SchedulingRole;
|
|
50
|
+
/** The service being booked. Nothing is offered until it resolves. */
|
|
51
|
+
readonly service: Reference<HealthcareService> | WithId<HealthcareService> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* The site being booked at. Actors sited elsewhere are left out: a room or a
|
|
54
|
+
* device anywhere inside it counts, a provider only if one of their
|
|
55
|
+
* PractitionerRoles names it.
|
|
56
|
+
*/
|
|
57
|
+
readonly location?: Reference<Location_2> | WithId<Location_2>;
|
|
58
|
+
readonly defaultValue?: readonly ScheduleCandidate[];
|
|
59
|
+
readonly onChange: (candidates: readonly ScheduleCandidate[]) => void;
|
|
60
|
+
readonly error?: string;
|
|
61
|
+
readonly disabled?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
12
64
|
export declare interface AppointmentDay {
|
|
13
65
|
/** `YYYY-MM-DD` in the scheduling timezone. */
|
|
14
66
|
readonly key: string;
|
|
@@ -39,6 +91,42 @@ export declare interface AppointmentDayTimesProps {
|
|
|
39
91
|
readonly selected?: Appointment;
|
|
40
92
|
}
|
|
41
93
|
|
|
94
|
+
/**
|
|
95
|
+
* One option in an appointment pick list: what it is called, over what tells it
|
|
96
|
+
* apart from the others.
|
|
97
|
+
* @param props - The React props.
|
|
98
|
+
* @returns The row.
|
|
99
|
+
*/
|
|
100
|
+
export declare function AppointmentOptionRow(props: AppointmentOptionRowProps): JSX.Element;
|
|
101
|
+
|
|
102
|
+
export declare interface AppointmentOptionRowProps {
|
|
103
|
+
readonly label: string;
|
|
104
|
+
/** What tells this option apart from one of the same name. Omitted when there is nothing on file. */
|
|
105
|
+
readonly detail?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Chooses the service an appointment is for.
|
|
110
|
+
*
|
|
111
|
+
* Only services configured for scheduling are offered. A `HealthcareService`
|
|
112
|
+
* without a `SchedulingParameters` extension has no duration or alignment for
|
|
113
|
+
* `$find` to work from, so booking against it cannot succeed.
|
|
114
|
+
*
|
|
115
|
+
* @param props - The React props.
|
|
116
|
+
* @returns The service field.
|
|
117
|
+
*/
|
|
118
|
+
export declare function AppointmentServiceSelect(props: AppointmentServiceSelectProps): JSX.Element;
|
|
119
|
+
|
|
120
|
+
export declare interface AppointmentServiceSelectProps {
|
|
121
|
+
readonly defaultValue?: WithId<HealthcareService>;
|
|
122
|
+
readonly onChange: (service: WithId<HealthcareService> | undefined) => void;
|
|
123
|
+
/** A chosen site, which narrows the services on offer to the ones held there. */
|
|
124
|
+
readonly location?: WithId<Location_2> | Reference<Location_2>;
|
|
125
|
+
readonly label?: string;
|
|
126
|
+
readonly error?: string;
|
|
127
|
+
readonly disabled?: boolean;
|
|
128
|
+
}
|
|
129
|
+
|
|
42
130
|
/** A calendar day's worth of available times, split by the actors offering them. */
|
|
43
131
|
export declare interface AppointmentSlotGroup {
|
|
44
132
|
/** Stable key derived from the actors, so React keys survive a refetch. */
|
|
@@ -65,6 +153,17 @@ export declare interface AppointmentSlotGroupCardProps {
|
|
|
65
153
|
readonly disabled?: boolean;
|
|
66
154
|
}
|
|
67
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Actor types whose schedules may be offered for booking.
|
|
158
|
+
*
|
|
159
|
+
* Does not include `PractitionerRole` to prevent double-booking
|
|
160
|
+
* a `Practitioner` who holds multiple roles. See `getSchedulingRole` for how
|
|
161
|
+
* `PractitionerRole` is still used to determine eligibility for a schedule.
|
|
162
|
+
*/
|
|
163
|
+
export declare const BOOKABLE_ACTOR_TYPES: readonly ["Practitioner", "Location", "Device"];
|
|
164
|
+
|
|
165
|
+
export declare type BookableActorType = (typeof BOOKABLE_ACTOR_TYPES)[number];
|
|
166
|
+
|
|
68
167
|
export declare function Calendar(props: CalendarProps): JSX.Element;
|
|
69
168
|
|
|
70
169
|
export declare interface CalendarProps {
|
|
@@ -135,6 +234,25 @@ export declare function enumerateDateRange(range: DateRange, limit?: number): Da
|
|
|
135
234
|
*/
|
|
136
235
|
export declare function filterByTimeOfDay(appointments: readonly Appointment[], timeOfDay: TimeOfDay, timezone?: string): Appointment[];
|
|
137
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Narrows candidates to the ones available at one location.
|
|
239
|
+
*
|
|
240
|
+
* A candidate that says nothing about where it is, or whose ancestry cannot be
|
|
241
|
+
* read, is kept: hiding something the caller may be entitled to book is worse
|
|
242
|
+
* than offering something at the wrong site.
|
|
243
|
+
*
|
|
244
|
+
* @param medplum - The Medplum client.
|
|
245
|
+
* @param candidates - Candidates to narrow.
|
|
246
|
+
* @param location - The site being booked at, or undefined to keep everything.
|
|
247
|
+
* @param options - Abort signal.
|
|
248
|
+
* @returns The candidates, minus the ones sited elsewhere.
|
|
249
|
+
*/
|
|
250
|
+
export declare function filterCandidatesByLocation(medplum: MedplumClient, candidates: readonly ScheduleCandidate[], location: Reference<Location_2> | WithId<Location_2> | undefined, options?: FilterCandidatesOptions): Promise<ScheduleCandidate[]>;
|
|
251
|
+
|
|
252
|
+
export declare interface FilterCandidatesOptions {
|
|
253
|
+
readonly signal?: AbortSignal;
|
|
254
|
+
}
|
|
255
|
+
|
|
138
256
|
/**
|
|
139
257
|
* Says in words which days a search covers.
|
|
140
258
|
* @param range - The days asked for.
|
|
@@ -157,6 +275,18 @@ export declare function formatDayHeading(date: Date): string;
|
|
|
157
275
|
*/
|
|
158
276
|
export declare function formatZonedTime(date: Date, timezone?: string): string;
|
|
159
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Builds the sets of actors an appointment could be held on.
|
|
280
|
+
*
|
|
281
|
+
* One combination is one `$find` request: the schedules within it are
|
|
282
|
+
* intersected, so its times are the times all of those actors are free.
|
|
283
|
+
*
|
|
284
|
+
* @param selections - What has been chosen.
|
|
285
|
+
* @returns One combination holding every chosen actor, in role order, or an
|
|
286
|
+
* empty list when nothing is chosen.
|
|
287
|
+
*/
|
|
288
|
+
export declare function getActorCombinations(selections: ActorSelections): ActorCombination[];
|
|
289
|
+
|
|
160
290
|
/**
|
|
161
291
|
* Builds a key identifying the set of actors an appointment is offered by.
|
|
162
292
|
* @param appointment - The proposed appointment.
|
|
@@ -193,6 +323,20 @@ export declare function getActorsKey(actors: readonly Reference[]): string;
|
|
|
193
323
|
*/
|
|
194
324
|
export declare function getAppointmentKey(appointment: Appointment): string;
|
|
195
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Names a candidate's actor, for use in plain-text option lists.
|
|
328
|
+
* @param candidate - The candidate to name.
|
|
329
|
+
* @returns The name to show.
|
|
330
|
+
*/
|
|
331
|
+
export declare function getCandidateDisplay(candidate: ScheduleCandidate): string;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Returns the role a candidate fills, from the type of its actor.
|
|
335
|
+
* @param candidate - The candidate to read.
|
|
336
|
+
* @returns The role, or undefined for an actor of a type nothing books against.
|
|
337
|
+
*/
|
|
338
|
+
export declare function getCandidateRole(candidate: ScheduleCandidate): SchedulingRole | undefined;
|
|
339
|
+
|
|
196
340
|
/**
|
|
197
341
|
* Returns an appointment's length in whole minutes.
|
|
198
342
|
* @param appointment - The proposed appointment.
|
|
@@ -241,6 +385,20 @@ export declare function getNativeInputType(type: 'date' | 'time'): string;
|
|
|
241
385
|
*/
|
|
242
386
|
export declare function getSchedulingRole(actorType: SchedulingActorType): SchedulingRole;
|
|
243
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Returns everything chosen, across roles.
|
|
390
|
+
* @param selections - What has been chosen.
|
|
391
|
+
* @returns The chosen candidates, in `SCHEDULING_ROLES` order.
|
|
392
|
+
*/
|
|
393
|
+
export declare function getSelectedCandidates(selections: ActorSelections): ScheduleCandidate[];
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Reports why the current selections cannot be searched, if they cannot.
|
|
397
|
+
* @param selections - What has been chosen.
|
|
398
|
+
* @returns A message to show the user, or undefined when the search can run.
|
|
399
|
+
*/
|
|
400
|
+
export declare function getSelectionError(selections: ActorSelections): string | undefined;
|
|
401
|
+
|
|
244
402
|
/**
|
|
245
403
|
* Groups proposed appointments into days, and each day into the sets of actors
|
|
246
404
|
* offering those times.
|
|
@@ -251,6 +409,15 @@ export declare function getSchedulingRole(actorType: SchedulingActorType): Sched
|
|
|
251
409
|
*/
|
|
252
410
|
export declare function groupAppointmentsByDay(appointments: readonly Appointment[], timezone?: string): AppointmentDay[];
|
|
253
411
|
|
|
412
|
+
export declare function isBookableActorType(value: string | undefined): value is BookableActorType;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Reports whether a role has to be filled.
|
|
416
|
+
* @param role - The role being filled.
|
|
417
|
+
* @returns Whether a search can run without it.
|
|
418
|
+
*/
|
|
419
|
+
export declare function isRoleRequired(role: SchedulingRole): boolean;
|
|
420
|
+
|
|
254
421
|
/**
|
|
255
422
|
* Returns whether two instants fall on the same local day.
|
|
256
423
|
* @param left - The first instant.
|
|
@@ -304,6 +471,16 @@ export declare function ScheduleAvailabilityEditor(props: ScheduleAvailabilityEd
|
|
|
304
471
|
*/
|
|
305
472
|
export declare type ScheduleAvailabilityEditorProps = ScheduleOverrideEditorProps | ServiceDefaultEditorProps;
|
|
306
473
|
|
|
474
|
+
/**
|
|
475
|
+
* A Schedule that can be booked for a service, paired with the actor it belongs
|
|
476
|
+
* to.
|
|
477
|
+
*/
|
|
478
|
+
export declare interface ScheduleCandidate {
|
|
479
|
+
readonly schedule: WithId<Schedule>;
|
|
480
|
+
/** The actor itself, when the search was able to include it. */
|
|
481
|
+
readonly actorResource: WithId<Resource> | undefined;
|
|
482
|
+
}
|
|
483
|
+
|
|
307
484
|
/**
|
|
308
485
|
* Props for editing the availability override a Schedule holds for one service.
|
|
309
486
|
* @param schedule - The Schedule holding the availability override. Must have exactly one actor, as scheduling requires.
|
|
@@ -338,6 +515,32 @@ export declare type SchedulingActorType = (typeof SCHEDULING_ACTOR_TYPES)[number
|
|
|
338
515
|
|
|
339
516
|
export declare type SchedulingRole = (typeof SCHEDULING_ROLES)[number];
|
|
340
517
|
|
|
518
|
+
/**
|
|
519
|
+
* Finds the Schedules that can be booked for one role of a HealthcareService,
|
|
520
|
+
* narrowed to the actors whose name matches what was typed.
|
|
521
|
+
* @param medplum - The Medplum client.
|
|
522
|
+
* @param service - The HealthcareService being booked.
|
|
523
|
+
* @param options - The role, the text typed, the site, an abort signal, and a page size.
|
|
524
|
+
* @returns The matching schedules, each with its actor, by display name.
|
|
525
|
+
*/
|
|
526
|
+
export declare function searchScheduleCandidates(medplum: MedplumClient, service: WithId<HealthcareService>, options: SearchScheduleCandidatesOptions): Promise<ScheduleCandidate[]>;
|
|
527
|
+
|
|
528
|
+
export declare interface SearchScheduleCandidatesOptions {
|
|
529
|
+
/** Which of the service's actors to offer. */
|
|
530
|
+
readonly role: SchedulingRole;
|
|
531
|
+
/** What the user typed. Empty offers whatever the role has, unfiltered by name. */
|
|
532
|
+
readonly query: string;
|
|
533
|
+
/**
|
|
534
|
+
* The site being booked at. Actors sited elsewhere are left out: a room or a
|
|
535
|
+
* device anywhere inside it counts, a provider only if one of their
|
|
536
|
+
* PractitionerRoles names it.
|
|
537
|
+
*/
|
|
538
|
+
readonly location?: Reference<Location_2> | WithId<Location_2>;
|
|
539
|
+
readonly signal?: AbortSignal;
|
|
540
|
+
/** Maximum schedules to consider. Defaults to 25. */
|
|
541
|
+
readonly count?: number;
|
|
542
|
+
}
|
|
543
|
+
|
|
341
544
|
/**
|
|
342
545
|
* Props for editing a service's own default hours, in place of any one calendar's override.
|
|
343
546
|
* @param schedule - Omitted, which is what selects this mode.
|
|
@@ -375,4 +578,34 @@ export declare function setScheduleAvailability(schedule: Schedule, service: Wit
|
|
|
375
578
|
|
|
376
579
|
export declare type TimeOfDay = 'any' | 'morning' | 'afternoon';
|
|
377
580
|
|
|
581
|
+
/**
|
|
582
|
+
* Searches for the times an appointment could be held at.
|
|
583
|
+
* @param options - The service, actor combinations, days, and page size.
|
|
584
|
+
* @returns The times offered, plus load and error state.
|
|
585
|
+
*/
|
|
586
|
+
export declare function useProposedAppointments(options: UseProposedAppointmentsOptions): UseProposedAppointmentsResult;
|
|
587
|
+
|
|
588
|
+
export declare interface UseProposedAppointmentsOptions {
|
|
589
|
+
/** The service being booked, as a reference or the resource itself. */
|
|
590
|
+
readonly service: Reference<HealthcareService> | WithId<HealthcareService> | undefined;
|
|
591
|
+
/** The sets of actors to search for, from `getActorCombinations`. */
|
|
592
|
+
readonly combinations: readonly ActorCombination[];
|
|
593
|
+
/** The days to search. Both ends are needed; `$find` refuses an open range. */
|
|
594
|
+
readonly range: DateRange;
|
|
595
|
+
/** Times to ask for per combination. Defaults to 20. */
|
|
596
|
+
readonly count?: number;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export declare interface UseProposedAppointmentsResult {
|
|
600
|
+
/**
|
|
601
|
+
* Every time offered, never persisted — `$find` proposes.
|
|
602
|
+
*/
|
|
603
|
+
readonly appointments: readonly Appointment[];
|
|
604
|
+
/** How many `$find` requests the current combinations take. */
|
|
605
|
+
readonly requestCount: number;
|
|
606
|
+
readonly loading: boolean;
|
|
607
|
+
/** Set only when every combination failed. */
|
|
608
|
+
readonly error: Error | undefined;
|
|
609
|
+
}
|
|
610
|
+
|
|
378
611
|
export { }
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,13 +2,65 @@ import type { Appointment } from '@medplum/fhirtypes';
|
|
|
2
2
|
import type { HealthcareService } from '@medplum/fhirtypes';
|
|
3
3
|
import type { HealthcareServiceAvailableTime } from '@medplum/fhirtypes';
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
|
+
import type { Location as Location_2 } from '@medplum/fhirtypes';
|
|
6
|
+
import type { MedplumClient } from '@medplum/core';
|
|
5
7
|
import type { Reference } from '@medplum/fhirtypes';
|
|
8
|
+
import type { Resource } from '@medplum/fhirtypes';
|
|
6
9
|
import type { Schedule } from '@medplum/fhirtypes';
|
|
7
10
|
import type { Slot } from '@medplum/fhirtypes';
|
|
8
11
|
import type { WithId } from '@medplum/core';
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* One way of holding an appointment: a set of actors whose schedules `$find`
|
|
15
|
+
* intersects in a single request. A role contributes as many actors as were
|
|
16
|
+
* chosen for it, since everything chosen attends.
|
|
17
|
+
*/
|
|
18
|
+
export declare interface ActorCombination {
|
|
19
|
+
/** Matches `getActorGroupKey` of the appointments offered for these actors. */
|
|
20
|
+
readonly key: string;
|
|
21
|
+
readonly label: string;
|
|
22
|
+
readonly actors: readonly SchedulingActor[];
|
|
23
|
+
readonly schedules: readonly Reference<Schedule>[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* What an appointment is being asked for: the schedules chosen, per role.
|
|
28
|
+
* Everything named attends.
|
|
29
|
+
*/
|
|
30
|
+
export declare type ActorSelections = Partial<Record<SchedulingRole, readonly ScheduleCandidate[]>>;
|
|
31
|
+
|
|
10
32
|
export declare function addDays(date: Date, days: number): Date;
|
|
11
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Chooses the actors an appointment is held on, for one role.
|
|
36
|
+
*
|
|
37
|
+
* Everything chosen attends: `$find` intersects the schedules behind them,
|
|
38
|
+
* so naming a second actor narrows the times to the ones both are free for.
|
|
39
|
+
*
|
|
40
|
+
* Schedules are searched for as the name is typed (via `AsyncAutocomplete`).
|
|
41
|
+
*
|
|
42
|
+
* @param props - The React props.
|
|
43
|
+
* @returns The field for one role.
|
|
44
|
+
*/
|
|
45
|
+
export declare function AppointmentActorSelect(props: AppointmentActorSelectProps): JSX.Element;
|
|
46
|
+
|
|
47
|
+
export declare interface AppointmentActorSelectProps {
|
|
48
|
+
/** The role being filled. */
|
|
49
|
+
readonly role: SchedulingRole;
|
|
50
|
+
/** The service being booked. Nothing is offered until it resolves. */
|
|
51
|
+
readonly service: Reference<HealthcareService> | WithId<HealthcareService> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* The site being booked at. Actors sited elsewhere are left out: a room or a
|
|
54
|
+
* device anywhere inside it counts, a provider only if one of their
|
|
55
|
+
* PractitionerRoles names it.
|
|
56
|
+
*/
|
|
57
|
+
readonly location?: Reference<Location_2> | WithId<Location_2>;
|
|
58
|
+
readonly defaultValue?: readonly ScheduleCandidate[];
|
|
59
|
+
readonly onChange: (candidates: readonly ScheduleCandidate[]) => void;
|
|
60
|
+
readonly error?: string;
|
|
61
|
+
readonly disabled?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
12
64
|
export declare interface AppointmentDay {
|
|
13
65
|
/** `YYYY-MM-DD` in the scheduling timezone. */
|
|
14
66
|
readonly key: string;
|
|
@@ -39,6 +91,42 @@ export declare interface AppointmentDayTimesProps {
|
|
|
39
91
|
readonly selected?: Appointment;
|
|
40
92
|
}
|
|
41
93
|
|
|
94
|
+
/**
|
|
95
|
+
* One option in an appointment pick list: what it is called, over what tells it
|
|
96
|
+
* apart from the others.
|
|
97
|
+
* @param props - The React props.
|
|
98
|
+
* @returns The row.
|
|
99
|
+
*/
|
|
100
|
+
export declare function AppointmentOptionRow(props: AppointmentOptionRowProps): JSX.Element;
|
|
101
|
+
|
|
102
|
+
export declare interface AppointmentOptionRowProps {
|
|
103
|
+
readonly label: string;
|
|
104
|
+
/** What tells this option apart from one of the same name. Omitted when there is nothing on file. */
|
|
105
|
+
readonly detail?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Chooses the service an appointment is for.
|
|
110
|
+
*
|
|
111
|
+
* Only services configured for scheduling are offered. A `HealthcareService`
|
|
112
|
+
* without a `SchedulingParameters` extension has no duration or alignment for
|
|
113
|
+
* `$find` to work from, so booking against it cannot succeed.
|
|
114
|
+
*
|
|
115
|
+
* @param props - The React props.
|
|
116
|
+
* @returns The service field.
|
|
117
|
+
*/
|
|
118
|
+
export declare function AppointmentServiceSelect(props: AppointmentServiceSelectProps): JSX.Element;
|
|
119
|
+
|
|
120
|
+
export declare interface AppointmentServiceSelectProps {
|
|
121
|
+
readonly defaultValue?: WithId<HealthcareService>;
|
|
122
|
+
readonly onChange: (service: WithId<HealthcareService> | undefined) => void;
|
|
123
|
+
/** A chosen site, which narrows the services on offer to the ones held there. */
|
|
124
|
+
readonly location?: WithId<Location_2> | Reference<Location_2>;
|
|
125
|
+
readonly label?: string;
|
|
126
|
+
readonly error?: string;
|
|
127
|
+
readonly disabled?: boolean;
|
|
128
|
+
}
|
|
129
|
+
|
|
42
130
|
/** A calendar day's worth of available times, split by the actors offering them. */
|
|
43
131
|
export declare interface AppointmentSlotGroup {
|
|
44
132
|
/** Stable key derived from the actors, so React keys survive a refetch. */
|
|
@@ -65,6 +153,17 @@ export declare interface AppointmentSlotGroupCardProps {
|
|
|
65
153
|
readonly disabled?: boolean;
|
|
66
154
|
}
|
|
67
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Actor types whose schedules may be offered for booking.
|
|
158
|
+
*
|
|
159
|
+
* Does not include `PractitionerRole` to prevent double-booking
|
|
160
|
+
* a `Practitioner` who holds multiple roles. See `getSchedulingRole` for how
|
|
161
|
+
* `PractitionerRole` is still used to determine eligibility for a schedule.
|
|
162
|
+
*/
|
|
163
|
+
export declare const BOOKABLE_ACTOR_TYPES: readonly ["Practitioner", "Location", "Device"];
|
|
164
|
+
|
|
165
|
+
export declare type BookableActorType = (typeof BOOKABLE_ACTOR_TYPES)[number];
|
|
166
|
+
|
|
68
167
|
export declare function Calendar(props: CalendarProps): JSX.Element;
|
|
69
168
|
|
|
70
169
|
export declare interface CalendarProps {
|
|
@@ -135,6 +234,25 @@ export declare function enumerateDateRange(range: DateRange, limit?: number): Da
|
|
|
135
234
|
*/
|
|
136
235
|
export declare function filterByTimeOfDay(appointments: readonly Appointment[], timeOfDay: TimeOfDay, timezone?: string): Appointment[];
|
|
137
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Narrows candidates to the ones available at one location.
|
|
239
|
+
*
|
|
240
|
+
* A candidate that says nothing about where it is, or whose ancestry cannot be
|
|
241
|
+
* read, is kept: hiding something the caller may be entitled to book is worse
|
|
242
|
+
* than offering something at the wrong site.
|
|
243
|
+
*
|
|
244
|
+
* @param medplum - The Medplum client.
|
|
245
|
+
* @param candidates - Candidates to narrow.
|
|
246
|
+
* @param location - The site being booked at, or undefined to keep everything.
|
|
247
|
+
* @param options - Abort signal.
|
|
248
|
+
* @returns The candidates, minus the ones sited elsewhere.
|
|
249
|
+
*/
|
|
250
|
+
export declare function filterCandidatesByLocation(medplum: MedplumClient, candidates: readonly ScheduleCandidate[], location: Reference<Location_2> | WithId<Location_2> | undefined, options?: FilterCandidatesOptions): Promise<ScheduleCandidate[]>;
|
|
251
|
+
|
|
252
|
+
export declare interface FilterCandidatesOptions {
|
|
253
|
+
readonly signal?: AbortSignal;
|
|
254
|
+
}
|
|
255
|
+
|
|
138
256
|
/**
|
|
139
257
|
* Says in words which days a search covers.
|
|
140
258
|
* @param range - The days asked for.
|
|
@@ -157,6 +275,18 @@ export declare function formatDayHeading(date: Date): string;
|
|
|
157
275
|
*/
|
|
158
276
|
export declare function formatZonedTime(date: Date, timezone?: string): string;
|
|
159
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Builds the sets of actors an appointment could be held on.
|
|
280
|
+
*
|
|
281
|
+
* One combination is one `$find` request: the schedules within it are
|
|
282
|
+
* intersected, so its times are the times all of those actors are free.
|
|
283
|
+
*
|
|
284
|
+
* @param selections - What has been chosen.
|
|
285
|
+
* @returns One combination holding every chosen actor, in role order, or an
|
|
286
|
+
* empty list when nothing is chosen.
|
|
287
|
+
*/
|
|
288
|
+
export declare function getActorCombinations(selections: ActorSelections): ActorCombination[];
|
|
289
|
+
|
|
160
290
|
/**
|
|
161
291
|
* Builds a key identifying the set of actors an appointment is offered by.
|
|
162
292
|
* @param appointment - The proposed appointment.
|
|
@@ -193,6 +323,20 @@ export declare function getActorsKey(actors: readonly Reference[]): string;
|
|
|
193
323
|
*/
|
|
194
324
|
export declare function getAppointmentKey(appointment: Appointment): string;
|
|
195
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Names a candidate's actor, for use in plain-text option lists.
|
|
328
|
+
* @param candidate - The candidate to name.
|
|
329
|
+
* @returns The name to show.
|
|
330
|
+
*/
|
|
331
|
+
export declare function getCandidateDisplay(candidate: ScheduleCandidate): string;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Returns the role a candidate fills, from the type of its actor.
|
|
335
|
+
* @param candidate - The candidate to read.
|
|
336
|
+
* @returns The role, or undefined for an actor of a type nothing books against.
|
|
337
|
+
*/
|
|
338
|
+
export declare function getCandidateRole(candidate: ScheduleCandidate): SchedulingRole | undefined;
|
|
339
|
+
|
|
196
340
|
/**
|
|
197
341
|
* Returns an appointment's length in whole minutes.
|
|
198
342
|
* @param appointment - The proposed appointment.
|
|
@@ -241,6 +385,20 @@ export declare function getNativeInputType(type: 'date' | 'time'): string;
|
|
|
241
385
|
*/
|
|
242
386
|
export declare function getSchedulingRole(actorType: SchedulingActorType): SchedulingRole;
|
|
243
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Returns everything chosen, across roles.
|
|
390
|
+
* @param selections - What has been chosen.
|
|
391
|
+
* @returns The chosen candidates, in `SCHEDULING_ROLES` order.
|
|
392
|
+
*/
|
|
393
|
+
export declare function getSelectedCandidates(selections: ActorSelections): ScheduleCandidate[];
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Reports why the current selections cannot be searched, if they cannot.
|
|
397
|
+
* @param selections - What has been chosen.
|
|
398
|
+
* @returns A message to show the user, or undefined when the search can run.
|
|
399
|
+
*/
|
|
400
|
+
export declare function getSelectionError(selections: ActorSelections): string | undefined;
|
|
401
|
+
|
|
244
402
|
/**
|
|
245
403
|
* Groups proposed appointments into days, and each day into the sets of actors
|
|
246
404
|
* offering those times.
|
|
@@ -251,6 +409,15 @@ export declare function getSchedulingRole(actorType: SchedulingActorType): Sched
|
|
|
251
409
|
*/
|
|
252
410
|
export declare function groupAppointmentsByDay(appointments: readonly Appointment[], timezone?: string): AppointmentDay[];
|
|
253
411
|
|
|
412
|
+
export declare function isBookableActorType(value: string | undefined): value is BookableActorType;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Reports whether a role has to be filled.
|
|
416
|
+
* @param role - The role being filled.
|
|
417
|
+
* @returns Whether a search can run without it.
|
|
418
|
+
*/
|
|
419
|
+
export declare function isRoleRequired(role: SchedulingRole): boolean;
|
|
420
|
+
|
|
254
421
|
/**
|
|
255
422
|
* Returns whether two instants fall on the same local day.
|
|
256
423
|
* @param left - The first instant.
|
|
@@ -304,6 +471,16 @@ export declare function ScheduleAvailabilityEditor(props: ScheduleAvailabilityEd
|
|
|
304
471
|
*/
|
|
305
472
|
export declare type ScheduleAvailabilityEditorProps = ScheduleOverrideEditorProps | ServiceDefaultEditorProps;
|
|
306
473
|
|
|
474
|
+
/**
|
|
475
|
+
* A Schedule that can be booked for a service, paired with the actor it belongs
|
|
476
|
+
* to.
|
|
477
|
+
*/
|
|
478
|
+
export declare interface ScheduleCandidate {
|
|
479
|
+
readonly schedule: WithId<Schedule>;
|
|
480
|
+
/** The actor itself, when the search was able to include it. */
|
|
481
|
+
readonly actorResource: WithId<Resource> | undefined;
|
|
482
|
+
}
|
|
483
|
+
|
|
307
484
|
/**
|
|
308
485
|
* Props for editing the availability override a Schedule holds for one service.
|
|
309
486
|
* @param schedule - The Schedule holding the availability override. Must have exactly one actor, as scheduling requires.
|
|
@@ -338,6 +515,32 @@ export declare type SchedulingActorType = (typeof SCHEDULING_ACTOR_TYPES)[number
|
|
|
338
515
|
|
|
339
516
|
export declare type SchedulingRole = (typeof SCHEDULING_ROLES)[number];
|
|
340
517
|
|
|
518
|
+
/**
|
|
519
|
+
* Finds the Schedules that can be booked for one role of a HealthcareService,
|
|
520
|
+
* narrowed to the actors whose name matches what was typed.
|
|
521
|
+
* @param medplum - The Medplum client.
|
|
522
|
+
* @param service - The HealthcareService being booked.
|
|
523
|
+
* @param options - The role, the text typed, the site, an abort signal, and a page size.
|
|
524
|
+
* @returns The matching schedules, each with its actor, by display name.
|
|
525
|
+
*/
|
|
526
|
+
export declare function searchScheduleCandidates(medplum: MedplumClient, service: WithId<HealthcareService>, options: SearchScheduleCandidatesOptions): Promise<ScheduleCandidate[]>;
|
|
527
|
+
|
|
528
|
+
export declare interface SearchScheduleCandidatesOptions {
|
|
529
|
+
/** Which of the service's actors to offer. */
|
|
530
|
+
readonly role: SchedulingRole;
|
|
531
|
+
/** What the user typed. Empty offers whatever the role has, unfiltered by name. */
|
|
532
|
+
readonly query: string;
|
|
533
|
+
/**
|
|
534
|
+
* The site being booked at. Actors sited elsewhere are left out: a room or a
|
|
535
|
+
* device anywhere inside it counts, a provider only if one of their
|
|
536
|
+
* PractitionerRoles names it.
|
|
537
|
+
*/
|
|
538
|
+
readonly location?: Reference<Location_2> | WithId<Location_2>;
|
|
539
|
+
readonly signal?: AbortSignal;
|
|
540
|
+
/** Maximum schedules to consider. Defaults to 25. */
|
|
541
|
+
readonly count?: number;
|
|
542
|
+
}
|
|
543
|
+
|
|
341
544
|
/**
|
|
342
545
|
* Props for editing a service's own default hours, in place of any one calendar's override.
|
|
343
546
|
* @param schedule - Omitted, which is what selects this mode.
|
|
@@ -375,4 +578,34 @@ export declare function setScheduleAvailability(schedule: Schedule, service: Wit
|
|
|
375
578
|
|
|
376
579
|
export declare type TimeOfDay = 'any' | 'morning' | 'afternoon';
|
|
377
580
|
|
|
581
|
+
/**
|
|
582
|
+
* Searches for the times an appointment could be held at.
|
|
583
|
+
* @param options - The service, actor combinations, days, and page size.
|
|
584
|
+
* @returns The times offered, plus load and error state.
|
|
585
|
+
*/
|
|
586
|
+
export declare function useProposedAppointments(options: UseProposedAppointmentsOptions): UseProposedAppointmentsResult;
|
|
587
|
+
|
|
588
|
+
export declare interface UseProposedAppointmentsOptions {
|
|
589
|
+
/** The service being booked, as a reference or the resource itself. */
|
|
590
|
+
readonly service: Reference<HealthcareService> | WithId<HealthcareService> | undefined;
|
|
591
|
+
/** The sets of actors to search for, from `getActorCombinations`. */
|
|
592
|
+
readonly combinations: readonly ActorCombination[];
|
|
593
|
+
/** The days to search. Both ends are needed; `$find` refuses an open range. */
|
|
594
|
+
readonly range: DateRange;
|
|
595
|
+
/** Times to ask for per combination. Defaults to 20. */
|
|
596
|
+
readonly count?: number;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export declare interface UseProposedAppointmentsResult {
|
|
600
|
+
/**
|
|
601
|
+
* Every time offered, never persisted — `$find` proposes.
|
|
602
|
+
*/
|
|
603
|
+
readonly appointments: readonly Appointment[];
|
|
604
|
+
/** How many `$find` requests the current combinations take. */
|
|
605
|
+
readonly requestCount: number;
|
|
606
|
+
readonly loading: boolean;
|
|
607
|
+
/** Set only when every combination failed. */
|
|
608
|
+
readonly error: Error | undefined;
|
|
609
|
+
}
|
|
610
|
+
|
|
378
611
|
export { }
|