-
Notifications
You must be signed in to change notification settings - Fork 204
/
visit-operations.ts
31 lines (27 loc) · 1.07 KB
/
visit-operations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { type APIRequestContext, expect } from '@playwright/test';
import { type Visit } from '@openmrs/esm-framework';
import dayjs from 'dayjs';
export const startVisit = async (api: APIRequestContext, patientId: string): Promise<Visit> => {
const visitRes = await api.post('visit', {
data: {
startDatetime: dayjs().subtract(1, 'D').format('YYYY-MM-DDTHH:mm:ss.SSSZZ'),
patient: patientId,
location: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID,
visitType: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed',
attributes: [],
},
});
await expect(visitRes.ok()).toBeTruthy();
return await visitRes.json();
};
export const endVisit = async (api: APIRequestContext, uuid: string) => {
const visitRes = await api.post(`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',
stopDatetime: dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ'),
},
});
return await visitRes.json();
};