@medplum/core 2.0.27 → 2.0.28

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.
@@ -1,4 +1,4 @@
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
4
  import { Hl7Message } from './hl7';
@@ -996,6 +996,31 @@ export declare class MedplumClient extends EventTarget {
996
996
  * @returns The result of the create operation.
997
997
  */
998
998
  createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: RequestInit): Promise<T>;
999
+ /**
1000
+ * Creates a FHIR `Attachment` with the provided data content.
1001
+ *
1002
+ * This is a convenience method for creating a `Binary` resource and then creating an `Attachment` element.
1003
+ *
1004
+ * The `data` parameter can be a string or a `File` object.
1005
+ *
1006
+ * A `File` object often comes from a `<input type="file">` element.
1007
+ *
1008
+ * Example:
1009
+ *
1010
+ * ```typescript
1011
+ * const result = await medplum.createAttachment(myFile, 'test.jpg', 'image/jpeg');
1012
+ * console.log(result);
1013
+ * ```
1014
+ *
1015
+ * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
1016
+ * @category Create
1017
+ * @param data The binary data to upload.
1018
+ * @param filename Optional filename for the binary.
1019
+ * @param contentType Content type for the binary.
1020
+ * @param onProgress Optional callback for progress events.
1021
+ * @returns The result of the create operation.
1022
+ */
1023
+ createAttachment(data: string | File | Blob | Uint8Array, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void): Promise<Attachment>;
999
1024
  /**
1000
1025
  * Creates a FHIR `Binary` resource with the provided data content.
1001
1026
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "2.0.27",
3
+ "version": "2.0.28",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",