@pih/esm-referrals-queue-app 2.0.0-pre.9 → 2.1.1-pre.101
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/.turbo/turbo-build.log +41 -0
- package/README.md +1 -17
- package/dist/13.js +2 -0
- package/dist/13.js.LICENSE.txt +38 -0
- package/dist/13.js.map +1 -0
- package/dist/144.js +2 -0
- package/dist/144.js.LICENSE.txt +19 -0
- package/dist/144.js.map +1 -0
- package/dist/146.js +1 -0
- package/dist/146.js.map +1 -0
- package/dist/15.js +2 -0
- package/dist/15.js.LICENSE.txt +28 -0
- package/dist/15.js.map +1 -0
- package/dist/300.js +1 -0
- package/dist/304.js +1 -0
- package/dist/304.js.map +1 -0
- package/dist/372.js +1 -0
- package/dist/372.js.map +1 -0
- package/dist/41.js +2 -0
- package/dist/41.js.map +1 -0
- package/dist/423.js +1 -0
- package/dist/423.js.map +1 -0
- package/dist/470.js +2 -0
- package/dist/470.js.LICENSE.txt +9 -0
- package/dist/470.js.map +1 -0
- package/dist/495.js +1 -0
- package/dist/495.js.map +1 -0
- package/dist/55.js +1 -0
- package/dist/84.js +2 -0
- package/dist/{147.js.LICENSE.txt → 84.js.LICENSE.txt} +7 -24
- package/dist/84.js.map +1 -0
- package/dist/876.js +2 -0
- package/dist/876.js.LICENSE.txt +9 -0
- package/dist/876.js.map +1 -0
- package/dist/89.js +1 -0
- package/dist/89.js.map +1 -0
- package/dist/913.js +2 -0
- package/dist/{879.js.LICENSE.txt → 913.js.LICENSE.txt} +13 -2
- package/dist/913.js.map +1 -0
- package/dist/92.js +2 -0
- package/dist/92.js.LICENSE.txt +9 -0
- package/dist/92.js.map +1 -0
- package/dist/99.js +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -0
- package/dist/pih-esm-referrals-queue-app.js +1 -1
- package/dist/pih-esm-referrals-queue-app.js.buildmanifest.json +429 -60
- package/dist/pih-esm-referrals-queue-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/jest.config.js +3 -0
- package/package.json +27 -70
- package/src/config-schema.ts +8 -16
- package/src/declarations.d.tsx +4 -4
- package/src/index.ts +11 -65
- package/src/referrals-queue/referrals-queue.component.tsx +71 -120
- package/src/referrals-queue/referrals-queue.resource.tsx +6 -9
- package/src/referrals-queue/referrals-queue.scss +24 -0
- package/src/referrals-queue/referrals-queue.test.tsx +148 -116
- package/src/root.component.test.tsx +3 -3
- package/src/root.component.tsx +6 -6
- package/src/routes.json +9 -0
- package/src/setup-tests.ts +8 -8
- package/src/table/referrals-table.component.tsx +83 -0
- package/src/util.ts +5 -9
- package/translations/en.json +13 -2
- package/translations/es.json +15 -0
- package/translations/fr.json +15 -0
- package/tsconfig.json +4 -22
- package/.editorconfig +0 -12
- package/.eslintignore +0 -2
- package/.eslintrc +0 -4
- package/.github/workflows/node.js.yml +0 -79
- package/.husky/pre-commit +0 -6
- package/.husky/pre-push +0 -6
- package/.prettierignore +0 -14
- package/LICENSE +0 -401
- package/__mocks__/react-i18next.js +0 -51
- package/dist/132.js +0 -1
- package/dist/147.js +0 -2
- package/dist/281.js +0 -1
- package/dist/294.js +0 -2
- package/dist/574.js +0 -1
- package/dist/595.js +0 -2
- package/dist/595.js.LICENSE.txt +0 -1
- package/dist/879.js +0 -2
- package/dist/90.js +0 -1
- package/dist/pih-esm-referrals-queue-app.old +0 -1
- package/jest.config.json +0 -19
- package/src/referrals-queue/react-dates-overrides.css +0 -39
- package/src/referrals-queue/referrals-queue.css +0 -63
- package/src/table/table.component.tsx +0 -95
- package/src/table/table.css +0 -16
- /package/dist/{294.js.LICENSE.txt → 41.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,100 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pih/esm-referrals-queue-app",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"license": "MPL-2.0",
|
|
3
|
+
"version": "2.1.1-pre.101",
|
|
5
4
|
"description": "A page for viewing the J9 Home Visits from CommCare",
|
|
6
5
|
"browser": "dist/pih-esm-referrals-queue-app.js",
|
|
7
6
|
"main": "src/index.ts",
|
|
8
7
|
"source": true,
|
|
8
|
+
"license": "MPL-2.0",
|
|
9
|
+
"homepage": "https://github.com/PIH/openmrs-esm-pihemr#readme",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"start": "openmrs develop",
|
|
11
12
|
"serve": "webpack serve --mode=development",
|
|
13
|
+
"debug": "npm run serve",
|
|
12
14
|
"build": "webpack --mode production",
|
|
13
15
|
"analyze": "webpack --mode=production --env.analyze=true",
|
|
14
|
-
"lint": "eslint src --ext
|
|
15
|
-
"
|
|
16
|
+
"lint": "cross-env eslint src --ext ts,tsx",
|
|
17
|
+
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color",
|
|
18
|
+
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
|
|
19
|
+
"coverage": "yarn test --coverage",
|
|
16
20
|
"typescript": "tsc",
|
|
17
|
-
"
|
|
18
|
-
"verify": "concurrently 'yarn:lint' 'yarn:test' 'yarn:typescript'",
|
|
19
|
-
"coverage": "yarn test -- --coverage",
|
|
20
|
-
"prepare": "husky install"
|
|
21
|
-
},
|
|
22
|
-
"husky": {
|
|
23
|
-
"hooks": {
|
|
24
|
-
"pre-commit": "pretty-quick --staged && yarn verify"
|
|
25
|
-
}
|
|
21
|
+
"extract-translations": "i18next 'src/**/*.component.tsx'"
|
|
26
22
|
},
|
|
27
23
|
"browserslist": [
|
|
28
24
|
"extends browserslist-config-openmrs"
|
|
29
25
|
],
|
|
30
26
|
"keywords": [
|
|
31
|
-
"openmrs"
|
|
32
|
-
"microfrontends"
|
|
27
|
+
"openmrs"
|
|
33
28
|
],
|
|
34
|
-
"repository": {
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/pih/pih-esm-referrals-queue.git"
|
|
37
|
-
},
|
|
38
|
-
"homepage": "https://github.com/pih/pih-esm-referrals-queue#readme",
|
|
39
29
|
"publishConfig": {
|
|
40
30
|
"access": "public"
|
|
41
31
|
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/PIH/openmrs-esm-pihemr.git"
|
|
35
|
+
},
|
|
42
36
|
"bugs": {
|
|
43
|
-
"url": "https://github.com/
|
|
37
|
+
"url": "https://github.com/PIH/openmrs-esm-pihemr/issues"
|
|
44
38
|
},
|
|
45
39
|
"dependencies": {
|
|
46
|
-
"
|
|
40
|
+
"@babel/runtime": "^7.24.0",
|
|
41
|
+
"moment": "^2.30.1",
|
|
42
|
+
"react-dates": "^21.8.0",
|
|
43
|
+
"webpack": "^5.74.0"
|
|
47
44
|
},
|
|
48
45
|
"peerDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
51
|
-
"dayjs": "1.x",
|
|
46
|
+
"@openmrs/esm-framework": "8.x",
|
|
47
|
+
"i18next": "^19.0.0",
|
|
52
48
|
"react": "18.x",
|
|
53
|
-
"react-i18next": "
|
|
54
|
-
"react-router-dom": "6.x",
|
|
55
|
-
"
|
|
49
|
+
"react-i18next": "16.x",
|
|
50
|
+
"react-router-dom": "^6.x",
|
|
51
|
+
"swr": "2.x"
|
|
56
52
|
},
|
|
57
53
|
"devDependencies": {
|
|
58
|
-
"
|
|
59
|
-
"@carbon/icons-react": "^10.18.0",
|
|
60
|
-
"@openmrs/esm-framework": "next",
|
|
61
|
-
"@swc/core": "^1.2.203",
|
|
62
|
-
"@swc/jest": "^0.2.21",
|
|
63
|
-
"@testing-library/dom": "^7.20.0",
|
|
64
|
-
"@testing-library/jest-dom": "^5.16.5",
|
|
65
|
-
"@testing-library/react": "^13.3.0",
|
|
66
|
-
"@testing-library/user-event": "^14.4.3",
|
|
67
|
-
"@types/jest": "^28.1.4",
|
|
68
|
-
"@types/react": "^18.0.14",
|
|
69
|
-
"@types/react-dates": "^21.8.0",
|
|
70
|
-
"@types/react-dom": "^18.0.5",
|
|
71
|
-
"@types/react-router": "^5.1.14",
|
|
72
|
-
"@types/react-router-dom": "^5.1.7",
|
|
73
|
-
"@types/webpack-env": "^1.16.0",
|
|
74
|
-
"@typescript-eslint/parser": "^5.28.0",
|
|
75
|
-
"concurrently": "^6.2.0",
|
|
76
|
-
"css-loader": "^6.7.1",
|
|
77
|
-
"eslint": "^7.27.0",
|
|
78
|
-
"eslint-config-prettier": "^8.3.0",
|
|
79
|
-
"eslint-config-ts-react-important-stuff": "^3.0.0",
|
|
80
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
81
|
-
"husky": "^6.0.0",
|
|
82
|
-
"identity-obj-proxy": "^3.0.0",
|
|
83
|
-
"jest": "^27.0.4",
|
|
84
|
-
"jest-cli": "^27.0.4",
|
|
85
|
-
"mockdate": "^3.0.5",
|
|
86
|
-
"openmrs": "next",
|
|
87
|
-
"prettier": "^2.3.0",
|
|
88
|
-
"pretty-quick": "^3.1.0",
|
|
89
|
-
"react": "^18.2.0",
|
|
90
|
-
"react-dates": "^21.8.0",
|
|
91
|
-
"react-dom": "^18.2.0",
|
|
92
|
-
"react-i18next": "^11.7.0",
|
|
93
|
-
"react-router-dom": "^6.3.0",
|
|
94
|
-
"rxjs": "^6.5.4",
|
|
95
|
-
"typescript": "^4.3.2"
|
|
54
|
+
"webpack": "^5.74.0"
|
|
96
55
|
},
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}
|
|
56
|
+
"stableVersion": "2.1.0"
|
|
57
|
+
}
|
package/src/config-schema.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type, validators } from
|
|
1
|
+
import { Type, validators } from '@openmrs/esm-framework';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is the config schema. It expects a configuration object which
|
|
@@ -25,33 +25,25 @@ export const configSchema = {
|
|
|
25
25
|
patientDash: {
|
|
26
26
|
_type: Type.String,
|
|
27
27
|
_default:
|
|
28
|
-
|
|
29
|
-
_validators: [validators.isUrlWithTemplateParameters([
|
|
28
|
+
'${openmrsBase}/coreapps/clinicianfacing/patient.page?patientId=${patientUuid}&app=pih.app.clinicianDashboard',
|
|
29
|
+
_validators: [validators.isUrlWithTemplateParameters(['patientUuid'])],
|
|
30
30
|
},
|
|
31
31
|
visitPage: {
|
|
32
32
|
_type: Type.String,
|
|
33
33
|
_default:
|
|
34
|
-
|
|
35
|
-
_validators: [
|
|
36
|
-
validators.isUrlWithTemplateParameters(["patientUuid", "visitUuid"]),
|
|
37
|
-
],
|
|
34
|
+
'${openmrsBase}/pihcore/visit/visit.page?patient=${patientUuid}&visit=${visitUuid}&suppressActions=true#/overview',
|
|
35
|
+
_validators: [validators.isUrlWithTemplateParameters(['patientUuid', 'visitUuid'])],
|
|
38
36
|
},
|
|
39
37
|
homeVisitForm: {
|
|
40
38
|
_type: Type.String,
|
|
41
39
|
_default:
|
|
42
|
-
|
|
43
|
-
_validators: [
|
|
44
|
-
validators.isUrlWithTemplateParameters([
|
|
45
|
-
"patientUuid",
|
|
46
|
-
"visitUuid",
|
|
47
|
-
"encounterUuid",
|
|
48
|
-
]),
|
|
49
|
-
],
|
|
40
|
+
'${openmrsBase}/htmlformentryui/htmlform/editHtmlFormWithStandardUi.page?patientId=${patientUuid}&visitId=${visitUuid}&encounterId=${encounterUuid}&definitionUiResource=file:configuration/pih/htmlforms/section-mch-referral.xml&returnUrl=/mirebalais/spa/referrals-queue',
|
|
41
|
+
_validators: [validators.isUrlWithTemplateParameters(['patientUuid', 'visitUuid', 'encounterUuid'])],
|
|
50
42
|
},
|
|
51
43
|
},
|
|
52
44
|
pendingStatuses: {
|
|
53
45
|
_type: Type.Array,
|
|
54
|
-
_default: [
|
|
46
|
+
_default: ['Pending status', 'Referral unmet'],
|
|
55
47
|
_elements: {
|
|
56
48
|
_type: Type.String,
|
|
57
49
|
},
|
package/src/declarations.d.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
declare module
|
|
4
|
-
declare
|
|
1
|
+
declare module '@carbon/react';
|
|
2
|
+
declare module '*.css';
|
|
3
|
+
declare module '*.scss';
|
|
4
|
+
declare type SideNavProps = {};
|
|
5
5
|
|
|
6
6
|
type Referral = {
|
|
7
7
|
details: string;
|
package/src/index.ts
CHANGED
|
@@ -5,79 +5,25 @@
|
|
|
5
5
|
* microfrontend.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
defineConfigSchema,
|
|
11
|
-
registerBreadcrumbs,
|
|
12
|
-
} from "@openmrs/esm-framework";
|
|
13
|
-
import { configSchema } from "./config-schema";
|
|
8
|
+
import { getAsyncLifecycle, defineConfigSchema, registerBreadcrumbs } from '@openmrs/esm-framework';
|
|
9
|
+
import { configSchema } from './config-schema';
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* package.json
|
|
21
|
-
*/
|
|
22
|
-
declare var __VERSION__: string;
|
|
23
|
-
const version = __VERSION__;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* This tells the app shell how to obtain translation files: that they
|
|
27
|
-
* are JSON files in the directory `../translations` (which you should
|
|
28
|
-
* see in the directory structure).
|
|
29
|
-
*/
|
|
30
|
-
const importTranslation = require.context(
|
|
31
|
-
"../translations",
|
|
32
|
-
false,
|
|
33
|
-
/.json$/,
|
|
34
|
-
"lazy"
|
|
35
|
-
);
|
|
11
|
+
const moduleName = '@pih/esm-referrals-queue-app';
|
|
12
|
+
const options = {
|
|
13
|
+
featureName: 'referrals-queue',
|
|
14
|
+
moduleName,
|
|
15
|
+
};
|
|
36
16
|
|
|
37
|
-
|
|
38
|
-
* This tells the app shell what versions of what OpenMRS backend modules
|
|
39
|
-
* are expected. Warnings will appear if suitable modules are not
|
|
40
|
-
* installed. The keys are the part of the module name after
|
|
41
|
-
* `openmrs-module-`; e.g., `openmrs-module-fhir2` becomes `fhir2`.
|
|
42
|
-
*/
|
|
43
|
-
const backendDependencies = {};
|
|
17
|
+
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
|
|
44
18
|
|
|
45
|
-
|
|
46
|
-
* This function performs any setup that should happen at microfrontend
|
|
47
|
-
* load-time (such as defining the config schema) and then returns an
|
|
48
|
-
* object which describes how the React application(s) should be
|
|
49
|
-
* rendered.
|
|
50
|
-
*
|
|
51
|
-
* In this example, our return object contains a single page definition.
|
|
52
|
-
* It tells the app shell that the default export of `greeter.tsx`
|
|
53
|
-
* should be rendered when the route matches `hello`. The full route
|
|
54
|
-
* will be `openmrsSpaBase() + 'hello'`, which is usually
|
|
55
|
-
* `/openmrs/spa/hello`.
|
|
56
|
-
*/
|
|
57
|
-
function setupOpenMRS() {
|
|
58
|
-
const moduleName = "@pih/esm-referrals-queue-app";
|
|
59
|
-
const options = {
|
|
60
|
-
featureName: "referrals-queue",
|
|
61
|
-
moduleName,
|
|
62
|
-
};
|
|
19
|
+
export const root = getAsyncLifecycle(() => import('./root.component'), options);
|
|
63
20
|
|
|
21
|
+
export function startupApp() {
|
|
64
22
|
defineConfigSchema(moduleName, configSchema);
|
|
65
|
-
|
|
66
23
|
registerBreadcrumbs([
|
|
67
24
|
{
|
|
68
25
|
path: `${window.spaBase}/referrals-queue`,
|
|
69
|
-
title:
|
|
26
|
+
title: 'Referrals Queue',
|
|
70
27
|
},
|
|
71
28
|
]);
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
pages: [
|
|
75
|
-
{
|
|
76
|
-
load: getAsyncLifecycle(() => import("./root.component"), options),
|
|
77
|
-
route: "referrals-queue",
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
};
|
|
81
29
|
}
|
|
82
|
-
|
|
83
|
-
export { backendDependencies, importTranslation, setupOpenMRS, version };
|
|
@@ -1,185 +1,136 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Trans, useTranslation } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { createErrorHandler } from
|
|
8
|
-
import Table from
|
|
9
|
-
import styles from
|
|
10
|
-
import { getReferrals } from
|
|
11
|
-
|
|
12
|
-
// Override the webpack CSS loader config in order to load react-dates styles.
|
|
13
|
-
// See thread: https://github.com/webpack-contrib/css-loader/issues/295
|
|
14
|
-
import "!style-loader!css-loader!react-dates/lib/css/_datepicker.css";
|
|
15
|
-
import "!style-loader!css-loader!./react-dates-overrides.css";
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
3
|
+
import 'react-dates/initialize';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import { Content, Tile, Heading, Search, Dropdown, DatePicker, DatePickerInput } from '@carbon/react';
|
|
6
|
+
import 'moment/locale/fr';
|
|
7
|
+
import { createErrorHandler } from '@openmrs/esm-framework';
|
|
8
|
+
import Table from '../table/referrals-table.component';
|
|
9
|
+
import styles from './referrals-queue.scss';
|
|
10
|
+
import { getReferrals } from './referrals-queue.resource';
|
|
16
11
|
|
|
17
12
|
export default function ReferralsQueue(props: ReferralsQueueProps) {
|
|
18
13
|
const [referrals, setReferrals]: [Referral[], Function] = React.useState([]);
|
|
19
|
-
const [referralTypeFilter, setReferralTypeFilter] = React.useState(
|
|
20
|
-
const [statusFilter, setStatusFilter] = React.useState(
|
|
14
|
+
const [referralTypeFilter, setReferralTypeFilter] = React.useState('');
|
|
15
|
+
const [statusFilter, setStatusFilter] = React.useState('');
|
|
21
16
|
const today = moment();
|
|
22
|
-
const [fromDate, setFromDate] = React.useState(moment().subtract(1,
|
|
17
|
+
const [fromDate, setFromDate] = React.useState(moment().subtract(1, 'month'));
|
|
23
18
|
const [toDate, setToDate] = React.useState(today);
|
|
24
|
-
const [ptQuery, setPtQuery] = React.useState(
|
|
25
|
-
const [fromDateFocused, setFromDateFocused] = React.useState(false);
|
|
26
|
-
const [toDateFocused, setToDateFocused] = React.useState(false);
|
|
19
|
+
const [ptQuery, setPtQuery] = React.useState('');
|
|
27
20
|
const { t, i18n } = useTranslation();
|
|
28
21
|
|
|
29
22
|
const languageMatches = i18n.language?.match(/^(en|fr|ht).*/);
|
|
30
|
-
const language = (languageMatches && languageMatches[1]) ||
|
|
23
|
+
const language = (languageMatches && languageMatches[1]) || 'en';
|
|
31
24
|
|
|
32
25
|
React.useEffect(() => {
|
|
33
|
-
moment.locale(language ===
|
|
26
|
+
moment.locale(language === 'ht' ? 'fr' : language);
|
|
34
27
|
}, [language]);
|
|
35
28
|
|
|
36
29
|
React.useEffect(() => {
|
|
37
30
|
if (fromDate && toDate) {
|
|
38
31
|
const sub = getReferrals({
|
|
39
|
-
fromDate: fromDate.format(
|
|
40
|
-
toDate: toDate.format(
|
|
32
|
+
fromDate: fromDate.format('YYYY-MM-DD'),
|
|
33
|
+
toDate: toDate.format('YYYY-MM-DD'),
|
|
41
34
|
locale: language,
|
|
42
|
-
}).subscribe(
|
|
43
|
-
(referrals) => setReferrals(referrals),
|
|
44
|
-
createErrorHandler()
|
|
45
|
-
);
|
|
35
|
+
}).subscribe((referrals) => setReferrals(referrals), createErrorHandler());
|
|
46
36
|
return () => sub.unsubscribe();
|
|
47
37
|
}
|
|
48
38
|
}, [fromDate, toDate, language]);
|
|
49
39
|
|
|
50
|
-
// console.log(referrals);
|
|
51
40
|
const filteredReferrals = referrals
|
|
52
|
-
.filter(
|
|
53
|
-
|
|
41
|
+
.filter(
|
|
42
|
+
(r) => !referralTypeFilter || referralTypeFilter == t('any', 'Any') || r.referral_type == referralTypeFilter,
|
|
43
|
+
)
|
|
44
|
+
.filter((r) => !statusFilter || statusFilter == t('any', 'Any') || r.fulfillment_status == statusFilter)
|
|
54
45
|
.filter((r) => matchQuery(r, ptQuery));
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
];
|
|
46
|
+
|
|
47
|
+
const referralTypes = [t('any', 'Any'), ...new Set(referrals.map((r) => r.referral_type).filter((r) => r != null))];
|
|
48
|
+
|
|
49
|
+
const statuses = [t('any', 'Any'), ...new Set(referrals.map((r) => r.fulfillment_status).filter((r) => r != null))];
|
|
50
|
+
|
|
61
51
|
return (
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
52
|
+
<Content className={styles.container}>
|
|
53
|
+
<Tile>
|
|
54
|
+
<Heading>
|
|
65
55
|
<Trans i18nKey="referrals-queue">Referrals Queue</Trans>
|
|
66
|
-
</
|
|
56
|
+
</Heading>
|
|
67
57
|
<div className={styles.controlsContainer}>
|
|
68
58
|
<div className={styles.inputContainer}>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
date
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<Trans i18nKey="to">To</Trans>
|
|
87
|
-
</label>
|
|
88
|
-
<SingleDatePicker
|
|
89
|
-
id="to-date"
|
|
90
|
-
date={toDate}
|
|
91
|
-
onDateChange={(date) => setToDate(date)}
|
|
92
|
-
focused={toDateFocused}
|
|
93
|
-
onFocusChange={({ focused }) => setToDateFocused(focused)}
|
|
94
|
-
isOutsideRange={(date: Moment) => date.isAfter(today)}
|
|
95
|
-
displayFormat="DD MMM YYYY"
|
|
96
|
-
numberOfMonths={1}
|
|
97
|
-
/>
|
|
98
|
-
</div>
|
|
59
|
+
<DatePicker
|
|
60
|
+
dateFormat="d/M/Y"
|
|
61
|
+
datePickerType="range"
|
|
62
|
+
locale={language === 'ht' ? 'fr' : language}
|
|
63
|
+
maxDate={new Date().toISOString()}
|
|
64
|
+
onChange={(date) => {
|
|
65
|
+
if (date && date.length > 0) {
|
|
66
|
+
setFromDate(date ? moment(date[0]) : null);
|
|
67
|
+
if (date.length > 1) {
|
|
68
|
+
setToDate(date ? moment(date[1]) : null);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}}
|
|
72
|
+
value={[fromDate.toISOString(), toDate.toISOString()]}>
|
|
73
|
+
<DatePickerInput id="from-date" labelText={t('from', 'From')} />
|
|
74
|
+
<DatePickerInput id="to-date" labelText={t('to', 'To')} />
|
|
75
|
+
</DatePicker>
|
|
99
76
|
</div>
|
|
100
77
|
<div className={styles.inputContainer}>
|
|
101
|
-
<div
|
|
102
|
-
<
|
|
103
|
-
<Trans i18nKey="referral-type">Referral Type</Trans>
|
|
104
|
-
</label>
|
|
105
|
-
<select
|
|
78
|
+
<div style={{ width: 400 }}>
|
|
79
|
+
<Dropdown
|
|
106
80
|
id="referral-type"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
{referralTypes.map((t) => (
|
|
113
|
-
<option key={t} value={t}>
|
|
114
|
-
{t}
|
|
115
|
-
</option>
|
|
116
|
-
))}
|
|
117
|
-
</select>
|
|
81
|
+
label={t('select-referral-type', 'Select Referral Type')}
|
|
82
|
+
titleText={t('referral-type', 'Referral Type')}
|
|
83
|
+
items={referralTypes}
|
|
84
|
+
onChange={(e) => setReferralTypeFilter(e.selectedItem)}
|
|
85
|
+
/>
|
|
118
86
|
</div>
|
|
119
87
|
</div>
|
|
120
88
|
<div className={styles.inputContainer}>
|
|
121
|
-
<div
|
|
89
|
+
<div style={{ width: 400 }}>
|
|
122
90
|
<label htmlFor="query-input">
|
|
123
91
|
<Trans i18nKey="filter-by-patient">Filter by patient</Trans>
|
|
124
92
|
</label>
|
|
125
|
-
<input
|
|
126
|
-
id="query-input"
|
|
127
|
-
type="text"
|
|
128
|
-
value={ptQuery}
|
|
129
|
-
onChange={(e) => setPtQuery(e.target.value)}
|
|
130
|
-
className="omrs-input-outlined"
|
|
131
|
-
/>
|
|
93
|
+
<Search id="query-input" labelText="" onChange={(e) => setPtQuery(e.target.value)} />
|
|
132
94
|
</div>
|
|
133
95
|
</div>
|
|
134
96
|
<div className={styles.inputContainer}>
|
|
135
|
-
<div
|
|
136
|
-
<
|
|
137
|
-
<Trans i18nKey="status">Status</Trans>
|
|
138
|
-
</label>
|
|
139
|
-
<select
|
|
97
|
+
<div style={{ width: 400 }}>
|
|
98
|
+
<Dropdown
|
|
140
99
|
id="status"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{statuses.map((t) => (
|
|
147
|
-
<option key={t} value={t}>
|
|
148
|
-
{t}
|
|
149
|
-
</option>
|
|
150
|
-
))}
|
|
151
|
-
</select>
|
|
100
|
+
label={t('select-status', 'Select Status')}
|
|
101
|
+
titleText={t('status', 'Status')}
|
|
102
|
+
items={statuses}
|
|
103
|
+
onChange={(e) => setStatusFilter(e.selectedItem)}
|
|
104
|
+
/>
|
|
152
105
|
</div>
|
|
153
106
|
</div>
|
|
154
107
|
</div>
|
|
155
108
|
<div className={styles.tableContainer}>
|
|
156
109
|
<Table referrals={filteredReferrals} />
|
|
157
110
|
</div>
|
|
158
|
-
</
|
|
159
|
-
</
|
|
111
|
+
</Tile>
|
|
112
|
+
</Content>
|
|
160
113
|
);
|
|
161
114
|
}
|
|
162
115
|
|
|
163
116
|
function matchQuery(referral: Referral, query: string): boolean {
|
|
164
117
|
return (
|
|
165
118
|
!query ||
|
|
166
|
-
prepareQuery(query).every((regexp) =>
|
|
167
|
-
|
|
168
|
-
) ||
|
|
169
|
-
new RegExp(query, "i").test(referral.zl_emr_id)
|
|
119
|
+
prepareQuery(query).every((regexp) => regexp.test(removeDiacritics(referral.patient_name))) ||
|
|
120
|
+
new RegExp(query, 'i').test(referral.zl_emr_id)
|
|
170
121
|
);
|
|
171
122
|
}
|
|
172
123
|
|
|
173
124
|
function prepareQuery(query: string): RegExp[] {
|
|
174
125
|
return query.split(/\s/).map((token) => {
|
|
175
126
|
const tokenCleaned = removeDiacritics(token);
|
|
176
|
-
return new RegExp(
|
|
127
|
+
return new RegExp('\\b' + tokenCleaned, 'i');
|
|
177
128
|
});
|
|
178
129
|
}
|
|
179
130
|
|
|
180
131
|
function removeDiacritics(str: string) {
|
|
181
132
|
// From https://stackoverflow.com/a/37511463/1464495
|
|
182
|
-
return str.normalize(
|
|
133
|
+
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
183
134
|
}
|
|
184
135
|
|
|
185
136
|
type ReferralsQueueProps = {};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { openmrsObservableFetch } from
|
|
2
|
-
import {
|
|
1
|
+
import { openmrsObservableFetch } from '@openmrs/esm-framework';
|
|
2
|
+
import { type Observable } from 'rxjs';
|
|
3
|
+
import { map } from 'rxjs/operators';
|
|
3
4
|
|
|
4
|
-
export function getReferrals({
|
|
5
|
-
fromDate,
|
|
6
|
-
toDate,
|
|
7
|
-
locale,
|
|
8
|
-
}): Observable<Object[]> {
|
|
5
|
+
export function getReferrals({ fromDate, toDate, locale }): Observable<Object[]> {
|
|
9
6
|
return openmrsObservableFetch(
|
|
10
|
-
`/ws/rest/v1/reportingrest/reportdata/cd7dfde7-764a-4da6-81c2-d5887ed1df51?startDate=${fromDate}&endDate=${toDate}&locale=${locale}
|
|
11
|
-
).pipe(map(({ data }) => data[
|
|
7
|
+
`/ws/rest/v1/reportingrest/reportdata/cd7dfde7-764a-4da6-81c2-d5887ed1df51?startDate=${fromDate}&endDate=${toDate}&locale=${locale}`,
|
|
8
|
+
).pipe(map(({ data }) => data['dataSets'][0]['rows']));
|
|
12
9
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
margin-right: auto;
|
|
3
|
+
margin-left: auto;
|
|
4
|
+
max-width: 1500px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.tableContainer {
|
|
8
|
+
height: 500px;
|
|
9
|
+
overflow-x: auto;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.controlsContainer {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.inputContainer {
|
|
18
|
+
display: flex;
|
|
19
|
+
width: 50%;
|
|
20
|
+
min-width: 300px;
|
|
21
|
+
text-align: left;
|
|
22
|
+
padding: 0.5rem;
|
|
23
|
+
align-items: flex-end;
|
|
24
|
+
}
|