@medicus.ai/medicus-report-pdf-generator 1.3.2 → 1.3.4
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/index.js +1 -1
- package/lib/wellbeing_report_generator.js +36 -6
- package/package.json +1 -1
- package/test.js +3 -2
- package/testing-reports/pha/with-wellbeing-full-data.js +735 -733
package/index.js
CHANGED
|
@@ -235,7 +235,7 @@ module.exports = {
|
|
|
235
235
|
showHeaderLogo || true
|
|
236
236
|
);
|
|
237
237
|
|
|
238
|
-
const fileBuffer = await generatePDFReport({ ...html, client: reportData.client });
|
|
238
|
+
const fileBuffer = await generatePDFReport({ ...html, client: reportData.client, footer: decodedJSON?.footer });
|
|
239
239
|
|
|
240
240
|
if (isDebugging) {
|
|
241
241
|
console.log('3: save PDF buffer');
|
|
@@ -1137,6 +1137,8 @@ let generateHTMLWellbeingReportWithSmartReport = async (data, isDebugging, clien
|
|
|
1137
1137
|
|
|
1138
1138
|
if (client.toLowerCase() === 'pha') {
|
|
1139
1139
|
$('#content').append('<style>.patient-details .details-label, .patient-details .details-value { padding: 4px !important; }</style>');
|
|
1140
|
+
// PHA-only: Prevent first page content from overlapping PDF footer (email/address)
|
|
1141
|
+
$('#content').append('<style>body { padding-bottom: 60px !important; } #content { padding-bottom: 35px !important; } .first-section-scores { overflow: visible; clear: both; } .report-header { overflow: auto; } .row.scores-parts { clear: both; }</style>');
|
|
1140
1142
|
}
|
|
1141
1143
|
|
|
1142
1144
|
// Handle missing photo
|
|
@@ -1433,6 +1435,7 @@ let generateHTMLWellbeingReportWithSmartReport = async (data, isDebugging, clien
|
|
|
1433
1435
|
historyData,
|
|
1434
1436
|
profileInfo,
|
|
1435
1437
|
language,
|
|
1438
|
+
selectedLabs,
|
|
1436
1439
|
pdfHeader: cleanStyledHeader(renderedPdfHeader, profileInfo, language, clientName, selectedLabs, showHeaderLogo)
|
|
1437
1440
|
};
|
|
1438
1441
|
};
|
|
@@ -1612,25 +1615,51 @@ const cleanStyledHeader = (html, profileInfo, language = 'ar', clientName = 'med
|
|
|
1612
1615
|
/**
|
|
1613
1616
|
* Get PDF footer template HTML (client-specific contact info)
|
|
1614
1617
|
* @param {string} [client='mediclinic'] - Client identifier: 'mediclinic' | 'pha' | other
|
|
1618
|
+
* @param {array} [selectedLabs=[]] - Selected divisions/labs (e.g. ['wp'], ['labcorp'])
|
|
1619
|
+
* @param {object} [footerFromData] - Footer data from input (e.g. { address: "123 Main St..." }) for PHA + LabCorp
|
|
1615
1620
|
* @returns {string} Footer template HTML
|
|
1616
1621
|
*/
|
|
1617
|
-
const getPdfFooterTemplate = (client = 'mediclinic') => {
|
|
1622
|
+
const getPdfFooterTemplate = (client = 'mediclinic', selectedLabs = [], footerFromData = null) => {
|
|
1618
1623
|
const clientKey = (client || 'mediclinic').toLocaleLowerCase();
|
|
1624
|
+
const isPhaWithWp = clientKey === 'pha' && selectedLabs?.some(lab => lab?.toLowerCase() === 'wp');
|
|
1625
|
+
const isPhaWithLabcorp = clientKey === 'pha' && selectedLabs?.some(lab => lab?.toLowerCase() === 'labcorp');
|
|
1626
|
+
const footerAddress =
|
|
1627
|
+
(footerFromData && typeof footerFromData === 'object' && footerFromData.address) ? String(footerFromData.address) : null;
|
|
1619
1628
|
let contactBlock = '';
|
|
1620
1629
|
if (clientKey === 'mediclinic') {
|
|
1621
1630
|
contactBlock = `
|
|
1622
1631
|
<div style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';">Telephone: 800 20 33</div>
|
|
1623
1632
|
<div style="font-family: 'Open Sans', sans-serif;">Email: info@mediclinic.ae</div>`;
|
|
1624
1633
|
} else if (clientKey === 'pha') {
|
|
1625
|
-
|
|
1634
|
+
// PHA + LabCorp: use address from data.footer (fallback to no-address if footer missing)
|
|
1635
|
+
// PHA + WP: use static footer (106 W 3rd St...)
|
|
1636
|
+
// PHA + no lab: hide address (Tel + Email only)
|
|
1637
|
+
if (isPhaWithLabcorp && footerAddress) {
|
|
1638
|
+
contactBlock = `
|
|
1639
|
+
<div style="font-family: 'Open Sans', sans-serif;">Address: ${footerAddress}</div>
|
|
1640
|
+
<div style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';">Tel: (877) 345-7775</div>
|
|
1641
|
+
<div style="font-family: 'Open Sans', sans-serif;">Email: processing@wellness-partners.org</div>`;
|
|
1642
|
+
} else if (isPhaWithWp) {
|
|
1643
|
+
contactBlock = `
|
|
1644
|
+
<div style="font-family: 'Open Sans', sans-serif;">Address: 106 W 3rd St, McCook, NE 69001</div>
|
|
1626
1645
|
<div style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';">Telephone: (877) 345-7775</div>
|
|
1627
1646
|
<div style="font-family: 'Open Sans', sans-serif;">Email: processing@wellness-partners.org</div>`;
|
|
1647
|
+
} else {
|
|
1648
|
+
// PHA with no lab, or PHA + LabCorp without footer address: hide address line
|
|
1649
|
+
contactBlock = `
|
|
1650
|
+
<div style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';">Tel: (877) 345-7775</div>
|
|
1651
|
+
<div style="font-family: 'Open Sans', sans-serif;">Email: processing@wellness-partners.org</div>`;
|
|
1652
|
+
}
|
|
1628
1653
|
} else {
|
|
1629
1654
|
contactBlock = `
|
|
1630
1655
|
<div style="font-family: 'Open Sans', sans-serif;"> </div>`;
|
|
1631
1656
|
}
|
|
1657
|
+
const isPha = clientKey === 'pha';
|
|
1658
|
+
const footerStyle = isPha
|
|
1659
|
+
? 'width: 100%; font-size: 6px; line-height: 1.2; color: ' + config.colors.footerText + '; padding: 0 20px 2px; box-sizing: border-box; display: flex; justify-content: space-between; align-items: center; font-family: \'Open Sans\', sans-serif;'
|
|
1660
|
+
: 'width: 100%; font-size:7.3px; color: ' + config.colors.footerText + '; padding: 0 20px; box-sizing: border-box; display: flex; justify-content: space-between; align-items: center; font-family: \'Open Sans\', sans-serif;';
|
|
1632
1661
|
return `
|
|
1633
|
-
<div style="
|
|
1662
|
+
<div style="${footerStyle}">
|
|
1634
1663
|
<div style="display: flex; align-items: center;font-family: 'Open Sans', sans-serif;">
|
|
1635
1664
|
<span style="font-style: italic; font-family: 'Open Sans', sans-serif;">Page
|
|
1636
1665
|
<span class="pageNumber" style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';"></span>
|
|
@@ -1701,7 +1730,7 @@ const generatePDFReport = async (data, hideWellbeingUI = false) => {
|
|
|
1701
1730
|
try {
|
|
1702
1731
|
const contentHtml = data.html;
|
|
1703
1732
|
const OUT_FILE = data.outputFile;
|
|
1704
|
-
const footerTemplate = getPdfFooterTemplate(data.client);
|
|
1733
|
+
const footerTemplate = getPdfFooterTemplate(data.client, data.selectedLabs, data.footer);
|
|
1705
1734
|
|
|
1706
1735
|
// Launch browser and setup page
|
|
1707
1736
|
const browser = await launchExtendedBrowser();
|
|
@@ -1710,7 +1739,8 @@ const generatePDFReport = async (data, hideWellbeingUI = false) => {
|
|
|
1710
1739
|
// Setup content
|
|
1711
1740
|
await setupExtendedPageContent(page, contentHtml, Pdf_file);
|
|
1712
1741
|
|
|
1713
|
-
// Generate PDF with header and footer
|
|
1742
|
+
// Generate PDF with header and footer (PHA needs larger bottom margin to prevent content overlapping footer)
|
|
1743
|
+
const bottomMargin = (data.client || '').toLowerCase() === 'pha' ? '60px' : '50px';
|
|
1714
1744
|
const buffer = await page.pdf({
|
|
1715
1745
|
format: 'A4',
|
|
1716
1746
|
displayHeaderFooter: true,
|
|
@@ -1719,7 +1749,7 @@ const generatePDFReport = async (data, hideWellbeingUI = false) => {
|
|
|
1719
1749
|
width: "220mm",
|
|
1720
1750
|
margin: {
|
|
1721
1751
|
top: '125px',
|
|
1722
|
-
bottom:
|
|
1752
|
+
bottom: bottomMargin,
|
|
1723
1753
|
left: '20px',
|
|
1724
1754
|
right: '20px'
|
|
1725
1755
|
},
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -36,7 +36,7 @@ async function generateTestPDF() {
|
|
|
36
36
|
true,
|
|
37
37
|
client,
|
|
38
38
|
"en",
|
|
39
|
-
[
|
|
39
|
+
[],
|
|
40
40
|
true
|
|
41
41
|
);
|
|
42
42
|
|
|
@@ -47,11 +47,12 @@ async function generateTestPDF() {
|
|
|
47
47
|
defaultConfig = require(configPath);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// Generate the raw PDF buffer
|
|
50
|
+
// Generate the raw PDF buffer (pass data.footer for PHA + LabCorp address)
|
|
51
51
|
const fileBuffer = await generatePDFReport({
|
|
52
52
|
...html,
|
|
53
53
|
client: client,
|
|
54
54
|
logo: defaultConfig.logo,
|
|
55
|
+
footer: data.footer,
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
// Write original PDF
|