Skip to content

Commit

Permalink
Merge branch 'main' into fix/search-results-count
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Oct 28, 2023
2 parents 985bf30 + bac09af commit 5ae859c
Show file tree
Hide file tree
Showing 70 changed files with 777 additions and 462 deletions.
2 changes: 1 addition & 1 deletion e2e/pages/patient-lists-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class PatientListsPage {

async editPatientList(listName: string, description: string) {
await this.page.getByRole('button', { name: 'Actions' }).click();
await this.page.getByRole('menuitem', { name: 'Edit Name or Description' }).click();
await this.page.getByRole('menuitem', { name: 'Edit name or description' }).click();
await this.page.getByLabel('List name').fill(listName);
await this.page.getByLabel('Describe the purpose of this list in a few words').fill(description);
await this.page.getByRole('button', { name: 'Edit list' }).click();
Expand Down
1 change: 0 additions & 1 deletion e2e/specs/patient-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ test('Manage patients in a list', async ({ api, page }) => {
await removePatientFromCohort(api, createdCohortMember.uuid);
await patientListPage.goto(cohort.uuid);
await expect(patientListPage.patientListHeader()).toHaveText(/0 patients/);
await expect(patientListPage.patientsTable()).not.toHaveText(new RegExp(patient.person.display));
createdCohortMember = null;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const MedicationSummary: React.FC<MedicationSummaryProps> = ({ medications }) =>
&mdash; {medication.order.frequency?.display} &mdash;{' '}
{!medication.order.duration
? t('orderIndefiniteDuration', 'Indefinite duration')
: t('orderDurationAndUnit', 'for {duration} {durationUnit}', {
: t('orderDurationAndUnit', 'for {{duration}} {{durationUnit}}', {
duration: medication.order.duration,
durationUnit: medication.order.durationUnits?.display,
})}
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-active-visits-app/translations/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"notes": "Notes",
"noVisitsFound": "No visits found",
"noVisitsToDisplay": "No visits to display",
"orderDurationAndUnit": "for {duration} {durationUnit}",
"orderDurationAndUnit": "for {{duration}} {{durationUnit}}",
"orderIndefiniteDuration": "Indefinite duration",
"provider": "Provider",
"refills": "Refills",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-active-visits-app/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"notes": "الملاحظات",
"noVisitsFound": "No visits found",
"noVisitsToDisplay": "لا زيارات للعرض",
"orderDurationAndUnit": "لمدة {duration} {durationUnit}",
"orderDurationAndUnit": "لمدة {{duration}} {{durationUnit}}",
"orderIndefiniteDuration": "مدة غير محددة",
"provider": "مقدم الخدمة",
"refills": "إعادة التعبئة",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-active-visits-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"notes": "Notes",
"noVisitsFound": "No visits found",
"noVisitsToDisplay": "No visits to display",
"orderDurationAndUnit": "for {duration} {durationUnit}",
"orderDurationAndUnit": "for {{duration}} {{durationUnit}}",
"orderIndefiniteDuration": "Indefinite duration",
"provider": "Provider",
"refills": "Refills",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-active-visits-app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"notes": "Informations complémentaires",
"noVisitsFound": "No visits found",
"noVisitsToDisplay": "No visits to display",
"orderDurationAndUnit": "Pour {duration} {durationUnit}",
"orderDurationAndUnit": "Pour {{duration}} {{durationUnit}}",
"orderIndefiniteDuration": "Durée illimitée",
"provider": "Fournisseur",
"refills": "Recharges",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-active-visits-app/translations/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"notes": "הערות",
"noVisitsFound": "No visits found",
"noVisitsToDisplay": "No visits to display",
"orderDurationAndUnit": "למשך {duration} {durationUnit}",
"orderDurationAndUnit": "למשך {{duration}} {{durationUnit}}",
"orderIndefiniteDuration": "למשך זמן בלתי מוגבל",
"provider": "ספק",
"refills": "תערובות",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ const AppointmentsMetrics: React.FC<AppointmentMetricsProps> = ({ serviceUuid })
highestServiceLoad?.count !== 0 ? t(highestServiceLoad?.serviceName) : t('serviceName', 'Service name')
}
value={highestServiceLoad?.count ?? '--'}
headerLabel={t('highestServiceVolume', 'High volume service: {time}', { time: formattedStartDate })}
headerLabel={t('highestServiceVolume', 'High volume service: {{time}}', { time: formattedStartDate })}
/>
<MetricsCard
label={t('providers', 'Providers')}
value={totalProviders}
headerLabel={t('providersAvailableToday', 'Providers available: {time}', { time: formattedStartDate })}
headerLabel={t('providersAvailableToday', 'Providers available: {{time}}', { time: formattedStartDate })}
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export const EmptyState: React.FC<EmptyStateProps> = ({ headerTitle, displayText
</div>
<EmptyDataIllustration />
<p className={styles.content}>
<Trans i18nKey="emptyStateText" values={{ displayText: displayText }}>
There are no {displayText} to display
</Trans>
{t('emptyStateText', 'There are no {{displayText}} to display', { displayText })}
</p>
{scheduleType === 'Scheduled' ? (
<p className={styles.action}>
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-appointments-app/translations/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"durationMins": "Duration min",
"editAppointment": "Edit Appointment",
"editAppointments": "Edit Appointment",
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"encounters": "Encounters",
"encounterType": "Encounter type",
"endTime": "End Time",
Expand All @@ -73,7 +73,7 @@
"errorCreatingAppointmentService": "Error creating appointment service",
"filter": "Filter",
"gender": "Gender",
"highestServiceVolume": "High volume service: {time}",
"highestServiceVolume": "High volume service: {{time}}",
"home": "Home",
"identifier": "Identifier",
"launchFormUpForm": "Follow up",
Expand Down Expand Up @@ -102,7 +102,7 @@
"prev": "Prev",
"provider": "Provider",
"providers": "Providers",
"providersAvailableToday": "Providers available: {time}",
"providersAvailableToday": "Providers available: {{time}}",
"queueAddedSuccessfully": "",
"queueEntryError": "Error adding patient to the queue",
"reasonForChanges": "Reason For Changes",
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-appointments-app/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"durationMins": "المدة بالدقائق",
"editAppointment": "تعديل الموعد",
"editAppointments": "تعديل الموعد",
"emptyStateText": "لا يوجد {displayText} للعرض",
"emptyStateText": "لا يوجد {{displayText}} للعرض",
"encounters": "اللقاءات",
"encounterType": "نوع اللقاء",
"endTime": "وقت الانتهاء",
Expand All @@ -73,7 +73,7 @@
"errorCreatingAppointmentService": "Error creating appointment service",
"filter": "فلتر",
"gender": "الجنس",
"highestServiceVolume": "خدمة بأعلى حجم: {time}",
"highestServiceVolume": "خدمة بأعلى حجم: {{time}}",
"home": "الرئيسية",
"identifier": "معرف",
"launchFormUpForm": "متابعة",
Expand Down Expand Up @@ -102,7 +102,7 @@
"prev": "السابق",
"provider": "مقدم الخدمة",
"providers": "مقدمي الخدمة",
"providersAvailableToday": "المقدمون المتاحون: {time}",
"providersAvailableToday": "المقدمون المتاحون: {{time}}",
"queueAddedSuccessfully": "تمت إضافة الطابور بنجاح",
"queueEntryError": "خطأ في إضافة المريض إلى الطابور",
"reasonForChanges": "سبب التغييرات",
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-appointments-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"durationMins": "Duration min",
"editAppointment": "Edit Appointment",
"editAppointments": "Edit Appointment",
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"encounters": "Encounters",
"encounterType": "Encounter type",
"endTime": "End Time",
Expand All @@ -73,7 +73,7 @@
"errorCreatingAppointmentService": "Error creating appointment service",
"filter": "Filter",
"gender": "Gender",
"highestServiceVolume": "High volume service: {time}",
"highestServiceVolume": "High volume service: {{time}}",
"home": "Home",
"identifier": "Identifier",
"launchFormUpForm": "Follow up",
Expand Down Expand Up @@ -102,7 +102,7 @@
"prev": "Prev",
"provider": "Provider",
"providers": "Providers",
"providersAvailableToday": "Providers available: {time}",
"providersAvailableToday": "Providers available: {{time}}",
"queueAddedSuccessfully": "",
"queueEntryError": "Error adding patient to the queue",
"reasonForChanges": "Reason For Changes",
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-appointments-app/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"durationMins": "Duración (min)",
"editAppointment": "Editar cita",
"editAppointments": "Editar cita",
"emptyStateText": "No hay {displayText} para mostrar",
"emptyStateText": "No hay {{displayText}} para mostrar",
"encounters": "Encuentros",
"encounterType": "Tipo de encuentro",
"endTime": "Hora de finalización",
Expand All @@ -73,7 +73,7 @@
"errorCreatingAppointmentService": "Error creating appointment service",
"filter": "Filtrar",
"gender": "Género",
"highestServiceVolume": "Servicio de alto volumen: {time}",
"highestServiceVolume": "Servicio de alto volumen: {{time}}",
"home": "Inicio",
"identifier": "Identificador",
"launchFormUpForm": "Seguimiento",
Expand Down Expand Up @@ -102,7 +102,7 @@
"prev": "Anterior",
"provider": "Proveedor",
"providers": "Proveedores",
"providersAvailableToday": "Proveedores disponibles: {time}",
"providersAvailableToday": "Proveedores disponibles: {{time}}",
"queueAddedSuccessfully": "",
"queueEntryError": "Error al agregar paciente a la cola",
"reasonForChanges": "Motivo de los cambios",
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-appointments-app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"durationMins": "Duration min",
"editAppointment": "Edit Appointment",
"editAppointments": "Edit Appointment",
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"encounters": "Encounters",
"encounterType": "Encounter type",
"endTime": "End Time",
Expand All @@ -73,7 +73,7 @@
"errorCreatingAppointmentService": "Error creating appointment service",
"filter": "Filter",
"gender": "Gender",
"highestServiceVolume": "High volume service: {time}",
"highestServiceVolume": "High volume service: {{time}}",
"home": "Home",
"identifier": "Identifier",
"launchFormUpForm": "Follow up",
Expand Down Expand Up @@ -102,7 +102,7 @@
"prev": "Prev",
"provider": "Provider",
"providers": "Providers",
"providersAvailableToday": "Providers available: {time}",
"providersAvailableToday": "Providers available: {{time}}",
"queueAddedSuccessfully": "",
"queueEntryError": "Error adding patient to the queue",
"reasonForChanges": "Reason For Changes",
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-appointments-app/translations/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"durationMins": "משך בדקות",
"editAppointment": "עריכת תור",
"editAppointments": "Edit Appointment",
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"encounters": "פגישות",
"encounterType": "סוג הפגישה",
"endTime": "שעת סיום",
Expand All @@ -73,7 +73,7 @@
"errorCreatingAppointmentService": "Error creating appointment service",
"filter": "סינון",
"gender": "Gender",
"highestServiceVolume": "נפח שירות גבוה: {time}",
"highestServiceVolume": "נפח שירות גבוה: {{time}}",
"home": "Home",
"identifier": "מזהה",
"launchFormUpForm": "Follow up",
Expand Down Expand Up @@ -102,7 +102,7 @@
"prev": "Prev",
"provider": "ספק",
"providers": "ספקים",
"providersAvailableToday": "ספקים זמינים: {time}",
"providersAvailableToday": "ספקים זמינים: {{time}}",
"queueAddedSuccessfully": "",
"queueEntryError": "שגיאה בהוספת המטופל לתור",
"reasonForChanges": "סיבת השינויים",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-appointments-app/translations/km.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"durationMins": "រយៈពេលអប្បបរមា",
"editAppointment": "កែសម្រួលការណាត់ជួប",
"editAppointments": "Edit Appointment",
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"encounters": "ការជួប",
"encounterType": "ប្រភេទជួប",
"endTime": "ពេលវេលាបញ្ចប់",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect, useMemo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { TFunction } from 'i18next';
import useSWR from 'swr';
import {
getDynamicOfflineDataEntries,
Expand All @@ -11,11 +12,10 @@ import {
navigate,
useConfig,
} from '@openmrs/esm-framework';
import { Button, Checkbox, Pagination, Search, SkeletonText, CheckboxSkeleton } from '@carbon/react';
import { Button, Checkbox, Pagination, Search, CheckboxSkeleton } from '@carbon/react';
import { addPatientToList, getAllPatientLists, getPatientListIdsForPatient } from '../api/api-remote';
import { TFunction } from 'i18next';
import styles from './add-patient.scss';
import { ConfigSchema } from '../config-schema';
import styles from './add-patient.scss';

interface AddPatientProps {
closeModal: () => void;
Expand Down
23 changes: 22 additions & 1 deletion packages/esm-patient-list-app/src/api/api-remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,24 @@ export async function getPatientListMembers(cohortUuid: string, ac = new AbortCo
throw error;
}

const currentDate = new Date();
const searchQuery = results.map((p) => p.patient.uuid).join(',');
const result = await openmrsFetch(`/ws/fhir2/R4/Patient/_search?_id=${searchQuery}`, {
method: 'POST',
signal: ac.signal,
});

const patients: Array<PatientListMember> = result.data.entry.map((e) => e.resource);
return patients;
const validPatients = patients.filter((patient) => {
if (!patient.endDate) {
return true;
}

const endDate = new Date(patient.endDate);
return endDate >= currentDate;
});

return validPatients;
}

export async function getPatientListIdsForPatient(patientUuid: string, ac = new AbortController()) {
Expand All @@ -136,6 +146,17 @@ export async function addPatientToList(data: AddPatientData, ac = new AbortContr
return postData(`${cohortUrl}/cohortmember`, data, ac);
}

export async function removePatientFromList(cohortMembershipUuid: string) {
const ac = new AbortController();
return postData(
`${cohortUrl}/cohortmember/${cohortMembershipUuid}`,
{
endDate: new Date(),
},
ac,
);
}

export async function createPatientList(cohort: NewCohortDataPayload, ac = new AbortController()) {
return postData(
`${cohortUrl}/cohort/`,
Expand Down
32 changes: 22 additions & 10 deletions packages/esm-patient-list-app/src/api/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { useEffect, useState } from 'react';
import useSWR from 'swr';
import useSWRInfinite from 'swr/infinite';
import { openmrsFetch, FetchResponse, useConfig } from '@openmrs/esm-framework';
import { cohortUrl, getAllPatientLists, getPatientListIdsForPatient, getPatientListMembers } from './api-remote';
import { ConfigSchema } from '../config-schema';
import {
CohortResponse,
CohortType,
Expand All @@ -6,12 +12,6 @@ import {
PatientListFilter,
PatientListType,
} from './types';
import { openmrsFetch, FetchResponse, useConfig } from '@openmrs/esm-framework';
import useSWR from 'swr';
import useSWRInfinite from 'swr/infinite';
import { cohortUrl, getAllPatientLists, getPatientListIdsForPatient, getPatientListMembers } from './api-remote';
import { ConfigSchema } from '../config-schema';
import { useEffect, useState } from 'react';

interface PatientListResponse {
results: CohortResponse<OpenmrsCohort>;
Expand Down Expand Up @@ -120,10 +120,10 @@ export function usePatientListDetails(patientListUuid: string) {
);

return {
data: data?.data,
listDetails: data?.data,
error,
isLoading,
mutate,
mutateListDetails: mutate,
};
}

Expand All @@ -134,11 +134,23 @@ export function usePatientListMembers(
pageSize: number = 10,
v: string = 'full',
) {
const swrResult = useSWR<FetchResponse<CohortResponse<OpenmrsCohortMember>>, Error>(
const { data, error, isLoading, mutate } = useSWR<FetchResponse<CohortResponse<OpenmrsCohortMember>>, Error>(
`${cohortUrl}/cohortmember?cohort=${patientListUuid}&startIndex=${startIndex}&limit=${pageSize}&v=${v}&q=${searchQuery}`,
openmrsFetch,
);
return { ...swrResult, data: swrResult?.data?.data?.results };

// FIXME: This is a workaround for removing a patient from a list
const filterList = (listMembers: Array<OpenmrsCohortMember>) =>
listMembers.filter((member) => !member.endDate && !member.voided);

const filteredListMembers = filterList(data?.data?.results ?? []);

return {
listMembers: filteredListMembers,
isLoadingListMembers: isLoading,
error: error,
mutateListMembers: mutate,
};
}

export function useCohortTypes() {
Expand Down
Loading

0 comments on commit 5ae859c

Please sign in to comment.