@openmrs/esm-active-visits-app 3.0.0-pre.178 → 3.0.0-pre.196
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/dist/165.openmrs-esm-active-visits-app.js +1 -1
- package/dist/165.openmrs-esm-active-visits-app.js.map +1 -1
- package/dist/2.openmrs-esm-active-visits-app.js +2 -0
- package/dist/2.openmrs-esm-active-visits-app.js.map +1 -0
- package/dist/404.openmrs-esm-active-visits-app.js +3 -0
- package/dist/{799.openmrs-esm-active-visits-app.js.LICENSE.txt → 404.openmrs-esm-active-visits-app.js.LICENSE.txt} +0 -0
- package/dist/404.openmrs-esm-active-visits-app.js.map +1 -0
- package/dist/415.openmrs-esm-active-visits-app.js +1 -1
- package/dist/415.openmrs-esm-active-visits-app.js.map +1 -1
- package/dist/574.openmrs-esm-active-visits-app.js +1 -1
- package/dist/openmrs-esm-active-visits-app.js +1 -1
- package/dist/openmrs-esm-active-visits-app.js.buildmanifest.json +54 -54
- package/dist/openmrs-esm-active-visits-app.js.map +1 -1
- package/package.json +2 -2
- package/src/active-visits-widget/active-visits.component.tsx +137 -133
- package/src/active-visits-widget/active-visits.resource.tsx +34 -10
- package/src/active-visits-widget/active-visits.scss +7 -0
- package/src/visits-summary/visit-detail.component.tsx +42 -46
- package/src/visits-summary/visit.resource.ts +14 -5
- package/translations/en.json +2 -1
- package/dist/288.openmrs-esm-active-visits-app.js +0 -2
- package/dist/288.openmrs-esm-active-visits-app.js.map +0 -1
- package/dist/799.openmrs-esm-active-visits-app.js +0 -3
- package/dist/799.openmrs-esm-active-visits-app.js.map +0 -1
|
@@ -13,36 +13,31 @@ import DataTable, {
|
|
|
13
13
|
TableExpandHeader,
|
|
14
14
|
} from 'carbon-components-react/es/components/DataTable';
|
|
15
15
|
import DataTableSkeleton from 'carbon-components-react/es/components/DataTableSkeleton';
|
|
16
|
+
import InlineLoading from 'carbon-components-react/lib/components/InlineLoading';
|
|
16
17
|
import Pagination from 'carbon-components-react/es/components/Pagination';
|
|
17
18
|
import Search from 'carbon-components-react/es/components/Search';
|
|
18
19
|
import { useLayoutType, useConfig, usePagination, ConfigurableLink, ExtensionSlot } from '@openmrs/esm-framework';
|
|
19
20
|
import { useTranslation } from 'react-i18next';
|
|
20
|
-
import {
|
|
21
|
+
import { ActiveVisit, useActiveVisits } from './active-visits.resource';
|
|
21
22
|
import styles from './active-visits.scss';
|
|
22
23
|
import dayjs from 'dayjs';
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dayjs(startDatetime).get('month') === todayDate.get('month') &&
|
|
29
|
-
dayjs(startDatetime).get('year') === todayDate.get('year');
|
|
30
|
-
if (today) {
|
|
31
|
-
return `Today - ${dayjs(startDatetime).format('HH:mm')}`;
|
|
32
|
-
} else {
|
|
33
|
-
return dayjs(startDatetime).format("DD MMM 'YY - HH:mm");
|
|
34
|
-
}
|
|
25
|
+
interface PaginationData {
|
|
26
|
+
goTo: (page: number) => void;
|
|
27
|
+
results: Array<ActiveVisit>;
|
|
28
|
+
currentPage: number;
|
|
35
29
|
}
|
|
36
30
|
|
|
37
31
|
const ActiveVisitsTable = () => {
|
|
38
32
|
const { t } = useTranslation();
|
|
33
|
+
const config = useConfig();
|
|
39
34
|
const layout = useLayoutType();
|
|
35
|
+
|
|
36
|
+
const { data: activeVisits, isError, isLoading, isValidating } = useActiveVisits();
|
|
37
|
+
|
|
40
38
|
const desktopView = layout === 'desktop';
|
|
41
|
-
const config = useConfig();
|
|
42
|
-
const [currentPageSize, setPageSize] = useState(config?.activeVisits?.pageSize ?? 10);
|
|
43
39
|
const pageSizes = config?.activeVisits?.pageSizes ?? [10, 20, 50];
|
|
44
|
-
const [
|
|
45
|
-
const [activeVisits, setActiveVisits] = useState<ActiveVisitRow[]>([]);
|
|
40
|
+
const [currentPageSize, setPageSize] = useState(config?.activeVisits?.pageSize ?? 10);
|
|
46
41
|
const [searchString, setSearchString] = useState('');
|
|
47
42
|
|
|
48
43
|
const headerData = useMemo(
|
|
@@ -54,8 +49,8 @@ const ActiveVisitsTable = () => {
|
|
|
54
49
|
},
|
|
55
50
|
{
|
|
56
51
|
id: 1,
|
|
57
|
-
header: t('
|
|
58
|
-
key: '
|
|
52
|
+
header: t('idNumber', 'ID Number'),
|
|
53
|
+
key: 'idNumber',
|
|
59
54
|
},
|
|
60
55
|
{
|
|
61
56
|
id: 2,
|
|
@@ -81,31 +76,15 @@ const ActiveVisitsTable = () => {
|
|
|
81
76
|
[t],
|
|
82
77
|
);
|
|
83
78
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
id: `${ind}`,
|
|
89
|
-
visitStartTime: formatDatetime(visit.startDatetime),
|
|
90
|
-
IDNumber: visit?.patient?.identifiers[0]?.identifier,
|
|
91
|
-
name: visit?.patient?.person?.display,
|
|
92
|
-
gender: visit?.patient?.person?.gender,
|
|
93
|
-
age: visit?.patient?.person?.age,
|
|
94
|
-
visitType: visit?.visitType?.display,
|
|
95
|
-
patientUuid: visit?.patient?.uuid,
|
|
96
|
-
visitUuid: visit?.uuid,
|
|
97
|
-
}));
|
|
98
|
-
setActiveVisits(rowData);
|
|
99
|
-
setLoading(false);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return () => abortController.abort();
|
|
103
|
-
}, []);
|
|
79
|
+
const rowData = activeVisits.map((visit) => ({
|
|
80
|
+
...visit,
|
|
81
|
+
visitStartTime: formatDatetime(visit.visitStartTime),
|
|
82
|
+
}));
|
|
104
83
|
|
|
105
84
|
const searchResults = useMemo(() => {
|
|
106
85
|
if (searchString && searchString.trim() !== '') {
|
|
107
86
|
const search = searchString.toLowerCase();
|
|
108
|
-
return
|
|
87
|
+
return rowData.filter((activeVisitRow) =>
|
|
109
88
|
Object.keys(activeVisitRow).some((header) => {
|
|
110
89
|
if (header === 'patientUuid') {
|
|
111
90
|
return false;
|
|
@@ -114,11 +93,16 @@ const ActiveVisitsTable = () => {
|
|
|
114
93
|
}),
|
|
115
94
|
);
|
|
116
95
|
} else {
|
|
117
|
-
return
|
|
96
|
+
return rowData;
|
|
118
97
|
}
|
|
119
|
-
}, [searchString,
|
|
98
|
+
}, [searchString, rowData]);
|
|
99
|
+
|
|
100
|
+
const {
|
|
101
|
+
goTo,
|
|
102
|
+
results: paginatedActiveVisits,
|
|
103
|
+
currentPage,
|
|
104
|
+
}: PaginationData = usePagination(searchResults, currentPageSize);
|
|
120
105
|
|
|
121
|
-
const { goTo, results, currentPage } = usePagination(searchResults, currentPageSize);
|
|
122
106
|
const handleSearch = useCallback((e) => setSearchString(e.target.value), []);
|
|
123
107
|
|
|
124
108
|
useEffect(() => {
|
|
@@ -127,98 +111,118 @@ const ActiveVisitsTable = () => {
|
|
|
127
111
|
}
|
|
128
112
|
}, [searchString]);
|
|
129
113
|
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
<
|
|
136
|
-
{
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
114
|
+
if (isLoading) {
|
|
115
|
+
return <DataTableSkeleton role="progressbar" />;
|
|
116
|
+
}
|
|
117
|
+
if (activeVisits?.length) {
|
|
118
|
+
return (
|
|
119
|
+
<div className={styles.activeVisitsContainer}>
|
|
120
|
+
<div className={styles.activeVisitsDetailHeaderContainer}>
|
|
121
|
+
<h4 className={styles.productiveHeading02}>{t('activeVisits', 'Active Visits')}</h4>
|
|
122
|
+
<div className={styles.backgroundDataFetchingIndicator}>
|
|
123
|
+
<span>{isValidating ? <InlineLoading /> : null}</span>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
<DataTable rows={paginatedActiveVisits} headers={headerData} isSortable>
|
|
127
|
+
{({ rows, headers, getHeaderProps, getTableProps, getBatchActionProps, getRowProps }) => (
|
|
128
|
+
<TableContainer title="" className={styles.tableContainer}>
|
|
129
|
+
<TableToolbar>
|
|
130
|
+
<TableToolbarContent>
|
|
131
|
+
<Search
|
|
132
|
+
tabIndex={getBatchActionProps().shouldShowBatchActions ? -1 : 0}
|
|
133
|
+
labelText=""
|
|
134
|
+
placeholder={t('filterTable', 'Filter table')}
|
|
135
|
+
onChange={handleSearch}
|
|
136
|
+
/>
|
|
137
|
+
</TableToolbarContent>
|
|
138
|
+
</TableToolbar>
|
|
139
|
+
<Table className={styles.activeVisitsTable} {...getTableProps()} size={desktopView ? 'short' : 'normal'}>
|
|
140
|
+
<TableHead>
|
|
141
|
+
<TableRow>
|
|
142
|
+
<TableExpandHeader />
|
|
143
|
+
{headers.map((header) => (
|
|
144
|
+
<TableHeader {...getHeaderProps({ header })}>{header.header}</TableHeader>
|
|
145
|
+
))}
|
|
146
|
+
</TableRow>
|
|
147
|
+
</TableHead>
|
|
148
|
+
<TableBody>
|
|
149
|
+
{rows.map((row, index) => (
|
|
150
|
+
<React.Fragment key={index}>
|
|
151
|
+
<TableExpandRow {...getRowProps({ row })}>
|
|
152
|
+
{row.cells.map((cell) => (
|
|
153
|
+
<TableCell key={cell.id}>
|
|
154
|
+
{cell.info.header === 'name' ? (
|
|
155
|
+
<ConfigurableLink
|
|
156
|
+
to={`\${openmrsSpaBase}/patient/${paginatedActiveVisits?.[index]?.patientUuid}/chart/`}>
|
|
157
|
+
{cell.value}
|
|
158
|
+
</ConfigurableLink>
|
|
159
|
+
) : (
|
|
160
|
+
cell.value
|
|
161
|
+
)}
|
|
162
|
+
</TableCell>
|
|
163
|
+
))}
|
|
164
|
+
</TableExpandRow>
|
|
165
|
+
{row.isExpanded && (
|
|
166
|
+
<TableRow className={styles.expandedActiveVisitRow}>
|
|
167
|
+
<th colSpan={headers.length + 2}>
|
|
168
|
+
<ExtensionSlot
|
|
169
|
+
className={styles.visitSummaryContainer}
|
|
170
|
+
extensionSlotName="visit-summary-slot"
|
|
171
|
+
state={{
|
|
172
|
+
visitUuid: paginatedActiveVisits[index]?.visitUuid,
|
|
173
|
+
patientUuid: paginatedActiveVisits[index]?.patientUuid,
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
</th>
|
|
177
|
+
</TableRow>
|
|
178
|
+
)}
|
|
179
|
+
</React.Fragment>
|
|
154
180
|
))}
|
|
155
|
-
</
|
|
156
|
-
</
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</React.Fragment>
|
|
188
|
-
))}
|
|
189
|
-
</TableBody>
|
|
190
|
-
</Table>
|
|
191
|
-
{rows.length === 0 && (
|
|
192
|
-
<p
|
|
193
|
-
style={{ height: desktopView ? '2rem' : '3rem', marginLeft: desktopView ? '2rem' : '3rem' }}
|
|
194
|
-
className={`${styles.emptyRow} ${styles.bodyLong01}`}>
|
|
195
|
-
{t('noVisitsFound', 'No visits found')}
|
|
196
|
-
</p>
|
|
197
|
-
)}
|
|
198
|
-
<Pagination
|
|
199
|
-
forwardText=""
|
|
200
|
-
backwardText=""
|
|
201
|
-
page={currentPage}
|
|
202
|
-
pageSize={currentPageSize}
|
|
203
|
-
pageSizes={pageSizes}
|
|
204
|
-
totalItems={searchResults.length}
|
|
205
|
-
className={styles.pagination}
|
|
206
|
-
onChange={({ pageSize, page }) => {
|
|
207
|
-
if (pageSize !== currentPageSize) {
|
|
208
|
-
setPageSize(pageSize);
|
|
209
|
-
}
|
|
210
|
-
if (page !== currentPage) {
|
|
211
|
-
goTo(page);
|
|
212
|
-
}
|
|
213
|
-
}}
|
|
214
|
-
/>
|
|
215
|
-
</TableContainer>
|
|
216
|
-
)}
|
|
217
|
-
</DataTable>
|
|
218
|
-
</div>
|
|
219
|
-
) : (
|
|
220
|
-
<DataTableSkeleton />
|
|
221
|
-
);
|
|
181
|
+
</TableBody>
|
|
182
|
+
</Table>
|
|
183
|
+
{rows.length === 0 && (
|
|
184
|
+
<p
|
|
185
|
+
style={{ height: desktopView ? '2rem' : '3rem', marginLeft: desktopView ? '2rem' : '3rem' }}
|
|
186
|
+
className={`${styles.emptyRow} ${styles.bodyLong01}`}>
|
|
187
|
+
{t('noVisitsFound', 'No visits found')}
|
|
188
|
+
</p>
|
|
189
|
+
)}
|
|
190
|
+
<Pagination
|
|
191
|
+
forwardText="Next page"
|
|
192
|
+
backwardText="Previous page"
|
|
193
|
+
page={currentPage}
|
|
194
|
+
pageSize={currentPageSize}
|
|
195
|
+
pageSizes={pageSizes}
|
|
196
|
+
totalItems={searchResults.length}
|
|
197
|
+
className={styles.pagination}
|
|
198
|
+
onChange={({ pageSize, page }) => {
|
|
199
|
+
if (pageSize !== currentPageSize) {
|
|
200
|
+
setPageSize(pageSize);
|
|
201
|
+
}
|
|
202
|
+
if (page !== currentPage) {
|
|
203
|
+
goTo(page);
|
|
204
|
+
}
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
</TableContainer>
|
|
208
|
+
)}
|
|
209
|
+
</DataTable>
|
|
210
|
+
</div>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
222
213
|
};
|
|
223
214
|
|
|
215
|
+
function formatDatetime(startDatetime) {
|
|
216
|
+
const dateToday = dayjs();
|
|
217
|
+
const today =
|
|
218
|
+
dayjs(startDatetime).get('date') === dateToday.get('date') &&
|
|
219
|
+
dayjs(startDatetime).get('month') === dateToday.get('month') &&
|
|
220
|
+
dayjs(startDatetime).get('year') === dateToday.get('year');
|
|
221
|
+
if (today) {
|
|
222
|
+
return `Today - ${dayjs(startDatetime).format('HH:mm')}`;
|
|
223
|
+
} else {
|
|
224
|
+
return dayjs(startDatetime).format("DD MMM 'YY - HH:mm");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
224
228
|
export default ActiveVisitsTable;
|
|
@@ -1,23 +1,47 @@
|
|
|
1
|
+
import useSWR from 'swr';
|
|
1
2
|
import { openmrsFetch, Visit } from '@openmrs/esm-framework';
|
|
2
3
|
|
|
3
|
-
export interface
|
|
4
|
+
export interface ActiveVisit {
|
|
5
|
+
age: string;
|
|
4
6
|
id: string;
|
|
5
|
-
|
|
6
|
-
IDNumber: string;
|
|
7
|
-
name: string;
|
|
7
|
+
idNumber: string;
|
|
8
8
|
gender: string;
|
|
9
|
-
|
|
10
|
-
visitType: string;
|
|
9
|
+
name: string;
|
|
11
10
|
patientUuid: string;
|
|
11
|
+
visitStartTime: string;
|
|
12
|
+
visitType: string;
|
|
12
13
|
visitUuid: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export function
|
|
16
|
-
const
|
|
16
|
+
export function useActiveVisits() {
|
|
17
|
+
const customRepresentation =
|
|
17
18
|
'custom:(uuid,patient:(uuid,identifiers:(identifier,uuid),person:(age,display,gender,uuid)),' +
|
|
18
19
|
'visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,' +
|
|
19
20
|
'stopDatetime)';
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
const { data, error, isValidating } = useSWR<{ data: { results: Array<Visit> } }, Error>(
|
|
23
|
+
`/ws/rest/v1/visit?includeInactive=false&v=${customRepresentation}`,
|
|
24
|
+
openmrsFetch,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const mapVisitProperties = (visit: Visit): ActiveVisit => ({
|
|
28
|
+
age: visit?.patient?.person?.age,
|
|
29
|
+
id: visit.uuid,
|
|
30
|
+
idNumber: visit?.patient?.identifiers[0]?.identifier,
|
|
31
|
+
gender: visit?.patient?.person?.gender,
|
|
32
|
+
name: visit?.patient?.person?.display,
|
|
33
|
+
patientUuid: visit?.patient?.uuid,
|
|
34
|
+
visitStartTime: visit.startDate,
|
|
35
|
+
visitType: visit?.visitType?.display,
|
|
36
|
+
visitUuid: visit.uuid,
|
|
22
37
|
});
|
|
38
|
+
|
|
39
|
+
const formattedActiveVisits = data?.data?.results.length ? data.data.results.map(mapVisitProperties) : [];
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
data: formattedActiveVisits,
|
|
43
|
+
isLoading: !data && !error,
|
|
44
|
+
isError: error,
|
|
45
|
+
isValidating,
|
|
46
|
+
};
|
|
23
47
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
2
|
import Button from 'carbon-components-react/es/components/Button';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { Encounter,
|
|
4
|
+
import { Encounter, useVisit } from './visit.resource';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
|
-
import { Visit, createErrorHandler } from '@openmrs/esm-framework';
|
|
7
6
|
import styles from './visit-detail-overview.scss';
|
|
8
7
|
import EncounterList from './visits-components/encounter-list.component';
|
|
9
8
|
import VisitSummary from './visits-components/visit-summary.component';
|
|
10
9
|
import DataTableSkeleton from 'carbon-components-react/es/components/DataTableSkeleton';
|
|
11
10
|
|
|
12
|
-
function formatDateTime(date) {
|
|
13
|
-
return dayjs(date).format('MMM DD, YYYY - hh:mm');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
11
|
interface VisitDetailComponentProps {
|
|
17
12
|
visitUuid: string;
|
|
18
13
|
patientUuid: string;
|
|
@@ -21,11 +16,13 @@ interface VisitDetailComponentProps {
|
|
|
21
16
|
const VisitDetailComponent: React.FC<VisitDetailComponentProps> = ({ visitUuid, patientUuid }) => {
|
|
22
17
|
const { t } = useTranslation();
|
|
23
18
|
const [listView, setView] = useState(true);
|
|
24
|
-
|
|
19
|
+
|
|
20
|
+
const { data: visit, isError, isLoading, isValidating } = useVisit(visitUuid);
|
|
21
|
+
|
|
25
22
|
const encounters = useMemo(
|
|
26
23
|
() =>
|
|
27
24
|
visit
|
|
28
|
-
? visit
|
|
25
|
+
? visit?.encounters?.map((encounter: Encounter) => ({
|
|
29
26
|
id: encounter.uuid,
|
|
30
27
|
time: dayjs(encounter.encounterDateTime).format('hh:mm'),
|
|
31
28
|
encounterType: encounter.encounterType.display,
|
|
@@ -36,45 +33,44 @@ const VisitDetailComponent: React.FC<VisitDetailComponentProps> = ({ visitUuid,
|
|
|
36
33
|
[visit],
|
|
37
34
|
);
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
onClick={() => setView(false)}>
|
|
68
|
-
{t('visitSummary', 'Visit Summary')}
|
|
69
|
-
</Button>
|
|
36
|
+
if (isLoading) {
|
|
37
|
+
return <DataTableSkeleton role="progressbar" />;
|
|
38
|
+
}
|
|
39
|
+
if (visit) {
|
|
40
|
+
return (
|
|
41
|
+
<div className={styles.visitsDetailWidgetContainer}>
|
|
42
|
+
<div className={styles.visitsDetailHeaderContainer}>
|
|
43
|
+
<h4 className={styles.productiveHeading02}>
|
|
44
|
+
{visit?.visitType?.display}
|
|
45
|
+
<br />
|
|
46
|
+
<p className={`${styles.bodyLong01} ${styles.text02}`}>{formatDateTime(visit?.startDatetime)}</p>
|
|
47
|
+
</h4>
|
|
48
|
+
<div className={styles.toggleButtons}>
|
|
49
|
+
<Button
|
|
50
|
+
className={`${styles.toggle} ${listView ? styles.toggleActive : ''}`}
|
|
51
|
+
size="small"
|
|
52
|
+
kind="ghost"
|
|
53
|
+
onClick={() => setView(true)}>
|
|
54
|
+
{t('allEncounters', 'All Encounters')}
|
|
55
|
+
</Button>
|
|
56
|
+
<Button
|
|
57
|
+
className={`${styles.toggle} ${!listView ? styles.toggleActive : ''}`}
|
|
58
|
+
size="small"
|
|
59
|
+
kind="ghost"
|
|
60
|
+
onClick={() => setView(false)}>
|
|
61
|
+
{t('visitSummary', 'Visit Summary')}
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
70
64
|
</div>
|
|
65
|
+
{listView && visit?.encounters && <EncounterList visitUuid={visit.uuid} encounters={encounters} />}
|
|
66
|
+
{!listView && <VisitSummary encounters={visit.encounters} patientUuid={patientUuid} />}
|
|
71
67
|
</div>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</div>
|
|
75
|
-
) : (
|
|
76
|
-
<DataTableSkeleton />
|
|
77
|
-
);
|
|
68
|
+
);
|
|
69
|
+
}
|
|
78
70
|
};
|
|
79
71
|
|
|
72
|
+
function formatDateTime(date) {
|
|
73
|
+
return date ? dayjs(date).format('MMM DD, YYYY - hh:mm') : null;
|
|
74
|
+
}
|
|
75
|
+
|
|
80
76
|
export default VisitDetailComponent;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { openmrsFetch, Visit } from '@openmrs/esm-framework';
|
|
2
|
+
import useSWR from 'swr';
|
|
2
3
|
|
|
3
4
|
export interface Encounter {
|
|
4
5
|
uuid: string;
|
|
@@ -125,8 +126,8 @@ export interface OrderItem {
|
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
export function
|
|
129
|
-
const
|
|
129
|
+
export function useVisit(visitUuid: string) {
|
|
130
|
+
const customRepresentation =
|
|
130
131
|
'custom:(uuid,encounters:(uuid,encounterDatetime,' +
|
|
131
132
|
'orders:(uuid,dateActivated,' +
|
|
132
133
|
'drug:(uuid,name,strength),doseUnits:(uuid,display),' +
|
|
@@ -139,9 +140,17 @@ export function fetchVisit(visitUuid: string, abortController: AbortController)
|
|
|
139
140
|
'encounterProviders:(uuid,display,encounterRole:(uuid,display),' +
|
|
140
141
|
'provider:(uuid,person:(uuid,display)))),visitType:(uuid,name,display),startDatetime';
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const { data, error, isValidating } = useSWR<{ data: Visit }, Error>(
|
|
144
|
+
`/ws/rest/v1/visit/${visitUuid}?v=${customRepresentation}`,
|
|
145
|
+
openmrsFetch,
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
data: data ? data.data : null,
|
|
150
|
+
isError: error,
|
|
151
|
+
isLoading: !data && !error,
|
|
152
|
+
isValidating,
|
|
153
|
+
};
|
|
145
154
|
}
|
|
146
155
|
|
|
147
156
|
export function getDosage(strength: string, doseNumber: number) {
|
package/translations/en.json
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
"diagnoses": "Diagnoses",
|
|
6
6
|
"dose": "Dose",
|
|
7
7
|
"encounterType": "Encounter Type",
|
|
8
|
+
"filterTable": "Filter table",
|
|
8
9
|
"gender": "Gender",
|
|
9
|
-
"
|
|
10
|
+
"idNumber": "ID Number",
|
|
10
11
|
"medications": "Medications",
|
|
11
12
|
"name": "Name",
|
|
12
13
|
"noDiagnosesFound": "No diagnoses found",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_openmrs_esm_active_visits_app=self.webpackChunk_openmrs_esm_active_visits_app||[]).push([[288],{9288:(e,t,a)=>{a.d(t,{Z:()=>K});var n,r,i,l,o,c=a(3980),s=a.n(c),u=a(5954),p=a(2779),d=a.n(p),f=a(5214),g=a(2434),m=a(3346),b=a(3766),h=["children"],v=["children"],y=u.default.forwardRef((function(e,t){var a=e.children,l=(0,b._)(e,h);return u.default.createElement(b.I,(0,b.a)({width:16,height:16,viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",ref:t},l),n||(n=u.default.createElement("path",{fill:"none",d:"M16,26a1.5,1.5,0,1,1,1.5-1.5A1.5,1.5,0,0,1,16,26Zm-1.125-5h2.25V12h-2.25Z","data-icon-path":"inner-path"})),r||(r=u.default.createElement("path",{d:"M16.002,6.1714h-.004L4.6487,27.9966,4.6506,28H27.3494l.0019-.0034ZM14.875,12h2.25v9h-2.25ZM16,26a1.5,1.5,0,1,1,1.5-1.5A1.5,1.5,0,0,1,16,26Z"})),i||(i=u.default.createElement("path",{d:"M29,30H3a1,1,0,0,1-.8872-1.4614l13-25a1,1,0,0,1,1.7744,0l13,25A1,1,0,0,1,29,30ZM4.6507,28H27.3493l.002-.0033L16.002,6.1714h-.004L4.6487,27.9967Z"})),a)})),x=u.default.forwardRef((function(e,t){var a=e.children,n=(0,b._)(e,v);return u.default.createElement(b.I,(0,b.a)({width:16,height:16,viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",ref:t},n),l||(l=u.default.createElement("path",{d:"M8,1C4.2,1,1,4.2,1,8s3.2,7,7,7s7-3.1,7-7S11.9,1,8,1z M7.5,4h1v5h-1C7.5,9,7.5,4,7.5,4z M8,12.2\tc-0.4,0-0.8-0.4-0.8-0.8s0.3-0.8,0.8-0.8c0.4,0,0.8,0.4,0.8,0.8S8.4,12.2,8,12.2z"})),o||(o=u.default.createElement("path",{d:"M7.5,4h1v5h-1C7.5,9,7.5,4,7.5,4z M8,12.2c-0.4,0-0.8-0.4-0.8-0.8s0.3-0.8,0.8-0.8\tc0.4,0,0.8,0.4,0.8,0.8S8.4,12.2,8,12.2z","data-icon-path":"inner-path",opacity:"0"})),a)})),_=a(3597),w=a(6590),S=a(330),T=["className","id","inline","labelText","disabled","children","noLabel","iconDescription","hideLabel","invalid","invalidText","helperText","light","size","warn","warnText"];function O(){return O=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},O.apply(this,arguments)}function P(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var z=u.default.forwardRef((function(e,t){var a,n,r,i=e.className,l=e.id,o=e.inline,c=e.labelText,s=e.disabled,p=e.children,f=e.noLabel,g=(e.iconDescription,e.hideLabel),b=e.invalid,h=e.invalidText,v=e.helperText,_=e.light,z=e.size,N=e.warn,E=e.warnText,j=function(e,t){if(null==e)return{};var a,n,r=function(e,t){if(null==e)return{};var a,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}(e,T),I=(0,S.A)(),C=(0,w.ye)("enable-v11-release"),k=d()((P(a={},"".concat(I,"--select"),!0),P(a,"".concat(I,"--select--inline"),o),P(a,"".concat(I,"--select--light"),_),P(a,"".concat(I,"--select--invalid"),b),P(a,"".concat(I,"--select--disabled"),s),P(a,"".concat(I,"--select--warning"),N),a),[C?null:i]),R=d()("".concat(I,"--label"),(P(n={},"".concat(I,"--visually-hidden"),g),P(n,"".concat(I,"--label--disabled"),s),n)),M=d()((P(r={},"".concat(I,"--select-input"),!0),P(r,"".concat(I,"--select-input--").concat(z),z),r)),L="".concat(l,"-error-msg"),D=b?h:N?E:void 0,Z=b||N?u.default.createElement("div",{className:"".concat(I,"--form-requirement"),id:L},D):null,A=d()("".concat(I,"--form__helper-text"),P({},"".concat(I,"--form__helper-text--disabled"),s)),q=v?u.default.createElement("div",{className:A},v):null,U={};b&&(U["aria-describedby"]=L);var B=u.default.createElement(u.default.Fragment,null,u.default.createElement("select",O({},j,U,{id:l,className:M,disabled:s||void 0,"aria-invalid":b||void 0,ref:t}),p),u.default.createElement(m.cRw,{className:"".concat(I,"--select__arrow")}),b&&u.default.createElement(x,{className:"".concat(I,"--select__invalid-icon")}),!b&&N&&u.default.createElement(y,{className:"".concat(I,"--select__invalid-icon ").concat(I,"--select__invalid-icon--warning")}));return u.default.createElement("div",{className:C?d()("".concat(I,"--form-item"),i):"".concat(I,"--form-item")},u.default.createElement("div",{className:k},!f&&u.default.createElement("label",{htmlFor:l,className:R},c),o&&u.default.createElement("div",{className:"".concat(I,"--select-input--inline__wrapper")},u.default.createElement("div",{className:"".concat(I,"--select-input__wrapper"),"data-invalid":b||null},B),Z),!o&&u.default.createElement("div",{className:"".concat(I,"--select-input__wrapper"),"data-invalid":b||null},B),!o&&Z?Z:q))}));z.displayName="Select",z.propTypes={children:s().node,className:s().string,defaultValue:s().any,disabled:s().bool,helperText:s().node,hideLabel:s().bool,iconDescription:(0,_.Z)(s().string,"The `iconDescription` prop for `Select` is no longer needed and has been deprecated. It will be moved in the next major release."),id:s().string.isRequired,inline:s().bool,invalid:s().bool,invalidText:s().node,labelText:s().node,light:s().bool,noLabel:s().bool,onChange:s().func,size:s().oneOf(["sm","md","lg","xl"]),warn:s().bool,warnText:s().node},z.defaultProps={disabled:!1,labelText:"Select",inline:!1,invalid:!1,invalidText:"",helperText:"",light:!1};const N=z;var E=["className","value","disabled","hidden","text"];function j(){return j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},j.apply(this,arguments)}function I(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var C=g.settings.prefix,k=function(e){var t,a=e.className,n=e.value,r=e.disabled,i=e.hidden,l=e.text,o=function(e,t){if(null==e)return{};var a,n,r=function(e,t){if(null==e)return{};var a,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}(e,E),c=d()((I(t={},"".concat(C,"--select-option"),!0),I(t,a,a),t));return u.default.createElement("option",j({},o,{className:c,value:n,disabled:r,hidden:i}),l)};k.propTypes={className:s().string,disabled:s().bool,hidden:s().bool,text:s().string.isRequired,value:s().any.isRequired},k.defaultProps={disabled:!1,hidden:!1,value:"",text:""};const R=k;var M=a(7030),L=["backwardText","className","forwardText","id","itemsPerPageText","itemRangeText","pageRangeText","pageSize","pageSizes","itemText","pageText","pageNumberText","pagesUnknown","isLastPage","disabled","pageInputDisabled","pageSizeInputDisabled","totalItems","onChange","page","size"];function D(){return D=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},D.apply(this,arguments)}function Z(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function A(e,t){return A=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},A(e,t)}function q(e,t){return!t||"object"!==H(t)&&"function"!=typeof t?U(e):t}function U(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},B(e)}function F(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function H(e){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},H(e)}var V=g.settings.prefix,G=0,J=function(e){return"object"===H(e[0])&&null!==e[0]?e:e.map((function(e){return{text:e,value:e}}))},K=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&A(e,t)}(o,e);var t,a,n,r,i,l=(r=o,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=B(r);if(i){var a=B(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return q(this,e)});function o(e){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),F(U(t=l.call(this,e)),"handleSizeChange",(function(e){var a=Number(e.target.value);t.setState({pageSize:a,page:1}),t.props.onChange({page:1,pageSize:a})})),F(U(t),"handlePageChange",(function(e){t.setState({page:e.target.value})})),F(U(t),"handlePageInputChange",(function(e){var a=Number(e.target.value);a>0&&a<=Math.max(Math.ceil(t.props.totalItems/t.state.pageSize),1)&&(t.setState({page:a}),t.props.onChange({page:a,pageSize:t.state.pageSize}))})),F(U(t),"incrementPage",(function(){var e=t.state.page+1;t.setState({page:e}),t.props.onChange({page:e,pageSize:t.state.pageSize})})),F(U(t),"decrementPage",(function(){var e=t.state.page-1;t.setState({page:e}),t.props.onChange({page:e,pageSize:t.state.pageSize})})),F(U(t),"renderSelectItems",(function(e){for(var t=1,a=[];t<=e;)a.push(u.default.createElement(R,{key:t,value:t,text:String(t)})),t++;return a}));var a=t.props,n=a.pageSizes,r=a.page,i=a.pageSize,c=J(n);return t.state={page:r,pageSize:i&&c.some((function(e){return i===e.value}))?i:c[0].value,prevPageSizes:c,prevPage:r,prevPageSize:i},t.uniqueId=++G,t}return t=o,n=[{key:"getDerivedStateFromProps",value:function(e,t){var a=e.pageSizes,n=e.page,r=e.pageSize,i=t.prevPageSizes,l=t.prevPage,o=t.prevPageSize,c=t.page,s=t.pageSize,u=J(a),p=!function(e,t){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;if(e===t)return!0;for(var a=0;a<e.length;a++)if(e[a]!==t[a])return!1;return!0}(u.map((function(e){return e.value})),i.map((function(e){return e.value})));p&&!u.some((function(e){return r===e.value}))&&(r=u[0].value);var d=n!==l,f=r!==o;return p||d||f?{page:(f?1:d&&n)||c,pageSize:f?r:s,prevPageSizes:u,prevPage:n,prevPageSize:r}:null}}],(a=[{key:"render",value:function(){var e=this.props,t=e.backwardText,a=e.className,n=e.forwardText,r=e.id,i=e.itemsPerPageText,l=e.itemRangeText,o=e.pageRangeText,c=(e.pageSize,e.pageSizes),s=e.itemText,p=e.pageText,g=(e.pageNumberText,e.pagesUnknown),m=e.isLastPage,b=e.disabled,h=e.pageInputDisabled,v=e.pageSizeInputDisabled,y=e.totalItems,x=(e.onChange,e.page,e.size),_=function(e,t){if(null==e)return{};var a,n,r=function(e,t){if(null==e)return{};var a,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}(e,L),w=d()("".concat(V,"--pagination"),a,F({},"".concat(V,"--pagination--").concat(x),x)),S=r||this.uniqueId,T=this.state,O=T.page,P=T.pageSize,z=Math.max(Math.ceil(y/P),1),E=b||1===O,j=d()("".concat(V,"--pagination__button"),"".concat(V,"--pagination__button--backward"),F({},"".concat(V,"--pagination__button--no-index"),E)),I=b||O===z,C=d()("".concat(V,"--pagination__button"),"".concat(V,"--pagination__button--forward"),F({},"".concat(V,"--pagination__button--no-index"),I)),k=this.renderSelectItems(z),Z=J(c);return u.default.createElement("div",D({className:w},_),u.default.createElement("div",{className:"".concat(V,"--pagination__left")},u.default.createElement("label",{id:"".concat(V,"-pagination-select-").concat(S,"-count-label"),className:"".concat(V,"--pagination__text"),htmlFor:"".concat(V,"-pagination-select-").concat(S)},i),u.default.createElement(N,{id:"".concat(V,"-pagination-select-").concat(S),className:"".concat(V,"--select__item-count"),labelText:"",hideLabel:!0,noLabel:!0,inline:!0,onChange:this.handleSizeChange,disabled:v||b,value:P},Z.map((function(e){return u.default.createElement(R,{key:e.value,value:e.value,text:String(e.text)})}))),u.default.createElement("span",{className:"".concat(V,"--pagination__text ").concat(V,"--pagination__items-count")},g?s(P*(O-1)+1,O*P):l(Math.min(P*(O-1)+1,y),Math.min(O*P,y),y))),u.default.createElement("div",{className:"".concat(V,"--pagination__right")},u.default.createElement(N,{id:"".concat(V,"-pagination-select-").concat(S,"-right"),className:"".concat(V,"--select__page-number"),labelText:"Page number, of ".concat(z," pages"),inline:!0,hideLabel:!0,onChange:this.handlePageInputChange,value:O,disabled:h||b},k),u.default.createElement("span",{className:"".concat(V,"--pagination__text")},g?p(O):o(O,z)),u.default.createElement("div",{className:"".concat(V,"--pagination__control-buttons")},u.default.createElement(M.Z,{kind:"ghost",className:j,hasIconOnly:!0,renderIcon:f.bdU,iconDescription:t,tooltipAlignment:"center",tooltipPosition:"top",onClick:this.decrementPage,disabled:E}),u.default.createElement(M.Z,{kind:"ghost",className:C,hasIconOnly:!0,renderIcon:f.VUy,iconDescription:n,tooltipAlignment:"end",tooltipPosition:"top",onClick:this.incrementPage,disabled:I||m}))))}}])&&Z(t.prototype,a),n&&Z(t,n),o}(u.Component);F(K,"propTypes",{backwardText:s().string,className:s().string,disabled:s().bool,forwardText:s().string,id:s().oneOfType([s().string,s().number]),isLastPage:s().bool,itemRangeText:s().func,itemText:s().func,itemsPerPageText:s().string,onChange:s().func,page:s().number,pageInputDisabled:s().bool,pageNumberText:s().string,pageRangeText:s().func,pageSize:s().number,pageSizeInputDisabled:s().bool,pageSizes:s().oneOfType([s().arrayOf(s().number),s().arrayOf(s().shape({text:s().text,value:s().number}))]).isRequired,pageText:s().func,pagesUnknown:s().bool,size:s().oneOf(["sm","md","lg"]),totalItems:s().number}),F(K,"defaultProps",{backwardText:"Previous page",itemRangeText:function(e,t,a){return"".concat(e,"–").concat(t," of ").concat(a," items")},forwardText:"Next page",itemsPerPageText:"Items per page:",pageNumberText:"Page Number",pageRangeText:function(e,t){return"of ".concat(t," ").concat(1===t?"page":"pages")},disabled:!1,page:1,pagesUnknown:!1,isLastPage:!1,itemText:function(e,t){return"".concat(e,"–").concat(t," items")},pageText:function(e){return"page ".concat(e)}})}}]);
|
|
2
|
-
//# sourceMappingURL=288.openmrs-esm-active-visits-app.js.map
|