@pih/esm-referrals-queue-app 2.0.0-pre.17 → 2.1.1-pre.2
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 +39 -0
- package/dist/144.js +2 -0
- package/dist/144.js.LICENSE.txt +19 -0
- package/dist/144.js.map +1 -0
- package/dist/173.js +1 -0
- package/dist/173.js.map +1 -0
- package/dist/300.js +1 -0
- package/dist/{294.js → 41.js} +2 -2
- package/dist/41.js.map +1 -0
- package/dist/534.js +2 -0
- package/dist/{468.js.LICENSE.txt → 534.js.LICENSE.txt} +7 -24
- package/dist/534.js.map +1 -0
- package/dist/{757.js → 55.js} +1 -1
- package/dist/60.js +1 -0
- package/dist/60.js.map +1 -0
- package/dist/726.js +1 -0
- package/dist/726.js.map +1 -0
- package/dist/746.js +2 -0
- package/dist/{512.js.LICENSE.txt → 746.js.LICENSE.txt} +22 -0
- package/dist/746.js.map +1 -0
- package/dist/831.js +2 -0
- package/dist/{800.js.LICENSE.txt → 831.js.LICENSE.txt} +0 -2
- package/dist/831.js.map +1 -0
- package/dist/{319.js → 99.js} +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/pih-esm-referrals-queue-app.js +1 -1
- package/dist/pih-esm-referrals-queue-app.js.buildmanifest.json +197 -176
- package/dist/pih-esm-referrals-queue-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/jest.config.js +3 -0
- package/package.json +23 -42
- package/src/config-schema.ts +8 -16
- package/src/declarations.d.tsx +3 -7
- package/src/index.ts +7 -19
- package/src/referrals-queue/referrals-queue.component.tsx +36 -70
- package/src/referrals-queue/referrals-queue.resource.tsx +6 -9
- package/src/referrals-queue/referrals-queue.scss +1 -2
- package/src/referrals-queue/referrals-queue.test.tsx +124 -122
- package/src/root.component.test.tsx +3 -3
- package/src/root.component.tsx +5 -5
- package/src/setup-tests.ts +8 -8
- package/src/table/referrals-table.component.tsx +12 -31
- package/src/util.ts +5 -9
- 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-push +0 -7
- package/.prettierignore +0 -14
- package/LICENSE +0 -401
- package/dist/153.js +0 -1
- package/dist/153.js.map +0 -1
- package/dist/294.js.map +0 -1
- package/dist/468.js +0 -2
- package/dist/468.js.map +0 -1
- package/dist/512.js +0 -2
- package/dist/512.js.map +0 -1
- package/dist/559.js +0 -1
- package/dist/559.js.map +0 -1
- package/dist/574.js +0 -1
- package/dist/783.js +0 -1
- package/dist/783.js.map +0 -1
- package/dist/800.js +0 -2
- package/dist/800.js.map +0 -1
- package/dist/897.js +0 -2
- package/dist/897.js.LICENSE.txt +0 -21
- package/dist/897.js.map +0 -1
- package/jest.config.json +0 -19
- /package/dist/{294.js.LICENSE.txt → 41.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pih/esm-referrals-queue-app",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"license": "MPL-2.0",
|
|
3
|
+
"version": "2.1.1-pre.2",
|
|
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",
|
|
@@ -14,50 +15,40 @@
|
|
|
14
15
|
"lint": "eslint src --ext js,jsx,ts,tsx",
|
|
15
16
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
16
17
|
"typescript": "tsc",
|
|
17
|
-
"
|
|
18
|
-
"verify": "concurrently 'yarn:lint' 'yarn:test' 'yarn:typescript'",
|
|
18
|
+
"verify": "turbo lint typescript test --color --concurrency=2",
|
|
19
19
|
"coverage": "yarn test -- --coverage",
|
|
20
20
|
"prepare": "husky install"
|
|
21
21
|
},
|
|
22
|
-
"husky": {
|
|
23
|
-
"hooks": {
|
|
24
|
-
"pre-commit": "pretty-quick --staged && yarn verify"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
22
|
"browserslist": [
|
|
28
23
|
"extends browserslist-config-openmrs"
|
|
29
24
|
],
|
|
30
25
|
"keywords": [
|
|
31
|
-
"openmrs"
|
|
32
|
-
"microfrontends"
|
|
26
|
+
"openmrs"
|
|
33
27
|
],
|
|
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
28
|
"publishConfig": {
|
|
40
29
|
"access": "public"
|
|
41
30
|
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/PIH/openmrs-esm-pihemr.git"
|
|
44
34
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/PIH/openmrs-esm-pihemr/issues"
|
|
47
37
|
},
|
|
48
38
|
"peerDependencies": {
|
|
49
39
|
"@carbon/react": "^1.9.0",
|
|
50
|
-
"@openmrs/esm-framework": "
|
|
40
|
+
"@openmrs/esm-framework": "^5.4.0",
|
|
51
41
|
"dayjs": "1.x",
|
|
42
|
+
"i18next": "^21.10.0",
|
|
52
43
|
"react": "18.x",
|
|
44
|
+
"react-dom": "18.x",
|
|
53
45
|
"react-i18next": "11.x",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
46
|
+
"rxjs": "6.x",
|
|
47
|
+
"single-spa": "^6.x",
|
|
48
|
+
"swr": "^2.2.2"
|
|
56
49
|
},
|
|
57
50
|
"devDependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@carbon/react": "1.9.0",
|
|
60
|
-
"@openmrs/esm-framework": "^5.0.3-pre.878",
|
|
51
|
+
"@openmrs/esm-framework": "^5.4.0",
|
|
61
52
|
"@swc/core": "^1.2.203",
|
|
62
53
|
"@swc/jest": "^0.2.21",
|
|
63
54
|
"@testing-library/dom": "^7.20.0",
|
|
@@ -71,30 +62,20 @@
|
|
|
71
62
|
"@types/react-router": "^5.1.14",
|
|
72
63
|
"@types/react-router-dom": "^5.1.7",
|
|
73
64
|
"@types/webpack-env": "^1.16.0",
|
|
74
|
-
"@typescript-eslint/parser": "^5.28.0",
|
|
75
|
-
"concurrently": "^6.2.0",
|
|
76
65
|
"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
66
|
"identity-obj-proxy": "^3.0.0",
|
|
83
67
|
"jest": "^27.0.4",
|
|
84
68
|
"jest-cli": "^27.0.4",
|
|
85
69
|
"mockdate": "^3.0.5",
|
|
86
|
-
"openmrs": "^5.0.3-pre.878",
|
|
87
|
-
"prettier": "^2.3.0",
|
|
88
|
-
"pretty-quick": "^3.1.0",
|
|
89
70
|
"react": "^18.2.0",
|
|
90
71
|
"react-dates": "^21.8.0",
|
|
91
72
|
"react-dom": "^18.2.0",
|
|
92
73
|
"react-i18next": "^11.7.0",
|
|
93
74
|
"react-router-dom": "^6.3.0",
|
|
94
|
-
"rxjs": "^6.
|
|
95
|
-
"
|
|
75
|
+
"rxjs": "^6.6.7",
|
|
76
|
+
"swc-loader": "^0.2.6",
|
|
77
|
+
"webpack": "^5.90.3",
|
|
78
|
+
"webpack-cli": "^4.10.0"
|
|
96
79
|
},
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}
|
|
80
|
+
"stableVersion": "2.1.0"
|
|
81
|
+
}
|
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,12 +1,8 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
declare module
|
|
4
|
-
declare module "*.scss";
|
|
5
|
-
declare module "@carbon/react";
|
|
1
|
+
declare module '*.css';
|
|
2
|
+
declare module '*.scss';
|
|
3
|
+
declare module '@carbon/react';
|
|
6
4
|
declare type SideNavProps = {};
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
6
|
type Referral = {
|
|
11
7
|
details: string;
|
|
12
8
|
encounter_uuid: string;
|
package/src/index.ts
CHANGED
|
@@ -5,37 +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
|
-
const moduleName =
|
|
11
|
+
const moduleName = '@pih/esm-referrals-queue-app';
|
|
16
12
|
const options = {
|
|
17
|
-
featureName:
|
|
13
|
+
featureName: 'referrals-queue',
|
|
18
14
|
moduleName,
|
|
19
15
|
};
|
|
20
16
|
|
|
21
|
-
export const importTranslation = require.context(
|
|
22
|
-
"../translations",
|
|
23
|
-
false,
|
|
24
|
-
/.json$/,
|
|
25
|
-
"lazy"
|
|
26
|
-
);
|
|
17
|
+
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
|
|
27
18
|
|
|
28
|
-
export const root = getAsyncLifecycle(
|
|
29
|
-
() => import("./root.component"),
|
|
30
|
-
options
|
|
31
|
-
);
|
|
19
|
+
export const root = getAsyncLifecycle(() => import('./root.component'), options);
|
|
32
20
|
|
|
33
21
|
export function startupApp() {
|
|
34
22
|
defineConfigSchema(moduleName, configSchema);
|
|
35
23
|
registerBreadcrumbs([
|
|
36
24
|
{
|
|
37
25
|
path: `${window.spaBase}/referrals-queue`,
|
|
38
|
-
title:
|
|
26
|
+
title: 'Referrals Queue',
|
|
39
27
|
},
|
|
40
28
|
]);
|
|
41
29
|
}
|
|
@@ -1,79 +1,52 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Trans, useTranslation } from
|
|
3
|
-
import
|
|
4
|
-
import moment from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
DatePicker,
|
|
12
|
-
DatePickerInput,
|
|
13
|
-
} from "@carbon/react";
|
|
14
|
-
import "moment/locale/fr";
|
|
15
|
-
import { createErrorHandler } from "@openmrs/esm-framework";
|
|
16
|
-
import Table from "../table/referrals-table.component";
|
|
17
|
-
import styles from "./referrals-queue.scss";
|
|
18
|
-
import { getReferrals } from "./referrals-queue.resource";
|
|
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';
|
|
19
11
|
|
|
20
12
|
export default function ReferralsQueue(props: ReferralsQueueProps) {
|
|
21
13
|
const [referrals, setReferrals]: [Referral[], Function] = React.useState([]);
|
|
22
|
-
const [referralTypeFilter, setReferralTypeFilter] = React.useState(
|
|
23
|
-
const [statusFilter, setStatusFilter] = React.useState(
|
|
14
|
+
const [referralTypeFilter, setReferralTypeFilter] = React.useState('');
|
|
15
|
+
const [statusFilter, setStatusFilter] = React.useState('');
|
|
24
16
|
const today = moment();
|
|
25
|
-
const [fromDate, setFromDate] = React.useState(moment().subtract(1,
|
|
17
|
+
const [fromDate, setFromDate] = React.useState(moment().subtract(1, 'month'));
|
|
26
18
|
const [toDate, setToDate] = React.useState(today);
|
|
27
|
-
const [ptQuery, setPtQuery] = React.useState(
|
|
19
|
+
const [ptQuery, setPtQuery] = React.useState('');
|
|
28
20
|
const { t, i18n } = useTranslation();
|
|
29
21
|
|
|
30
22
|
const languageMatches = i18n.language?.match(/^(en|fr|ht).*/);
|
|
31
|
-
const language = (languageMatches && languageMatches[1]) ||
|
|
23
|
+
const language = (languageMatches && languageMatches[1]) || 'en';
|
|
32
24
|
|
|
33
25
|
React.useEffect(() => {
|
|
34
|
-
moment.locale(language ===
|
|
26
|
+
moment.locale(language === 'ht' ? 'fr' : language);
|
|
35
27
|
}, [language]);
|
|
36
28
|
|
|
37
29
|
React.useEffect(() => {
|
|
38
30
|
if (fromDate && toDate) {
|
|
39
31
|
const sub = getReferrals({
|
|
40
|
-
fromDate: fromDate.format(
|
|
41
|
-
toDate: toDate.format(
|
|
32
|
+
fromDate: fromDate.format('YYYY-MM-DD'),
|
|
33
|
+
toDate: toDate.format('YYYY-MM-DD'),
|
|
42
34
|
locale: language,
|
|
43
|
-
}).subscribe(
|
|
44
|
-
(referrals) => setReferrals(referrals),
|
|
45
|
-
createErrorHandler()
|
|
46
|
-
);
|
|
35
|
+
}).subscribe((referrals) => setReferrals(referrals), createErrorHandler());
|
|
47
36
|
return () => sub.unsubscribe();
|
|
48
37
|
}
|
|
49
38
|
}, [fromDate, toDate, language]);
|
|
50
39
|
|
|
51
40
|
const filteredReferrals = referrals
|
|
52
41
|
.filter(
|
|
53
|
-
(r) =>
|
|
54
|
-
!referralTypeFilter ||
|
|
55
|
-
referralTypeFilter == t("any", "Any") ||
|
|
56
|
-
r.referral_type == referralTypeFilter
|
|
57
|
-
)
|
|
58
|
-
.filter(
|
|
59
|
-
(r) =>
|
|
60
|
-
!statusFilter ||
|
|
61
|
-
statusFilter == t("any", "Any") ||
|
|
62
|
-
r.fulfillment_status == statusFilter
|
|
42
|
+
(r) => !referralTypeFilter || referralTypeFilter == t('any', 'Any') || r.referral_type == referralTypeFilter,
|
|
63
43
|
)
|
|
44
|
+
.filter((r) => !statusFilter || statusFilter == t('any', 'Any') || r.fulfillment_status == statusFilter)
|
|
64
45
|
.filter((r) => matchQuery(r, ptQuery));
|
|
65
46
|
|
|
66
|
-
const referralTypes = [
|
|
67
|
-
t("any", "Any"),
|
|
68
|
-
...new Set(referrals.map((r) => r.referral_type).filter((r) => r != null)),
|
|
69
|
-
];
|
|
47
|
+
const referralTypes = [t('any', 'Any'), ...new Set(referrals.map((r) => r.referral_type).filter((r) => r != null))];
|
|
70
48
|
|
|
71
|
-
const statuses = [
|
|
72
|
-
t("any", "Any"),
|
|
73
|
-
...new Set(
|
|
74
|
-
referrals.map((r) => r.fulfillment_status).filter((r) => r != null)
|
|
75
|
-
),
|
|
76
|
-
];
|
|
49
|
+
const statuses = [t('any', 'Any'), ...new Set(referrals.map((r) => r.fulfillment_status).filter((r) => r != null))];
|
|
77
50
|
|
|
78
51
|
return (
|
|
79
52
|
<Content className={styles.container}>
|
|
@@ -86,7 +59,7 @@ export default function ReferralsQueue(props: ReferralsQueueProps) {
|
|
|
86
59
|
<DatePicker
|
|
87
60
|
dateFormat="d/M/Y"
|
|
88
61
|
datePickerType="range"
|
|
89
|
-
locale={language ===
|
|
62
|
+
locale={language === 'ht' ? 'fr' : language}
|
|
90
63
|
maxDate={new Date().toISOString()}
|
|
91
64
|
onChange={(date) => {
|
|
92
65
|
if (date && date.length > 0) {
|
|
@@ -96,18 +69,17 @@ export default function ReferralsQueue(props: ReferralsQueueProps) {
|
|
|
96
69
|
}
|
|
97
70
|
}
|
|
98
71
|
}}
|
|
99
|
-
value={[fromDate.toISOString(), toDate.toISOString()]}
|
|
100
|
-
|
|
101
|
-
<DatePickerInput id="
|
|
102
|
-
<DatePickerInput id="to-date" labelText={t("to", "To")} />
|
|
72
|
+
value={[fromDate.toISOString(), toDate.toISOString()]}>
|
|
73
|
+
<DatePickerInput id="from-date" labelText={t('from', 'From')} />
|
|
74
|
+
<DatePickerInput id="to-date" labelText={t('to', 'To')} />
|
|
103
75
|
</DatePicker>
|
|
104
76
|
</div>
|
|
105
77
|
<div className={styles.inputContainer}>
|
|
106
78
|
<div style={{ width: 400 }}>
|
|
107
79
|
<Dropdown
|
|
108
80
|
id="referral-type"
|
|
109
|
-
label={t(
|
|
110
|
-
titleText={t(
|
|
81
|
+
label={t('select-referral-type', 'Select Referral Type')}
|
|
82
|
+
titleText={t('referral-type', 'Referral Type')}
|
|
111
83
|
items={referralTypes}
|
|
112
84
|
onChange={(e) => setReferralTypeFilter(e.selectedItem)}
|
|
113
85
|
/>
|
|
@@ -118,19 +90,15 @@ export default function ReferralsQueue(props: ReferralsQueueProps) {
|
|
|
118
90
|
<label htmlFor="query-input">
|
|
119
91
|
<Trans i18nKey="filter-by-patient">Filter by patient</Trans>
|
|
120
92
|
</label>
|
|
121
|
-
<Search
|
|
122
|
-
id="query-input"
|
|
123
|
-
labelText=""
|
|
124
|
-
onChange={(e) => setPtQuery(e.target.value)}
|
|
125
|
-
/>
|
|
93
|
+
<Search id="query-input" labelText="" onChange={(e) => setPtQuery(e.target.value)} />
|
|
126
94
|
</div>
|
|
127
95
|
</div>
|
|
128
96
|
<div className={styles.inputContainer}>
|
|
129
97
|
<div style={{ width: 400 }}>
|
|
130
98
|
<Dropdown
|
|
131
99
|
id="status"
|
|
132
|
-
label={t(
|
|
133
|
-
titleText={t(
|
|
100
|
+
label={t('select-status', 'Select Status')}
|
|
101
|
+
titleText={t('status', 'Status')}
|
|
134
102
|
items={statuses}
|
|
135
103
|
onChange={(e) => setStatusFilter(e.selectedItem)}
|
|
136
104
|
/>
|
|
@@ -148,23 +116,21 @@ export default function ReferralsQueue(props: ReferralsQueueProps) {
|
|
|
148
116
|
function matchQuery(referral: Referral, query: string): boolean {
|
|
149
117
|
return (
|
|
150
118
|
!query ||
|
|
151
|
-
prepareQuery(query).every((regexp) =>
|
|
152
|
-
|
|
153
|
-
) ||
|
|
154
|
-
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)
|
|
155
121
|
);
|
|
156
122
|
}
|
|
157
123
|
|
|
158
124
|
function prepareQuery(query: string): RegExp[] {
|
|
159
125
|
return query.split(/\s/).map((token) => {
|
|
160
126
|
const tokenCleaned = removeDiacritics(token);
|
|
161
|
-
return new RegExp(
|
|
127
|
+
return new RegExp('\\b' + tokenCleaned, 'i');
|
|
162
128
|
});
|
|
163
129
|
}
|
|
164
130
|
|
|
165
131
|
function removeDiacritics(str: string) {
|
|
166
132
|
// From https://stackoverflow.com/a/37511463/1464495
|
|
167
|
-
return str.normalize(
|
|
133
|
+
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
168
134
|
}
|
|
169
135
|
|
|
170
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
|
}
|