From 6c0f98f977b21b55f2c26d18e9a1ef4d19670736 Mon Sep 17 00:00:00 2001 From: Donald Kibet Date: Mon, 10 Jul 2023 18:16:39 +0300 Subject: [PATCH 1/6] (refactor): Display all active visits by removing filter for showing only today's active visits (#755) --- .../src/active-visits-widget/active-visits.resource.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx b/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx index c541bbbe0..64151aa80 100644 --- a/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx +++ b/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx @@ -37,7 +37,6 @@ interface VisitResponse { export function useActiveVisits() { const session = useSession(); const config = useConfig(); - const startDate = dayjs().format('YYYY-MM-DD'); const sessionLocation = session?.sessionLocation?.uuid; const customRepresentation = @@ -49,7 +48,7 @@ export function useActiveVisits() { return null; } - let url = `/ws/rest/v1/visit?includeInactive=false&v=${customRepresentation}&totalCount=true&fromStartDate=${startDate}&location=${sessionLocation}`; + let url = `/ws/rest/v1/visit?includeInactive=false&v=${customRepresentation}&totalCount=true&location=${sessionLocation}`; if (pageIndex) { url += `&startIndex=${pageIndex * 50}`; From 3612ea9354ea80c6f9d580a44027bfba745990e3 Mon Sep 17 00:00:00 2001 From: Donald Kibet Date: Tue, 11 Jul 2023 09:42:30 +0300 Subject: [PATCH 2/6] (refactor): changed activeVisits.idNumber assignment for improved code robustness (#756) --- .../active-visits.resource.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx b/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx index 64151aa80..4b60735e4 100644 --- a/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx +++ b/packages/esm-active-visits-app/src/active-visits-widget/active-visits.resource.tsx @@ -87,11 +87,11 @@ export function useActiveVisits() { visitUuid: visit.uuid, }; - //in case no configuration is given the previsous behavior remanes the same + //in case no configuration is given the previous behavior remains the same if (!config?.activeVisits?.identifiers) { - activeVisits.idNumber = visit?.patient?.identifiers[0].identifier; + activeVisits.idNumber = visit?.patient?.identifiers[0]?.identifier ?? '--'; } else { - //map identifires on config + //map identifiers on config config?.activeVisits?.identifiers?.map((configIdentifier) => { //check if in the current visit the patient has in his identifiers the current identifierType name const visitIdentifier = visit?.patient?.identifiers.find( @@ -99,7 +99,7 @@ export function useActiveVisits() { ); //add the new identifier or rewrite existing one to activeVisit object - //the parameter will corresponde to the name of the key value of the configuration + //the parameter will corresponds to the name of the key value of the configuration //and the respective value is the visit identifier //If there isn't a identifier we display this default text '--' activeVisits[configIdentifier.header?.key] = visitIdentifier?.identifier ?? '--'; @@ -114,7 +114,7 @@ export function useActiveVisits() { ); //add the new attribute or rewrite existing one to activeVisit object - //the parameter will corresponde to the name of the key value of the configuration + //the parameter will correspond to the name of the key value of the configuration //and the respective value is the persons value //If there isn't a attribute we display this default text '--' activeVisits[header?.key] = personAttributes?.value ?? '--'; @@ -124,12 +124,7 @@ export function useActiveVisits() { }; const formattedActiveVisits: Array = data - ? [].concat( - ...data?.map( - (res) => res?.data?.results?.map(mapVisitProperties), - // ?.filter(({ visitStartTime }) => dayjs(visitStartTime).isToday()), - ), - ) + ? [].concat(...data?.map((res) => res?.data?.results?.map(mapVisitProperties))) : []; return { From 7dbf922e29a96925edb0bc700b4383f904b8ac6a Mon Sep 17 00:00:00 2001 From: Jexsie Date: Tue, 11 Jul 2023 23:38:41 +0300 Subject: [PATCH 3/6] (feat) O3-2100: Unknown patient name and estimated DOB config (#697) Co-authored-by: Vineet Sharma --- .../src/config-schema.ts | 16 +++-- .../field/dob/dob.component.tsx | 26 ++++---- .../field/dob/dob.test.tsx | 7 ++- .../field/name/name-field.component.tsx | 59 ++++++++++++------- .../patient-registration/form-manager.test.ts | 1 - .../src/patient-registration/form-manager.ts | 8 --- .../dummy-data/dummy-data-input.component.tsx | 1 - .../patient-registration-hooks.ts | 14 ++++- .../patient-registration-types.tsx | 1 - .../patient-registration-utils.ts | 3 - 10 files changed, 82 insertions(+), 54 deletions(-) diff --git a/packages/esm-patient-registration-app/src/config-schema.ts b/packages/esm-patient-registration-app/src/config-schema.ts index 7a6a77aad..c19f56f9f 100644 --- a/packages/esm-patient-registration-app/src/config-schema.ts +++ b/packages/esm-patient-registration-app/src/config-schema.ts @@ -37,7 +37,7 @@ export interface RegistrationConfig { fieldConfigurations: { name: { displayMiddleName: boolean; - unidentifiedPatient: boolean; + allowUnidentifiedPatients: boolean; defaultUnknownGivenName: string; defaultUnknownFamilyName: string; displayCapturePhoto: boolean; @@ -52,6 +52,7 @@ export interface RegistrationConfig { }; }; dateOfBirth: { + allowEstimatedDateOfBirth: boolean; useEstimatedDateOfBirth: { enabled: boolean; dayOfMonth: number; @@ -201,10 +202,10 @@ export const esmPatientRegistrationSchema = { fieldConfigurations: { name: { displayMiddleName: { _type: Type.Boolean, _default: true }, - unidentifiedPatient: { + allowUnidentifiedPatients: { _type: Type.Boolean, _default: true, - _description: 'Whether to allow patients to be registered without names.', + _description: 'Whether to allow registering unidentified patients.', }, defaultUnknownGivenName: { _type: Type.String, @@ -296,10 +297,15 @@ export const esmPatientRegistrationSchema = { }, }, dateOfBirth: { + allowEstimatedDateOfBirth: { + _type: Type.Boolean, + _description: 'Whether to allow estimated date of birth for a patient during registration', + _default: true, + }, useEstimatedDateOfBirth: { enabled: { _type: Type.Boolean, - _description: 'Whether to use custom day and month for estimated date of birth', + _description: 'Whether to use a fixed day and month for estimated date of birth', _default: false, }, dayOfMonth: { @@ -309,7 +315,7 @@ export const esmPatientRegistrationSchema = { }, month: { _type: Type.Number, - _description: 'The custom month to use on the estimated date of birth i.e 0 = Jan 11 = Dec', + _description: 'The custom month to use on the estimated date of birth i.e 0 = Jan & 11 = Dec', _default: 0, }, }, diff --git a/packages/esm-patient-registration-app/src/patient-registration/field/dob/dob.component.tsx b/packages/esm-patient-registration-app/src/patient-registration/field/dob/dob.component.tsx index a3db5b409..35d674c77 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/field/dob/dob.component.tsx +++ b/packages/esm-patient-registration-app/src/patient-registration/field/dob/dob.component.tsx @@ -25,9 +25,9 @@ export const DobField: React.FC = () => { const { t } = useTranslation(); const { fieldConfigurations: { dateOfBirth }, - } = useConfig() as RegistrationConfig; - const [dobUnknown] = useField('birthdateEstimated'); - const dobKnown = !dobUnknown.value; + } = useConfig(); + const allowEstimatedBirthDate = dateOfBirth?.allowEstimatedDateOfBirth; + const [{ value: dobUnknown }] = useField('birthdateEstimated'); const [birthdate, birthdateMeta] = useField('birthdate'); const [yearsEstimated, yearsEstimateMeta] = useField('yearsEstimated'); const [monthsEstimated, monthsEstimateMeta] = useField('monthsEstimated'); @@ -75,17 +75,19 @@ export const DobField: React.FC = () => { return (

{t('birthFieldLabelText', 'Birth')}

-
-
- {t('dobToggleLabelText', 'Date of Birth Known?')} + {(allowEstimatedBirthDate || dobUnknown) && ( +
+
+ {t('dobToggleLabelText', 'Date of Birth Known?')} +
+ + + +
- - - - -
+ )} - {dobKnown ? ( + {!dobUnknown ? (
{ return { ...originalModule, useConfig: jest.fn().mockImplementation(() => ({ - fieldConfigurations: { dateOfBirth: { useEstimatedDateOfBirth: { enabled: true, dayOfMonth: 0, month: 0 } } }, + fieldConfigurations: { + dateOfBirth: { + allowEstimatedDateOfBirth: true, + useEstimatedDateOfBirth: { enabled: true, dayOfMonth: 0, month: 0 }, + }, + }, })), }; }); diff --git a/packages/esm-patient-registration-app/src/patient-registration/field/name/name-field.component.tsx b/packages/esm-patient-registration-app/src/patient-registration/field/name/name-field.component.tsx index d25da7614..4a004f550 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/field/name/name-field.component.tsx +++ b/packages/esm-patient-registration-app/src/patient-registration/field/name/name-field.component.tsx @@ -8,6 +8,7 @@ import { PatientRegistrationContext } from '../../patient-registration-context'; import styles from '../field.scss'; import { RegistrationConfig } from '../../../config-schema'; +export const unidentifiedPatientAttributeTypeUuid = '8b56eac7-5c76-4b9c-8c6f-1deab8d3fc47'; const containsNoNumbers = /^([^0-9]*)$/; function checkNumber(value: string) { @@ -19,17 +20,26 @@ function checkNumber(value: string) { } export const NameField = () => { + const { t } = useTranslation(); + const { setCapturePhotoProps, currentPhoto, setFieldValue } = useContext(PatientRegistrationContext); const { fieldConfigurations: { - name: { displayCapturePhoto, displayReverseFieldOrder }, + name: { + displayCapturePhoto, + allowUnidentifiedPatients, + defaultUnknownGivenName, + defaultUnknownFamilyName, + displayMiddleName, + displayReverseFieldOrder, + }, }, - } = useConfig() as RegistrationConfig; - const { t } = useTranslation(); - const { setCapturePhotoProps, currentPhoto, setFieldValue } = useContext(PatientRegistrationContext); - const { fieldConfigurations } = useConfig(); - const fieldConfigs = fieldConfigurations?.name; - const [{ value: unidentified }] = useField('unidentifiedPatient'); - const nameKnown = !unidentified; + } = useConfig(); + + const [{ value: isPatientUnknownValue }, , { setValue: setUnknownPatient }] = useField( + `attributes.${unidentifiedPatientAttributeTypeUuid}`, + ); + + const isPatientUnknown = isPatientUnknownValue === 'true'; const onCapturePhoto = useCallback( (dataUri: string, photoDateTime: string) => { @@ -47,11 +57,11 @@ export const NameField = () => { if (e.name === 'known') { setFieldValue('givenName', ''); setFieldValue('familyName', ''); - setFieldValue('unidentifiedPatient', false); + setUnknownPatient('false'); } else { - setFieldValue('givenName', fieldConfigs.defaultUnknownGivenName); - setFieldValue('familyName', fieldConfigs.defaultUnknownFamilyName); - setFieldValue('unidentifiedPatient', true); + setFieldValue('givenName', defaultUnknownGivenName); + setFieldValue('familyName', defaultUnknownFamilyName); + setUnknownPatient('true'); } }; @@ -65,7 +75,7 @@ export const NameField = () => { /> ); - const middleNameField = fieldConfigs.displayMiddleName && ( + const middleNameField = displayMiddleName && ( { )}
-
- {t('patientNameKnown', "Patient's Name is Known?")} -
- - - - - {nameKnown && + {(allowUnidentifiedPatients || isPatientUnknown) && ( + <> +
+ {t('patientNameKnown', "Patient's Name is Known?")} +
+ + + + + + )} + {!isPatientUnknown && (!displayReverseFieldOrder ? ( <> {firstNameField} diff --git a/packages/esm-patient-registration-app/src/patient-registration/form-manager.test.ts b/packages/esm-patient-registration-app/src/patient-registration/form-manager.test.ts index bd431b105..51957e7f2 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/form-manager.test.ts +++ b/packages/esm-patient-registration-app/src/patient-registration/form-manager.test.ts @@ -8,7 +8,6 @@ const formValues: FormValues = { givenName: '', middleName: '', familyName: '', - unidentifiedPatient: false, additionalGivenName: '', additionalMiddleName: '', additionalFamilyName: '', diff --git a/packages/esm-patient-registration-app/src/patient-registration/form-manager.ts b/packages/esm-patient-registration-app/src/patient-registration/form-manager.ts index 685cd95e4..e094d1bba 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/form-manager.ts +++ b/packages/esm-patient-registration-app/src/patient-registration/form-manager.ts @@ -364,14 +364,6 @@ export class FormManager { } } - if (values.unidentifiedPatient) { - attributes.push({ - // The UUID of the 'Unknown Patient' attribute-type will always be static across all implementations of OpenMRS - attributeType: '8b56eac7-5c76-4b9c-8c6f-1deab8d3fc47', - value: 'true', - }); - } - return attributes; } diff --git a/packages/esm-patient-registration-app/src/patient-registration/input/dummy-data/dummy-data-input.component.tsx b/packages/esm-patient-registration-app/src/patient-registration/input/dummy-data/dummy-data-input.component.tsx index 22494978f..a0bccefe8 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/input/dummy-data/dummy-data-input.component.tsx +++ b/packages/esm-patient-registration-app/src/patient-registration/input/dummy-data/dummy-data-input.component.tsx @@ -12,7 +12,6 @@ export const dummyFormValues: FormValues = { givenName: 'John', middleName: '', familyName: 'Smith', - unidentifiedPatient: false, additionalGivenName: 'Joey', additionalMiddleName: '', additionalFamilyName: 'Smitty', diff --git a/packages/esm-patient-registration-app/src/patient-registration/patient-registration-hooks.ts b/packages/esm-patient-registration-app/src/patient-registration/patient-registration-hooks.ts index a18f8f9a0..db7ab45fc 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/patient-registration-hooks.ts +++ b/packages/esm-patient-registration-app/src/patient-registration/patient-registration-hooks.ts @@ -21,6 +21,7 @@ import { latestFirstEncounter, } from './patient-registration-utils'; import { useInitialPatientRelationships } from './section/patient-relationships/relationships.resource'; +import dayjs from 'dayjs'; export function useInitialFormValues(patientUuid: string): [FormValues, Dispatch] { const { isLoading: isLoadingPatientToEdit, patient: patientToEdit } = usePatient(patientUuid); @@ -34,7 +35,6 @@ export function useInitialFormValues(patientUuid: string): [FormValues, Dispatch givenName: '', middleName: '', familyName: '', - unidentifiedPatient: false, additionalGivenName: '', additionalMiddleName: '', additionalFamilyName: '', @@ -56,11 +56,22 @@ export function useInitialFormValues(patientUuid: string): [FormValues, Dispatch useEffect(() => { (async () => { if (patientToEdit) { + const birthdateEstimated = !/^\d{4}-\d{2}-\d{2}$/.test(patientToEdit.birthDate); + const [years = 0, months = 0] = patientToEdit.birthDate.split('-').map((val) => parseInt(val)); + // Please refer: https://github.com/openmrs/openmrs-esm-patient-management/pull/697#issuecomment-1562706118 + const estimatedMonthsAvailable = patientToEdit.birthDate.split('-').length > 1; + const yearsEstimated = birthdateEstimated ? Math.floor(dayjs().diff(patientToEdit.birthDate, 'month') / 12) : 0; + const monthsEstimated = + birthdateEstimated && estimatedMonthsAvailable ? dayjs().diff(patientToEdit.birthDate, 'month') % 12 : 0; + setInitialFormValues({ ...initialFormValues, ...getFormValuesFromFhirPatient(patientToEdit), address: getAddressFieldValuesFromFhirPatient(patientToEdit), ...getPhonePersonAttributeValueFromFhirPatient(patientToEdit), + birthdateEstimated: !/^\d{4}-\d{2}-\d{2}$/.test(patientToEdit.birthDate), + yearsEstimated, + monthsEstimated, }); } else if (!isLoadingPatientToEdit && patientUuid) { const registration = await getPatientRegistration(patientUuid); @@ -107,6 +118,7 @@ export function useInitialFormValues(patientUuid: string): [FormValues, Dispatch ? attribute.value?.uuid : attribute.value; }); + setInitialFormValues((initialFormValues) => ({ ...initialFormValues, attributes: personAttributes, diff --git a/packages/esm-patient-registration-app/src/patient-registration/patient-registration-types.tsx b/packages/esm-patient-registration-app/src/patient-registration/patient-registration-types.tsx index 020e00f6b..e59037bb9 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/patient-registration-types.tsx +++ b/packages/esm-patient-registration-app/src/patient-registration/patient-registration-types.tsx @@ -158,7 +158,6 @@ export interface FormValues { givenName: string; middleName: string; familyName: string; - unidentifiedPatient: boolean; additionalGivenName: string; additionalMiddleName: string; additionalFamilyName: string; diff --git a/packages/esm-patient-registration-app/src/patient-registration/patient-registration-utils.ts b/packages/esm-patient-registration-app/src/patient-registration/patient-registration-utils.ts index 437eba037..4624bc91b 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/patient-registration-utils.ts +++ b/packages/esm-patient-registration-app/src/patient-registration/patient-registration-utils.ts @@ -115,9 +115,6 @@ export function getFormValuesFromFhirPatient(patient: fhir.Patient) { result.givenName = patientName?.given[0]; result.middleName = patientName?.given[1]; result.familyName = patientName?.family; - result.unidentifiedPatient = - patientName.given[0] === 'UNKNOWN' && patientName.family === 'unknown' ? true : undefined; - result.addNameInLocalLanguage = !!additionalPatientName ? true : undefined; result.additionalGivenName = additionalPatientName?.given[0]; result.additionalMiddleName = additionalPatientName?.given[1]; From 88a04dc985f52c9089af18ce8830dcce137768f8 Mon Sep 17 00:00:00 2001 From: Ayush <54752747+ayush-AI@users.noreply.github.com> Date: Wed, 12 Jul 2023 19:55:16 +0530 Subject: [PATCH 4/6] (test) O3-2225/6: Add tests for cancel-patient-edit.component and delete-identifier-confirmation-modal (#750) --- .../src/widgets/cancel-patient-edit.test.tsx | 24 ++++++++++++++ ...ete-identifier-confirmation-modal.test.tsx | 31 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 packages/esm-patient-registration-app/src/widgets/cancel-patient-edit.test.tsx create mode 100644 packages/esm-patient-registration-app/src/widgets/delete-identifier-confirmation-modal.test.tsx diff --git a/packages/esm-patient-registration-app/src/widgets/cancel-patient-edit.test.tsx b/packages/esm-patient-registration-app/src/widgets/cancel-patient-edit.test.tsx new file mode 100644 index 000000000..68c22971a --- /dev/null +++ b/packages/esm-patient-registration-app/src/widgets/cancel-patient-edit.test.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { screen, render, fireEvent } from '@testing-library/react'; +import CancelPatientEdit from './cancel-patient-edit.component'; + +describe('CancelPatientEdit component', () => { + const mockClose = jest.fn(); + const mockOnConfirm = jest.fn(); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('renders the modal and triggers close and onConfirm functions', () => { + render(); + + const cancelButton = screen.getByRole('button', { name: /Cancel/i }); + fireEvent.click(cancelButton); + expect(mockClose).toHaveBeenCalledTimes(1); + + const discardButton = screen.getByRole('button', { name: /discard/i }); + fireEvent.click(discardButton); + expect(mockOnConfirm).toHaveBeenCalledTimes(1); + }); +}); diff --git a/packages/esm-patient-registration-app/src/widgets/delete-identifier-confirmation-modal.test.tsx b/packages/esm-patient-registration-app/src/widgets/delete-identifier-confirmation-modal.test.tsx new file mode 100644 index 000000000..0c9876dbc --- /dev/null +++ b/packages/esm-patient-registration-app/src/widgets/delete-identifier-confirmation-modal.test.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, fireEvent, screen } from '@testing-library/react'; +import DeleteIdentifierConfirmationModal from './delete-identifier-confirmation-modal'; + +describe('DeleteIdentifierConfirmationModal component', () => { + const mockDeleteIdentifier = jest.fn(); + const mockIdentifierName = 'Identifier Name'; + const mockIdentifierValue = 'Identifier Value'; + + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('renders the modal and triggers deleteIdentifier function', () => { + render( + , + ); + + const cancelButton = screen.getByRole('button', { name: /cancel/i }); + fireEvent.click(cancelButton); + expect(mockDeleteIdentifier).toHaveBeenCalledWith(false); + + const removeButton = screen.getByRole('button', { name: /remove identifier/i }); + fireEvent.click(removeButton); + expect(mockDeleteIdentifier).toHaveBeenCalledWith(true); + }); +}); From 49d5f6902a251abc6a8558e725eede42b4d0dda7 Mon Sep 17 00:00:00 2001 From: Ayush <54752747+ayush-AI@users.noreply.github.com> Date: Thu, 13 Jul 2023 19:05:58 +0530 Subject: [PATCH 5/6] (test) O3-2229: Add unit tests for utils.ts file (#747) * added test for utils.ts * resolved review commits * (feat) Remove filtering todays queue entries on frontend (#752) * (refactor): Display all active visits by removing filter for showing only today's active visits (#755) * (refactor): changed activeVisits.idNumber assignment for improved code robustness (#756) * (feat) O3-2100: Unknown patient name and estimated DOB config (#697) Co-authored-by: Vineet Sharma * (test) O3-2225/6: Add tests for cancel-patient-edit.component and delete-identifier-confirmation-modal (#750) * removed the extra types --------- Co-authored-by: Anjula Shanaka Co-authored-by: Dennis Kigen Co-authored-by: CynthiaKamau Co-authored-by: Donald Kibet Co-authored-by: Jexsie Co-authored-by: Vineet Sharma --- .../custom-input/identifier/utils.test.ts | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 packages/esm-patient-registration-app/src/patient-registration/input/custom-input/identifier/utils.test.ts diff --git a/packages/esm-patient-registration-app/src/patient-registration/input/custom-input/identifier/utils.test.ts b/packages/esm-patient-registration-app/src/patient-registration/input/custom-input/identifier/utils.test.ts new file mode 100644 index 000000000..5f3bd0c02 --- /dev/null +++ b/packages/esm-patient-registration-app/src/patient-registration/input/custom-input/identifier/utils.test.ts @@ -0,0 +1,81 @@ +import { isUniqueIdentifierTypeForOffline, shouldBlockPatientIdentifierInOfflineMode } from './utils'; + +interface IdentifierTypeOptions { + uniquenessBehavior?: 'UNIQUE' | 'LOCATION' | 'NON_UNIQUE'; + manualEntryEnabled?: boolean; + automaticGenerationEnabled?: boolean; +} + +function createIdentifierType(options: IdentifierTypeOptions) { + return { + uniquenessBehavior: options.uniquenessBehavior, + identifierSources: [ + { + uuid: 'identifier-source-uuid', + name: 'Identifier Source Name', + autoGenerationOption: { + manualEntryEnabled: options.manualEntryEnabled, + automaticGenerationEnabled: options.automaticGenerationEnabled, + }, + }, + ], + name: 'Identifier Type Name', + required: true, + uuid: 'identifier-type-uuid', + fieldName: 'identifierFieldName', + format: 'identifierFormat', + isPrimary: true, + }; +} + +describe('shouldBlockPatientIdentifierInOfflineMode function', () => { + it('should return false if identifierType is not unique', () => { + const identifierType = createIdentifierType({ uniquenessBehavior: null }); + + const result = shouldBlockPatientIdentifierInOfflineMode(identifierType); + + expect(result).toBe(false); + }); + + it('should return false if identifierType is unique and no manual entry is enabled', () => { + const identifierType = createIdentifierType({ uniquenessBehavior: null }); + + const result = shouldBlockPatientIdentifierInOfflineMode(identifierType); + + expect(result).toBe(false); + }); + + it('should return true if identifierType is unique and manual entry is enabled', () => { + const identifierType = createIdentifierType({ manualEntryEnabled: true, uniquenessBehavior: 'UNIQUE' }); + + const result = shouldBlockPatientIdentifierInOfflineMode(identifierType); + + expect(result).toBe(true); + }); +}); + +describe('isUniqueIdentifierTypeForOffline function', () => { + it('should return true if uniquenessBehavior is UNIQUE', () => { + const identifierType = createIdentifierType({ uniquenessBehavior: 'UNIQUE' }); + + const result = isUniqueIdentifierTypeForOffline(identifierType); + + expect(result).toBe(true); + }); + + it('should return true if uniquenessBehavior is LOCATION', () => { + const identifierType = createIdentifierType({ uniquenessBehavior: 'LOCATION' }); + + const result = isUniqueIdentifierTypeForOffline(identifierType); + + expect(result).toBe(true); + }); + + it('should return false for other uniqueness behaviors', () => { + const identifierType = createIdentifierType({ uniquenessBehavior: null }); + + const result = isUniqueIdentifierTypeForOffline(identifierType); + + expect(result).toBe(false); + }); +}); From 2234a566ef6ae492e872a5e0a063f03e349d68ff Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Tue, 18 Jul 2023 22:29:15 +0300 Subject: [PATCH 6/6] (chore) Release `v5.0.0` (#759) --- lerna.json | 2 +- packages/esm-active-visits-app/package.json | 2 +- packages/esm-appointments-app/package.json | 2 +- packages/esm-outpatient-app/package.json | 2 +- packages/esm-patient-list-app/package.json | 2 +- packages/esm-patient-registration-app/package.json | 2 +- packages/esm-patient-search-app/package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lerna.json b/lerna.json index 29b8f3da4..28d427afa 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "4.5.0", + "version": "5.0.0", "command": { "publish": { "verifyAccess": false diff --git a/packages/esm-active-visits-app/package.json b/packages/esm-active-visits-app/package.json index 9e8b064ea..6503b858f 100644 --- a/packages/esm-active-visits-app/package.json +++ b/packages/esm-active-visits-app/package.json @@ -1,6 +1,6 @@ { "name": "@openmrs/esm-active-visits-app", - "version": "4.5.0", + "version": "5.0.0", "description": "Active visits widget microfrontend for the OpenMRS SPA", "browser": "dist/openmrs-esm-active-visits-app.js", "main": "src/index.ts", diff --git a/packages/esm-appointments-app/package.json b/packages/esm-appointments-app/package.json index e3947e01b..fbd9f6a91 100644 --- a/packages/esm-appointments-app/package.json +++ b/packages/esm-appointments-app/package.json @@ -1,6 +1,6 @@ { "name": "@openmrs/esm-appointments-app", - "version": "4.5.0", + "version": "5.0.0", "description": "Appointments front-end module for the OpenMRS SPA", "browser": "dist/openmrs-esm-appointments-app.js", "main": "src/index.ts", diff --git a/packages/esm-outpatient-app/package.json b/packages/esm-outpatient-app/package.json index 327e11d11..52072f920 100644 --- a/packages/esm-outpatient-app/package.json +++ b/packages/esm-outpatient-app/package.json @@ -1,6 +1,6 @@ { "name": "@openmrs/esm-outpatient-app", - "version": "4.5.0", + "version": "5.0.0", "description": "Outpatient front-end module for the OpenMRS SPA", "browser": "dist/openmrs-esm-outpatient-app.js", "main": "src/index.ts", diff --git a/packages/esm-patient-list-app/package.json b/packages/esm-patient-list-app/package.json index 51a3cb653..7efc7a439 100644 --- a/packages/esm-patient-list-app/package.json +++ b/packages/esm-patient-list-app/package.json @@ -1,6 +1,6 @@ { "name": "@openmrs/esm-patient-list-app", - "version": "4.5.0", + "version": "5.0.0", "description": "Patient list microfrontend for the OpenMRS SPA", "browser": "dist/openmrs-esm-patient-list-app.js", "main": "src/index.ts", diff --git a/packages/esm-patient-registration-app/package.json b/packages/esm-patient-registration-app/package.json index 0d0f141dc..b325e0782 100644 --- a/packages/esm-patient-registration-app/package.json +++ b/packages/esm-patient-registration-app/package.json @@ -1,6 +1,6 @@ { "name": "@openmrs/esm-patient-registration-app", - "version": "4.5.0", + "version": "5.0.0", "description": "Patient registration microfrontend for the OpenMRS SPA", "browser": "dist/openmrs-esm-patient-registration-app.js", "main": "src/index.ts", diff --git a/packages/esm-patient-search-app/package.json b/packages/esm-patient-search-app/package.json index 2236130d4..1a47eddd2 100644 --- a/packages/esm-patient-search-app/package.json +++ b/packages/esm-patient-search-app/package.json @@ -1,6 +1,6 @@ { "name": "@openmrs/esm-patient-search-app", - "version": "4.5.0", + "version": "5.0.0", "description": "Patient search microfrontend for the OpenMRS SPA", "browser": "dist/openmrs-esm-patient-search-app.js", "main": "src/index.ts",