@kenyaemr/esm-shr-app 5.4.2-pre.2308 → 5.4.2-pre.2311

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.
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"shrRoot","route":"referrals"}],"extensions":[{"component":"shrAuthorizationForm","name":"shr-authorization-form"},{"name":"patient-chart-shr-summary-dashboard-link","component":"shrSummaryDashboardLink","slot":"patient-chart-dashboard-slot","meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-shr-summary-dashboard-slot","path":"SHR Portal"},"featureFlag":"healthInformationExchange"},{"name":"SHR Portal","slot":"patient-chart-shr-summary-dashboard-slot","component":"patientSHRSummary","meta":{"columnSpan":4}},{"name":"referrals","slot":"referrals-slot","component":"shrRoot"},{"name":"referrals-link","slot":"homepage-dashboard-slot","component":"ReferralsDashboardLink","meta":{"name":"referrals","title":"referrals","slot":"referrals-slot"}},{"name":"referral-reasons-dialog","component":"referralReasonsDialogPopup"},{"name":"facility-referral-form","component":"facilityRefferalForm"},{"name":"referral-view-link","component":"referralLink","slot":"patient-chart-dashboard-slot","order":13,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-referral-slot","path":"referral","layoutMode":"anchored"}},{"name":"referral-view","slot":"patient-chart-referral-slot","component":"referralWidget","order":0,"online":true,"offline":false}],"version":"5.4.2-pre.2308"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"shrRoot","route":"referrals"}],"extensions":[{"component":"shrAuthorizationForm","name":"shr-authorization-form"},{"name":"patient-chart-shr-summary-dashboard-link","component":"shrSummaryDashboardLink","slot":"patient-chart-dashboard-slot","meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-shr-summary-dashboard-slot","path":"SHR Portal"},"featureFlag":"healthInformationExchange"},{"name":"SHR Portal","slot":"patient-chart-shr-summary-dashboard-slot","component":"patientSHRSummary","meta":{"columnSpan":4}},{"name":"referrals","slot":"referrals-slot","component":"shrRoot"},{"name":"referrals-link","slot":"homepage-dashboard-slot","component":"ReferralsDashboardLink","meta":{"name":"referrals","title":"referrals","slot":"referrals-slot"}},{"name":"referral-reasons-dialog","component":"referralReasonsDialogPopup"},{"name":"facility-referral-form","component":"facilityRefferalForm"},{"name":"referral-view-link","component":"referralLink","slot":"patient-chart-dashboard-slot","order":13,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-referral-slot","path":"referral","layoutMode":"anchored"}},{"name":"referral-view","slot":"patient-chart-referral-slot","component":"referralWidget","order":0,"online":true,"offline":false}],"version":"5.4.2-pre.2311"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-shr-app",
3
- "version": "5.4.2-pre.2308",
3
+ "version": "5.4.2-pre.2311",
4
4
  "description": "Patient care panels microfrontend for the OpenMRS SPA",
5
5
  "browser": "dist/kenyaemr-esm-shr-app.js",
6
6
  "main": "src/index.ts",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "lodash-es": "^4.17.15",
41
- "react-to-print": "^3.1.0"
41
+ "react-to-print": "2.14.13"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@carbon/react": "1.x",
@@ -1,11 +1,10 @@
1
- import React, { useRef, useState } from 'react';
1
+ import React, { useRef, useState, useCallback } from 'react';
2
2
  import styles from './shr-summary.scss';
3
3
  import { Tab, Tabs, TabList, TabPanel, TabPanels, StructuredListSkeleton, Button } from '@carbon/react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useLayoutType, useSession } from '@openmrs/esm-framework';
6
6
  import { useSHRSummary } from '../hooks/useSHRSummary';
7
7
  import { Printer } from '@carbon/react/icons';
8
- import { useReactToPrint } from 'react-to-print';
9
8
  import PrintComponent from '../print-layout/print.component';
10
9
  import SHRDataTable from './shrDataTable.component';
11
10
  import { EmptyState, ErrorState } from '@openmrs/esm-patient-common-lib';
@@ -23,22 +22,50 @@ const SharedHealthRecordsSummary: React.FC<SHRSummaryProps> = ({ patientUuid })
23
22
  const { t } = useTranslation();
24
23
  const isTablet = useLayoutType() == 'tablet';
25
24
 
26
- const printRef = useReactToPrint({
27
- contentRef: componentRef,
28
- onBeforePrint: async () => {
25
+ // Custom print handler to avoid React 18 compatibility issues
26
+ const handlePrint = useCallback(async () => {
27
+ try {
29
28
  setPrintMode(true);
30
- return Promise.resolve();
31
- },
32
- onAfterPrint: () => setPrintMode(false),
33
- pageStyle: styles.pageStyle,
34
- documentTitle: 'Shared Health Records',
35
- });
36
29
 
37
- const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
38
- const handlePrint = async () => {
39
- await delay(500);
40
- printRef();
41
- };
30
+ // Wait for the component to render in print mode
31
+ await new Promise((resolve) => setTimeout(resolve, 500));
32
+
33
+ if (componentRef.current) {
34
+ const printWindow = window.open('', '_blank');
35
+ if (printWindow) {
36
+ const printContent = componentRef.current.innerHTML;
37
+ printWindow.document.documentElement.innerHTML = `
38
+ <head>
39
+ <title>Shared Health Records</title>
40
+ <style>
41
+ body { font-family: Arial, sans-serif; margin: 20px; }
42
+ .bodyContainer { max-width: 1200px; margin: 0 auto; }
43
+ .card { border: 1px solid #ccc; padding: 20px; margin-bottom: 20px; }
44
+ .title { font-size: 18px; font-weight: bold; margin-bottom: 20px; }
45
+ table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
46
+ th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
47
+ th { background-color: #f2f2f2; font-weight: bold; }
48
+ .tablist { display: none; }
49
+ .tabpanel { display: block !important; }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ ${printContent}
54
+ </body>
55
+ `;
56
+ printWindow.focus();
57
+ printWindow.print();
58
+ printWindow.close();
59
+ }
60
+ }
61
+ } catch (error) {
62
+ console.error('Print error:', error);
63
+ // Fallback to browser print
64
+ window.print();
65
+ } finally {
66
+ setPrintMode(false);
67
+ }
68
+ }, []);
42
69
 
43
70
  // If still loading
44
71
  if (isLoading) {
@@ -210,7 +237,17 @@ const SharedHealthRecordsSummary: React.FC<SHRSummaryProps> = ({ patientUuid })
210
237
 
211
238
  <div className={styles.card}>
212
239
  <div className={isTablet ? styles.tabletHeading : styles.desktopHeading}>
213
- <h4 className={styles.title}> {t('shrPatientSHRSummary', 'Patient SHR Summary')}</h4>
240
+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
241
+ <h4 className={styles.title}> {t('shrPatientSHRSummary', 'Patient SHR Summary')}</h4>
242
+ <Button
243
+ kind="ghost"
244
+ renderIcon={Printer}
245
+ onClick={handlePrint}
246
+ iconDescription={t('print', 'Print')}
247
+ size="sm">
248
+ {t('print', 'Print')}
249
+ </Button>
250
+ </div>
214
251
  </div>
215
252
 
216
253
  <hr />
@@ -33,6 +33,7 @@
33
33
  "noSHRRecords": "የSHR መዝገቦች አልተሳቡም",
34
34
  "nupi": "UPI",
35
35
  "onsetDate": "የጀመረበት ቀን",
36
+ "print": "አትም",
36
37
  "priority": "ቅድሚያ",
37
38
  "processReferral": "ሪፈራል አስተናግድ",
38
39
  "processReferralError": "ሪፈራል በማስተናገድ ላይ ስህተት",
@@ -33,6 +33,7 @@
33
33
  "noSHRRecords": "SHR Records have not been pulled",
34
34
  "nupi": "UPI",
35
35
  "onsetDate": "Onset Date",
36
+ "print": "Print",
36
37
  "priority": "Priority",
37
38
  "processReferral": "Process referral",
38
39
  "processReferralError": "Process referral error",
@@ -33,6 +33,7 @@
33
33
  "noSHRRecords": "SHR Records have not been pulled",
34
34
  "nupi": "UPI",
35
35
  "onsetDate": "Onset Date",
36
+ "print": "Print",
36
37
  "priority": "Priority",
37
38
  "processReferral": "Process referral",
38
39
  "processReferralError": "Process referral error",