@medplum/core 5.0.7 → 5.0.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.
@@ -3869,6 +3869,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3869
3869
  * @returns The resource if available.
3870
3870
  */
3871
3871
  readReference<T extends Resource>(reference: Reference<T>, options?: MedplumRequestOptions): ReadablePromise<WithId<T>>;
3872
+ readCanonical<RT extends ResourceType>(resourceType: RT | RT[], url: string, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>> | undefined>;
3872
3873
  /**
3873
3874
  * Requests the schema for a resource type.
3874
3875
  * If the schema is already cached, the promise is resolved immediately.
@@ -6298,6 +6299,30 @@ export declare class ParserBuilder {
6298
6299
  */
6299
6300
  export declare function reorderBundle(bundle: Bundle): Bundle;
6300
6301
 
6302
+ /**
6303
+ * Replaces prefetch query variables with values from the context or user profile.
6304
+ *
6305
+ * A prefetch token is a placeholder in a prefetch template that is *replaced by information from the hook's context*
6306
+ * to construct the FHIR URL used to request the prefetch data.
6307
+ *
6308
+ * Prefetch tokens MUST be delimited by `{{` and `}}`, and MUST contain only the qualified path to a hook context field
6309
+ * or one of the following user identifiers: `userPractitionerId`, `userPractitionerRoleId`, `userPatientId`, or `userRelatedPersonId`.
6310
+ *
6311
+ * Note that the spec says:
6312
+ *
6313
+ * > Individual hooks specify which of their `context` fields can be used as prefetch tokens.
6314
+ * > Only root-level fields with a primitive value within the `context` object are eligible to be used as prefetch tokens.
6315
+ * > For example, `{{context.medication.id}}` is not a valid prefetch token because it attempts to access the `id` field of the `medication` field.
6316
+ *
6317
+ * Unfortunately, many CDS Hooks services do not follow this rule. Therefore, this implementation allows access to nested fields.
6318
+ *
6319
+ * @param user - The user resource.
6320
+ * @param context - The CDS request context.
6321
+ * @param query - The prefetch query template.
6322
+ * @returns The prefetch query with variables replaced.
6323
+ */
6324
+ export declare function replaceQueryVariables(user: CdsUserResource, context: Record<string, unknown>, query: string): string;
6325
+
6301
6326
  export declare interface RequestProfileSchemaOptions {
6302
6327
  /** (optional) Whether to include nested profiles, e.g. from extensions. Defaults to false. */
6303
6328
  expandProfile?: boolean;
@@ -3869,6 +3869,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3869
3869
  * @returns The resource if available.
3870
3870
  */
3871
3871
  readReference<T extends Resource>(reference: Reference<T>, options?: MedplumRequestOptions): ReadablePromise<WithId<T>>;
3872
+ readCanonical<RT extends ResourceType>(resourceType: RT | RT[], url: string, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>> | undefined>;
3872
3873
  /**
3873
3874
  * Requests the schema for a resource type.
3874
3875
  * If the schema is already cached, the promise is resolved immediately.
@@ -6298,6 +6299,30 @@ export declare class ParserBuilder {
6298
6299
  */
6299
6300
  export declare function reorderBundle(bundle: Bundle): Bundle;
6300
6301
 
6302
+ /**
6303
+ * Replaces prefetch query variables with values from the context or user profile.
6304
+ *
6305
+ * A prefetch token is a placeholder in a prefetch template that is *replaced by information from the hook's context*
6306
+ * to construct the FHIR URL used to request the prefetch data.
6307
+ *
6308
+ * Prefetch tokens MUST be delimited by `{{` and `}}`, and MUST contain only the qualified path to a hook context field
6309
+ * or one of the following user identifiers: `userPractitionerId`, `userPractitionerRoleId`, `userPatientId`, or `userRelatedPersonId`.
6310
+ *
6311
+ * Note that the spec says:
6312
+ *
6313
+ * > Individual hooks specify which of their `context` fields can be used as prefetch tokens.
6314
+ * > Only root-level fields with a primitive value within the `context` object are eligible to be used as prefetch tokens.
6315
+ * > For example, `{{context.medication.id}}` is not a valid prefetch token because it attempts to access the `id` field of the `medication` field.
6316
+ *
6317
+ * Unfortunately, many CDS Hooks services do not follow this rule. Therefore, this implementation allows access to nested fields.
6318
+ *
6319
+ * @param user - The user resource.
6320
+ * @param context - The CDS request context.
6321
+ * @param query - The prefetch query template.
6322
+ * @returns The prefetch query with variables replaced.
6323
+ */
6324
+ export declare function replaceQueryVariables(user: CdsUserResource, context: Record<string, unknown>, query: string): string;
6325
+
6301
6326
  export declare interface RequestProfileSchemaOptions {
6302
6327
  /** (optional) Whether to include nested profiles, e.g. from extensions. Defaults to false. */
6303
6328
  expandProfile?: boolean;