@openmrs/esm-dispensing-app 1.9.2-pre.889 → 1.9.2-pre.897

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.
package/.eslintrc CHANGED
@@ -14,6 +14,14 @@
14
14
  },
15
15
  "plugins": ["@typescript-eslint", "import", "react-hooks", "unused-imports"],
16
16
  "root": true,
17
+ "overrides": [
18
+ {
19
+ "files": ["e2e/**/*.ts"],
20
+ "rules": {
21
+ "react-hooks/rules-of-hooks": "off"
22
+ }
23
+ }
24
+ ],
17
25
  "rules": {
18
26
  "react-hooks/exhaustive-deps": "warn",
19
27
  "react-hooks/rules-of-hooks": "error",
@@ -0,0 +1 @@
1
+ {"hash":"c4771faf2947f17f","duration":41501}
@@ -40,4 +40,4 @@ Entrypoints:
40
40
  main (568 KiB)
41
41
  main.js
42
42
 
43
- webpack 5.99.9 compiled with 2 warnings in 42736 ms
43
+ webpack 5.99.9 compiled with 2 warnings in 39350 ms
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.2.0"},"pages":[{"component":"dispensing","route":"dispensing","online":true,"offline":true}],"extensions":[{"name":"dispensing-link","slot":"app-menu-slot","component":"dispensingLink","online":true,"offline":true},{"name":"patient-diagnoses","component":"patientDiagnoses","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"patient-conditions","component":"patientConditions","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"dispensing-dashboard","slot":"dispensing-dashboard-slot","component":"dispensingDashboard","online":true,"offline":true},{"name":"dispensing-dashboard-link","component":"dispensingDashboardLink","meta":{"name":"dispensing","slot":"dispensing-dashboard-slot","title":"Dispensing"}},{"name":"dispense-action-button","slot":"prescription-action-button-slot","component":"dispenseActionButton"},{"name":"pause-action-button","slot":"prescription-action-button-slot","component":"pauseActionButton"},{"name":"close-action-button","slot":"prescription-action-button-slot","component":"closeActionButton"}],"workspaces":[{"name":"close-dispense-workspace","component":"closeDispenseWorkspace","type":"dispense","title":"Close prescription"},{"name":"pause-dispense-workspace","component":"pauseDispenseWorkspace","type":"dispense","title":"Pause prescription"},{"name":"dispense-workspace","component":"dispenseWorkspace","type":"dispense","title":"Dispense prescription","width":"wider"}],"modals":[{"name":"prescription-print-preview-modal","component":"printPrescriptionPreviewModal"},{"name":"delete-confirm-modal","component":"deleteConfirmModal"}],"version":"1.9.2-pre.889"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.2.0"},"pages":[{"component":"dispensing","route":"dispensing","online":true,"offline":true}],"extensions":[{"name":"dispensing-link","slot":"app-menu-slot","component":"dispensingLink","online":true,"offline":true},{"name":"patient-diagnoses","component":"patientDiagnoses","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"patient-conditions","component":"patientConditions","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"dispensing-dashboard","slot":"dispensing-dashboard-slot","component":"dispensingDashboard","online":true,"offline":true},{"name":"dispensing-dashboard-link","component":"dispensingDashboardLink","meta":{"name":"dispensing","slot":"dispensing-dashboard-slot","title":"Dispensing"}},{"name":"dispense-action-button","slot":"prescription-action-button-slot","component":"dispenseActionButton"},{"name":"pause-action-button","slot":"prescription-action-button-slot","component":"pauseActionButton"},{"name":"close-action-button","slot":"prescription-action-button-slot","component":"closeActionButton"}],"workspaces":[{"name":"close-dispense-workspace","component":"closeDispenseWorkspace","type":"dispense","title":"Close prescription"},{"name":"pause-dispense-workspace","component":"pauseDispenseWorkspace","type":"dispense","title":"Pause prescription"},{"name":"dispense-workspace","component":"dispenseWorkspace","type":"dispense","title":"Dispense prescription","width":"wider"}],"modals":[{"name":"prescription-print-preview-modal","component":"printPrescriptionPreviewModal"},{"name":"delete-confirm-modal","component":"deleteConfirmModal"}],"version":"1.9.2-pre.897"}
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/await-thenable */
2
1
  import { type APIRequestContext, expect } from '@playwright/test';
3
2
  import { type Order } from '@openmrs/esm-patient-common-lib';
4
3
  import { type Encounter } from './types';
@@ -35,10 +34,10 @@ export const generateRandomDrugOrder = async (
35
34
  orderReasonNonCoded: 'order reason',
36
35
  },
37
36
  });
38
- await expect(order.ok()).toBeTruthy();
37
+ expect(order.ok()).toBeTruthy();
39
38
  return await order.json();
40
39
  };
41
40
 
42
41
  export const deleteDrugOrder = async (api: APIRequestContext, uuid: string) => {
43
- await api.delete(`order/${uuid}`, { data: {} });
42
+ await api.delete(`order/${uuid}`);
44
43
  };
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/await-thenable */
2
1
  import { type APIRequestContext, expect } from '@playwright/test';
3
2
  import { type Encounter } from './types';
4
3
  import { type Visit } from '@openmrs/esm-framework';
@@ -52,10 +51,10 @@ export const createEncounter = async (
52
51
  encounterType: '39da3525-afe4-45ff-8977-c53b7b359158',
53
52
  },
54
53
  });
55
- await expect(encounterRes.ok()).toBeTruthy();
54
+ expect(encounterRes.ok()).toBeTruthy();
56
55
  return await encounterRes.json();
57
56
  };
58
57
 
59
58
  export const deleteEncounter = async (api: APIRequestContext, uuid: string) => {
60
- await api.delete(`encounter/${uuid}`, { data: {} });
59
+ await api.delete(`encounter/${uuid}`);
61
60
  };
@@ -1,5 +1,5 @@
1
- export * from './patient-operations';
2
- export * from './visit-operations';
3
- export * from './encounter-operations';
4
1
  export * from './drug-order-operations';
2
+ export * from './encounter-operations';
3
+ export * from './patient-operations';
5
4
  export * from './provider-operations';
5
+ export * from './visit-operations';
@@ -0,0 +1,93 @@
1
+ import dayjs from 'dayjs';
2
+ import { type APIRequestContext, expect } from '@playwright/test';
3
+ import { type Patient } from '.';
4
+ import { type Provider } from './types';
5
+ import { MedicationDispenseStatus, type MedicationDispense } from '../../src/types';
6
+
7
+ export const generateMedicationDispense = async (
8
+ fhirApi: APIRequestContext,
9
+ patient: Patient,
10
+ provider: Provider,
11
+ medicationRequestUuid: string,
12
+ ): Promise<MedicationDispense> => {
13
+ const dispense = await fhirApi.post('MedicationDispense', {
14
+ data: {
15
+ resourceType: 'MedicationDispense',
16
+ status: MedicationDispenseStatus.completed,
17
+ authorizingPrescription: [
18
+ {
19
+ reference: `MedicationRequest/${medicationRequestUuid}`,
20
+ type: 'MedicationRequest',
21
+ },
22
+ ],
23
+ medicationReference: {
24
+ reference: 'Medication/09e58895-e7f0-4649-b7c0-e665c5c08e93',
25
+ type: 'Medication',
26
+ display: 'Aspirin 81mg',
27
+ },
28
+ subject: {
29
+ reference: `Patient/${patient.uuid}`,
30
+ },
31
+ performer: [
32
+ {
33
+ actor: {
34
+ reference: `Practitioner/${provider.uuid}`,
35
+ },
36
+ },
37
+ ],
38
+ location: {
39
+ reference: `Location/${process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID}`,
40
+ },
41
+ whenHandedOver: dayjs().format(),
42
+ quantity: {
43
+ value: 5,
44
+ code: '1513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
45
+ unit: 'Tablet',
46
+ },
47
+ dosageInstruction: [
48
+ {
49
+ timing: {
50
+ repeat: {
51
+ durationUnit: 'd',
52
+ },
53
+ code: {
54
+ coding: [
55
+ {
56
+ code: '160862AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
57
+ display: 'Once daily',
58
+ },
59
+ ],
60
+ text: 'Once daily',
61
+ },
62
+ },
63
+ asNeededBoolean: false,
64
+ route: {
65
+ coding: [
66
+ {
67
+ code: '160240AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
68
+ display: 'Oral',
69
+ },
70
+ ],
71
+ text: 'Oral',
72
+ },
73
+ doseAndRate: [
74
+ {
75
+ doseQuantity: {
76
+ value: 1,
77
+ unit: 'Milligram',
78
+ code: '161553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
79
+ },
80
+ },
81
+ ],
82
+ },
83
+ ],
84
+ },
85
+ });
86
+
87
+ expect(dispense.ok()).toBeTruthy();
88
+ return await dispense.json();
89
+ };
90
+
91
+ export const deleteMedicationDispense = async (fhirApi: APIRequestContext, id: string) => {
92
+ await fhirApi.delete(`MedicationDispense/${id}`);
93
+ };
@@ -51,8 +51,7 @@ export const generateRandomPatient = async (api: APIRequestContext): Promise<Pat
51
51
  data: {},
52
52
  });
53
53
 
54
- // eslint-disable-next-line @typescript-eslint/await-thenable
55
- await expect(identifierRes.ok()).toBeTruthy();
54
+ expect(identifierRes.ok()).toBeTruthy();
56
55
  const { identifier } = await identifierRes.json();
57
56
 
58
57
  const patientRes = await api.post('patient', {
@@ -94,8 +93,7 @@ export const generateRandomPatient = async (api: APIRequestContext): Promise<Pat
94
93
  },
95
94
  });
96
95
 
97
- // eslint-disable-next-line @typescript-eslint/await-thenable
98
- await expect(patientRes.ok()).toBeTruthy();
96
+ expect(patientRes.ok()).toBeTruthy();
99
97
  return await patientRes.json();
100
98
  };
101
99
 
@@ -105,5 +103,5 @@ export const getPatient = async (api: APIRequestContext, uuid: string): Promise<
105
103
  };
106
104
 
107
105
  export const deletePatient = async (api: APIRequestContext, uuid: string) => {
108
- await api.delete(`patient/${uuid}`, { data: {} });
106
+ await api.delete(`patient/${uuid}`);
109
107
  };
@@ -1,12 +1,9 @@
1
- /* eslint-disable @typescript-eslint/await-thenable */
2
1
  import { type APIRequestContext, expect } from '@playwright/test';
3
2
  import { type Provider } from './types';
4
3
 
5
4
  export const getProvider = async (api: APIRequestContext): Promise<Provider> => {
6
- const providerRes = await api.get('provider?q=admin', {
7
- data: {},
8
- });
9
- await expect(providerRes.ok()).toBeTruthy();
5
+ const providerRes = await api.get('provider?q=admin');
6
+ expect(providerRes.ok()).toBeTruthy();
10
7
  const { results } = await providerRes.json();
11
8
  return await results[0];
12
9
  };
@@ -16,15 +16,16 @@ export const startVisit = async (api: APIRequestContext, patientId: string): Pro
16
16
  });
17
17
 
18
18
  expect(visitRes.ok()).toBeTruthy();
19
- return await visitRes.json();
19
+ const visit = await visitRes.json();
20
+ return await getVisit(api, visit.uuid);
20
21
  };
21
22
 
22
23
  export const endVisit = async (api: APIRequestContext, visit: Visit) => {
23
24
  const visitRes = await api.post(`visit/${visit.uuid}`, {
24
25
  data: {
25
- location: visit.location.uuid,
26
- startDatetime: visit.startDatetime,
27
- visitType: visit.visitType.uuid,
26
+ location: visit?.location?.uuid,
27
+ startDatetime: visit?.startDatetime,
28
+ visitType: visit?.visitType?.uuid,
28
29
  stopDatetime: dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ'),
29
30
  },
30
31
  });
package/e2e/core/test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type APIRequestContext, type Page, test as base } from '@playwright/test';
2
- import { api } from '../fixtures';
2
+ import { api, fhirApi } from '../fixtures';
3
3
  import { type Patient } from '../types';
4
4
  import { generateRandomPatient, deletePatient } from '../commands';
5
5
 
@@ -16,10 +16,12 @@ export interface CustomTestFixtures {
16
16
 
17
17
  export interface CustomWorkerFixtures {
18
18
  api: APIRequestContext;
19
+ fhirApi: APIRequestContext;
19
20
  }
20
21
 
21
22
  export const test = base.extend<CustomTestFixtures, CustomWorkerFixtures>({
22
23
  api: [api, { scope: 'worker' }],
24
+ fhirApi: [fhirApi, { scope: 'worker' }],
23
25
  patient: [
24
26
  async ({ api }, use) => {
25
27
  const patient = await generateRandomPatient(api);
@@ -1,4 +1,3 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
1
  import { type APIRequestContext, type PlaywrightWorkerArgs, type WorkerFixture } from '@playwright/test';
3
2
 
4
3
  /**
@@ -23,5 +22,5 @@ export const api: WorkerFixture<APIRequestContext, PlaywrightWorkerArgs> = async
23
22
  },
24
23
  });
25
24
 
26
- await use(ctx);
25
+ use(ctx);
27
26
  };
@@ -0,0 +1,27 @@
1
+ import { type APIRequestContext, type PlaywrightWorkerArgs, type WorkerFixture } from '@playwright/test';
2
+
3
+ /**
4
+ * A fixture which initializes an [`APIRequestContext`](https://playwright.dev/docs/api/class-apirequestcontext)
5
+ * that is bound to the configured OpenMRS API server. The context is automatically authenticated
6
+ * using the configured admin account.
7
+ *
8
+ * Use the request context like this:
9
+ * ```ts
10
+ * test('your test', async ({ api }) => {
11
+ * const res = await api.get('patient/1234');
12
+ * await expect(res.ok()).toBeTruthy();
13
+ * });
14
+ * ```
15
+ */
16
+
17
+ export const fhirApi: WorkerFixture<APIRequestContext, PlaywrightWorkerArgs> = async ({ playwright }, use) => {
18
+ const fhirctx = await playwright.request.newContext({
19
+ baseURL: `${process.env.E2E_BASE_URL}/ws/fhir2/R4/`,
20
+ httpCredentials: {
21
+ username: process.env.E2E_USER_ADMIN_USERNAME,
22
+ password: process.env.E2E_USER_ADMIN_PASSWORD,
23
+ },
24
+ });
25
+
26
+ use(fhirctx);
27
+ };
@@ -1 +1,2 @@
1
1
  export * from './api';
2
+ export * from './fhirApi';
@@ -0,0 +1,80 @@
1
+ import { expect } from '@playwright/test';
2
+ import { type Visit } from '@openmrs/esm-framework';
3
+ import { type Order } from '@openmrs/esm-patient-common-lib';
4
+ import {
5
+ createEncounter,
6
+ deleteDrugOrder,
7
+ deleteEncounter,
8
+ endVisit,
9
+ generateRandomDrugOrder,
10
+ getProvider,
11
+ startVisit,
12
+ } from '../commands';
13
+ import { deleteMedicationDispense, generateMedicationDispense } from '../commands/medication-dispense-operations';
14
+ import { DispensingPage } from '../pages';
15
+ import { test } from '../core';
16
+ import { type Encounter, type Provider } from '../commands/types';
17
+ import { type MedicationDispense } from '../../src/types';
18
+
19
+ let drugOrder: Order;
20
+ let encounter: Encounter;
21
+ let medicationDispense: MedicationDispense;
22
+ let orderer: Provider;
23
+ let visit: Visit;
24
+
25
+ test.beforeEach(async ({ fhirApi, api, patient }) => {
26
+ visit = await startVisit(api, patient.uuid);
27
+ orderer = await getProvider(api);
28
+ encounter = await createEncounter(api, patient.uuid, orderer.uuid, visit);
29
+ drugOrder = await generateRandomDrugOrder(api, patient.uuid, encounter, orderer.uuid);
30
+ medicationDispense = await generateMedicationDispense(fhirApi, patient, orderer, drugOrder.uuid);
31
+ });
32
+
33
+ test('Delete medication dispense', async ({ fhirApi, page, patient }) => {
34
+ const dispensingPage = new DispensingPage(page);
35
+
36
+ await test.step('When I navigate to the dispensing app', async () => {
37
+ await dispensingPage.goTo();
38
+ await expect(page).toHaveURL(`/openmrs/spa/dispensing`);
39
+ });
40
+
41
+ await test.step('And I click on the "Active prescriptions" tab', async () => {
42
+ await page.getByRole('tab', { name: 'Active prescriptions' }).click();
43
+ await expect(page.getByRole('tab', { name: 'Active prescriptions' })).toHaveAttribute('aria-selected', 'true');
44
+ });
45
+
46
+ await test.step('Then I should see the prescription in the table', async () => {
47
+ await expect(page.getByRole('row', { name: 'Expand current row' }).first()).toBeVisible();
48
+ });
49
+
50
+ await test.step('And I expand the prescription row', async () => {
51
+ await page.getByRole('row', { name: 'Expand current row' }).getByLabel('Expand current row').first().click();
52
+ });
53
+
54
+ await test.step('And I navigate to the History and comments tab', async () => {
55
+ await page.getByRole('tab', { name: 'History and comments' }).click();
56
+ });
57
+
58
+ await test.step('And I click on the "Options" menu', async () => {
59
+ await page.getByRole('button', { name: 'Options' }).first().click();
60
+ });
61
+
62
+ await test.step('And I select the "Delete" option', async () => {
63
+ await page.getByRole('menuitem', { name: 'Delete' }).click();
64
+ });
65
+
66
+ await test.step('And I select the "Delete" button in the modal', async () => {
67
+ await page.getByRole('button', { name: 'danger Delete' }).click();
68
+ });
69
+
70
+ await test.step('Then I should see a success notification confirming the deletion', async () => {
71
+ await expect(page.getByText(/medication dispense was deleted successfully/i)).toBeVisible();
72
+ });
73
+ });
74
+
75
+ test.afterEach(async ({ api, fhirApi }) => {
76
+ await deleteMedicationDispense(fhirApi, medicationDispense.id);
77
+ await deleteEncounter(api, encounter.uuid);
78
+ await deleteDrugOrder(api, drugOrder.uuid);
79
+ await endVisit(api, visit);
80
+ });
@@ -1,5 +1,4 @@
1
- # syntax=docker/dockerfile:1.3
2
- FROM --platform=$BUILDPLATFORM node:18-alpine as dev
1
+ FROM --platform=$BUILDPLATFORM node:22-alpine as dev
3
2
 
4
3
  ARG APP_SHELL_VERSION=next
5
4
 
@@ -4,45 +4,40 @@
4
4
  script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5
5
  # create a temporary working directory
6
6
  working_dir=$(mktemp -d "${TMPDIR:-/tmp/}openmrs-e2e-frontends.XXXXXXXXXX")
7
- # get a list of all the apps in this workspace
8
- apps=$(yarn workspaces list --json | jq -r 'select(.name | test("-app")) | .name')
9
- # this array will hold all of the packed app names
10
- app_names=()
7
+ # cleanup temp directory on exit
8
+ trap 'rm -rf "$working_dir"' EXIT
9
+ # get the app name
10
+ app_name=$(jq -r '.name' "$script_dir/../../../package.json")
11
11
 
12
- echo "Packing local dispensing app..."
13
- yarn workspace "@openmrs/esm-dispensing-app" pack -o "$working_dir/_openmrs_esm_dispensing_app.tgz" >/dev/null
14
- app_names+=("_openmrs_esm_dispensing_app.tgz")
12
+ echo "Creating packed archive of the app..."
13
+ # @openmrs/esm-whatever -> _openmrs_esm_whatever
14
+ packed_app_name=$(echo "$app_name" | tr '[:punct:]' '_');
15
+ # run yarn pack for our app and add it to the working directory
16
+ yarn pack -o "$working_dir/$packed_app_name.tgz" >/dev/null;
17
+ echo "Created packed app archives"
15
18
 
16
- echo "Packing other apps..."
17
- for app in $apps; do
18
- if [ "$app" != "@openmrs/esm-dispensing-app" ]; then
19
- app_name=$(echo "$app" | tr '[:punct:]' '_')
20
- app_names+=("$app_name.tgz")
21
- yarn workspace "$app" pack -o "$working_dir/$app_name.tgz" >/dev/null
22
- fi
23
- done
24
-
25
- echo "Generating spa-assemble-config.json..."
19
+ echo "Creating dynamic spa-assemble-config.json..."
20
+ # dynamically assemble our list of frontend modules, prepending the login app and
21
+ # primary navigation apps; apps will all be in the /app directory of the Docker
22
+ # container
26
23
  jq -n \
27
- --arg apps "$apps" \
28
- --arg app_names "$(echo ${app_names[@]})" \
24
+ --arg app_name "$app_name" \
25
+ --arg app_file "/app/$packed_app_name.tgz" \
29
26
  '{
30
27
  "@openmrs/esm-primary-navigation-app": "next",
31
28
  "@openmrs/esm-patient-banner-app": "next"
32
- } + (
33
- ($apps | split("\n")) as $apps |
34
- ($app_names | split(" ") | map("/app/" + .)) as $app_files
35
- | [$apps, $app_files]
36
- | transpose
37
- | map({"key": .[0], "value": .[1]})
38
- | from_entries
39
- )' | jq '{"frontendModules": .}' > "$working_dir/spa-assemble-config.json"
29
+ } + {
30
+ ($app_name): $app_file
31
+ }' | jq '{"frontendModules": .}' > "$working_dir/spa-assemble-config.json"
32
+ echo "Created dynamic spa-assemble-config.json"
40
33
 
41
- echo "Setting up Docker..."
34
+ echo "Copying Docker configuration..."
42
35
  cp "$script_dir/Dockerfile" "$working_dir/Dockerfile"
43
36
  cp "$script_dir/docker-compose.yml" "$working_dir/docker-compose.yml"
44
37
 
45
38
  cd "$working_dir"
39
+ echo "Starting Docker containers..."
40
+ # CACHE_BUST to ensure the assemble step is always run
46
41
  docker compose build --build-arg CACHE_BUST=$(date +%s) frontend
47
42
  docker compose up -d
48
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-dispensing-app",
3
- "version": "1.9.2-pre.889",
3
+ "version": "1.9.2-pre.897",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Medication dispensing application",
6
6
  "browser": "dist/openmrs-esm-dispensing-app.js",
@@ -1 +0,0 @@
1
- {"hash":"adf051de4b68cd85","duration":45181}
@@ -1,97 +0,0 @@
1
- /* eslint-disable @typescript-eslint/await-thenable */
2
- import { type APIRequestContext, expect } from '@playwright/test';
3
- import { type Order } from '@openmrs/esm-patient-common-lib';
4
- import { type Patient } from '../commands';
5
- import { type Encounter } from './types';
6
- import { type MedicationRequest } from '../../src/types';
7
-
8
- export const generateRandomMedicationRequest = async (
9
- fhirApi: APIRequestContext,
10
- patient: Patient,
11
- encounter: Encounter,
12
- providerUuid: string,
13
- drugOrder: Order,
14
- ): Promise<MedicationRequest> => {
15
- const dispense = await fhirApi.post('MedicationRequest?_summary=data', {
16
- data: {
17
- resourceType: 'MedicationDispense',
18
- medicationReference: {
19
- reference: 'Medication/',
20
- },
21
- encounter: encounter,
22
- intent: String,
23
- priority: String,
24
- subject: patient,
25
- requester: [
26
- {
27
- actor: {
28
- reference: providerUuid,
29
- },
30
- },
31
- ],
32
- quantity: {
33
- value: 1,
34
- unit: 'Tablet',
35
- code: '1513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
36
- },
37
- asNeededBoolean: false,
38
- location: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID,
39
- dosageInstruction: [
40
- {
41
- timing: {
42
- code: {
43
- coding: [
44
- {
45
- code: '160862AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
46
- display: 'Once daily',
47
- },
48
- {
49
- system: 'https://cielterminology.org',
50
- code: '160862',
51
- },
52
- {
53
- system: 'http://snomed.info/sct/',
54
- code: '229797004',
55
- },
56
- ],
57
- text: 'Once daily',
58
- },
59
- },
60
- asNeededBoolean: false,
61
- route: {
62
- coding: [
63
- {
64
- code: '160240AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
65
- display: 'Oral',
66
- },
67
- {
68
- system: 'https://cielterminology.org',
69
- code: '160240',
70
- },
71
- {
72
- system: 'http://snomed.info/sct/',
73
- code: '26643006',
74
- },
75
- ],
76
- text: 'Oral',
77
- },
78
- doseAndRate: [
79
- {
80
- doseQuantity: {
81
- value: 1,
82
- unit: 'Milligram',
83
- code: '161553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
84
- },
85
- },
86
- ],
87
- },
88
- ],
89
- },
90
- });
91
- await expect(dispense.ok()).toBeTruthy();
92
- return await dispense.json();
93
- };
94
-
95
- export const deleteMedicationRequest = async (fhirApi: APIRequestContext, uuid: string) => {
96
- await fhirApi.delete(`MedicationDispense/${uuid}`, { data: {} });
97
- };