@medplum/core 5.1.22 → 5.1.24

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.
@@ -115,6 +115,21 @@ export declare const AckCode: {
115
115
 
116
116
  export declare type AckCode = keyof typeof AckCode;
117
117
 
118
+ /**
119
+ * o If the target location specifies an array index, a new value is
120
+ * inserted into the array at the specified index.
121
+ * o If the target location specifies an object member that does not
122
+ * already exist, a new member is added to the object.
123
+ * o If the target location specifies an object member that does exist,
124
+ * that member's value is replaced.
125
+ *
126
+ * @param object - The object being patched.
127
+ * @param operation - The operation to perform on the object.
128
+ * @param options - Optional params.
129
+ * @returns null on success, or error if one occurred.
130
+ */
131
+ export declare function add(object: any, operation: AddOperation, options?: PatchOptions): MissingError | null;
132
+
118
133
  /**
119
134
  * Parameters for adding a pharmacy to a patient's favorites.
120
135
  */
@@ -124,6 +139,12 @@ export declare interface AddFavoriteParams {
124
139
  setAsPrimary: boolean;
125
140
  }
126
141
 
142
+ export declare interface AddOperation {
143
+ op: 'add';
144
+ path: string;
145
+ value: any;
146
+ }
147
+
127
148
  /**
128
149
  * Response from adding a pharmacy to a patient's favorites.
129
150
  */
@@ -192,12 +213,26 @@ export declare interface AgentHeartbeatResponse extends BaseAgentMessage {
192
213
  export declare interface AgentLogsRequest extends BaseAgentRequestMessage {
193
214
  type: 'agent:logs:request';
194
215
  limit?: number;
216
+ /**
217
+ * Opaque pagination cursor. Pass the `nextBefore` value from a previous
218
+ * response to fetch the next (older) page; treat it as an opaque token rather
219
+ * than parsing it. Logs are read across all rotated log files, not just the
220
+ * most recent one.
221
+ */
222
+ before?: string;
195
223
  }
196
224
 
197
225
  export declare interface AgentLogsResponse extends BaseAgentMessage {
198
226
  type: 'agent:logs:response';
199
227
  statusCode: number;
200
228
  logs: LogMessage[];
229
+ /** Whether more (older) log entries exist beyond the ones returned in this page. */
230
+ hasMore: boolean;
231
+ /**
232
+ * Opaque cursor to pass as `before` in a subsequent request to fetch the next
233
+ * older page. Only present when `hasMore` is true.
234
+ */
235
+ nextBefore?: string;
201
236
  }
202
237
 
203
238
  export declare type AgentMessage = AgentRequestMessage | AgentResponseMessage;
@@ -303,6 +338,17 @@ export declare class AndAtom extends InfixOperatorAtom {
303
338
 
304
339
  export declare function append<T>(array: T[] | undefined, value: T): T[];
305
340
 
341
+ /**
342
+ * Switch on `operation.op`, applying the corresponding patch function for each
343
+ * case to `object`.
344
+ *
345
+ * @param object - The object being patched.
346
+ * @param operation - The operation to perform on the object.
347
+ * @param options - Optional params.
348
+ * @returns null on success, or error if one occurred.
349
+ */
350
+ export declare function apply(object: any, operation: Operation, options?: PatchOptions): MissingError | InvalidOperationError | TestError | null;
351
+
306
352
  /**
307
353
  * Adds default values to `existingValue` for the given `key` and its children. If `key` is undefined,
308
354
  * default values are added to all elements in `elements`. Default values consist of all fixed and pattern
@@ -328,6 +374,26 @@ export declare function applyDefaultValuesToResource(resource: Resource, schema:
328
374
 
329
375
  export declare function applyFixedOrPatternValue(inputValue: any, key: string, element: InternalSchemaElement, elements: Record<string, InternalSchemaElement>): any;
330
376
 
377
+ /**
378
+ * Apply a 'application/json-patch+json'-type patch to an object.
379
+ *
380
+ * `patch` *must* be an array of operations.
381
+ *
382
+ * Operation objects MUST have exactly one "op" member, whose value
383
+ * indicates the operation to perform. Its value MUST be one of "add",
384
+ * "remove", "replace", "move", "copy", or "test"; other values are
385
+ * errors.
386
+ *
387
+ * This method mutates the target object in-place.
388
+ *
389
+ * @param object - The object to apply the patch to
390
+ * @param patch - Array of operations to apply
391
+ * @param options - Optional customization of patch application behavior
392
+ * @returns list of results, one for each operation: `null` indicated success,
393
+ * otherwise, the result will be an instance of one of the Error classes.
394
+ */
395
+ export declare function applyPatch(object: any, patch: Operation[], options?: PatchOptions): (null | MissingError | InvalidOperationError | TestError)[];
396
+
331
397
  export declare class ArithmeticOperatorAtom extends InfixOperatorAtom {
332
398
  readonly impl: (x: number, y: number) => number | boolean;
333
399
  constructor(operator: string, left: Atom, right: Atom, impl: (x: number, y: number) => number | boolean);
@@ -882,6 +948,7 @@ export declare const ContentType: {
882
948
  readonly HL7_V2: "x-application/hl7-v2+er7";
883
949
  readonly HTML: "text/html";
884
950
  readonly JAVASCRIPT: "text/javascript";
951
+ readonly JOSE: "application/jose";
885
952
  readonly JSON: "application/json";
886
953
  readonly JSON_PATCH: "application/json-patch+json";
887
954
  readonly JWT: "application/jwt";
@@ -933,6 +1000,32 @@ export declare function convertToSearchableUris(typedValues: TypedValue[]): stri
933
1000
  */
934
1001
  export declare function convertToTransactionBundle(bundle: Bundle): Bundle;
935
1002
 
1003
+ /**
1004
+ * The "copy" operation copies the value at a specified location to the
1005
+ * target location.
1006
+ * The operation object MUST contain a "from" member, which is a string
1007
+ * containing a JSON Pointer value that references the location in the
1008
+ * target document to copy the value from.
1009
+ * The "from" location MUST exist for the operation to be successful.
1010
+ *
1011
+ * This operation is functionally identical to an "add" operation at the
1012
+ * target location using the value specified in the "from" member.
1013
+ *
1014
+ * Alternatively, it's like 'move' without the 'remove'.
1015
+ *
1016
+ * @param object - The object being patched.
1017
+ * @param operation - The operation to perform on the object.
1018
+ * @param _options - Optional params.
1019
+ * @returns null on success, or error if one occurred.
1020
+ */
1021
+ export declare function copy(object: any, operation: CopyOperation, _options?: PatchOptions): MissingError | null;
1022
+
1023
+ export declare interface CopyOperation {
1024
+ op: 'copy';
1025
+ from: string;
1026
+ path: string;
1027
+ }
1028
+
936
1029
  export declare const CPT = "http://www.ama-assn.org/go/cpt";
937
1030
 
938
1031
  export declare interface CrawlerOptions {
@@ -1023,6 +1116,26 @@ export declare interface CreateMediaOptions extends CreateBinaryOptions {
1023
1116
 
1024
1117
  export declare function createOperationOutcomeIssue(severity: IssueSeverity, code: IssueType, message: string, path: string, data?: Record<string, any>): OperationOutcomeIssue;
1025
1118
 
1119
+ /**
1120
+ * Produce a 'application/json-patch+json'-type patch to get from one object to
1121
+ * another.
1122
+ *
1123
+ * This does not alter `input` or `output` unless they have a property getter with
1124
+ * side-effects (which is not a good idea anyway).
1125
+ *
1126
+ * `diff` is called on each pair of comparable non-primitive nodes in the
1127
+ * `input`/`output` object trees, producing nested patches. Return `undefined`
1128
+ * to fall back to default behaviour.
1129
+ *
1130
+ * Returns list of operations to perform on `input` to produce `output`.
1131
+ *
1132
+ * @param input - The input value.
1133
+ * @param output - The target value.
1134
+ * @param diff - Optional diff function.
1135
+ * @returns The list of patch operations.
1136
+ */
1137
+ export declare function createPatch(input: any, output: any, diff?: VoidableDiff): Operation[];
1138
+
1026
1139
  export declare interface CreatePdfFunction {
1027
1140
  (docDefinition: TDocumentDefinitions, tableLayouts?: Record<string, CustomTableLayout>, fonts?: TFontDictionary): Promise<any>;
1028
1141
  }
@@ -1069,6 +1182,22 @@ export declare function createReference<T extends Resource>(resource: T): Refere
1069
1182
 
1070
1183
  export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue;
1071
1184
 
1185
+ /**
1186
+ * Produce an 'application/json-patch+json'-type list of tests, to verify that
1187
+ * existing values in an object are identical to the those captured at some
1188
+ * checkpoint (whenever this function is called).
1189
+ *
1190
+ * This does not alter `input` or `output` unless they have a property getter with
1191
+ * side-effects (which is not a good idea anyway).
1192
+ *
1193
+ * Returns list of test operations.
1194
+ *
1195
+ * @param input - The input value.
1196
+ * @param patch - The list of patch operations.
1197
+ * @returns A list of test operations corresponding to the current values.
1198
+ */
1199
+ export declare function createTests(input: any, patch: Operation[]): TestOperation[];
1200
+
1072
1201
  export declare type CriteriaState = 'idle' | 'connecting' | 'active' | 'refreshing' | 'removed';
1073
1202
 
1074
1203
  export declare type CurrentContext<T extends FhircastAnchorResourceType | '' = FhircastAnchorResourceType | ''> = T extends '' ? {
@@ -1183,6 +1312,75 @@ export declare const DEFAULT_SEARCH_COUNT = 20;
1183
1312
  */
1184
1313
  export declare function deriveIdentifierSearchParameter(inputParam: SearchParameter): SearchParameter;
1185
1314
 
1315
+ export declare type Diff = (input: any, output: any, ptr: Pointer) => Operation[];
1316
+
1317
+ /**
1318
+ * `diffAny()` returns an empty array if `input` and `output` are materially equal
1319
+ * (i.e., would produce equivalent JSON); otherwise it produces an array of patches
1320
+ * that would transform `input` into `output`.
1321
+ *
1322
+ * Here, "equal" means that the value at the target location and the
1323
+ * value conveyed by "value" are of the same JSON type, and that they
1324
+ * are considered equal by the following rules for that type:
1325
+ * o strings: are considered equal if they contain the same number of
1326
+ * Unicode characters and their code points are byte-by-byte equal.
1327
+ * o numbers: are considered equal if their values are numerically
1328
+ * equal.
1329
+ * o arrays: are considered equal if they contain the same number of
1330
+ * values, and if each value can be considered equal to the value at
1331
+ * the corresponding position in the other array, using this list of
1332
+ * type-specific rules.
1333
+ * o objects: are considered equal if they contain the same number of
1334
+ * members, and if each member can be considered equal to a member in
1335
+ * the other object, by comparing their keys (as strings) and their
1336
+ * values (using this list of type-specific rules).
1337
+ * o literals (false, true, and null): are considered equal if they are
1338
+ * the same.
1339
+ *
1340
+ * @param input - The original value.
1341
+ * @param output - The target value.
1342
+ * @param ptr - JSON Pointer.
1343
+ * @param diff - Diff function.
1344
+ * @returns The list of operations to get form the original to target value.
1345
+ */
1346
+ export declare function diffAny(input: any, output: any, ptr: Pointer, diff?: Diff): Operation[];
1347
+
1348
+ /**
1349
+ * Calculate the shortest sequence of operations to get from `input` to `output`,
1350
+ * using a dynamic programming implementation of the Levenshtein distance algorithm.
1351
+ *
1352
+ * To get from the input ABC to the output AZ we could just delete all the input
1353
+ * and say "insert A, insert Z" and be done with it. That's what we do if the
1354
+ * input is empty. But we can be smarter.
1355
+ *
1356
+ * output
1357
+ * A Z
1358
+ * - -
1359
+ * [0] 1 2
1360
+ * input A | 1 [0] 1
1361
+ * B | 2 [1] 1
1362
+ * C | 3 2 [2]
1363
+ *
1364
+ * 1) start at 0,0 (+0)
1365
+ * 2) keep A (+0)
1366
+ * 3) remove B (+1)
1367
+ * 4) replace C with Z (+1)
1368
+ *
1369
+ * If the `input` (source) is empty, they'll all be in the top row, resulting in an
1370
+ * array of 'add' operations.
1371
+ * If the `output` (target) is empty, everything will be in the left column,
1372
+ * resulting in an array of 'remove' operations.
1373
+ *
1374
+ * @param input - The original array.
1375
+ * @param output - The target array.
1376
+ * @param ptr - JSON Pointer.
1377
+ * @param diff - Diff function.
1378
+ * @returns A list of add/remove/replace operations.
1379
+ */
1380
+ export declare function diffArrays<T>(input: T[], output: T[], ptr: Pointer, diff?: Diff): Operation[];
1381
+
1382
+ export declare function diffObjects(input: any, output: any, ptr: Pointer, diff?: Diff): Operation[];
1383
+
1186
1384
  export declare class DotAtom extends InfixOperatorAtom {
1187
1385
  constructor(left: Atom, right: Atom);
1188
1386
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
@@ -1270,6 +1468,8 @@ export declare function encodeBase64(data: string): string;
1270
1468
  */
1271
1469
  export declare function encodeBase64Url(data: string): string;
1272
1470
 
1471
+ export declare function encodeSmartHealthLink(payload: SmartHealthLinkPayload): string;
1472
+
1273
1473
  /**
1274
1474
  * Encrypts a string with SHA256 encryption.
1275
1475
  * @param str - The unencrypted input string.
@@ -1314,13 +1514,29 @@ export { ErrorEvent_2 as ErrorEvent }
1314
1514
  */
1315
1515
  export declare function escapeHtml(unsafe: string): string;
1316
1516
 
1517
+ /**
1518
+ * Escape token part of a JSON Pointer string
1519
+ *
1520
+ * '~' needs to be encoded as '~0' and '/'
1521
+ * needs to be encoded as '~1' when these characters appear in a
1522
+ * reference token.
1523
+ *
1524
+ * This is the exact inverse of `unescapeToken()`, so the reverse replacements must take place in reverse order.
1525
+ *
1526
+ * @param token - The token to escape.
1527
+ * @returns The escaped token.
1528
+ */
1529
+ export declare function escapeToken(token: string): string;
1530
+
1317
1531
  /**
1318
1532
  * Evaluates a FHIRPath expression against a resource or other object.
1319
1533
  * @param expression - The FHIRPath expression to evaluate.
1320
1534
  * @param input - The resource or object to evaluate the expression against.
1535
+ * @param variables - A map of variables for eval input.
1536
+ * @param cache - Cache for parsed ASTs.
1321
1537
  * @returns The result of the FHIRPath expression against the resource or object.
1322
1538
  */
1323
- export declare function evalFhirPath(expression: string | FhirPathAtom, input: unknown): unknown[];
1539
+ export declare function evalFhirPath(expression: string | FhirPathAtom, input: unknown, variables?: Record<string, TypedValue>, cache?: LRUCache<FhirPathAtom> | undefined): unknown[];
1324
1540
 
1325
1541
  /**
1326
1542
  * Evaluates a FHIRPath expression against a resource or other object.
@@ -2107,6 +2323,15 @@ export declare class FunctionAtom implements Atom {
2107
2323
  */
2108
2324
  export declare function generateId(): string;
2109
2325
 
2326
+ export declare interface GenerateSmartHealthLinkParams {
2327
+ mode?: SmartHealthLinkMode;
2328
+ _type?: string;
2329
+ exp?: number;
2330
+ label?: string;
2331
+ passcode?: string;
2332
+ includeQrCode?: boolean;
2333
+ }
2334
+
2110
2335
  export declare function getAllDataTypes(): DataTypesMap;
2111
2336
 
2112
2337
  /**
@@ -2360,6 +2585,8 @@ export declare function getSearchParameterDetails(resourceType: string, searchPa
2360
2585
  */
2361
2586
  export declare function getSearchParameters(resourceType: string): Record<string, SearchParameter> | undefined;
2362
2587
 
2588
+ export declare function getSmartHealthLinkId(manifestUrl: string): string | undefined;
2589
+
2363
2590
  export declare function getStatus(outcome: OperationOutcome): number;
2364
2591
 
2365
2592
  /**
@@ -2973,6 +3200,18 @@ export declare interface InternalTypeSchema {
2973
3200
  mandatoryProperties?: Set<string>;
2974
3201
  }
2975
3202
 
3203
+ /**
3204
+ * List the keys that shared by all `objects`.
3205
+ *
3206
+ * The semantics of what constitutes a "key" is described in {@link subtract}.
3207
+ *
3208
+ * @param objects - Array of objects to compare
3209
+ * @returns Array of keys that are in ("own-properties" of) every object in `objects`.
3210
+ */
3211
+ export declare function intersection(objects: ArrayLike<{
3212
+ [index: string]: any;
3213
+ }>): string[];
3214
+
2976
3215
  /**
2977
3216
  * Stable error when a bot response does not match {@link MedicationOrderResponse}.
2978
3217
  */
@@ -2988,6 +3227,11 @@ export declare const INVALID_MEDICATION_ORDER_SET_RESPONSE = "Invalid response f
2988
3227
  */
2989
3228
  export declare const INVALID_MEDICATION_SEARCH_RESPONSE = "Invalid response from medication search bot";
2990
3229
 
3230
+ export declare class InvalidOperationError extends Error {
3231
+ operation: Operation;
3232
+ constructor(operation: Operation);
3233
+ }
3234
+
2991
3235
  export declare function invalidSearchOperator(operator: Operator, searchParameterCodeOrId: string): OperationOutcome;
2992
3236
 
2993
3237
  export declare interface InviteRequest {
@@ -2996,6 +3240,12 @@ export declare interface InviteRequest {
2996
3240
  lastName: string;
2997
3241
  email?: string;
2998
3242
  externalId?: string;
3243
+ /**
3244
+ * The patient that a newly provisioned `RelatedPerson` is related to.
3245
+ * Required when inviting a `RelatedPerson` without an existing
3246
+ * `membership.profile`, since `RelatedPerson.patient` is a required FHIR field.
3247
+ */
3248
+ patient?: Reference<Patient>;
2999
3249
  scope?: 'project' | 'server';
3000
3250
  password?: string;
3001
3251
  sendEmail?: boolean;
@@ -3106,6 +3356,8 @@ export declare function isDateTimeString(input: unknown): input is string;
3106
3356
  */
3107
3357
  export declare function isDefined<T>(value: T | undefined | null): value is T;
3108
3358
 
3359
+ export declare function isDestructive({ op }: Operation): boolean;
3360
+
3109
3361
  /**
3110
3362
  * Returns true if the value is empty (null, undefined, empty string, or empty object).
3111
3363
  * @param v - Any value.
@@ -3535,6 +3787,12 @@ export declare interface LoginAuthenticationResponse {
3535
3787
  readonly mfaEnrollRequired?: boolean;
3536
3788
  readonly mfaRequired?: boolean;
3537
3789
  readonly enrollQrCode?: string;
3790
+ /** MFA enrollment methods the project allows (e.g. 'totp', 'email'). */
3791
+ readonly allowedMfaMethods?: ('totp' | 'email')[];
3792
+ /** MFA methods the user is enrolled in, returned when an MFA challenge is required. */
3793
+ readonly mfaMethods?: ('totp' | 'email')[];
3794
+ /** The user's email address, returned with an MFA challenge so the UI can show where a magic link was sent. */
3795
+ readonly email?: string;
3538
3796
  readonly code?: string;
3539
3797
  readonly memberships?: ProjectMembership[];
3540
3798
  }
@@ -5332,11 +5590,17 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
5332
5590
  */
5333
5591
  private setRequestBody;
5334
5592
  /**
5335
- * Handles an unauthenticated response from the server.
5336
- * First, tries to refresh the access token and retry the request.
5337
- * Otherwise, calls unauthenticated callbacks and rejects.
5593
+ * Handles an unauthenticated (HTTP 401) response from the server.
5594
+ *
5595
+ * Bounded and terminal: at most {@link MAX_AUTH_ATTEMPTS} attempts per request (1 initial
5596
+ * + 1 recovery, tracked via {@link RequestState.authAttempt}). The recovery re-mints via a
5597
+ * forced {@link MedplumClient.refresh} (bypassing the {@link MedplumClient.isAuthenticated}
5598
+ * short-circuit on the rejected token), single-flight so concurrent 401s share one re-mint.
5599
+ * A second 401 is terminal: clear auth, `onUnauthenticated`, reject — never recurse.
5600
+ *
5338
5601
  * @param url - The URL of the original request.
5339
5602
  * @param options - Optional fetch request init options.
5603
+ * @param state - The request state carrying the per-request attempt count.
5340
5604
  * @returns The result of the retry.
5341
5605
  */
5342
5606
  private handleUnauthenticated;
@@ -5383,6 +5647,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
5383
5647
  * has already refreshed.
5384
5648
  *
5385
5649
  * @param gracePeriod - Optional grace period in milliseconds threaded through to the post-lock authentication check.
5650
+ * @param force - When true, re-mint even if the current token still looks locally valid — used by the 401 recovery path, where the server has rejected a token that has not locally expired. A newer token already in storage (e.g. from a peer tab) is still preferred over a fresh mint.
5386
5651
  * @returns The refresh promise if available; otherwise undefined.
5387
5652
  * @see https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens
5388
5653
  */
@@ -5392,6 +5657,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
5392
5657
  * Tabs that wait on the lock check storage on acquisition and skip the network call
5393
5658
  * if a peer tab has already produced a fresh access token.
5394
5659
  * @param gracePeriod - Optional grace period in milliseconds used by the post-lock authentication check to decide whether the current token still has enough life left to skip the network refresh.
5660
+ * @param force - When true, bypass the post-lock expiry short-circuit for the current token (still preferring a newer token a peer tab produced).
5395
5661
  * @returns Promise that resolves when the refresh (or short-circuit) is complete.
5396
5662
  */
5397
5663
  private runRefreshWithLock;
@@ -6382,6 +6648,11 @@ export declare class MemoryStorage implements Storage {
6382
6648
 
6383
6649
  export declare type Message = string | ArrayBuffer | Blob | ArrayBufferView;
6384
6650
 
6651
+ export declare class MissingError extends Error {
6652
+ path: string;
6653
+ constructor(path: string);
6654
+ }
6655
+
6385
6656
  /**
6386
6657
  * The MockAsyncClientStorage class is a mock implementation of the ClientStorage class.
6387
6658
  * This can be used for testing async initialization of the MedplumClient.
@@ -6396,6 +6667,34 @@ export declare class MockAsyncClientStorage extends ClientStorage implements ICl
6396
6667
  get isInitialized(): boolean;
6397
6668
  }
6398
6669
 
6670
+ /**
6671
+ * The "move" operation removes the value at a specified location and
6672
+ * adds it to the target location.
6673
+ * The operation object MUST contain a "from" member, which is a string
6674
+ * containing a JSON Pointer value that references the location in the
6675
+ * target document to move the value from.
6676
+ * This operation is functionally identical to a "remove" operation on
6677
+ * the "from" location, followed immediately by an "add" operation at
6678
+ * the target location with the value that was just removed.
6679
+ *
6680
+ * The "from" location MUST NOT be a proper prefix of the "path"
6681
+ * location; i.e., a location cannot be moved into one of its children.
6682
+ *
6683
+ * TODO: throw if the check described in the previous paragraph fails.
6684
+ *
6685
+ * @param object - The object being patched.
6686
+ * @param operation - The operation to perform on the object.
6687
+ * @param _options - Optional params.
6688
+ * @returns null on success, or error if one occurred.
6689
+ */
6690
+ export declare function move(object: any, operation: MoveOperation, _options?: PatchOptions): MissingError | null;
6691
+
6692
+ export declare interface MoveOperation {
6693
+ op: 'move';
6694
+ from: string;
6695
+ path: string;
6696
+ }
6697
+
6399
6698
  export declare const multipleMatches: OperationOutcome;
6400
6699
 
6401
6700
  export declare const NDC = "http://hl7.org/fhir/sid/ndc";
@@ -6562,6 +6861,8 @@ export declare const OAuthTokenType: {
6562
6861
 
6563
6862
  export declare type OAuthTokenType = (typeof OAuthTokenType)[keyof typeof OAuthTokenType];
6564
6863
 
6864
+ export declare type Operation = AddOperation | RemoveOperation | ReplaceOperation | MoveOperation | CopyOperation | TestOperation;
6865
+
6565
6866
  export declare class OperationOutcomeError extends Error {
6566
6867
  readonly outcome: OperationOutcome;
6567
6868
  constructor(outcome: OperationOutcome, options?: ErrorOptions);
@@ -6797,6 +7098,8 @@ export declare class ParserBuilder {
6797
7098
  */
6798
7099
  export declare function parseSearchRequest<T extends Resource = Resource>(url: URL | string, query?: Record<string, string[] | string | undefined>): SearchRequest<T>;
6799
7100
 
7101
+ export declare function parseSmartHealthLink(input: string): SmartHealthLinkPayload;
7102
+
6800
7103
  /**
6801
7104
  * Parses a StructureDefinition resource into an internal schema better suited for
6802
7105
  * programmatic validation and usage in internal systems
@@ -6826,6 +7129,8 @@ export declare class ParserBuilder {
6826
7129
  */
6827
7130
  export declare function parseXFhirQuery(query: string, variables: Record<string, TypedValue>, context?: TypedValue[]): SearchRequest;
6828
7131
 
7132
+ export declare type Patch = Operation[];
7133
+
6829
7134
  /**
6830
7135
  * JSONPatch patch operation.
6831
7136
  * Compatible with fast-json-patch and rfc6902 Operation.
@@ -6836,6 +7141,25 @@ export declare class ParserBuilder {
6836
7141
  readonly value?: any;
6837
7142
  }
6838
7143
 
7144
+ export declare interface PatchOptions {
7145
+ /**
7146
+ * When true, "add" operations with path ending in "/-" will implicitly
7147
+ * create an empty array where possible.
7148
+ *
7149
+ * For example, with this option enabled, for the object `{live: true}`,
7150
+ * the operation `add "/tag/-" 123` will result in `{live: true, tag: [123]}`.
7151
+ * Subsequent operations behave normally: another `add "/tag/-" 456` will result
7152
+ * in `{live: true, tag: [123, 456]}`.
7153
+ *
7154
+ * If the indicated array property already exists but is not an array, this will
7155
+ * produce an error.
7156
+ *
7157
+ * Only the leaf array will be inferred; missing parent objects will still
7158
+ * produce errors.
7159
+ */
7160
+ implicitArrayCreation?: boolean;
7161
+ }
7162
+
6839
7163
  /**
6840
7164
  * Translates a path emitted by this crawler into an RFC6902 JSON Patch pointer
6841
7165
  *
@@ -6871,6 +7195,52 @@ export declare class ParserBuilder {
6871
7195
  ncpdpID?: string;
6872
7196
  }
6873
7197
 
7198
+ /**
7199
+ * JSON Pointer representation
7200
+ */
7201
+ export declare class Pointer {
7202
+ tokens: string[];
7203
+ constructor(tokens?: string[]);
7204
+ /**
7205
+ * @param path - The JSON path: *must* be a properly escaped string.
7206
+ * @returns The JSON pointer object.
7207
+ */
7208
+ static fromJSON(path: string): Pointer;
7209
+ toString(): string;
7210
+ /**
7211
+ * Returns an object with 'parent', 'key', and 'value' properties.
7212
+ * In the special case that this Pointer's path == "",
7213
+ * this object will be `{parent: null, key: '', value: object}`.
7214
+ * Otherwise, parent and key will have the property such that parent[key] == value.
7215
+ *
7216
+ * @param object - The object against which to evaluate the pointer.
7217
+ * @returns The evaluation result.
7218
+ */
7219
+ evaluate(object: any): PointerEvaluation;
7220
+ get(object: any): any;
7221
+ set(object: any, value: any): void;
7222
+ push(token: string): void;
7223
+ /**
7224
+ * @param token - The token to add to the pointer.
7225
+ * @returns An updated pointer.
7226
+ */
7227
+ add(token: string): Pointer;
7228
+ /**
7229
+ * Create a new Pointer representing the parent of this one.
7230
+ *
7231
+ * The parent of the empty pointer is the empty pointer.
7232
+ *
7233
+ * @returns The parent pointer.
7234
+ */
7235
+ parent(): Pointer;
7236
+ }
7237
+
7238
+ export declare interface PointerEvaluation {
7239
+ parent: any;
7240
+ key: string;
7241
+ value: any;
7242
+ }
7243
+
6874
7244
  /**
6875
7245
  * Returns true if the two numbers are equal to the given precision.
6876
7246
  * @param a - The first number.
@@ -7252,6 +7622,17 @@ export declare class ParserBuilder {
7252
7622
  }[];
7253
7623
  };
7254
7624
 
7625
+ /**
7626
+ * The "remove" operation removes the value at the target location.
7627
+ * The target location MUST exist for the operation to be successful.
7628
+ *
7629
+ * @param object - The object being patched.
7630
+ * @param operation - The operation to perform on the object.
7631
+ * @param _options - Optional params.
7632
+ * @returns null on success, or error if one occurred.
7633
+ */
7634
+ export declare function remove(object: any, operation: RemoveOperation, _options?: PatchOptions): MissingError | null;
7635
+
7255
7636
  /**
7256
7637
  * Removes duplicates in array using FHIRPath equality rules.
7257
7638
  * @param arr - The input array.
@@ -7259,6 +7640,11 @@ export declare class ParserBuilder {
7259
7640
  */
7260
7641
  export declare function removeDuplicates(arr: TypedValue[]): TypedValue[];
7261
7642
 
7643
+ export declare interface RemoveOperation {
7644
+ op: 'remove';
7645
+ path: string;
7646
+ }
7647
+
7262
7648
  /**
7263
7649
  * Removes a preferred pharmacy extension from a Patient.
7264
7650
  *
@@ -7288,6 +7674,31 @@ export declare class ParserBuilder {
7288
7674
  */
7289
7675
  export declare function reorderBundle(bundle: Bundle): Bundle;
7290
7676
 
7677
+ /**
7678
+ * The "replace" operation replaces the value at the target location
7679
+ * with a new value. The operation object MUST contain a "value" member
7680
+ * whose content specifies the replacement value.
7681
+ * The target location MUST exist for the operation to be successful.
7682
+ *
7683
+ * This operation is functionally identical to a "remove" operation for
7684
+ * a value, followed immediately by an "add" operation at the same
7685
+ * location with the replacement value.
7686
+ *
7687
+ * Even more simply, it's like the add operation with an existence check.
7688
+ *
7689
+ * @param object - The object being patched.
7690
+ * @param operation - The operation to perform on the object.
7691
+ * @param _options - Optional params.
7692
+ * @returns null on success, or error if one occurred.
7693
+ */
7694
+ export declare function replace(object: any, operation: ReplaceOperation, _options?: PatchOptions): MissingError | null;
7695
+
7696
+ export declare interface ReplaceOperation {
7697
+ op: 'replace';
7698
+ path: string;
7699
+ value: any;
7700
+ }
7701
+
7291
7702
  /**
7292
7703
  * Replaces prefetch query variables with values from the context or user profile.
7293
7704
  *
@@ -7329,6 +7740,12 @@ export declare class ParserBuilder {
7329
7740
  */
7330
7741
  export declare function resolveId(input: Reference | Resource | undefined): string | undefined;
7331
7742
 
7743
+ export declare interface ResolveSmartHealthLinkParams {
7744
+ shlink?: string;
7745
+ recipient?: string;
7746
+ passcode?: string;
7747
+ }
7748
+
7332
7749
  /**
7333
7750
  * ResourceArray is an array of resources with a bundle property.
7334
7751
  * The bundle property is a FHIR Bundle containing the search results.
@@ -7532,6 +7949,23 @@ export declare class ParserBuilder {
7532
7949
  slices: SliceDefinition[];
7533
7950
  }
7534
7951
 
7952
+ export declare interface SmartHealthLinkManifestFile {
7953
+ contentType: string;
7954
+ embedded: string;
7955
+ lastUpdated?: string;
7956
+ }
7957
+
7958
+ export declare type SmartHealthLinkMode = 'manifest' | 'direct';
7959
+
7960
+ export declare interface SmartHealthLinkPayload {
7961
+ url: string;
7962
+ key: string;
7963
+ exp?: number;
7964
+ flag?: string;
7965
+ label?: string;
7966
+ v?: 1;
7967
+ }
7968
+
7535
7969
  export declare const SNOMED = "http://snomed.info/sct";
7536
7970
 
7537
7971
  export declare interface SortRule {
@@ -7761,6 +8195,23 @@ export declare class ParserBuilder {
7761
8195
  */
7762
8196
  export declare function subsetResource<T extends Resource>(resource: T | undefined, properties: string[]): T | undefined;
7763
8197
 
8198
+ /**
8199
+ * List the keys in `minuend` that are not in `subtrahend`.
8200
+ *
8201
+ * A key is only considered if it is both 1) an own-property (o.hasOwnProperty(k))
8202
+ * of the object, and 2) has a value that is not undefined. This is to match JSON
8203
+ * semantics, where JSON object serialization drops keys with undefined values.
8204
+ *
8205
+ * @param minuend - Object of interest
8206
+ * @param subtrahend - Object of comparison
8207
+ * @returns Array of keys that are in `minuend` but not in `subtrahend`.
8208
+ */
8209
+ export declare function subtract(minuend: {
8210
+ [index: string]: any;
8211
+ }, subtrahend: {
8212
+ [index: string]: any;
8213
+ }): string[];
8214
+
7764
8215
  /**
7765
8216
  * Summarizes a group of Observations into a single computed summary value, with the individual values
7766
8217
  * preserved in `Observation.component.valueSampledData`.
@@ -7781,6 +8232,34 @@ export declare class ParserBuilder {
7781
8232
  toString(): string;
7782
8233
  }
7783
8234
 
8235
+ /**
8236
+ * The "test" operation tests that a value at the target location is
8237
+ * equal to a specified value.
8238
+ * The operation object MUST contain a "value" member that conveys the
8239
+ * value to be compared to the target location's value.
8240
+ * The target location MUST be equal to the "value" value for the
8241
+ * operation to be considered successful.
8242
+ *
8243
+ * @param object - The object being patched.
8244
+ * @param operation - The add operation to perform on the object.
8245
+ * @param _options - Optional params.
8246
+ * @returns null on success, or error if one occurred.
8247
+ */
8248
+ declare function test_2(object: any, operation: TestOperation, _options?: PatchOptions): TestError | null;
8249
+ export { test_2 as test }
8250
+
8251
+ export declare class TestError extends Error {
8252
+ actual: any;
8253
+ expected: any;
8254
+ constructor(actual: any, expected: any);
8255
+ }
8256
+
8257
+ export declare interface TestOperation {
8258
+ op: 'test';
8259
+ path: string;
8260
+ value: any;
8261
+ }
8262
+
7784
8263
  /**
7785
8264
  * Converts unknown object into a JavaScript boolean.
7786
8265
  * Note that this is different than the FHIRPath "toBoolean",
@@ -7957,6 +8436,31 @@ export declare class ParserBuilder {
7957
8436
 
7958
8437
  export declare const unauthorizedTokenExpired: OperationOutcome;
7959
8438
 
8439
+ /**
8440
+ * Unescape token part of a JSON Pointer string
8441
+ *
8442
+ * `token` should *not* contain any '/' characters.
8443
+ *
8444
+ * Evaluation of each reference token begins by decoding any escaped
8445
+ * character sequence. This is performed by first transforming any
8446
+ * occurrence of the sequence '~1' to '/', and then transforming any
8447
+ * occurrence of the sequence '~0' to '~'. By performing the
8448
+ * substitutions in this order, an implementation avoids the error of
8449
+ * turning '~01' first into '~1' and then into '/', which would be
8450
+ * incorrect (the string '~01' correctly becomes '~1' after
8451
+ * transformation).
8452
+ *
8453
+ * Here's my take:
8454
+ *
8455
+ * ~1 is unescaped with higher priority than ~0 because it is a lower-order escape character.
8456
+ * I say "lower order" because '/' needs escaping due to the JSON Pointer serialization technique.
8457
+ * Whereas, '~' is escaped because escaping '/' uses the '~' character.
8458
+ *
8459
+ * @param token - The token to unescape.
8460
+ * @returns The unescaped token.
8461
+ */
8462
+ export declare function unescapeToken(token: string): string;
8463
+
7960
8464
  export declare class UnionAtom extends InfixOperatorAtom {
7961
8465
  constructor(left: Atom, right: Atom);
7962
8466
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
@@ -8044,6 +8548,13 @@ export declare class ParserBuilder {
8044
8548
  displayLanguage?: string;
8045
8549
  }
8046
8550
 
8551
+ /**
8552
+ * VoidableDiff exists to allow the user to provide a partial diff(...) function,
8553
+ * falling back to the built-in diffAny(...) function if the user-provided function
8554
+ * returns void.
8555
+ */
8556
+ export declare type VoidableDiff = (input: any, output: any, ptr: Pointer) => Operation[] | undefined;
8557
+
8047
8558
  /**
8048
8559
  * Checks if a newer version of Medplum is available and logs a warning if so.
8049
8560
  * @param appName - The name of the app to check the version for.