Skip to content

Commit

Permalink
Merge branch 'main' into O3-4218
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Nov 27, 2024
2 parents e0d3041 + cf778ee commit 6b850e4
Show file tree
Hide file tree
Showing 43 changed files with 762 additions and 306 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@carbon/react": "~1.37.0",
"@carbon/react": "^1.71.0",
"@openmrs/esm-framework": "next",
"@openmrs/esm-patient-common-lib": "next",
"@playwright/test": "1.48.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-active-visits-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/openmrs/openmrs-esm-patient-management/issues"
},
"dependencies": {
"@carbon/react": "~1.37.0",
"@carbon/react": "^1.71.0",
"lodash-es": "^4.17.15"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-appointments-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/openmrs/openmrs-esm-patient-management/issues"
},
"dependencies": {
"@carbon/react": "~1.37.0",
"@carbon/react": "^1.71.0",
"formik": "^2.2.9",
"lodash-es": "^4.17.15",
"yup": "^0.32.11"
Expand Down
4 changes: 3 additions & 1 deletion packages/esm-appointments-app/src/appointments.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ describe('Appointments', () => {
await screen.findByText(/^appointments$/i);
expect(screen.getByRole('button', { name: /appointments calendar/i })).toBeInTheDocument();
expect(screen.getByPlaceholderText(/dd-mmm-yyyy/i)).toBeInTheDocument();
expect(screen.getByRole('combobox', { name: /view/i })).toBeInTheDocument();
screen.getByRole('combobox', {
name: /select service type/i,
});
expect(screen.getByText(/appointment metrics/i)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ const AppointmentsForm: React.FC<AppointmentsFormProps & DefaultWorkspaceProps>
appointmentRequest: appointmentPayload,
recurringPattern: constructRecurringPattern(data),
};

const abortController = new AbortController();

(isRecurringAppointment
? saveRecurringAppointments(recurringAppointmentPayload, abortController)
: saveAppointment(appointmentPayload, abortController)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const defaultProps = {
closeWorkspace: jest.fn(),
patientUuid: mockPatient.id,
promptBeforeClosing: jest.fn(),
closeWorkspaceWithSavedChanges: jest.fn(),
setTitle: jest.fn(),
};

const mockCreateAppointment = jest.mocked(saveAppointment);
Expand Down Expand Up @@ -206,6 +208,7 @@ describe('AppointmentForm', () => {
await user.selectOptions(timeFormat, 'AM');
await user.selectOptions(serviceSelect, ['Outpatient']);
await user.selectOptions(appointmentTypeSelect, ['Scheduled']);
// TODO: Fix the `Error: Not implemented: HTMLFormElement.prototype.requestSubmit` error shown after the form is submitted
await user.click(saveButton);
});
});
2 changes: 1 addition & 1 deletion packages/esm-bed-management-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/openmrs/openmrs-esm-patient-management/issues"
},
"dependencies": {
"@carbon/react": "~1.37.0",
"@carbon/react": "^1.71.0",
"lodash-es": "^4.17.15"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-list-management-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/openmrs/openmrs-esm-patient-management/issues"
},
"dependencies": {
"@carbon/react": "~1.37.0",
"@carbon/react": "^1.71.0",
"dexie": "^3.0.3",
"fuzzy": "^0.1.3",
"lodash-es": "^4.17.15"
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-registration-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/openmrs/openmrs-esm-patient-management/issues"
},
"dependencies": {
"@carbon/react": "~1.37.0",
"@carbon/react": "^1.71.0",
"formik": "^2.1.5",
"lodash-es": "^4.17.15",
"uuid": "^8.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function DeathDateField() {
selectedDate ? dayjs(selectedDate).hour(0).minute(0).second(0).millisecond(0).toDate() : undefined,
);
},
[deathDate],
[setFieldValue],
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const DobField: React.FC = () => {
setFieldValue('monthsEstimated', '');
setFieldTouched('birthdateEstimated', true, false);
},
[setFieldValue],
[setFieldTouched, setFieldValue],
);

const onDateChange = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const GenderField: React.FC = () => {
<div className={styles.halfWidthInDesktopView}>
<h4 className={styles.productiveHeading02Light}>{t('sexFieldLabelText', 'Sex')}</h4>
<div className={styles.sexField}>
<p className="cds--label">{t('genderLabelText', 'Sex')}</p>
<RadioButtonGroup name="gender" orientation="vertical" onChange={setGender} valueSelected={field.value}>
<RadioButtonGroup
name="gender"
legendText={t('genderLabelText', 'Sex')}
orientation="vertical"
onChange={setGender}
valueSelected={field.value}>
{fieldConfigs.map((option) => (
<RadioButton
key={option.label ?? option.value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useTranslation } from 'react-i18next';
import { ContentSwitcher, Switch } from '@carbon/react';
import { useField } from 'formik';
import { ExtensionSlot, useConfig } from '@openmrs/esm-framework';
import { type RegistrationConfig } from '../../../config-schema';
import { Input } from '../../input/basic-input/input/input.component';
import { PatientRegistrationContext } from '../../patient-registration-context';
import { type RegistrationConfig } from '../../../config-schema';
import styles from '../field.scss';

export const unidentifiedPatientAttributeTypeUuid = '8b56eac7-5c76-4b9c-8c6f-1deab8d3fc47';
Expand Down Expand Up @@ -51,7 +51,7 @@ export const NameField = () => {
setFieldTouched('photo', true, false);
}
},
[setCapturePhotoProps],
[setCapturePhotoProps, setFieldTouched],
);

const toggleNameKnown = (e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { Field } from 'formik';
import { Layer, Select, SelectItem } from '@carbon/react';
import { reportError } from '@openmrs/esm-framework';
import { type PersonAttributeTypeResponse } from '../../patient-registration.types';
import { useConceptAnswers } from '../field.resource';
import styles from './../field.scss';
import { reportError } from '@openmrs/esm-framework';

export interface CodedPersonAttributeFieldProps {
id: string;
Expand Down Expand Up @@ -44,7 +44,7 @@ export function CodedPersonAttributeField({
);
setError(true);
}
}, [answerConceptSetUuid, customConceptAnswers]);
}, [answerConceptSetUuid, customConceptAnswers, id, t]);

useEffect(() => {
if (!isLoadingConceptAnswers && !customConceptAnswers.length) {
Expand Down Expand Up @@ -72,7 +72,7 @@ export function CodedPersonAttributeField({
setError(true);
}
}
}, [isLoadingConceptAnswers, conceptAnswers, customConceptAnswers]);
}, [isLoadingConceptAnswers, conceptAnswers, customConceptAnswers, t, id, answerConceptSetUuid]);

const answers = useMemo(() => {
if (customConceptAnswers.length) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { type Dispatch, useEffect, useMemo, useState } from 'react';
import {
type FetchResponse,
type OpenmrsResource,
getSynchronizationItems,
openmrsFetch,
type OpenmrsResource,
restBaseUrl,
useConfig,
usePatient,
} from '@openmrs/esm-framework';
import camelCase from 'lodash-es/camelCase';
import { type Dispatch, useEffect, useMemo, useState } from 'react';
import dayjs from 'dayjs';
import useSWR from 'swr';
import { v4 } from 'uuid';
import { type RegistrationConfig } from '../config-schema';
Expand All @@ -29,7 +30,15 @@ import {
latestFirstEncounter,
} from './patient-registration-utils';
import { useInitialPatientRelationships } from './section/patient-relationships/relationships.resource';
import dayjs from 'dayjs';

interface DeathInfoResults {
uuid: string;
display: string;
causeOfDeath: OpenmrsResource | null;
dead: boolean;
deathDate: string;
causeOfDeathNonCoded: string | null;
}

export function useInitialFormValues(patientUuid: string): [FormValues, Dispatch<FormValues>] {
const { freeTextFieldConceptUuid } = useConfig<RegistrationConfig>();
Expand Down Expand Up @@ -99,7 +108,7 @@ export function useInitialFormValues(patientUuid: string): [FormValues, Dispatch
setInitialFormValues(registration._patientRegistrationData.formValues);
}
})();
}, [isLoadingPatientToEdit, patientToEdit, patientUuid]);
}, [initialFormValues, isLoadingPatientToEdit, patientToEdit, patientUuid]);

// Set initial patient death info
useEffect(() => {
Expand All @@ -118,7 +127,7 @@ export function useInitialFormValues(patientUuid: string): [FormValues, Dispatch
nonCodedCauseOfDeath: deathInfo.causeOfDeathNonCoded,
}));
}
}, [isLoadingDeathInfo, deathInfo, setInitialFormValues]);
}, [isLoadingDeathInfo, deathInfo, setInitialFormValues, freeTextFieldConceptUuid]);

// Set initial patient relationships
useEffect(() => {
Expand Down Expand Up @@ -187,7 +196,7 @@ export function useInitialAddressFieldValues(patientUuid: string, fallback = {})
setInitialAddressFieldValues(registration?._patientRegistrationData.initialAddressFieldValues ?? fallback);
}
})();
}, [isLoading, patient, patientUuid]);
}, [fallback, initialAddressFieldValues, isLoading, patient, patientUuid]);

return [initialAddressFieldValues, setInitialAddressFieldValues];
}
Expand All @@ -208,7 +217,7 @@ export function usePatientUuidMap(
setPatientUuidMap(registration?._patientRegistrationData.initialAddressFieldValues ?? fallback),
);
}
}, [isLoadingPatientToEdit, patientToEdit, patientUuid]);
}, [fallback, isLoadingPatientToEdit, patientToEdit, patientUuid, patientUuidMap]);

useEffect(() => {
if (attributes) {
Expand Down Expand Up @@ -263,7 +272,7 @@ export function useInitialPatientIdentifiers(patientUuid: string): {
data: identifiers,
isLoading,
};
}, [data, error]);
}, [data?.data?.results, isLoading]);

return result;
}
Expand Down Expand Up @@ -299,19 +308,10 @@ function useInitialPersonAttributes(personUuid: string) {
data: data?.data?.results,
isLoading,
};
}, [data, error]);
}, [data?.data?.results, isLoading]);
return result;
}

interface DeathInfoResults {
uuid: string;
display: string;
causeOfDeath: OpenmrsResource | null;
dead: boolean;
deathDate: string;
causeOfDeathNonCoded: string | null;
}

function useInitialPersonDeathInfo(personUuid: string) {
const { data, error, isLoading } = useSWR<FetchResponse<DeathInfoResults>, Error>(
!!personUuid
Expand All @@ -325,7 +325,7 @@ function useInitialPersonDeathInfo(personUuid: string) {
data: data?.data,
isLoading,
};
}, [data, error]);
}, [data?.data, isLoading]);
return result;
}

Expand Down
Loading

0 comments on commit 6b850e4

Please sign in to comment.