Skip to content

Commit

Permalink
Add feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
reagan-meant committed Oct 14, 2024
1 parent b892d1b commit 03e3a4d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
3 changes: 3 additions & 0 deletions packages/esm-patient-search-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getSyncLifecycle,
makeUrl,
messageOmrsServiceWorker,
registerFeatureFlag,
setupDynamicOfflineDataHandler,
} from '@openmrs/esm-framework';
import { configSchema } from './config-schema';
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,6 +81,7 @@ export const ErrorState: React.FC<CommonProps> = ({ inTabletOrOverlay }) => {

export const SearchResultsEmptyState: React.FC<CommonProps> = ({ inTabletOrOverlay, searchMode, searchTerm }) => {
const { t } = useTranslation();
const isMPIEnabled = useFeatureFlag('mpiFlag');
return (
<Layer>
<Tile
Expand All @@ -91,28 +92,36 @@ export const SearchResultsEmptyState: React.FC<CommonProps> = ({ inTabletOrOverl
<p className={styles.emptyResultText}>
{t('noPatientChartsFoundMessage', 'Sorry, no patient charts were found')}
</p>
<div className={styles.dividerWrapper}>
<div className={styles.divider}></div>
</div>
{searchMode == 'internal' && (
{isMPIEnabled ? (
<>
<div className={styles.emptyResultsMarginRules}>
<p>
{t(
'trySearchFromClientRegistry',
"Try searching using the patient's unique ID number or search the external registry",
)}
</p>
<div className={styles.dividerWrapper}>
<div className={styles.divider}></div>
</div>
<Button
kind="ghost"
renderIcon={'Search'}
onClick={(e) => {
doMPISearch(searchTerm);
}}>
{`${t('search', 'Search')} ${'External Registry'}`}
</Button>
{searchMode == 'internal' && (
<>
<div className={styles.emptyResultsMarginRules}>
<p>
{t(
'trySearchFromClientRegistry',
"Try searching using the patient's unique ID number or search the external registry",
)}
</p>
</div>
<Button
kind="ghost"
renderIcon={'Search'}
onClick={(e) => {
doMPISearch(searchTerm);
}}>
{`${t('search', 'Search')} ${'External Registry'}`}
</Button>
</>
)}
</>
) : (
<p className={styles.actionText}>
<span>{t('trySearchWithPatientUniqueID', "Try to search again using the patient's unique ID number")}</span>
</p>
)}
</Tile>
</Layer>
Expand Down

0 comments on commit 03e3a4d

Please sign in to comment.