@medplum/core 3.2.32 → 3.2.33

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.
@@ -13,13 +13,16 @@ import { Communication } from '@medplum/fhirtypes';
13
13
  import { ConceptMap } from '@medplum/fhirtypes';
14
14
  import type { CustomTableLayout } from 'pdfmake/interfaces';
15
15
  import { Device } from '@medplum/fhirtypes';
16
+ import { DiagnosticReport } from '@medplum/fhirtypes';
16
17
  import { ElementDefinition } from '@medplum/fhirtypes';
17
18
  import { ElementDefinitionBinding } from '@medplum/fhirtypes';
19
+ import { Encounter } from '@medplum/fhirtypes';
18
20
  import { Extension } from '@medplum/fhirtypes';
19
21
  import { ExtensionValue } from '@medplum/fhirtypes';
20
22
  import { ExtractResource } from '@medplum/fhirtypes';
21
23
  import { HumanName } from '@medplum/fhirtypes';
22
24
  import { Identifier } from '@medplum/fhirtypes';
25
+ import { ImagingStudy } from '@medplum/fhirtypes';
23
26
  import { Media } from '@medplum/fhirtypes';
24
27
  import { Money } from '@medplum/fhirtypes';
25
28
  import { Observation } from '@medplum/fhirtypes';
@@ -166,6 +169,8 @@ export declare interface AgentUpgradeResponse extends BaseAgentMessage {
166
169
 
167
170
  export declare const allOk: OperationOutcome;
168
171
 
172
+ export declare type AnchorResourceOpenEvent<T extends FhircastAnchorResourceType> = T extends FhircastAnchorResourceType ? `${T}-open` : never;
173
+
169
174
  /**
170
175
  * 6.5.1. and
171
176
  * Returns true if both operands evaluate to true,
@@ -191,8 +196,6 @@ export declare function append<T>(array: T[] | undefined, value: T): T[];
191
196
  */
192
197
  export declare function applyDefaultValuesToElement(existingValue: object, elements: Record<string, InternalSchemaElement>, key?: string): object;
193
198
 
194
- export declare function applyDefaultValuesToElementWithVisitor(existingValue: any, path: string, element: InternalSchemaElement, elements: Record<string, InternalSchemaElement>, schema: InternalTypeSchema): any;
195
-
196
199
  /**
197
200
  * Adds default values to `resource` based on the supplied `schema`. Default values includes all required fixed and pattern
198
201
  * values specified on elements in the schema. If an element has a fixed/pattern value but is optional, i.e.
@@ -562,8 +565,6 @@ export declare function convertContainedResourcesToBundle(resource: Resource & {
562
565
  */
563
566
  export declare function convertToTransactionBundle(bundle: Bundle): Bundle;
564
567
 
565
- export declare type ConvertToUnion<T> = T[keyof T];
566
-
567
568
  export declare const CPT = "http://www.ama-assn.org/go/cpt";
568
569
 
569
570
  export declare interface CrawlerOptions {
@@ -675,9 +676,9 @@ export declare const created: OperationOutcome;
675
676
  * @param versionId - The current `versionId` of the anchor context. For example, in `DiagnosticReport-update`, it's the `versionId` of the `DiagnosticReport`.
676
677
  * @returns A serializable `FhircastMessagePayload`.
677
678
  */
678
- export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionOptional>(topic: string, event: EventName, context: FhircastValidContextForEvent<EventName> | FhircastValidContextForEvent<EventName>[], versionId?: never): FhircastMessagePayload<EventName>;
679
+ export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionOptional>(topic: string, event: EventName, context: FhircastEventContext<EventName> | FhircastEventContext<EventName>[], versionId?: never): FhircastMessagePayload<EventName>;
679
680
 
680
- export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionRequired>(topic: string, event: EventName, context: FhircastValidContextForEvent<EventName> | FhircastValidContextForEvent<EventName>[], versionId: string): FhircastMessagePayload<EventName>;
681
+ export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionRequired>(topic: string, event: EventName, context: FhircastEventContext<EventName> | FhircastEventContext<EventName>[], versionId: string): FhircastMessagePayload<EventName>;
681
682
 
682
683
  export declare interface CreateMediaOptions extends CreateBinaryOptions {
683
684
  /**
@@ -723,11 +724,18 @@ export declare function createReference<T extends Resource>(resource: T): Refere
723
724
 
724
725
  export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue;
725
726
 
726
- export declare type CurrentContext<EventName extends FhircastResourceEventName = FhircastResourceEventName> = {
727
- 'context.type': ResourceType | '';
728
- 'context.versionId'?: string;
729
- context: FhircastEventContext<EventName>[];
730
- };
727
+ export declare type CurrentContext<T extends FhircastAnchorResourceType | '' = FhircastAnchorResourceType | ''> = T extends '' ? {
728
+ 'context.type': '';
729
+ context: never[];
730
+ } : T extends 'DiagnosticReport' ? {
731
+ 'context.type': 'DiagnosticReport';
732
+ 'context.versionId': string;
733
+ context: (FhircastEventContext<'DiagnosticReport-open'> | FhircastHubContentContext)[];
734
+ } : T extends 'Patient' | 'Encounter' | 'ImagingStudy' ? {
735
+ 'context.type': T;
736
+ 'context.versionId': string;
737
+ context: FhircastEventContext<AnchorResourceOpenEvent<T>>;
738
+ } : never;
731
739
 
732
740
  export declare type DataTypesMap = {
733
741
  [type: string]: InternalTypeSchema;
@@ -1094,23 +1102,28 @@ export declare const FHIRCAST_EVENT_RESOURCES: {
1094
1102
  readonly 'DiagnosticReport-select': {
1095
1103
  readonly report: {
1096
1104
  readonly resourceType: "DiagnosticReport";
1105
+ readonly reference: true;
1106
+ };
1107
+ readonly patient: {
1108
+ readonly resourceType: "Patient";
1109
+ readonly optional: true;
1110
+ readonly reference: true;
1097
1111
  };
1098
1112
  readonly select: {
1099
1113
  readonly resourceType: "*";
1100
- readonly isArray: true;
1114
+ readonly array: true;
1115
+ readonly reference: true;
1101
1116
  };
1102
1117
  };
1103
1118
  readonly 'DiagnosticReport-update': {
1104
1119
  readonly report: {
1105
1120
  readonly resourceType: "DiagnosticReport";
1121
+ readonly reference: true;
1106
1122
  };
1107
1123
  readonly patient: {
1108
1124
  readonly resourceType: "Patient";
1109
1125
  readonly optional: true;
1110
- };
1111
- readonly study: {
1112
- readonly resourceType: "ImagingStudy";
1113
- readonly optional: true;
1126
+ readonly reference: true;
1114
1127
  };
1115
1128
  readonly updates: {
1116
1129
  readonly resourceType: "Bundle";
@@ -1127,6 +1140,8 @@ export declare const FHIRCAST_EVENT_VERSION_REQUIRED: readonly ["DiagnosticRepor
1127
1140
 
1128
1141
  export declare const FHIRCAST_RESOURCE_TYPES: readonly ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
1129
1142
 
1143
+ export declare type FhircastAnchorResourceType = 'Patient' | 'ImagingStudy' | 'Encounter' | 'DiagnosticReport';
1144
+
1130
1145
  export declare type FhircastConnectEvent = {
1131
1146
  type: 'connect';
1132
1147
  };
@@ -1152,46 +1167,66 @@ export declare class FhircastConnection extends TypedEventTarget<FhircastSubscri
1152
1167
  disconnect(): void;
1153
1168
  }
1154
1169
 
1170
+ export declare type FhircastContextResourceType<EventName extends FhircastEventName, K extends FhircastEventKeys<EventName>> = (typeof FHIRCAST_EVENT_RESOURCES)[EventName][K] extends {
1171
+ resourceType: infer R;
1172
+ } ? R : never;
1173
+
1174
+ export declare type FhircastDiagnosticReportCloseContext = FhircastDiagnosticReportOpenContext;
1175
+
1176
+ export declare type FhircastDiagnosticReportOpenContext = FhircastReportContext | FhircastEncounterContext | FhircastStudyContext | FhircastPatientContext;
1177
+
1178
+ export declare type FhircastDiagnosticReportSelectContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastSelectContext;
1179
+
1180
+ export declare type FhircastDiagnosticReportUpdateContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastUpdatesContext;
1181
+
1155
1182
  export declare type FhircastDisconnectEvent = {
1156
1183
  type: 'disconnect';
1157
1184
  };
1158
1185
 
1159
- export declare type FhircastEventContext<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = FhircastEventContextMap<EventName>[K] extends infer _Ev extends FhircastEventContextDetails ? _Ev['isArray'] extends true ? FhircastMultiResourceContext<EventName, K> : FhircastSingleResourceContext<EventName, K> : never;
1186
+ export declare type FhircastEncounterCloseContext = FhircastEncounterOpenContext;
1187
+
1188
+ export declare type FhircastEncounterContext = {
1189
+ key: 'encounter';
1190
+ resource: Encounter;
1191
+ };
1192
+
1193
+ export declare type FhircastEncounterOpenContext = FhircastEncounterContext | FhircastPatientContext;
1194
+
1195
+ export declare type FhircastEventContext<EventName extends FhircastEventName = FhircastResourceEventName> = EventName extends 'Patient-open' ? FhircastPatientOpenContext : EventName extends 'Patient-close' ? FhircastPatientCloseContext : EventName extends 'ImagingStudy-open' ? FhircastImagingStudyOpenContext : EventName extends 'ImagingStudy-close' ? FhircastImagingStudyCloseContext : EventName extends 'Encounter-open' ? FhircastEncounterOpenContext : EventName extends 'Encounter-close' ? FhircastEncounterCloseContext : EventName extends 'DiagnosticReport-open' ? FhircastDiagnosticReportOpenContext : EventName extends 'DiagnosticReport-close' ? FhircastDiagnosticReportCloseContext : EventName extends 'DiagnosticReport-update' ? FhircastDiagnosticReportUpdateContext : EventName extends 'DiagnosticReport-select' ? FhircastDiagnosticReportSelectContext : EventName extends 'syncerror' ? FhircastSyncErrorContext : never;
1160
1196
 
1161
1197
  export declare type FhircastEventContextDetails = {
1162
1198
  resourceType: FhircastResourceType | '*';
1163
1199
  optional?: boolean;
1164
1200
  manyAllowed?: boolean;
1165
- isArray?: boolean;
1201
+ array?: boolean;
1202
+ reference?: boolean;
1166
1203
  };
1167
1204
 
1168
- export declare type FhircastEventContextKey<EventName extends FhircastEventName = FhircastEventName> = keyof FhircastEventContextMap<EventName>;
1169
-
1170
- export declare type FhircastEventContextMap<EventName extends FhircastEventName = FhircastEventName> = (typeof FHIRCAST_EVENT_RESOURCES)[EventName];
1205
+ export declare type FhircastEventKeys<EventName extends FhircastEventName> = keyof (typeof FHIRCAST_EVENT_RESOURCES)[EventName];
1171
1206
 
1172
1207
  export declare type FhircastEventName = keyof typeof FHIRCAST_EVENT_NAMES;
1173
1208
 
1174
- export declare type FhircastEventPayload<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = {
1209
+ export declare type FhircastEventPayload<EventName extends FhircastEventName = FhircastEventName> = {
1175
1210
  'hub.topic': string;
1176
1211
  'hub.event': EventName;
1177
- context: FhircastEventContext<EventName, K>[];
1212
+ context: FhircastEventContext<EventName>[];
1178
1213
  'context.versionId'?: string;
1179
1214
  'context.priorVersionId'?: string;
1180
1215
  };
1181
1216
 
1182
- export declare type FhircastEventResource<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = FhircastEventContextMap<EventName>[K] extends infer _Ev extends FhircastEventContextDetails ? FhircastEventResourceType<EventName, K> extends '*' ? Resource & {
1183
- id: string;
1184
- } : Resource & {
1185
- resourceType: FhircastEventResourceType<EventName, K>;
1186
- id: string;
1187
- } : never;
1188
-
1189
- export declare type FhircastEventResourceType<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = FhircastEventContextMap<EventName>[K] extends infer _Ev extends FhircastEventContextDetails ? _Ev['resourceType'] : never;
1190
-
1191
1217
  export declare type FhircastEventVersionOptional = Exclude<FhircastEventName, FhircastEventVersionRequired>;
1192
1218
 
1193
1219
  export declare type FhircastEventVersionRequired = (typeof FHIRCAST_EVENT_VERSION_REQUIRED)[number];
1194
1220
 
1221
+ export declare type FhircastHubContentContext = {
1222
+ key: 'content';
1223
+ resource: Bundle;
1224
+ };
1225
+
1226
+ export declare type FhircastImagingStudyCloseContext = FhircastImagingStudyOpenContext;
1227
+
1228
+ export declare type FhircastImagingStudyOpenContext = FhircastStudyContext | FhircastEncounterContext | FhircastPatientContext;
1229
+
1195
1230
  export declare type FhircastMessageEvent = {
1196
1231
  type: 'message';
1197
1232
  payload: FhircastMessagePayload;
@@ -1203,18 +1238,53 @@ export declare type FhircastMessagePayload<EventName extends FhircastEventName =
1203
1238
  event: FhircastEventPayload<EventName>;
1204
1239
  };
1205
1240
 
1206
- export declare type FhircastMultiResourceContext<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = {
1207
- key: K;
1208
- resources: FhircastEventResource<EventName, K>[];
1241
+ export declare type FhircastMultiReferenceContext = FhircastSelectContext;
1242
+
1243
+ export declare type FhircastOperationOutcomeContext = {
1244
+ key: 'operationoutcome';
1245
+ resource: OperationOutcome;
1246
+ };
1247
+
1248
+ export declare type FhircastPatientCloseContext = FhircastPatientOpenContext;
1249
+
1250
+ export declare type FhircastPatientContext = {
1251
+ key: 'patient';
1252
+ resource: Patient;
1253
+ };
1254
+
1255
+ export declare type FhircastPatientOpenContext = FhircastPatientContext | FhircastEncounterContext;
1256
+
1257
+ export declare type FhircastPatientReferenceContext = {
1258
+ key: 'patient';
1259
+ reference: Reference<Patient>;
1260
+ };
1261
+
1262
+ export declare type FhircastReportContext = {
1263
+ key: 'report';
1264
+ resource: DiagnosticReport;
1265
+ };
1266
+
1267
+ export declare type FhircastReportReferenceContext = {
1268
+ key: 'report';
1269
+ reference: Reference<DiagnosticReport>;
1209
1270
  };
1210
1271
 
1272
+ export declare type FhircastResourceContext = FhircastPatientContext | FhircastEncounterContext | FhircastStudyContext | FhircastReportContext | FhircastUpdatesContext | FhircastOperationOutcomeContext;
1273
+
1211
1274
  export declare type FhircastResourceEventName = Exclude<FhircastEventName, 'syncerror'>;
1212
1275
 
1213
1276
  export declare type FhircastResourceType = (typeof FHIRCAST_RESOURCE_TYPES)[number];
1214
1277
 
1215
- export declare type FhircastSingleResourceContext<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = {
1216
- key: K;
1217
- resource: FhircastEventResource<EventName, K>;
1278
+ export declare type FhircastSelectContext = {
1279
+ key: 'select';
1280
+ reference: Reference[];
1281
+ };
1282
+
1283
+ export declare type FhircastSingleReferenceContext = FhircastReportReferenceContext | FhircastPatientReferenceContext;
1284
+
1285
+ export declare type FhircastStudyContext = {
1286
+ key: 'study';
1287
+ resource: ImagingStudy;
1218
1288
  };
1219
1289
 
1220
1290
  export declare type FhircastSubscriptionEventMap = {
@@ -1223,9 +1293,12 @@ export declare type FhircastSubscriptionEventMap = {
1223
1293
  disconnect: FhircastDisconnectEvent;
1224
1294
  };
1225
1295
 
1226
- export declare type FhircastValidContextForEvent<EventName extends FhircastEventName = FhircastEventName> = ConvertToUnion<{
1227
- [key in FhircastEventContextKey<EventName>]: FhircastEventContext<EventName, key>;
1228
- }>;
1296
+ export declare type FhircastSyncErrorContext = FhircastOperationOutcomeContext;
1297
+
1298
+ export declare type FhircastUpdatesContext = {
1299
+ key: 'updates';
1300
+ resource: Bundle;
1301
+ };
1229
1302
 
1230
1303
  /**
1231
1304
  * The FhirFilterComparison class represents a comparison expression.
@@ -3405,6 +3478,26 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3405
3478
  * @returns A Bundle of all Resources related to the Patient
3406
3479
  */
3407
3480
  readPatientEverything(id: string, options?: MedplumRequestOptions): ReadablePromise<Bundle>;
3481
+ /**
3482
+ * Executes the Patient "summary" operation for a patient.
3483
+ *
3484
+ * @example
3485
+ * Example:
3486
+ *
3487
+ * ```typescript
3488
+ * const bundle = await medplum.readPatientSummary('123');
3489
+ * console.log(bundle);
3490
+ * ```
3491
+ *
3492
+ * See International Patient Summary Implementation Guide: https://build.fhir.org/ig/HL7/fhir-ips/index.html
3493
+ *
3494
+ * See Patient summary operation: https://build.fhir.org/ig/HL7/fhir-ips/OperationDefinition-summary.html
3495
+ *
3496
+ * @param id - The Patient ID.
3497
+ * @param options - Optional fetch options.
3498
+ * @returns A patient summary bundle, organized into the patient summary sections.
3499
+ */
3500
+ readPatientSummary(id: string, options?: MedplumRequestOptions): ReadablePromise<Bundle>;
3408
3501
  /**
3409
3502
  * Creates a new FHIR resource.
3410
3503
  *
@@ -4008,6 +4101,15 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4008
4101
  * @returns The key value client.
4009
4102
  */
4010
4103
  get keyValue(): MedplumKeyValueClient;
4104
+ /**
4105
+ * Internal helper method to get a bundle from a URL.
4106
+ * In addition to returning the bundle, it also caches all of the resources in the bundle.
4107
+ * This should be used by any method that returns a bundle of resources to be cached.
4108
+ * @param url - The bundle URL.
4109
+ * @param options - Optional fetch options.
4110
+ * @returns Promise to the bundle.
4111
+ */
4112
+ private getBundle;
4011
4113
  /**
4012
4114
  * Returns the cache entry if available and not expired.
4013
4115
  * @param key - The cache key to retrieve.
@@ -13,13 +13,16 @@ import { Communication } from '@medplum/fhirtypes';
13
13
  import { ConceptMap } from '@medplum/fhirtypes';
14
14
  import type { CustomTableLayout } from 'pdfmake/interfaces';
15
15
  import { Device } from '@medplum/fhirtypes';
16
+ import { DiagnosticReport } from '@medplum/fhirtypes';
16
17
  import { ElementDefinition } from '@medplum/fhirtypes';
17
18
  import { ElementDefinitionBinding } from '@medplum/fhirtypes';
19
+ import { Encounter } from '@medplum/fhirtypes';
18
20
  import { Extension } from '@medplum/fhirtypes';
19
21
  import { ExtensionValue } from '@medplum/fhirtypes';
20
22
  import { ExtractResource } from '@medplum/fhirtypes';
21
23
  import { HumanName } from '@medplum/fhirtypes';
22
24
  import { Identifier } from '@medplum/fhirtypes';
25
+ import { ImagingStudy } from '@medplum/fhirtypes';
23
26
  import { Media } from '@medplum/fhirtypes';
24
27
  import { Money } from '@medplum/fhirtypes';
25
28
  import { Observation } from '@medplum/fhirtypes';
@@ -166,6 +169,8 @@ export declare interface AgentUpgradeResponse extends BaseAgentMessage {
166
169
 
167
170
  export declare const allOk: OperationOutcome;
168
171
 
172
+ export declare type AnchorResourceOpenEvent<T extends FhircastAnchorResourceType> = T extends FhircastAnchorResourceType ? `${T}-open` : never;
173
+
169
174
  /**
170
175
  * 6.5.1. and
171
176
  * Returns true if both operands evaluate to true,
@@ -191,8 +196,6 @@ export declare function append<T>(array: T[] | undefined, value: T): T[];
191
196
  */
192
197
  export declare function applyDefaultValuesToElement(existingValue: object, elements: Record<string, InternalSchemaElement>, key?: string): object;
193
198
 
194
- export declare function applyDefaultValuesToElementWithVisitor(existingValue: any, path: string, element: InternalSchemaElement, elements: Record<string, InternalSchemaElement>, schema: InternalTypeSchema): any;
195
-
196
199
  /**
197
200
  * Adds default values to `resource` based on the supplied `schema`. Default values includes all required fixed and pattern
198
201
  * values specified on elements in the schema. If an element has a fixed/pattern value but is optional, i.e.
@@ -562,8 +565,6 @@ export declare function convertContainedResourcesToBundle(resource: Resource & {
562
565
  */
563
566
  export declare function convertToTransactionBundle(bundle: Bundle): Bundle;
564
567
 
565
- export declare type ConvertToUnion<T> = T[keyof T];
566
-
567
568
  export declare const CPT = "http://www.ama-assn.org/go/cpt";
568
569
 
569
570
  export declare interface CrawlerOptions {
@@ -675,9 +676,9 @@ export declare const created: OperationOutcome;
675
676
  * @param versionId - The current `versionId` of the anchor context. For example, in `DiagnosticReport-update`, it's the `versionId` of the `DiagnosticReport`.
676
677
  * @returns A serializable `FhircastMessagePayload`.
677
678
  */
678
- export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionOptional>(topic: string, event: EventName, context: FhircastValidContextForEvent<EventName> | FhircastValidContextForEvent<EventName>[], versionId?: never): FhircastMessagePayload<EventName>;
679
+ export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionOptional>(topic: string, event: EventName, context: FhircastEventContext<EventName> | FhircastEventContext<EventName>[], versionId?: never): FhircastMessagePayload<EventName>;
679
680
 
680
- export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionRequired>(topic: string, event: EventName, context: FhircastValidContextForEvent<EventName> | FhircastValidContextForEvent<EventName>[], versionId: string): FhircastMessagePayload<EventName>;
681
+ export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionRequired>(topic: string, event: EventName, context: FhircastEventContext<EventName> | FhircastEventContext<EventName>[], versionId: string): FhircastMessagePayload<EventName>;
681
682
 
682
683
  export declare interface CreateMediaOptions extends CreateBinaryOptions {
683
684
  /**
@@ -723,11 +724,18 @@ export declare function createReference<T extends Resource>(resource: T): Refere
723
724
 
724
725
  export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue;
725
726
 
726
- export declare type CurrentContext<EventName extends FhircastResourceEventName = FhircastResourceEventName> = {
727
- 'context.type': ResourceType | '';
728
- 'context.versionId'?: string;
729
- context: FhircastEventContext<EventName>[];
730
- };
727
+ export declare type CurrentContext<T extends FhircastAnchorResourceType | '' = FhircastAnchorResourceType | ''> = T extends '' ? {
728
+ 'context.type': '';
729
+ context: never[];
730
+ } : T extends 'DiagnosticReport' ? {
731
+ 'context.type': 'DiagnosticReport';
732
+ 'context.versionId': string;
733
+ context: (FhircastEventContext<'DiagnosticReport-open'> | FhircastHubContentContext)[];
734
+ } : T extends 'Patient' | 'Encounter' | 'ImagingStudy' ? {
735
+ 'context.type': T;
736
+ 'context.versionId': string;
737
+ context: FhircastEventContext<AnchorResourceOpenEvent<T>>;
738
+ } : never;
731
739
 
732
740
  export declare type DataTypesMap = {
733
741
  [type: string]: InternalTypeSchema;
@@ -1094,23 +1102,28 @@ export declare const FHIRCAST_EVENT_RESOURCES: {
1094
1102
  readonly 'DiagnosticReport-select': {
1095
1103
  readonly report: {
1096
1104
  readonly resourceType: "DiagnosticReport";
1105
+ readonly reference: true;
1106
+ };
1107
+ readonly patient: {
1108
+ readonly resourceType: "Patient";
1109
+ readonly optional: true;
1110
+ readonly reference: true;
1097
1111
  };
1098
1112
  readonly select: {
1099
1113
  readonly resourceType: "*";
1100
- readonly isArray: true;
1114
+ readonly array: true;
1115
+ readonly reference: true;
1101
1116
  };
1102
1117
  };
1103
1118
  readonly 'DiagnosticReport-update': {
1104
1119
  readonly report: {
1105
1120
  readonly resourceType: "DiagnosticReport";
1121
+ readonly reference: true;
1106
1122
  };
1107
1123
  readonly patient: {
1108
1124
  readonly resourceType: "Patient";
1109
1125
  readonly optional: true;
1110
- };
1111
- readonly study: {
1112
- readonly resourceType: "ImagingStudy";
1113
- readonly optional: true;
1126
+ readonly reference: true;
1114
1127
  };
1115
1128
  readonly updates: {
1116
1129
  readonly resourceType: "Bundle";
@@ -1127,6 +1140,8 @@ export declare const FHIRCAST_EVENT_VERSION_REQUIRED: readonly ["DiagnosticRepor
1127
1140
 
1128
1141
  export declare const FHIRCAST_RESOURCE_TYPES: readonly ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
1129
1142
 
1143
+ export declare type FhircastAnchorResourceType = 'Patient' | 'ImagingStudy' | 'Encounter' | 'DiagnosticReport';
1144
+
1130
1145
  export declare type FhircastConnectEvent = {
1131
1146
  type: 'connect';
1132
1147
  };
@@ -1152,46 +1167,66 @@ export declare class FhircastConnection extends TypedEventTarget<FhircastSubscri
1152
1167
  disconnect(): void;
1153
1168
  }
1154
1169
 
1170
+ export declare type FhircastContextResourceType<EventName extends FhircastEventName, K extends FhircastEventKeys<EventName>> = (typeof FHIRCAST_EVENT_RESOURCES)[EventName][K] extends {
1171
+ resourceType: infer R;
1172
+ } ? R : never;
1173
+
1174
+ export declare type FhircastDiagnosticReportCloseContext = FhircastDiagnosticReportOpenContext;
1175
+
1176
+ export declare type FhircastDiagnosticReportOpenContext = FhircastReportContext | FhircastEncounterContext | FhircastStudyContext | FhircastPatientContext;
1177
+
1178
+ export declare type FhircastDiagnosticReportSelectContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastSelectContext;
1179
+
1180
+ export declare type FhircastDiagnosticReportUpdateContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastUpdatesContext;
1181
+
1155
1182
  export declare type FhircastDisconnectEvent = {
1156
1183
  type: 'disconnect';
1157
1184
  };
1158
1185
 
1159
- export declare type FhircastEventContext<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = FhircastEventContextMap<EventName>[K] extends infer _Ev extends FhircastEventContextDetails ? _Ev['isArray'] extends true ? FhircastMultiResourceContext<EventName, K> : FhircastSingleResourceContext<EventName, K> : never;
1186
+ export declare type FhircastEncounterCloseContext = FhircastEncounterOpenContext;
1187
+
1188
+ export declare type FhircastEncounterContext = {
1189
+ key: 'encounter';
1190
+ resource: Encounter;
1191
+ };
1192
+
1193
+ export declare type FhircastEncounterOpenContext = FhircastEncounterContext | FhircastPatientContext;
1194
+
1195
+ export declare type FhircastEventContext<EventName extends FhircastEventName = FhircastResourceEventName> = EventName extends 'Patient-open' ? FhircastPatientOpenContext : EventName extends 'Patient-close' ? FhircastPatientCloseContext : EventName extends 'ImagingStudy-open' ? FhircastImagingStudyOpenContext : EventName extends 'ImagingStudy-close' ? FhircastImagingStudyCloseContext : EventName extends 'Encounter-open' ? FhircastEncounterOpenContext : EventName extends 'Encounter-close' ? FhircastEncounterCloseContext : EventName extends 'DiagnosticReport-open' ? FhircastDiagnosticReportOpenContext : EventName extends 'DiagnosticReport-close' ? FhircastDiagnosticReportCloseContext : EventName extends 'DiagnosticReport-update' ? FhircastDiagnosticReportUpdateContext : EventName extends 'DiagnosticReport-select' ? FhircastDiagnosticReportSelectContext : EventName extends 'syncerror' ? FhircastSyncErrorContext : never;
1160
1196
 
1161
1197
  export declare type FhircastEventContextDetails = {
1162
1198
  resourceType: FhircastResourceType | '*';
1163
1199
  optional?: boolean;
1164
1200
  manyAllowed?: boolean;
1165
- isArray?: boolean;
1201
+ array?: boolean;
1202
+ reference?: boolean;
1166
1203
  };
1167
1204
 
1168
- export declare type FhircastEventContextKey<EventName extends FhircastEventName = FhircastEventName> = keyof FhircastEventContextMap<EventName>;
1169
-
1170
- export declare type FhircastEventContextMap<EventName extends FhircastEventName = FhircastEventName> = (typeof FHIRCAST_EVENT_RESOURCES)[EventName];
1205
+ export declare type FhircastEventKeys<EventName extends FhircastEventName> = keyof (typeof FHIRCAST_EVENT_RESOURCES)[EventName];
1171
1206
 
1172
1207
  export declare type FhircastEventName = keyof typeof FHIRCAST_EVENT_NAMES;
1173
1208
 
1174
- export declare type FhircastEventPayload<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = {
1209
+ export declare type FhircastEventPayload<EventName extends FhircastEventName = FhircastEventName> = {
1175
1210
  'hub.topic': string;
1176
1211
  'hub.event': EventName;
1177
- context: FhircastEventContext<EventName, K>[];
1212
+ context: FhircastEventContext<EventName>[];
1178
1213
  'context.versionId'?: string;
1179
1214
  'context.priorVersionId'?: string;
1180
1215
  };
1181
1216
 
1182
- export declare type FhircastEventResource<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = FhircastEventContextMap<EventName>[K] extends infer _Ev extends FhircastEventContextDetails ? FhircastEventResourceType<EventName, K> extends '*' ? Resource & {
1183
- id: string;
1184
- } : Resource & {
1185
- resourceType: FhircastEventResourceType<EventName, K>;
1186
- id: string;
1187
- } : never;
1188
-
1189
- export declare type FhircastEventResourceType<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = FhircastEventContextMap<EventName>[K] extends infer _Ev extends FhircastEventContextDetails ? _Ev['resourceType'] : never;
1190
-
1191
1217
  export declare type FhircastEventVersionOptional = Exclude<FhircastEventName, FhircastEventVersionRequired>;
1192
1218
 
1193
1219
  export declare type FhircastEventVersionRequired = (typeof FHIRCAST_EVENT_VERSION_REQUIRED)[number];
1194
1220
 
1221
+ export declare type FhircastHubContentContext = {
1222
+ key: 'content';
1223
+ resource: Bundle;
1224
+ };
1225
+
1226
+ export declare type FhircastImagingStudyCloseContext = FhircastImagingStudyOpenContext;
1227
+
1228
+ export declare type FhircastImagingStudyOpenContext = FhircastStudyContext | FhircastEncounterContext | FhircastPatientContext;
1229
+
1195
1230
  export declare type FhircastMessageEvent = {
1196
1231
  type: 'message';
1197
1232
  payload: FhircastMessagePayload;
@@ -1203,18 +1238,53 @@ export declare type FhircastMessagePayload<EventName extends FhircastEventName =
1203
1238
  event: FhircastEventPayload<EventName>;
1204
1239
  };
1205
1240
 
1206
- export declare type FhircastMultiResourceContext<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = {
1207
- key: K;
1208
- resources: FhircastEventResource<EventName, K>[];
1241
+ export declare type FhircastMultiReferenceContext = FhircastSelectContext;
1242
+
1243
+ export declare type FhircastOperationOutcomeContext = {
1244
+ key: 'operationoutcome';
1245
+ resource: OperationOutcome;
1246
+ };
1247
+
1248
+ export declare type FhircastPatientCloseContext = FhircastPatientOpenContext;
1249
+
1250
+ export declare type FhircastPatientContext = {
1251
+ key: 'patient';
1252
+ resource: Patient;
1253
+ };
1254
+
1255
+ export declare type FhircastPatientOpenContext = FhircastPatientContext | FhircastEncounterContext;
1256
+
1257
+ export declare type FhircastPatientReferenceContext = {
1258
+ key: 'patient';
1259
+ reference: Reference<Patient>;
1260
+ };
1261
+
1262
+ export declare type FhircastReportContext = {
1263
+ key: 'report';
1264
+ resource: DiagnosticReport;
1265
+ };
1266
+
1267
+ export declare type FhircastReportReferenceContext = {
1268
+ key: 'report';
1269
+ reference: Reference<DiagnosticReport>;
1209
1270
  };
1210
1271
 
1272
+ export declare type FhircastResourceContext = FhircastPatientContext | FhircastEncounterContext | FhircastStudyContext | FhircastReportContext | FhircastUpdatesContext | FhircastOperationOutcomeContext;
1273
+
1211
1274
  export declare type FhircastResourceEventName = Exclude<FhircastEventName, 'syncerror'>;
1212
1275
 
1213
1276
  export declare type FhircastResourceType = (typeof FHIRCAST_RESOURCE_TYPES)[number];
1214
1277
 
1215
- export declare type FhircastSingleResourceContext<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = {
1216
- key: K;
1217
- resource: FhircastEventResource<EventName, K>;
1278
+ export declare type FhircastSelectContext = {
1279
+ key: 'select';
1280
+ reference: Reference[];
1281
+ };
1282
+
1283
+ export declare type FhircastSingleReferenceContext = FhircastReportReferenceContext | FhircastPatientReferenceContext;
1284
+
1285
+ export declare type FhircastStudyContext = {
1286
+ key: 'study';
1287
+ resource: ImagingStudy;
1218
1288
  };
1219
1289
 
1220
1290
  export declare type FhircastSubscriptionEventMap = {
@@ -1223,9 +1293,12 @@ export declare type FhircastSubscriptionEventMap = {
1223
1293
  disconnect: FhircastDisconnectEvent;
1224
1294
  };
1225
1295
 
1226
- export declare type FhircastValidContextForEvent<EventName extends FhircastEventName = FhircastEventName> = ConvertToUnion<{
1227
- [key in FhircastEventContextKey<EventName>]: FhircastEventContext<EventName, key>;
1228
- }>;
1296
+ export declare type FhircastSyncErrorContext = FhircastOperationOutcomeContext;
1297
+
1298
+ export declare type FhircastUpdatesContext = {
1299
+ key: 'updates';
1300
+ resource: Bundle;
1301
+ };
1229
1302
 
1230
1303
  /**
1231
1304
  * The FhirFilterComparison class represents a comparison expression.
@@ -3405,6 +3478,26 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3405
3478
  * @returns A Bundle of all Resources related to the Patient
3406
3479
  */
3407
3480
  readPatientEverything(id: string, options?: MedplumRequestOptions): ReadablePromise<Bundle>;
3481
+ /**
3482
+ * Executes the Patient "summary" operation for a patient.
3483
+ *
3484
+ * @example
3485
+ * Example:
3486
+ *
3487
+ * ```typescript
3488
+ * const bundle = await medplum.readPatientSummary('123');
3489
+ * console.log(bundle);
3490
+ * ```
3491
+ *
3492
+ * See International Patient Summary Implementation Guide: https://build.fhir.org/ig/HL7/fhir-ips/index.html
3493
+ *
3494
+ * See Patient summary operation: https://build.fhir.org/ig/HL7/fhir-ips/OperationDefinition-summary.html
3495
+ *
3496
+ * @param id - The Patient ID.
3497
+ * @param options - Optional fetch options.
3498
+ * @returns A patient summary bundle, organized into the patient summary sections.
3499
+ */
3500
+ readPatientSummary(id: string, options?: MedplumRequestOptions): ReadablePromise<Bundle>;
3408
3501
  /**
3409
3502
  * Creates a new FHIR resource.
3410
3503
  *
@@ -4008,6 +4101,15 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4008
4101
  * @returns The key value client.
4009
4102
  */
4010
4103
  get keyValue(): MedplumKeyValueClient;
4104
+ /**
4105
+ * Internal helper method to get a bundle from a URL.
4106
+ * In addition to returning the bundle, it also caches all of the resources in the bundle.
4107
+ * This should be used by any method that returns a bundle of resources to be cached.
4108
+ * @param url - The bundle URL.
4109
+ * @param options - Optional fetch options.
4110
+ * @returns Promise to the bundle.
4111
+ */
4112
+ private getBundle;
4011
4113
  /**
4012
4114
  * Returns the cache entry if available and not expired.
4013
4115
  * @param key - The cache key to retrieve.