From e9b6a125e7e92b6a16697a7bcae169889a1c4e46 Mon Sep 17 00:00:00 2001 From: Ayush Date: Thu, 20 Jul 2023 00:20:49 +0530 Subject: [PATCH] merge main into id-field --- 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 +- .../esm-patient-registration-app/package.json | 2 +- .../custom-input/identifier/utils.test.ts | 81 +++++++++++++++++++ packages/esm-patient-search-app/package.json | 2 +- 8 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 packages/esm-patient-registration-app/src/patient-registration/input/custom-input/identifier/utils.test.ts diff --git a/lerna.json b/lerna.json index 29b8f3da4d..28d427afa4 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 9e8b064eae..6503b858f9 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 e3947e01bc..fbd9f6a911 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 327e11d113..52072f9207 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 51a3cb6536..7efc7a4397 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 0d0f141dcf..b325e0782d 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-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 0000000000..5f3bd0c029 --- /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); + }); +}); diff --git a/packages/esm-patient-search-app/package.json b/packages/esm-patient-search-app/package.json index 2236130d4f..1a47eddd2a 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",