Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-management into id-field
  • Loading branch information
ayush-AI committed Jul 19, 2023
2 parents a422034 + 2234a56 commit c7cf1f9
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "4.5.0",
"version": "5.0.0",
"command": {
"publish": {
"verifyAccess": false
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
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-appointments-app/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-outpatient-app/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-list-app/package.json
Original file line number Diff line number Diff line change
@@ -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",
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
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
});
2 changes: 1 addition & 1 deletion packages/esm-patient-search-app/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit c7cf1f9

Please sign in to comment.