@ampath/esm-dispensing-app 1.10.0-next.1
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/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +80 -0
- package/.husky/pre-commit +7 -0
- package/.husky/pre-push +6 -0
- package/.prettierignore +12 -0
- package/.tx/config +11 -0
- package/.yarn/versions/1c40b9b6.yml +0 -0
- package/.yarn/versions/ff162597.yml +0 -0
- package/LICENSE +401 -0
- package/README.md +124 -0
- package/__mocks__/react-i18next.js +51 -0
- package/dist/1043.js +1 -0
- package/dist/1043.js.map +1 -0
- package/dist/1119.js +1 -0
- package/dist/1197.js +1 -0
- package/dist/2146.js +1 -0
- package/dist/2177.js +2 -0
- package/dist/2177.js.LICENSE.txt +9 -0
- package/dist/2177.js.map +1 -0
- package/dist/2690.js +1 -0
- package/dist/2890.js +2 -0
- package/dist/2890.js.LICENSE.txt +14 -0
- package/dist/2890.js.map +1 -0
- package/dist/2898.js +1 -0
- package/dist/2898.js.map +1 -0
- package/dist/3041.js +1 -0
- package/dist/3041.js.map +1 -0
- package/dist/3099.js +1 -0
- package/dist/3184.js +2 -0
- package/dist/3184.js.LICENSE.txt +14 -0
- package/dist/3184.js.map +1 -0
- package/dist/3568.js +1 -0
- package/dist/3568.js.map +1 -0
- package/dist/3584.js +1 -0
- package/dist/4055.js +1 -0
- package/dist/4099.js +1 -0
- package/dist/4099.js.map +1 -0
- package/dist/4132.js +1 -0
- package/dist/4225.js +1 -0
- package/dist/4225.js.map +1 -0
- package/dist/4300.js +1 -0
- package/dist/4335.js +1 -0
- package/dist/4353.js +1 -0
- package/dist/4353.js.map +1 -0
- package/dist/439.js +1 -0
- package/dist/4618.js +1 -0
- package/dist/4652.js +1 -0
- package/dist/4944.js +1 -0
- package/dist/5173.js +1 -0
- package/dist/5241.js +1 -0
- package/dist/5422.js +1 -0
- package/dist/5422.js.map +1 -0
- package/dist/5442.js +1 -0
- package/dist/5661.js +1 -0
- package/dist/5897.js +1 -0
- package/dist/5897.js.map +1 -0
- package/dist/6022.js +1 -0
- package/dist/609.js +1 -0
- package/dist/609.js.map +1 -0
- package/dist/6468.js +1 -0
- package/dist/6540.js +2 -0
- package/dist/6540.js.LICENSE.txt +9 -0
- package/dist/6540.js.map +1 -0
- package/dist/6589.js +1 -0
- package/dist/6606.js +1 -0
- package/dist/6606.js.map +1 -0
- package/dist/6679.js +1 -0
- package/dist/6825.js +1 -0
- package/dist/6825.js.map +1 -0
- package/dist/6840.js +1 -0
- package/dist/6841.js +1 -0
- package/dist/6841.js.map +1 -0
- package/dist/6859.js +1 -0
- package/dist/7097.js +1 -0
- package/dist/7159.js +1 -0
- package/dist/723.js +1 -0
- package/dist/7240.js +1 -0
- package/dist/7240.js.map +1 -0
- package/dist/7255.js +1 -0
- package/dist/7255.js.map +1 -0
- package/dist/7617.js +1 -0
- package/dist/795.js +1 -0
- package/dist/8163.js +1 -0
- package/dist/8349.js +1 -0
- package/dist/8371.js +1 -0
- package/dist/8569.js +2 -0
- package/dist/8569.js.LICENSE.txt +41 -0
- package/dist/8569.js.map +1 -0
- package/dist/8600.js +1 -0
- package/dist/8600.js.map +1 -0
- package/dist/8618.js +1 -0
- package/dist/8885.js +1 -0
- package/dist/8885.js.map +1 -0
- package/dist/890.js +1 -0
- package/dist/9214.js +1 -0
- package/dist/9538.js +1 -0
- package/dist/9569.js +1 -0
- package/dist/961.js +2 -0
- package/dist/961.js.LICENSE.txt +19 -0
- package/dist/961.js.map +1 -0
- package/dist/963.js +1 -0
- package/dist/963.js.map +1 -0
- package/dist/986.js +1 -0
- package/dist/9879.js +1 -0
- package/dist/9895.js +1 -0
- package/dist/9900.js +1 -0
- package/dist/9913.js +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +51 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-dispensing-app.js +1 -0
- package/dist/openmrs-esm-dispensing-app.js.buildmanifest.json +1645 -0
- package/dist/openmrs-esm-dispensing-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/e2e/README.md +119 -0
- package/e2e/commands/drug-order-operations.ts +43 -0
- package/e2e/commands/encounter-operations.ts +60 -0
- package/e2e/commands/index.ts +5 -0
- package/e2e/commands/patient-operations.ts +109 -0
- package/e2e/commands/provider-operations.ts +9 -0
- package/e2e/commands/types/index.ts +157 -0
- package/e2e/commands/visit-operations.ts +38 -0
- package/e2e/core/global-setup.ts +32 -0
- package/e2e/core/index.ts +1 -0
- package/e2e/core/test.ts +31 -0
- package/e2e/fixtures/api.ts +27 -0
- package/e2e/fixtures/index.ts +1 -0
- package/e2e/pages/dispensing-page.ts +9 -0
- package/e2e/pages/index.ts +1 -0
- package/e2e/specs/active-prescriptions.spec.ts +72 -0
- package/e2e/specs/close-prescription.spec.ts +71 -0
- package/e2e/specs/dispense-medication.spec.ts +71 -0
- package/e2e/specs/pause-prescription.spec.ts +72 -0
- package/e2e/support/github/Dockerfile +34 -0
- package/e2e/support/github/docker-compose.yml +24 -0
- package/e2e/support/github/run-e2e-docker-env.sh +42 -0
- package/e2e/types/index.ts +157 -0
- package/example.env +7 -0
- package/jest.config.js +24 -0
- package/package.json +110 -0
- package/playwright.config.ts +36 -0
- package/prettier.config.js +8 -0
- package/src/components/action-buttons.component.tsx +87 -0
- package/src/components/action-buttons.scss +16 -0
- package/src/components/action-buttons.test.tsx +217 -0
- package/src/components/medication-card.component.tsx +37 -0
- package/src/components/medication-card.scss +20 -0
- package/src/components/medication-card.test.tsx +36 -0
- package/src/components/medication-dispense-review.scss +108 -0
- package/src/components/medication-event.component.tsx +96 -0
- package/src/components/medication-event.scss +44 -0
- package/src/components/medication-event.test.tsx +212 -0
- package/src/components/prescription-actions/close-action-button.component.tsx +50 -0
- package/src/components/prescription-actions/dispense-action-button.component.tsx +57 -0
- package/src/components/prescription-actions/pause-action-button.component.tsx +49 -0
- package/src/conditions/conditions.component.tsx +118 -0
- package/src/conditions/conditions.resource.ts +100 -0
- package/src/conditions/conditions.scss +26 -0
- package/src/conditions/conditions.test.tsx +200 -0
- package/src/config-schema.ts +192 -0
- package/src/constants.ts +22 -0
- package/src/dashboard/dispensing-dashboard-link.component.tsx +36 -0
- package/src/dashboard/dispensing-dashboard.component.tsx +36 -0
- package/src/declarations.d.ts +2 -0
- package/src/diagnoses/diagnoses.component.tsx +111 -0
- package/src/diagnoses/diagnoses.resource.ts +30 -0
- package/src/diagnoses/diagnoses.scss +31 -0
- package/src/dispensing-link.component.tsx +9 -0
- package/src/dispensing-tiles/dispensing-tile.component.tsx +42 -0
- package/src/dispensing-tiles/dispensing-tile.scss +43 -0
- package/src/dispensing-tiles/dispensing-tiles.component.tsx +39 -0
- package/src/dispensing-tiles/dispensing-tiles.resource.tsx +30 -0
- package/src/dispensing-tiles/dispensing-tiles.scss +11 -0
- package/src/dispensing.component.tsx +31 -0
- package/src/dispensing.scss +5 -0
- package/src/dispensing.test.tsx +9 -0
- package/src/fill-prescription/fill-prescription-button.component.tsx +103 -0
- package/src/fill-prescription/fill-prescription-button.scss +8 -0
- package/src/fill-prescription/on-prescription-filled.modal.tsx +140 -0
- package/src/fill-prescription/on-prescription-filled.scss +7 -0
- package/src/forms/close-dispense-form.workspace.tsx +194 -0
- package/src/forms/dispense-form.workspace.test.tsx +334 -0
- package/src/forms/dispense-form.workspace.tsx +324 -0
- package/src/forms/forms.scss +152 -0
- package/src/forms/medication-dispense-review.component.tsx +649 -0
- package/src/forms/medication-dispense-review.test.tsx +158 -0
- package/src/forms/pause-dispense-form.workspace.tsx +196 -0
- package/src/forms/stock-dispense/stock-dispense.component.tsx +126 -0
- package/src/forms/stock-dispense/stock.resource.tsx +67 -0
- package/src/history/delete-confirm.modal.tsx +35 -0
- package/src/history/history-and-comments.component.tsx +338 -0
- package/src/history/history-and-comments.scss +54 -0
- package/src/index.ts +57 -0
- package/src/location/location.resource.test.tsx +108 -0
- package/src/location/location.resource.tsx +32 -0
- package/src/medication/medication.resource.test.tsx +156 -0
- package/src/medication/medication.resource.tsx +45 -0
- package/src/medication-dispense/medication-dispense.resource.test.tsx +243 -0
- package/src/medication-dispense/medication-dispense.resource.tsx +178 -0
- package/src/medication-request/medication-request.resource.test.tsx +1333 -0
- package/src/medication-request/medication-request.resource.tsx +257 -0
- package/src/patient/patient-info-cell.component.tsx +26 -0
- package/src/patient/patient.resources.ts +14 -0
- package/src/pharmacy-header/pharmacy-header.component.tsx +35 -0
- package/src/pharmacy-header/pharmacy-header.scss +55 -0
- package/src/pharmacy-header/pharmacy-illustration.component.tsx +30 -0
- package/src/prescriptions/patient-search-tab-panel.component.tsx +58 -0
- package/src/prescriptions/patient-search-tab-panel.scss +26 -0
- package/src/prescriptions/prescription-actions.component.tsx +24 -0
- package/src/prescriptions/prescription-actions.scss +14 -0
- package/src/prescriptions/prescription-details.component.tsx +152 -0
- package/src/prescriptions/prescription-details.scss +87 -0
- package/src/prescriptions/prescription-details.test.tsx +267 -0
- package/src/prescriptions/prescription-expanded.component.tsx +58 -0
- package/src/prescriptions/prescription-expanded.scss +56 -0
- package/src/prescriptions/prescription-tab-lists.component.tsx +70 -0
- package/src/prescriptions/prescription-tab-panel.component.tsx +83 -0
- package/src/prescriptions/prescriptions-table.component.tsx +189 -0
- package/src/prescriptions/prescriptions.scss +152 -0
- package/src/print-prescription/prescription-print-action.component.tsx +30 -0
- package/src/print-prescription/prescription-print-preview.modal.tsx +92 -0
- package/src/print-prescription/prescription-printout.component.tsx +154 -0
- package/src/print-prescription/print-prescription.scss +75 -0
- package/src/print-prescription/printable-prescriptions.component.tsx +57 -0
- package/src/routes.json +137 -0
- package/src/types.ts +530 -0
- package/src/utils.test.ts +2947 -0
- package/src/utils.ts +637 -0
- package/tools/i18next-parser.config.js +89 -0
- package/tools/setup-tests.ts +8 -0
- package/tools/update-openmrs-deps.mjs +42 -0
- package/translations/am.json +133 -0
- package/translations/ar.json +133 -0
- package/translations/ar_SY.json +133 -0
- package/translations/bn.json +133 -0
- package/translations/cs.json +133 -0
- package/translations/de.json +133 -0
- package/translations/en.json +133 -0
- package/translations/en_US.json +133 -0
- package/translations/es.json +133 -0
- package/translations/es_MX.json +133 -0
- package/translations/fr.json +133 -0
- package/translations/he.json +133 -0
- package/translations/hi.json +133 -0
- package/translations/hi_IN.json +133 -0
- package/translations/id.json +133 -0
- package/translations/it.json +133 -0
- package/translations/ka.json +133 -0
- package/translations/km.json +133 -0
- package/translations/ku.json +133 -0
- package/translations/ky.json +133 -0
- package/translations/lg.json +133 -0
- package/translations/ne.json +133 -0
- package/translations/pl.json +133 -0
- package/translations/pt.json +133 -0
- package/translations/pt_BR.json +133 -0
- package/translations/qu.json +133 -0
- package/translations/ro_RO.json +133 -0
- package/translations/ru_RU.json +133 -0
- package/translations/si.json +133 -0
- package/translations/sq.json +133 -0
- package/translations/sw.json +133 -0
- package/translations/sw_KE.json +133 -0
- package/translations/tr.json +133 -0
- package/translations/tr_TR.json +133 -0
- package/translations/uk.json +133 -0
- package/translations/uz.json +133 -0
- package/translations/uz@Latn.json +133 -0
- package/translations/uz_UZ.json +133 -0
- package/translations/vi.json +133 -0
- package/translations/zh.json +133 -0
- package/translations/zh_CN.json +133 -0
- package/translations/zh_TW.json +133 -0
- package/tsconfig.json +23 -0
- package/turbo.json +41 -0
- package/webpack.config.js +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ampath/esm-dispensing-app",
|
|
3
|
+
"version": "1.10.0-next.1",
|
|
4
|
+
"license": "MPL-2.0",
|
|
5
|
+
"description": "Medication dispensing application",
|
|
6
|
+
"browser": "dist/openmrs-esm-dispensing-app.js",
|
|
7
|
+
"main": "src/index.ts",
|
|
8
|
+
"source": true,
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "openmrs develop",
|
|
11
|
+
"serve": "webpack serve --mode=development",
|
|
12
|
+
"build": "webpack --mode production",
|
|
13
|
+
"analyze": "webpack --mode=production --env.analyze=true",
|
|
14
|
+
"lint": "eslint src --ext js,jsx,ts,tsx",
|
|
15
|
+
"test": "jest --config jest.config.js",
|
|
16
|
+
"test:watch": "jest --config jest.config.js --watch",
|
|
17
|
+
"typescript": "tsc",
|
|
18
|
+
"verify": "turbo run lint test typescript",
|
|
19
|
+
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ./tools/i18next-parser.config.js",
|
|
20
|
+
"coverage": "yarn test --coverage",
|
|
21
|
+
"postinstall": "husky install",
|
|
22
|
+
"test-e2e": "playwright test"
|
|
23
|
+
},
|
|
24
|
+
"browserslist": [
|
|
25
|
+
"extends browserslist-config-openmrs"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"openmrs",
|
|
29
|
+
"microfrontends",
|
|
30
|
+
"medication",
|
|
31
|
+
"dispensing",
|
|
32
|
+
"pharmacy"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/openmrs/openmrs-esm-dispensing.git"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/openmrs/openmrs-esm-dispensing#readme",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/openmrs/openmrs-esm-dispensing/issues"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@carbon/react": "^1.83.0",
|
|
47
|
+
"classnames": "^2.5.1",
|
|
48
|
+
"lodash-es": "^4.17.21",
|
|
49
|
+
"react-to-print": "^2.14.13"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@openmrs/esm-framework": "9.x",
|
|
53
|
+
"dayjs": "1.x",
|
|
54
|
+
"react": "18.x",
|
|
55
|
+
"react-dom": "18.x",
|
|
56
|
+
"react-i18next": "16.x",
|
|
57
|
+
"rxjs": "6.x",
|
|
58
|
+
"swr": "2.x"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@openmrs/esm-framework": "next",
|
|
62
|
+
"@playwright/test": "^1.52.0",
|
|
63
|
+
"@swc/core": "^1.7.14",
|
|
64
|
+
"@swc/jest": "^0.2.36",
|
|
65
|
+
"@testing-library/dom": "^8.20.1",
|
|
66
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
67
|
+
"@testing-library/react": "^13.4.0",
|
|
68
|
+
"@testing-library/user-event": "^14.5.2",
|
|
69
|
+
"@types/jest": "^28.1.4",
|
|
70
|
+
"@types/react": "^18.3.21",
|
|
71
|
+
"@types/react-dom": "^18.3.0",
|
|
72
|
+
"@types/react-router": "^5.1.20",
|
|
73
|
+
"@types/react-router-dom": "^5.1.7",
|
|
74
|
+
"@types/webpack-env": "^1.16.0",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
76
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
77
|
+
"dayjs": "^1.11.13",
|
|
78
|
+
"dotenv": "^16.3.1",
|
|
79
|
+
"eslint": "^8.57.0",
|
|
80
|
+
"eslint-plugin-import": "^2.31.0",
|
|
81
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
82
|
+
"eslint-plugin-unused-imports": "^4.3.0",
|
|
83
|
+
"husky": "^6.0.0",
|
|
84
|
+
"i18next": "^25.0.0",
|
|
85
|
+
"i18next-parser": "^9.3.0",
|
|
86
|
+
"identity-obj-proxy": "^3.0.0",
|
|
87
|
+
"jest": "^28.1.3",
|
|
88
|
+
"jest-cli": "^28.1.3",
|
|
89
|
+
"jest-environment-jsdom": "^28.1.3",
|
|
90
|
+
"lint-staged": "^15.2.9",
|
|
91
|
+
"openmrs": "next",
|
|
92
|
+
"prettier": "^3.2.5",
|
|
93
|
+
"react": "^18.3.1",
|
|
94
|
+
"react-dom": "^18.3.1",
|
|
95
|
+
"react-i18next": "^16.0.0",
|
|
96
|
+
"react-router-dom": "^6.3.0",
|
|
97
|
+
"rxjs": "^6.6.7",
|
|
98
|
+
"swr": "^2.2.5",
|
|
99
|
+
"turbo": "^2.5.2",
|
|
100
|
+
"typescript": "^5.0.0",
|
|
101
|
+
"webpack": "^5.99.9",
|
|
102
|
+
"webpack-cli": "^6.0.1"
|
|
103
|
+
},
|
|
104
|
+
"lint-staged": {
|
|
105
|
+
"*.{ts,tsx}": "eslint --cache --fix --max-warnings 0",
|
|
106
|
+
"*.{css,scss,ts,tsx}": "prettier --write --list-different"
|
|
107
|
+
},
|
|
108
|
+
"packageManager": "yarn@4.10.3",
|
|
109
|
+
"stableVersion": "1.10.0"
|
|
110
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { devices, type PlaywrightTestConfig } from '@playwright/test';
|
|
2
|
+
import { config as dotenvConfig } from 'dotenv';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
dotenvConfig({ path: resolve(process.cwd(), '.env') });
|
|
5
|
+
dotenvConfig();
|
|
6
|
+
|
|
7
|
+
// See https://playwright.dev/docs/test-configuration.
|
|
8
|
+
const config: PlaywrightTestConfig = {
|
|
9
|
+
testDir: './e2e/specs',
|
|
10
|
+
timeout: 3 * 60 * 1000,
|
|
11
|
+
expect: {
|
|
12
|
+
timeout: 40 * 1000,
|
|
13
|
+
},
|
|
14
|
+
fullyParallel: true,
|
|
15
|
+
forbidOnly: !!process.env.CI,
|
|
16
|
+
retries: 0,
|
|
17
|
+
reporter: process.env.CI ? [['junit', { outputFile: 'results.xml' }], ['html']] : [['html']],
|
|
18
|
+
globalSetup: require.resolve('./e2e/core/global-setup'),
|
|
19
|
+
use: {
|
|
20
|
+
baseURL: `${process.env.E2E_BASE_URL}/spa/`,
|
|
21
|
+
storageState: 'e2e/storageState.json',
|
|
22
|
+
video: 'retain-on-failure',
|
|
23
|
+
trace: 'retain-on-failure',
|
|
24
|
+
},
|
|
25
|
+
projects: [
|
|
26
|
+
{
|
|
27
|
+
name: 'chromium',
|
|
28
|
+
use: {
|
|
29
|
+
...devices['Desktop Chrome'],
|
|
30
|
+
channel: 'chromium',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default config;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExtensionSlot, useConfig, useSession } from '@openmrs/esm-framework';
|
|
3
|
+
import { MedicationDispenseStatus, type MedicationRequestBundle, MedicationRequestStatus } from '../types';
|
|
4
|
+
import {
|
|
5
|
+
computeMedicationRequestStatus,
|
|
6
|
+
computeQuantityRemaining,
|
|
7
|
+
getMostRecentMedicationDispenseStatus,
|
|
8
|
+
computeTotalQuantityDispensed,
|
|
9
|
+
} from '../utils';
|
|
10
|
+
import { type PharmacyConfig } from '../config-schema';
|
|
11
|
+
import { useProviders } from '../medication-dispense/medication-dispense.resource';
|
|
12
|
+
import styles from './action-buttons.scss';
|
|
13
|
+
|
|
14
|
+
interface ActionButtonsProps {
|
|
15
|
+
medicationRequestBundle: MedicationRequestBundle;
|
|
16
|
+
patientUuid: string;
|
|
17
|
+
encounterUuid: string;
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const ActionButtons: React.FC<ActionButtonsProps> = ({
|
|
22
|
+
medicationRequestBundle,
|
|
23
|
+
patientUuid,
|
|
24
|
+
encounterUuid,
|
|
25
|
+
disabled,
|
|
26
|
+
}) => {
|
|
27
|
+
const config = useConfig<PharmacyConfig>();
|
|
28
|
+
const session = useSession();
|
|
29
|
+
const providers = useProviders(config.dispenserProviderRoles);
|
|
30
|
+
const mostRecentMedicationDispenseStatus: MedicationDispenseStatus = getMostRecentMedicationDispenseStatus(
|
|
31
|
+
medicationRequestBundle.dispenses,
|
|
32
|
+
);
|
|
33
|
+
const medicationRequestStatus = computeMedicationRequestStatus(
|
|
34
|
+
medicationRequestBundle.request,
|
|
35
|
+
config.medicationRequestExpirationPeriodInDays,
|
|
36
|
+
);
|
|
37
|
+
const dispensable =
|
|
38
|
+
medicationRequestStatus === MedicationRequestStatus.active &&
|
|
39
|
+
mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined;
|
|
40
|
+
|
|
41
|
+
const pauseable =
|
|
42
|
+
config.actionButtons.pauseButton.enabled &&
|
|
43
|
+
medicationRequestStatus === MedicationRequestStatus.active &&
|
|
44
|
+
mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.on_hold &&
|
|
45
|
+
mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined;
|
|
46
|
+
|
|
47
|
+
const closeable =
|
|
48
|
+
config.actionButtons.closeButton.enabled &&
|
|
49
|
+
medicationRequestStatus === MedicationRequestStatus.active &&
|
|
50
|
+
mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined;
|
|
51
|
+
|
|
52
|
+
let quantityRemaining = null;
|
|
53
|
+
if (config.dispenseBehavior.restrictTotalQuantityDispensed) {
|
|
54
|
+
quantityRemaining = computeQuantityRemaining(medicationRequestBundle);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let quantityDispensed = 0;
|
|
58
|
+
if (config.dispenseBehavior.restrictTotalQuantityDispensed && medicationRequestBundle.dispenses) {
|
|
59
|
+
quantityDispensed = computeTotalQuantityDispensed(medicationRequestBundle.dispenses);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const prescriptionActionsState = {
|
|
63
|
+
dispensable,
|
|
64
|
+
pauseable,
|
|
65
|
+
closeable,
|
|
66
|
+
quantityRemaining,
|
|
67
|
+
quantityDispensed,
|
|
68
|
+
patientUuid,
|
|
69
|
+
encounterUuid,
|
|
70
|
+
medicationRequestBundle,
|
|
71
|
+
session,
|
|
72
|
+
providers,
|
|
73
|
+
disabled,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className={styles.actionBtns}>
|
|
78
|
+
<ExtensionSlot
|
|
79
|
+
className={styles.extensionSlot}
|
|
80
|
+
name="prescription-action-button-slot"
|
|
81
|
+
state={prescriptionActionsState}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default ActionButtons;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.actionBtns {
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: 0;
|
|
4
|
+
justify-content: flex-end;
|
|
5
|
+
align-items: flex-end;
|
|
6
|
+
margin-top: auto;
|
|
7
|
+
align-self: flex-end;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.extensionSlot {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: row-reverse;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
height: 100%;
|
|
15
|
+
position: relative;
|
|
16
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { useConfig, ExtensionSlot } from '@openmrs/esm-framework';
|
|
4
|
+
import { computeMedicationRequestStatus, getMostRecentMedicationDispenseStatus } from '../utils';
|
|
5
|
+
import { MedicationDispenseStatus, type MedicationRequest, MedicationRequestStatus } from '../types';
|
|
6
|
+
import ActionButtons from './action-buttons.component';
|
|
7
|
+
import CloseActionButton from './prescription-actions/close-action-button.component';
|
|
8
|
+
import DispenseActionButton from './prescription-actions/dispense-action-button.component';
|
|
9
|
+
import PauseActionButton from './prescription-actions/pause-action-button.component';
|
|
10
|
+
|
|
11
|
+
const mockedUseConfig = jest.mocked(useConfig);
|
|
12
|
+
const mockedExtensionSlot = jest.mocked(ExtensionSlot);
|
|
13
|
+
const mockPatientUuid = '558494fe-5850-4b34-a3bf-06550334ba4a';
|
|
14
|
+
const mockEncounterUuid = '7aee7123-9e50-4f72-a636-895d77a63e98';
|
|
15
|
+
|
|
16
|
+
const medicationRequest: MedicationRequest = {
|
|
17
|
+
resourceType: 'MedicationRequest',
|
|
18
|
+
id: 'd4f69a68-1171-4e47-8693-478df18daf40',
|
|
19
|
+
meta: {
|
|
20
|
+
lastUpdated: '2023-01-24T19:02:04.000-05:00',
|
|
21
|
+
},
|
|
22
|
+
status: MedicationRequestStatus.active,
|
|
23
|
+
intent: 'order',
|
|
24
|
+
priority: 'routine',
|
|
25
|
+
medicationReference: {
|
|
26
|
+
reference: 'Medication/c8d3444c-41a4-48d3-9ec1-811fe7b27d99',
|
|
27
|
+
type: 'Medication',
|
|
28
|
+
display: 'Ascorbic acid (Vitamin C), 250mg tablet',
|
|
29
|
+
},
|
|
30
|
+
subject: {
|
|
31
|
+
reference: 'Patient/558494fe-5850-4b34-a3bf-06550334ba4a',
|
|
32
|
+
type: 'Patient',
|
|
33
|
+
display: 'Dylan, Bob (ZL EMR ID: Y2CK2G)',
|
|
34
|
+
},
|
|
35
|
+
encounter: {
|
|
36
|
+
reference: 'Encounter/7aee7123-9e50-4f72-a636-895d77a63e98',
|
|
37
|
+
type: 'Encounter',
|
|
38
|
+
},
|
|
39
|
+
requester: {
|
|
40
|
+
reference: 'Practitioner/19e06fb0-22ea-4dd4-aafd-da14c14a1487',
|
|
41
|
+
type: 'Practitioner',
|
|
42
|
+
identifier: {
|
|
43
|
+
value: 'MAADH',
|
|
44
|
+
},
|
|
45
|
+
display: 'Goodrich, Mark (Identifier: MAADH)',
|
|
46
|
+
},
|
|
47
|
+
dosageInstruction: [
|
|
48
|
+
{
|
|
49
|
+
text: 'test',
|
|
50
|
+
timing: {
|
|
51
|
+
repeat: {
|
|
52
|
+
duration: 6,
|
|
53
|
+
durationUnit: 'd',
|
|
54
|
+
},
|
|
55
|
+
code: {
|
|
56
|
+
coding: [
|
|
57
|
+
{
|
|
58
|
+
code: '37328251-6759-4270-8a2e-8cab2c0b315b',
|
|
59
|
+
display: 'OD (once daily)',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
system: 'http://snomed.info/sct',
|
|
63
|
+
code: '229797004',
|
|
64
|
+
display: 'OD (once daily)',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
text: 'OD (once daily)',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
asNeededBoolean: false,
|
|
71
|
+
route: {
|
|
72
|
+
coding: [
|
|
73
|
+
{
|
|
74
|
+
code: '46aaaca8-1f21-410a-aac9-67bfcc1fd577',
|
|
75
|
+
display: 'Oral',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
system: 'http://snomed.info/sct',
|
|
79
|
+
code: '26643006',
|
|
80
|
+
display: 'Oral',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
text: 'Oral',
|
|
84
|
+
},
|
|
85
|
+
doseAndRate: [
|
|
86
|
+
{
|
|
87
|
+
doseQuantity: {
|
|
88
|
+
value: 5.0,
|
|
89
|
+
unit: 'Ampule(s)',
|
|
90
|
+
system: 'http://snomed.info/sct',
|
|
91
|
+
code: '413516001',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
dispenseRequest: {
|
|
98
|
+
validityPeriod: {
|
|
99
|
+
start: new Date().toISOString(),
|
|
100
|
+
},
|
|
101
|
+
numberOfRepeatsAllowed: 8,
|
|
102
|
+
quantity: {
|
|
103
|
+
value: 7.0,
|
|
104
|
+
unit: 'Application',
|
|
105
|
+
system: 'http://snomed.info/sct',
|
|
106
|
+
code: '413568008',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const medicationRequestStatus = computeMedicationRequestStatus(medicationRequest, 90);
|
|
112
|
+
const mostRecentMedicationDispenseStatus: MedicationDispenseStatus = getMostRecentMedicationDispenseStatus([]);
|
|
113
|
+
|
|
114
|
+
const prescriptionActionsState = {
|
|
115
|
+
dispensable:
|
|
116
|
+
medicationRequestStatus === MedicationRequestStatus.active &&
|
|
117
|
+
mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined,
|
|
118
|
+
pauseable: true,
|
|
119
|
+
closeable: true,
|
|
120
|
+
quantityRemaining: 0,
|
|
121
|
+
quantityDispensed: 0,
|
|
122
|
+
patientUuid: mockPatientUuid,
|
|
123
|
+
encounterUuid: mockEncounterUuid,
|
|
124
|
+
medicationRequestBundle: { request: medicationRequest, dispenses: [] },
|
|
125
|
+
session: undefined,
|
|
126
|
+
providers: [],
|
|
127
|
+
disabled: false,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
describe('Action Buttons Component tests', () => {
|
|
131
|
+
beforeEach(() => {
|
|
132
|
+
mockedUseConfig.mockReturnValue({
|
|
133
|
+
medicationRequestExpirationPeriodInDays: 90,
|
|
134
|
+
actionButtons: {
|
|
135
|
+
pauseButton: {
|
|
136
|
+
enabled: true,
|
|
137
|
+
},
|
|
138
|
+
closeButton: {
|
|
139
|
+
enabled: true,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
dispenseBehavior: {
|
|
143
|
+
allowModifyingPrescription: false,
|
|
144
|
+
restrictTotalQuantityDispensed: false,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('component should render dispense button if active medication', () => {
|
|
150
|
+
// status = active, and validity period start set to current datetime
|
|
151
|
+
mockedExtensionSlot.mockImplementationOnce(() => (
|
|
152
|
+
<div>
|
|
153
|
+
<DispenseActionButton {...prescriptionActionsState} />
|
|
154
|
+
<PauseActionButton {...prescriptionActionsState} />
|
|
155
|
+
<CloseActionButton {...prescriptionActionsState} />
|
|
156
|
+
</div>
|
|
157
|
+
));
|
|
158
|
+
|
|
159
|
+
const { getByText, container } = render(
|
|
160
|
+
<ActionButtons
|
|
161
|
+
patientUuid={mockPatientUuid}
|
|
162
|
+
encounterUuid={mockEncounterUuid}
|
|
163
|
+
medicationRequestBundle={{ request: medicationRequest, dispenses: [] }}
|
|
164
|
+
disabled={false}
|
|
165
|
+
/>,
|
|
166
|
+
);
|
|
167
|
+
expect(getByText('Dispense')).toBeInTheDocument();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// status = active, but validity period start time years in the past
|
|
171
|
+
test('component should not render dispense button if expired medication', () => {
|
|
172
|
+
const expiredMedicationRequest = {
|
|
173
|
+
...medicationRequest,
|
|
174
|
+
dispenseRequest: {
|
|
175
|
+
...medicationRequest.dispenseRequest,
|
|
176
|
+
validityPeriod: {
|
|
177
|
+
start: '2019-01-24T19:02:04.000-05:00',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Recalculate status with expired medication
|
|
183
|
+
const expiredMedicationRequestStatus = computeMedicationRequestStatus(expiredMedicationRequest, 90);
|
|
184
|
+
const mostRecentDispenseStatus = getMostRecentMedicationDispenseStatus([]);
|
|
185
|
+
|
|
186
|
+
// Create new state with expired medication
|
|
187
|
+
const expiredPrescriptionActionsState = {
|
|
188
|
+
...prescriptionActionsState,
|
|
189
|
+
dispensable:
|
|
190
|
+
expiredMedicationRequestStatus === MedicationRequestStatus.active &&
|
|
191
|
+
mostRecentDispenseStatus !== MedicationDispenseStatus.declined,
|
|
192
|
+
medicationRequestBundle: {
|
|
193
|
+
request: expiredMedicationRequest,
|
|
194
|
+
dispenses: [],
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
mockedExtensionSlot.mockImplementationOnce(() => (
|
|
199
|
+
<div>
|
|
200
|
+
<DispenseActionButton {...expiredPrescriptionActionsState} />
|
|
201
|
+
<PauseActionButton {...expiredPrescriptionActionsState} />
|
|
202
|
+
<CloseActionButton {...expiredPrescriptionActionsState} />
|
|
203
|
+
</div>
|
|
204
|
+
));
|
|
205
|
+
|
|
206
|
+
const { queryByText } = render(
|
|
207
|
+
<ActionButtons
|
|
208
|
+
patientUuid={mockPatientUuid}
|
|
209
|
+
encounterUuid={mockEncounterUuid}
|
|
210
|
+
medicationRequestBundle={{ request: expiredMedicationRequest, dispenses: [] }}
|
|
211
|
+
disabled={false}
|
|
212
|
+
/>,
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
expect(queryByText('Dispense')).not.toBeInTheDocument();
|
|
216
|
+
});
|
|
217
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButton, Tile } from '@carbon/react';
|
|
3
|
+
import { Edit } from '@carbon/react/icons';
|
|
4
|
+
import { type MedicationReferenceOrCodeableConcept } from '../types';
|
|
5
|
+
import { getMedicationDisplay } from '../utils';
|
|
6
|
+
import styles from './medication-card.scss';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This component shows up in the dispensing form to display the medication to be dispensed
|
|
11
|
+
*/
|
|
12
|
+
const MedicationCard: React.FC<{
|
|
13
|
+
medication: MedicationReferenceOrCodeableConcept;
|
|
14
|
+
editAction?();
|
|
15
|
+
}> = ({ medication, editAction }) => {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Tile className={styles.medicationTile}>
|
|
20
|
+
<p className={styles.medicationName}>
|
|
21
|
+
<strong>{getMedicationDisplay(medication)}</strong>
|
|
22
|
+
</p>
|
|
23
|
+
{editAction && (
|
|
24
|
+
<IconButton
|
|
25
|
+
align="bottom-end"
|
|
26
|
+
kind="ghost"
|
|
27
|
+
size="sm"
|
|
28
|
+
label={t('editFormulation', 'Edit formulation')}
|
|
29
|
+
onClick={editAction}>
|
|
30
|
+
<Edit />
|
|
31
|
+
</IconButton>
|
|
32
|
+
)}
|
|
33
|
+
</Tile>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default MedicationCard;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@use '@carbon/layout';
|
|
2
|
+
@use '@carbon/type';
|
|
3
|
+
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
+
|
|
5
|
+
.medicationTile {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
width: 100%;
|
|
10
|
+
margin: layout.$spacing-01 0 layout.$spacing-03;
|
|
11
|
+
padding: 0 layout.$spacing-03 0 layout.$spacing-03;
|
|
12
|
+
background-color: #fff;
|
|
13
|
+
border-left: layout.$spacing-02 solid var(--brand-03);
|
|
14
|
+
color: $text-02;
|
|
15
|
+
margin-bottom: layout.$spacing-05 !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.medicationName {
|
|
19
|
+
font-size: layout.$spacing-05 !important;
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { type MedicationReferenceOrCodeableConcept } from '../types';
|
|
4
|
+
import MedicationCard from './medication-card.component';
|
|
5
|
+
|
|
6
|
+
describe('Medication Card Component tests', () => {
|
|
7
|
+
test('component should render medication card without edit action button', () => {
|
|
8
|
+
const medication: MedicationReferenceOrCodeableConcept = {
|
|
9
|
+
medicationReference: {
|
|
10
|
+
display: 'Some Medication',
|
|
11
|
+
reference: '',
|
|
12
|
+
type: '',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const { getByText, container } = render(<MedicationCard medication={medication} />);
|
|
17
|
+
expect(getByText('Some Medication')).toBeInTheDocument();
|
|
18
|
+
expect(container.querySelector('svg')).not.toBeInTheDocument();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('component should render medication card with edit action button', () => {
|
|
22
|
+
const medication: MedicationReferenceOrCodeableConcept = {
|
|
23
|
+
medicationReference: {
|
|
24
|
+
display: 'Some Medication',
|
|
25
|
+
reference: '',
|
|
26
|
+
type: '',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const action = () => 0;
|
|
31
|
+
|
|
32
|
+
const { getByText, container } = render(<MedicationCard medication={medication} editAction={action} />);
|
|
33
|
+
expect(getByText('Some Medication')).toBeInTheDocument();
|
|
34
|
+
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
@use '@carbon/layout';
|
|
2
|
+
@use '@carbon/type';
|
|
3
|
+
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
+
|
|
5
|
+
.medicationDispenseReviewContainer {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
padding-bottom: 10px;
|
|
9
|
+
|
|
10
|
+
:global(.cds--css-grid) {
|
|
11
|
+
padding-left: 0 !important;
|
|
12
|
+
padding-right: 0 !important;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.medicationCardContainer {
|
|
17
|
+
position: sticky;
|
|
18
|
+
top: 0;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
background-color: inherit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.dispenseDetailsContainer {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
flex: 1;
|
|
27
|
+
gap: layout.$spacing-05;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.substitutionReason {
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.substitutionType {
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.productiveHeading02 {
|
|
39
|
+
color: $color-gray-70;
|
|
40
|
+
@include type.type-style('heading-02');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:global(.omrs-breakpoint-lt-desktop) .formWrapper {
|
|
44
|
+
background-color: $openmrs-background-grey;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:global(.omrs-breakpoint-gt-tablet) .formWrapper {
|
|
48
|
+
background-color: $ui-02;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.formGroup {
|
|
52
|
+
display: flex;
|
|
53
|
+
margin-bottom: layout.$spacing-02;
|
|
54
|
+
padding: layout.$spacing-05;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:global(.omrs-breakpoint-lt-desktop) .formGroup > span {
|
|
58
|
+
flex: 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:global(.omrs-breakpoint-lt-desktop) .formGroup > div {
|
|
62
|
+
flex: 3;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.formGroup span {
|
|
66
|
+
@extend .productiveHeading02;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.patientInfo {
|
|
70
|
+
position: sticky;
|
|
71
|
+
z-index: 1000;
|
|
72
|
+
background-color: $ui-02;
|
|
73
|
+
top: layout.$spacing-09;
|
|
74
|
+
overflow-y: auto;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:global(.omrs-breakpoint-lt-desktop) .formGroup {
|
|
78
|
+
flex-direction: row;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
:global(.omrs-breakpoint-gt-tablet) .formGroup {
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.buttonGroup {
|
|
86
|
+
display: flex;
|
|
87
|
+
position: sticky;
|
|
88
|
+
bottom: 0;
|
|
89
|
+
width: 100%;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:global(.omrs-breakpoint-lt-desktop) .buttonGroup {
|
|
93
|
+
padding: layout.$spacing-05 layout.$spacing-06;
|
|
94
|
+
background-color: $ui-02;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.buttonGroup button {
|
|
98
|
+
max-width: none;
|
|
99
|
+
width: 50%;
|
|
100
|
+
height: layout.$spacing-10;
|
|
101
|
+
align-items: flex-start;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.quantitySummary {
|
|
105
|
+
display: flex;
|
|
106
|
+
flex-direction: column;
|
|
107
|
+
font-size: 0.8rem;
|
|
108
|
+
}
|