@medplum/core 5.1.27 → 5.1.29

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.
@@ -22,6 +22,7 @@ import type { Encounter } from '@medplum/fhirtypes';
22
22
  import type { Extension } from '@medplum/fhirtypes';
23
23
  import type { ExtensionValue } from '@medplum/fhirtypes';
24
24
  import type { ExtractResource } from '@medplum/fhirtypes';
25
+ import type { HealthcareService } from '@medplum/fhirtypes';
25
26
  import type { HumanName } from '@medplum/fhirtypes';
26
27
  import type { Identifier } from '@medplum/fhirtypes';
27
28
  import type { ImagingStudy } from '@medplum/fhirtypes';
@@ -56,6 +57,7 @@ import type { RelatedPerson } from '@medplum/fhirtypes';
56
57
  import type { Resource } from '@medplum/fhirtypes';
57
58
  import type { ResourceType } from '@medplum/fhirtypes';
58
59
  import type { SampledData } from '@medplum/fhirtypes';
60
+ import type { Schedule } from '@medplum/fhirtypes';
59
61
  import type { SearchParameter } from '@medplum/fhirtypes';
60
62
  import type { StructureDefinition } from '@medplum/fhirtypes';
61
63
  import type { StructureMap } from '@medplum/fhirtypes';
@@ -431,6 +433,24 @@ export { assert_2 as assert }
431
433
 
432
434
  export declare function assertContextVersionOptional(event: string): asserts event is FhircastEventVersionOptional;
433
435
 
436
+ /**
437
+ * Checks that a value has type `never`. Useful for ensuring exhaustive
438
+ * matches.
439
+ *
440
+ * @example
441
+ * ```typescript
442
+ * type MyUnion = 'a' | 'b' | 'c'
443
+ * function f(arg: MyUnion) {
444
+ * if (arg === 'a') { return 1; }
445
+ * if (arg === 'b') { return 2; }
446
+ * assertNever(arg); // Type error: 'c' is unhandled
447
+ * }
448
+ * ```
449
+ *
450
+ * @param value - The value that should never be present
451
+ */
452
+ export declare function assertNever(value: never): never;
453
+
434
454
  /**
435
455
  * Asserts that the operation completed successfully and that the resource is defined.
436
456
  * @param outcome - The operation outcome.
@@ -811,6 +831,17 @@ export declare function checkIfValidMedplumVersion(appName: string, version: str
811
831
  */
812
832
  export declare function clearReleaseCache(): void;
813
833
 
834
+ /**
835
+ * Immutably clears one scheduling parameter a Schedule sets for a HealthcareService, dropping that
836
+ * calendar back to the service-level parameter of the same name. Pairs with `setScheduleParameter`
837
+ * and `getScheduleParameters`.
838
+ * @param schedule - Schedule to update
839
+ * @param service - HealthcareService referenced by the parameters
840
+ * @param url - Url of the SchedulingParameters sub-extension to remove, for example `availability`
841
+ * @returns A cloned Schedule without the matching parameter
842
+ */
843
+ export declare function clearScheduleParameter(schedule: Schedule, service: WithId<HealthcareService>, url: string): Schedule;
844
+
814
845
  /**
815
846
  * Log level for MedplumClient requests and responses.
816
847
  * - 'none': No logging
@@ -954,6 +985,7 @@ export declare function contentTooLarge(text: string): OperationOutcome;
954
985
  export declare const ContentType: {
955
986
  readonly CSS: "text/css";
956
987
  readonly DICOM: "application/dicom";
988
+ readonly DICOM_JSON: "application/dicom+json";
957
989
  readonly EVENT_STREAM: "text/event-stream";
958
990
  readonly FAVICON: "image/vnd.microsoft.icon";
959
991
  readonly FHIR_JSON: "application/fhir+json";
@@ -1254,6 +1286,10 @@ export declare type DataTypesMap = {
1254
1286
  [type: string]: InternalTypeSchema;
1255
1287
  };
1256
1288
 
1289
+ export declare type DayOfWeek = (typeof DAYS_OF_WEEK)[number];
1290
+
1291
+ export declare const DAYS_OF_WEEK: readonly ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
1292
+
1257
1293
  /**
1258
1294
  * Decodes a base64 string.
1259
1295
  * Handles both browser and Node environments.
@@ -1607,6 +1643,15 @@ export declare interface ExtendedInternalSchemaElement extends InternalSchemaEle
1607
1643
  readonly?: boolean;
1608
1644
  }
1609
1645
 
1646
+ /**
1647
+ * Anything that can carry FHIR extensions: resources such as `Patient`, data types such as
1648
+ * `CodeableConcept`, and extensions themselves. Structural, so any of those is accepted, while a
1649
+ * type that cannot hold extensions, `Binary` being the notable example, is rejected.
1650
+ */
1651
+ export declare interface Extensible {
1652
+ extension?: Extension[];
1653
+ }
1654
+
1610
1655
  export declare type ExternalSecret<T extends ExternalSecretPrimitive = ExternalSecretPrimitive> = {
1611
1656
  system: ExternalSecretSystem;
1612
1657
  key: string;
@@ -1630,6 +1675,13 @@ export declare const ExternalSecretSystems: {
1630
1675
  */
1631
1676
  export declare function extractAccountReferences(meta: Meta | undefined): Reference[] | undefined;
1632
1677
 
1678
+ /**
1679
+ * Extracts HealthcareService references from serviceType concepts.
1680
+ * @param serviceType - CodeableConcept values to inspect
1681
+ * @returns HealthcareService references embedded in the concepts
1682
+ */
1683
+ export declare function extractServiceTypeReferences(serviceType: CodeableConcept[] | undefined): Reference<HealthcareService>[];
1684
+
1633
1685
  /**
1634
1686
  * Fetches the version strings for all published Medplum releases.
1635
1687
  * @param appName - The name of the app to fetch the release list for.
@@ -2434,6 +2486,18 @@ export declare function getExpressionsForResourceType(resourceType: string, expr
2434
2486
  */
2435
2487
  export declare function getExtension(resource: any, ...urls: string[]): Extension | undefined;
2436
2488
 
2489
+ /**
2490
+ * Returns every extension reachable by the given extension URLs.
2491
+ *
2492
+ * Like `getExtension`, but does not stop at the first match: extensions that repeat under one URL are
2493
+ * all returned, at every level. Use it for extensions defined with a cardinality above one, where
2494
+ * `getExtension` would silently read only the first.
2495
+ * @param extensible - The base resource, data type, or extension. Anything that may hold an `extension` array.
2496
+ * @param urlOrUrls - One extension URL, or an array of them where each entry represents descending a level in a nested extension.
2497
+ * @returns Every matching extension, in document order. Empty if none match or no URL is given.
2498
+ */
2499
+ export declare function getExtensions(extensible: Extensible | undefined, urlOrUrls: string | string[]): Extension[];
2500
+
2437
2501
  /**
2438
2502
  * Returns an extension value by extension URLs.
2439
2503
  * @param resource - The base resource.
@@ -2576,6 +2640,30 @@ export declare function getReferenceString(input: Reference | Resource): string
2576
2640
  */
2577
2641
  export declare function getResourceTypes(): ResourceType[];
2578
2642
 
2643
+ /**
2644
+ * Reads one scheduling parameter a Schedule sets for a HealthcareService, taking precedence over the
2645
+ * service-level parameter of the same name. Pairs with `setScheduleParameter` and `clearScheduleParameter`.
2646
+ *
2647
+ * The result is a list rather than a single extension because a Schedule may carry more than one
2648
+ * SchedulingParameters extension matching the service, and because a parameter may legitimately repeat.
2649
+ * @param schedule - Schedule to inspect
2650
+ * @param service - HealthcareService referenced by the parameters
2651
+ * @param url - Url of the SchedulingParameters sub-extension to read, for example `availability`
2652
+ * @returns Every matching sub-extension, in document order
2653
+ */
2654
+ export declare function getScheduleParameters(schedule: Schedule, service: WithId<HealthcareService>, url: string): Extension[];
2655
+
2656
+ /**
2657
+ * Resolves the timezone used by scheduling in server priority order: the Schedule's parameters for the
2658
+ * service, then the service's own parameters, then the actor's standard FHIR timezone extension.
2659
+ * @param service - HealthcareService whose parameters may define a timezone
2660
+ * @param schedule - Schedule whose parameters may define a timezone. Omit to resolve the service's own timezone,
2661
+ * as when the service default hours are being read on their own rather than through a particular calendar.
2662
+ * @param actor - Optional Schedule actor used as a timezone fallback
2663
+ * @returns The resolved IANA timezone identifier, if present
2664
+ */
2665
+ export declare function getSchedulingTimezone(service: WithId<HealthcareService>, schedule?: Schedule, actor?: Resource): string | undefined;
2666
+
2579
2667
  /**
2580
2668
  * Returns a search parameter for a resource type by search code.
2581
2669
  * @param resourceType - The FHIR resource type.
@@ -2686,6 +2774,16 @@ export declare interface GoogleLoginRequest extends BaseLoginRequest {
2686
2774
  readonly createUser?: boolean;
2687
2775
  }
2688
2776
 
2777
+ /**
2778
+ * Returns whether a Schedule or HealthcareService has a SchedulingParameters extension.
2779
+ *
2780
+ * Unscoped: on a Schedule, where the extension repeats once per service, this reports that some
2781
+ * service is configured rather than any particular one. Ask `getScheduleParameters` about a service.
2782
+ * @param resource - Schedule or HealthcareService to inspect
2783
+ * @returns True if the resource has a SchedulingParameters extension
2784
+ */
2785
+ export declare function hasSchedulingParameters(resource: Schedule | HealthcareService): boolean;
2786
+
2689
2787
  export declare interface Hl7AckOptions {
2690
2788
  ackCode: AckCode;
2691
2789
  errSegment?: Hl7Segment;
@@ -3397,6 +3495,8 @@ export declare function isDateString(input: unknown): input is string;
3397
3495
  */
3398
3496
  export declare function isDateTimeString(input: unknown): input is string;
3399
3497
 
3498
+ export declare function isDayOfWeek(value: string | undefined): value is DayOfWeek;
3499
+
3400
3500
  /**
3401
3501
  * Helper function to narrow a type by excluding undefined/null values.
3402
3502
  * @param value - The value to refine
@@ -3627,7 +3727,7 @@ export declare function isStringArray(arr: any[]): arr is string[];
3627
3727
 
3628
3728
  export declare type IssueSeverity = 'error' | 'fatal' | 'warning' | 'information';
3629
3729
 
3630
- export declare type IssueType = 'structure' | 'invariant' | 'processing';
3730
+ export declare type IssueType = 'structure' | 'invariant' | 'processing' | 'required';
3631
3731
 
3632
3732
  /**
3633
3733
  * Returns true if the input value is an object with a string text property.
@@ -4182,6 +4282,25 @@ export declare interface MedicationOrderDrugInput {
4182
4282
  readonly ndc?: string;
4183
4283
  readonly rxNorm?: string;
4184
4284
  readonly routedMedId?: number;
4285
+ /**
4286
+ * Vendor formulation key, paired with {@link routedMedId} to order a drug that
4287
+ * has no dose-level product to resolve an NDC from — OTC / topical /
4288
+ * wide-multi-strength generics for which the vendor's dose-format lookup
4289
+ * returns nothing. Supply {@link drugName} alongside it, since there is no
4290
+ * catalog row to derive a name from.
4291
+ */
4292
+ readonly gcnSeqno?: number;
4293
+ /** Drug name, required for a {@link gcnSeqno}-keyed line (no catalog row to name it). */
4294
+ readonly drugName?: string;
4295
+ /**
4296
+ * Dose text for a {@link gcnSeqno}-keyed line, e.g. `"solution"`.
4297
+ *
4298
+ * Optional, and only worth sending when the caller holds dose text *separate*
4299
+ * from {@link drugName} — a hand-entered form, say. Passing a full product
4300
+ * label duplicates it in the description the vendor renders. When omitted, the
4301
+ * vendor derives the dose from the formulation key or falls back to the sig.
4302
+ */
4303
+ readonly line1?: string;
4185
4304
  readonly quantity: number;
4186
4305
  readonly quantityQualifier?: string;
4187
4306
  readonly refill?: number;
@@ -4337,6 +4456,13 @@ export declare interface MedicationSearchParams {
4337
4456
  readonly ndc?: string;
4338
4457
  readonly rxNorm?: string;
4339
4458
  readonly routedMedId?: number;
4459
+ /**
4460
+ * Vendor formulation keys under {@link routedMedId}, from the name-search hit.
4461
+ * Only used when the drug has no dose-level products: each key is resolved to
4462
+ * its marketed strength so the caller still gets selectable formulations
4463
+ * instead of an empty result. Ignored otherwise.
4464
+ */
4465
+ readonly gcnSeqnos?: number[];
4340
4466
  readonly searchOtc?: boolean;
4341
4467
  readonly searchSupply?: boolean;
4342
4468
  readonly searchBrand?: boolean;
@@ -7318,6 +7444,16 @@ export declare function parametersToOrderSetSyncResponse(params: Parameters_2):
7318
7444
  */
7319
7445
  export declare function parseFhirPath(input: string): FhirPathAtom;
7320
7446
 
7447
+ /**
7448
+ * Parses a FHIRPath Patch `Parameters` resource into the array of operations consumed by
7449
+ * {@link fhirpathPatchTypedValue}. Each repeating `operation` parameter is decoded from its
7450
+ * `part` entries (`type`, `path`, `name`, `value`, `index`, `source`, `destination`), where
7451
+ * the polymorphic `value[x]` part becomes a {@link TypedValue}.
7452
+ * @param parameters - The FHIRPath Patch Parameters resource.
7453
+ * @returns The parsed FHIRPath Patch operations.
7454
+ */
7455
+ export declare function parseFhirPathPatchParameters(parameters: Parameters_2): FhirPathPatch[];
7456
+
7321
7457
  /**
7322
7458
  * Parses a FHIR _filter parameter expression into an AST.
7323
7459
  * @param input - The FHIR _filter parameter expression.
@@ -8114,6 +8250,12 @@ export declare class ParserBuilder {
8114
8250
  */
8115
8251
  export declare function satisfiedAccessPolicy(resource: Resource, interaction: AccessPolicyInteraction, accessPolicy: AccessPolicy | undefined): AccessPolicyResource | undefined;
8116
8252
 
8253
+ export declare const SchedulingEncounterCodingURI = "https://medplum.com/fhir/StructureDefinition/SchedulingEncounterCoding";
8254
+
8255
+ export declare const SchedulingParametersURI = "https://medplum.com/fhir/StructureDefinition/SchedulingParameters";
8256
+
8257
+ export declare const SchedulingPlanDefinitionURI = "https://medplum.com/fhir/StructureDefinition/SchedulingPlanDefinition";
8258
+
8117
8259
  export declare interface SearchableToken {
8118
8260
  readonly system: string | undefined;
8119
8261
  readonly value: string | undefined;
@@ -8196,6 +8338,42 @@ export declare class ParserBuilder {
8196
8338
 
8197
8339
  export declare function serverTimeout(msg?: string): OperationOutcome;
8198
8340
 
8341
+ /**
8342
+ * Returns whether any serviceType concept refers to the given HealthcareService.
8343
+ * @param serviceType - CodeableConcept values to inspect
8344
+ * @param service - HealthcareService or reference to match
8345
+ * @returns True if any concept references the service
8346
+ */
8347
+ export declare function serviceTypeIncludesService(serviceType: CodeableConcept[] | undefined, service: WithId<HealthcareService> | (Reference<HealthcareService> & {
8348
+ reference: string;
8349
+ })): boolean;
8350
+
8351
+ /**
8352
+ * Extension URI holding a `Reference<HealthcareService>` on a `serviceType` CodeableConcept.
8353
+ *
8354
+ * In R5/R6, `serviceType` attributes change from `CodeableConcept[]` to
8355
+ * `CodeableReference<HealthcareService>`. We approximate that in R4 with this extension.
8356
+ *
8357
+ * Example: a Schedule whose serviceType refers to a HealthcareService:
8358
+ * ```json
8359
+ * {
8360
+ * "resourceType": "Schedule",
8361
+ * "actor": [{ "reference": "Practitioner/abc" }],
8362
+ * "serviceType": [
8363
+ * {
8364
+ * "extension": [
8365
+ * {
8366
+ * "url": "https://medplum.com/fhir/service-type-reference",
8367
+ * "valueReference": { "reference": "HealthcareService/123" }
8368
+ * }
8369
+ * ]
8370
+ * }
8371
+ * ]
8372
+ * }
8373
+ * ```
8374
+ */
8375
+ export declare const ServiceTypeReferenceURI = "https://medplum.com/fhir/service-type-reference";
8376
+
8199
8377
  /**
8200
8378
  * Sets a code for a given system within a given codeable concept.
8201
8379
  * @param concept - The codeable concept.
@@ -8229,6 +8407,23 @@ export declare class ParserBuilder {
8229
8407
  use?: Identifier['use'];
8230
8408
  }
8231
8409
 
8410
+ /**
8411
+ * Immutably sets one scheduling parameter on a Schedule for a HealthcareService, so that calendar keeps
8412
+ * it in place of the service-level parameter of the same name. Whatever the Schedule already holds at the
8413
+ * sub-extension's url is replaced, and the SchedulingParameters extension is created if the Schedule has
8414
+ * none for the service yet.
8415
+ *
8416
+ * Untyped by design, taking any sub-extension of the shape the parameter calls for, for example
8417
+ * `{ url: 'bufferBefore', valueDuration: { value: 10, unit: 'min' } }`. A parameter whose value is a nested
8418
+ * structure rather than a single `value[x]` is worth a typed wrapper over this; `availability` has one in
8419
+ * `@medplum/react-scheduling`. Pairs with `clearScheduleParameter` and `getScheduleParameters`.
8420
+ * @param schedule - Schedule to update
8421
+ * @param service - HealthcareService referenced by the parameters
8422
+ * @param subextension - SchedulingParameters sub-extension to set
8423
+ * @returns A cloned Schedule containing the parameter
8424
+ */
8425
+ export declare function setScheduleParameter(schedule: Schedule, service: WithId<HealthcareService>, subextension: Extension): Schedule;
8426
+
8232
8427
  export declare function singleton(collection: TypedValue[], type?: string): TypedValue | undefined;
8233
8428
 
8234
8429
  export declare function singularize<T>(value: T | T[] | undefined): T | undefined;
@@ -8585,6 +8780,8 @@ export declare class ParserBuilder {
8585
8780
  value: any;
8586
8781
  }
8587
8782
 
8783
+ export declare const TimezoneExtensionURI = "http://hl7.org/fhir/StructureDefinition/timezone";
8784
+
8588
8785
  /**
8589
8786
  * Converts unknown object into a JavaScript boolean.
8590
8787
  * Note that this is different than the FHIRPath "toBoolean",
@@ -8621,6 +8818,19 @@ export declare class ParserBuilder {
8621
8818
  private consumeQuotedSymbol;
8622
8819
  private consumeDateTime;
8623
8820
  private consumeNumber;
8821
+ /**
8822
+ * Consumes an unquoted string value that begins with digits, such as a UUID in a `_filter`
8823
+ * expression, starting over from the beginning of the value.
8824
+ *
8825
+ * The value ends at the first character that cannot be part of a token, per `symbolRegex`. For the
8826
+ * `_filter` tokenizer that is whitespace, ")", and "]", so a value at the end of a nested
8827
+ * expression such as "(_id eq 12345678-1234-4123-8123-123456789abc)" does not swallow the closing
8828
+ * parenthesis.
8829
+ *
8830
+ * @param start - The index of the first character of the value.
8831
+ * @returns The string token.
8832
+ */
8833
+ private consumeUnquotedString;
8624
8834
  private consumeSymbol;
8625
8835
  private consumeOperator;
8626
8836
  private consumeWhile;
@@ -8661,6 +8871,15 @@ export declare class ParserBuilder {
8661
8871
  */
8662
8872
  export declare function toPeriod(input: unknown): Period | undefined;
8663
8873
 
8874
+ /**
8875
+ * Converts a HealthcareService into the CodeableConcept values used by
8876
+ * `Schedule.serviceType` and `Appointment.serviceType`, which encode an R4
8877
+ * approximation of `CodeableReference<HealthcareService>`.
8878
+ * @param service - HealthcareService to represent
8879
+ * @returns CodeableConcept values containing a reference to the service
8880
+ */
8881
+ export declare function toServiceTypeCodeableConcepts(service: WithId<HealthcareService>): CodeableConcept[];
8882
+
8664
8883
  /**
8665
8884
  * Returns a "best guess" TypedValue for a given value.
8666
8885
  * @param value - The unknown value to check.