Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-3552: Add feature flag for printing patient identifier stickers #1893

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions packages/esm-patient-banner-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ export const configSchema = {
'Specifies the paper size for printing the sticker. You can define the size using units (e.g., mm, in) or named sizes (e.g., "148mm 210mm", "A1", "A2", "A4", "A5").',
_default: '4in 6in',
},
showPrintIdentifierStickerButton: {
_type: Type.Boolean,
_description: "Whether to display the 'Print identifier sticker' button in the patient banner",
_default: false,
},
useRelationshipNameLink: {
_type: Type.Boolean,
_description: "Whether to use the relationship name as a link to the associated person's patient chart.",
Expand All @@ -51,6 +46,5 @@ export interface ConfigObject {
};
printIdentifierStickerFields: Array<string>;
printIdentifierStickerSize: string;
showPrintIdentifierStickerButton: boolean;
useRelationshipNameLink: boolean;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { OverflowMenuItem } from '@carbon/react';
import { showModal, useConfig, usePatient } from '@openmrs/esm-framework';
import { showModal, useFeatureFlag, usePatient } from '@openmrs/esm-framework';
import styles from './action-button.scss';

interface PrintIdentifierStickerOverflowMenuItemProps {
Expand All @@ -13,9 +13,7 @@ const PrintIdentifierStickerOverflowMenuItem: React.FC<PrintIdentifierStickerOve
}) => {
const { t } = useTranslation();
const { patient } = usePatient(patientUuid);
const { showPrintIdentifierStickerButton } = useConfig<{ showPrintIdentifierStickerButton: boolean }>({
externalModuleName: '@openmrs/esm-patient-banner-app',
});
const canPrintPatientIdentifierSticker = useFeatureFlag('print-patient-identifier-sticker');

const handleLaunchModal = useCallback(() => {
const dispose = showModal('print-identifier-sticker-modal', {
Expand All @@ -24,15 +22,16 @@ const PrintIdentifierStickerOverflowMenuItem: React.FC<PrintIdentifierStickerOve
});
}, [patient]);

if (!patient || !canPrintPatientIdentifierSticker) {
return null;
}

return (
patient &&
Boolean(showPrintIdentifierStickerButton) && (
<OverflowMenuItem
className={styles.menuitem}
itemText={t('printIdentifierSticker', 'Print identifier sticker')}
onClick={handleLaunchModal}
/>
)
<OverflowMenuItem
className={styles.menuitem}
itemText={t('printIdentifierSticker', 'Print identifier sticker')}
onClick={handleLaunchModal}
/>
);
};

Expand Down
5 changes: 5 additions & 0 deletions packages/esm-patient-chart-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export function startupApp() {
'Retrospective Data Entry',
"Features to enter data for past visits. Includes the 'Edit Past Visit' button in the start visit dialog, and the 'Add Past Visit' button in the patient header.",
);
registerFeatureFlag(
'print-patient-identifier-sticker',
'Print patient identifier sticker',
'Features to support printing a patient identifier sticker',
);
}

export const root = getSyncLifecycle(patientChartPageComponent, { featureName: 'patient-chart', moduleName });
Expand Down
Loading