@openmrs/esm-emr-api 10.0.1-pre.5434 → 10.0.1-pre.5452

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,3 +1,3 @@
1
- [0] Successfully compiled: 21 files with swc (186.1ms)
1
+ [0] Successfully compiled: 21 files with swc (185.83ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -18,12 +18,17 @@ export declare const attachmentUrl = "/ws/rest/v1/attachment";
18
18
  */
19
19
  export declare function getAttachmentByUuid(attachmentUuid: string, abortController: AbortController): Promise<import("@openmrs/esm-api").FetchResponse<any>>;
20
20
  /**
21
- * Fetches all attachments for a specific patient from the OpenMRS server.
21
+ * Fetches attachments for a specific patient from the OpenMRS server.
22
22
  *
23
23
  * @param patientUuid The UUID of the patient whose attachments should be fetched.
24
24
  * @param includeEncounterless Whether to include attachments that are not associated
25
- * with any encounter.
25
+ * with any encounter. Ignored when `encounterUuid` is set.
26
26
  * @param abortController An AbortController to allow cancellation of the request.
27
+ * @param encounterUuid When set, only attachments recorded on this encounter are returned.
28
+ * The `includeEncounterless` parameter is not sent in that case, because the server
29
+ * ignores the encounter filter whenever `includeEncounterless` is present. Pass a UUID
30
+ * the server can resolve: an unknown encounter UUID makes the server fall back to every
31
+ * attachment of the patient, encounterless ones included.
27
32
  * @returns A Promise that resolves with the FetchResponse containing an array of attachments.
28
33
  *
29
34
  * @example
@@ -32,9 +37,21 @@ export declare function getAttachmentByUuid(attachmentUuid: string, abortControl
32
37
  * const abortController = new AbortController();
33
38
  * const response = await getAttachments('patient-uuid', true, abortController);
34
39
  * console.log(response.data.results);
40
+ *
41
+ * const forEncounter = await getAttachments('patient-uuid', false, abortController, 'encounter-uuid');
35
42
  * ```
36
43
  */
37
- export declare function getAttachments(patientUuid: string, includeEncounterless: boolean, abortController: AbortController): Promise<import("@openmrs/esm-api").FetchResponse<any>>;
44
+ export declare function getAttachments(patientUuid: string, includeEncounterless: boolean, abortController: AbortController, encounterUuid?: string): Promise<import("@openmrs/esm-api").FetchResponse<any>>;
45
+ /**
46
+ * Builds the attachment search URL for a patient. Used by `getAttachments` and `useAttachments`
47
+ * so both request (and cache under) the same key.
48
+ *
49
+ * @param patientUuid The UUID of the patient whose attachments should be fetched.
50
+ * @param includeEncounterless Whether to include attachments that are not associated
51
+ * with any encounter. Ignored when `encounterUuid` is set.
52
+ * @param encounterUuid When set, restricts the search to attachments on this encounter.
53
+ */
54
+ export declare function getAttachmentsUrl(patientUuid: string, includeEncounterless: boolean, encounterUuid?: string): string;
38
55
  /**
39
56
  * Creates a new attachment for a patient by uploading a file to the OpenMRS server.
40
57
  * The file can be provided either as a File object or as base64-encoded content.
@@ -43,6 +60,8 @@ export declare function getAttachments(patientUuid: string, includeEncounterless
43
60
  * @param fileToUpload An object containing the file data and metadata to upload.
44
61
  * Should include `file` (File object) or `base64Content`, plus `fileName` and
45
62
  * `fileDescription`.
63
+ * @param encounterUuid Optional UUID of an existing encounter to record the attachment on.
64
+ * When omitted the attachment is saved without an encounter.
46
65
  * @returns A Promise that resolves with the FetchResponse containing the created
47
66
  * attachment data.
48
67
  *
@@ -54,9 +73,12 @@ export declare function getAttachments(patientUuid: string, includeEncounterless
54
73
  * fileName: 'document.pdf',
55
74
  * fileDescription: 'Patient consent form'
56
75
  * });
76
+ *
77
+ * // Record the attachment on a specific encounter
78
+ * await createAttachment('patient-uuid', uploadedFile, 'encounter-uuid');
57
79
  * ```
58
80
  */
59
- export declare function createAttachment(patientUuid: string, fileToUpload: UploadedFile): Promise<import("@openmrs/esm-api").FetchResponse<any>>;
81
+ export declare function createAttachment(patientUuid: string, fileToUpload: UploadedFile, encounterUuid?: string): Promise<import("@openmrs/esm-api").FetchResponse<any>>;
60
82
  /**
61
83
  * Permanently deletes an attachment from the OpenMRS server. This action cannot
62
84
  * be undone.
@@ -1 +1 @@
1
- {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,qDAAqD;AACrD,eAAO,MAAM,aAAa,2BAA8B,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,0DAI3F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,0DAIlH;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,0DAiBrF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,0DAKnG"}
1
+ {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,qDAAqD;AACrD,eAAO,MAAM,aAAa,2BAA8B,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,0DAI3F;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,OAAO,EAC7B,eAAe,EAAE,eAAe,EAChC,aAAa,CAAC,EAAE,MAAM,0DAKvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,UAK3G;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,MAAM,0DAqB7G;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,0DAKnG"}
@@ -20,12 +20,17 @@
20
20
  });
21
21
  }
22
22
  /**
23
- * Fetches all attachments for a specific patient from the OpenMRS server.
23
+ * Fetches attachments for a specific patient from the OpenMRS server.
24
24
  *
25
25
  * @param patientUuid The UUID of the patient whose attachments should be fetched.
26
26
  * @param includeEncounterless Whether to include attachments that are not associated
27
- * with any encounter.
27
+ * with any encounter. Ignored when `encounterUuid` is set.
28
28
  * @param abortController An AbortController to allow cancellation of the request.
29
+ * @param encounterUuid When set, only attachments recorded on this encounter are returned.
30
+ * The `includeEncounterless` parameter is not sent in that case, because the server
31
+ * ignores the encounter filter whenever `includeEncounterless` is present. Pass a UUID
32
+ * the server can resolve: an unknown encounter UUID makes the server fall back to every
33
+ * attachment of the patient, encounterless ones included.
29
34
  * @returns A Promise that resolves with the FetchResponse containing an array of attachments.
30
35
  *
31
36
  * @example
@@ -34,12 +39,28 @@
34
39
  * const abortController = new AbortController();
35
40
  * const response = await getAttachments('patient-uuid', true, abortController);
36
41
  * console.log(response.data.results);
42
+ *
43
+ * const forEncounter = await getAttachments('patient-uuid', false, abortController, 'encounter-uuid');
37
44
  * ```
38
- */ export function getAttachments(patientUuid, includeEncounterless, abortController) {
39
- return openmrsFetch(`${attachmentUrl}?patient=${patientUuid}&includeEncounterless=${includeEncounterless}`, {
45
+ */ export function getAttachments(patientUuid, includeEncounterless, abortController, encounterUuid) {
46
+ return openmrsFetch(getAttachmentsUrl(patientUuid, includeEncounterless, encounterUuid), {
40
47
  signal: abortController.signal
41
48
  });
42
49
  }
50
+ /**
51
+ * Builds the attachment search URL for a patient. Used by `getAttachments` and `useAttachments`
52
+ * so both request (and cache under) the same key.
53
+ *
54
+ * @param patientUuid The UUID of the patient whose attachments should be fetched.
55
+ * @param includeEncounterless Whether to include attachments that are not associated
56
+ * with any encounter. Ignored when `encounterUuid` is set.
57
+ * @param encounterUuid When set, restricts the search to attachments on this encounter.
58
+ */ export function getAttachmentsUrl(patientUuid, includeEncounterless, encounterUuid) {
59
+ if (encounterUuid) {
60
+ return `${attachmentUrl}?patient=${patientUuid}&encounter=${encounterUuid}`;
61
+ }
62
+ return `${attachmentUrl}?patient=${patientUuid}&includeEncounterless=${includeEncounterless}`;
63
+ }
43
64
  /**
44
65
  * Creates a new attachment for a patient by uploading a file to the OpenMRS server.
45
66
  * The file can be provided either as a File object or as base64-encoded content.
@@ -48,6 +69,8 @@
48
69
  * @param fileToUpload An object containing the file data and metadata to upload.
49
70
  * Should include `file` (File object) or `base64Content`, plus `fileName` and
50
71
  * `fileDescription`.
72
+ * @param encounterUuid Optional UUID of an existing encounter to record the attachment on.
73
+ * When omitted the attachment is saved without an encounter.
51
74
  * @returns A Promise that resolves with the FetchResponse containing the created
52
75
  * attachment data.
53
76
  *
@@ -59,11 +82,17 @@
59
82
  * fileName: 'document.pdf',
60
83
  * fileDescription: 'Patient consent form'
61
84
  * });
85
+ *
86
+ * // Record the attachment on a specific encounter
87
+ * await createAttachment('patient-uuid', uploadedFile, 'encounter-uuid');
62
88
  * ```
63
- */ export async function createAttachment(patientUuid, fileToUpload) {
89
+ */ export async function createAttachment(patientUuid, fileToUpload, encounterUuid) {
64
90
  const formData = new FormData();
65
91
  formData.append('fileCaption', fileToUpload.fileDescription);
66
92
  formData.append('patient', patientUuid);
93
+ if (encounterUuid) {
94
+ formData.append('encounter', encounterUuid);
95
+ }
67
96
  if (fileToUpload.file) {
68
97
  formData.append('file', fileToUpload.file, fileToUpload.fileName);
69
98
  } else {
package/mock-jest.ts CHANGED
@@ -2,6 +2,12 @@ export const setCurrentVisit = jest.fn();
2
2
  export const attachmentUrl = '/ws/rest/v1/attachment';
3
3
  export const getAttachmentByUuid = jest.fn();
4
4
  export const getAttachments = jest.fn();
5
+ export const getAttachmentsUrl = jest.fn(
6
+ (patientUuid: string, includeEncounterless: boolean, encounterUuid?: string) =>
7
+ encounterUuid
8
+ ? `${attachmentUrl}?patient=${patientUuid}&encounter=${encounterUuid}`
9
+ : `${attachmentUrl}?patient=${patientUuid}&includeEncounterless=${includeEncounterless}`,
10
+ );
5
11
  export const createAttachment = jest.fn();
6
12
  export const deleteAttachmentPermanently = jest.fn();
7
13
  export const updateVisit = jest.fn();
package/mock.ts CHANGED
@@ -4,6 +4,11 @@ export const setCurrentVisit = vi.fn();
4
4
  export const attachmentUrl = '/ws/rest/v1/attachment';
5
5
  export const getAttachmentByUuid = vi.fn();
6
6
  export const getAttachments = vi.fn();
7
+ export const getAttachmentsUrl = vi.fn((patientUuid: string, includeEncounterless: boolean, encounterUuid?: string) =>
8
+ encounterUuid
9
+ ? `${attachmentUrl}?patient=${patientUuid}&encounter=${encounterUuid}`
10
+ : `${attachmentUrl}?patient=${patientUuid}&includeEncounterless=${includeEncounterless}`,
11
+ );
7
12
  export const createAttachment = vi.fn();
8
13
  export const deleteAttachmentPermanently = vi.fn();
9
14
  export const updateVisit = vi.fn();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-emr-api",
3
- "version": "10.0.1-pre.5434",
3
+ "version": "10.0.1-pre.5452",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The javascript module for interacting with the OpenMRS API",
6
6
  "type": "module",
@@ -58,14 +58,14 @@
58
58
  "lodash-es": "^4.17.21"
59
59
  },
60
60
  "peerDependencies": {
61
- "@openmrs/esm-api": "^10.0.1-pre.5434",
62
- "@openmrs/esm-offline": "^10.0.1-pre.5434",
63
- "@openmrs/esm-state": "^10.0.1-pre.5434"
61
+ "@openmrs/esm-api": "^10.0.1-pre.5452",
62
+ "@openmrs/esm-offline": "^10.0.1-pre.5452",
63
+ "@openmrs/esm-state": "^10.0.1-pre.5452"
64
64
  },
65
65
  "devDependencies": {
66
- "@openmrs/esm-api": "10.0.1-pre.5434",
67
- "@openmrs/esm-offline": "10.0.1-pre.5434",
68
- "@openmrs/esm-state": "10.0.1-pre.5434",
66
+ "@openmrs/esm-api": "10.0.1-pre.5452",
67
+ "@openmrs/esm-offline": "10.0.1-pre.5452",
68
+ "@openmrs/esm-state": "10.0.1-pre.5452",
69
69
  "@swc/cli": "0.8.1",
70
70
  "@swc/core": "1.15.21",
71
71
  "@vitest/coverage-v8": "^4.1.2",
@@ -0,0 +1,105 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { openmrsFetch } from '@openmrs/esm-api';
3
+ import { attachmentUrl, createAttachment, getAttachments, getAttachmentsUrl } from './attachments';
4
+
5
+ vi.mock('@openmrs/esm-api', async (importOriginal) => ({
6
+ ...(await importOriginal<typeof import('@openmrs/esm-api')>()),
7
+ openmrsFetch: vi.fn(),
8
+ }));
9
+
10
+ const mockOpenmrsFetch = vi.mocked(openmrsFetch);
11
+
12
+ describe('getAttachmentsUrl', () => {
13
+ it('filters by patient and includeEncounterless by default', () => {
14
+ expect(getAttachmentsUrl('patient-uuid', true)).toBe(
15
+ `${attachmentUrl}?patient=patient-uuid&includeEncounterless=true`,
16
+ );
17
+ expect(getAttachmentsUrl('patient-uuid', false)).toBe(
18
+ `${attachmentUrl}?patient=patient-uuid&includeEncounterless=false`,
19
+ );
20
+ });
21
+
22
+ it('filters by encounter and drops includeEncounterless when an encounter is given', () => {
23
+ expect(getAttachmentsUrl('patient-uuid', true, 'encounter-uuid')).toBe(
24
+ `${attachmentUrl}?patient=patient-uuid&encounter=encounter-uuid`,
25
+ );
26
+ });
27
+ });
28
+
29
+ describe('getAttachments', () => {
30
+ beforeEach(() => {
31
+ mockOpenmrsFetch.mockReset();
32
+ });
33
+
34
+ it('requests the patient attachments', () => {
35
+ const abortController = new AbortController();
36
+ getAttachments('patient-uuid', true, abortController);
37
+
38
+ expect(mockOpenmrsFetch).toHaveBeenCalledWith(`${attachmentUrl}?patient=patient-uuid&includeEncounterless=true`, {
39
+ signal: abortController.signal,
40
+ });
41
+ });
42
+
43
+ it('requests only the attachments on an encounter when one is given', () => {
44
+ const abortController = new AbortController();
45
+ getAttachments('patient-uuid', true, abortController, 'encounter-uuid');
46
+
47
+ expect(mockOpenmrsFetch).toHaveBeenCalledWith(`${attachmentUrl}?patient=patient-uuid&encounter=encounter-uuid`, {
48
+ signal: abortController.signal,
49
+ });
50
+ });
51
+ });
52
+
53
+ describe('createAttachment', () => {
54
+ const file = new File(['content'], 'photo.png', { type: 'image/png' });
55
+
56
+ beforeEach(() => {
57
+ mockOpenmrsFetch.mockReset();
58
+ });
59
+
60
+ function submittedFormData(): FormData {
61
+ const [, options] = mockOpenmrsFetch.mock.calls[0];
62
+ return options.body as FormData;
63
+ }
64
+
65
+ it('posts the file, caption and patient', async () => {
66
+ await createAttachment('patient-uuid', {
67
+ file,
68
+ base64Content: '',
69
+ fileName: 'photo.png',
70
+ fileType: 'image/png',
71
+ fileDescription: 'Wound photo',
72
+ });
73
+
74
+ expect(mockOpenmrsFetch).toHaveBeenCalledWith(attachmentUrl, expect.objectContaining({ method: 'POST' }));
75
+ const formData = submittedFormData();
76
+ expect(formData.get('patient')).toBe('patient-uuid');
77
+ expect(formData.get('fileCaption')).toBe('Wound photo');
78
+ expect(formData.get('file')).toBeInstanceOf(File);
79
+ expect(formData.has('encounter')).toBe(false);
80
+ expect(formData.has('base64Content')).toBe(false);
81
+ });
82
+
83
+ it('records the attachment on the encounter when one is given', async () => {
84
+ await createAttachment(
85
+ 'patient-uuid',
86
+ { file, base64Content: '', fileName: 'photo.png', fileType: 'image/png', fileDescription: 'Wound photo' },
87
+ 'encounter-uuid',
88
+ );
89
+
90
+ expect(submittedFormData().get('encounter')).toBe('encounter-uuid');
91
+ });
92
+
93
+ it('sends base64 content with a placeholder file when no File is given', async () => {
94
+ await createAttachment('patient-uuid', {
95
+ base64Content: 'data:image/png;base64,AAAA',
96
+ fileName: 'capture.png',
97
+ fileType: 'image/png',
98
+ fileDescription: 'Webcam capture',
99
+ });
100
+
101
+ const formData = submittedFormData();
102
+ expect(formData.get('base64Content')).toBe('data:image/png;base64,AAAA');
103
+ expect((formData.get('file') as File).name).toBe('capture.png');
104
+ });
105
+ });
@@ -27,12 +27,17 @@ export function getAttachmentByUuid(attachmentUuid: string, abortController: Abo
27
27
  }
28
28
 
29
29
  /**
30
- * Fetches all attachments for a specific patient from the OpenMRS server.
30
+ * Fetches attachments for a specific patient from the OpenMRS server.
31
31
  *
32
32
  * @param patientUuid The UUID of the patient whose attachments should be fetched.
33
33
  * @param includeEncounterless Whether to include attachments that are not associated
34
- * with any encounter.
34
+ * with any encounter. Ignored when `encounterUuid` is set.
35
35
  * @param abortController An AbortController to allow cancellation of the request.
36
+ * @param encounterUuid When set, only attachments recorded on this encounter are returned.
37
+ * The `includeEncounterless` parameter is not sent in that case, because the server
38
+ * ignores the encounter filter whenever `includeEncounterless` is present. Pass a UUID
39
+ * the server can resolve: an unknown encounter UUID makes the server fall back to every
40
+ * attachment of the patient, encounterless ones included.
36
41
  * @returns A Promise that resolves with the FetchResponse containing an array of attachments.
37
42
  *
38
43
  * @example
@@ -41,14 +46,37 @@ export function getAttachmentByUuid(attachmentUuid: string, abortController: Abo
41
46
  * const abortController = new AbortController();
42
47
  * const response = await getAttachments('patient-uuid', true, abortController);
43
48
  * console.log(response.data.results);
49
+ *
50
+ * const forEncounter = await getAttachments('patient-uuid', false, abortController, 'encounter-uuid');
44
51
  * ```
45
52
  */
46
- export function getAttachments(patientUuid: string, includeEncounterless: boolean, abortController: AbortController) {
47
- return openmrsFetch(`${attachmentUrl}?patient=${patientUuid}&includeEncounterless=${includeEncounterless}`, {
53
+ export function getAttachments(
54
+ patientUuid: string,
55
+ includeEncounterless: boolean,
56
+ abortController: AbortController,
57
+ encounterUuid?: string,
58
+ ) {
59
+ return openmrsFetch(getAttachmentsUrl(patientUuid, includeEncounterless, encounterUuid), {
48
60
  signal: abortController.signal,
49
61
  });
50
62
  }
51
63
 
64
+ /**
65
+ * Builds the attachment search URL for a patient. Used by `getAttachments` and `useAttachments`
66
+ * so both request (and cache under) the same key.
67
+ *
68
+ * @param patientUuid The UUID of the patient whose attachments should be fetched.
69
+ * @param includeEncounterless Whether to include attachments that are not associated
70
+ * with any encounter. Ignored when `encounterUuid` is set.
71
+ * @param encounterUuid When set, restricts the search to attachments on this encounter.
72
+ */
73
+ export function getAttachmentsUrl(patientUuid: string, includeEncounterless: boolean, encounterUuid?: string) {
74
+ if (encounterUuid) {
75
+ return `${attachmentUrl}?patient=${patientUuid}&encounter=${encounterUuid}`;
76
+ }
77
+ return `${attachmentUrl}?patient=${patientUuid}&includeEncounterless=${includeEncounterless}`;
78
+ }
79
+
52
80
  /**
53
81
  * Creates a new attachment for a patient by uploading a file to the OpenMRS server.
54
82
  * The file can be provided either as a File object or as base64-encoded content.
@@ -57,6 +85,8 @@ export function getAttachments(patientUuid: string, includeEncounterless: boolea
57
85
  * @param fileToUpload An object containing the file data and metadata to upload.
58
86
  * Should include `file` (File object) or `base64Content`, plus `fileName` and
59
87
  * `fileDescription`.
88
+ * @param encounterUuid Optional UUID of an existing encounter to record the attachment on.
89
+ * When omitted the attachment is saved without an encounter.
60
90
  * @returns A Promise that resolves with the FetchResponse containing the created
61
91
  * attachment data.
62
92
  *
@@ -68,14 +98,21 @@ export function getAttachments(patientUuid: string, includeEncounterless: boolea
68
98
  * fileName: 'document.pdf',
69
99
  * fileDescription: 'Patient consent form'
70
100
  * });
101
+ *
102
+ * // Record the attachment on a specific encounter
103
+ * await createAttachment('patient-uuid', uploadedFile, 'encounter-uuid');
71
104
  * ```
72
105
  */
73
- export async function createAttachment(patientUuid: string, fileToUpload: UploadedFile) {
106
+ export async function createAttachment(patientUuid: string, fileToUpload: UploadedFile, encounterUuid?: string) {
74
107
  const formData = new FormData();
75
108
 
76
109
  formData.append('fileCaption', fileToUpload.fileDescription);
77
110
  formData.append('patient', patientUuid);
78
111
 
112
+ if (encounterUuid) {
113
+ formData.append('encounter', encounterUuid);
114
+ }
115
+
79
116
  if (fileToUpload.file) {
80
117
  formData.append('file', fileToUpload.file, fileToUpload.fileName);
81
118
  } else {