From 6b5e053f7b7e5a8691a64b8f13b1ffd35a61b69e Mon Sep 17 00:00:00 2001 From: lucille Date: Fri, 16 Aug 2024 20:03:11 +0300 Subject: [PATCH] update- from the comments on the PR --- .../esm-appointments-app/src/config-schema.ts | 4 ++-- .../esm-appointments-app/src/helpers/excel.ts | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/esm-appointments-app/src/config-schema.ts b/packages/esm-appointments-app/src/config-schema.ts index 5fbcc49f4..baa698a8c 100644 --- a/packages/esm-appointments-app/src/config-schema.ts +++ b/packages/esm-appointments-app/src/config-schema.ts @@ -2,7 +2,7 @@ import { Type, restBaseUrl, validators } from '@openmrs/esm-framework'; import { spaHomePage } from './constants'; export const configSchema = { - includeTelephoneNumbers: { + includeTelephoneNumbersInExcelDownload: { _type: Type.Boolean, _description: 'Whether to include phone numbers in the Excel export.', _default: false, @@ -151,5 +151,5 @@ export interface ConfigObject { showUnscheduledAppointmentsTab: boolean; useBahmniAppointmentsUI: boolean; useFullViewPrivilege: boolean; - includeTelephoneNumbers: boolean; + includeTelephoneNumbersInExcelDownload: boolean; } diff --git a/packages/esm-appointments-app/src/helpers/excel.ts b/packages/esm-appointments-app/src/helpers/excel.ts index 41bf4b7f5..7738a4415 100644 --- a/packages/esm-appointments-app/src/helpers/excel.ts +++ b/packages/esm-appointments-app/src/helpers/excel.ts @@ -4,7 +4,7 @@ import { type Appointment } from '../types'; import { type ConfigObject } from '../config-schema'; import { moduleName } from '../constants'; -async function fetchPatient(patientUuid: string): Promise { +async function fetchCurrentPatient(patientUuid: string): Promise { // Fetch the FHIR Patient object because telephone numbers are not included // in the standard appointments REST response const apiUrl = `${fhirBaseUrl}/Patient/${patientUuid}`; @@ -18,16 +18,15 @@ async function fetchPatient(patientUuid: string): Promise { */ export async function downloadAppointmentsAsExcel(appointments: Array, fileName = 'Appointments') { const config = await getConfig(moduleName); - const INCLUDE_TELEPHONE_NUMBERS = config.includeTelephoneNumbers ?? false; + const includeTelephoneNumbers = config.includeTelephoneNumbersInExcelDownload ?? false; const appointmentsJSON = await Promise.all( appointments.map(async (appointment: Appointment) => { - const patientinfo = await fetchPatient(appointment.patient.uuid); + const patientInfo = await fetchCurrentPatient(appointment.patient.uuid); const phoneNumber = - INCLUDE_TELEPHONE_NUMBERS && patientinfo?.telecom - ? patientinfo.telecom.map((telecomObj) => telecomObj?.value).join(', ') + includeTelephoneNumbers && patientInfo?.telecom + ? patientInfo.telecom.map((telecomObj) => telecomObj?.value).join(', ') : ''; - return { 'Patient name': appointment.patient.name, Gender: appointment.patient.gender === 'F' ? 'Female' : 'Male', @@ -35,7 +34,7 @@ export async function downloadAppointmentsAsExcel(appointments: Array