@medplum/react-hooks 5.1.26 → 5.1.27
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 +8 -6
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/cjs/index.d.ts +141 -5
- package/dist/esm/index.d.ts +141 -5
- package/dist/esm/index.mjs +9 -7
- package/dist/esm/index.mjs.map +4 -4
- package/package.json +6 -6
package/dist/cjs/index.d.ts
CHANGED
|
@@ -8,11 +8,18 @@ import type { ExtractResource } from '@medplum/fhirtypes';
|
|
|
8
8
|
import type { Identifier } from '@medplum/fhirtypes';
|
|
9
9
|
import type { JSX } from 'react';
|
|
10
10
|
import type { Medication } from '@medplum/fhirtypes';
|
|
11
|
+
import type { MedicationCartClearRequest } from '@medplum/core';
|
|
12
|
+
import type { MedicationCartManageResponse } from '@medplum/core';
|
|
13
|
+
import type { MedicationCartRemoveRequest } from '@medplum/core';
|
|
14
|
+
import type { MedicationCheckoutRequest } from '@medplum/core';
|
|
15
|
+
import type { MedicationCheckoutResponse } from '@medplum/core';
|
|
11
16
|
import type { MedicationOrderRequest } from '@medplum/core';
|
|
12
17
|
import type { MedicationOrderResponse } from '@medplum/core';
|
|
18
|
+
import type { MedicationRequest } from '@medplum/fhirtypes';
|
|
13
19
|
import type { MedicationSearchParams } from '@medplum/core';
|
|
14
20
|
import type { MedplumClient } from '@medplum/core';
|
|
15
21
|
import type { OperationOutcome } from '@medplum/fhirtypes';
|
|
22
|
+
import type { OrderSetSyncResponse } from '@medplum/core';
|
|
16
23
|
import type { Organization } from '@medplum/fhirtypes';
|
|
17
24
|
import type { Patient } from '@medplum/fhirtypes';
|
|
18
25
|
import type { PharmacySearchParams } from '@medplum/core';
|
|
@@ -30,6 +37,7 @@ import type { ReactNode } from 'react';
|
|
|
30
37
|
import type { Reference } from '@medplum/fhirtypes';
|
|
31
38
|
import type { Resource } from '@medplum/fhirtypes';
|
|
32
39
|
import type { ResourceArray } from '@medplum/core';
|
|
40
|
+
import type { ResourceModifiedEvent } from '@medplum/core';
|
|
33
41
|
import type { ResourceType } from '@medplum/fhirtypes';
|
|
34
42
|
import type { SearchRequest } from '@medplum/core';
|
|
35
43
|
import type { Signature } from '@medplum/fhirtypes';
|
|
@@ -106,8 +114,22 @@ export declare function isChoiceQuestion(item: QuestionnaireItem): boolean;
|
|
|
106
114
|
*/
|
|
107
115
|
export declare function isQuestionEnabled(item: QuestionnaireItem, questionnaireResponse: QuestionnaireResponse | undefined): boolean;
|
|
108
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Returns true if an error thrown while expanding a ValueSet means the value set itself is
|
|
119
|
+
* unavailable — a permanent 400/404 (e.g. "ValueSet not found"). Transient failures (429 rate
|
|
120
|
+
* limit, 401, 5xx, network) return false so a blip never disables a field.
|
|
121
|
+
* @param err - The error thrown by `valueSetExpand`.
|
|
122
|
+
* @returns True for a permanent 400/404, false for a transient failure.
|
|
123
|
+
*/
|
|
124
|
+
export declare function isValueSetUnavailableError(err: unknown): boolean;
|
|
125
|
+
|
|
126
|
+
/** Thrown by {@link UseMedicationCartReturn.checkout} when an {@link UseMedicationCartReturn.addToCart} call is still in flight. */
|
|
127
|
+
export declare const MEDICATION_CART_ADD_IN_PROGRESS = "Cannot checkout while a medication is still being added to the cart";
|
|
128
|
+
|
|
109
129
|
export declare interface MedicationIFrameOptions {
|
|
110
130
|
readonly patientId?: string;
|
|
131
|
+
/** Selected practice location for multi-practice deployments. */
|
|
132
|
+
readonly organization?: Reference<Organization>;
|
|
111
133
|
readonly onPatientSyncSuccess?: () => void;
|
|
112
134
|
readonly onIframeSuccess?: (url: string) => void;
|
|
113
135
|
readonly onError?: (err: unknown) => void;
|
|
@@ -296,6 +318,53 @@ export declare function typedValueToResponseItem(item: QuestionnaireItem, value:
|
|
|
296
318
|
|
|
297
319
|
export declare const useCachedBinaryUrl: (binaryUrl: string | undefined) => string | undefined;
|
|
298
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Vendor-neutral hook for the full **medication cart** lifecycle: add a draft
|
|
323
|
+
* line (`createResource`), check out a set of drafts into the vendor's batch
|
|
324
|
+
* approval queue (`$checkout-medications`), and remove/clear cart lines
|
|
325
|
+
* (`$remove-cart-medication` / `$clear-cart`).
|
|
326
|
+
*
|
|
327
|
+
* Cart checkout / remove / clear hit project-scoped **FHIR custom operations**
|
|
328
|
+
* whose backing Bot is chosen at deploy time via an `OperationDefinition`
|
|
329
|
+
* carrying the `operationDefinition-implementation` extension — see
|
|
330
|
+
* [bot operations docs](https://www.medplum.com/docs/bots/custom-fhir-operations).
|
|
331
|
+
* The server's `tryCustomOperation` dispatch handles the OD → Bot lookup, so
|
|
332
|
+
* projects swap vendors by deploying a different bot under the same code.
|
|
333
|
+
*
|
|
334
|
+
* `addToCart` is plain FHIR `createResource` (no `$add-cart` operation): the
|
|
335
|
+
* Medplum-side cart is the set of draft `MedicationRequest`s. Vendor staging
|
|
336
|
+
* (e.g. ScriptSure MedCart) happens at checkout. Vendors without a batch
|
|
337
|
+
* approval queue (e.g. DoseSpot iframe-first) simply never call `checkout` /
|
|
338
|
+
* `removeFromCart` / `clearCart`.
|
|
339
|
+
*
|
|
340
|
+
* Requests for the custom operations are encoded as `Parameters` bodies and
|
|
341
|
+
* decoded by the matching `@medplum/core` helpers. Per-line outcomes arrive in
|
|
342
|
+
* `response.items`.
|
|
343
|
+
*
|
|
344
|
+
* @returns Cart add / checkout / remove / clear callbacks plus `adding` state.
|
|
345
|
+
*/
|
|
346
|
+
export declare function useMedicationCart(): UseMedicationCartReturn;
|
|
347
|
+
|
|
348
|
+
export declare interface UseMedicationCartReturn {
|
|
349
|
+
/**
|
|
350
|
+
* Persist a draft `MedicationRequest` as a cart line via plain FHIR
|
|
351
|
+
* `createResource` (no custom operation). Vendor staging happens later at
|
|
352
|
+
* {@link UseMedicationCartReturn.checkout}.
|
|
353
|
+
*/
|
|
354
|
+
addToCart: (medicationRequest: MedicationRequest) => Promise<MedicationRequest>;
|
|
355
|
+
/** True while one or more {@link UseMedicationCartReturn.addToCart} calls are in flight. */
|
|
356
|
+
adding: boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Submit draft cart lines to the vendor's batch approval queue and return an
|
|
359
|
+
* embeddable approval-widget URL. Refuses while {@link UseMedicationCartReturn.adding} is true.
|
|
360
|
+
*/
|
|
361
|
+
checkout: (input: MedicationCheckoutRequest) => Promise<MedicationCheckoutResponse>;
|
|
362
|
+
/** Remove a single draft `MedicationRequest` from the patient's vendor cart. */
|
|
363
|
+
removeFromCart: (input: MedicationCartRemoveRequest) => Promise<MedicationCartManageResponse>;
|
|
364
|
+
/** Remove every item from the patient's vendor cart. */
|
|
365
|
+
clearCart: (input: MedicationCartClearRequest) => Promise<MedicationCartManageResponse>;
|
|
366
|
+
}
|
|
367
|
+
|
|
299
368
|
/**
|
|
300
369
|
* Generic React hook that syncs a patient to a medication-order vendor and
|
|
301
370
|
* returns the chart iframe URL.
|
|
@@ -379,6 +448,8 @@ export declare interface UseMedicationOrderSetOptions {
|
|
|
379
448
|
/** Vendor-side order set id, when picked directly (escape hatch when no synced PD exists yet). */
|
|
380
449
|
readonly vendorOrderSetId?: number | string;
|
|
381
450
|
readonly appId?: string;
|
|
451
|
+
/** Selected practice location for multi-practice deployments. */
|
|
452
|
+
readonly organization?: Reference<Organization>;
|
|
382
453
|
}
|
|
383
454
|
|
|
384
455
|
export declare interface UseMedicationOrderSetReturn {
|
|
@@ -542,6 +613,30 @@ export declare interface UseResourceBoardResult<T extends Resource = Resource> {
|
|
|
542
613
|
readonly refresh: () => Promise<void>;
|
|
543
614
|
}
|
|
544
615
|
|
|
616
|
+
/**
|
|
617
|
+
* React hook for observing FHIR resource modifications made through the Medplum client.
|
|
618
|
+
*
|
|
619
|
+
* The callback is invoked whenever this client instance creates, updates, patches, or deletes
|
|
620
|
+
* a resource of one of the given types, including modifications announced with
|
|
621
|
+
* `MedplumClient.notifyResourceModified`. Use it to keep local component state in sync with
|
|
622
|
+
* mutations made elsewhere in the application. Subscribing to a single resource type narrows
|
|
623
|
+
* the event so `event.resource` is typed to that resource, no type guard required:
|
|
624
|
+
*
|
|
625
|
+
* ```tsx
|
|
626
|
+
* useResourceModified('Slot', (event) => {
|
|
627
|
+
* // event.resource is `WithId<Slot> | undefined`
|
|
628
|
+
* });
|
|
629
|
+
* useResourceModified(['Slot', 'Appointment'], () => refreshSchedule());
|
|
630
|
+
* ```
|
|
631
|
+
*
|
|
632
|
+
* Modifications made by other clients (or other users) are not observed;
|
|
633
|
+
* use `useSubscription` for server-side change notifications.
|
|
634
|
+
*
|
|
635
|
+
* @param resourceType - The resource type or types to observe.
|
|
636
|
+
* @param callback - Invoked with the event payload for each matching modification.
|
|
637
|
+
*/
|
|
638
|
+
export declare function useResourceModified<K extends ResourceType>(resourceType: K | K[], callback: (event: ResourceModifiedEvent<ExtractResource<K>>) => void): void;
|
|
639
|
+
|
|
545
640
|
/**
|
|
546
641
|
* React hook for searching FHIR resources.
|
|
547
642
|
*
|
|
@@ -615,13 +710,18 @@ export declare type UseSubscriptionOptions = {
|
|
|
615
710
|
* to the configured e-prescribing vendor via the `$sync-orderset` custom FHIR operation
|
|
616
711
|
* (`POST /fhir/R4/PlanDefinition/$sync-orderset`).
|
|
617
712
|
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
713
|
+
* Resolves with the decoded `OrderSetSyncResponse` so callers can surface
|
|
714
|
+
* per-action failures (`results[i].status === 'failed'` / `failedCount > 0`) —
|
|
715
|
+
* without this, an order set that only partially synced would silently apply
|
|
716
|
+
* with fewer meds than the PlanDefinition requested.
|
|
621
717
|
*
|
|
622
|
-
*
|
|
718
|
+
* Resolves with `undefined` when the operation is not deployed (i.e. no
|
|
719
|
+
* e-prescribing vendor is configured for the project), so callers do not need to
|
|
720
|
+
* guard against missing integrations.
|
|
721
|
+
*
|
|
722
|
+
* @returns A stable `syncOrderSet(planDefinitionId, organization?)` callback.
|
|
623
723
|
*/
|
|
624
|
-
export declare function useSyncOrderSet(): (planDefinitionId: string) => Promise<
|
|
724
|
+
export declare function useSyncOrderSet(): (planDefinitionId: string, organization?: Reference<Organization>) => Promise<OrderSetSyncResponse | undefined>;
|
|
625
725
|
|
|
626
726
|
export declare function useThreadInbox({ query, threadId }: UseThreadInboxOptions): UseThreadInboxReturn;
|
|
627
727
|
|
|
@@ -641,6 +741,30 @@ export declare interface UseThreadInboxReturn {
|
|
|
641
741
|
refreshThreadMessages: () => Promise<void>;
|
|
642
742
|
}
|
|
643
743
|
|
|
744
|
+
/**
|
|
745
|
+
* Probes a set of ValueSet URLs for availability, each with a filter-free, count-limited expansion.
|
|
746
|
+
*
|
|
747
|
+
* A filter-free probe means a 400/404 unambiguously describes the value set itself (unlike a
|
|
748
|
+
* user-typed search, whose 400 can be filter-specific), so the verdict is safe to act on. Repeated
|
|
749
|
+
* probes of the same URL are deduplicated by the `MedplumClient` request cache, which caches
|
|
750
|
+
* rejections too, so many fields bound to the same missing value set cost one request. Recovery
|
|
751
|
+
* after a value set is imported happens on the next mount (i.e. a page refresh) — there is no live
|
|
752
|
+
* subscription. Transient failures (429/5xx/network) resolve as available so a blip never disables
|
|
753
|
+
* a field; only a permanent 400/404 marks a URL unavailable.
|
|
754
|
+
* @param urls - The ValueSet URLs to probe. Falsy entries are ignored, and duplicates collapse to a
|
|
755
|
+
* single probe.
|
|
756
|
+
* @returns The availability verdict, with `loading` true until every requested URL has settled.
|
|
757
|
+
*/
|
|
758
|
+
export declare function useValueSetAvailabilities(urls: readonly (string | undefined)[]): ValueSetAvailability;
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Probes a single ValueSet's availability once on mount. A thin wrapper around
|
|
762
|
+
* {@link useValueSetAvailabilities} for the common single-value-set case.
|
|
763
|
+
* @param url - The ValueSet URL, or undefined for unbound inputs (always available).
|
|
764
|
+
* @returns undefined while the probe is in flight, true if available, false if unavailable.
|
|
765
|
+
*/
|
|
766
|
+
export declare function useValueSetAvailability(url: string | undefined): boolean | undefined;
|
|
767
|
+
|
|
644
768
|
export declare function useWhisper({ language, model, onTranscript, idleTimeoutMs, }: UseWhisperOptions): UseWhisperResult;
|
|
645
769
|
|
|
646
770
|
export declare type UseWhisperOptions = {
|
|
@@ -666,6 +790,18 @@ export declare type UseWhisperResult = {
|
|
|
666
790
|
setMuted: (value: boolean) => void;
|
|
667
791
|
};
|
|
668
792
|
|
|
793
|
+
/**
|
|
794
|
+
* The result of probing one or more ValueSet URLs for availability.
|
|
795
|
+
*/
|
|
796
|
+
export declare interface ValueSetAvailability {
|
|
797
|
+
/** True while at least one requested URL is still being probed. */
|
|
798
|
+
readonly loading: boolean;
|
|
799
|
+
/** The subset of requested URLs known to be available. */
|
|
800
|
+
readonly available: string[];
|
|
801
|
+
/** The subset of requested URLs known to be unavailable (a permanent 400/404). */
|
|
802
|
+
readonly unavailable: string[];
|
|
803
|
+
}
|
|
804
|
+
|
|
669
805
|
export declare type WhisperStatus = 'idle' | 'requesting_microphone' | 'connecting' | 'connected' | 'listening' | 'speech_started' | 'speech_stopped' | 'disconnected' | 'error';
|
|
670
806
|
|
|
671
807
|
export { }
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,11 +8,18 @@ import type { ExtractResource } from '@medplum/fhirtypes';
|
|
|
8
8
|
import type { Identifier } from '@medplum/fhirtypes';
|
|
9
9
|
import type { JSX } from 'react';
|
|
10
10
|
import type { Medication } from '@medplum/fhirtypes';
|
|
11
|
+
import type { MedicationCartClearRequest } from '@medplum/core';
|
|
12
|
+
import type { MedicationCartManageResponse } from '@medplum/core';
|
|
13
|
+
import type { MedicationCartRemoveRequest } from '@medplum/core';
|
|
14
|
+
import type { MedicationCheckoutRequest } from '@medplum/core';
|
|
15
|
+
import type { MedicationCheckoutResponse } from '@medplum/core';
|
|
11
16
|
import type { MedicationOrderRequest } from '@medplum/core';
|
|
12
17
|
import type { MedicationOrderResponse } from '@medplum/core';
|
|
18
|
+
import type { MedicationRequest } from '@medplum/fhirtypes';
|
|
13
19
|
import type { MedicationSearchParams } from '@medplum/core';
|
|
14
20
|
import type { MedplumClient } from '@medplum/core';
|
|
15
21
|
import type { OperationOutcome } from '@medplum/fhirtypes';
|
|
22
|
+
import type { OrderSetSyncResponse } from '@medplum/core';
|
|
16
23
|
import type { Organization } from '@medplum/fhirtypes';
|
|
17
24
|
import type { Patient } from '@medplum/fhirtypes';
|
|
18
25
|
import type { PharmacySearchParams } from '@medplum/core';
|
|
@@ -30,6 +37,7 @@ import type { ReactNode } from 'react';
|
|
|
30
37
|
import type { Reference } from '@medplum/fhirtypes';
|
|
31
38
|
import type { Resource } from '@medplum/fhirtypes';
|
|
32
39
|
import type { ResourceArray } from '@medplum/core';
|
|
40
|
+
import type { ResourceModifiedEvent } from '@medplum/core';
|
|
33
41
|
import type { ResourceType } from '@medplum/fhirtypes';
|
|
34
42
|
import type { SearchRequest } from '@medplum/core';
|
|
35
43
|
import type { Signature } from '@medplum/fhirtypes';
|
|
@@ -106,8 +114,22 @@ export declare function isChoiceQuestion(item: QuestionnaireItem): boolean;
|
|
|
106
114
|
*/
|
|
107
115
|
export declare function isQuestionEnabled(item: QuestionnaireItem, questionnaireResponse: QuestionnaireResponse | undefined): boolean;
|
|
108
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Returns true if an error thrown while expanding a ValueSet means the value set itself is
|
|
119
|
+
* unavailable — a permanent 400/404 (e.g. "ValueSet not found"). Transient failures (429 rate
|
|
120
|
+
* limit, 401, 5xx, network) return false so a blip never disables a field.
|
|
121
|
+
* @param err - The error thrown by `valueSetExpand`.
|
|
122
|
+
* @returns True for a permanent 400/404, false for a transient failure.
|
|
123
|
+
*/
|
|
124
|
+
export declare function isValueSetUnavailableError(err: unknown): boolean;
|
|
125
|
+
|
|
126
|
+
/** Thrown by {@link UseMedicationCartReturn.checkout} when an {@link UseMedicationCartReturn.addToCart} call is still in flight. */
|
|
127
|
+
export declare const MEDICATION_CART_ADD_IN_PROGRESS = "Cannot checkout while a medication is still being added to the cart";
|
|
128
|
+
|
|
109
129
|
export declare interface MedicationIFrameOptions {
|
|
110
130
|
readonly patientId?: string;
|
|
131
|
+
/** Selected practice location for multi-practice deployments. */
|
|
132
|
+
readonly organization?: Reference<Organization>;
|
|
111
133
|
readonly onPatientSyncSuccess?: () => void;
|
|
112
134
|
readonly onIframeSuccess?: (url: string) => void;
|
|
113
135
|
readonly onError?: (err: unknown) => void;
|
|
@@ -296,6 +318,53 @@ export declare function typedValueToResponseItem(item: QuestionnaireItem, value:
|
|
|
296
318
|
|
|
297
319
|
export declare const useCachedBinaryUrl: (binaryUrl: string | undefined) => string | undefined;
|
|
298
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Vendor-neutral hook for the full **medication cart** lifecycle: add a draft
|
|
323
|
+
* line (`createResource`), check out a set of drafts into the vendor's batch
|
|
324
|
+
* approval queue (`$checkout-medications`), and remove/clear cart lines
|
|
325
|
+
* (`$remove-cart-medication` / `$clear-cart`).
|
|
326
|
+
*
|
|
327
|
+
* Cart checkout / remove / clear hit project-scoped **FHIR custom operations**
|
|
328
|
+
* whose backing Bot is chosen at deploy time via an `OperationDefinition`
|
|
329
|
+
* carrying the `operationDefinition-implementation` extension — see
|
|
330
|
+
* [bot operations docs](https://www.medplum.com/docs/bots/custom-fhir-operations).
|
|
331
|
+
* The server's `tryCustomOperation` dispatch handles the OD → Bot lookup, so
|
|
332
|
+
* projects swap vendors by deploying a different bot under the same code.
|
|
333
|
+
*
|
|
334
|
+
* `addToCart` is plain FHIR `createResource` (no `$add-cart` operation): the
|
|
335
|
+
* Medplum-side cart is the set of draft `MedicationRequest`s. Vendor staging
|
|
336
|
+
* (e.g. ScriptSure MedCart) happens at checkout. Vendors without a batch
|
|
337
|
+
* approval queue (e.g. DoseSpot iframe-first) simply never call `checkout` /
|
|
338
|
+
* `removeFromCart` / `clearCart`.
|
|
339
|
+
*
|
|
340
|
+
* Requests for the custom operations are encoded as `Parameters` bodies and
|
|
341
|
+
* decoded by the matching `@medplum/core` helpers. Per-line outcomes arrive in
|
|
342
|
+
* `response.items`.
|
|
343
|
+
*
|
|
344
|
+
* @returns Cart add / checkout / remove / clear callbacks plus `adding` state.
|
|
345
|
+
*/
|
|
346
|
+
export declare function useMedicationCart(): UseMedicationCartReturn;
|
|
347
|
+
|
|
348
|
+
export declare interface UseMedicationCartReturn {
|
|
349
|
+
/**
|
|
350
|
+
* Persist a draft `MedicationRequest` as a cart line via plain FHIR
|
|
351
|
+
* `createResource` (no custom operation). Vendor staging happens later at
|
|
352
|
+
* {@link UseMedicationCartReturn.checkout}.
|
|
353
|
+
*/
|
|
354
|
+
addToCart: (medicationRequest: MedicationRequest) => Promise<MedicationRequest>;
|
|
355
|
+
/** True while one or more {@link UseMedicationCartReturn.addToCart} calls are in flight. */
|
|
356
|
+
adding: boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Submit draft cart lines to the vendor's batch approval queue and return an
|
|
359
|
+
* embeddable approval-widget URL. Refuses while {@link UseMedicationCartReturn.adding} is true.
|
|
360
|
+
*/
|
|
361
|
+
checkout: (input: MedicationCheckoutRequest) => Promise<MedicationCheckoutResponse>;
|
|
362
|
+
/** Remove a single draft `MedicationRequest` from the patient's vendor cart. */
|
|
363
|
+
removeFromCart: (input: MedicationCartRemoveRequest) => Promise<MedicationCartManageResponse>;
|
|
364
|
+
/** Remove every item from the patient's vendor cart. */
|
|
365
|
+
clearCart: (input: MedicationCartClearRequest) => Promise<MedicationCartManageResponse>;
|
|
366
|
+
}
|
|
367
|
+
|
|
299
368
|
/**
|
|
300
369
|
* Generic React hook that syncs a patient to a medication-order vendor and
|
|
301
370
|
* returns the chart iframe URL.
|
|
@@ -379,6 +448,8 @@ export declare interface UseMedicationOrderSetOptions {
|
|
|
379
448
|
/** Vendor-side order set id, when picked directly (escape hatch when no synced PD exists yet). */
|
|
380
449
|
readonly vendorOrderSetId?: number | string;
|
|
381
450
|
readonly appId?: string;
|
|
451
|
+
/** Selected practice location for multi-practice deployments. */
|
|
452
|
+
readonly organization?: Reference<Organization>;
|
|
382
453
|
}
|
|
383
454
|
|
|
384
455
|
export declare interface UseMedicationOrderSetReturn {
|
|
@@ -542,6 +613,30 @@ export declare interface UseResourceBoardResult<T extends Resource = Resource> {
|
|
|
542
613
|
readonly refresh: () => Promise<void>;
|
|
543
614
|
}
|
|
544
615
|
|
|
616
|
+
/**
|
|
617
|
+
* React hook for observing FHIR resource modifications made through the Medplum client.
|
|
618
|
+
*
|
|
619
|
+
* The callback is invoked whenever this client instance creates, updates, patches, or deletes
|
|
620
|
+
* a resource of one of the given types, including modifications announced with
|
|
621
|
+
* `MedplumClient.notifyResourceModified`. Use it to keep local component state in sync with
|
|
622
|
+
* mutations made elsewhere in the application. Subscribing to a single resource type narrows
|
|
623
|
+
* the event so `event.resource` is typed to that resource, no type guard required:
|
|
624
|
+
*
|
|
625
|
+
* ```tsx
|
|
626
|
+
* useResourceModified('Slot', (event) => {
|
|
627
|
+
* // event.resource is `WithId<Slot> | undefined`
|
|
628
|
+
* });
|
|
629
|
+
* useResourceModified(['Slot', 'Appointment'], () => refreshSchedule());
|
|
630
|
+
* ```
|
|
631
|
+
*
|
|
632
|
+
* Modifications made by other clients (or other users) are not observed;
|
|
633
|
+
* use `useSubscription` for server-side change notifications.
|
|
634
|
+
*
|
|
635
|
+
* @param resourceType - The resource type or types to observe.
|
|
636
|
+
* @param callback - Invoked with the event payload for each matching modification.
|
|
637
|
+
*/
|
|
638
|
+
export declare function useResourceModified<K extends ResourceType>(resourceType: K | K[], callback: (event: ResourceModifiedEvent<ExtractResource<K>>) => void): void;
|
|
639
|
+
|
|
545
640
|
/**
|
|
546
641
|
* React hook for searching FHIR resources.
|
|
547
642
|
*
|
|
@@ -615,13 +710,18 @@ export declare type UseSubscriptionOptions = {
|
|
|
615
710
|
* to the configured e-prescribing vendor via the `$sync-orderset` custom FHIR operation
|
|
616
711
|
* (`POST /fhir/R4/PlanDefinition/$sync-orderset`).
|
|
617
712
|
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
713
|
+
* Resolves with the decoded `OrderSetSyncResponse` so callers can surface
|
|
714
|
+
* per-action failures (`results[i].status === 'failed'` / `failedCount > 0`) —
|
|
715
|
+
* without this, an order set that only partially synced would silently apply
|
|
716
|
+
* with fewer meds than the PlanDefinition requested.
|
|
621
717
|
*
|
|
622
|
-
*
|
|
718
|
+
* Resolves with `undefined` when the operation is not deployed (i.e. no
|
|
719
|
+
* e-prescribing vendor is configured for the project), so callers do not need to
|
|
720
|
+
* guard against missing integrations.
|
|
721
|
+
*
|
|
722
|
+
* @returns A stable `syncOrderSet(planDefinitionId, organization?)` callback.
|
|
623
723
|
*/
|
|
624
|
-
export declare function useSyncOrderSet(): (planDefinitionId: string) => Promise<
|
|
724
|
+
export declare function useSyncOrderSet(): (planDefinitionId: string, organization?: Reference<Organization>) => Promise<OrderSetSyncResponse | undefined>;
|
|
625
725
|
|
|
626
726
|
export declare function useThreadInbox({ query, threadId }: UseThreadInboxOptions): UseThreadInboxReturn;
|
|
627
727
|
|
|
@@ -641,6 +741,30 @@ export declare interface UseThreadInboxReturn {
|
|
|
641
741
|
refreshThreadMessages: () => Promise<void>;
|
|
642
742
|
}
|
|
643
743
|
|
|
744
|
+
/**
|
|
745
|
+
* Probes a set of ValueSet URLs for availability, each with a filter-free, count-limited expansion.
|
|
746
|
+
*
|
|
747
|
+
* A filter-free probe means a 400/404 unambiguously describes the value set itself (unlike a
|
|
748
|
+
* user-typed search, whose 400 can be filter-specific), so the verdict is safe to act on. Repeated
|
|
749
|
+
* probes of the same URL are deduplicated by the `MedplumClient` request cache, which caches
|
|
750
|
+
* rejections too, so many fields bound to the same missing value set cost one request. Recovery
|
|
751
|
+
* after a value set is imported happens on the next mount (i.e. a page refresh) — there is no live
|
|
752
|
+
* subscription. Transient failures (429/5xx/network) resolve as available so a blip never disables
|
|
753
|
+
* a field; only a permanent 400/404 marks a URL unavailable.
|
|
754
|
+
* @param urls - The ValueSet URLs to probe. Falsy entries are ignored, and duplicates collapse to a
|
|
755
|
+
* single probe.
|
|
756
|
+
* @returns The availability verdict, with `loading` true until every requested URL has settled.
|
|
757
|
+
*/
|
|
758
|
+
export declare function useValueSetAvailabilities(urls: readonly (string | undefined)[]): ValueSetAvailability;
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Probes a single ValueSet's availability once on mount. A thin wrapper around
|
|
762
|
+
* {@link useValueSetAvailabilities} for the common single-value-set case.
|
|
763
|
+
* @param url - The ValueSet URL, or undefined for unbound inputs (always available).
|
|
764
|
+
* @returns undefined while the probe is in flight, true if available, false if unavailable.
|
|
765
|
+
*/
|
|
766
|
+
export declare function useValueSetAvailability(url: string | undefined): boolean | undefined;
|
|
767
|
+
|
|
644
768
|
export declare function useWhisper({ language, model, onTranscript, idleTimeoutMs, }: UseWhisperOptions): UseWhisperResult;
|
|
645
769
|
|
|
646
770
|
export declare type UseWhisperOptions = {
|
|
@@ -666,6 +790,18 @@ export declare type UseWhisperResult = {
|
|
|
666
790
|
setMuted: (value: boolean) => void;
|
|
667
791
|
};
|
|
668
792
|
|
|
793
|
+
/**
|
|
794
|
+
* The result of probing one or more ValueSet URLs for availability.
|
|
795
|
+
*/
|
|
796
|
+
export declare interface ValueSetAvailability {
|
|
797
|
+
/** True while at least one requested URL is still being probed. */
|
|
798
|
+
readonly loading: boolean;
|
|
799
|
+
/** The subset of requested URLs known to be available. */
|
|
800
|
+
readonly available: string[];
|
|
801
|
+
/** The subset of requested URLs known to be unavailable (a permanent 400/404). */
|
|
802
|
+
readonly unavailable: string[];
|
|
803
|
+
}
|
|
804
|
+
|
|
669
805
|
export declare type WhisperStatus = 'idle' | 'requesting_microphone' | 'connecting' | 'connected' | 'listening' | 'speech_started' | 'speech_stopped' | 'disconnected' | 'error';
|
|
670
806
|
|
|
671
807
|
export { }
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{useEffect as en,useMemo as nn,useState as tn}from"react";import{createContext as Ye,useContext as Ze}from"react";var j=Ye(void 0);function z(){return Ze(j)}function P(){return z().medplum}function _t(){return z().navigate}function ge(){return z().profile}import{jsx as on}from"react/jsx-runtime";var Ie=["change","storageInitialized","storageInitFailed","profileRefreshing","profileRefreshed"];function Nt(e){let t=e.medplum,n=e.navigate??rn,[o,r]=tn({profile:t.getProfile(),loading:t.isLoading()});en(()=>{function s(){r(a=>({...a,profile:t.getProfile(),loading:t.isLoading()}))}for(let a of Ie)t.addEventListener(a,s);return()=>{for(let a of Ie)t.removeEventListener(a,s)}},[t]);let i=nn(()=>({...o,medplum:t,navigate:n}),[o,t,n]);return on(j.Provider,{value:i,children:e.children})}function rn(e){window.location.assign(e)}import{useMemo as sn}from"react";var Se=new Map,Dt=e=>sn(()=>{if(!e)return;let t=e.split("?")[0];if(!t)return e;let n;try{n=new URLSearchParams(new URL(e).search)}catch{return e}if(!n.has("Key-Pair-Id")||!n.has("Signature"))return e;let o=n.get("Expires");if(!o||o.length>13)return e;let r=Se.get(t);if(r){let s=new URLSearchParams(new URL(r).search).get("Expires");if(s&&Number.parseInt(s,10)*1e3-5e3>Date.now())return r}return Se.set(t,e),e},[e]);import{useEffect as xe,useRef as J,useState as an}from"react";function Kt(e,t,n){let o=P(),{patientId:r,onPatientSyncSuccess:i,onIframeSuccess:s,onError:a}=n,[l,I]=an(void 0),E=J(i),T=J(s),g=J(a);return xe(()=>{E.current=i,T.current=s,g.current=a},[i,s,a]),xe(()=>{let h=!1;return(async()=>{try{if(r){if(await o.executeBot(e,{patientId:r}),h)return;E.current?.()}let u=await o.executeBot(t,{patientId:r});if(h)return;u.url&&(I(u.url),T.current?.(u.url))}catch(u){h||g.current?.(u)}})().catch(()=>{}),()=>{h=!0}},[o,e,t,r]),l}import{INVALID_MEDICATION_ORDER_RESPONSE as un,INVALID_MEDICATION_SEARCH_RESPONSE as cn,isResource as G,medicationOrderRequestToParameters as dn,medicationSearchParamsToParameters as fn,parametersToMedicationOrderResponse as pn}from"@medplum/core";import{useCallback as be}from"react";function Ht(){let e=P(),t=be(async o=>{let r=e.fhirUrl("Medication","$drug-search"),i=fn(o),s=await e.post(r,i);if(!G(s,"Bundle"))throw new Error(cn);return(s.entry??[]).map(a=>a.resource).filter(a=>G(a,"Medication"))},[e]),n=be(async o=>{let r=e.fhirUrl("MedicationRequest","$order-medication"),i=dn(o),s=await e.post(r,i);if(!G(s,"Parameters"))throw new Error(un);return pn(s)},[e]);return{searchMedications:t,orderMedication:n}}import{INVALID_MEDICATION_ORDER_SET_RESPONSE as ln,isResource as mn,medicationOrderSetRequestToParameters as hn,parametersToMedicationOrderSetResponse as yn}from"@medplum/core";import{useCallback as Ee,useEffect as Rn,useRef as Te,useState as H}from"react";function nr(e){let t=P(),{patientId:n,planDefinitionId:o,vendorOrderSetId:r,appId:i}=e,[s,a]=H(void 0),[l,I]=H(!1),[E,T]=H(void 0),g=Te({patientId:n,planDefinitionId:o,vendorOrderSetId:r,appId:i});g.current={patientId:n,planDefinitionId:o,vendorOrderSetId:r,appId:i};let h=()=>{let c=g.current;if(!c.patientId)return;let m=!!c.planDefinitionId,f=c.vendorOrderSetId!==void 0&&c.vendorOrderSetId!==null&&c.vendorOrderSetId!=="";return!m&&!f?void 0:{patientId:c.patientId,planDefinitionId:m?c.planDefinitionId:void 0,vendorOrderSetId:f?c.vendorOrderSetId:void 0,appId:c.appId}},y=Ee(async c=>{let m=t.fhirUrl("PlanDefinition","$order-set-url"),f=hn(c),S=await t.post(m,f);if(!mn(S,"Parameters"))throw new Error(ln);return yn(S).launchUrl},[t]),u=Te(0),d=Ee(async()=>{let c=h();if(!c)return;u.current+=1;let m=u.current;I(!0),T(void 0);try{let f=await y(c);return u.current!==m?void 0:(a(f),f)}catch(f){u.current===m&&(T(f),a(void 0));return}finally{u.current===m&&I(!1)}},[y]);return Rn(()=>{let c=!1,m=h();if(!m){u.current+=1,a(void 0),I(!1),T(void 0);return}u.current+=1;let f=u.current;return I(!0),T(void 0),y(m).then(S=>{c||u.current!==f||a(S)}).catch(S=>{c||u.current!==f||(T(S),a(void 0))}).finally(()=>{!c&&u.current===f&&I(!1)}),()=>{c=!0}},[y,n,o,r,i]),{url:s,loading:l,error:E,refresh:d}}import{useCallback as In,useEffect as Sn,useState as xn}from"react";import{deepEquals as ve}from"@medplum/core";import{useCallback as L,useEffect as X,useRef as _,useState as Pe}from"react";var gn=3e3;function Qe(e,t,n){let o=P(),i=ge()?e:void 0,[s,a]=Pe(),[l,I]=Pe(n?.subscriptionProps),E=_(!1),T=_(void 0),g=_(void 0),h=_(void 0),y=_(t);y.current=t;let u=_(n?.onWebSocketOpen);u.current=n?.onWebSocketOpen;let d=_(n?.onWebSocketClose);d.current=n?.onWebSocketClose;let c=_(n?.onSubscriptionConnect);c.current=n?.onSubscriptionConnect;let m=_(n?.onSubscriptionDisconnect);m.current=n?.onSubscriptionDisconnect;let f=_(n?.onError);f.current=n?.onError,X(()=>{ve(n?.subscriptionProps,l)||I(n?.subscriptionProps)},[l,n]),X(()=>{T.current&&(clearTimeout(T.current),T.current=void 0);let v=!1;return(g.current!==i||!ve(h.current,l))&&(v=!0),v&&g.current&&o.unsubscribeFromCriteria(g.current,h.current),g.current=i,h.current=l,v&&i?a(o.subscribeToCriteria(i,l)):i||a(void 0),()=>{T.current=setTimeout(()=>{a(void 0),i&&o.unsubscribeFromCriteria(i,l)},gn)}},[o,i,l]);let S=L(v=>{y.current?.(v.payload)},[]),b=L(()=>{u.current?.()},[]),x=L(()=>{d.current?.()},[]),p=L(v=>{c.current?.(v.payload.subscriptionId)},[]),M=L(v=>{m.current?.(v.payload.subscriptionId)},[]),Q=L(v=>{f.current?.(v.payload)},[]);X(()=>s?(E.current||(s.addEventListener("message",S),s.addEventListener("open",b),s.addEventListener("close",x),s.addEventListener("connect",p),s.addEventListener("disconnect",M),s.addEventListener("error",Q),E.current=!0),()=>{E.current=!1,s.removeEventListener("message",S),s.removeEventListener("open",b),s.removeEventListener("close",x),s.removeEventListener("connect",p),s.removeEventListener("disconnect",M),s.removeEventListener("error",Q)}):()=>{},[s,S,b,x,p,M,Q])}function dr(e){let t=P(),{resourceType:n,countCriteria:o,subscriptionCriteria:r}=e,[i,s]=xn(0),a=In(l=>{t.search(n,o,{cache:l}).then(I=>s(I.total)).catch(console.error)},[t,n,o]);return Sn(()=>{a("default")},[a]),Qe(r,()=>{a("reload")}),i}import{resolveId as bn}from"@medplum/core";import{useEffect as En,useMemo as Ce,useState as Y}from"react";function Oe(e){let t=e.patientParam??"subject",n=e.query,o="";if(n!=null)if(typeof n=="string")o=n;else if(n instanceof URLSearchParams){let r=Array.from(n.entries()).sort((i,s)=>i[0].localeCompare(s[0])||i[1].localeCompare(s[1]));o=JSON.stringify(r)}else if(Array.isArray(n)){let r=[...n].sort((i,s)=>i[0].localeCompare(s[0])||i[1].localeCompare(s[1]));o=JSON.stringify(r)}else{let r=Object.entries(n).filter(([,i])=>i!==void 0).sort(([i],[s])=>i.localeCompare(s));o=JSON.stringify(r)}return`${e.resourceType}:${t}:${o}`}function Tn(e){return e.map(t=>{let n=t.searches?t.searches.map(Oe).join(","):"";return`${t.key}:[${n}]`}).join("|")}function hr(e,t){let n=P(),[o,r]=Y([]),[i,s]=Y(!0),[a,l]=Y(),I=Tn(t),E=Ce(()=>t,[I]),T=Ce(()=>bn(e),[e]);return En(()=>{if(!T)return;let g=!1,h=`Patient/${T}`,y={_count:100,_sort:"-_lastUpdated"},u=[],d=new Map,c=[];for(let f of E){let S=[];if(f.searches)for(let b of f.searches){let x=Oe(b),p=d.get(x);p===void 0&&(p=u.length,d.set(x,p),u.push(b)),S.push({searchIdx:p,resultKey:b.key})}c.push(S)}if(u.length===0){r(E.map(()=>({}))),s(!1);return}let m=u.map(f=>{let S=f.patientParam??"subject",b={[S]:h};if(f.query){if(typeof f.query=="string")return n.searchResources(f.resourceType,`${S}=${h}&${f.query}&_count=100&_sort=-_lastUpdated`);if(f.query instanceof URLSearchParams)f.query.forEach((x,p)=>{b[p]=x});else if(Array.isArray(f.query))for(let[x,p]of f.query)b[x]=p;else for(let[x,p]of Object.entries(f.query))p!==void 0&&(b[x]=p)}return n.searchResources(f.resourceType,{...y,...b})});return s(!0),l(void 0),Promise.allSettled(m).then(f=>{if(g)return;let S=c.map(x=>{let p={};for(let{searchIdx:M,resultKey:Q}of x){let v=f[M];p[Q]=v.status==="fulfilled"?v.value:[]}return p});r(S),s(!1);let b=f.filter(x=>x.status==="rejected");if(b.length>0){console.error("Some patient summary searches failed:",b.map(p=>p.reason));let x=b[0].reason;l(x instanceof Error?x:new Error(String(x)))}}).catch(f=>{g||(l(f instanceof Error?f:new Error(String(f))),s(!1))}),()=>{g=!0}},[n,T,E]),{sectionData:o,loading:i,error:a}}import{isAddPharmacyResponse as vn,isOrganizationArray as Pn}from"@medplum/core";import{useCallback as Me}from"react";function Sr(e,t){let n=P(),o=Me(async i=>{let s=await n.executeBot(e,i);if(!Pn(s))throw new Error("Invalid response from pharmacy search");return s},[n,e]),r=Me(async i=>{let s=await n.executeBot(t,{patientId:i.patientId,pharmacy:i.pharmacy,setAsPrimary:i.setAsPrimary});if(!vn(s))throw new Error("Invalid response from add pharmacy bot");return s},[n,t]);return{searchPharmacies:o,addToFavorites:r}}import{useEffect as Qn,useRef as Cn}from"react";function Er(e){let t=Cn(void 0);return Qn(()=>{t.current=e}),t.current}import{getExtension as ot}from"@medplum/core";import{useReducer as it,useRef as st}from"react";import{deepEquals as On,isReference as Ae,isResource as Mn,normalizeOperationOutcome as wn}from"@medplum/core";import{useCallback as An,useEffect as _n,useState as kn}from"react";function Z(e,t){let n=P(),[o,r]=kn(()=>we(n,e)),i=An(s=>{On(s,o)||r(s)},[o]);return _n(()=>{let s=!0,a=we(n,e);return!a&&Ae(e)?n.readReference(e).then(l=>{s&&i(l)}).catch(l=>{s&&(i(void 0),t&&t(wn(l)))}):i(a),(()=>s=!1)},[n,e,i,t]),o}function we(e,t){if(t){if(Mn(t))return t;if(Ae(t))return e.getCachedReference(t)}}import{EMPTY as qe,HTTP_HL7_ORG as U,PropertyType as w,append as _e,capitalize as ke,deepClone as Un,evalFhirPathTyped as ne,getExtension as W,getReferenceString as qn,getTypedPropertyValueWithoutSchema as $,normalizeErrorString as Nn,splitN as Ln,toJsBoolean as Wn,toTypedValue as Ne,typedValueToString as Fn}from"@medplum/core";var C={group:"group",display:"display",question:"question",boolean:"boolean",decimal:"decimal",integer:"integer",date:"date",dateTime:"dateTime",time:"time",string:"string",text:"text",url:"url",choice:"choice",openChoice:"open-choice",attachment:"attachment",reference:"reference",quantity:"quantity"},Le=`${U}/fhir/StructureDefinition/questionnaire-itemControl`,Dn=`${U}/fhir/StructureDefinition/questionnaire-referenceFilter`,ee=`${U}/fhir/StructureDefinition/questionnaire-referenceResource`,Vn=`${U}/fhir/StructureDefinition/questionnaire-validationError`,$n=`${U}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression`,Bn=`${U}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression`,Mr=`${U}/fhir/StructureDefinition/questionnaire-signatureRequired`,B=`${U}/fhir/StructureDefinition/questionnaireresponse-signature`,Kn=`${U}/fhir/StructureDefinition/questionnaire-hidden`;function wr(e){return e.type==="choice"||e.type==="open-choice"}function te(e,t){return{...t,item:We(e.item,t.item,t)}}function We(e,t,n){if(!t)return t;let o=[];for(let r of t){let i=e?.find(s=>s.linkId===r.linkId);i&&!jn(i,n)||(i?.item&&r.item?o.push({...r,item:We(i.item,r.item,n)}):o.push(r))}return o}function jn(e,t){if(W(e,Kn)?.valueBoolean===!0)return!1;let o=zn(e,t);return o!==void 0?o:Jn(e,t)}function zn(e,t){let n=W(e,$n);if(t&&n){let o=n.valueExpression?.expression;if(o){let r=Ne(t),i=ne(o,[r],{"%resource":r});return Wn(i)}}}function Jn(e,t){if(!e.enableWhen)return!0;let n=e.enableBehavior??"any";for(let o of e.enableWhen){let r=Fe(t?.item,o.question);if(o.operator==="exists"&&!o.answerBoolean&&!r?.length){if(n==="any")return!0;continue}let{anyMatch:i,allMatch:s}=et(o,r,n);if(n==="any"&&i)return!0;if(n==="all"&&!s)return!1}return n!=="any"}function re(e,t,n=t.item){for(let o of e){let r=n?.find(i=>i.linkId===o.linkId);r&&(Gn(t,o,r),o.item&&r.item&&re(o.item,t,r.item))}}function Gn(e,t,n){try{let o=Yn(t,e);if(!o)return;let r=Xn(t,o);if(!r)return;n.answer=[r]}catch(o){n.extension=[{url:Vn,valueString:`Expression evaluation failed: ${Nn(o)}`}]}}var Hn={[C.boolean]:[w.boolean],[C.date]:[w.date],[C.dateTime]:[w.dateTime],[C.time]:[w.time],[C.url]:[w.string,w.uri,w.url],[C.attachment]:[w.Attachment],[C.reference]:[w.Reference],[C.quantity]:[w.Quantity],[C.decimal]:[w.decimal,w.integer],[C.integer]:[w.decimal,w.integer]};function Xn(e,t){if(!e.type)return;if(e.type===C.choice||e.type===C.openChoice)return{[`value${ke(t.type)}`]:t.value};if(e.type===C.string||e.type===C.text)return typeof t.value=="string"?{valueString:t.value}:void 0;if(Hn[e.type]?.includes(t.type))return{[`value${ke(e.type)}`]:t.value}}function Yn(e,t){if(!t)return;let n=W(e,Bn);if(n){let o=n.valueExpression?.expression;if(o){let r=Ne(t),i=ne(o,[r],{"%resource":r});return i.length!==0?i[0]:void 0}}}function Ar(e,t,n){let o=[];for(let r of e){let i=n.answerOption?.find(s=>Fn(Ue(s))===r);if(i){let s=Ue(i);s&&o.push({[t]:s.value})}}return o}function Fe(e,t){for(let n of e??qe){if(n.linkId===t)return n.answer;if(n.item){let o=Fe(n.item,t);if(o)return o}}}function Zn(e,t,n){if(n==="exists")return!!e===t.value;if(e){let o=n==="="||n==="!="?n?.replace("=","~"):n,[{value:r}]=ne(`%actualAnswer ${o} %expectedAnswer`,[e],{"%actualAnswer":e,"%expectedAnswer":t});return r}else return!1}function et(e,t,n){let o=t||[],r=tt(e),i=!1,s=!0;for(let a of o){let l=rt(a),{operator:I}=e;if(Zn(l,r,I)?i=!0:s=!1,n==="any"&&i)break}return{anyMatch:i,allMatch:s}}function _r(e){let t=W(e,ee);if(t){if(t.valueCode!==void 0)return[t.valueCode];if(t.valueCodeableConcept)return t.valueCodeableConcept?.coding?.map(n=>n.code)}}function kr(e,t){let n=Un(e),o=W(n,ee);return!t||t.length===0?(o&&(n.extension=n.extension?.filter(r=>r!==o)),n):(o||(n.extension??=[],o={url:ee},n.extension.push(o)),t.length===1?(o.valueCode=t[0],delete o.valueCodeableConcept):(o.valueCodeableConcept={coding:t.map(r=>({code:r}))},delete o.valueCode),n)}function Ur(e,t,n){let o=W(e,Dn);if(!o?.valueString)return;let r=o.valueString;t?.reference&&(r=r.replaceAll("$subj",t.reference)),n?.reference&&(r=r.replaceAll("$encounter",n.reference));let i={},s=r.split("&");for(let a of s){let[l,I]=Ln(a,"=",2);i[l]=I}return i}function oe(e,t){return{resourceType:"QuestionnaireResponse",questionnaire:e.url??qn(e),item:ie(e.item,t?.item),status:"in-progress"}}function ie(e,t){let n;for(let o of e??qe){if(o.type===C.display)continue;let r=t?.filter(i=>i.linkId===o.linkId);if(r?.length)for(let i of r)i.id=i.id??De(),i.text=i.text??o.text,i.item=ie(o.item,i.item),i.answer=Ve(o,i),n=_e(n,i);else n=_e(n,se(o))}return n}function se(e){return{id:De(),linkId:e.linkId,text:e.text,item:ie(e.item,void 0),answer:Ve(e)}}var nt=1;function De(){return"id-"+nt++}function Ve(e,t){if(!(e.type===C.display||e.type===C.group)){if(t?.answer&&t.answer.length>0)return t.answer;if(e.initial&&e.initial.length>0)return e.initial.map(n=>({...n}));if(e.answerOption)return e.answerOption.filter(n=>n.initialSelected).map(n=>({...n,initialSelected:void 0}))}}function qr(e){return $({type:"QuestionnaireItemInitial",value:e},"value")}function Ue(e){return $({type:"QuestionnaireItemAnswerOption",value:e},"value")}function tt(e){return $({type:"QuestionnaireItemEnableWhen",value:e},"answer")}function rt(e){return $({type:"QuestionnaireResponseItemAnswer",value:e},"value")}function Vr(e){let t=Z(e.questionnaire),n=Z(e.defaultValue),[,o]=it(y=>y+1,0),r=st({activePage:0});if(!r.current.questionnaire&&t&&(r.current.questionnaire=t,r.current.pages=e.disablePagination?void 0:at(t)),t&&e.defaultValue&&n&&!r.current.questionnaireResponse&&(r.current.questionnaireResponse=oe(t,n),h()),t&&!e.defaultValue&&!r.current.questionnaireResponse&&(r.current.questionnaireResponse=oe(t),h()),!r.current.questionnaire||!r.current.questionnaireResponse)return{loading:!0};function i(y,u){let d=r.current.questionnaireResponse;for(let c of y)d=d?.item?.find(m=>c.id?m.id===c.id:m.linkId===c.linkId);return u&&(d=d?.item?.find(c=>c.linkId===u.linkId)),d}function s(){r.current.activePage=(r.current.activePage??0)+1,o()}function a(){r.current.activePage=(r.current.activePage??0)-1,o()}function l(y,u){let d=i(y);d&&(d.item??=[],d.item.push(se(u)),h())}function I(y,u){let d=i(y,u);d&&(d.answer??=[],d.answer.push({}),h())}function E(y,u,d){let c=i(y,u);c&&(c.answer=d,h())}function T(y){let u=r.current.questionnaireResponse;u&&(y?(u.extension=u.extension??[],u.extension=u.extension.filter(d=>d.url!==B),u.extension.push({url:B,valueSignature:y})):u.extension=u.extension?.filter(d=>d.url!==B),h())}function g(){let y=r.current.questionnaire;if(y?.item){let u=r.current.questionnaireResponse;re(y.item,u)}}function h(){let y=r.current.questionnaireResponse,u=r.current.questionnaire;!y||!u||(g(),o(),e.onChange?.(te(u,y)))}return{loading:!1,pagination:!!r.current.pages,questionnaire:r.current.questionnaire,questionnaireResponse:te(r.current.questionnaire,r.current.questionnaireResponse),subject:e.subject,encounter:e.encounter,activePage:r.current.activePage,pages:r.current.pages,items:ut(r.current.questionnaire,r.current.pages,r.current.activePage),responseItems:ct(r.current.questionnaireResponse,r.current.pages,r.current.activePage),onNextPage:s,onPrevPage:a,onAddGroup:l,onAddAnswer:I,onChangeAnswer:E,onChangeSignature:T}}function at(e){if(!(!e?.item||ot(e?.item?.[0],Le)?.valueCodeableConcept?.coding?.[0]?.code!=="page"))return e.item.map((n,o)=>({linkId:n.linkId,title:n.text??`Page ${o+1}`,group:n}))}function ut(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}function ct(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}import{deepEquals as dt,formatSearchQuery as ft}from"@medplum/core";import{useCallback as pt,useEffect as ae,useRef as ue,useState as F}from"react";async function lt(e,t){let n=await t.search(e.resourceType,ft({...e,total:e.total??"accurate"}),{cache:"no-cache"});return{items:n.entry?.map(r=>r.resource).filter(r=>r!==void 0)??[],total:n.total}}function zr(e){let{search:t,selectedId:n,loadItems:o,reloadKey:r}=e,i=P(),[s,a]=F(t),[l,I]=F([]),[E,T]=F(),[g,h]=F(!0),[y,u]=F(),d=ue(e),c=ue(0),m=ue(0),f=s.resourceType,S=n!==void 0&&y?.id===n?y.value:void 0;dt(t,s)||(a(t),h(!0));let b=pt(async()=>{let x=++c.current;try{let p=o?await o(s,i):await lt(s,i);if(x!==c.current)return;I(p.items),T(p.total),d.current.onLoad?.(p.items,p.total),d.current.selectedId===void 0&&p.items.length>0&&d.current.onSelectFirst?.(p.items[0])}catch(p){x===c.current&&(d.current.onError??console.error)(p)}finally{x===c.current&&h(!1)}},[s,o,i]);return ae(()=>{d.current=e}),ae(()=>{b().catch(console.error)},[b,r]),ae(()=>{let x=++m.current;if(!n)return;let p=async()=>{let Q=d.current.resolveSelected;if(Q)return Q(n,l,i);let v=l.find(N=>N.id===n);return v!==void 0?v:await i.readResource(f,n)};(async()=>{try{let Q=await p();x===m.current&&u({id:n,value:Q})}catch(Q){x===m.current&&(u({id:n,value:void 0}),(d.current.onError??console.error)(Q))}})().catch(console.error)},[n,l,i,f]),{items:l,total:E,loading:g,selected:S,search:s,refresh:b}}import{allOk as yt,normalizeOperationOutcome as Rt}from"@medplum/core";import{useEffect as gt,useMemo as It,useState as de}from"react";import{useCallback as mt,useEffect as $e,useRef as ce,useState as ht}from"react";function Be(e,t,n={leading:!1}){let[o,r]=ht(e),i=ce(!1),s=ce(void 0),a=ce(!1),l=mt(()=>window.clearTimeout(s.current),[]);return $e(()=>{i.current&&(!a.current&&n.leading?(a.current=!0,r(e),s.current=setTimeout(()=>{a.current=!1},t)):(l(),s.current=setTimeout(()=>{a.current=!1,r(e)},t)))},[e,n.leading,t,l]),$e(()=>(i.current=!0,l),[l]),[o,l]}var St=250;function no(e,t,n){return fe("search",e,t,n)}function to(e,t,n){return fe("searchOne",e,t,n)}function ro(e,t,n){return fe("searchResources",e,t,n)}function fe(e,t,n,o){let r=P(),[i,s]=de(!1),[a,l]=de(),[I,E]=de(),T=r.fhirSearchUrl(t,n).toString(),g=It(()=>({resourceType:t,query:n}),[T]),h=o?.enabled??!0,y=o?.debounceMs??St,[u]=Be(g,y,{leading:!0});return gt(()=>{if(!h)return()=>{};s(!0);let d=!0;return r[e](u.resourceType,u.query).then(c=>{d&&(s(!1),l(c),E(yt))}).catch(c=>{d&&(s(!1),l(void 0),E(Rt(c)))}),()=>{d=!1}},[r,e,u,h]),[a,i,I]}import{OperationOutcomeError as xt}from"@medplum/core";import{useCallback as bt}from"react";function uo(){let e=P();return bt(async t=>{try{await e.post(e.fhirUrl("PlanDefinition","$sync-orderset"),{planDefinitionId:t})}catch(n){if(n instanceof xt&&n.outcome.issue?.some(o=>o.code==="not-found"))return;throw n}},[e])}import{getReferenceString as Et}from"@medplum/core";import{useCallback as Tt,useEffect as Ke,useState as D}from"react";function mo({query:e,threadId:t}){let n=P(),[o,r]=D(!0),[i,s]=D([]),[a,l]=D(void 0),[I,E]=D(null),[T,g]=D(void 0),h=Tt(async()=>{let d=new URLSearchParams(e);d.append("identifier:not","http://medplum.com/ai-message|"),d.append("part-of:missing","true"),d.append("_has:Communication:part-of:_id:not","null");let c=await n.search("Communication",d.toString(),{cache:"no-cache"}),m=c.entry?.map(p=>p.resource).filter(p=>p!==void 0)||[];if(c.total!==void 0&&g(c.total),m.length===0){s([]);return}let S=`
|
|
1
|
+
import{useEffect as cn,useMemo as dn,useState as ln}from"react";import{createContext as an,useContext as un}from"react";var j=an(void 0);function J(){return un(j)}function v(){return J().medplum}function sr(){return J().navigate}function Se(){return J().profile}import{jsx as pn}from"react/jsx-runtime";var xe=["change","storageInitialized","storageInitFailed","profileRefreshing","profileRefreshed"];function dr(e){let t=e.medplum,n=e.navigate??fn,[r,o]=ln({profile:t.getProfile(),loading:t.isLoading()});cn(()=>{function i(){o(a=>({...a,profile:t.getProfile(),loading:t.isLoading()}))}for(let a of xe)t.addEventListener(a,i);return()=>{for(let a of xe)t.removeEventListener(a,i)}},[t]);let s=dn(()=>({...r,medplum:t,navigate:n}),[r,t,n]);return pn(j.Provider,{value:s,children:e.children})}function fn(e){window.location.assign(e)}import{useMemo as mn}from"react";var be=new Map,mr=e=>mn(()=>{if(!e)return;let t=e.split("?")[0];if(!t)return e;let n;try{n=new URLSearchParams(new URL(e).search)}catch{return e}if(!n.has("Key-Pair-Id")||!n.has("Signature"))return e;let r=n.get("Expires");if(!r||r.length>13)return e;let o=be.get(t);if(o){let i=new URLSearchParams(new URL(o).search).get("Expires");if(i&&Number.parseInt(i,10)*1e3-5e3>Date.now())return o}return be.set(t,e),e},[e]);import{INVALID_MEDICATION_CART_RESPONSE as Ee,INVALID_MEDICATION_CHECKOUT_RESPONSE as Rn,isResource as G,medicationCartClearRequestToParameters as hn,medicationCartRemoveRequestToParameters as yn,medicationCheckoutRequestToParameters as gn,parametersToMedicationCartManageResponse as ve,parametersToMedicationCheckoutResponse as In}from"@medplum/core";import{useCallback as K,useRef as Sn,useState as xn}from"react";var bn="Cannot checkout while a medication is still being added to the cart";function Ir(){let e=v(),[t,n]=xn(!1),r=Sn(0),o=K(async u=>{r.current+=1,n(!0);try{return await e.createResource(u)}finally{r.current-=1,r.current<=0&&(r.current=0,n(!1))}},[e]),s=K(async u=>{if(r.current>0)throw new Error(bn);let R=e.fhirUrl("MedicationRequest","$checkout-medications"),h=gn(u),T=await e.post(R,h);if(!G(T,"Parameters"))throw new Error(Rn);return In(T)},[e]),i=K(async u=>{let R=e.fhirUrl("MedicationRequest","$remove-cart-medication"),h=await e.post(R,yn(u));if(!G(h,"Parameters"))throw new Error(Ee);return ve(h)},[e]),a=K(async u=>{let R=e.fhirUrl("MedicationRequest","$clear-cart"),h=await e.post(R,hn(u));if(!G(h,"Parameters"))throw new Error(Ee);return ve(h)},[e]);return{addToCart:o,adding:t,checkout:s,removeFromCart:i,clearCart:a}}import{resolveId as En}from"@medplum/core";import{useEffect as Pe,useRef as H,useState as vn}from"react";function vr(e,t,n){let r=v(),{patientId:o,organization:s,onPatientSyncSuccess:i,onIframeSuccess:a,onError:u}=n,R=En(s),[h,T]=vn(void 0),I=H(i),g=H(a),y=H(u);return Pe(()=>{I.current=i,g.current=a,y.current=u},[i,a,u]),Pe(()=>{let l=!1;return(async()=>{try{if(o){if(await r.executeBot(e,{patientId:o,organizationId:R}),l)return;I.current?.()}let m=await r.executeBot(t,{patientId:o,organizationId:R});if(l)return;m.url&&(T(m.url),g.current?.(m.url))}catch(m){l||y.current?.(m)}})().catch(()=>{}),()=>{l=!0}},[r,e,t,o,R]),h}import{INVALID_MEDICATION_ORDER_RESPONSE as Pn,INVALID_MEDICATION_SEARCH_RESPONSE as Tn,isResource as X,medicationOrderRequestToParameters as Cn,medicationSearchParamsToParameters as Mn,parametersToMedicationOrderResponse as Qn}from"@medplum/core";import{useCallback as Te}from"react";function Qr(){let e=v(),t=Te(async r=>{let o=e.fhirUrl("Medication","$drug-search"),s=Mn(r),i=await e.post(o,s);if(!X(i,"Bundle"))throw new Error(Tn);return(i.entry??[]).map(a=>a.resource).filter(a=>X(a,"Medication"))},[e]),n=Te(async r=>{let o=e.fhirUrl("MedicationRequest","$order-medication"),s=Cn(r),i=await e.post(o,s);if(!X(i,"Parameters"))throw new Error(Pn);return Qn(i)},[e]);return{searchMedications:t,orderMedication:n}}import{INVALID_MEDICATION_ORDER_SET_RESPONSE as On,isResource as wn,medicationOrderSetRequestToParameters as An,parametersToMedicationOrderSetResponse as kn}from"@medplum/core";import{useCallback as Ce,useEffect as _n,useRef as Me,useState as Y}from"react";function _r(e){let t=v(),{patientId:n,planDefinitionId:r,vendorOrderSetId:o,appId:s,organization:i}=e,[a,u]=Y(void 0),[R,h]=Y(!1),[T,I]=Y(void 0),g=Me({patientId:n,planDefinitionId:r,vendorOrderSetId:o,appId:s,organization:i});g.current={patientId:n,planDefinitionId:r,vendorOrderSetId:o,appId:s,organization:i};let y=()=>{let d=g.current;if(!d.patientId)return;let p=!!d.planDefinitionId,S=d.vendorOrderSetId!==void 0&&d.vendorOrderSetId!==null&&d.vendorOrderSetId!=="";return!p&&!S?void 0:{patientId:d.patientId,planDefinitionId:p?d.planDefinitionId:void 0,vendorOrderSetId:S?d.vendorOrderSetId:void 0,appId:d.appId,organization:d.organization}},l=Ce(async d=>{let p=t.fhirUrl("PlanDefinition","$order-set-url"),S=An(d),x=await t.post(p,S);if(!wn(x,"Parameters"))throw new Error(On);return kn(x).launchUrl},[t]),c=Me(0),m=Ce(async()=>{let d=y();if(!d)return;c.current+=1;let p=c.current;h(!0),I(void 0);try{let S=await l(d);return c.current!==p?void 0:(u(S),S)}catch(S){c.current===p&&(I(S),u(void 0));return}finally{c.current===p&&h(!1)}},[l]);return _n(()=>{let d=!1,p=y();if(!p){c.current+=1,u(void 0),h(!1),I(void 0);return}c.current+=1;let S=c.current;return h(!0),I(void 0),l(p).then(x=>{d||c.current!==S||u(x)}).catch(x=>{d||c.current!==S||(I(x),u(void 0))}).finally(()=>{!d&&c.current===S&&h(!1)}),()=>{d=!0}},[l,n,r,o,s,i]),{url:a,loading:R,error:T,refresh:m}}import{useCallback as Un,useEffect as Nn,useState as Ln}from"react";import{deepEquals as Qe}from"@medplum/core";import{useCallback as L,useEffect as Z,useRef as k,useState as Oe}from"react";var qn=3e3;function we(e,t,n){let r=v(),s=Se()?e:void 0,[i,a]=Oe(),[u,R]=Oe(n?.subscriptionProps),h=k(!1),T=k(void 0),I=k(void 0),g=k(void 0),y=k(t);y.current=t;let l=k(n?.onWebSocketOpen);l.current=n?.onWebSocketOpen;let c=k(n?.onWebSocketClose);c.current=n?.onWebSocketClose;let m=k(n?.onSubscriptionConnect);m.current=n?.onSubscriptionConnect;let d=k(n?.onSubscriptionDisconnect);d.current=n?.onSubscriptionDisconnect;let p=k(n?.onError);p.current=n?.onError,Z(()=>{Qe(n?.subscriptionProps,u)||R(n?.subscriptionProps)},[u,n]),Z(()=>{T.current&&(clearTimeout(T.current),T.current=void 0);let P=!1;return(I.current!==s||!Qe(g.current,u))&&(P=!0),P&&I.current&&r.unsubscribeFromCriteria(I.current,g.current),I.current=s,g.current=u,P&&s?a(r.subscribeToCriteria(s,u)):s||a(void 0),()=>{T.current=setTimeout(()=>{a(void 0),s&&r.unsubscribeFromCriteria(s,u)},qn)}},[r,s,u]);let S=L(P=>{y.current?.(P.payload)},[]),x=L(()=>{l.current?.()},[]),E=L(()=>{c.current?.()},[]),f=L(P=>{m.current?.(P.payload.subscriptionId)},[]),O=L(P=>{d.current?.(P.payload.subscriptionId)},[]),C=L(P=>{p.current?.(P.payload)},[]);Z(()=>i?(h.current||(i.addEventListener("message",S),i.addEventListener("open",x),i.addEventListener("close",E),i.addEventListener("connect",f),i.addEventListener("disconnect",O),i.addEventListener("error",C),h.current=!0),()=>{h.current=!1,i.removeEventListener("message",S),i.removeEventListener("open",x),i.removeEventListener("close",E),i.removeEventListener("connect",f),i.removeEventListener("disconnect",O),i.removeEventListener("error",C)}):()=>{},[i,S,x,E,f,O,C])}function Kr(e){let t=v(),{resourceType:n,countCriteria:r,subscriptionCriteria:o}=e,[s,i]=Ln(0),a=Un(u=>{t.search(n,r,{cache:u}).then(R=>i(R.total)).catch(console.error)},[t,n,r]);return Nn(()=>{a("default")},[a]),we(o,()=>{a("reload")}),s}import{resolveId as Wn}from"@medplum/core";import{useEffect as Dn,useMemo as Ae,useState as ee}from"react";function ke(e){let t=e.patientParam??"subject",n=e.query,r="";if(n!=null)if(typeof n=="string")r=n;else if(n instanceof URLSearchParams){let o=Array.from(n.entries()).sort((s,i)=>s[0].localeCompare(i[0])||s[1].localeCompare(i[1]));r=JSON.stringify(o)}else if(Array.isArray(n)){let o=[...n].sort((s,i)=>s[0].localeCompare(i[0])||s[1].localeCompare(i[1]));r=JSON.stringify(o)}else{let o=Object.entries(n).filter(([,s])=>s!==void 0).sort(([s],[i])=>s.localeCompare(i));r=JSON.stringify(o)}return`${e.resourceType}:${t}:${r}`}function Fn(e){return e.map(t=>{let n=t.searches?t.searches.map(ke).join(","):"";return`${t.key}:[${n}]`}).join("|")}function Jr(e,t){let n=v(),[r,o]=ee([]),[s,i]=ee(!0),[a,u]=ee(),R=Fn(t),h=Ae(()=>t,[R]),T=Ae(()=>Wn(e),[e]);return Dn(()=>{if(!T)return;let I=!1,g=`Patient/${T}`,y={_count:100,_sort:"-_lastUpdated"},l=[],c=new Map,m=[];for(let p of h){let S=[];if(p.searches)for(let x of p.searches){let E=ke(x),f=c.get(E);f===void 0&&(f=l.length,c.set(E,f),l.push(x)),S.push({searchIdx:f,resultKey:x.key})}m.push(S)}if(l.length===0){o(h.map(()=>({}))),i(!1);return}let d=l.map(p=>{let S=p.patientParam??"subject",x={[S]:g};if(p.query){if(typeof p.query=="string")return n.searchResources(p.resourceType,`${S}=${g}&${p.query}&_count=100&_sort=-_lastUpdated`);if(p.query instanceof URLSearchParams)p.query.forEach((E,f)=>{x[f]=E});else if(Array.isArray(p.query))for(let[E,f]of p.query)x[E]=f;else for(let[E,f]of Object.entries(p.query))f!==void 0&&(x[E]=f)}return n.searchResources(p.resourceType,{...y,...x})});return i(!0),u(void 0),Promise.allSettled(d).then(p=>{if(I)return;let S=m.map(E=>{let f={};for(let{searchIdx:O,resultKey:C}of E){let P=p[O];f[C]=P.status==="fulfilled"?P.value:[]}return f});o(S),i(!1);let x=p.filter(E=>E.status==="rejected");if(x.length>0){console.error("Some patient summary searches failed:",x.map(f=>f.reason));let E=x[0].reason;u(E instanceof Error?E:new Error(String(E)))}}).catch(p=>{I||(u(p instanceof Error?p:new Error(String(p))),i(!1))}),()=>{I=!0}},[n,T,h]),{sectionData:r,loading:s,error:a}}import{isAddPharmacyResponse as Vn,isOrganizationArray as Kn,resolveId as _e}from"@medplum/core";import{useCallback as qe}from"react";function Zr(e,t){let n=v(),r=qe(async s=>{let{organization:i,...a}=s,u=_e(i),R=await n.executeBot(e,u?{...a,organizationId:u}:a);if(!Kn(R))throw new Error("Invalid response from pharmacy search");return R},[n,e]),o=qe(async s=>{let i=await n.executeBot(t,{patientId:s.patientId,pharmacy:s.pharmacy,setAsPrimary:s.setAsPrimary,organizationId:_e(s.organization)});if(!Vn(i))throw new Error("Invalid response from add pharmacy bot");return i},[n,t]);return{searchPharmacies:r,addToFavorites:o}}import{useEffect as $n,useRef as Bn}from"react";function to(e){let t=Bn(void 0);return $n(()=>{t.current=e}),t.current}import{getExtension as xt}from"@medplum/core";import{useReducer as bt,useRef as Et}from"react";import{deepEquals as zn,isReference as Ne,isResource as jn,normalizeOperationOutcome as Jn}from"@medplum/core";import{useCallback as Gn,useEffect as Hn,useState as Xn}from"react";function ne(e,t){let n=v(),[r,o]=Xn(()=>Ue(n,e)),s=Gn(i=>{zn(i,r)||o(i)},[r]);return Hn(()=>{let i=!0,a=Ue(n,e);return!a&&Ne(e)?n.readReference(e).then(u=>{i&&s(u)}).catch(u=>{i&&(s(void 0),t&&t(Jn(u)))}):s(a),(()=>i=!1)},[n,e,s,t]),r}function Ue(e,t){if(t){if(jn(t))return t;if(Ne(t))return e.getCachedReference(t)}}import{EMPTY as Fe,HTTP_HL7_ORG as q,PropertyType as w,append as Le,capitalize as We,deepClone as Yn,evalFhirPathTyped as re,getExtension as W,getReferenceString as Zn,getTypedPropertyValueWithoutSchema as $,normalizeErrorString as et,splitN as nt,toJsBoolean as tt,toTypedValue as Ve,typedValueToString as rt}from"@medplum/core";var M={group:"group",display:"display",question:"question",boolean:"boolean",decimal:"decimal",integer:"integer",date:"date",dateTime:"dateTime",time:"time",string:"string",text:"text",url:"url",choice:"choice",openChoice:"open-choice",attachment:"attachment",reference:"reference",quantity:"quantity"},Ke=`${q}/fhir/StructureDefinition/questionnaire-itemControl`,ot=`${q}/fhir/StructureDefinition/questionnaire-referenceFilter`,te=`${q}/fhir/StructureDefinition/questionnaire-referenceResource`,it=`${q}/fhir/StructureDefinition/questionnaire-validationError`,st=`${q}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression`,at=`${q}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression`,co=`${q}/fhir/StructureDefinition/questionnaire-signatureRequired`,B=`${q}/fhir/StructureDefinition/questionnaireresponse-signature`,ut=`${q}/fhir/StructureDefinition/questionnaire-hidden`;function lo(e){return e.type==="choice"||e.type==="open-choice"}function oe(e,t){return{...t,item:$e(e.item,t.item,t)}}function $e(e,t,n){if(!t)return t;let r=[];for(let o of t){let s=e?.find(i=>i.linkId===o.linkId);s&&!ct(s,n)||(s?.item&&o.item?r.push({...o,item:$e(s.item,o.item,n)}):r.push(o))}return r}function ct(e,t){if(W(e,ut)?.valueBoolean===!0)return!1;let r=dt(e,t);return r!==void 0?r:lt(e,t)}function dt(e,t){let n=W(e,st);if(t&&n){let r=n.valueExpression?.expression;if(r){let o=Ve(t),s=re(r,[o],{"%resource":o});return tt(s)}}}function lt(e,t){if(!e.enableWhen)return!0;let n=e.enableBehavior??"any";for(let r of e.enableWhen){let o=Be(t?.item,r.question);if(r.operator==="exists"&&!r.answerBoolean&&!o?.length){if(n==="any")return!0;continue}let{anyMatch:s,allMatch:i}=yt(r,o,n);if(n==="any"&&s)return!0;if(n==="all"&&!i)return!1}return n!=="any"}function ie(e,t,n=t.item){for(let r of e){let o=n?.find(s=>s.linkId===r.linkId);o&&(ft(t,r,o),r.item&&o.item&&ie(r.item,t,o.item))}}function ft(e,t,n){try{let r=Rt(t,e);if(!r)return;let o=mt(t,r);if(!o)return;n.answer=[o]}catch(r){n.extension=[{url:it,valueString:`Expression evaluation failed: ${et(r)}`}]}}var pt={[M.boolean]:[w.boolean],[M.date]:[w.date],[M.dateTime]:[w.dateTime],[M.time]:[w.time],[M.url]:[w.string,w.uri,w.url],[M.attachment]:[w.Attachment],[M.reference]:[w.Reference],[M.quantity]:[w.Quantity],[M.decimal]:[w.decimal,w.integer],[M.integer]:[w.decimal,w.integer]};function mt(e,t){if(!e.type)return;if(e.type===M.choice||e.type===M.openChoice)return{[`value${We(t.type)}`]:t.value};if(e.type===M.string||e.type===M.text)return typeof t.value=="string"?{valueString:t.value}:void 0;if(pt[e.type]?.includes(t.type))return{[`value${We(e.type)}`]:t.value}}function Rt(e,t){if(!t)return;let n=W(e,at);if(n){let r=n.valueExpression?.expression;if(r){let o=Ve(t),s=re(r,[o],{"%resource":o});return s.length!==0?s[0]:void 0}}}function fo(e,t,n){let r=[];for(let o of e){let s=n.answerOption?.find(i=>rt(De(i))===o);if(s){let i=De(s);i&&r.push({[t]:i.value})}}return r}function Be(e,t){for(let n of e??Fe){if(n.linkId===t)return n.answer;if(n.item){let r=Be(n.item,t);if(r)return r}}}function ht(e,t,n){if(n==="exists")return!!e===t.value;if(e){let r=n==="="||n==="!="?n?.replace("=","~"):n,[{value:o}]=re(`%actualAnswer ${r} %expectedAnswer`,[e],{"%actualAnswer":e,"%expectedAnswer":t});return o}else return!1}function yt(e,t,n){let r=t||[],o=It(e),s=!1,i=!0;for(let a of r){let u=St(a),{operator:R}=e;if(ht(u,o,R)?s=!0:i=!1,n==="any"&&s)break}return{anyMatch:s,allMatch:i}}function po(e){let t=W(e,te);if(t){if(t.valueCode!==void 0)return[t.valueCode];if(t.valueCodeableConcept)return t.valueCodeableConcept?.coding?.map(n=>n.code)}}function mo(e,t){let n=Yn(e),r=W(n,te);return!t||t.length===0?(r&&(n.extension=n.extension?.filter(o=>o!==r)),n):(r||(n.extension??=[],r={url:te},n.extension.push(r)),t.length===1?(r.valueCode=t[0],delete r.valueCodeableConcept):(r.valueCodeableConcept={coding:t.map(o=>({code:o}))},delete r.valueCode),n)}function Ro(e,t,n){let r=W(e,ot);if(!r?.valueString)return;let o=r.valueString;t?.reference&&(o=o.replaceAll("$subj",t.reference)),n?.reference&&(o=o.replaceAll("$encounter",n.reference));let s={},i=o.split("&");for(let a of i){let[u,R]=nt(a,"=",2);s[u]=R}return s}function se(e,t){return{resourceType:"QuestionnaireResponse",questionnaire:e.url??Zn(e),item:ae(e.item,t?.item),status:"in-progress"}}function ae(e,t){let n;for(let r of e??Fe){if(r.type===M.display)continue;let o=t?.filter(s=>s.linkId===r.linkId);if(o?.length)for(let s of o)s.id=s.id??ze(),s.text=s.text??r.text,s.item=ae(r.item,s.item),s.answer=je(r,s),n=Le(n,s);else n=Le(n,ue(r))}return n}function ue(e){return{id:ze(),linkId:e.linkId,text:e.text,item:ae(e.item,void 0),answer:je(e)}}var gt=1;function ze(){return"id-"+gt++}function je(e,t){if(!(e.type===M.display||e.type===M.group)){if(t?.answer&&t.answer.length>0)return t.answer;if(e.initial&&e.initial.length>0)return e.initial.map(n=>({...n}));if(e.answerOption)return e.answerOption.filter(n=>n.initialSelected).map(n=>({...n,initialSelected:void 0}))}}function ho(e){return $({type:"QuestionnaireItemInitial",value:e},"value")}function De(e){return $({type:"QuestionnaireItemAnswerOption",value:e},"value")}function It(e){return $({type:"QuestionnaireItemEnableWhen",value:e},"answer")}function St(e){return $({type:"QuestionnaireResponseItemAnswer",value:e},"value")}function bo(e){let t=ne(e.questionnaire),n=ne(e.defaultValue),[,r]=bt(y=>y+1,0),o=Et({activePage:0});if(!o.current.questionnaire&&t&&(o.current.questionnaire=t,o.current.pages=e.disablePagination?void 0:vt(t)),t&&e.defaultValue&&n&&!o.current.questionnaireResponse&&(o.current.questionnaireResponse=se(t,n),g()),t&&!e.defaultValue&&!o.current.questionnaireResponse&&(o.current.questionnaireResponse=se(t),g()),!o.current.questionnaire||!o.current.questionnaireResponse)return{loading:!0};function s(y,l){let c=o.current.questionnaireResponse;for(let m of y)c=c?.item?.find(d=>m.id?d.id===m.id:d.linkId===m.linkId);return l&&(c=c?.item?.find(m=>m.linkId===l.linkId)),c}function i(){o.current.activePage=(o.current.activePage??0)+1,r()}function a(){o.current.activePage=(o.current.activePage??0)-1,r()}function u(y,l){let c=s(y);c&&(c.item??=[],c.item.push(ue(l)),g())}function R(y,l){let c=s(y,l);c&&(c.answer??=[],c.answer.push({}),g())}function h(y,l,c){let m=s(y,l);m&&(m.answer=c,g())}function T(y){let l=o.current.questionnaireResponse;l&&(y?(l.extension=l.extension??[],l.extension=l.extension.filter(c=>c.url!==B),l.extension.push({url:B,valueSignature:y})):l.extension=l.extension?.filter(c=>c.url!==B),g())}function I(){let y=o.current.questionnaire;if(y?.item){let l=o.current.questionnaireResponse;ie(y.item,l)}}function g(){let y=o.current.questionnaireResponse,l=o.current.questionnaire;!y||!l||(I(),r(),e.onChange?.(oe(l,y)))}return{loading:!1,pagination:!!o.current.pages,questionnaire:o.current.questionnaire,questionnaireResponse:oe(o.current.questionnaire,o.current.questionnaireResponse),subject:e.subject,encounter:e.encounter,activePage:o.current.activePage,pages:o.current.pages,items:Pt(o.current.questionnaire,o.current.pages,o.current.activePage),responseItems:Tt(o.current.questionnaireResponse,o.current.pages,o.current.activePage),onNextPage:i,onPrevPage:a,onAddGroup:u,onAddAnswer:R,onChangeAnswer:h,onChangeSignature:T}}function vt(e){if(!(!e?.item||xt(e?.item?.[0],Ke)?.valueCodeableConcept?.coding?.[0]?.code!=="page"))return e.item.map((n,r)=>({linkId:n.linkId,title:n.text??`Page ${r+1}`,group:n}))}function Pt(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}function Tt(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}import{deepEquals as Ct,formatSearchQuery as Mt}from"@medplum/core";import{useCallback as Qt,useEffect as ce,useRef as de,useState as D}from"react";async function Ot(e,t){let n=await t.search(e.resourceType,Mt({...e,total:e.total??"accurate"}),{cache:"no-cache"});return{items:n.entry?.map(o=>o.resource).filter(o=>o!==void 0)??[],total:n.total}}function Co(e){let{search:t,selectedId:n,loadItems:r,reloadKey:o}=e,s=v(),[i,a]=D(t),[u,R]=D([]),[h,T]=D(),[I,g]=D(!0),[y,l]=D(),c=de(e),m=de(0),d=de(0),p=i.resourceType,S=n!==void 0&&y?.id===n?y.value:void 0;Ct(t,i)||(a(t),g(!0));let x=Qt(async()=>{let E=++m.current;try{let f=r?await r(i,s):await Ot(i,s);if(E!==m.current)return;R(f.items),T(f.total),c.current.onLoad?.(f.items,f.total),c.current.selectedId===void 0&&f.items.length>0&&c.current.onSelectFirst?.(f.items[0])}catch(f){E===m.current&&(c.current.onError??console.error)(f)}finally{E===m.current&&g(!1)}},[i,r,s]);return ce(()=>{c.current=e}),ce(()=>{x().catch(console.error)},[x,o]),ce(()=>{let E=++d.current;if(!n)return;let f=async()=>{let C=c.current.resolveSelected;if(C)return C(n,u,s);let P=u.find(N=>N.id===n);return P!==void 0?P:await s.readResource(p,n)};(async()=>{try{let C=await f();E===d.current&&l({id:n,value:C})}catch(C){E===d.current&&(l({id:n,value:void 0}),(c.current.onError??console.error)(C))}})().catch(console.error)},[n,u,s,p]),{items:u,total:h,loading:I,selected:S,search:i,refresh:x}}import{useEffect as Je,useRef as wt}from"react";function wo(e,t){let n=v(),r=wt(t);Je(()=>{r.current=t});let o=Array.isArray(e)?e.join(","):e;Je(()=>{let s=new Set(o.split(",")),i=a=>{s.has(a.payload.resourceType)&&r.current(a.payload)};return n.addEventListener("resourceModified",i),()=>n.removeEventListener("resourceModified",i)},[n,o])}import{allOk as _t,normalizeOperationOutcome as qt}from"@medplum/core";import{useEffect as Ut,useMemo as Nt,useState as fe}from"react";import{useCallback as At,useEffect as Ge,useRef as le,useState as kt}from"react";function He(e,t,n={leading:!1}){let[r,o]=kt(e),s=le(!1),i=le(void 0),a=le(!1),u=At(()=>window.clearTimeout(i.current),[]);return Ge(()=>{s.current&&(!a.current&&n.leading?(a.current=!0,o(e),i.current=setTimeout(()=>{a.current=!1},t)):(u(),i.current=setTimeout(()=>{a.current=!1,o(e)},t)))},[e,n.leading,t,u]),Ge(()=>(s.current=!0,u),[u]),[r,u]}var Lt=250;function Wo(e,t,n){return pe("search",e,t,n)}function Do(e,t,n){return pe("searchOne",e,t,n)}function Fo(e,t,n){return pe("searchResources",e,t,n)}function pe(e,t,n,r){let o=v(),[s,i]=fe(!1),[a,u]=fe(),[R,h]=fe(),T=o.fhirSearchUrl(t,n).toString(),I=Nt(()=>({resourceType:t,query:n}),[T]),g=r?.enabled??!0,y=r?.debounceMs??Lt,[l]=He(I,y,{leading:!0});return Ut(()=>{if(!g)return()=>{};i(!0);let c=!0;return o[e](l.resourceType,l.query).then(m=>{c&&(i(!1),u(m),h(_t))}).catch(m=>{c&&(i(!1),u(void 0),h(qt(m)))}),()=>{c=!1}},[o,e,l,g]),[a,s,R]}import{OperationOutcomeError as Wt,isResource as Dt,parametersToOrderSetSyncResponse as Ft,resolveId as Vt}from"@medplum/core";import{useCallback as Kt}from"react";function zo(){let e=v();return Kt(async(t,n)=>{try{let r=await e.post(e.fhirUrl("PlanDefinition","$sync-orderset"),{planDefinitionId:t,organizationId:Vt(n)});return Dt(r,"Parameters")?Ft(r):void 0}catch(r){if(r instanceof Wt&&r.outcome.issue?.some(o=>o.code==="not-found"))return;throw r}},[e])}import{getReferenceString as $t}from"@medplum/core";import{useCallback as Bt,useEffect as Xe,useState as F}from"react";function Xo({query:e,threadId:t}){let n=v(),[r,o]=F(!0),[s,i]=F([]),[a,u]=F(void 0),[R,h]=F(null),[T,I]=F(void 0),g=Bt(async()=>{let c=new URLSearchParams(e);c.append("identifier:not","http://medplum.com/ai-message|"),c.append("part-of:missing","true"),c.append("_has:Communication:part-of:_id:not","null");let m=await n.search("Communication",c.toString(),{cache:"no-cache"}),d=m.entry?.map(f=>f.resource).filter(f=>f!==void 0)||[];if(m.total!==void 0&&I(m.total),d.length===0){i([]);return}let S=`
|
|
2
2
|
query {
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
part_of: "${
|
|
3
|
+
${d.map(f=>{let C=`thread_${f.id?.replaceAll("-","")||""}`,P=$t(f);return`
|
|
4
|
+
${C}: CommunicationList(
|
|
5
|
+
part_of: "${P}"
|
|
6
6
|
_sort: "-sent"
|
|
7
7
|
_count: 1
|
|
8
8
|
) {
|
|
@@ -26,7 +26,9 @@ import{useEffect as en,useMemo as nn,useState as tn}from"react";import{createCon
|
|
|
26
26
|
`}).join(`
|
|
27
27
|
`)}
|
|
28
28
|
}
|
|
29
|
-
`,
|
|
29
|
+
`,x=await n.graphql(S),E=d.map(f=>{let C=`thread_${f.id?.replaceAll("-","")||""}`,P=x.data[C],N=P&&P.length>0?P[0]:void 0;return[f,N]}).filter(f=>f[1]!==void 0);i(E)},[n,e]);return Xe(()=>{o(!0),g().catch(c=>{h(c)}).finally(()=>{o(!1)})},[g]),Xe(()=>{(async()=>{if(!t){u(void 0);return}let m=s.find(p=>p[0].id===t);if(m){u(m[0]);return}let d=await n.readResource("Communication",t);if(d.partOf===void 0)u(d);else{let p=d.partOf[0].reference;if(p){let S=await n.readReference({reference:p});u(S)}}})().catch(m=>{h(m)})},[t,s,n]),{loading:r,error:R,threadMessages:s,selectedThread:a,total:T,addThreadMessage:c=>{(async()=>{await g(),i(d=>[[c,void 0],...d])})().catch(d=>h(d))},handleThreadStatusChange:c=>{if(!a)return;(async()=>{let d=await n.updateResource({...a,status:c});u(d),i(p=>p.map(([S,x])=>S.id===d.id?[d,x]:[S,x]))})().catch(d=>h(d))},refreshThreadMessages:g}}import{getStatus as zt,OperationOutcomeError as jt}from"@medplum/core";import{useEffect as Jt,useMemo as Ye,useState as Gt}from"react";function Ht(e){if(e instanceof jt){let t=zt(e.outcome);return t===400||t===404}return!1}var Ze=[];function Xt(e){let t=v(),n=Array.from(new Set(e.filter(i=>!!i))).sort((i,a)=>i.localeCompare(a)).join(`
|
|
30
|
+
`),r=Ye(()=>n===""?Ze:n.split(`
|
|
31
|
+
`),[n]),[o,s]=Gt({});return Jt(()=>{if(r.length===0)return;let i=!1,a=new AbortController;for(let u of r)t.valueSetExpand({url:u,count:1},{signal:a.signal}).then(()=>{i||s(R=>({...R,[u]:!0}))}).catch(R=>{i||s(h=>({...h,[u]:!Ht(R)}))});return()=>{i=!0,a.abort()}},[t,r]),Ye(()=>{let i=[],a=[],u=!1;for(let R of r){let h=o[R];h===void 0?u=!0:h?i.push(R):a.push(R)}return{loading:u,available:i,unavailable:a}},[r,o])}function ti(e){let{loading:t,unavailable:n}=Xt(e?[e]:Ze);if(!e)return!0;if(!t)return!n.includes(e)}import{ReconnectingWebSocket as Yt,sleep as Zt}from"@medplum/core";import{useCallback as A,useEffect as me,useRef as U,useState as z}from"react";var er=12e4;function ai({language:e="en",model:t="gpt-4o-transcribe",onTranscript:n,idleTimeoutMs:r=er}){let o=v(),s=U(n);me(()=>{s.current=n},[n]);let[i,a]=z("idle"),[u,R]=z(void 0),[h,T]=z([]),I=U(void 0),g=U(void 0),y=U(void 0),l=U(void 0),c=U(!1),m=U(!1),d=U(!1),[p,S]=z(!1),x=U(!1),E=A(b=>{x.current=b,S(b),g.current?.getAudioTracks().forEach(Q=>{Q.enabled=!b})},[]),f=A(()=>{d.current=!1,l.current?.disconnect(),l.current=void 0,y.current?.close().catch(()=>{}),y.current=void 0,g.current?.getTracks().forEach(b=>b.stop()),g.current=void 0,x.current=!1,S(!1),a(I.current?"idle":"disconnected")},[]),O=A(()=>{f(),I.current?.close(),I.current=void 0,m.current=!1,a("disconnected")},[f]),C=A(()=>{I.current?.send(JSON.stringify({type:"session.update",session:{type:"transcription",audio:{input:{format:{type:"audio/pcm",rate:24e3},transcription:{model:t,language:e},turn_detection:{type:"server_vad",threshold:.5,prefix_padding_ms:300,silence_duration_ms:200},noise_reduction:{type:"near_field"}}}}}))},[e,t]),P=A(async()=>{if(!(l.current||c.current)&&!(!g.current||!I.current)){c.current=!0;try{let b=new AudioContext({sampleRate:24e3});await b.audioWorklet.addModule(or());let Q=g.current,_=I.current;if(!d.current||!Q||!_){await b.close().catch(()=>{});return}let tn=b.createMediaStreamSource(Q),V=new AudioWorkletNode(b,en);V.port.onmessage=rn=>{if(_.readyState!==WebSocket.OPEN){console.warn("WebSocket is not open. Unable to send audio data.");return}let on=nr(rn.data),sn=btoa(String.fromCharCode(...on));_.send(JSON.stringify({type:"input_audio_buffer.append",audio:sn}))},tn.connect(V),V.connect(b.destination),y.current=b,l.current=V,a("listening")}catch(b){R(b),a("error"),f()}finally{c.current=!1}}},[f]),N=A(()=>{d.current&&m.current&&g.current&&(l.current||(I.current?.send(JSON.stringify({type:"input_audio_buffer.clear"})),P().catch(()=>{})))},[P]),he=A(b=>{switch(b.type){case"session.created":C();break;case"session.updated":m.current=!0,N();break;case"input_audio_buffer.speech_started":a("speech_started");break;case"input_audio_buffer.speech_stopped":a("speech_stopped");break;case"conversation.item.input_audio_transcription.completed":case"input_audio_transcription.completed":if(b.transcript){let Q={text:b.transcript,timestamp:new Date().toISOString()};T(_=>[..._,Q]),s.current?.(b.transcript)}break;case"ai-realtime:connected":console.debug("[useWhisper] upstream connected");break;case"ai-realtime:error":case"error":console.error("[useWhisper] error event",b),R(b),a("error");break;default:console.debug("[useWhisper] unhandled message",b.type,b);break}},[C,N]),ye=A(async()=>{a("requesting_microphone");let b=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:24e3,channelCount:1,echoCancellation:!0,noiseSuppression:!0}});return b.getAudioTracks().forEach(Q=>{Q.enabled=!x.current}),g.current=b,b},[]),ge=A(()=>{a("connecting");let b=tr(o.getBaseUrl());console.debug("[useWhisper] connecting to",b);let Q=new Yt(b);return I.current=Q,Q.onopen=()=>{m.current=!1,d.current?a("connected"):a("idle"),Q.send(JSON.stringify({type:"ai-realtime:connect",accessToken:o.getAccessToken()}))},Q.onmessage=_=>he(JSON.parse(_.data)),Q.onerror=_=>{d.current&&(R(_),O(),a("error"))},Q.onclose=()=>{m.current=!1,I.current&&a(d.current?"connecting":"idle")},Q},[o,he,O]),Ie=A(()=>I.current??ge(),[ge]),nn=A(async()=>{try{R(void 0),d.current=!0,Ie(),await ye(),N()}catch(b){R(b),a("error"),f()}},[ye,Ie,f,N]);return me(()=>{if(i!=="idle"||!I.current||!Number.isFinite(r)||r<=0)return;let b=new AbortController;return Zt(r,{signal:b.signal}).then(()=>O()).catch(()=>{}),()=>b.abort()},[i,r,O]),me(()=>()=>O(),[O]),{status:i,error:u,transcripts:h,start:nn,stop:f,isListening:i==="listening"||i==="speech_started"||i==="speech_stopped",muted:p,setMuted:E}}function nr(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=Math.max(-1,Math.min(1,e[n]));t[n]=r*32767}return new Uint8Array(t.buffer)}function tr(e){let t=new URL("ws/ai-realtime",e);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.toString()}var en="medplum-pcm-worklet",rr=`
|
|
30
32
|
class PcmWorkletProcessor extends AudioWorkletProcessor {
|
|
31
33
|
constructor() {
|
|
32
34
|
super();
|
|
@@ -58,6 +60,6 @@ class PcmWorkletProcessor extends AudioWorkletProcessor {
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
registerProcessor('${
|
|
62
|
-
`,
|
|
63
|
+
registerProcessor('${en}', PcmWorkletProcessor);
|
|
64
|
+
`,Re;function or(){if(!Re){let e=new Blob([rr],{type:"application/javascript"});Re=URL.createObjectURL(e)}return Re}export{bn as MEDICATION_CART_ADD_IN_PROGRESS,dr as MedplumProvider,at as QUESTIONNAIRE_CALCULATED_EXPRESSION_URL,st as QUESTIONNAIRE_ENABLED_WHEN_EXPRESSION_URL,ut as QUESTIONNAIRE_HIDDEN_URL,Ke as QUESTIONNAIRE_ITEM_CONTROL_URL,ot as QUESTIONNAIRE_REFERENCE_FILTER_URL,te as QUESTIONNAIRE_REFERENCE_RESOURCE_URL,co as QUESTIONNAIRE_SIGNATURE_REQUIRED_URL,B as QUESTIONNAIRE_SIGNATURE_RESPONSE_URL,it as QUESTIONNAIRE_VALIDATION_ERROR_URL,M as QuestionnaireItemType,se as buildInitialResponse,ue as buildInitialResponseItem,nr as convertToPCM16,ie as evaluateCalculatedExpressionsInQuestionnaire,De as getItemAnswerOptionValue,It as getItemEnableWhenValueAnswer,ho as getItemInitialValue,fo as getNewMultiSelectValues,Ro as getQuestionnaireItemReferenceFilter,po as getQuestionnaireItemReferenceTargetTypes,St as getResponseItemAnswerValue,lo as isChoiceQuestion,ct as isQuestionEnabled,Ht as isValueSetUnavailableError,j as reactContext,oe as removeDisabledItems,mo as setQuestionnaireItemReferenceTargetTypes,mt as typedValueToResponseItem,mr as useCachedBinaryUrl,Ir as useMedicationCart,vr as useMedicationIFrame,Qr as useMedicationOrder,_r as useMedicationOrderSet,v as useMedplum,J as useMedplumContext,sr as useMedplumNavigate,Se as useMedplumProfile,Kr as useNotificationCount,Jr as usePatientSummaryData,Zr as usePharmacySearch,to as usePrevious,bo as useQuestionnaireForm,ne as useResource,Co as useResourceBoard,wo as useResourceModified,Wo as useSearch,Do as useSearchOne,Fo as useSearchResources,we as useSubscription,zo as useSyncOrderSet,Xo as useThreadInbox,Xt as useValueSetAvailabilities,ti as useValueSetAvailability,ai as useWhisper};
|
|
63
65
|
//# sourceMappingURL=index.mjs.map
|