@kenyaemr/esm-billing-app 5.4.2-pre.2259 → 5.4.2-pre.2265

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +16 -16
  2. package/dist/300.js +1 -1
  3. package/dist/632.js +1 -0
  4. package/dist/632.js.map +1 -0
  5. package/dist/{46.js → 910.js} +3 -3
  6. package/dist/910.js.map +1 -0
  7. package/dist/kenyaemr-esm-billing-app.js +1 -1
  8. package/dist/kenyaemr-esm-billing-app.js.buildmanifest.json +712 -712
  9. package/dist/kenyaemr-esm-billing-app.js.map +1 -1
  10. package/dist/main.js +3 -3
  11. package/dist/main.js.map +1 -1
  12. package/dist/routes.json +1 -1
  13. package/package.json +1 -1
  14. package/src/{invoice/print-bill-receipt/print-bill-receipt.resource.ts → hooks/usePrintPreview.tsx} +2 -4
  15. package/src/index.ts +7 -2
  16. package/src/invoice/invoice.component.tsx +13 -34
  17. package/src/invoice/print-bill-receipt/receipt-print-button.component.tsx +5 -3
  18. package/src/payment-modes/payment-mode-dashboard.compont.tsx +2 -2
  19. package/src/payment-modes/payment-mode.workspace.test.tsx +57 -1
  20. package/src/payment-modes/payment-mode.workspace.tsx +9 -3
  21. package/src/payment-modes/usePaymentModeFormSchema.tsx +1 -1
  22. package/src/print-preview/print-preview.modal.tsx +45 -0
  23. package/src/routes.json +4 -4
  24. package/translations/en.json +1 -3
  25. package/dist/46.js.map +0 -1
  26. package/dist/964.js +0 -1
  27. package/dist/964.js.map +0 -1
  28. package/src/invoice/print-bill-receipt/receipt-print-preview.modal.tsx +0 -42
  29. package/src/invoice/printable-invoice/print-invoice.test.tsx +0 -36
  30. package/src/invoice/printable-invoice/print-receipt.component.tsx +0 -28
  31. package/src/invoice/printable-invoice/print-receipt.scss +0 -10
  32. package/src/invoice/printable-invoice/printable-footer.component.tsx +0 -33
  33. package/src/invoice/printable-invoice/printable-footer.scss +0 -24
  34. package/src/invoice/printable-invoice/printable-footer.test.tsx +0 -19
  35. package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +0 -63
  36. package/src/invoice/printable-invoice/printable-invoice-header.scss +0 -61
  37. package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +0 -56
  38. package/src/invoice/printable-invoice/printable-invoice.component.tsx +0 -134
  39. package/src/invoice/printable-invoice/printable-invoice.scss +0 -60
  40. /package/dist/{46.js.LICENSE.txt → 910.js.LICENSE.txt} +0 -0
  41. /package/src/{invoice/print-bill-receipt/print-bill-receipt.scss → print-preview/print-preview.scss} +0 -0
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false}],"extensions":[{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","slot":"patient-chart-dashboard-slot","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"billingOverviewLink","name":"billing-overview-link","order":0,"slot":"billing-dashboard-group-nav-slot"},{"component":"billDepositDashboardLink","name":"bill-deposit-dashboard-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentHistoryLink","name":"payment-history-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentPointsLink","name":"payment-points-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentModesLink","name":"payment-modes-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billManagerLink","name":"bill-manager-link","slot":"billing-dashboard-group-nav-slot"},{"component":"chargeableItemsLink","name":"chargeable-items-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billableExemptionsLink","name":"billable-exemptions-link","slot":"billing-dashboard-group-nav-slot"},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","order":0,"slot":"claims-management-dashboard-link-slot"},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slot":"claims-management-dashboard-link-slot"},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"paid-bill-receipt-print-preview-modal","component":"paidBillReceiptPrintPreviewModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"}],"version":"5.4.2-pre.2259"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false}],"extensions":[{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","slot":"patient-chart-dashboard-slot","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"billingOverviewLink","name":"billing-overview-link","order":0,"slot":"billing-dashboard-group-nav-slot"},{"component":"billDepositDashboardLink","name":"bill-deposit-dashboard-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentHistoryLink","name":"payment-history-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentPointsLink","name":"payment-points-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentModesLink","name":"payment-modes-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billManagerLink","name":"bill-manager-link","slot":"billing-dashboard-group-nav-slot"},{"component":"chargeableItemsLink","name":"chargeable-items-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billableExemptionsLink","name":"billable-exemptions-link","slot":"billing-dashboard-group-nav-slot"},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","order":0,"slot":"claims-management-dashboard-link-slot"},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slot":"claims-management-dashboard-link-slot"},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"},{"name":"print-preview-modal","component":"printPreviewModal"}],"version":"5.4.2-pre.2265"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-billing-app",
3
- "version": "5.4.2-pre.2259",
3
+ "version": "5.4.2-pre.2265",
4
4
  "description": "Billing app for KenyaEMR",
5
5
  "browser": "dist/kenyaemr-esm-billing-app.js",
6
6
  "main": "src/index.ts",
@@ -1,4 +1,3 @@
1
- import { restBaseUrl } from '@openmrs/esm-framework';
2
1
  import useSWR from 'swr';
3
2
 
4
3
  const fetcher = async (url: string) => {
@@ -12,8 +11,7 @@ const fetcher = async (url: string) => {
12
11
  return URL.createObjectURL(blob);
13
12
  };
14
13
 
15
- export const usePaidBillReceiptFileObjectUrl = (billId: number) => {
16
- const url = `/openmrs${restBaseUrl}/cashier/receipt?billId=${billId}`;
14
+ export const usePrintPreview = (url: string) => {
17
15
  const { data, isLoading, error, mutate } = useSWR<String>(url, fetcher);
18
- return { url: data, isLoading, error, mutate };
16
+ return { data, isLoading, error, mutate };
19
17
  };
package/src/index.ts CHANGED
@@ -57,7 +57,6 @@ import ClaimsManagementOverview from './claims/claims-management/main/claims-ove
57
57
  import { ManageClaimRequest } from './claims/claims-management/table/manage-claim-request.modal';
58
58
  import InitiatePaymentDialog from './invoice/payments/initiate-payment/initiate-payment.component';
59
59
  import VisitAttributeTags from './invoice/payments/visit-tags/visit-attribute.component';
60
- import ReceiptPrintPreviewModal from './invoice/print-bill-receipt/receipt-print-preview.modal';
61
60
  import DeletePaymentModeModal from './payment-modes/delete-payment-mode.modal';
62
61
  import PaymentModeWorkspace from './payment-modes/payment-mode.workspace';
63
62
  import RequirePaymentModal from './prompt-payment/prompt-payment-modal.component';
@@ -74,6 +73,9 @@ import DeleteDepositModal from './bill-deposit/components/modal/delete-deposit.m
74
73
  import ReverseTransactionModal from './bill-deposit/components/modal/reverse-transaction.modal';
75
74
  import DepositTransactionWorkspace from './bill-deposit/components/forms/deposit-transactions/deposit-transaction.workspace';
76
75
 
76
+ // Print Preview Components
77
+ import PrintPreviewModal from './print-preview/print-preview.modal';
78
+
77
79
  // Translation
78
80
  export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
79
81
 
@@ -212,7 +214,6 @@ export const visitAttributeTags = getSyncLifecycle(VisitAttributeTags, options);
212
214
  export const initiatePaymentDialog = getSyncLifecycle(InitiatePaymentDialog, options);
213
215
  export const paymentModeWorkspace = getSyncLifecycle(PaymentModeWorkspace, options);
214
216
  export const deletePaymentModeModal = getSyncLifecycle(DeletePaymentModeModal, options);
215
- export const paidBillReceiptPrintPreviewModal = getSyncLifecycle(ReceiptPrintPreviewModal, options);
216
217
 
217
218
  // Payment Points Components
218
219
  export const createPaymentPoint = getSyncLifecycle(CreatePaymentPoint, options);
@@ -234,6 +235,10 @@ export const addDepositWorkspace = getSyncLifecycle(AddDepositWorkspace, options
234
235
  export const deleteDepositModal = getSyncLifecycle(DeleteDepositModal, options);
235
236
  export const depositTransactionWorkspace = getSyncLifecycle(DepositTransactionWorkspace, options);
236
237
  export const reverseTransactionModal = getSyncLifecycle(ReverseTransactionModal, options);
238
+
239
+ // Print Preview Components
240
+ export const printPreviewModal = getSyncLifecycle(PrintPreviewModal, options);
241
+
237
242
  // App Startup
238
243
  export function startupApp() {
239
244
  defineConfigSchema(moduleName, configSchema);
@@ -17,11 +17,10 @@ import {
17
17
  useVisitContextStore,
18
18
  } from '@openmrs/esm-framework';
19
19
  import { ErrorState } from '@openmrs/esm-patient-common-lib';
20
- import React, { useEffect, useRef, useState } from 'react';
20
+ import React, { useEffect, useState } from 'react';
21
21
  import { useTranslation } from 'react-i18next';
22
22
  import { useParams } from 'react-router-dom';
23
- import { useReactToPrint } from 'react-to-print';
24
- import { useBill, useDefaultFacility } from '../billing.resource';
23
+ import { useBill } from '../billing.resource';
25
24
  import { spaBasePath } from '../constants';
26
25
  import { convertToCurrency } from '../helpers';
27
26
  import { usePaymentsReconciler } from '../hooks/use-payments-reconciler';
@@ -31,16 +30,14 @@ import { useShaFacilityStatus } from './invoice.resource';
31
30
  import styles from './invoice.scss';
32
31
  import Payments from './payments/payments.component';
33
32
  import ReceiptPrintButton from './print-bill-receipt/receipt-print-button.component';
34
- import PrintableInvoice from './printable-invoice/printable-invoice.component';
35
33
  import capitalize from 'lodash-es/capitalize';
36
34
  import { mutate } from 'swr';
35
+ import startCase from 'lodash-es/startCase';
37
36
 
38
37
  const Invoice: React.FC = () => {
39
38
  const { t } = useTranslation();
40
- const { data: facilityInfo } = useDefaultFacility();
41
39
  const { shaFacilityStatus } = useShaFacilityStatus();
42
40
  const { billUuid, patientUuid } = useParams();
43
- const [isPrinting, setIsPrinting] = useState(false);
44
41
  const { patient, isLoading: isLoadingPatient, error: patientError } = usePatient(patientUuid);
45
42
  const { bill, isLoading: isLoadingBill, error: billingError } = useBill(billUuid);
46
43
  const isInsurancePayment = (payments) => {
@@ -50,7 +47,6 @@ const Invoice: React.FC = () => {
50
47
  const { activeVisit, isLoading: isVisitLoading, error: visitError } = useVisit(patientUuid);
51
48
  const { patientUuid: visitStorePatientUuid, manuallySetVisitUuid } = useVisitContextStore();
52
49
  const [selectedLineItems, setSelectedLineItems] = useState([]);
53
- const componentRef = useRef<HTMLDivElement>(null);
54
50
  const isProcessClaimsFormEnabled = useFeatureFlag('healthInformationExchange');
55
51
 
56
52
  const isShaFacilityStatusValid =
@@ -65,19 +61,13 @@ const Invoice: React.FC = () => {
65
61
  setSelectedLineItems(uniqueLineItems);
66
62
  };
67
63
 
68
- const handlePrint = useReactToPrint({
69
- contentRef: componentRef,
70
- documentTitle: `Invoice ${bill?.receiptNumber} - ${patient?.name?.[0]?.given?.join(' ')} ${
71
- patient?.name?.[0].family
72
- }`,
73
- onBeforePrint: async () => {
74
- setIsPrinting(true);
75
- return Promise.resolve();
76
- },
77
- onAfterPrint() {
78
- setIsPrinting(false);
79
- },
80
- });
64
+ const handlePrint = () => {
65
+ const dispose = showModal('print-preview-modal', {
66
+ onClose: () => dispose(),
67
+ title: `${t('invoice', 'Invoice')} ${bill?.receiptNumber} - ${startCase(bill?.patientName)}`,
68
+ documentUrl: `/openmrs${restBaseUrl}/cashier/print?documentType=invoice&billId=${bill?.id}`,
69
+ });
70
+ };
81
71
 
82
72
  const handleBillPayment = () => {
83
73
  const dispose = showModal('initiate-payment-modal', {
@@ -185,11 +175,10 @@ const Invoice: React.FC = () => {
185
175
  onClick={handlePrint}
186
176
  kind="tertiary"
187
177
  size="sm"
188
- disabled={isPrinting}
189
178
  renderIcon={Printer}
190
179
  iconDescription="Add"
191
180
  tooltipPosition="right">
192
- {isPrinting ? t('printingInvoice', 'Printing invoice...') : t('printInvoice', 'Print invoice')}
181
+ {t('printInvoice', 'Print invoice')}
193
182
  </Button>
194
183
  <Button
195
184
  onClick={handleBillPayment}
@@ -217,21 +206,11 @@ const Invoice: React.FC = () => {
217
206
 
218
207
  <InvoiceTable bill={bill} isLoadingBill={isLoadingBill} onSelectItem={handleSelectItem} />
219
208
  <Payments bill={bill} selectedLineItems={selectedLineItems} />
220
-
221
- <div className={styles.printContainer}>
222
- <PrintableInvoice
223
- ref={componentRef}
224
- facilityInfo={facilityInfo}
225
- bill={bill}
226
- patient={patient}
227
- isPrinting={isPrinting}
228
- />
229
- </div>
230
209
  </div>
231
210
  );
232
211
  };
233
212
 
234
- function InvoiceSummary({ bill }: { readonly bill: MappedBill }) {
213
+ export function InvoiceSummary({ bill }: { readonly bill: MappedBill }) {
235
214
  const { t } = useTranslation();
236
215
  return (
237
216
  <>
@@ -271,7 +250,7 @@ function InvoiceSummary({ bill }: { readonly bill: MappedBill }) {
271
250
  );
272
251
  }
273
252
 
274
- function InvoiceSummaryItem({ label, value }: { readonly label: string; readonly value: string | number }) {
253
+ export function InvoiceSummaryItem({ label, value }: { readonly label: string; readonly value: string | number }) {
275
254
  return (
276
255
  <div className={styles.invoiceSummaryItem}>
277
256
  <span className={styles.label}>{label}</span>
@@ -1,9 +1,10 @@
1
1
  import { Button } from '@carbon/react';
2
2
  import { Printer } from '@carbon/react/icons';
3
- import { showModal } from '@openmrs/esm-framework';
3
+ import { restBaseUrl, showModal } from '@openmrs/esm-framework';
4
4
  import React from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { MappedBill, PaymentStatus } from '../../types';
7
+ import startCase from 'lodash-es/startCase';
7
8
 
8
9
  interface ReceiptPrintButtonProps {
9
10
  bill: MappedBill;
@@ -15,9 +16,10 @@ const ReceiptPrintButton: React.FC<ReceiptPrintButtonProps> = ({ bill }) => {
15
16
  const isPrintingDisabled = shouldDisablePrinting(bill);
16
17
 
17
18
  const handlePrintClick = () => {
18
- const dispose = showModal('paid-bill-receipt-print-preview-modal', {
19
+ const dispose = showModal('print-preview-modal', {
19
20
  onClose: () => dispose(),
20
- bill,
21
+ title: `${t('receipt', 'Receipt')} ${bill?.receiptNumber} - ${startCase(bill?.patientName)}`,
22
+ documentUrl: `/openmrs${restBaseUrl}/cashier/receipt?billId=${bill.id}`,
21
23
  });
22
24
  };
23
25
 
@@ -22,7 +22,7 @@ import {
22
22
  } from '@carbon/react';
23
23
 
24
24
  import styles from './payment-mode-dashboard.scss';
25
- import { formatDate, launchWorkspace, showModal, useDebounce } from '@openmrs/esm-framework';
25
+ import { formatDate, launchWorkspace, showModal, useDebounce, useLayoutType } from '@openmrs/esm-framework';
26
26
  import { PaymentMode } from '../types';
27
27
  import startCase from 'lodash/startCase';
28
28
 
@@ -30,7 +30,7 @@ type PaymentModeDashboardProps = {};
30
30
 
31
31
  const PaymentModeDashboard: React.FC<PaymentModeDashboardProps> = () => {
32
32
  const { t } = useTranslation();
33
- const size = 'md';
33
+ const size = useLayoutType() === 'tablet' ? 'md' : 'sm';
34
34
  const { paymentModes = [], isLoading } = usePaymentModes(false);
35
35
  const [searchTerm, setSearchTerm] = useState('');
36
36
 
@@ -99,7 +99,7 @@ describe('PaymentModeWorkspace', () => {
99
99
  // Key in attribute type name, description, required and format
100
100
  const attributeTypeNameInput = screen.getByRole('textbox', { name: /Attribute name/i });
101
101
  const attributeTypeDescriptionInput = screen.getByRole('textbox', { name: /Attribute description/i });
102
- const attributeRegExpInput = screen.getByRole('textbox', { name: /Enter regular expression/i });
102
+ const attributeRegExpInput = screen.getByRole('textbox', { name: /Regular expression/i });
103
103
  const attributeRetiredToggle = screen.getByRole('switch', { name: /Attribute retired/i });
104
104
  const attributeRequiredToggle = screen.getByRole('switch', { name: /Attribute required/i });
105
105
 
@@ -148,4 +148,60 @@ describe('PaymentModeWorkspace', () => {
148
148
  '',
149
149
  );
150
150
  });
151
+
152
+ test('should submit payload with attributeTypes and uuid when in edit mode', async () => {
153
+ const initialPaymentMode = {
154
+ uuid: '123',
155
+ name: 'Test Name',
156
+ description: 'Test Description',
157
+ retired: false,
158
+ attributeTypes: [
159
+ {
160
+ name: 'Test Attribute Name',
161
+ uuid: '456',
162
+ format: 'java.lang.String',
163
+ regExp: null,
164
+ attributeOrder: 0,
165
+ foreignKey: null,
166
+ description: 'Test Attribute Description',
167
+ retired: false,
168
+ required: false,
169
+ },
170
+ ],
171
+ };
172
+
173
+ const user = userEvent.setup();
174
+ render(<PaymentModeWorkspace {...testProps} initialPaymentMode={initialPaymentMode} />);
175
+
176
+ // make the attribute type required
177
+ const attributeRequiredToggle = screen.getByRole('switch', { name: /Attribute required/i });
178
+ await user.click(attributeRequiredToggle);
179
+
180
+ // click save and close
181
+ const saveAndCloseButton = screen.getByRole('button', { name: /Save & Close/i });
182
+ await user.click(saveAndCloseButton);
183
+
184
+ // should call createPaymentMode with attributeTypes and uuid
185
+ expect(mockCreatePaymentMode).toHaveBeenCalledWith(
186
+ {
187
+ description: 'Test Description',
188
+ name: 'Test Name',
189
+ attributeTypes: [
190
+ {
191
+ name: 'Test Attribute Name',
192
+ uuid: '456',
193
+ description: 'Test Attribute Description',
194
+ retired: false,
195
+ required: true,
196
+ format: 'java.lang.String',
197
+ regExp: null,
198
+ attributeOrder: 0,
199
+ foreignKey: null,
200
+ },
201
+ ],
202
+ retired: false,
203
+ },
204
+ '123',
205
+ );
206
+ });
151
207
  });
@@ -54,16 +54,22 @@ const PaymentModeWorkspace: React.FC<PaymentModeWorkspaceProps> = ({
54
54
  });
55
55
 
56
56
  const mappedAttributeTypes = (attributes) => {
57
- return {
57
+ const uuid = initialPaymentMode?.uuid
58
+ ? initialPaymentMode.attributeTypes.find((a) => a.name === attributes.name)?.uuid
59
+ : null;
60
+
61
+ const attributeType = {
58
62
  name: attributes.name,
59
63
  description: attributes.description,
60
64
  retired: attributes.retired,
61
65
  attributeOrder: attributes?.attributeOrder ?? 0,
62
66
  format: attributes?.format ?? '',
63
67
  foreignKey: attributes?.foreignKey ?? null,
64
- regExp: attributes?.regExp ?? '',
68
+ regExp: attributes?.regExp ?? null,
65
69
  required: attributes.required,
66
70
  };
71
+
72
+ return uuid ? { ...attributeType, uuid } : attributeType;
67
73
  };
68
74
 
69
75
  const onSubmit = async (data: PaymentModeFormSchema) => {
@@ -192,7 +198,7 @@ const PaymentModeWorkspace: React.FC<PaymentModeWorkspaceProps> = ({
192
198
  </Stack>
193
199
  </div>
194
200
  <ButtonSet className={classNames({ [styles.tablet]: isTablet, [styles.desktop]: !isTablet })}>
195
- <Button style={{ maxWidth: '50%' }} kind="secondary" onClick={() => closeWorkspace}>
201
+ <Button style={{ maxWidth: '50%' }} kind="secondary" onClick={() => closeWorkspace()}>
196
202
  {t('cancel', 'Cancel')}
197
203
  </Button>
198
204
  <Button
@@ -8,7 +8,7 @@ const usePaymentModeFormSchema = () => {
8
8
  retired: z.boolean().default(false),
9
9
  retiredReason: z.string().optional(),
10
10
  format: z.string().optional(),
11
- regExp: z.string().optional(),
11
+ regExp: z.union([z.string(), z.null()]).optional(),
12
12
  required: z.boolean().default(false),
13
13
  })
14
14
  .refine(
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { usePrintPreview } from '../hooks/usePrintPreview';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { ModalBody, ModalHeader, InlineLoading, ModalFooter, Button } from '@carbon/react';
5
+ import { ErrorState } from '@openmrs/esm-framework';
6
+ import styles from './print-preview.scss';
7
+
8
+ type PrintPreviewModalProps = {
9
+ onClose: () => void;
10
+ title?: string;
11
+ documentUrl?: string;
12
+ };
13
+
14
+ const PrintPreviewModal: React.FC<PrintPreviewModalProps> = ({ onClose, title, documentUrl }) => {
15
+ const { t } = useTranslation();
16
+
17
+ const { data, isLoading, error } = usePrintPreview(documentUrl);
18
+ return (
19
+ <div>
20
+ <>
21
+ <ModalHeader closeModal={onClose} className={styles.title}>
22
+ {t('printPreview', 'Print Preview {{title}}', { title })}
23
+ </ModalHeader>
24
+ <ModalBody>
25
+ {isLoading && (
26
+ <InlineLoading
27
+ status="active"
28
+ iconDescription="Loading"
29
+ description={t('loadingReceipt', 'Loading Receipt')}
30
+ />
31
+ )}
32
+ {error && <ErrorState error={error} headerTitle={t('previewError', 'Preview Error')} />}
33
+ {data && !isLoading && <iframe src={String(data)} title="Receipt Preview" className={styles.previewFrame} />}
34
+ </ModalBody>
35
+ <ModalFooter>
36
+ <Button kind="secondary" onClick={onClose} type="button" className={styles.btn}>
37
+ {t('close', 'Close')}
38
+ </Button>
39
+ </ModalFooter>
40
+ </>
41
+ </div>
42
+ );
43
+ };
44
+
45
+ export default PrintPreviewModal;
package/src/routes.json CHANGED
@@ -302,10 +302,6 @@
302
302
  "name": "manage-claim-request-modal",
303
303
  "component": "manageClaimRequestModal"
304
304
  },
305
- {
306
- "name": "paid-bill-receipt-print-preview-modal",
307
- "component": "paidBillReceiptPrintPreviewModal"
308
- },
309
305
  {
310
306
  "name": "clock-in-modal",
311
307
  "component": "clockIn"
@@ -321,6 +317,10 @@
321
317
  {
322
318
  "name": "reverse-transaction-modal",
323
319
  "component": "reverseTransactionModal"
320
+ },
321
+ {
322
+ "name": "print-preview-modal",
323
+ "component": "printPreviewModal"
324
324
  }
325
325
  ]
326
326
  }
@@ -33,7 +33,6 @@
33
33
  "billDate": "Date",
34
34
  "billDepositForm": "Bill Deposit Form",
35
35
  "billedItems": "Billed Items",
36
- "billedTo": "Billed to",
37
36
  "billErrorService": "Bill service error",
38
37
  "billing": "Billing",
39
38
  "billingForm": "Billing Form",
@@ -134,7 +133,6 @@
134
133
  "filterTable": "Filter table",
135
134
  "finalDiagnosis": "Final Diagnosis",
136
135
  "formTitle": "Fill in the form details",
137
- "generatedMessage": "The invoice has been electronically generated and is a valid document. It was created by {{userName}} on {{date}} at {{time}}",
138
136
  "hieVerificationFailure": "HIE verification failure",
139
137
  "home": "Home",
140
138
  "identifier": "Identifier",
@@ -232,7 +230,6 @@
232
230
  "previousPage": "Previous page",
233
231
  "price": "Price",
234
232
  "prices": "Prices",
235
- "printingInvoice": "Printing invoice...",
236
233
  "printInvoice": "Print invoice",
237
234
  "printReceipt": "Print receipt",
238
235
  "proceedToCare": "Proceed to care",
@@ -244,6 +241,7 @@
244
241
  "providerMessage": "By clicking Proceed to care, you acknowledge that you have advised the patient to settle the bill.",
245
242
  "providerName": "Provider Name",
246
243
  "quantity": "Quantity",
244
+ "receipt": "Receipt",
247
245
  "referenceCodes": " Reference Codes",
248
246
  "referenceNumber": "Reference number",
249
247
  "refundItem": "Refund item",