Skip to content

Commit

Permalink
fix/O3-3515: Add user & timestamp to the Printed patient identifier s…
Browse files Browse the repository at this point in the history
…ticker
  • Loading branch information
jwnasambu committed Oct 15, 2024
1 parent d1833f1 commit 994ae22
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import Barcode from 'react-barcode';
import { useTranslation } from 'react-i18next';
import { useReactToPrint } from 'react-to-print';
import { Button, InlineLoading, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
import { getPatientName, showSnackbar, useConfig, getCoreTranslation } from '@openmrs/esm-framework';
import {
getPatientName,
showSnackbar,
useConfig,
getCoreTranslation,
formatDate,
useSession,
} from '@openmrs/esm-framework';
import { type ConfigObject } from '../config-schema';
import { defaultBarcodeParams, getPatientField } from './print-identifier-sticker.resource';
import styles from './print-identifier-sticker.scss';
Expand All @@ -25,6 +32,7 @@ const PrintIdentifierSticker: React.FC<PrintIdentifierStickerProps> = ({ closeMo
const onBeforeGetContentResolve = useRef<() => void | null>(null);
const [isPrinting, setIsPrinting] = useState(false);
const headerTitle = t('patientIdentifierSticker', 'Patient identifier sticker');
const session = useSession();

useEffect(() => {
if (isPrinting && onBeforeGetContentResolve.current) {
Expand Down Expand Up @@ -83,11 +91,17 @@ const PrintIdentifierSticker: React.FC<PrintIdentifierStickerProps> = ({ closeMo
<div ref={contentToPrintRef}>
<style type="text/css" media="print">
{`
@page {
size: ${pageSize};
}
`}
@page {
size: ${pageSize};
}
`}
</style>
<div className={styles.printedBy}>
<span>
{t('printedBy', 'Printed by')} {session?.user?.display || t('unknownUser', 'Unknown user')}{' '}
{t('onDate', 'on')} {formatDate(new Date(), { noToday: true })}
</span>
</div>
<PrintComponent patient={patient} />
</div>
</ModalBody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use '@carbon/colors';
@use '@carbon/layout';
@use '@carbon/type';
@use '@openmrs/esm-styleguide/src/_vars' as *;
Expand All @@ -6,6 +7,12 @@
padding: layout.$spacing-03 layout.$spacing-05;
}

.printedBy {
display: none;
background-color: colors.$white;
padding: 15px;
}

.documentHeader {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -80,4 +87,10 @@
padding: 0 !important;
overflow: hidden;
}

.printedBy {
@include type.type-style('body-compact-01');
display: flex;
gap: 10px;
}
}
5 changes: 4 additions & 1 deletion packages/esm-patient-banner-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
"countyDistrict": "District",
"district": "District",
"implementationLogo": "Implementation logo",
"onDate": "On date",
"patientAge": "Age:",
"patientDateOfBirthWithSeparator": "Date of birth:",
"patientGenderWithSeparator": "Gender:",
"patientIdentifierSticker": "Patient identifier sticker",
"patientNameWithSeparator": "Patient name:",
"postalCode": "Postal code",
"printedBy": "Printed by",
"printIdentifierSticker": "Print identifier sticker",
"state": "State",
"stateProvince": "State",
"telephoneNumberWithSeparator": "Telephone number:"
"telephoneNumberWithSeparator": "Telephone number:",
"unknownUser": "Unknown user"
}

0 comments on commit 994ae22

Please sign in to comment.