@medplum/core 2.0.27 → 2.0.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.
@@ -9,3 +9,14 @@ import { Bundle } from '@medplum/fhirtypes';
9
9
  * @returns transaction type bundle
10
10
  */
11
11
  export declare function convertToTransactionBundle(bundle: Bundle): Bundle;
12
+ /**
13
+ * Topologically sorts a `batch` or `transaction` bundle to improve reference resolution.
14
+ * The bundle is sorted such that a resource is created _before_ references to that resource appear in the bundle.
15
+ *
16
+ * In the event of cycles, this function will first create a POST request for each resource in the cycle, and then will
17
+ * append a PUT request to the bundle. This ensures that each resources in the cycle is visited twice, and all
18
+ * references can be resolved
19
+ * @param bundle Input bundle with type `batch` or `transaction`
20
+ * @returns Bundle of the same type, with Bundle.entry reordered
21
+ */
22
+ export declare function reorderBundle(bundle: Bundle): Bundle;
@@ -1,6 +1,7 @@
1
- import { AccessPolicy, Binary, BulkDataExport, Bundle, Communication, ExtractResource, Identifier, Media, OperationOutcome, Project, ProjectMembership, ProjectMembershipAccess, ProjectSecret, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
1
+ import { AccessPolicy, Attachment, Binary, BulkDataExport, Bundle, Communication, ExtractResource, Identifier, Media, OperationOutcome, Project, ProjectMembership, ProjectMembershipAccess, ProjectSecret, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
2
2
  /** @ts-ignore */
3
3
  import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
4
+ import { EventTarget } from './eventtarget';
4
5
  import { Hl7Message } from './hl7';
5
6
  import { ReadablePromise } from './readablepromise';
6
7
  import { ClientStorage } from './storage';
@@ -107,6 +108,14 @@ export interface MedplumClientOptions {
107
108
  * For Node.js applications, consider the 'node-fetch' package.
108
109
  */
109
110
  fetch?: FetchLike;
111
+ /**
112
+ * The profile name.
113
+ *
114
+ * This is for handling multiple profiles to access different FHIR Servers
115
+ *
116
+ * If undefined, the default profile is "default".
117
+ */
118
+ profile?: string;
110
119
  /**
111
120
  * Storage implementation.
112
121
  *
@@ -996,6 +1005,31 @@ export declare class MedplumClient extends EventTarget {
996
1005
  * @returns The result of the create operation.
997
1006
  */
998
1007
  createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: RequestInit): Promise<T>;
1008
+ /**
1009
+ * Creates a FHIR `Attachment` with the provided data content.
1010
+ *
1011
+ * This is a convenience method for creating a `Binary` resource and then creating an `Attachment` element.
1012
+ *
1013
+ * The `data` parameter can be a string or a `File` object.
1014
+ *
1015
+ * A `File` object often comes from a `<input type="file">` element.
1016
+ *
1017
+ * Example:
1018
+ *
1019
+ * ```typescript
1020
+ * const result = await medplum.createAttachment(myFile, 'test.jpg', 'image/jpeg');
1021
+ * console.log(result);
1022
+ * ```
1023
+ *
1024
+ * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
1025
+ * @category Create
1026
+ * @param data The binary data to upload.
1027
+ * @param filename Optional filename for the binary.
1028
+ * @param contentType Content type for the binary.
1029
+ * @param onProgress Optional callback for progress events.
1030
+ * @returns The result of the create operation.
1031
+ */
1032
+ createAttachment(data: string | File | Blob | Uint8Array, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void): Promise<Attachment>;
999
1033
  /**
1000
1034
  * Creates a FHIR `Binary` resource with the provided data content.
1001
1035
  *
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Content type constants.
3
+ */
4
+ export declare const ContentType: {
5
+ CSS: string;
6
+ FAVICON: string;
7
+ FHIR_JSON: string;
8
+ FORM_URL_ENCODED: string;
9
+ HL7_V2: string;
10
+ HTML: string;
11
+ JAVASCRIPT: string;
12
+ JSON: string;
13
+ JSON_PATCH: string;
14
+ PNG: string;
15
+ SVG: string;
16
+ TEXT: string;
17
+ TYPESCRIPT: string;
18
+ };
@@ -9,3 +9,11 @@ export declare function getRandomString(): string;
9
9
  * @returns The encrypted value in an ArrayBuffer.
10
10
  */
11
11
  export declare function encryptSHA256(str: string): Promise<ArrayBuffer>;
12
+ /**
13
+ * Cross platform random UUID generator
14
+ * Note that this is not intended for production use, but rather for testing
15
+ * This should be replaced when crypto.randomUUID is fully supported
16
+ * See: https://stackoverflow.com/revisions/2117523/28
17
+ * @returns A random UUID.
18
+ */
19
+ export declare function generateId(): string;
@@ -0,0 +1,12 @@
1
+ export interface Event {
2
+ readonly type: string;
3
+ readonly defaultPrevented?: boolean;
4
+ }
5
+ export type EventListener = (e: Event) => void;
6
+ export declare class EventTarget {
7
+ private readonly listeners;
8
+ constructor();
9
+ addEventListener(type: string, callback: EventListener): void;
10
+ removeEventListener(type: string, callback: EventListener): void;
11
+ dispatchEvent(event: Event): boolean;
12
+ }
@@ -18,6 +18,11 @@ export declare class Hl7Context {
18
18
  readonly escapeCharacter: string;
19
19
  readonly subcomponentSeparator: string;
20
20
  constructor(segmentSeparator?: string, fieldSeparator?: string, componentSeparator?: string, repetitionSeparator?: string, escapeCharacter?: string, subcomponentSeparator?: string);
21
+ /**
22
+ * Returns the MSH-1 field value based on the configured separators.
23
+ * @returns The HL7 MSH-1 field value.
24
+ */
25
+ getMsh1(): string;
21
26
  /**
22
27
  * Returns the MSH-2 field value based on the configured separators.
23
28
  * @returns The HL7 MSH-2 field value.
@@ -209,15 +214,29 @@ export declare class Hl7Field {
209
214
  */
210
215
  static parse(text: string, context?: Hl7Context): Hl7Field;
211
216
  }
212
- interface Hl7DateParseOptions {
213
- seconds?: boolean;
217
+ export interface Hl7DateParseOptions {
218
+ /**
219
+ * Default timezone offset.
220
+ * Example: "-0500"
221
+ */
214
222
  tzOffset?: string;
215
223
  }
216
224
  /**
217
225
  * Returns a formatted string representing the date in ISO-8601 format.
218
- * @param hl7Date Date string.
219
- * @param options Optional configuration Object
226
+ *
227
+ * HL7-Definition V2
228
+ * Specifies a point in time using a 24-hour clock notation.
229
+ *
230
+ * Format: YYYY[MM[DD[HH[MM[SS[. S[S[S[S]]]]]]]]][+/-ZZZZ].
231
+ *
232
+ * @param hl7DateTime Date/time string.
233
+ * @param options Optional parsing options.
220
234
  * @returns The date in ISO-8601 format.
221
235
  */
222
- export declare function parseHl7Date(hl7Date: string | undefined, options?: Hl7DateParseOptions): string | undefined;
223
- export {};
236
+ export declare function parseHl7DateTime(hl7DateTime: string | undefined, options?: Hl7DateParseOptions): string | undefined;
237
+ /**
238
+ * Formats an ISO date/time string into an HL7 date/time string.
239
+ * @param isoDate The ISO date/time string.
240
+ * @returns The HL7 date/time string.
241
+ */
242
+ export declare function formatHl7DateTime(isoDate: Date | string): string;
@@ -4,6 +4,9 @@ export * from './bundle';
4
4
  export * from './cache';
5
5
  export * from './client';
6
6
  export * from './config';
7
+ export * from './contenttype';
8
+ export * from './crypto';
9
+ export * from './eventtarget';
7
10
  export * from './fhirlexer';
8
11
  export * from './fhirmapper';
9
12
  export * from './fhirpath';
@@ -20,6 +23,6 @@ export * from './search/search';
20
23
  export * from './sftp';
21
24
  export * from './storage';
22
25
  export * from './types';
26
+ export * from './typeschema/types';
27
+ export * from './typeschema/validation';
23
28
  export * from './utils';
24
- export { loadDataTypes } from './typeschema/types';
25
- export { validate } from './typeschema/validation';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",