@kenyaemr/esm-appointments-app 8.1.2-pre.181 → 8.1.2-pre.183

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/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"home-appointments","slot":"homepage-widgets-slot","component":"homeAppointments","order":1},{"name":"clinical-appointments-dashboard-link","slot":"homepage-dashboard-slot","component":"appointmentsDashboardLink","meta":{"name":"appointments","slot":"clinical-appointments-dashboard-slot","title":"Appointments"}},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"expected-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"checked-in-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"completed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"missed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"cancelled-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"early-appointments-panel","component":"earlyAppointments"},{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-appointments-dashboard-slot","title":"Appointments","path":"Appointments"}},{"name":"patientAppointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"visit-form-top-slot"},{"name":"edit-appointments-form","component":"appointmentsForm","meta":{"title":{"key":"editAppointment","default":"Edit Appointment"}}},{"name":"search-patient","component":"searchPatient"},{"name":"create-appointment","component":"appointmentsForm","meta":{"title":{"key":"appointmentForm","default":"Appointment Form"}}},{"name":"add-appointment","component":"appointmentsForm","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"patient-appointment-cancel-confirmation-dialog","component":"patientAppointmentsCancelConfirmationDialog"}],"version":"8.1.2-pre.181"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"home-appointments","slot":"homepage-widgets-slot","component":"homeAppointments","order":1},{"name":"clinical-appointments-dashboard-link","slot":"homepage-dashboard-slot","component":"appointmentsDashboardLink","meta":{"name":"appointments","slot":"clinical-appointments-dashboard-slot","title":"Appointments"}},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"expected-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"checked-in-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"completed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"missed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"cancelled-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"early-appointments-panel","component":"earlyAppointments"},{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-appointments-dashboard-slot","title":"Appointments","path":"Appointments"}},{"name":"patientAppointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"visit-form-top-slot"},{"name":"edit-appointments-form","component":"appointmentsForm","meta":{"title":{"key":"editAppointment","default":"Edit Appointment"}}},{"name":"search-patient","component":"searchPatient"},{"name":"create-appointment","component":"appointmentsForm","meta":{"title":{"key":"appointmentForm","default":"Appointment Form"}}},{"name":"add-appointment","component":"appointmentsForm","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"patient-appointment-cancel-confirmation-dialog","component":"patientAppointmentsCancelConfirmationDialog"}],"version":"8.1.2-pre.183"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-appointments-app",
3
- "version": "8.1.2-pre.181",
3
+ "version": "8.1.2-pre.183",
4
4
  "description": "Appointments front-end module for the OpenMRS SPA",
5
5
  "browser": "dist/kenyaemr-esm-appointments-app.js",
6
6
  "main": "src/index.ts",
@@ -1,5 +1,5 @@
1
1
  import * as XLSX from 'xlsx';
2
- import { fetchCurrentPatient, formatDate, getConfig } from '@openmrs/esm-framework';
2
+ import { fetchCurrentPatient, formatDate, getConfig, openmrsFetch, type Patient, restBaseUrl } from '@openmrs/esm-framework';
3
3
  import { type Appointment } from '../types';
4
4
  import { type ConfigObject } from '../config-schema';
5
5
  import { moduleName } from '../constants';
@@ -16,16 +16,18 @@ export async function exportAppointmentsToSpreadsheet(appointments: Array<Appoin
16
16
  const appointmentsJSON = await Promise.all(
17
17
  appointments.map(async (appointment: Appointment) => {
18
18
  const patientInfo = await fetchCurrentPatient(appointment.patient.uuid);
19
+
20
+ const phoneNumberFromPatientAttributes = await getPhoneNumber(appointment.patient.uuid);
19
21
  const phoneNumber =
20
22
  includePhoneNumbers && patientInfo?.telecom
21
23
  ? patientInfo.telecom.map((telecomObj) => telecomObj?.value).join(', ')
22
- : '';
24
+ : phoneNumberFromPatientAttributes;
23
25
 
24
26
  return {
25
27
  'Patient name': appointment.patient.name,
26
28
  Gender: appointment.patient.gender === 'F' ? 'Female' : 'Male',
27
29
  Age: appointment.patient.age,
28
- Identifier: appointment.patient.identifier ?? '--',
30
+ Identifier: extractIdentifier(patientInfo) ?? appointment.patient.identifier ?? '--',
29
31
  'Appointment type': appointment.service?.name,
30
32
  Date: formatDate(new Date(appointment.startDateTime), { mode: 'wide' }),
31
33
  ...(includePhoneNumbers ? { 'Telephone number': phoneNumber } : {}),
@@ -52,7 +54,7 @@ export function exportUnscheduledAppointmentsToSpreadsheet(
52
54
  Gender: appointment.gender === 'F' ? 'Female' : 'Male',
53
55
  Age: appointment.age,
54
56
  'Phone Number': appointment.phoneNumber ?? '--',
55
- Identifier: appointment.identifier ?? '--',
57
+ Identifier: extractIdentifier(appointment) ?? appointment.identifier,
56
58
  }));
57
59
 
58
60
  const worksheet = createWorksheet(appointmentsJSON);
@@ -75,3 +77,26 @@ function createWorkbook(worksheet: XLSX.WorkSheet, sheetName: string) {
75
77
  XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
76
78
  return workbook;
77
79
  }
80
+
81
+ const customRepresentation =
82
+ 'custom:(uuid,display,identifiers:(identifier,uuid,preferred,location:(uuid,name),identifierType:(uuid,name,format,formatDescription,validator)),person:(uuid,display,gender,birthdate,dead,age,deathDate,birthdateEstimated,causeOfDeath,preferredName:(uuid,preferred,givenName,middleName,familyName),attributes,preferredAddress:(uuid,preferred,address1,address2,cityVillage,longitude,stateProvince,latitude,country,postalCode,countyDistrict,address3,address4,address5,address6,address7)))';
83
+
84
+ // This is a temporary fix to get the phone number from the patient attributes.
85
+ export const getPhoneNumber = async (patientUuid: string) => {
86
+ const response = await openmrsFetch<Patient>(`${restBaseUrl}/patient/${patientUuid}?v=${customRepresentation}`);
87
+ const phoneNumberPersonAttributeTypeUuid = 'b2c38640-2603-4629-aebd-3b54f33f1e3a';
88
+ return (
89
+ response?.data?.person?.attributes?.find(
90
+ (attribute) => attribute.attributeType.uuid === phoneNumberPersonAttributeTypeUuid,
91
+ )?.value ?? '--'
92
+ );
93
+ };
94
+
95
+ export const extractIdentifier = (patientInfo: fhir.Patient) => {
96
+ const patientClinicNumberIdentifierTypeUuid = 'b4d66522-11fc-45c7-83e3-39a1af21ae0d';
97
+ const identifiers = patientInfo?.identifier;
98
+ const clinicNumberIdentifier = identifiers?.find((identifier) =>
99
+ identifier?.type?.coding.find((coding) => coding?.code === patientClinicNumberIdentifierTypeUuid),
100
+ );
101
+ return clinicNumberIdentifier?.value ?? '';
102
+ };