diff --git a/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-content.component.tsx b/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-content.component.tsx index 5aa7bca214..c6913b3a81 100644 --- a/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-content.component.tsx +++ b/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-content.component.tsx @@ -19,6 +19,10 @@ const PrintIdentifierStickerContent: React.FC { const { printIdentifierStickerWidth, printIdentifierStickerHeight, printIdentifierStickerPaperSize } = useConfig(); + + if (numberOfLabelColumns < 1 || numberOfLabelRowsPerPage < 1 || labels.length < 1) { + return; + } const maxLabelsPerPage = numberOfLabelRowsPerPage * numberOfLabelColumns; const pages = []; diff --git a/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-modal.test.tsx b/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-modal.test.tsx index 9092801ae8..83f2cd61e2 100644 --- a/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-modal.test.tsx +++ b/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker-modal.test.tsx @@ -30,9 +30,9 @@ describe('PrintIdentifierSticker', () => { render(); expect(screen.getByText(/Print Identifier Sticker/i)).toBeInTheDocument(); - expect(screen.getByText('John Wilson')).toBeInTheDocument(); - expect(screen.getByText('100GEJ')).toBeInTheDocument(); - expect(screen.getByText('1972-04-04')).toBeInTheDocument(); + expect(screen.getAllByText(/John Wilson/i)[0]).toBeInTheDocument(); + expect(screen.getAllByText(/100GEJ/i)[0]).toBeInTheDocument(); + expect(screen.getAllByText(/1972-04-04/i)[0]).toBeInTheDocument(); }); test('calls closeModal when cancel button is clicked', async () => { diff --git a/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker.modal.tsx b/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker.modal.tsx index 49c6155dbd..7a9e9dd16b 100644 --- a/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker.modal.tsx +++ b/packages/esm-patient-banner-app/src/banner-tags/print-identifier-sticker.modal.tsx @@ -20,17 +20,14 @@ const PrintIdentifierStickerModal: React.FC = useConfig(); const contentToPrintRef = useRef(null); const onBeforeGetContentResolve = useRef<() => void | null>(null); + const [numberOfLabelColumns, setNumberOfLabelColumns] = useState(numberOfPatientIdStickerColumns); + const [numberOfLabelRowsPerPage, setNumberOfLabelRowsPerPage] = useState(numberOfPatientIdStickerRowsPerPage); + const [numberOfLabels, setNumberOfLabels] = useState(numberOfPatientIdStickers); const [isPrinting, setIsPrinting] = useState(false); const headerTitle = t('patientIdentifierSticker', 'Patient identifier sticker'); const [isPreviewVisible, setIsPreviewVisible] = useState(false); - const labels = Array.from({ length: numberOfPatientIdStickers }); - const maxLabelsPerPage = numberOfPatientIdStickerRowsPerPage * numberOfPatientIdStickerColumns; - const pages = []; - - for (let i = 0; i < labels.length; i += maxLabelsPerPage) { - pages.push(labels.slice(i, i + maxLabelsPerPage)); - } + const labels = Array.from({ length: numberOfLabels }); useEffect(() => { if (isPrinting && onBeforeGetContentResolve.current) { @@ -85,6 +82,30 @@ const PrintIdentifierStickerModal: React.FC = title={getCoreTranslation('printIdentifierSticker', 'Print identifier sticker')} /> + setNumberOfLabelColumns(parseInt(event.target.value || 1))} + value={numberOfLabelColumns} + hideSteppers={true} + /> + setNumberOfLabelRowsPerPage(parseInt(event.target.value || 1))} + value={numberOfLabelRowsPerPage} + hideSteppers={true} + /> + setNumberOfLabels(parseInt(event.target.value || 1))} + value={numberOfLabels} + hideSteppers={true} + />
@@ -109,8 +130,8 @@ const PrintIdentifierStickerModal: React.FC =
diff --git a/packages/esm-patient-banner-app/translations/en.json b/packages/esm-patient-banner-app/translations/en.json index f5efa1b460..0b6e5127ac 100644 --- a/packages/esm-patient-banner-app/translations/en.json +++ b/packages/esm-patient-banner-app/translations/en.json @@ -8,6 +8,9 @@ "district": "District", "dob": "DOB", "hidePreview": "Hide Preview", + "numberOfLabelColumns": "Number of patient Id sticker columns", + "numberOfLabelRowsPerPage": "Number of patient Id sticker rows per page", + "numberOfLabels": "Number of patient Id stickers", "patientIdentifierSticker": "Patient identifier sticker", "postalCode": "Postal code", "preview": "Preview",