@medplum/core 4.1.6 → 4.1.7

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.
@@ -14,6 +14,7 @@ import { ConceptMap } from '@medplum/fhirtypes';
14
14
  import type { CustomTableLayout } from 'pdfmake/interfaces';
15
15
  import { Device } from '@medplum/fhirtypes';
16
16
  import { DiagnosticReport } from '@medplum/fhirtypes';
17
+ import { DocumentReference } from '@medplum/fhirtypes';
17
18
  import { ElementDefinition } from '@medplum/fhirtypes';
18
19
  import { ElementDefinitionBinding } from '@medplum/fhirtypes';
19
20
  import { Encounter } from '@medplum/fhirtypes';
@@ -47,6 +48,7 @@ import { Reference } from '@medplum/fhirtypes';
47
48
  import { RelatedPerson } from '@medplum/fhirtypes';
48
49
  import { Resource } from '@medplum/fhirtypes';
49
50
  import { ResourceType } from '@medplum/fhirtypes';
51
+ import { SampledData } from '@medplum/fhirtypes';
50
52
  import { SearchParameter } from '@medplum/fhirtypes';
51
53
  import { StructureDefinition } from '@medplum/fhirtypes';
52
54
  import { StructureMap } from '@medplum/fhirtypes';
@@ -632,6 +634,13 @@ export declare function createConstraintIssue(expression: string, constraint: Co
632
634
 
633
635
  export declare const created: OperationOutcome;
634
636
 
637
+ export declare interface CreateDocumentReferenceOptions extends CreateBinaryOptions {
638
+ /**
639
+ * Optional additional fields for the DocumentReference resource.
640
+ */
641
+ readonly additionalFields?: Omit<Partial<DocumentReference>, 'content'>;
642
+ }
643
+
635
644
  /**
636
645
  * Creates a serializable JSON payload for the `FHIRcast` protocol
637
646
  *
@@ -702,6 +711,28 @@ export declare type CurrentContext<T extends FhircastAnchorResourceType | '' = F
702
711
  context: FhircastEventContext<AnchorResourceOpenEvent<T>>[];
703
712
  } : never;
704
713
 
714
+ export declare class DataSampler {
715
+ private code?;
716
+ private unit?;
717
+ private readonly sampling?;
718
+ private readonly dataPoints;
719
+ /**
720
+ * @param opts - Optional parameters.
721
+ * @param opts.code - Code for data points.
722
+ * @param opts.unit - Unit for data points.
723
+ * @param opts.sampling - Sampling information for high-frequency Observations.
724
+ */
725
+ constructor(opts?: {
726
+ code?: CodeableConcept;
727
+ unit?: QuantityUnit;
728
+ sampling?: SamplingInfo;
729
+ });
730
+ addObservation(obs: Observation): void;
731
+ addData(...data: number[]): void;
732
+ private checkUnit;
733
+ summarize(code: CodeableConcept, fn: StatsFn): Observation;
734
+ }
735
+
705
736
  export declare type DataTypesMap = {
706
737
  [type: string]: InternalTypeSchema;
707
738
  };
@@ -920,6 +951,10 @@ declare class EventTarget_2 {
920
951
  }
921
952
  export { EventTarget_2 as EventTarget }
922
953
 
954
+ export declare function expandSampledData(sample: SampledData): number[];
955
+
956
+ export declare function expandSampledObservation(obs: Observation): Observation[];
957
+
923
958
  export declare type ExtendedElementProperties = {
924
959
  readonly: boolean;
925
960
  hidden: boolean;
@@ -4145,6 +4180,15 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4145
4180
  * @deprecated Use `createMedia` with `CreateMediaOptions` instead. To be removed in a future version.
4146
4181
  */
4147
4182
  uploadMedia(contents: string | Uint8Array | File | Blob, contentType: string, filename: string | undefined, additionalFields?: Partial<Media>, options?: MedplumRequestOptions): Promise<Media>;
4183
+ /**
4184
+ * Creates a FHIR DocumentReference resource with the provided data content.
4185
+ *
4186
+ * @category Create
4187
+ * @param createDocumentReferenceOptions - The document reference creation options. See `CreateDocumentReferenceOptions` for full details.
4188
+ * @param requestOptions - Optional fetch options.
4189
+ * @returns The new document reference resource.
4190
+ */
4191
+ createDocumentReference(createDocumentReferenceOptions: CreateDocumentReferenceOptions, requestOptions?: MedplumRequestOptions): Promise<DocumentReference>;
4148
4192
  /**
4149
4193
  * Performs Bulk Data Export operation request flow. See The FHIR "Bulk Data Export" for full details: https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-export
4150
4194
  * @param exportLevel - Optional export level. Defaults to system level export. 'Group/:id' - Group of Patients, 'Patient' - All Patients.
@@ -4869,6 +4913,10 @@ export declare interface MedplumRequestOptions extends RequestInit {
4869
4913
  * Optional max number of retries that should be made in the case of a failed request. Default is `2`.
4870
4914
  */
4871
4915
  maxRetries?: number;
4916
+ /**
4917
+ * Optional maximum time to wait between retries, in milliseconds; defaults to `2000` (2 s).
4918
+ */
4919
+ maxRetryTime?: number;
4872
4920
  /**
4873
4921
  * Optional flag to disable auto-batching for this specific request.
4874
4922
  * Only applies when the client is configured with auto-batching enabled.
@@ -5540,6 +5588,8 @@ export declare const protectedResourceTypes: string[];
5540
5588
 
5541
5589
  export declare type ProtocolsProvider = null | string | string[];
5542
5590
 
5591
+ export declare type QuantityUnit = Pick<Quantity, 'unit' | 'code' | 'system'>;
5592
+
5543
5593
  /**
5544
5594
  * QueryTypes defines the different ways to specify FHIR search parameters.
5545
5595
  *
@@ -5794,6 +5844,8 @@ export declare type ResourceWithCode = Resource & Code;
5794
5844
 
5795
5845
  export declare const RXNORM = "http://www.nlm.nih.gov/research/umls/rxnorm";
5796
5846
 
5847
+ export declare type SamplingInfo = Omit<SampledData, 'data'>;
5848
+
5797
5849
  /**
5798
5850
  * Checks that there is an access policy permitting the given resource interaction, returning the matching policy object.
5799
5851
  * @param resource - The resource being acted upon.
@@ -5970,6 +6022,8 @@ export declare function splitN(str: string, delim: string, n: number): string[];
5970
6022
  */
5971
6023
  export declare function splitSearchOnComma(input: string): string[];
5972
6024
 
6025
+ export declare type StatsFn = (data: number[]) => number | Quantity;
6026
+
5973
6027
  /**
5974
6028
  * Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data.
5975
6029
  * @param stream - The Readable stream to read from.
@@ -6143,6 +6197,17 @@ export declare type SubscriptionRequest = {
6143
6197
  */
6144
6198
  export declare function subsetResource<T extends Resource>(resource: T | undefined, properties: string[]): T | undefined;
6145
6199
 
6200
+ /**
6201
+ * Summarizes a group of Observations into a single computed summary value, with the individual values
6202
+ * preserved in `Observation.component.valueSampledData`.
6203
+ *
6204
+ * @param observations - The Observations to summarize.
6205
+ * @param summaryCode - The code for the summarized value.
6206
+ * @param summarizeFn - Function to summarize the data points.
6207
+ * @returns - The summary Observation resource.
6208
+ */
6209
+ export declare function summarizeObservations(observations: Observation[] | Bundle<Observation>, summaryCode: CodeableConcept, summarizeFn: StatsFn): Observation;
6210
+
6146
6211
  export declare class SymbolAtom implements Atom {
6147
6212
  readonly name: string;
6148
6213
  constructor(name: string);
@@ -14,6 +14,7 @@ import { ConceptMap } from '@medplum/fhirtypes';
14
14
  import type { CustomTableLayout } from 'pdfmake/interfaces';
15
15
  import { Device } from '@medplum/fhirtypes';
16
16
  import { DiagnosticReport } from '@medplum/fhirtypes';
17
+ import { DocumentReference } from '@medplum/fhirtypes';
17
18
  import { ElementDefinition } from '@medplum/fhirtypes';
18
19
  import { ElementDefinitionBinding } from '@medplum/fhirtypes';
19
20
  import { Encounter } from '@medplum/fhirtypes';
@@ -47,6 +48,7 @@ import { Reference } from '@medplum/fhirtypes';
47
48
  import { RelatedPerson } from '@medplum/fhirtypes';
48
49
  import { Resource } from '@medplum/fhirtypes';
49
50
  import { ResourceType } from '@medplum/fhirtypes';
51
+ import { SampledData } from '@medplum/fhirtypes';
50
52
  import { SearchParameter } from '@medplum/fhirtypes';
51
53
  import { StructureDefinition } from '@medplum/fhirtypes';
52
54
  import { StructureMap } from '@medplum/fhirtypes';
@@ -632,6 +634,13 @@ export declare function createConstraintIssue(expression: string, constraint: Co
632
634
 
633
635
  export declare const created: OperationOutcome;
634
636
 
637
+ export declare interface CreateDocumentReferenceOptions extends CreateBinaryOptions {
638
+ /**
639
+ * Optional additional fields for the DocumentReference resource.
640
+ */
641
+ readonly additionalFields?: Omit<Partial<DocumentReference>, 'content'>;
642
+ }
643
+
635
644
  /**
636
645
  * Creates a serializable JSON payload for the `FHIRcast` protocol
637
646
  *
@@ -702,6 +711,28 @@ export declare type CurrentContext<T extends FhircastAnchorResourceType | '' = F
702
711
  context: FhircastEventContext<AnchorResourceOpenEvent<T>>[];
703
712
  } : never;
704
713
 
714
+ export declare class DataSampler {
715
+ private code?;
716
+ private unit?;
717
+ private readonly sampling?;
718
+ private readonly dataPoints;
719
+ /**
720
+ * @param opts - Optional parameters.
721
+ * @param opts.code - Code for data points.
722
+ * @param opts.unit - Unit for data points.
723
+ * @param opts.sampling - Sampling information for high-frequency Observations.
724
+ */
725
+ constructor(opts?: {
726
+ code?: CodeableConcept;
727
+ unit?: QuantityUnit;
728
+ sampling?: SamplingInfo;
729
+ });
730
+ addObservation(obs: Observation): void;
731
+ addData(...data: number[]): void;
732
+ private checkUnit;
733
+ summarize(code: CodeableConcept, fn: StatsFn): Observation;
734
+ }
735
+
705
736
  export declare type DataTypesMap = {
706
737
  [type: string]: InternalTypeSchema;
707
738
  };
@@ -920,6 +951,10 @@ declare class EventTarget_2 {
920
951
  }
921
952
  export { EventTarget_2 as EventTarget }
922
953
 
954
+ export declare function expandSampledData(sample: SampledData): number[];
955
+
956
+ export declare function expandSampledObservation(obs: Observation): Observation[];
957
+
923
958
  export declare type ExtendedElementProperties = {
924
959
  readonly: boolean;
925
960
  hidden: boolean;
@@ -4145,6 +4180,15 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4145
4180
  * @deprecated Use `createMedia` with `CreateMediaOptions` instead. To be removed in a future version.
4146
4181
  */
4147
4182
  uploadMedia(contents: string | Uint8Array | File | Blob, contentType: string, filename: string | undefined, additionalFields?: Partial<Media>, options?: MedplumRequestOptions): Promise<Media>;
4183
+ /**
4184
+ * Creates a FHIR DocumentReference resource with the provided data content.
4185
+ *
4186
+ * @category Create
4187
+ * @param createDocumentReferenceOptions - The document reference creation options. See `CreateDocumentReferenceOptions` for full details.
4188
+ * @param requestOptions - Optional fetch options.
4189
+ * @returns The new document reference resource.
4190
+ */
4191
+ createDocumentReference(createDocumentReferenceOptions: CreateDocumentReferenceOptions, requestOptions?: MedplumRequestOptions): Promise<DocumentReference>;
4148
4192
  /**
4149
4193
  * Performs Bulk Data Export operation request flow. See The FHIR "Bulk Data Export" for full details: https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-export
4150
4194
  * @param exportLevel - Optional export level. Defaults to system level export. 'Group/:id' - Group of Patients, 'Patient' - All Patients.
@@ -4869,6 +4913,10 @@ export declare interface MedplumRequestOptions extends RequestInit {
4869
4913
  * Optional max number of retries that should be made in the case of a failed request. Default is `2`.
4870
4914
  */
4871
4915
  maxRetries?: number;
4916
+ /**
4917
+ * Optional maximum time to wait between retries, in milliseconds; defaults to `2000` (2 s).
4918
+ */
4919
+ maxRetryTime?: number;
4872
4920
  /**
4873
4921
  * Optional flag to disable auto-batching for this specific request.
4874
4922
  * Only applies when the client is configured with auto-batching enabled.
@@ -5540,6 +5588,8 @@ export declare const protectedResourceTypes: string[];
5540
5588
 
5541
5589
  export declare type ProtocolsProvider = null | string | string[];
5542
5590
 
5591
+ export declare type QuantityUnit = Pick<Quantity, 'unit' | 'code' | 'system'>;
5592
+
5543
5593
  /**
5544
5594
  * QueryTypes defines the different ways to specify FHIR search parameters.
5545
5595
  *
@@ -5794,6 +5844,8 @@ export declare type ResourceWithCode = Resource & Code;
5794
5844
 
5795
5845
  export declare const RXNORM = "http://www.nlm.nih.gov/research/umls/rxnorm";
5796
5846
 
5847
+ export declare type SamplingInfo = Omit<SampledData, 'data'>;
5848
+
5797
5849
  /**
5798
5850
  * Checks that there is an access policy permitting the given resource interaction, returning the matching policy object.
5799
5851
  * @param resource - The resource being acted upon.
@@ -5970,6 +6022,8 @@ export declare function splitN(str: string, delim: string, n: number): string[];
5970
6022
  */
5971
6023
  export declare function splitSearchOnComma(input: string): string[];
5972
6024
 
6025
+ export declare type StatsFn = (data: number[]) => number | Quantity;
6026
+
5973
6027
  /**
5974
6028
  * Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data.
5975
6029
  * @param stream - The Readable stream to read from.
@@ -6143,6 +6197,17 @@ export declare type SubscriptionRequest = {
6143
6197
  */
6144
6198
  export declare function subsetResource<T extends Resource>(resource: T | undefined, properties: string[]): T | undefined;
6145
6199
 
6200
+ /**
6201
+ * Summarizes a group of Observations into a single computed summary value, with the individual values
6202
+ * preserved in `Observation.component.valueSampledData`.
6203
+ *
6204
+ * @param observations - The Observations to summarize.
6205
+ * @param summaryCode - The code for the summarized value.
6206
+ * @param summarizeFn - Function to summarize the data points.
6207
+ * @returns - The summary Observation resource.
6208
+ */
6209
+ export declare function summarizeObservations(observations: Observation[] | Bundle<Observation>, summaryCode: CodeableConcept, summarizeFn: StatsFn): Observation;
6210
+
6146
6211
  export declare class SymbolAtom implements Atom {
6147
6212
  readonly name: string;
6148
6213
  constructor(name: string);