@medicus.ai/medicus-report-pdf-generator 1.3.17 → 1.3.18

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.
@@ -929,9 +929,13 @@ const renderPatientTable = (profileInfo, startIndex = 4) => {
929
929
  /**
930
930
  * Render doctor quiz details
931
931
  * @param {array} doctorData - Doctor data array
932
+ * @param {boolean} startQuizAnswersOnNewPage - when true, force the "Quiz Answers"
933
+ * title onto a fresh page instead of letting it orphan at the bottom of the
934
+ * previous one. Only set for the Maison Sante quiz-only doctor PDF (no smart
935
+ * report); the report-backed doctor PDF passes false so its layout is untouched.
932
936
  * @returns {string} Rendered doctor details HTML
933
937
  */
934
- const renderDoctorDetails = (doctorData) => {
938
+ const renderDoctorDetails = (doctorData, startQuizAnswersOnNewPage = false) => {
935
939
  if (empty(doctorData)) {
936
940
  return '';
937
941
  }
@@ -962,27 +966,42 @@ const renderDoctorDetails = (doctorData) => {
962
966
  `;
963
967
  }
964
968
 
965
- return `
966
- <p class="resume-title">Quiz Answers</p>
967
- <!-- display:flow-root overrides the class's flex-direction:column. Chrome 73
968
- (puppeteer 1.15) does not fragment inside flex containers, so
969
- break-inside:avoid on a row is ignored while the rows are flex items
970
- and a row can be sliced across a page boundary. As block boxes they
971
- honour it. flow-root rather than block: block lets the first row's
972
- margin-top:1% collapse out through the column, shifting the whole section
973
- up ~9px, which changes where the natural page break lands and spills rows
974
- onto the previous page. flow-root establishes a block formatting context so
975
- the margin is contained and the geometry matches the original exactly.
976
- width:100% on the rows is required too: a row is a
977
- block-level flex container and Chrome computes its width as 0 here
978
- once it is no longer stretched by the flex parent, which collapses the
979
- whole section. Measured: baseline row 907px, block-only 0px,
980
- block+width:100% 907px. Inline so only these two columns change --
981
- .details-column and .details-row are shared with renderPatientTable
982
- and the patient-table.html blocks of maisonsante, Mediclinic and Pha. -->
969
+ // display:flow-root overrides the class's flex-direction:column. Chrome 73
970
+ // (puppeteer 1.15) does not fragment inside flex containers, so
971
+ // break-inside:avoid on a row is ignored while the rows are flex items
972
+ // and a row can be sliced across a page boundary. As block boxes they
973
+ // honour it. flow-root rather than block: block lets the first row's
974
+ // margin-top:1% collapse out through the column, shifting the whole section
975
+ // up ~9px, which changes where the natural page break lands and spills rows
976
+ // onto the previous page. flow-root establishes a block formatting context so
977
+ // the margin is contained and the geometry matches the original exactly.
978
+ // width:100% on the rows is required too: a row is a
979
+ // block-level flex container and Chrome computes its width as 0 here
980
+ // once it is no longer stretched by the flex parent, which collapses the
981
+ // whole section. Measured: baseline row 907px, block-only 0px,
982
+ // block+width:100% 907px. Inline so only these two columns change --
983
+ // .details-column and .details-row are shared with renderPatientTable
984
+ // and the patient-table.html blocks of maisonsante, Mediclinic and Pha.
985
+ const columnsHTML = `
983
986
  <div class="details-column" style="display:flow-root">${details1HTML}</div>
984
987
  <div class="details-column" style="display:flow-root;margin-left: 1%">${details2HTML}</div>
985
988
  `;
989
+
990
+ // Quiz-only: the caller turns .doctor-details into a page-break-inside:avoid block so
991
+ // the whole Quiz Answers section is pushed onto a fresh page (see the caller for why
992
+ // that mechanism is used instead of page-break-before). Once .doctor-details is a
993
+ // block rather than the shared flex container, the two columns need their own flex
994
+ // row to stay side by side, mirroring the gap/flex-wrap the .doctor-details flex rule
995
+ // normally supplies. The report-backed doctor PDF keeps the shared flex layout
996
+ // untouched.
997
+ const bodyHTML = startQuizAnswersOnNewPage
998
+ ? `<div style="display:flex; flex-wrap:wrap; gap:25px; width:100%;">${columnsHTML}</div>`
999
+ : columnsHTML;
1000
+
1001
+ return `
1002
+ <p class="resume-title">Quiz Answers</p>
1003
+ ${bodyHTML}
1004
+ `;
986
1005
  };
987
1006
 
988
1007
  /**
@@ -1355,8 +1374,32 @@ let generateHTMLWellbeingReportWithSmartReport = async (data, isDebugging, clien
1355
1374
 
1356
1375
  // Render doctor details
1357
1376
  if (!empty(doctorData)) {
1358
- const doctorDetailsHtml = renderDoctorDetails(doctorData);
1377
+ // Quiz-only Maison Sante doctor PDF has no smart report above the Quiz Answers
1378
+ // block, so its title would orphan at the bottom of page 1; start it on a fresh
1379
+ // page there. The report-backed doctor PDF keeps its existing pagination.
1380
+ const startQuizAnswersOnNewPage = empty(smartReport)
1381
+ && client.toLowerCase() === 'maisonsante'
1382
+ && !!data.IsDoctor;
1383
+ const doctorDetailsHtml = renderDoctorDetails(doctorData, startQuizAnswersOnNewPage);
1359
1384
  $('.doctor-details').html(doctorDetailsHtml);
1385
+ // Quiz-only: start the whole Quiz Answers block on a fresh page so its title
1386
+ // does not orphan at the bottom of page 1. Chrome 73 (puppeteer 1.15) ignores
1387
+ // page-break-before here (both on the flex container and its items), so this
1388
+ // reuses the mechanism the .new-page sections rely on: a block that establishes
1389
+ // its own formatting context (display:block + overflow:hidden) and refuses to be
1390
+ // split (page-break-inside:avoid) is pushed to the next page when it cannot fit
1391
+ // in the space left on the current one. display:block also restores the columns'
1392
+ // side-by-side layout (they carry their own flex row now). Inline so only this
1393
+ // render changes; the shared .doctor-details flex rule is untouched for the
1394
+ // report-backed doctor PDF and every other client.
1395
+ if (startQuizAnswersOnNewPage) {
1396
+ $('.doctor-details').css({
1397
+ 'display': 'block',
1398
+ 'overflow': 'hidden',
1399
+ 'page-break-inside': 'avoid',
1400
+ 'break-inside': 'avoid'
1401
+ });
1402
+ }
1360
1403
  }
1361
1404
 
1362
1405
  // Render Big Integral Questionnaire section (Maison Sante doctor PDF only)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medicus.ai/medicus-report-pdf-generator",
3
- "version": "1.3.17",
3
+ "version": "1.3.18",
4
4
  "description": "Nasco corporate report - latest update in 12/10/2023 - Fix HRC for bionext",
5
5
  "main": "index.js",
6
6
  "scripts": {