@openmrs/esm-appointments-app 5.2.2-pre.2602 → 5.2.2-pre.2607
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 +4 -4
- package/dist/530.js +1 -1
- package/dist/530.js.map +1 -1
- package/dist/636.js +1 -0
- package/dist/636.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-appointments-app.js +1 -1
- package/dist/openmrs-esm-appointments-app.js.buildmanifest.json +30 -30
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/appointments-calendar/calendar-view.component.tsx +2 -2
- package/src/appointments-calendar/daily/daily-calendar-view.component.tsx +7 -5
- package/src/appointments-calendar/daily/daily-header.component.tsx +1 -4
- package/src/appointments-calendar/daily/{daily-view-workload.component.tsx → daily-workload-view.component.tsx} +8 -9
- package/src/appointments-calendar/daily/{daily-view-workload.test.tsx → daily-workload-view.test.tsx} +13 -11
- package/src/appointments-calendar/header/calendar-header.component.tsx +2 -20
- package/src/appointments-calendar/monthly/monthly-calendar-view.component.tsx +4 -4
- package/src/appointments-calendar/monthly/{monthly-view-workload.component.tsx → monthly-workload-view.component.tsx} +14 -8
- package/src/appointments-calendar/weekly/weekly-calendar-view.component.tsx +7 -6
- package/src/appointments-calendar/weekly/weekly-header.component.tsx +0 -3
- package/src/appointments-calendar/weekly/{weekly-view-workload.component.tsx → weekly-workload-view.component.tsx} +8 -9
- package/src/appointments-calendar/weekly/{weekly-view-workload.test.tsx → weekly-workload-view.test.tsx} +13 -11
- package/src/hooks/useAppointmentsCalendar.ts +28 -20
- package/src/types/index.ts +8 -0
- package/dist/799.js +0 -1
- package/dist/799.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
|
+
import WeeklyWorkloadView from './weekly-workload-view.component';
|
|
4
|
+
import { type CalendarType, type DailyAppointmentsCountByService } from '../../types';
|
|
3
5
|
import userEvent from '@testing-library/user-event';
|
|
4
6
|
import { render, screen } from '@testing-library/react';
|
|
5
|
-
import { type CalendarType } from '../../types';
|
|
6
7
|
import { spaBasePath } from '../../constants';
|
|
7
8
|
import { navigate } from '@openmrs/esm-framework';
|
|
8
|
-
import WeeklyWorkloadView from './weekly-view-workload.component';
|
|
9
9
|
|
|
10
10
|
jest.mock('@openmrs/esm-framework', () => ({
|
|
11
11
|
...jest.requireActual('@openmrs/esm-framework'),
|
|
@@ -14,19 +14,21 @@ jest.mock('@openmrs/esm-framework', () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
16
|
describe('WeeklyWorkloadView Component', () => {
|
|
17
|
+
const events: Array<DailyAppointmentsCountByService> = [
|
|
18
|
+
{
|
|
19
|
+
appointmentDate: '2023-08-17',
|
|
20
|
+
services: [
|
|
21
|
+
{ serviceName: 'HIV', count: 2 },
|
|
22
|
+
{ serviceName: 'Lab testing', count: 3 },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
17
27
|
const mockData = {
|
|
18
28
|
type: 'weekly' as CalendarType,
|
|
19
29
|
dateTime: dayjs('2023-08-17'),
|
|
20
30
|
currentDate: dayjs('2023-08-17'),
|
|
21
|
-
events:
|
|
22
|
-
{
|
|
23
|
-
appointmentDate: '2023-08-17',
|
|
24
|
-
service: [
|
|
25
|
-
{ serviceName: 'HIV', count: 2 },
|
|
26
|
-
{ serviceName: 'Lab testing', count: 3 },
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
],
|
|
31
|
+
events: events,
|
|
30
32
|
index: 1,
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -1,36 +1,44 @@
|
|
|
1
|
-
import { openmrsFetch
|
|
1
|
+
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import useSWR from 'swr';
|
|
4
4
|
import { omrsDateFormat } from '../constants';
|
|
5
|
+
import { type DailyAppointmentsCountByService } from '../types';
|
|
5
6
|
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
appointmentCountMap: OpenmrsResource | null;
|
|
16
|
-
totalServiceCount: number;
|
|
7
|
+
interface AppointmentCountMapEntry {
|
|
8
|
+
allAppointmentsCount: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface AppointmentSummaryResponse {
|
|
12
|
+
appointmentService: {
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
appointmentCountMap: Map<string, AppointmentCountMapEntry>;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
export const useAppointmentsCalendar = (forDate: string, period: string) => {
|
|
20
19
|
const { startDate, endDate } = evaluateAppointmentCalendarDates(forDate, period);
|
|
21
|
-
const url = `/ws/rest/v1/appointment/
|
|
20
|
+
const url = `/ws/rest/v1/appointment/appointmentSummary?startDate=${startDate}&endDate=${endDate}`;
|
|
22
21
|
|
|
23
|
-
const { data, error, isLoading } = useSWR<{ data: Array<
|
|
22
|
+
const { data, error, isLoading } = useSWR<{ data: Array<AppointmentSummaryResponse> }>(
|
|
24
23
|
startDate && endDate ? url : null,
|
|
25
24
|
openmrsFetch,
|
|
26
25
|
{ errorRetryCount: 2 },
|
|
27
26
|
);
|
|
28
|
-
const results =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const results: Array<DailyAppointmentsCountByService> = data?.data.reduce((acc, service) => {
|
|
28
|
+
const serviceName = service.appointmentService.name;
|
|
29
|
+
Object.entries(service.appointmentCountMap).map(([key, value]) => {
|
|
30
|
+
const existingEntry = acc.find((entry) => entry.appointmentDate === key);
|
|
31
|
+
if (existingEntry) {
|
|
32
|
+
existingEntry.services.push({ serviceName, count: value.allAppointmentsCount });
|
|
33
|
+
} else {
|
|
34
|
+
acc.push({
|
|
35
|
+
appointmentDate: key,
|
|
36
|
+
services: [{ serviceName, count: value.allAppointmentsCount }],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return acc;
|
|
41
|
+
}, []);
|
|
34
42
|
return { isLoading, calendarEvents: results, error };
|
|
35
43
|
};
|
|
36
44
|
|
package/src/types/index.ts
CHANGED
|
@@ -199,3 +199,11 @@ export interface Identifier {
|
|
|
199
199
|
identifier: string;
|
|
200
200
|
identifierName?: string;
|
|
201
201
|
}
|
|
202
|
+
|
|
203
|
+
export interface DailyAppointmentsCountByService {
|
|
204
|
+
appointmentDate: string;
|
|
205
|
+
services: Array<{
|
|
206
|
+
serviceName: string;
|
|
207
|
+
count: number;
|
|
208
|
+
}>;
|
|
209
|
+
}
|