Skip to content

Commit 23ee944

Browse files
authored
Merge branch 'openmrs:main' into O3-3975
2 parents d87eb81 + 00b2cb2 commit 23ee944

36 files changed

+993
-89
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@
4444
"dependencies": {
4545
"@carbon/react": "^1.33.1",
4646
"@hookform/resolvers": "^3.3.0",
47-
"@playwright/test": "^1.48.0",
47+
"@playwright/test": "^1.49.0",
4848
"dotenv": "^16.4.5",
4949
"file-saver": "^2.0.5",
5050
"lodash-es": "^4.17.21",
5151
"react-hook-form": "^7.45.4",
5252
"react-image-annotate": "^1.8.0",
53+
"react-to-print": "^2.14.13",
5354
"yup": "^1.2.0",
5455
"zod": "^3.22.2"
5556
},

src/config-schema.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ export const configSchema = {
55
_default: false,
66
_description: 'Whether to print item costs on the print out',
77
},
8+
enablePrintButton: {
9+
_type: Type.Boolean,
10+
_default: true,
11+
_description: 'Enable or disable the print button in the stock management UI',
12+
},
13+
autoPopulateResponsiblePerson: {
14+
type: Type.Boolean,
15+
_default: false,
16+
_description: 'Auto populate responsible person in stock operations with the currently logged in user',
17+
},
818
printBalanceOnHand: {
919
type: Type.Boolean,
1020
_default: false,
@@ -55,6 +65,8 @@ export const configSchema = {
5565
};
5666

5767
export type ConfigObject = {
68+
autoPopulateResponsiblePerson: boolean;
69+
enablePrintButton: boolean;
5870
printItemCost: boolean;
5971
printBalanceOnHand: boolean;
6072
packagingUnitsUUID: string;

src/core/api/types/stockItem/StockItemTransaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ export interface StockItemTransactionDTO {
2020
packagingUomName: string;
2121
operationSourcePartyName: string;
2222
operationDestinationPartyName: string;
23+
patientId: number;
24+
patientUuid: string;
2325
}

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import StockSources from './stock-sources/stock-sources.component';
2020
import StockLocations from './stock-locations/stock-locations.component';
2121
import StockReports from './stock-reports/report-list/stock-reports.component';
2222
import StockSettings from './stock-settings/stock-settings.component';
23+
import TransactionsBincardPrintPreview from './stock-items/add-stock-item/transactions/printout/transactions-print-bincard-preview.modal';
24+
import TransactionsStockcardPrintPreview from './stock-items/add-stock-item/transactions/printout/transactions-print-stockcard-preview.modal';
25+
2326
const moduleName = '@openmrs/esm-stock-management-app';
2427

2528
const options = {
@@ -127,6 +130,9 @@ export const deletePackagingUnitButton = getSyncLifecycle(deletePackagingUnitMod
127130

128131
export const stockManagementAppMenuItem = getSyncLifecycle(appMenu, options);
129132

133+
export const transactionBincardPrintPreviewModal = getSyncLifecycle(TransactionsBincardPrintPreview, options);
134+
export const transactionStockcardPrintPreviewModal = getSyncLifecycle(TransactionsStockcardPrintPreview, options);
135+
130136
export function startupApp() {
131137
defineConfigSchema(moduleName, configSchema);
132138
}

src/routes.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@
198198
{
199199
"name": "stock-operation-dialog",
200200
"component": "stockOperationModal"
201+
},
202+
{
203+
"name": "transactions-print-bincard-preview-modal",
204+
"component": "transactionBincardPrintPreviewModal"
205+
},
206+
{
207+
"name": "transactions-print-stockcard-preview-modal",
208+
"component": "transactionStockcardPrintPreviewModal"
201209
}
202210
],
203211
"pages": [
@@ -206,4 +214,4 @@
206214
"route": "stock-management"
207215
}
208216
]
209-
}
217+
}

src/stock-home/stock-home-inventory-card.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ const StockHomeInventoryCard = () => {
5252
<div className={styles.cardText}>
5353
<p>EXPIRING STOCK</p>
5454
<p>
55-
<strong>{item?.drugName}</strong> {item?.dispensingUnitName}
55+
<strong>{item?.drugName}</strong> Batch No: {item?.batchNo} Quantity: {item?.quantity}{' '}
56+
{item?.dispensingUnitName}
5657
</p>
5758
</div>
5859
</div>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from 'react';
2+
import styles from './printable-transaction-header.scss';
3+
import { useConfig } from '@openmrs/esm-framework';
4+
import { useTranslation } from 'react-i18next';
5+
import startCase from 'lodash-es/startCase';
6+
7+
interface PrintableTransactionHeaderProps {
8+
itemName: string;
9+
}
10+
11+
const PrintableBincardTransactionHeader: React.FC<PrintableTransactionHeaderProps> = ({ itemName }) => {
12+
const { t } = useTranslation();
13+
const { logo } = useConfig({ externalModuleName: '@kenyaemr/esm-login-app' });
14+
15+
return (
16+
<div className={styles.container}>
17+
<div className={styles.printableHeader}>
18+
<p className={styles.heading}>{t('bincard', 'Bin Card')}</p>
19+
{logo?.src ? (
20+
<img className={styles.img} height={60} width={250} src={logo.src} alt={logo.alt} />
21+
) : logo?.name ? (
22+
logo.name
23+
) : (
24+
// OpenMRS Logo
25+
<svg
26+
className={styles.img}
27+
role="img"
28+
width={110}
29+
height={40}
30+
viewBox="0 0 380 119"
31+
xmlns="http://www.w3.org/2000/svg"
32+
>
33+
<path
34+
fillRule="evenodd"
35+
clipRule="evenodd"
36+
d="M40.29 40.328a27.755 27.755 0 0 1 19.688-8.154c7.669 0 14.613 3.102 19.647 8.116l.02-18.54A42.835 42.835 0 0 0 59.978 17c-7.089 0-13.813 1.93-19.709 4.968l.021 18.36ZM79.645 79.671a27.744 27.744 0 0 1-19.684 8.154c-7.67 0-14.614-3.101-19.651-8.116l-.02 18.54A42.857 42.857 0 0 0 59.96 103a42.833 42.833 0 0 0 19.672-4.751l.013-18.578ZM40.328 79.696c-5.038-5.037-8.154-11.995-8.154-19.685 0-7.669 3.102-14.612 8.116-19.65l-18.54-.02A42.85 42.85 0 0 0 17 60.012a42.819 42.819 0 0 0 4.752 19.672l18.576.013ZM79.634 40.289a27.753 27.753 0 0 1 8.154 19.688 27.744 27.744 0 0 1-8.117 19.646l18.542.02a42.842 42.842 0 0 0 4.749-19.666c0-7.09-1.714-13.779-4.751-19.675l-18.577-.013ZM156.184 60.002c0-8.748-6.118-15.776-15.025-15.776-8.909 0-15.025 7.028-15.025 15.776 0 8.749 6.116 15.78 15.025 15.78 8.907 0 15.025-7.031 15.025-15.78Zm-34.881 0c0-11.482 8.318-19.958 19.856-19.958 11.536 0 19.855 8.477 19.855 19.959 0 11.484-8.319 19.964-19.855 19.964-11.538 0-19.856-8.48-19.856-19.965ZM179.514 75.54c5.507 0 9.05-4.14 9.05-9.482 0-5.341-3.543-9.483-9.05-9.483-5.505 0-9.046 4.142-9.046 9.483 0 5.342 3.541 9.482 9.046 9.482ZM166.22 53.306h4.248v3.704h.11c2.344-2.725 5.449-4.36 9.154-4.36 8.014 0 13.408 5.67 13.408 13.408 0 7.63-5.613 13.406-12.752 13.406-4.58 0-8.231-2.29-9.81-5.178h-.11V90.87h-4.248V53.306ZM217.773 63.768c-.163-4.305-3-7.193-7.686-7.193-4.685 0-7.79 2.888-8.335 7.193h16.021Zm3.653 10.412c-3.001 3.868-6.596 5.284-11.339 5.284-8.01 0-12.914-5.993-12.914-13.406 0-7.901 5.559-13.407 13.08-13.407 7.196 0 12.096 4.906 12.096 13.354v1.362h-20.597c.325 4.413 3.704 8.173 8.335 8.173 3.65 0 6.105-1.307 8.12-3.868l3.219 2.508ZM227.854 59.356c0-2.346-.216-4.36-.216-6.05h4.031c0 1.363.11 2.777.11 4.195h.11c1.144-2.505 4.306-4.85 8.5-4.85 6.705 0 9.699 4.252 9.699 10.41v15.748h-4.248v-15.31c0-4.253-1.856-6.924-5.833-6.924-5.503 0-7.903 3.979-7.903 9.811V78.81h-4.25V59.356ZM259.211 41.008h6.708L278.8 70.791h.107l12.982-29.782h6.549v37.99h-4.506V47.124h-.106L280.192 79h-2.738l-13.629-31.875h-.107V79h-4.507V41.01ZM312.392 57.752h4.023c4.992 0 11.487 0 11.487-6.282 0-5.47-4.776-6.276-9.177-6.276h-6.333v12.558Zm-4.506-16.744h9.711c7.352 0 15.132 1.072 15.132 10.462 0 5.527-3.594 9.125-9.495 10.037L334.018 79h-5.525l-10.304-17.063h-5.797V79h-4.506V41.01ZM358.123 47.712c-1.506-2.413-4.187-3.486-6.926-3.486-3.973 0-8.1 1.88-8.1 6.385 0 3.49 1.931 5.047 7.994 6.98 5.903 1.878 11.377 3.809 11.377 11.267 0 7.567-6.495 11.11-13.36 11.11-4.402 0-9.125-1.45-11.7-5.262l3.862-3.165c1.61 2.794 4.83 4.24 8.105 4.24 3.862 0 8.263-2.253 8.263-6.601 0-4.669-3.165-5.474-9.928-7.728-5.366-1.771-9.442-4.134-9.442-10.463 0-7.298 6.277-10.945 12.929-10.945 4.241 0 7.836 1.178 10.625 4.45l-3.699 3.218Z"
37+
/>
38+
</svg>
39+
)}
40+
</div>
41+
42+
<div className={styles.printableBody}>
43+
<div className={styles.transactionDetails}>
44+
<p className={styles.itemHeading}>{t('itemname', 'Item Name')}</p>
45+
<p className={styles.itemLabel}>{startCase(itemName)}</p>
46+
</div>
47+
</div>
48+
</div>
49+
);
50+
};
51+
52+
export default PrintableBincardTransactionHeader;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from 'react';
2+
import styles from './printable-transaction-header.scss';
3+
import { useConfig } from '@openmrs/esm-framework';
4+
import { useTranslation } from 'react-i18next';
5+
import startCase from 'lodash-es/startCase';
6+
7+
interface PrintableTransactionHeaderProps {
8+
itemName: string;
9+
}
10+
11+
const PrintableStockcardTransactionHeader: React.FC<PrintableTransactionHeaderProps> = ({ itemName }) => {
12+
const { t } = useTranslation();
13+
const { logo } = useConfig({ externalModuleName: '@kenyaemr/esm-login-app' });
14+
15+
return (
16+
<div className={styles.container}>
17+
<div className={styles.printableHeader}>
18+
<p className={styles.heading}>{t('bincard', 'Stock Card')}</p>
19+
{logo?.src ? (
20+
<img className={styles.img} height={60} width={250} src={logo.src} alt={logo.alt} />
21+
) : logo?.name ? (
22+
logo.name
23+
) : (
24+
// OpenMRS Logo
25+
<svg
26+
className={styles.img}
27+
role="img"
28+
width={110}
29+
height={40}
30+
viewBox="0 0 380 119"
31+
xmlns="http://www.w3.org/2000/svg"
32+
>
33+
<path
34+
fillRule="evenodd"
35+
clipRule="evenodd"
36+
d="M40.29 40.328a27.755 27.755 0 0 1 19.688-8.154c7.669 0 14.613 3.102 19.647 8.116l.02-18.54A42.835 42.835 0 0 0 59.978 17c-7.089 0-13.813 1.93-19.709 4.968l.021 18.36ZM79.645 79.671a27.744 27.744 0 0 1-19.684 8.154c-7.67 0-14.614-3.101-19.651-8.116l-.02 18.54A42.857 42.857 0 0 0 59.96 103a42.833 42.833 0 0 0 19.672-4.751l.013-18.578ZM40.328 79.696c-5.038-5.037-8.154-11.995-8.154-19.685 0-7.669 3.102-14.612 8.116-19.65l-18.54-.02A42.85 42.85 0 0 0 17 60.012a42.819 42.819 0 0 0 4.752 19.672l18.576.013ZM79.634 40.289a27.753 27.753 0 0 1 8.154 19.688 27.744 27.744 0 0 1-8.117 19.646l18.542.02a42.842 42.842 0 0 0 4.749-19.666c0-7.09-1.714-13.779-4.751-19.675l-18.577-.013ZM156.184 60.002c0-8.748-6.118-15.776-15.025-15.776-8.909 0-15.025 7.028-15.025 15.776 0 8.749 6.116 15.78 15.025 15.78 8.907 0 15.025-7.031 15.025-15.78Zm-34.881 0c0-11.482 8.318-19.958 19.856-19.958 11.536 0 19.855 8.477 19.855 19.959 0 11.484-8.319 19.964-19.855 19.964-11.538 0-19.856-8.48-19.856-19.965ZM179.514 75.54c5.507 0 9.05-4.14 9.05-9.482 0-5.341-3.543-9.483-9.05-9.483-5.505 0-9.046 4.142-9.046 9.483 0 5.342 3.541 9.482 9.046 9.482ZM166.22 53.306h4.248v3.704h.11c2.344-2.725 5.449-4.36 9.154-4.36 8.014 0 13.408 5.67 13.408 13.408 0 7.63-5.613 13.406-12.752 13.406-4.58 0-8.231-2.29-9.81-5.178h-.11V90.87h-4.248V53.306ZM217.773 63.768c-.163-4.305-3-7.193-7.686-7.193-4.685 0-7.79 2.888-8.335 7.193h16.021Zm3.653 10.412c-3.001 3.868-6.596 5.284-11.339 5.284-8.01 0-12.914-5.993-12.914-13.406 0-7.901 5.559-13.407 13.08-13.407 7.196 0 12.096 4.906 12.096 13.354v1.362h-20.597c.325 4.413 3.704 8.173 8.335 8.173 3.65 0 6.105-1.307 8.12-3.868l3.219 2.508ZM227.854 59.356c0-2.346-.216-4.36-.216-6.05h4.031c0 1.363.11 2.777.11 4.195h.11c1.144-2.505 4.306-4.85 8.5-4.85 6.705 0 9.699 4.252 9.699 10.41v15.748h-4.248v-15.31c0-4.253-1.856-6.924-5.833-6.924-5.503 0-7.903 3.979-7.903 9.811V78.81h-4.25V59.356ZM259.211 41.008h6.708L278.8 70.791h.107l12.982-29.782h6.549v37.99h-4.506V47.124h-.106L280.192 79h-2.738l-13.629-31.875h-.107V79h-4.507V41.01ZM312.392 57.752h4.023c4.992 0 11.487 0 11.487-6.282 0-5.47-4.776-6.276-9.177-6.276h-6.333v12.558Zm-4.506-16.744h9.711c7.352 0 15.132 1.072 15.132 10.462 0 5.527-3.594 9.125-9.495 10.037L334.018 79h-5.525l-10.304-17.063h-5.797V79h-4.506V41.01ZM358.123 47.712c-1.506-2.413-4.187-3.486-6.926-3.486-3.973 0-8.1 1.88-8.1 6.385 0 3.49 1.931 5.047 7.994 6.98 5.903 1.878 11.377 3.809 11.377 11.267 0 7.567-6.495 11.11-13.36 11.11-4.402 0-9.125-1.45-11.7-5.262l3.862-3.165c1.61 2.794 4.83 4.24 8.105 4.24 3.862 0 8.263-2.253 8.263-6.601 0-4.669-3.165-5.474-9.928-7.728-5.366-1.771-9.442-4.134-9.442-10.463 0-7.298 6.277-10.945 12.929-10.945 4.241 0 7.836 1.178 10.625 4.45l-3.699 3.218Z"
37+
/>
38+
</svg>
39+
)}
40+
</div>
41+
42+
<div className={styles.printableBody}>
43+
<div className={styles.transactionDetails}>
44+
<p className={styles.itemHeading}>{t('itemname', 'Item Name')}</p>
45+
<p className={styles.itemLabel}>{startCase(itemName)}</p>
46+
</div>
47+
</div>
48+
</div>
49+
);
50+
};
51+
52+
export default PrintableStockcardTransactionHeader;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
import styles from './printable-transaction-footer.scss';
3+
import { useTranslation } from 'react-i18next';
4+
import dayjs from 'dayjs';
5+
import { formatDate, useSession } from '@openmrs/esm-framework';
6+
7+
type PrintableFooterProps = {
8+
title: string;
9+
};
10+
11+
const PrintableTransactionFooter: React.FC<PrintableFooterProps> = ({ title }) => {
12+
const { t } = useTranslation();
13+
const session = useSession();
14+
15+
return (
16+
<div className={styles.container}>
17+
<p className={styles.itemFooter}>{title}</p>
18+
<p className={styles.footDescription}>
19+
{t(
20+
'generatedMessage',
21+
'The card has been electronically generated and is a valid document. It was created by {{userName}} on {{date}}',
22+
{
23+
userName: `${session?.user?.display}`,
24+
// date: dayjs().format('DD-MM-YYYY'),
25+
// time: dayjs().format('hh:mm A'),
26+
date: `${formatDate(new Date(), { mode: 'standard', noToday: true })}`,
27+
},
28+
)}
29+
</p>
30+
</div>
31+
);
32+
};
33+
34+
export default PrintableTransactionFooter;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@use '@carbon/colors';
2+
@use '@carbon/layout';
3+
@use '@carbon/type';
4+
5+
.container {
6+
display: flex;
7+
flex-direction: column;
8+
width: 100%;
9+
bottom: 0;
10+
padding: layout.$spacing-01;
11+
justify-content: center;
12+
}
13+
14+
.itemFooter {
15+
padding: layout.$spacing-01 layout.$spacing-05;
16+
@include type.type-style('body-compact-02');
17+
color: colors.$cool-gray-90;
18+
}
19+
20+
.footDescription {
21+
@include type.type-style('legal-01');
22+
padding: layout.$spacing-01 layout.$spacing-05;
23+
color: colors.$cool-gray-70;
24+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@use '@carbon/colors';
2+
@use '@carbon/layout';
3+
@use '@carbon/type';
4+
5+
.container {
6+
padding: 0 1rem 2rem;
7+
border-bottom: 1px solid #ebedf2;
8+
margin-bottom: 2rem;
9+
}
10+
11+
.printableBody {
12+
display: flex;
13+
flex-direction: row;
14+
justify-content: space-between;
15+
}
16+
17+
.printableHeader {
18+
display: flex;
19+
flex-direction: row;
20+
}
21+
22+
.img {
23+
display: flex;
24+
margin-left: auto;
25+
}
26+
27+
.transactionDetails {
28+
display: flex;
29+
width: 50%;
30+
flex-direction: column;
31+
}
32+
33+
.facilityDetails {
34+
display: flex;
35+
flex-flow: column wrap;
36+
text-align: right;
37+
}
38+
39+
.heading {
40+
font-size: 40px;
41+
text-transform: uppercase;
42+
margin-bottom: layout.$spacing-05;
43+
}
44+
45+
.facilityName {
46+
@include type.type-style('heading-compact-02');
47+
font-weight: bold;
48+
color: colors.$green-70;
49+
}
50+
51+
.itemHeading {
52+
@include type.type-style('body-compact-02');
53+
margin-bottom: 0.25rem;
54+
font-weight: bold;
55+
color: colors.$cool-gray-90;
56+
}
57+
58+
.itemLabel {
59+
@include type.type-style('body-compact-02');
60+
color: colors.$cool-gray-90;
61+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@use '@carbon/colors';
2+
@use '@carbon/layout';
3+
@use '@carbon/type';
4+
5+
.printableInvoiceContainer {
6+
display: flex;
7+
flex-direction: row;
8+
}
9+
10+
.container {
11+
margin-top: layout.$spacing-05;
12+
}
13+
14+
.itemsContainer {
15+
display: flex;
16+
flex-direction: column;
17+
width: 96%;
18+
padding: layout.$spacing-05;
19+
margin: layout.$spacing-05;
20+
font-size: 6px;
21+
}
22+
23+
.detailsContainer {
24+
margin: layout.$spacing-05 0;
25+
width: 20%;
26+
}
27+
28+
.tableContainer {
29+
margin-bottom: layout.$spacing-05;
30+
font-size: 6px;
31+
}
32+
33+
.totalContainer {
34+
display: flex;
35+
flex-direction: column;
36+
}
37+
38+
.item {
39+
margin: layout.$spacing-04;
40+
}
41+
42+
.itemHeading {
43+
@include type.type-style('label-02');
44+
font-style: bold;
45+
color: colors.$cool-gray-90;
46+
margin-bottom: layout.$spacing-01;
47+
}
48+
49+
.itemValue {
50+
@include type.type-style('legal-01');
51+
color: colors.$cool-gray-90;
52+
}
53+
54+
.itemTotal {
55+
border-bottom: solid 0.00125rem colors.$cool-gray-10;
56+
padding: layout.$spacing-02;
57+
}
58+
59+
.itemLabel {
60+
float: right;
61+
@include type.type-style('label-01');
62+
}
63+
64+
.tableBody {
65+
font-size: 8px;
66+
}
67+
68+
.printButton {
69+
padding: layout.$spacing-01;
70+
margin: layout.$spacing-01;
71+
}

0 commit comments

Comments
 (0)