@medplum/react 5.1.6 → 5.1.8

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.
@@ -36,6 +36,7 @@ import type { ErrorInfo } from 'react';
36
36
  import type { ExtendedInternalSchemaElement } from '@medplum/core';
37
37
  import type { ExtractResource } from '@medplum/fhirtypes';
38
38
  import type { Filter } from '@medplum/core';
39
+ import { ForwardRefExoticComponent } from 'react';
39
40
  import { getPreferredPharmaciesFromPatient } from '@medplum/core';
40
41
  import type { HumanName } from '@medplum/fhirtypes';
41
42
  import type { HumanNameFormatOptions } from '@medplum/core';
@@ -83,6 +84,7 @@ import type { QuestionnaireResponseItemAnswer } from '@medplum/fhirtypes';
83
84
  import type { Range as Range_2 } from '@medplum/fhirtypes';
84
85
  import type { Ratio } from '@medplum/fhirtypes';
85
86
  import type { ReactNode } from 'react';
87
+ import { RefAttributes } from 'react';
86
88
  import type { Reference } from '@medplum/fhirtypes';
87
89
  import { removePreferredPharmacyFromPatient } from '@medplum/core';
88
90
  import type { RequestGroup } from '@medplum/fhirtypes';
@@ -226,6 +228,9 @@ export declare function addYearToDateFilter(definition: SearchRequest, field: st
226
228
  */
227
229
  export declare function addYesterdayFilter(definition: SearchRequest, field: string): SearchRequest;
228
230
 
231
+ /** Allergies section — searches for AllergyIntolerance resources. */
232
+ export declare const AllergiesSection: PatientSummarySectionConfig;
233
+
229
234
  export declare function AnnotationInput(props: AnnotationInputProps): JSX.Element;
230
235
 
231
236
  export declare interface AnnotationInputProps extends ComplexTypeInputProps<Annotation> {
@@ -520,6 +525,8 @@ export declare interface CodingInputProps extends Omit<ValueSetAutocompleteProps
520
525
  readonly response?: QuestionnaireResponseItem;
521
526
  }
522
527
 
528
+ export declare function codingToValueSetElement(coding: Coding): ValueSetExpansionContains;
529
+
523
530
  export declare type Command<T = string> = {
524
531
  command: string;
525
532
  value?: T;
@@ -570,6 +577,23 @@ export declare function convertIsoToLocal(isoString: string | undefined): string
570
577
  */
571
578
  export declare function convertLocalToIso(localString: string | undefined): string;
572
579
 
580
+ /**
581
+ * Labs section — searches for both ServiceRequest and DiagnosticReport resources.
582
+ * Accepts an optional `onRequestLabs` callback via closure.
583
+ * @param onRequestLabs - Optional callback invoked when the user requests labs.
584
+ * @returns A section config for labs.
585
+ */
586
+ export declare function createLabsSection(onRequestLabs?: () => void): PatientSummarySectionConfig;
587
+
588
+ /**
589
+ * Pharmacies section — no FHIR searches; the Pharmacies component resolves its own data
590
+ * from patient extensions.
591
+ * Accepts an optional `pharmacyDialogComponent` via closure.
592
+ * @param pharmacyDialogComponent - Optional component for the pharmacy search dialog.
593
+ * @returns A section config for pharmacies.
594
+ */
595
+ export declare function createPharmaciesSection(pharmacyDialogComponent?: ComponentType<PharmacyDialogBaseProps>): PatientSummarySectionConfig;
596
+
573
597
  export { createPreferredPharmacyExtension }
574
598
 
575
599
  /**
@@ -598,6 +622,12 @@ export declare interface DateTimeInputProps extends PrimitiveTypeInputProps {
598
622
  readonly onChange?: (value: string) => void;
599
623
  }
600
624
 
625
+ /**
626
+ * Default item component for resource autocomplete inputs.
627
+ * Displays the resource avatar, display name, and birth date or ID.
628
+ */
629
+ export declare const DefaultResourceItemComponent: ForwardRefExoticComponent<AsyncAutocompleteOption<Resource> & RefAttributes<HTMLDivElement>>;
630
+
601
631
  export declare function DefaultResourceTimeline(props: DefaultResourceTimelineProps): JSX.Element;
602
632
 
603
633
  export declare interface DefaultResourceTimelineProps extends Pick<ResourceTimelineProps<Resource>, 'getMenu'> {
@@ -612,6 +642,9 @@ export declare interface DefaultResourceTimelineProps extends Pick<ResourceTimel
612
642
  */
613
643
  export declare function deleteFilter(definition: SearchRequest, index: number): SearchRequest;
614
644
 
645
+ /** Demographics section — no FHIR searches, renders patient info items directly. */
646
+ export declare const DemographicsSection: PatientSummarySectionConfig;
647
+
615
648
  export declare function DescriptionList(props: DescriptionListProps): JSX.Element;
616
649
 
617
650
  export declare function DescriptionListEntry(props: DescriptionListEntryProps): JSX.Element;
@@ -664,6 +697,13 @@ export declare interface EncounterTimelineProps extends Pick<ResourceTimelinePro
664
697
  readonly encounter: Encounter | Reference<Encounter>;
665
698
  }
666
699
 
700
+ export declare interface EPrescribingIFrameOptions {
701
+ readonly patientId?: string;
702
+ readonly onPatientSyncSuccess?: () => void;
703
+ readonly onIframeSuccess?: (url: string) => void;
704
+ readonly onError?: (err: unknown) => void;
705
+ }
706
+
667
707
  /**
668
708
  * ErrorBoundary is a React component that handles errors in its child components.
669
709
  * See: https://reactjs.org/docs/error-boundaries.html
@@ -729,6 +769,20 @@ export declare interface FhirPathTableProps {
729
769
  readonly onBulk?: (ids: string[]) => void;
730
770
  }
731
771
 
772
+ /** Descriptor for a single FHIR search that a section needs. */
773
+ export declare interface FhirSearchDescriptor {
774
+ /** Unique key used to access this search's results via `SectionResults[key]`. */
775
+ readonly key: string;
776
+ readonly resourceType: ResourceType;
777
+ /** Which search param references the patient. Defaults to 'subject'. Examples: 'patient', 'beneficiary'. */
778
+ readonly patientParam?: string;
779
+ /**
780
+ * Additional search params — same format as the 2nd arg to medplum.searchResources().
781
+ * When using a string, do not include _count or _sort; they are appended automatically.
782
+ */
783
+ readonly query?: QueryTypes;
784
+ }
785
+
732
786
  export declare function Form(props: FormProps): JSX.Element;
733
787
 
734
788
  export declare interface FormProps {
@@ -759,6 +813,14 @@ export declare interface FormSectionProps {
759
813
  */
760
814
  export declare function getAppName(): string;
761
815
 
816
+ /**
817
+ * Returns the default set of sections, matching the original hardcoded PatientSummary layout.
818
+ * The `onRequestLabs` callback is threaded through to the Labs section.
819
+ * @param onRequestLabs - Optional callback invoked when the user requests labs.
820
+ * @returns The default array of section configs.
821
+ */
822
+ export declare function getDefaultSections(onRequestLabs?: () => void): PatientSummarySectionConfig[];
823
+
762
824
  export declare function getErrorsForInput(outcome: OperationOutcome | undefined, expression: string | undefined): string | undefined;
763
825
 
764
826
  /**
@@ -895,6 +957,9 @@ export declare interface InfoBarValueProps {
895
957
  */
896
958
  export declare function initRecaptcha(siteKey: string): void;
897
959
 
960
+ /** Insurance section — searches for Coverage resources. */
961
+ export declare const InsuranceSection: PatientSummarySectionConfig;
962
+
898
963
  export declare type IntervalGroup = {
899
964
  id: string;
900
965
  filters: Record<string, any>;
@@ -947,6 +1012,9 @@ export declare function isSupportedProfileStructureDefinition(profile?: Structur
947
1012
  */
948
1013
  export declare function killEvent(e: Event | SyntheticEvent): void;
949
1014
 
1015
+ /** Default Labs section constant (no onRequestLabs callback). */
1016
+ export declare const LabsSection: PatientSummarySectionConfig;
1017
+
950
1018
  export declare function LinkTabs(props: LinkTabsProps): JSX.Element;
951
1019
 
952
1020
  export declare interface LinkTabsProps extends Omit<TabsProps, 'value' | 'onChange'> {
@@ -970,6 +1038,9 @@ export declare interface MeasureReportDisplayProps {
970
1038
  readonly measureReport: MeasureReport | Reference<MeasureReport>;
971
1039
  }
972
1040
 
1041
+ /** Medications section — searches for MedicationRequest resources. */
1042
+ export declare const MedicationsSection: PatientSummarySectionConfig;
1043
+
973
1044
  export declare interface MedplumContext {
974
1045
  medplum: MedplumClient;
975
1046
  navigate: MedplumNavigateFunction;
@@ -1033,6 +1104,29 @@ export declare interface MoneyInputProps extends ComplexTypeInputProps<Money> {
1033
1104
  readonly placeholder?: string;
1034
1105
  }
1035
1106
 
1107
+ export declare function MultiResourceInput<T extends Resource = Resource>(props: MultiResourceInputProps<T>): JSX.Element | null;
1108
+
1109
+ export declare interface MultiResourceInputProps<T extends Resource = Resource> {
1110
+ readonly resourceType: T['resourceType'];
1111
+ readonly name: string;
1112
+ /**
1113
+ * Initial selected values. Each entry may be a full resource or a reference that will be
1114
+ * resolved on mount. Treated as uncontrolled — changes after mount are ignored.
1115
+ */
1116
+ readonly defaultValue?: (T | Reference<T>)[];
1117
+ readonly searchCriteria?: Record<string, string>;
1118
+ readonly placeholder?: string;
1119
+ readonly required?: boolean;
1120
+ readonly itemComponent?: (props: AsyncAutocompleteOption<T>) => JSX.Element | ReactNode;
1121
+ /** Called whenever the selection changes. Receives the full array of selected resources. */
1122
+ readonly onChange?: (value: T[]) => void;
1123
+ readonly disabled?: boolean;
1124
+ readonly label?: AsyncAutocompleteProps<T>['label'];
1125
+ readonly error?: AsyncAutocompleteProps<T>['error'];
1126
+ /** Maximum number of resources that can be selected. Defaults to uncapped. */
1127
+ readonly maxValues?: number;
1128
+ }
1129
+
1036
1130
  export declare function Navbar(props: NavbarProps): JSX.Element;
1037
1131
 
1038
1132
  export declare interface NavbarLink {
@@ -1150,6 +1244,13 @@ export declare interface ParticipantFilterProps {
1150
1244
 
1151
1245
  export { PATIENT_PREFERRED_PHARMACY_URL }
1152
1246
 
1247
+ export declare function PatientAccountsForm(props: PatientAccountsFormProps): JSX.Element;
1248
+
1249
+ export declare interface PatientAccountsFormProps {
1250
+ readonly patient: Patient;
1251
+ readonly onSaved?: () => void;
1252
+ }
1253
+
1153
1254
  export declare function PatientExportForm(props: PatientExportFormProps): JSX.Element;
1154
1255
 
1155
1256
  export declare interface PatientExportFormProps {
@@ -1164,11 +1265,34 @@ export declare interface PatientHeaderProps {
1164
1265
 
1165
1266
  export declare function PatientSummary(props: PatientSummaryProps): JSX.Element | null;
1166
1267
 
1268
+ export declare interface PatientSummaryData {
1269
+ /** One SectionResults map per section, indexed to match the sections array. */
1270
+ readonly sectionData: SectionResults[];
1271
+ readonly loading: boolean;
1272
+ readonly error: Error | undefined;
1273
+ }
1274
+
1167
1275
  export declare interface PatientSummaryProps {
1168
1276
  readonly patient: Patient | Reference<Patient>;
1169
1277
  readonly onClickResource?: (resource: Resource) => void;
1170
1278
  readonly onRequestLabs?: () => void;
1171
- readonly pharmacyDialogComponent?: ComponentType<PharmacyDialogBaseProps>;
1279
+ readonly sections?: PatientSummarySectionConfig[];
1280
+ }
1281
+
1282
+ /**
1283
+ * Configuration for a single section in the PatientSummary.
1284
+ * The `searches` field is an array to support sections like Labs which need multiple resource types.
1285
+ */
1286
+ export declare interface PatientSummarySectionConfig {
1287
+ readonly key: string;
1288
+ readonly title: string;
1289
+ readonly searches?: FhirSearchDescriptor[];
1290
+ /**
1291
+ * React component that renders this section.
1292
+ * Using ComponentType (rather than a render-prop function) ensures React treats it as a real
1293
+ * component, so hooks inside custom sections work correctly.
1294
+ */
1295
+ readonly component: ComponentType<SectionRenderContext>;
1172
1296
  }
1173
1297
 
1174
1298
  export declare function PatientTimeline(props: PatientTimelineProps): JSX.Element;
@@ -1186,6 +1310,9 @@ export declare interface PharmaciesProps {
1186
1310
  readonly pharmacyDialogComponent?: ComponentType<PharmacyDialogBaseProps>;
1187
1311
  }
1188
1312
 
1313
+ /** Default Pharmacies section constant (no pharmacy dialog component). */
1314
+ export declare const PharmaciesSection: PatientSummarySectionConfig;
1315
+
1189
1316
  export { PHARMACY_PREFERENCE_TYPE_SYSTEM }
1190
1317
 
1191
1318
  export { PHARMACY_TYPE_PREFERRED }
@@ -1238,6 +1365,9 @@ export declare interface PrimitiveTypeInputProps {
1238
1365
  readonly disabled?: boolean;
1239
1366
  }
1240
1367
 
1368
+ /** Problem List section — searches for Condition resources. */
1369
+ export declare const ProblemListSection: PatientSummarySectionConfig;
1370
+
1241
1371
  export declare function QuantityDisplay(props: QuantityDisplayProps): JSX.Element | null;
1242
1372
 
1243
1373
  export declare interface QuantityDisplayProps {
@@ -1586,8 +1716,15 @@ export declare interface ResourceHistoryTableProps {
1586
1716
  readonly id?: string;
1587
1717
  }
1588
1718
 
1719
+ /**
1720
+ * @param props - The props for the ResourceInput component.
1721
+ * @returns The ResourceInput component.
1722
+ */
1589
1723
  export declare function ResourceInput<T extends Resource = Resource>(props: ResourceInputProps<T>): JSX.Element | null;
1590
1724
 
1725
+ /**
1726
+ * @deprecated Use MultiResourceInput instead, which supports multiple default and selected values.
1727
+ */
1591
1728
  export declare interface ResourceInputProps<T extends Resource = Resource> {
1592
1729
  readonly resourceType: T['resourceType'];
1593
1730
  readonly name: string;
@@ -1786,8 +1923,20 @@ export declare class SearchLoadEvent extends Event {
1786
1923
 
1787
1924
  export declare type SearchOptions = {
1788
1925
  debounceMs?: number;
1926
+ enabled?: boolean;
1789
1927
  };
1790
1928
 
1929
+ /** Context passed to every section's component. */
1930
+ export declare interface SectionRenderContext {
1931
+ readonly patient: Patient;
1932
+ readonly onClickResource?: (resource: Resource) => void;
1933
+ /** Named results for each search in the section's `searches` array, keyed by `FhirSearchDescriptor.key`. */
1934
+ readonly results: SectionResults;
1935
+ }
1936
+
1937
+ /** Named map of FHIR results for a section: `results[searchKey]` returns the Resource[] for that search. */
1938
+ export declare type SectionResults = Record<string, Resource[]>;
1939
+
1791
1940
  /**
1792
1941
  * Sends a structured command to the iframe using postMessage.
1793
1942
  *
@@ -1853,6 +2002,9 @@ export declare function setQuestionnaireItemReferenceTargetTypes(item: Questionn
1853
2002
  */
1854
2003
  export declare function setSort(definition: SearchRequest, sort: string, desc?: boolean): SearchRequest;
1855
2004
 
2005
+ /** Sexual Orientation section — searches for Observation resources by LOINC 76690-7. */
2006
+ export declare const SexualOrientationSection: PatientSummarySectionConfig;
2007
+
1856
2008
  export declare function SignatureInput(props: SignatureInputProps): JSX.Element;
1857
2009
 
1858
2010
  export declare interface SignatureInputProps extends PaperProps {
@@ -1912,6 +2064,9 @@ export declare interface SmartSearchResponse {
1912
2064
  };
1913
2065
  }
1914
2066
 
2067
+ /** Smoking Status section — searches for Observation resources by LOINC 72166-2. */
2068
+ export declare const SmokingStatusSection: PatientSummarySectionConfig;
2069
+
1915
2070
  /**
1916
2071
  * Sorts an array of resources in place by meta.lastUpdated ascending.
1917
2072
  * @param resources - Array of resources.
@@ -1935,6 +2090,44 @@ export declare function SubmitButton(props: ButtonProps): JSX.Element;
1935
2090
 
1936
2091
  export declare type SubmitButtonProps = Omit<ButtonProps, 'type' | 'loading'>;
1937
2092
 
2093
+ export declare interface SummaryResourceListOptions {
2094
+ /** Unique key for React reconciliation. */
2095
+ readonly key: string;
2096
+ /** Section title displayed in the collapsible header. */
2097
+ readonly title: string;
2098
+ /** FHIR search configuration. */
2099
+ readonly search: {
2100
+ readonly resourceType: ResourceType;
2101
+ /** Which search param references the patient. Defaults to 'subject'. */
2102
+ readonly patientParam?: string;
2103
+ /** Additional search params. */
2104
+ readonly query?: Record<string, string | number | boolean | undefined>;
2105
+ };
2106
+ /** Override the default display string for each resource. */
2107
+ readonly getDisplayString?: (resource: Resource) => string;
2108
+ /** Return a status badge config, or undefined to show no badge. */
2109
+ readonly getStatus?: (resource: Resource) => {
2110
+ label: string;
2111
+ color: string;
2112
+ } | undefined;
2113
+ /** Return secondary text (shown dimmed below the primary text). */
2114
+ readonly getSecondaryText?: (resource: Resource) => string | undefined;
2115
+ /** Filter resources before display. */
2116
+ readonly filter?: (resource: Resource) => boolean;
2117
+ /** Sort resources before display. */
2118
+ readonly sort?: (a: Resource, b: Resource) => number;
2119
+ /** Callback for the "+" add button. If omitted, no add button is shown. */
2120
+ readonly onAdd?: () => void;
2121
+ }
2122
+
2123
+ /**
2124
+ * Creates a `PatientSummarySectionConfig` that renders a list of resources
2125
+ * using the same visual pattern as built-in sections (CollapsibleSection + SummaryItem + StatusBadge).
2126
+ * @param options - Configuration for the resource list section.
2127
+ * @returns A section config that renders a generic resource list.
2128
+ */
2129
+ export declare function summaryResourceListSection(options: SummaryResourceListOptions): PatientSummarySectionConfig;
2130
+
1938
2131
  export declare type SupportedProfileStructureDefinition = StructureDefinition & {
1939
2132
  url: NonNullable<StructureDefinition['url']>;
1940
2133
  name: NonNullable<StructureDefinition['name']>;
@@ -1966,7 +2159,7 @@ export declare function ThreadInbox(props: ThreadInboxProps): JSX.Element;
1966
2159
  * @param threadId - The id of the thread to select.
1967
2160
  * @param subject - The default subject when creating a new thread.
1968
2161
  * @param showPatientSummary - Whether to show the patient summary.
1969
- * @param pharmacyDialogComponent - Optional component to render as the pharmacy dialog in the patient summary.
2162
+ * @param sections - Optional sections configuration for the patient summary.
1970
2163
  * @param onNew - A function to handle a new thread.
1971
2164
  * @param getThreadUri - A function to build thread URIs.
1972
2165
  * @param onChange - A function to handle search changes.
@@ -1978,7 +2171,7 @@ export declare interface ThreadInboxProps {
1978
2171
  readonly threadId: string | undefined;
1979
2172
  readonly subject?: Reference<Patient> | Patient;
1980
2173
  readonly showPatientSummary?: boolean;
1981
- readonly pharmacyDialogComponent?: ComponentType<PharmacyDialogBaseProps>;
2174
+ readonly sections?: PatientSummarySectionConfig[];
1982
2175
  readonly onNew: (message: Communication) => void;
1983
2176
  readonly getThreadUri: (topic: Communication) => string;
1984
2177
  readonly onChange: (search: SearchRequest) => void;
@@ -2025,6 +2218,23 @@ export declare function typedValueToResponseItem(item: QuestionnaireItem, value:
2025
2218
 
2026
2219
  export declare const useCachedBinaryUrl: (binaryUrl: string | undefined) => string | undefined;
2027
2220
 
2221
+ /**
2222
+ * Generic React hook that syncs a patient to an e-prescribing system and
2223
+ * returns the iframe URL.
2224
+ *
2225
+ * Executes the patient-sync bot first (if patientId is provided), then
2226
+ * the iframe bot to obtain the prescribing UI URL.
2227
+ *
2228
+ * Uses an effect cleanup flag so React 18 Strict Mode double-mount does not
2229
+ * trigger duplicate bot executions.
2230
+ *
2231
+ * @param syncBotIdentifier - Bot identifier for the patient sync bot.
2232
+ * @param iframeBotIdentifier - Bot identifier for the iframe URL bot.
2233
+ * @param options - Configuration and callback options.
2234
+ * @returns The e-prescribing iframe URL, or undefined while loading.
2235
+ */
2236
+ export declare function useEPrescribingIFrame(syncBotIdentifier: Identifier, iframeBotIdentifier: Identifier, options: EPrescribingIFrameOptions): string | undefined;
2237
+
2028
2238
  /**
2029
2239
  * Returns the MedplumClient instance.
2030
2240
  * This is a shortcut for useMedplumContext().medplum.
@@ -2069,6 +2279,38 @@ export declare interface UseNotificationCountOptions {
2069
2279
  readonly subscriptionCriteria: string;
2070
2280
  }
2071
2281
 
2282
+ /**
2283
+ * Hook that collects all FHIR searches from section configs, deduplicates them,
2284
+ * executes them in parallel, and routes results back to each section.
2285
+ * Uses Promise.allSettled so a single failing search does not block all sections —
2286
+ * sections whose searches fail gracefully receive empty arrays.
2287
+ * @param patient - The patient or patient reference to fetch data for.
2288
+ * @param sections - The section configs defining which searches to execute.
2289
+ * @returns Section data, loading state, and any error.
2290
+ */
2291
+ export declare function usePatientSummaryData(patient: Patient | Reference<Patient>, sections: {
2292
+ readonly key: string;
2293
+ readonly searches?: FhirSearchDescriptor[];
2294
+ }[]): PatientSummaryData;
2295
+
2296
+ /**
2297
+ * Generic React hook that provides pharmacy search and add-to-favorites
2298
+ * functionality for any e-prescribing integration.
2299
+ *
2300
+ * Encapsulates calls to a search-pharmacy bot and an add-patient-pharmacy bot,
2301
+ * and can be composed with the generic `PharmacyDialog` component from `@medplum/react`.
2302
+ *
2303
+ * @param searchBotIdentifier - Bot identifier for the pharmacy search bot.
2304
+ * @param addPharmacyBotIdentifier - Bot identifier for the add-patient-pharmacy bot.
2305
+ * @returns An object with `searchPharmacies` and `addToFavorites` callbacks.
2306
+ */
2307
+ export declare function usePharmacySearch(searchBotIdentifier: Identifier, addPharmacyBotIdentifier: Identifier): UsePharmacySearchReturn;
2308
+
2309
+ export declare interface UsePharmacySearchReturn {
2310
+ searchPharmacies: (params: PharmacySearchParams) => Promise<Organization[]>;
2311
+ addToFavorites: (params: AddFavoriteParams) => Promise<AddPharmacyResponse>;
2312
+ }
2313
+
2072
2314
  /**
2073
2315
  * React Hook to keep track of the passed-in value from the previous render of the containing component.
2074
2316
  * @param value - The value to track.
@@ -2199,4 +2441,9 @@ export declare interface ValueSetAutocompleteProps extends Omit<AsyncAutocomplet
2199
2441
  readonly withHelpText?: boolean;
2200
2442
  }
2201
2443
 
2444
+ export declare function valueSetElementToCoding(element: ValueSetExpansionContains): Coding;
2445
+
2446
+ /** Vitals section — searches for Observation resources with category vital-signs. */
2447
+ export declare const VitalsSection: PatientSummarySectionConfig;
2448
+
2202
2449
  export { }