@medplum/core 5.2.2 → 5.2.4

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.
@@ -329,8 +329,25 @@ export declare interface AgentUpgradeResponse extends BaseAgentMessage {
329
329
  statusCode: number;
330
330
  }
331
331
 
332
+ /**
333
+ * The `Schedule.serviceType` code marking a Schedule that offers every HealthcareService, including ones
334
+ * created later.
335
+ *
336
+ * It decides only which services the Schedule accepts, not when: hours still resolve from the Schedule's
337
+ * SchedulingParameters for the service, then the service's own, then the defaults. Build it with
338
+ * `allServiceTypesCodeableConcept`.
339
+ */
340
+ export declare const ALL_SERVICE_TYPES_CODE = "all";
341
+
332
342
  export declare const allOk: OperationOutcome;
333
343
 
344
+ /**
345
+ * Builds the CodeableConcept that marks a Schedule as offering every HealthcareService, for
346
+ * `Schedule.serviceType`. An Appointment never carries it: it records the service actually booked.
347
+ * @returns The marker concept
348
+ */
349
+ export declare function allServiceTypesCodeableConcept(): CodeableConcept;
350
+
334
351
  export declare type AnchorResourceOpenEvent<T extends FhircastAnchorResourceType> = T extends FhircastAnchorResourceType ? `${T}-open` : never;
335
352
 
336
353
  /**
@@ -2472,6 +2489,30 @@ export declare interface GenerateSmartHealthLinkParams {
2472
2489
  includeQrCode?: boolean;
2473
2490
  }
2474
2491
 
2492
+ /**
2493
+ * Generates the contents of a TypeScript definition (`.d.ts`) file for a FHIR type schema,
2494
+ * including its inner (backbone element) types.
2495
+ *
2496
+ * The schema can be a base FHIR type or a profile, as returned by `parseStructureDefinition` or `tryGetProfile`.
2497
+ * @param fhirType - The type schema to generate an interface for.
2498
+ * @param options - Optional generator options.
2499
+ * @returns The TypeScript file contents, or undefined if the type has no elements.
2500
+ */
2501
+ export declare function generateTypeScriptDefinition(fhirType: InternalTypeSchema, options?: TypeScriptGeneratorOptions): string | undefined;
2502
+
2503
+ /**
2504
+ * Generates TypeScript definitions for FHIR StructureDefinitions, such as profiles.
2505
+ *
2506
+ * Returns one `.d.ts` file per StructureDefinition, plus an `index.d.ts` that exports them all.
2507
+ * Types that are not generated, such as base FHIR data types, are imported from `@medplum/fhirtypes` by default.
2508
+ *
2509
+ * The StructureDefinitions must include a `snapshot`, and are indexed as a side effect.
2510
+ * @param structureDefinitions - The StructureDefinitions to generate types for.
2511
+ * @param options - Optional generator options.
2512
+ * @returns A map of file names to TypeScript file contents.
2513
+ */
2514
+ export declare function generateTypeScriptDefinitions(structureDefinitions: StructureDefinition[], options?: TypeScriptGeneratorOptions): Record<string, string>;
2515
+
2475
2516
  export declare function getAllDataTypes(): DataTypesMap;
2476
2517
 
2477
2518
  /**
@@ -8566,6 +8607,9 @@ export declare class ParserBuilder {
8566
8607
  /** Every eligibility code naming something a booking must carry. */
8567
8608
  export declare const SCHEDULING_REQUIREMENT_CODES: readonly ["requires-procedure", "requires-diagnosis", "requires-medical-necessity"];
8568
8609
 
8610
+ /** Code system for the `Schedule.serviceType` codes Medplum scheduling defines. */
8611
+ export declare const SCHEDULING_SERVICE_TYPE_SYSTEM = "https://medplum.com/fhir/CodeSystem/scheduling-service-type";
8612
+
8569
8613
  /**
8570
8614
  * This extension marks an `Appointment` created by the `$book` operation. Its
8571
8615
  * value is a string recording the Medplum server version that handled the booking.
@@ -8710,8 +8754,20 @@ export declare class ParserBuilder {
8710
8754
 
8711
8755
  export declare function serverTimeout(msg?: string): OperationOutcome;
8712
8756
 
8757
+ /**
8758
+ * Returns whether serviceType concepts carry the marker for offering every HealthcareService.
8759
+ *
8760
+ * An empty or missing `serviceType` does not count.
8761
+ * @param serviceType - CodeableConcept values to inspect
8762
+ * @returns True if any concept is the marker
8763
+ */
8764
+ export declare function serviceTypeIncludesAllServices(serviceType: CodeableConcept[] | undefined): boolean;
8765
+
8713
8766
  /**
8714
8767
  * Returns whether any serviceType concept refers to the given HealthcareService.
8768
+ *
8769
+ * Ignores the marker for offering every HealthcareService; use `serviceTypeOffersService` to ask whether a
8770
+ * Schedule can be booked for the service.
8715
8771
  * @param serviceType - CodeableConcept values to inspect
8716
8772
  * @param service - HealthcareService or reference to match
8717
8773
  * @returns True if any concept references the service
@@ -8720,6 +8776,17 @@ export declare class ParserBuilder {
8720
8776
  reference: string;
8721
8777
  })): boolean;
8722
8778
 
8779
+ /**
8780
+ * Returns whether a Schedule with these serviceType concepts can be booked for the given HealthcareService:
8781
+ * because it refers to the service, or because it carries the marker for offering every one.
8782
+ * @param serviceType - CodeableConcept values to inspect
8783
+ * @param service - HealthcareService or reference to match
8784
+ * @returns True if the concepts offer the service
8785
+ */
8786
+ export declare function serviceTypeOffersService(serviceType: CodeableConcept[] | undefined, service: WithId<HealthcareService> | (Reference<HealthcareService> & {
8787
+ reference: string;
8788
+ })): boolean;
8789
+
8723
8790
  /**
8724
8791
  * Extension URI holding a `Reference<HealthcareService>` on a `serviceType` CodeableConcept.
8725
8792
  *
@@ -9337,6 +9404,13 @@ export declare class ParserBuilder {
9337
9404
 
9338
9405
  export declare function tryGetProfile(profileUrl: string): InternalTypeSchema | undefined;
9339
9406
 
9407
+ /**
9408
+ * Parses a reference and returns a tuple of [ResourceType, ID], or undefined if the reference cannot be parsed.
9409
+ * @param reference - A reference to a FHIR resource.
9410
+ * @returns A tuple containing the `ResourceType` and the ID of the resource, or undefined if the reference cannot be parsed.
9411
+ */
9412
+ export declare function tryParseReference<T extends Resource>(reference: Reference<T> | undefined): [T['resourceType'], string] | undefined;
9413
+
9340
9414
  export declare class TypedEventTarget<TEvents extends Record<string, Event_2>> {
9341
9415
  private readonly emitter;
9342
9416
  dispatchEvent<TEventType extends keyof TEvents>(event: TEvents[TEventType]): void;
@@ -9383,6 +9457,19 @@ export declare class ParserBuilder {
9383
9457
 
9384
9458
  export declare type TypeName<T> = T extends string ? 'string' : T extends number ? 'number' : T extends boolean ? 'boolean' : T extends undefined ? 'undefined' : 'object';
9385
9459
 
9460
+ export declare interface TypeScriptGeneratorOptions {
9461
+ /**
9462
+ * Returns the codes in a ValueSet, used to narrow bound string properties to a union of string literals.
9463
+ * If not provided, or if no codes are returned, bound properties are typed as `string`.
9464
+ */
9465
+ getValueSetValues?: (url: string) => string[] | undefined;
9466
+ /**
9467
+ * Returns the module specifier used to import a referenced type.
9468
+ * Defaults to a sibling file, e.g. `./Patient.d.ts`.
9469
+ */
9470
+ getImportPath?: (typeName: string) => string;
9471
+ }
9472
+
9386
9473
  export declare const UCUM = "http://unitsofmeasure.org";
9387
9474
 
9388
9475
  export declare class UnaryOperatorAtom extends PrefixOperatorAtom {
@@ -329,8 +329,25 @@ export declare interface AgentUpgradeResponse extends BaseAgentMessage {
329
329
  statusCode: number;
330
330
  }
331
331
 
332
+ /**
333
+ * The `Schedule.serviceType` code marking a Schedule that offers every HealthcareService, including ones
334
+ * created later.
335
+ *
336
+ * It decides only which services the Schedule accepts, not when: hours still resolve from the Schedule's
337
+ * SchedulingParameters for the service, then the service's own, then the defaults. Build it with
338
+ * `allServiceTypesCodeableConcept`.
339
+ */
340
+ export declare const ALL_SERVICE_TYPES_CODE = "all";
341
+
332
342
  export declare const allOk: OperationOutcome;
333
343
 
344
+ /**
345
+ * Builds the CodeableConcept that marks a Schedule as offering every HealthcareService, for
346
+ * `Schedule.serviceType`. An Appointment never carries it: it records the service actually booked.
347
+ * @returns The marker concept
348
+ */
349
+ export declare function allServiceTypesCodeableConcept(): CodeableConcept;
350
+
334
351
  export declare type AnchorResourceOpenEvent<T extends FhircastAnchorResourceType> = T extends FhircastAnchorResourceType ? `${T}-open` : never;
335
352
 
336
353
  /**
@@ -2472,6 +2489,30 @@ export declare interface GenerateSmartHealthLinkParams {
2472
2489
  includeQrCode?: boolean;
2473
2490
  }
2474
2491
 
2492
+ /**
2493
+ * Generates the contents of a TypeScript definition (`.d.ts`) file for a FHIR type schema,
2494
+ * including its inner (backbone element) types.
2495
+ *
2496
+ * The schema can be a base FHIR type or a profile, as returned by `parseStructureDefinition` or `tryGetProfile`.
2497
+ * @param fhirType - The type schema to generate an interface for.
2498
+ * @param options - Optional generator options.
2499
+ * @returns The TypeScript file contents, or undefined if the type has no elements.
2500
+ */
2501
+ export declare function generateTypeScriptDefinition(fhirType: InternalTypeSchema, options?: TypeScriptGeneratorOptions): string | undefined;
2502
+
2503
+ /**
2504
+ * Generates TypeScript definitions for FHIR StructureDefinitions, such as profiles.
2505
+ *
2506
+ * Returns one `.d.ts` file per StructureDefinition, plus an `index.d.ts` that exports them all.
2507
+ * Types that are not generated, such as base FHIR data types, are imported from `@medplum/fhirtypes` by default.
2508
+ *
2509
+ * The StructureDefinitions must include a `snapshot`, and are indexed as a side effect.
2510
+ * @param structureDefinitions - The StructureDefinitions to generate types for.
2511
+ * @param options - Optional generator options.
2512
+ * @returns A map of file names to TypeScript file contents.
2513
+ */
2514
+ export declare function generateTypeScriptDefinitions(structureDefinitions: StructureDefinition[], options?: TypeScriptGeneratorOptions): Record<string, string>;
2515
+
2475
2516
  export declare function getAllDataTypes(): DataTypesMap;
2476
2517
 
2477
2518
  /**
@@ -8566,6 +8607,9 @@ export declare class ParserBuilder {
8566
8607
  /** Every eligibility code naming something a booking must carry. */
8567
8608
  export declare const SCHEDULING_REQUIREMENT_CODES: readonly ["requires-procedure", "requires-diagnosis", "requires-medical-necessity"];
8568
8609
 
8610
+ /** Code system for the `Schedule.serviceType` codes Medplum scheduling defines. */
8611
+ export declare const SCHEDULING_SERVICE_TYPE_SYSTEM = "https://medplum.com/fhir/CodeSystem/scheduling-service-type";
8612
+
8569
8613
  /**
8570
8614
  * This extension marks an `Appointment` created by the `$book` operation. Its
8571
8615
  * value is a string recording the Medplum server version that handled the booking.
@@ -8710,8 +8754,20 @@ export declare class ParserBuilder {
8710
8754
 
8711
8755
  export declare function serverTimeout(msg?: string): OperationOutcome;
8712
8756
 
8757
+ /**
8758
+ * Returns whether serviceType concepts carry the marker for offering every HealthcareService.
8759
+ *
8760
+ * An empty or missing `serviceType` does not count.
8761
+ * @param serviceType - CodeableConcept values to inspect
8762
+ * @returns True if any concept is the marker
8763
+ */
8764
+ export declare function serviceTypeIncludesAllServices(serviceType: CodeableConcept[] | undefined): boolean;
8765
+
8713
8766
  /**
8714
8767
  * Returns whether any serviceType concept refers to the given HealthcareService.
8768
+ *
8769
+ * Ignores the marker for offering every HealthcareService; use `serviceTypeOffersService` to ask whether a
8770
+ * Schedule can be booked for the service.
8715
8771
  * @param serviceType - CodeableConcept values to inspect
8716
8772
  * @param service - HealthcareService or reference to match
8717
8773
  * @returns True if any concept references the service
@@ -8720,6 +8776,17 @@ export declare class ParserBuilder {
8720
8776
  reference: string;
8721
8777
  })): boolean;
8722
8778
 
8779
+ /**
8780
+ * Returns whether a Schedule with these serviceType concepts can be booked for the given HealthcareService:
8781
+ * because it refers to the service, or because it carries the marker for offering every one.
8782
+ * @param serviceType - CodeableConcept values to inspect
8783
+ * @param service - HealthcareService or reference to match
8784
+ * @returns True if the concepts offer the service
8785
+ */
8786
+ export declare function serviceTypeOffersService(serviceType: CodeableConcept[] | undefined, service: WithId<HealthcareService> | (Reference<HealthcareService> & {
8787
+ reference: string;
8788
+ })): boolean;
8789
+
8723
8790
  /**
8724
8791
  * Extension URI holding a `Reference<HealthcareService>` on a `serviceType` CodeableConcept.
8725
8792
  *
@@ -9337,6 +9404,13 @@ export declare class ParserBuilder {
9337
9404
 
9338
9405
  export declare function tryGetProfile(profileUrl: string): InternalTypeSchema | undefined;
9339
9406
 
9407
+ /**
9408
+ * Parses a reference and returns a tuple of [ResourceType, ID], or undefined if the reference cannot be parsed.
9409
+ * @param reference - A reference to a FHIR resource.
9410
+ * @returns A tuple containing the `ResourceType` and the ID of the resource, or undefined if the reference cannot be parsed.
9411
+ */
9412
+ export declare function tryParseReference<T extends Resource>(reference: Reference<T> | undefined): [T['resourceType'], string] | undefined;
9413
+
9340
9414
  export declare class TypedEventTarget<TEvents extends Record<string, Event_2>> {
9341
9415
  private readonly emitter;
9342
9416
  dispatchEvent<TEventType extends keyof TEvents>(event: TEvents[TEventType]): void;
@@ -9383,6 +9457,19 @@ export declare class ParserBuilder {
9383
9457
 
9384
9458
  export declare type TypeName<T> = T extends string ? 'string' : T extends number ? 'number' : T extends boolean ? 'boolean' : T extends undefined ? 'undefined' : 'object';
9385
9459
 
9460
+ export declare interface TypeScriptGeneratorOptions {
9461
+ /**
9462
+ * Returns the codes in a ValueSet, used to narrow bound string properties to a union of string literals.
9463
+ * If not provided, or if no codes are returned, bound properties are typed as `string`.
9464
+ */
9465
+ getValueSetValues?: (url: string) => string[] | undefined;
9466
+ /**
9467
+ * Returns the module specifier used to import a referenced type.
9468
+ * Defaults to a sibling file, e.g. `./Patient.d.ts`.
9469
+ */
9470
+ getImportPath?: (typeName: string) => string;
9471
+ }
9472
+
9386
9473
  export declare const UCUM = "http://unitsofmeasure.org";
9387
9474
 
9388
9475
  export declare class UnaryOperatorAtom extends PrefixOperatorAtom {