From 03e3a4d83a842d7e9303e4c0b5354215328e0aa9 Mon Sep 17 00:00:00 2001 From: reagan-meant Date: Mon, 14 Oct 2024 12:33:03 +0300 Subject: [PATCH] Add feature flag --- packages/esm-patient-search-app/src/index.ts | 3 ++ .../patient-search-views.component.tsx | 49 +++++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/esm-patient-search-app/src/index.ts b/packages/esm-patient-search-app/src/index.ts index efeb91047..2b6733698 100644 --- a/packages/esm-patient-search-app/src/index.ts +++ b/packages/esm-patient-search-app/src/index.ts @@ -5,6 +5,7 @@ import { getSyncLifecycle, makeUrl, messageOmrsServiceWorker, + registerFeatureFlag, setupDynamicOfflineDataHandler, } from '@openmrs/esm-framework'; import { configSchema } from './config-schema'; @@ -35,6 +36,8 @@ export const patientSearchBar = getSyncLifecycle(patientSearchBarComponent, opti export function startupApp() { defineConfigSchema(moduleName, configSchema); + registerFeatureFlag('mpiFlag', 'MPI Service', 'Enables the Master Patient Index workflows'); + setupDynamicOfflineDataHandler({ id: 'esm-patient-search-app:patient', type: 'patient', diff --git a/packages/esm-patient-search-app/src/patient-search-page/patient-search-views.component.tsx b/packages/esm-patient-search-app/src/patient-search-page/patient-search-views.component.tsx index 32be4a324..3bd1199bd 100644 --- a/packages/esm-patient-search-app/src/patient-search-page/patient-search-views.component.tsx +++ b/packages/esm-patient-search-app/src/patient-search-page/patient-search-views.component.tsx @@ -7,7 +7,7 @@ import PatientBanner, { PatientBannerSkeleton } from './patient-banner/banner/pa import { type SearchedPatient } from '../types'; import styles from './patient-search-lg.scss'; import { Button } from '@carbon/react'; -import { navigate } from '@openmrs/esm-framework'; +import { navigate, useFeatureFlag } from '@openmrs/esm-framework'; interface CommonProps { inTabletOrOverlay: boolean; @@ -81,6 +81,7 @@ export const ErrorState: React.FC = ({ inTabletOrOverlay }) => { export const SearchResultsEmptyState: React.FC = ({ inTabletOrOverlay, searchMode, searchTerm }) => { const { t } = useTranslation(); + const isMPIEnabled = useFeatureFlag('mpiFlag'); return ( = ({ inTabletOrOverl

{t('noPatientChartsFoundMessage', 'Sorry, no patient charts were found')}

-
-
-
- {searchMode == 'internal' && ( + {isMPIEnabled ? ( <> -
-

- {t( - 'trySearchFromClientRegistry', - "Try searching using the patient's unique ID number or search the external registry", - )} -

+
+
- + {searchMode == 'internal' && ( + <> +
+

+ {t( + 'trySearchFromClientRegistry', + "Try searching using the patient's unique ID number or search the external registry", + )} +

+
+ + + )} + ) : ( +

+ {t('trySearchWithPatientUniqueID', "Try to search again using the patient's unique ID number")} +

)}