@openmrs/esm-appointments-app 4.0.2-pre.971 → 4.1.1-pre.980
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 +3 -3
- package/dist/351.js +1 -1
- package/dist/437.js +1 -1
- package/dist/45.js +1 -1
- package/dist/497.js +1 -1
- package/dist/647.js +1 -1
- package/dist/692.js +1 -1
- package/dist/821.js +1 -1
- package/dist/openmrs-esm-appointments-app.js.buildmanifest.json +20 -20
- package/package.json +2 -2
- package/src/appointment-forms/appointment-forms.resource.ts +12 -6
- package/src/appointments/appointments.resources.ts +7 -4
- package/src/appointments-tabs/appointments-table.resource.ts +7 -4
- package/src/home-appointments/appointments-table.resource.ts +16 -10
- package/src/hooks/useAppointments.tsx +4 -4
- package/src/hooks/useClinicalMetrics.tsx +9 -6
- package/src/hooks/usePatientAppointmentHistory.tsx +5 -2
- package/src/hooks/useProviders.tsx +5 -2
- package/src/hooks/useServiceQueues.tsx +11 -0
- package/src/hooks/useVisits.tsx +9 -5
- package/src/past-visit/past-visit.resource.ts +2 -2
- package/src/patient-queue/visit-form/useVisit.ts +2 -2
- package/src/patient-queue/visit-form/visit-form.component.tsx +4 -1
- package/src/patient-table/patient-table.component.tsx +1 -1
- package/src/hooks/useServiceQueus.tsx +0 -8
|
@@ -22,7 +22,10 @@ export function useAppointments(patientUuid: string, startDate: string, abortCon
|
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
const { data, error, isValidating } = useSWR<AppointmentsFetchResponse, Error>(
|
|
25
|
+
const { data, error, isLoading, isValidating } = useSWR<AppointmentsFetchResponse, Error>(
|
|
26
|
+
appointmentsSearchUrl,
|
|
27
|
+
fetcher,
|
|
28
|
+
);
|
|
26
29
|
|
|
27
30
|
const appointments = data?.data?.length
|
|
28
31
|
? data.data.sort((a, b) => (b.startDateTime > a.startDateTime ? 1 : -1))
|
|
@@ -31,13 +34,13 @@ export function useAppointments(patientUuid: string, startDate: string, abortCon
|
|
|
31
34
|
return {
|
|
32
35
|
data: data ? appointments : null,
|
|
33
36
|
isError: error,
|
|
34
|
-
isLoading
|
|
37
|
+
isLoading,
|
|
35
38
|
isValidating,
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export function useAppointmentService() {
|
|
40
|
-
const { data, error } = useSWR<{ data: Array<AppointmentService> }, Error>(
|
|
43
|
+
const { data, error, isLoading } = useSWR<{ data: Array<AppointmentService> }, Error>(
|
|
41
44
|
`/ws/rest/v1/appointmentService/all/full`,
|
|
42
45
|
openmrsFetch,
|
|
43
46
|
);
|
|
@@ -45,7 +48,7 @@ export function useAppointmentService() {
|
|
|
45
48
|
return {
|
|
46
49
|
data: data ? data.data : null,
|
|
47
50
|
isError: error,
|
|
48
|
-
isLoading
|
|
51
|
+
isLoading,
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -8,7 +8,7 @@ export function useAppointments(status?: string) {
|
|
|
8
8
|
const startDate = useAppointmentDate();
|
|
9
9
|
const appointmentsByStatusUrl = `/ws/rest/v1/appointment/appointmentStatus?forDate=${startDate}&status=${status}`;
|
|
10
10
|
const allAppointmentsUrl = `/ws/rest/v1/appointment/all?forDate=${startDate}`;
|
|
11
|
-
const { data, error, isValidating, mutate } = useSWR<{ data: Array<Appointment> }, Error>(
|
|
11
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: Array<Appointment> }, Error>(
|
|
12
12
|
status ? allAppointmentsUrl : appointmentsByStatusUrl,
|
|
13
13
|
openmrsFetch,
|
|
14
14
|
);
|
|
@@ -20,7 +20,7 @@ export function useAppointments(status?: string) {
|
|
|
20
20
|
|
|
21
21
|
return {
|
|
22
22
|
appointments: formattedAppointments,
|
|
23
|
-
isLoading
|
|
23
|
+
isLoading,
|
|
24
24
|
isError: error,
|
|
25
25
|
isValidating,
|
|
26
26
|
mutate,
|
|
@@ -29,11 +29,14 @@ export function useAppointments(status?: string) {
|
|
|
29
29
|
|
|
30
30
|
export function useServices() {
|
|
31
31
|
const apiUrl = `/ws/rest/v1/appointmentService/all/default`;
|
|
32
|
-
const { data, error, isValidating } = useSWR<{ data: Array<AppointmentService> }, Error>(
|
|
32
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: Array<AppointmentService> }, Error>(
|
|
33
|
+
apiUrl,
|
|
34
|
+
openmrsFetch,
|
|
35
|
+
);
|
|
33
36
|
|
|
34
37
|
return {
|
|
35
38
|
services: data ? data.data : [],
|
|
36
|
-
isLoading
|
|
39
|
+
isLoading,
|
|
37
40
|
isError: error,
|
|
38
41
|
isValidating,
|
|
39
42
|
};
|
|
@@ -11,30 +11,36 @@ export function useTodayAppointments() {
|
|
|
11
11
|
const { t } = useTranslation();
|
|
12
12
|
const startDate = useAppointmentDate();
|
|
13
13
|
const apiUrl = `/ws/rest/v1/appointment/all?forDate=${startDate}`;
|
|
14
|
-
const { data, error, isValidating, mutate } = useSWR<{ data: Array<Appointment> }, Error>(
|
|
14
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: Array<Appointment> }, Error>(
|
|
15
|
+
apiUrl,
|
|
16
|
+
openmrsFetch,
|
|
17
|
+
);
|
|
15
18
|
|
|
16
|
-
const
|
|
19
|
+
const results = useMemo(() => {
|
|
20
|
+
const serverAppointments = data?.data?.map((appointment) => getTodaysAppointment(appointment, t)) ?? [];
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
() => ({
|
|
22
|
+
return {
|
|
20
23
|
appointments: serverAppointments,
|
|
21
|
-
isLoading
|
|
24
|
+
isLoading,
|
|
22
25
|
isError: error,
|
|
23
26
|
isValidating,
|
|
24
27
|
mutate,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
};
|
|
29
|
+
}, [data?.data, error, isLoading, isValidating, mutate, t]);
|
|
30
|
+
|
|
28
31
|
return results;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export function useServices() {
|
|
32
35
|
const apiUrl = `/ws/rest/v1/appointmentService/all/default`;
|
|
33
|
-
const { data, error, isValidating } = useSWR<{ data: Array<AppointmentService> }, Error>(
|
|
36
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: Array<AppointmentService> }, Error>(
|
|
37
|
+
apiUrl,
|
|
38
|
+
openmrsFetch,
|
|
39
|
+
);
|
|
34
40
|
|
|
35
41
|
return {
|
|
36
42
|
services: data ? data.data : [],
|
|
37
|
-
isLoading
|
|
43
|
+
isLoading,
|
|
38
44
|
isError: error,
|
|
39
45
|
isValidating,
|
|
40
46
|
};
|
|
@@ -12,11 +12,11 @@ interface AppointmentsReturnType {
|
|
|
12
12
|
|
|
13
13
|
export const useDailyAppointments = (startDateTime: string, durationPeriod: DurationPeriod) => {
|
|
14
14
|
const url = `/ws/rest/v1/appointment/all?forDate=${startDateTime}`;
|
|
15
|
-
const { data, error } = useSWR<{ data: Array<Appointment> }>(url, openmrsFetch);
|
|
15
|
+
const { data, error, isLoading } = useSWR<{ data: Array<Appointment> }>(url, openmrsFetch);
|
|
16
16
|
|
|
17
17
|
return {
|
|
18
18
|
appointments: data?.data ?? [],
|
|
19
|
-
isLoading
|
|
19
|
+
isLoading,
|
|
20
20
|
error: error,
|
|
21
21
|
};
|
|
22
22
|
};
|
|
@@ -38,8 +38,8 @@ export const useAppointmentsByDurationPeriod = (date: string, durationPeriod: Du
|
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
const url = 'openmrs/ws/rest/v1/appointments/search';
|
|
41
|
-
const { data, error } = useSWR<{ data: Array<Appointment> }>(url, fetcher);
|
|
42
|
-
return { isLoading
|
|
41
|
+
const { data, error, isLoading } = useSWR<{ data: Array<Appointment> }>(url, fetcher);
|
|
42
|
+
return { isLoading, appointments: data?.data ?? [], error };
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
const getStartAndEndDate = (durationPeriod: DurationPeriod, date: string) => {
|
|
@@ -15,7 +15,7 @@ export const useClinicalMetrics = () => {
|
|
|
15
15
|
const appointmentDate = useAppointmentDate();
|
|
16
16
|
const endDate = dayjs(new Date(appointmentDate).setHours(23, 59, 59, 59)).format(omrsDateFormat);
|
|
17
17
|
const url = `/ws/rest/v1/appointment/appointmentSummary?startDate=${appointmentDate}&endDate=${endDate}`;
|
|
18
|
-
const { data,
|
|
18
|
+
const { data, isLoading, error } = useSWR<{
|
|
19
19
|
data: Array<AppointmentSummary>;
|
|
20
20
|
}>(url, openmrsFetch);
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ export const useClinicalMetrics = () => {
|
|
|
27
27
|
const highestServiceLoad = getHighestAppointmentServiceLoad(transformedAppointments);
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
-
isLoading
|
|
30
|
+
isLoading,
|
|
31
31
|
error,
|
|
32
32
|
totalAppointments,
|
|
33
33
|
missedAppointments,
|
|
@@ -38,7 +38,10 @@ export const useClinicalMetrics = () => {
|
|
|
38
38
|
export function useAllAppointmentsByDate() {
|
|
39
39
|
const startDate = useAppointmentDate();
|
|
40
40
|
const apiUrl = `/ws/rest/v1/appointment/all?forDate=${startDate}`;
|
|
41
|
-
const { data, error, isValidating, mutate } = useSWR<{ data: Array<Appointment> }, Error>(
|
|
41
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: Array<Appointment> }, Error>(
|
|
42
|
+
apiUrl,
|
|
43
|
+
openmrsFetch,
|
|
44
|
+
);
|
|
42
45
|
|
|
43
46
|
const providersArray = data?.data?.filter(({ providers }) => providers !== null) ?? [];
|
|
44
47
|
const providersCount = uniqBy(
|
|
@@ -47,7 +50,7 @@ export function useAllAppointmentsByDate() {
|
|
|
47
50
|
).length;
|
|
48
51
|
return {
|
|
49
52
|
totalProviders: providersCount ? providersCount : 0,
|
|
50
|
-
isLoading
|
|
53
|
+
isLoading,
|
|
51
54
|
isError: error,
|
|
52
55
|
isValidating,
|
|
53
56
|
mutate,
|
|
@@ -58,14 +61,14 @@ export const useScheduledAppointment = () => {
|
|
|
58
61
|
const startDate = useAppointmentDate();
|
|
59
62
|
const url = `/ws/rest/v1/appointment/all?forDate=${startDate}`;
|
|
60
63
|
|
|
61
|
-
const { data, error,
|
|
64
|
+
const { data, error, isLoading } = useSWR<{
|
|
62
65
|
data: Array<AppointmentSummary>;
|
|
63
66
|
}>(url, openmrsFetch);
|
|
64
67
|
|
|
65
68
|
const totalScheduledAppointments = data?.data.length ?? 0;
|
|
66
69
|
|
|
67
70
|
return {
|
|
68
|
-
isLoading
|
|
71
|
+
isLoading,
|
|
69
72
|
error,
|
|
70
73
|
totalScheduledAppointments,
|
|
71
74
|
};
|
|
@@ -20,7 +20,10 @@ export function usePatientAppointmentHistory(patientUuid: string, abortControlle
|
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const { data, error, isValidating } = useSWR<AppointmentsFetchResponse, Error>(
|
|
23
|
+
const { data, error, isLoading, isValidating } = useSWR<AppointmentsFetchResponse, Error>(
|
|
24
|
+
appointmentsSearchUrl,
|
|
25
|
+
fetcher,
|
|
26
|
+
);
|
|
24
27
|
|
|
25
28
|
const missedAppointments = data?.data?.length
|
|
26
29
|
? data.data.filter((appointment) => appointment.status === 'Missed').length
|
|
@@ -38,7 +41,7 @@ export function usePatientAppointmentHistory(patientUuid: string, abortControlle
|
|
|
38
41
|
return {
|
|
39
42
|
appointmentsCount: { missedAppointments, completedAppointments, cancelledAppointments, upcomingAppointments },
|
|
40
43
|
isError: error,
|
|
41
|
-
isLoading
|
|
44
|
+
isLoading,
|
|
42
45
|
isValidating,
|
|
43
46
|
};
|
|
44
47
|
}
|
|
@@ -4,11 +4,14 @@ import { Provider } from '../types';
|
|
|
4
4
|
|
|
5
5
|
export function useProviders() {
|
|
6
6
|
const apiUrl = `/ws/rest/v1/provider`;
|
|
7
|
-
const { data, error, isValidating } = useSWR<{ data: { results: Array<Provider> } }, Error>(
|
|
7
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: { results: Array<Provider> } }, Error>(
|
|
8
|
+
apiUrl,
|
|
9
|
+
openmrsFetch,
|
|
10
|
+
);
|
|
8
11
|
|
|
9
12
|
return {
|
|
10
13
|
providers: data ? data.data?.results : [],
|
|
11
|
-
isLoading
|
|
14
|
+
isLoading,
|
|
12
15
|
isError: error,
|
|
13
16
|
isValidating,
|
|
14
17
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
+
import useSWR from 'swr';
|
|
3
|
+
|
|
4
|
+
export const useServiceQueues = () => {
|
|
5
|
+
const apiUrl = `/ws/rest/v1/visit-queue-entry?v=full`;
|
|
6
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: { results: Array<any> } }, Error>(
|
|
7
|
+
apiUrl,
|
|
8
|
+
openmrsFetch,
|
|
9
|
+
);
|
|
10
|
+
return { isLoading, queueEntries: data?.data?.results ?? [], isValidating };
|
|
11
|
+
};
|
package/src/hooks/useVisits.tsx
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import useSWR from 'swr';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
2
3
|
import { openmrsFetch, useSession, Visit } from '@openmrs/esm-framework';
|
|
3
4
|
import { useAppointmentDate } from '../helpers';
|
|
4
|
-
import dayjs from 'dayjs';
|
|
5
|
-
const defaultRepresentation = `v=custom:(uuid,patient:(uuid,identifiers:(identifier,uuid),person:(age,display,gender,uuid)),visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,stopDatetime)`;
|
|
6
5
|
|
|
7
6
|
export const useVisits = () => {
|
|
8
|
-
const startDateTime = useAppointmentDate();
|
|
9
7
|
const session = useSession();
|
|
8
|
+
const startDateTime = useAppointmentDate();
|
|
9
|
+
|
|
10
|
+
const defaultRepresentation = `v=custom:(uuid,patient:(uuid,identifiers:(identifier,uuid),person:(age,display,gender,uuid)),visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,stopDatetime)`;
|
|
11
|
+
|
|
10
12
|
const visitsUrl = `/ws/rest/v1/visit?includeInactive=false&${defaultRepresentation}&fromStartDate=${dayjs(
|
|
11
13
|
startDateTime,
|
|
12
14
|
).format('YYYY-MM-DD')}&location=${session?.sessionLocation?.uuid}`;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
const { data, error, isLoading } = useSWR<{ data: { results: Array<Visit> } }>(visitsUrl, openmrsFetch);
|
|
17
|
+
|
|
18
|
+
return { isLoading, visits: data?.data?.results ?? [], error };
|
|
15
19
|
};
|
|
@@ -10,7 +10,7 @@ export function usePastVisits(patientUuid: string) {
|
|
|
10
10
|
'visitType:(uuid,name,display),attributes:(uuid,display,value),location:(uuid,name,display),startDatetime,' +
|
|
11
11
|
'stopDatetime)';
|
|
12
12
|
|
|
13
|
-
const { data, error, isValidating } = useSWR<{ data: { results: Array<Visit> } }, Error>(
|
|
13
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: { results: Array<Visit> } }, Error>(
|
|
14
14
|
`/ws/rest/v1/visit?patient=${patientUuid}&v=${customRepresentation}`,
|
|
15
15
|
openmrsFetch,
|
|
16
16
|
);
|
|
@@ -18,7 +18,7 @@ export function usePastVisits(patientUuid: string) {
|
|
|
18
18
|
return {
|
|
19
19
|
data: data ? data.data.results : null,
|
|
20
20
|
isError: error,
|
|
21
|
-
isLoading
|
|
21
|
+
isLoading,
|
|
22
22
|
isValidating,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -8,11 +8,11 @@ export function useStatus() {
|
|
|
8
8
|
} = config;
|
|
9
9
|
|
|
10
10
|
const apiUrl = `/ws/rest/v1/concept/${statusConceptSetUuid}`;
|
|
11
|
-
const { data, error } = useSWRImmutable<FetchResponse>(apiUrl, openmrsFetch);
|
|
11
|
+
const { data, error, isLoading } = useSWRImmutable<FetchResponse>(apiUrl, openmrsFetch);
|
|
12
12
|
|
|
13
13
|
return {
|
|
14
14
|
statuses: data?.data?.setMembers ?? [],
|
|
15
|
-
isLoading
|
|
15
|
+
isLoading,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -189,10 +189,13 @@ const VisitForm: React.FC<VisitFormProps> = ({ patientUuid, appointment }) => {
|
|
|
189
189
|
selectedLocation,
|
|
190
190
|
service,
|
|
191
191
|
statuses,
|
|
192
|
+
priorities,
|
|
192
193
|
priority,
|
|
193
194
|
queues,
|
|
194
|
-
priorities,
|
|
195
195
|
t,
|
|
196
|
+
appointment.id,
|
|
197
|
+
mutate,
|
|
198
|
+
startDate,
|
|
196
199
|
],
|
|
197
200
|
);
|
|
198
201
|
|
|
@@ -82,7 +82,7 @@ const PatientTable: React.FC<PatientTableProps> = ({
|
|
|
82
82
|
[patients, columns],
|
|
83
83
|
);
|
|
84
84
|
|
|
85
|
-
const handleSearch = useMemo(() => debounce((searchTerm) => search.onSearch(searchTerm), 300), []);
|
|
85
|
+
const handleSearch = useMemo(() => debounce((searchTerm) => search.onSearch(searchTerm), 300), [search]);
|
|
86
86
|
const otherSearchProps = useMemo(() => search.otherSearchProps || {}, [search]);
|
|
87
87
|
|
|
88
88
|
if (isLoading) {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
-
import useSWR from 'swr';
|
|
3
|
-
|
|
4
|
-
export const useServiceQueues = () => {
|
|
5
|
-
const apiUrl = `/ws/rest/v1/visit-queue-entry?v=full`;
|
|
6
|
-
const { data, error, isValidating } = useSWR<{ data: { results: Array<any> } }, Error>(apiUrl, openmrsFetch);
|
|
7
|
-
return { isLoading: !data && !error, queueEntries: data?.data?.results ?? [], isValidating };
|
|
8
|
-
};
|