@medicus.ai/medicus-report-pdf-generator 1.3.3 → 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 +17 -5
- 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');
|
|
@@ -1615,25 +1615,37 @@ const cleanStyledHeader = (html, profileInfo, language = 'ar', clientName = 'med
|
|
|
1615
1615
|
/**
|
|
1616
1616
|
* Get PDF footer template HTML (client-specific contact info)
|
|
1617
1617
|
* @param {string} [client='mediclinic'] - Client identifier: 'mediclinic' | 'pha' | other
|
|
1618
|
-
* @param {array} [selectedLabs=[]] - Selected divisions/labs (e.g. ['wp'])
|
|
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
|
|
1619
1620
|
* @returns {string} Footer template HTML
|
|
1620
1621
|
*/
|
|
1621
|
-
const getPdfFooterTemplate = (client = 'mediclinic', selectedLabs = []) => {
|
|
1622
|
+
const getPdfFooterTemplate = (client = 'mediclinic', selectedLabs = [], footerFromData = null) => {
|
|
1622
1623
|
const clientKey = (client || 'mediclinic').toLocaleLowerCase();
|
|
1623
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;
|
|
1624
1628
|
let contactBlock = '';
|
|
1625
1629
|
if (clientKey === 'mediclinic') {
|
|
1626
1630
|
contactBlock = `
|
|
1627
1631
|
<div style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';">Telephone: 800 20 33</div>
|
|
1628
1632
|
<div style="font-family: 'Open Sans', sans-serif;">Email: info@mediclinic.ae</div>`;
|
|
1629
1633
|
} else if (clientKey === 'pha') {
|
|
1630
|
-
//
|
|
1631
|
-
|
|
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) {
|
|
1632
1643
|
contactBlock = `
|
|
1633
1644
|
<div style="font-family: 'Open Sans', sans-serif;">Address: 106 W 3rd St, McCook, NE 69001</div>
|
|
1634
1645
|
<div style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';">Telephone: (877) 345-7775</div>
|
|
1635
1646
|
<div style="font-family: 'Open Sans', sans-serif;">Email: processing@wellness-partners.org</div>`;
|
|
1636
1647
|
} else {
|
|
1648
|
+
// PHA with no lab, or PHA + LabCorp without footer address: hide address line
|
|
1637
1649
|
contactBlock = `
|
|
1638
1650
|
<div style="font-family: 'Open Sans', sans-serif; font-feature-settings: 'tnum';">Tel: (877) 345-7775</div>
|
|
1639
1651
|
<div style="font-family: 'Open Sans', sans-serif;">Email: processing@wellness-partners.org</div>`;
|
|
@@ -1718,7 +1730,7 @@ const generatePDFReport = async (data, hideWellbeingUI = false) => {
|
|
|
1718
1730
|
try {
|
|
1719
1731
|
const contentHtml = data.html;
|
|
1720
1732
|
const OUT_FILE = data.outputFile;
|
|
1721
|
-
const footerTemplate = getPdfFooterTemplate(data.client, data.selectedLabs);
|
|
1733
|
+
const footerTemplate = getPdfFooterTemplate(data.client, data.selectedLabs, data.footer);
|
|
1722
1734
|
|
|
1723
1735
|
// Launch browser and setup page
|
|
1724
1736
|
const browser = await launchExtendedBrowser();
|
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
|