Skip to content

Commit

Permalink
(feat) O3-3159: Add patient header on appointment form (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
usamaidrsk authored May 14, 2024
1 parent 87510b8 commit 416e4be
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import isToday from 'dayjs/plugin/isToday';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc);
dayjs.extend(isToday);
import {
Button,
DataTable,
Expand All @@ -28,13 +26,13 @@ import {
} from '@carbon/react';
import {
ConfigurableLink,
formatDatetime,
usePagination,
formatDate,
useConfig,
parseDate,
formatDatetime,
isDesktop,
parseDate,
useConfig,
useLayoutType,
usePagination,
} from '@openmrs/esm-framework';
import { Download } from '@carbon/react/icons';
import { EmptyState } from '../../empty-state/empty-state.component';
Expand All @@ -50,6 +48,9 @@ import AppointmentsForm from '../../form/appointments-form.component';
import PatientSearch from '../../patient-search/patient-search.component';
import styles from './appointments-table.scss';

dayjs.extend(utc);
dayjs.extend(isToday);

interface AppointmentsTableProps {
appointments: Array<Appointment>;
isLoading: boolean;
Expand Down Expand Up @@ -220,6 +221,7 @@ const AppointmentsTable: React.FC<AppointmentsTableProps> = ({ appointments, isL
launchOverlay(
t('editAppointments', 'Edit appointment'),
<AppointmentsForm
patientUuid={matchingAppointment.patient.uuid}
appointment={matchingAppointment}
context="editing"
closeWorkspace={closeOverlay}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import { Controller, useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import {
ExtensionSlot,
ResponsiveWrapper,
showSnackbar,
translateFrom,
useConfig,
useLayoutType,
useLocations,
usePatient,
useSession,
} from '@openmrs/esm-framework';
import {
Expand All @@ -47,16 +49,14 @@ import {
dateFormat,
datePickerFormat,
datePickerPlaceHolder,
moduleName,
weekDays,
} from '../constants';
import styles from './appointments-form.scss';
import SelectedDateContext from '../hooks/selectedDateContext';

import uniqBy from 'lodash/uniqBy';
import { moduleName } from '../constants';


const time12HourFormatRegexPattern = '^(1[0-2]|0?[1-9]):[0-5][0-9]$';

function isValidTime(timeStr) {
return timeStr.match(new RegExp(time12HourFormatRegexPattern));
}
Expand Down Expand Up @@ -117,6 +117,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
context,
closeWorkspace,
}) => {
const { patient } = usePatient(patientUuid);
const { mutateAppointments } = useMutateAppointments();
const editedAppointmentTimeFormat = new Date(appointment?.startDateTime).getHours() >= 12 ? 'PM' : 'AM';
const defaultTimeFormat = appointment?.startDateTime
Expand Down Expand Up @@ -369,6 +370,16 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
return (
<Form onSubmit={handleSubmit(handleSaveAppointment, onError)}>
<Stack gap={4}>
{patient && (
<ExtensionSlot
name="patient-header-slot"
state={{
patient,
patientUuid: patientUuid,
hideActionsOverflow: true,
}}
/>
)}
<section className={styles.formGroup}>
<span className={styles.heading}>{t('location', 'Location')}</span>
<ResponsiveWrapper>
Expand Down
2 changes: 0 additions & 2 deletions packages/esm-appointments-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"endAppointmentAndVisitConfirmationMessage": "Checking the patient out will mark the appointment as complete, and close out the active visit for this patient.",
"endAppointmentConfirmation": "Are you sure you want to check the patient out for this appointment?",
"endAppointmentConfirmationMessage": "Checking the patient out will mark the appointment as complete.",
"endDate": "End date",
"endTime": "End Time",
"errorCreatingAppointmentService": "Error creating appointment service",
"expected": "Expected",
Expand Down Expand Up @@ -138,7 +137,6 @@
"service": "Service",
"serviceName": "Service name",
"serviceType": "Service Type",
"startDate": "Start date",
"startTime": "Start Time",
"status": "Status",
"time": "Time",
Expand Down

0 comments on commit 416e4be

Please sign in to comment.