From ea4a9f793ee1a44c2dd38020978eff36ba7ed598 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Tue, 3 Feb 2009 23:19:11 +0000 Subject: [PATCH] added support for multiple pages --- interface/patient_file/printed_fee_sheet.php | 62 +++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/interface/patient_file/printed_fee_sheet.php b/interface/patient_file/printed_fee_sheet.php index fd4d50019..12ab481a9 100644 --- a/interface/patient_file/printed_fee_sheet.php +++ b/interface/patient_file/printed_fee_sheet.php @@ -12,6 +12,9 @@ require_once("$srcdir/patient.inc"); require_once("$srcdir/classes/Address.class.php"); require_once("$srcdir/classes/InsuranceCompany.class.php"); +$lines_per_page = 55; +$lines_in_stats = 16; + // This file is optional. You can create it to customize how the printed // fee sheet looks, otherwise you'll get a mirror of your actual fee sheet. // @@ -24,6 +27,15 @@ $page_height = trim($_REQUEST['page_height']) + 0; if (!$page_height) $page_height = 700; $padding = 0; +// The $SBCODES table is a simple indexed array whose values are +// strings of the form "code|text" where code may be either a billing +// code or one of the following: +// +// *H - A main heading, where "text" is its title (to be centered). +// *G - Specifies a new category, where "text" is its name. +// *B - A borderless blank row. +// *C - Ends the current column and starts a new one. + // If $SBCODES is not provided, then manufacture it from the Fee Sheet. // if (empty($SBCODES)) { @@ -71,12 +83,30 @@ if (empty($SBCODES)) { } } - // Extra stuff for the labs section and splitting evenly into 3 columns. + // Extra stuff for the labs section. $SBCODES[] = '*G|' . xl('Additional Labs'); $percol = intval((count($SBCODES) + 2) / 3); while (count($SBCODES) < $percol * 3) $SBCODES[] = '*B|'; - array_splice($SBCODES, $percol*2, 0, '*C|'); // ends 2nd column - array_splice($SBCODES, $percol*1, 0, '*C|'); // ends 1st column + + // Adjust lines per page to distribute lines evenly among the pages. + $pages = intval(($percol + $lines_in_stats + $lines_per_page - 1) / $lines_per_page); + $lines_per_page = intval($percol + $lines_in_stats + $pages - 1) / $pages; + + // Figure out page and column breaks. + $pages = 1; + $lines = $percol; + $page_start_index = 0; + while ($lines + $lines_in_stats > $lines_per_page) { + ++$pages; + $lines_this_page = $lines > $lines_per_page ? $lines_per_page : $lines; + $lines -= $lines_this_page; + array_splice($SBCODES, $lines_this_page*3 + $page_start_index, 0, '*C|'); + array_splice($SBCODES, $lines_this_page*2 + $page_start_index, 0, '*C|'); + array_splice($SBCODES, $lines_this_page*1 + $page_start_index, 0, '*C|'); + $page_start_index += $lines_this_page * 3 + 3; + } + array_splice($SBCODES, $lines*2 + $page_start_index, 0, '*C|'); + array_splice($SBCODES, $lines*1 + $page_start_index, 0, '*C|'); } ?> @@ -151,8 +181,8 @@ function genColumn($ix) { for ($imax = count($SBCODES); $ix < $imax; ++$ix) { $a = explode('|', $SBCODES[$ix], 2); $cmd = trim($a[0]); - if ($cmd == '*C') { - return ++$ix; // column break + if ($cmd == '*C') { // column break + return ++$ix; } if ($cmd == '*B') { // Borderless and empty echo " \n"; @@ -226,6 +256,8 @@ $cindex = 0; onsubmit='return top.restoreSession()'>
+= 0) { ?> + + + +
@@ -239,6 +271,9 @@ $cindex = 0; + + +
Patient:
@@ -314,6 +349,9 @@ else { Notes:
@@ -327,6 +365,9 @@ else { + + + Additional procedures:
@@ -337,6 +378,9 @@ else { Diagnosis:
+ + + @@ -350,6 +394,9 @@ else { + + +   @@ -360,12 +407,17 @@ else { M.D. Signature:
+ + + + +

' onclick='printme()' /> -- 2.11.4.GIT