diff --git a/e2e/commands/visit-operations.ts b/e2e/commands/visit-operations.ts index 752a07137f..b28b227893 100644 --- a/e2e/commands/visit-operations.ts +++ b/e2e/commands/visit-operations.ts @@ -13,16 +13,16 @@ export const startVisit = async (api: APIRequestContext, patientId: string): Pro }, }); - await expect(visitRes.ok()).toBeTruthy(); + expect(visitRes.ok()).toBeTruthy(); return await visitRes.json(); }; -export const endVisit = async (api: APIRequestContext, uuid: string) => { - const visitRes = await api.post(`visit/${uuid}`, { +export const endVisit = async (api: APIRequestContext, visit: Visit) => { + const visitRes = await api.post(`visit/${visit.uuid}`, { data: { - location: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID, - startDatetime: dayjs().subtract(1, 'D').format('YYYY-MM-DDTHH:mm:ss.SSSZZ'), - visitType: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed', + location: visit.location.uuid, + startDatetime: visit.startDatetime, + visitType: visit.visitType.uuid, stopDatetime: dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ'), }, }); diff --git a/e2e/specs/biometrics.spec.ts b/e2e/specs/biometrics.spec.ts index 9c76114378..44f3c484e3 100644 --- a/e2e/specs/biometrics.spec.ts +++ b/e2e/specs/biometrics.spec.ts @@ -67,6 +67,6 @@ test('Record biometrics', async ({ page }) => { }); test.afterEach(async ({ api }) => { - await endVisit(api, visit.uuid); + await endVisit(api, visit); await deletePatient(api, patient.uuid); }); diff --git a/e2e/specs/clinical-forms.spec.ts b/e2e/specs/clinical-forms.spec.ts index a8941ff10c..748af46dd4 100644 --- a/e2e/specs/clinical-forms.spec.ts +++ b/e2e/specs/clinical-forms.spec.ts @@ -273,6 +273,6 @@ test('Form state is retained when minimizing a form in the workspace', async ({ }); test.afterEach(async ({ api }) => { - await endVisit(api, visit.uuid); + await endVisit(api, visit); await deletePatient(api, patient.uuid); }); diff --git a/e2e/specs/drug-orders.spec.ts b/e2e/specs/drug-orders.spec.ts index 8f9b3518de..f5e1ce18a7 100644 --- a/e2e/specs/drug-orders.spec.ts +++ b/e2e/specs/drug-orders.spec.ts @@ -243,6 +243,6 @@ test('Record, edit and discontinue a drug order', async ({ page }) => { }); test.afterEach(async ({ api }) => { - await endVisit(api, visit.uuid); + await endVisit(api, visit); await deletePatient(api, patient.uuid); }); diff --git a/e2e/specs/lab-orders.spec.ts b/e2e/specs/lab-orders.spec.ts index 09babe1ec4..fbff4ac7a8 100644 --- a/e2e/specs/lab-orders.spec.ts +++ b/e2e/specs/lab-orders.spec.ts @@ -156,6 +156,6 @@ test.describe.serial('Running laboratory order tests sequentially', () => { }); test.afterAll(async ({ api }) => { - await endVisit(api, visit.uuid); + await endVisit(api, visit); await deletePatient(api, patient.uuid); }); diff --git a/e2e/specs/results-viewer.spec.ts b/e2e/specs/results-viewer.spec.ts index 4afba862c4..67f91646ef 100644 --- a/e2e/specs/results-viewer.spec.ts +++ b/e2e/specs/results-viewer.spec.ts @@ -364,6 +364,6 @@ test('Record and edit test results', async ({ page }) => { }); test.afterEach(async ({ api }) => { - await endVisit(api, visit.uuid); + await endVisit(api, visit); await deletePatient(api, patient.uuid); }); diff --git a/e2e/specs/visit-note.spec.ts b/e2e/specs/visit-note.spec.ts index 1ab5a7d24a..fd557d50c4 100644 --- a/e2e/specs/visit-note.spec.ts +++ b/e2e/specs/visit-note.spec.ts @@ -88,6 +88,6 @@ test('Add and delete a visit note', async ({ page }) => { }); test.afterEach(async ({ api }) => { - await endVisit(api, visit.uuid); + await endVisit(api, visit); await deletePatient(api, patient.uuid); }); diff --git a/e2e/specs/vitals.spec.ts b/e2e/specs/vitals.spec.ts index d67f633332..1072c40c1f 100644 --- a/e2e/specs/vitals.spec.ts +++ b/e2e/specs/vitals.spec.ts @@ -80,6 +80,6 @@ test('Record vital signs', async ({ page }) => { }); test.afterEach(async ({ api }) => { - await endVisit(api, visit.uuid); + await endVisit(api, visit); await deletePatient(api, patient.uuid); }); diff --git a/packages/esm-patient-common-lib/src/orders/postOrders.ts b/packages/esm-patient-common-lib/src/orders/postOrders.ts index 83b01b8286..404e54bf3e 100644 --- a/packages/esm-patient-common-lib/src/orders/postOrders.ts +++ b/packages/esm-patient-common-lib/src/orders/postOrders.ts @@ -71,8 +71,14 @@ export async function postOrders(encounterUuid: string, abortController: AbortCo const orders = patientItems[grouping]; for (let i = 0; i < orders.length; i++) { const order = orders[i]; - const dto = postDataPrepFunctions[grouping](order, patientUuid, encounterUuid); - await postOrder(dto, abortController).catch((error) => { + const dataPrepFn = postDataPrepFunctions[grouping]; + + if (typeof dataPrepFn !== 'function') { + console.warn(`The postDataPrep function registered for ${grouping} orders is not a function`); + continue; + } + + await postOrder(dataPrepFn(order, patientUuid, encounterUuid), abortController).catch((error) => { erroredItems.push({ ...order, orderError: error,