import type { AddFavoriteParams } from '@medplum/core'; import type { AddPharmacyResponse } from '@medplum/core'; import type { Bundle } from '@medplum/fhirtypes'; import type { Communication } from '@medplum/fhirtypes'; import { Context } from 'react'; import type { Encounter } from '@medplum/fhirtypes'; import type { ExtractResource } from '@medplum/fhirtypes'; import type { Identifier } from '@medplum/fhirtypes'; import type { JSX } from 'react'; import type { Medication } from '@medplum/fhirtypes'; import type { MedicationCartClearRequest } from '@medplum/core'; import type { MedicationCartManageResponse } from '@medplum/core'; import type { MedicationCartRemoveRequest } from '@medplum/core'; import type { MedicationCheckoutRequest } from '@medplum/core'; import type { MedicationCheckoutResponse } from '@medplum/core'; import type { MedicationOrderRequest } from '@medplum/core'; import type { MedicationOrderResponse } from '@medplum/core'; import type { MedicationRequest } from '@medplum/fhirtypes'; import type { MedicationSearchParams } from '@medplum/core'; import type { MedplumClient } from '@medplum/core'; import type { OperationOutcome } from '@medplum/fhirtypes'; import type { OrderSetSyncResponse } from '@medplum/core'; import type { Organization } from '@medplum/fhirtypes'; import type { Patient } from '@medplum/fhirtypes'; import type { PharmacySearchParams } from '@medplum/core'; import type { ProfileResource } from '@medplum/core'; import type { QueryTypes } from '@medplum/core'; import type { Questionnaire } from '@medplum/fhirtypes'; import type { QuestionnaireItem } from '@medplum/fhirtypes'; import type { QuestionnaireItemAnswerOption } from '@medplum/fhirtypes'; import type { QuestionnaireItemEnableWhen } from '@medplum/fhirtypes'; import type { QuestionnaireItemInitial } from '@medplum/fhirtypes'; import type { QuestionnaireResponse } from '@medplum/fhirtypes'; import type { QuestionnaireResponseItem } from '@medplum/fhirtypes'; import type { QuestionnaireResponseItemAnswer } from '@medplum/fhirtypes'; import type { ReactNode } from 'react'; import type { Reference } from '@medplum/fhirtypes'; import type { Resource } from '@medplum/fhirtypes'; import type { ResourceArray } from '@medplum/core'; import type { ResourceModifiedEvent } from '@medplum/core'; import type { ResourceType } from '@medplum/fhirtypes'; import type { SearchRequest } from '@medplum/core'; import type { Signature } from '@medplum/fhirtypes'; import type { Subscription } from '@medplum/fhirtypes'; import type { TypedValue } from '@medplum/core'; import type { WithId } from '@medplum/core'; export declare function buildInitialResponse(questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse): QuestionnaireResponse; export declare function buildInitialResponseItem(item: QuestionnaireItem): QuestionnaireResponseItem; export declare function convertToPCM16(float32Array: Float32Array): Uint8Array; /** * Evaluates the calculated expressions in a questionnaire. * Updates response item answers in place with the calculated values. * * See: https://build.fhir.org/ig/HL7/sdc/StructureDefinition-sdc-questionnaire-calculatedExpression.html * * @param items - The questionnaire items to evaluate. * @param response - The questionnaire response to evaluate against. * @param responseItems - The response items to update. */ export declare function evaluateCalculatedExpressionsInQuestionnaire(items: QuestionnaireItem[], response: QuestionnaireResponse, responseItems?: QuestionnaireResponseItem[] | undefined): void; /** Descriptor for a single FHIR search that a section needs. */ export declare interface FhirSearchDescriptor { /** Unique key used to access this search's results via `SectionResults[key]`. */ readonly key: string; readonly resourceType: ResourceType; /** Which search param references the patient. Defaults to 'subject'. Examples: 'patient', 'beneficiary'. */ readonly patientParam?: string; /** * Additional search params — same format as the 2nd arg to medplum.searchResources(). * When using a string, do not include _count or _sort; they are appended automatically. */ readonly query?: QueryTypes; } export declare function getItemAnswerOptionValue(option: QuestionnaireItemAnswerOption): TypedValue; export declare function getItemEnableWhenValueAnswer(enableWhen: QuestionnaireItemEnableWhen): TypedValue; export declare function getItemInitialValue(initial: QuestionnaireItemInitial | undefined): TypedValue; export declare function getNewMultiSelectValues(selected: string[], propertyName: string, item: QuestionnaireItem): QuestionnaireResponseItemAnswer[]; /** * Returns the reference filter for the given questionnaire item. * @see https://build.fhir.org/ig/HL7/fhir-extensions/StructureDefinition-questionnaire-referenceFilter-definitions.html * @param item - The questionnaire item to get the reference filter for. * @param subject - Optional subject reference. * @param encounter - Optional encounter reference. * @returns The reference filter as a map of key/value pairs. */ export declare function getQuestionnaireItemReferenceFilter(item: QuestionnaireItem, subject: Reference | undefined, encounter: Reference | undefined): Record | undefined; export declare function getQuestionnaireItemReferenceTargetTypes(item: QuestionnaireItem): ResourceType[] | undefined; export declare function getResponseItemAnswerValue(answer: QuestionnaireResponseItemAnswer): TypedValue | undefined; /** * Returns true if the item is a choice question. * @param item - The questionnaire item to check. * @returns True if the item is a choice question, false otherwise. */ export declare function isChoiceQuestion(item: QuestionnaireItem): boolean; /** * Returns true if the questionnaire item is enabled based on the enableWhen conditions or expression. * @param item - The questionnaire item to check. * @param questionnaireResponse - The questionnaire response to check against. * @returns True if the question is enabled, false otherwise. */ export declare function isQuestionEnabled(item: QuestionnaireItem, questionnaireResponse: QuestionnaireResponse | undefined): boolean; /** * Returns true if an error thrown while expanding a ValueSet means the value set itself is * unavailable — a permanent 400/404 (e.g. "ValueSet not found"). Transient failures (429 rate * limit, 401, 5xx, network) return false so a blip never disables a field. * @param err - The error thrown by `valueSetExpand`. * @returns True for a permanent 400/404, false for a transient failure. */ export declare function isValueSetUnavailableError(err: unknown): boolean; /** Thrown by {@link UseMedicationCartReturn.checkout} when an {@link UseMedicationCartReturn.addToCart} call is still in flight. */ export declare const MEDICATION_CART_ADD_IN_PROGRESS = "Cannot checkout while a medication is still being added to the cart"; export declare interface MedicationIFrameOptions { readonly patientId?: string; /** Selected practice location for multi-practice deployments. */ readonly organization?: Reference; readonly onPatientSyncSuccess?: () => void; readonly onIframeSuccess?: (url: string) => void; readonly onError?: (err: unknown) => void; } export declare interface MedplumContext { medplum: MedplumClient; navigate: MedplumNavigateFunction; profile?: ProfileResource; loading: boolean; } export declare type MedplumNavigateFunction = (path: string) => void; /** * The MedplumProvider component provides Medplum context state. * * Medplum context includes: * 1) medplum - Medplum client library * 2) profile - The current user profile (if signed in) * @param props - The MedplumProvider React props. * @returns The MedplumProvider React node. */ export declare function MedplumProvider(props: MedplumProviderProps): JSX.Element; export declare interface MedplumProviderProps { readonly medplum: MedplumClient; readonly navigate?: MedplumNavigateFunction; readonly children: ReactNode; } export declare interface PatientSummaryData { /** One SectionResults map per section, indexed to match the sections array. */ readonly sectionData: SectionResults[]; readonly loading: boolean; readonly error: Error | undefined; } export declare const QUESTIONNAIRE_CALCULATED_EXPRESSION_URL = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression"; export declare const QUESTIONNAIRE_ENABLED_WHEN_EXPRESSION_URL = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression"; export declare const QUESTIONNAIRE_HIDDEN_URL = "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden"; export declare const QUESTIONNAIRE_ITEM_CONTROL_URL = "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl"; export declare const QUESTIONNAIRE_REFERENCE_FILTER_URL = "http://hl7.org/fhir/StructureDefinition/questionnaire-referenceFilter"; export declare const QUESTIONNAIRE_REFERENCE_RESOURCE_URL = "http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource"; export declare const QUESTIONNAIRE_SIGNATURE_REQUIRED_URL = "http://hl7.org/fhir/StructureDefinition/questionnaire-signatureRequired"; export declare const QUESTIONNAIRE_SIGNATURE_RESPONSE_URL = "http://hl7.org/fhir/StructureDefinition/questionnaireresponse-signature"; export declare const QUESTIONNAIRE_VALIDATION_ERROR_URL = "http://hl7.org/fhir/StructureDefinition/questionnaire-validationError"; export declare interface QuestionnaireFormLoadedState { /** Not loading */ readonly loading: false; /** The loaded questionnaire */ questionnaire: Questionnaire; /** The current draft questionnaire response */ questionnaireResponse: QuestionnaireResponse; /** Optional questionnaire subject */ subject?: Reference; /** Optional questionnaire encounter */ encounter?: Reference; /** The top level items for the current page */ items: QuestionnaireItem[]; /** The response items for the current page */ responseItems: QuestionnaireResponseItem[]; /** * Adds a new group item to the current context. * @param context - The current context of the questionnaire response items. * @param item - The questionnaire item that is being added to the group. */ onAddGroup: (context: QuestionnaireResponseItem[], item: QuestionnaireItem) => void; /** * Adds an answer to a repeating item. * @param context - The current context of the questionnaire response items. * @param item - The questionnaire item that is being answered. */ onAddAnswer: (context: QuestionnaireResponseItem[], item: QuestionnaireItem) => void; /** * Changes an answer value. * @param context - The current context of the questionnaire response items. * @param item - The questionnaire item that is being answered. * @param answer - The answer(s) provided by the user for the questionnaire item. */ onChangeAnswer: (context: QuestionnaireResponseItem[], item: QuestionnaireItem, answer: QuestionnaireResponseItemAnswer[]) => void; /** * Sets or updates the signature for the questionnaire response. * @param signature - The signature to set, or undefined to clear the signature. */ onChangeSignature: (signature: Signature | undefined) => void; } export declare interface QuestionnaireFormLoadingState { /** Currently loading data such as the Questionnaire or the QuestionnaireResponse default value */ readonly loading: true; } export declare interface QuestionnaireFormPage { readonly linkId: string; readonly title: string; readonly group: QuestionnaireItem & { type: 'group'; }; } export declare interface QuestionnaireFormPaginationState extends QuestionnaireFormLoadedState { readonly pagination: true; pages: QuestionnaireFormPage[]; activePage: number; onNextPage: () => void; onPrevPage: () => void; } export declare interface QuestionnaireFormSinglePageState extends QuestionnaireFormLoadedState { readonly pagination: false; } export declare type QuestionnaireFormState = QuestionnaireFormLoadingState | QuestionnaireFormSinglePageState | QuestionnaireFormPaginationState; export declare const QuestionnaireItemType: { readonly group: "group"; readonly display: "display"; readonly question: "question"; readonly boolean: "boolean"; readonly decimal: "decimal"; readonly integer: "integer"; readonly date: "date"; readonly dateTime: "dateTime"; readonly time: "time"; readonly string: "string"; readonly text: "text"; readonly url: "url"; readonly choice: "choice"; readonly openChoice: "open-choice"; readonly attachment: "attachment"; readonly reference: "reference"; readonly quantity: "quantity"; }; export declare type QuestionnaireItemType = (typeof QuestionnaireItemType)[keyof typeof QuestionnaireItemType]; export declare const reactContext: Context; /** * Returns a copy of the questionnaire response with response items for disabled * questionnaire items removed. * * Per the FHIR R4 spec, a QuestionnaireResponse should not include answers for items * whose `enableWhen` evaluates to false or whose `questionnaire-hidden` extension is * true. The form preserves answers in local state so that re-enabling an item * restores its previous value, so callers must strip disabled items before * persisting or transmitting the response. * * @param questionnaire - The questionnaire defining the items. * @param response - The current questionnaire response. * @returns A new questionnaire response with disabled items removed. */ export declare function removeDisabledItems(questionnaire: Questionnaire, response: QuestionnaireResponse): QuestionnaireResponse; export declare interface ResourceBoardLoadResult { readonly items: WithId[]; readonly total?: number; } export declare type SearchOptions = { debounceMs?: number; enabled?: boolean; }; /** Named map of FHIR results for a section: `results[searchKey]` returns the Resource[] for that search. */ export declare type SectionResults = Record; export declare function setQuestionnaireItemReferenceTargetTypes(item: QuestionnaireItem, targetTypes: ResourceType[] | undefined): QuestionnaireItem; export declare type TranscriptItem = { text: string; timestamp: string; }; export declare function typedValueToResponseItem(item: QuestionnaireItem, value: TypedValue): QuestionnaireResponseItemAnswer | undefined; export declare const useCachedBinaryUrl: (binaryUrl: string | undefined) => string | undefined; /** * Vendor-neutral hook for the full **medication cart** lifecycle: add a draft * line (`createResource`), check out a set of drafts into the vendor's batch * approval queue (`$checkout-medications`), and remove/clear cart lines * (`$remove-cart-medication` / `$clear-cart`). * * Cart checkout / remove / clear hit project-scoped **FHIR custom operations** * whose backing Bot is chosen at deploy time via an `OperationDefinition` * carrying the `operationDefinition-implementation` extension — see * [bot operations docs](https://www.medplum.com/docs/bots/custom-fhir-operations). * The server's `tryCustomOperation` dispatch handles the OD → Bot lookup, so * projects swap vendors by deploying a different bot under the same code. * * `addToCart` is plain FHIR `createResource` (no `$add-cart` operation): the * Medplum-side cart is the set of draft `MedicationRequest`s. Vendor staging * (e.g. ScriptSure MedCart) happens at checkout. Vendors without a batch * approval queue (e.g. DoseSpot iframe-first) simply never call `checkout` / * `removeFromCart` / `clearCart`. * * Requests for the custom operations are encoded as `Parameters` bodies and * decoded by the matching `@medplum/core` helpers. Per-line outcomes arrive in * `response.items`. * * @returns Cart add / checkout / remove / clear callbacks plus `adding` state. */ export declare function useMedicationCart(): UseMedicationCartReturn; export declare interface UseMedicationCartReturn { /** * Persist a draft `MedicationRequest` as a cart line via plain FHIR * `createResource` (no custom operation). Vendor staging happens later at * {@link UseMedicationCartReturn.checkout}. */ addToCart: (medicationRequest: MedicationRequest) => Promise; /** True while one or more {@link UseMedicationCartReturn.addToCart} calls are in flight. */ adding: boolean; /** * Submit draft cart lines to the vendor's batch approval queue and return an * embeddable approval-widget URL. Refuses while {@link UseMedicationCartReturn.adding} is true. */ checkout: (input: MedicationCheckoutRequest) => Promise; /** Remove a single draft `MedicationRequest` from the patient's vendor cart. */ removeFromCart: (input: MedicationCartRemoveRequest) => Promise; /** Remove every item from the patient's vendor cart. */ clearCart: (input: MedicationCartClearRequest) => Promise; } /** * Generic React hook that syncs a patient to a medication-order vendor and * returns the chart iframe URL. * * Executes the patient-sync bot first (if patientId is provided), then * the iframe bot to obtain the prescribing UI URL. * * Uses an effect cleanup flag so React 18 Strict Mode double-mount does not * trigger duplicate bot executions. * * @param syncBotIdentifier - Bot identifier for the patient sync bot. * @param iframeBotIdentifier - Bot identifier for the iframe URL bot. * @param options - Configuration and callback options. * @returns The medication-order iframe URL, or undefined while loading. */ export declare function useMedicationIFrame(syncBotIdentifier: Identifier, iframeBotIdentifier: Identifier, options: MedicationIFrameOptions): string | undefined; /** * Vendor-neutral hook for e-prescribing drug search and order-medication via * **FHIR custom operations** (no Bot identifiers required). * * Hits two project-scoped operations whose backing Bot is chosen at deploy time * via an `OperationDefinition` resource carrying the * `operationDefinition-implementation` extension — see * [bot operations docs](https://www.medplum.com/docs/bots/custom-fhir-operations). * The server's `tryCustomOperation` dispatch handles the OD → Bot lookup, so * projects can swap vendors (ScriptSure today, DoseSpot tomorrow) by deploying * a different bot under the same operation code. * * - `searchMedications`: `POST /fhir/R4/Medication/$drug-search` — expects the * bot to return a `Bundle` (single-Resource `return` shortcut on * the OperationDefinition). * - `orderMedication`: `POST /fhir/R4/MedicationRequest/$order-medication` — * expects the bot to return a `Parameters` envelope with named primitives; * `parametersToMedicationOrderResponse` decodes it. * * @returns Callbacks to search medications and submit an order request. */ export declare function useMedicationOrder(): UseMedicationOrderReturn; export declare interface UseMedicationOrderReturn { searchMedications: (params: MedicationSearchParams) => Promise; orderMedication: (input: MedicationOrderRequest) => Promise; } /** * Vendor-neutral React hook that calls the `$order-set-url` custom FHIR * operation and exposes the resulting iframe URL plus refresh/loading/error * state. * * Hits the project-scoped operation whose backing bot is chosen at deploy time * via an `OperationDefinition` resource carrying the * `operationDefinition-implementation` extension — see * [bot operations docs](https://www.medplum.com/docs/bots/custom-fhir-operations). * The server's `tryCustomOperation` dispatch handles the OD → Bot lookup, so * projects can swap vendors (ScriptSure today, DoseSpot tomorrow) by deploying * a different bot under the same operation code. * * - URL: `POST /fhir/R4/PlanDefinition/$order-set-url` * - Body: `Parameters` with `patientId` + (`planDefinitionId` XOR `vendorOrderSetId`) + optional `appId`. * - Returns: `Parameters` whose `launchUrl` is exposed as `url` on the hook. * * The hook is a "build a URL" hook (mirrors {@link useMedicationIFrame}); it * does not stamp Medplum resources or create vendor-side resources, so * `refresh` is safe to call repeatedly (the operation is naturally idempotent). * * Re-runs whenever the input options change. In-flight calls are cancelled on * input change and on unmount via a per-effect `cancelled` flag, so React 18 * Strict Mode double-mount does not surface stale URLs. * * @param options - Patient, picker (PD or vendor id), and optional appId. * @returns `{ url, loading, error, refresh }`. */ export declare function useMedicationOrderSet(options: UseMedicationOrderSetOptions): UseMedicationOrderSetReturn; export declare interface UseMedicationOrderSetOptions { /** Patient to prescribe against. Hook stays idle (no operation call) until set. */ readonly patientId: string | undefined; /** Medplum PlanDefinition id (vendor-neutral). Bot resolves it to the vendor's order set id. */ readonly planDefinitionId?: string; /** Vendor-side order set id, when picked directly (escape hatch when no synced PD exists yet). */ readonly vendorOrderSetId?: number | string; readonly appId?: string; /** Selected practice location for multi-practice deployments. */ readonly organization?: Reference; } export declare interface UseMedicationOrderSetReturn { /** Most recent successful URL from the order-set operation, or undefined while loading / on error. */ readonly url: string | undefined; /** True while a request is in flight. */ readonly loading: boolean; /** Last error from the operation call, or undefined. */ readonly error: unknown; /** * Force a re-fetch using the current options. Useful when wiring * `PrescriptionIFrameModal.onRefreshLaunchUrl` so the session token in * the returned widget URL is fresh on every modal open. */ readonly refresh: () => Promise; } /** * Returns the MedplumClient instance. * This is a shortcut for useMedplumContext().medplum. * @returns The MedplumClient instance. */ export declare function useMedplum(): MedplumClient; /** * Returns the MedplumContext instance. * @returns The MedplumContext instance. */ export declare function useMedplumContext(): MedplumContext; /** * Returns the Medplum navigate function. * @returns The Medplum navigate function. */ export declare function useMedplumNavigate(): MedplumNavigateFunction; /** * Returns the current Medplum user profile (if signed in). * This is a shortcut for useMedplumContext().profile. * @returns The current user profile. */ export declare function useMedplumProfile(): ProfileResource | undefined; /** * Returns a live notification count for a given resource type. * * Uses `medplum.search()` for the initial count (with default cache policy) and * subscribes to real-time updates via `useSubscription()`, re-fetching with * `cache: 'reload'` whenever a matching event arrives. * * @param options - The resource type, count search criteria, and subscription criteria. * @returns The current notification count. */ export declare function useNotificationCount(options: UseNotificationCountOptions): number; export declare interface UseNotificationCountOptions { readonly resourceType: ResourceType; readonly countCriteria: string; readonly subscriptionCriteria: string; } /** * Hook that collects all FHIR searches from section configs, deduplicates them, * executes them in parallel, and routes results back to each section. * Uses Promise.allSettled so a single failing search does not block all sections — * sections whose searches fail gracefully receive empty arrays. * @param patient - The patient or patient reference to fetch data for. * @param sections - The section configs defining which searches to execute. * @returns Section data, loading state, and any error. */ export declare function usePatientSummaryData(patient: Patient | Reference, sections: { readonly key: string; readonly searches?: FhirSearchDescriptor[]; }[]): PatientSummaryData; /** * Generic React hook that provides pharmacy search and add-to-favorites * functionality for any e-prescribing integration. * * Encapsulates calls to a search-pharmacy bot and an add-patient-pharmacy bot, * and can be composed with the generic `PharmacyDialog` component from `@medplum/react`. * * The search param type is generic so vendor hooks can widen it with their own * filters (e.g. ScriptSure `specialties`); the extra keys are passed through to * the bot as-is at runtime. * * @param searchBotIdentifier - Bot identifier for the pharmacy search bot. * @param addPharmacyBotIdentifier - Bot identifier for the add-patient-pharmacy bot. * @returns An object with `searchPharmacies` and `addToFavorites` callbacks. */ export declare function usePharmacySearch(searchBotIdentifier: Identifier, addPharmacyBotIdentifier: Identifier): UsePharmacySearchReturn; export declare interface UsePharmacySearchReturn { searchPharmacies: (params: T) => Promise; addToFavorites: (params: AddFavoriteParams) => Promise; } /** * React Hook to keep track of the passed-in value from the previous render of the containing component. * @param value - The value to track. * @returns The value passed in from the previous render. */ export declare function usePrevious(value: T): T | undefined; export declare function useQuestionnaireForm(props: UseQuestionnaireFormProps): Readonly; export declare interface UseQuestionnaireFormProps { readonly questionnaire: Questionnaire | Reference; readonly defaultValue?: QuestionnaireResponse | Reference; readonly subject?: Reference; readonly encounter?: Reference; readonly source?: QuestionnaireResponse['source']; readonly disablePagination?: boolean; readonly onChange?: (response: QuestionnaireResponse) => void; } /** * React Hook to use a FHIR reference. * Handles the complexity of resolving references and caching resources. * @param value - The resource or reference to resource. * @param setOutcome - Optional callback to set the OperationOutcome. * @returns The resolved resource. */ export declare function useResource(value: Reference | Partial | undefined, setOutcome?: (outcome: OperationOutcome) => void): WithId | undefined; /** * useResourceBoard manages the data layer for the ResourceBoard component: * fetching the resource list, resolving the selected resource, and supporting * background refresh. * @param options - The data options, a subset of the ResourceBoard props. * @returns The loaded resources, total, loading state, resolved selection, and refresh helper. */ export declare function useResourceBoard(options: UseResourceBoardProps): UseResourceBoardResult; export declare interface UseResourceBoardProps { readonly search: SearchRequest; readonly selectedId?: string; readonly loadItems?: (search: SearchRequest, medplum: MedplumClient) => Promise>; readonly resolveSelected?: (id: string, items: WithId[], medplum: MedplumClient) => Promise | undefined>; /** * Manual refresh trigger: change this value (e.g. a counter) to re-run the load * without changing the search. Reloads in place — no skeleton — like `refresh()`. */ readonly reloadKey?: unknown; readonly onSelectFirst?: (item: WithId) => void; readonly onLoad?: (items: WithId[], total: number | undefined) => void; readonly onError?: (error: unknown) => void; } export declare interface UseResourceBoardResult { readonly items: WithId[]; readonly total: number | undefined; readonly loading: boolean; readonly selected: WithId | undefined; /** * The search currently in effect. Tracks the input `search`, but only updates when it * changes by deep equality — so this identity is stable across renders and safe to use * in dependency arrays or to derive pagination from. */ readonly search: SearchRequest; readonly refresh: () => Promise; } /** * React hook for observing FHIR resource modifications made through the Medplum client. * * The callback is invoked whenever this client instance creates, updates, patches, or deletes * a resource of one of the given types, including modifications announced with * `MedplumClient.notifyResourceModified`. Use it to keep local component state in sync with * mutations made elsewhere in the application. Subscribing to a single resource type narrows * the event so `event.resource` is typed to that resource, no type guard required: * * ```tsx * useResourceModified('Slot', (event) => { * // event.resource is `WithId | undefined` * }); * useResourceModified(['Slot', 'Appointment'], () => refreshSchedule()); * ``` * * Modifications made by other clients (or other users) are not observed; * use `useSubscription` for server-side change notifications. * * @param resourceType - The resource type or types to observe. * @param callback - Invoked with the event payload for each matching modification. */ export declare function useResourceModified(resourceType: K | K[], callback: (event: ResourceModifiedEvent>) => void): void; /** * React hook for searching FHIR resources. * * This is a convenience hook for calling the MedplumClient.search() method. * * @param resourceType - The FHIR resource type to search. * @param query - Optional search parameters. * @param options - Optional options for configuring the search. * @returns A 3-element tuple containing the search result, loading flag, and operation outcome. */ export declare function useSearch(resourceType: K, query?: QueryTypes, options?: SearchOptions): [Bundle>> | undefined, boolean, OperationOutcome | undefined]; /** * React hook for searching for a single FHIR resource. * * This is a convenience hook for calling the MedplumClient.searchOne() method. * * @param resourceType - The FHIR resource type to search. * @param query - Optional search parameters. * @param options - Optional options for configuring the search. * @returns A 3-element tuple containing the search result, loading flag, and operation outcome. */ export declare function useSearchOne(resourceType: K, query?: QueryTypes, options?: SearchOptions): [WithId> | undefined, boolean, OperationOutcome | undefined]; /** * React hook for searching for an array of FHIR resources. * * This is a convenience hook for calling the MedplumClient.searchResources() method. * * @param resourceType - The FHIR resource type to search. * @param query - Optional search parameters. * @param options - Optional options for configuring the search. * @returns A 3-element tuple containing the search result, loading flag, and operation outcome. */ export declare function useSearchResources(resourceType: K, query?: QueryTypes, options?: SearchOptions): [ResourceArray>> | undefined, boolean, OperationOutcome | undefined]; /** * Creates an in-memory `Subscription` resource with the given criteria on the Medplum server and calls the given callback when an event notification is triggered by a resource interaction over a WebSocket connection. * * Subscriptions created with this hook are lightweight, share a single WebSocket connection, and are automatically untracked and cleaned up when the containing component is no longer mounted. * * @param criteria - The FHIR search criteria to subscribe to. * @param callback - The callback to call when a notification event `Bundle` for this `Subscription` is received. * @param options - Optional options used to configure the created `Subscription`. See {@link UseSubscriptionOptions} * * -------------------------------------------------------------------------------------------------------------------------------- * * `options` contains the following properties, all of which are optional: * - `subscriptionProps` - Allows the caller to pass a `Partial` to use as part of the creation * of the `Subscription` resource for this subscription. It enables the user namely to pass things like the `extension` property and to create * the `Subscription` with extensions such the {@link https://www.medplum.com/docs/subscriptions/subscription-extensions#interactions | Supported Interaction} extension which would enable to listen for `create` or `update` only events. * - `onWebsocketOpen` - Called when the WebSocket connection is established with Medplum server. * - `onWebsocketClose` - Called when the WebSocket connection disconnects. * - `onSubscriptionConnect` - Called when the corresponding subscription starts to receive updates after the subscription has been initialized and connected to. * - `onSubscriptionDisconnect` - Called when the corresponding subscription is destroyed and stops receiving updates from the server. * - `onError` - Called whenever an error occurs during the lifecycle of the managed subscription. */ export declare function useSubscription(criteria: string | undefined, callback: (bundle: Bundle) => void, options?: UseSubscriptionOptions): void; export declare type UseSubscriptionOptions = { subscriptionProps?: Partial; onWebSocketOpen?: () => void; onWebSocketClose?: () => void; onSubscriptionConnect?: (subscriptionId: string) => void; onSubscriptionDisconnect?: (subscriptionId: string) => void; onError?: (err: Error) => void; }; /** * Vendor-neutral React hook that syncs a Medplum `PlanDefinition` (type=order-set) * to the configured e-prescribing vendor via the `$sync-orderset` custom FHIR operation * (`POST /fhir/R4/PlanDefinition/$sync-orderset`). * * Resolves with the decoded `OrderSetSyncResponse` so callers can surface * per-action failures (`results[i].status === 'failed'` / `failedCount > 0`) — * without this, an order set that only partially synced would silently apply * with fewer meds than the PlanDefinition requested. * * Resolves with `undefined` when the operation is not deployed (i.e. no * e-prescribing vendor is configured for the project), so callers do not need to * guard against missing integrations. * * @returns A stable `syncOrderSet(planDefinitionId, organization?)` callback. */ export declare function useSyncOrderSet(): (planDefinitionId: string, organization?: Reference) => Promise; export declare function useThreadInbox({ query, threadId }: UseThreadInboxOptions): UseThreadInboxReturn; export declare interface UseThreadInboxOptions { query: string; threadId: string | undefined; } export declare interface UseThreadInboxReturn { loading: boolean; error: Error | null; threadMessages: [Communication, Communication | undefined][]; selectedThread: Communication | undefined; total: number | undefined; addThreadMessage: (message: Communication) => void; handleThreadStatusChange: (newStatus: Communication['status']) => void; refreshThreadMessages: () => Promise; } /** * Probes a set of ValueSet URLs for availability, each with a filter-free, count-limited expansion. * * A filter-free probe means a 400/404 unambiguously describes the value set itself (unlike a * user-typed search, whose 400 can be filter-specific), so the verdict is safe to act on. Repeated * probes of the same URL are deduplicated by the `MedplumClient` request cache, which caches * rejections too, so many fields bound to the same missing value set cost one request. Recovery * after a value set is imported happens on the next mount (i.e. a page refresh) — there is no live * subscription. Transient failures (429/5xx/network) resolve as available so a blip never disables * a field; only a permanent 400/404 marks a URL unavailable. * @param urls - The ValueSet URLs to probe. Falsy entries are ignored, and duplicates collapse to a * single probe. * @returns The availability verdict, with `loading` true until every requested URL has settled. */ export declare function useValueSetAvailabilities(urls: readonly (string | undefined)[]): ValueSetAvailability; /** * Probes a single ValueSet's availability once on mount. A thin wrapper around * {@link useValueSetAvailabilities} for the common single-value-set case. * @param url - The ValueSet URL, or undefined for unbound inputs (always available). * @returns undefined while the probe is in flight, true if available, false if unavailable. */ export declare function useValueSetAvailability(url: string | undefined): boolean | undefined; export declare function useWhisper({ language, model, onTranscript, idleTimeoutMs, }: UseWhisperOptions): UseWhisperResult; export declare type UseWhisperOptions = { language?: string; model?: string; onTranscript?: (text: string) => void; /** * How long to keep the WebSocket warm after stop() before fully closing it, in milliseconds. * Defaults to 120000 (2 minutes). Set to 0 or a non-finite value to keep the socket warm * until unmount (the previous behavior). */ idleTimeoutMs?: number; }; export declare type UseWhisperResult = { status: WhisperStatus; error: unknown; transcripts: TranscriptItem[]; start: () => Promise; stop: () => void; isListening: boolean; muted: boolean; setMuted: (value: boolean) => void; }; /** * The result of probing one or more ValueSet URLs for availability. */ export declare interface ValueSetAvailability { /** True while at least one requested URL is still being probed. */ readonly loading: boolean; /** The subset of requested URLs known to be available. */ readonly available: string[]; /** The subset of requested URLs known to be unavailable (a permanent 400/404). */ readonly unavailable: string[]; } export declare type WhisperStatus = 'idle' | 'requesting_microphone' | 'connecting' | 'connected' | 'listening' | 'speech_started' | 'speech_stopped' | 'disconnected' | 'error'; export { }