Printing Statements - HELP PLEASE!

shawnmiller77 wrote on Wednesday, February 03, 2010:

Hi Everyone,

I am running version 3.1.0 and cannot print statements.  I have gone into the /custom/statement.inc php file and changed the printer code.  My new code reads
//$STMT_PRINT_CMD = “lpr -P Kyocera -o cpi=10 -o lpi=6 -o page-left=72 -o page-top=72”;

I select the statement I want to print and it says it is processing it, but it never prints.

Any idea.  Need some help ASAP!  Needs print out statements.

Thanks

Shawn

ideaman911 wrote on Wednesday, February 03, 2010:

Shawn;

The good news is that there will be an alternative which I have proven successful in my testing of 3.2, soon to release.  The bad news is I have yet to have success printing statements with the prior versions in Windows at all.  You might try to assure you have the LPR services installed (do a Google for “Linux Print in Windows” do see what i am talking about).  But I suspect you will have to wait until you get the 3.2 operating, then see …/custom/statements.inc.php for the formatted print, which you can change to what you need.  Then you will “Download Statements” instead of printing them, then print that file using Notepad to any Windows printer.  With proper line counts, it works perfectly.  I revised mine to work with standard #10 window envelopes to save even typing them.  The statements.inc.php file requires you to replace the labels found with your practice data manually, but it is a one-time fix.  Take a look at the 3.2 pre-release to see what I mean.  Good luck.

Joe Holzer    Idea Man    315-622-9241     im@holzerent.com  or  joe.im0602x@gmail.com
http://www.holzerent.com  or  http://www.EMRofCNY.com

xiaoanri wrote on Thursday, February 04, 2010:

Shawn,

You will need to first make sure you installed linux printer server, and tune up the print server to make sure it is working.  then you would be able to print by modifying the LPR command. 

Hui

shawnmiller77 wrote on Thursday, February 04, 2010:

Is there anyway to edit the /custom/statement.inc php file to make the statements print to a file?  I am having major issues trying to get these statements to print.

Shawn

sunsetsystems wrote on Thursday, February 04, 2010:

If you really have those two slashes in front of your $STMT_PRINT_CMD line, remove them.  Those turn the line into a comment.

Rod
www.sunsetsystems.com

sunsetsystems wrote on Thursday, February 04, 2010:

By the way, statements are already saved to an intermediate textg file, as specified in $STMT_TEMP_FILE.  So you can grab them from that.

Another thing you can do is install a virtual PDF printer. In Debian or Ubuntu that’s the cups-pdf package.  This can be set up to send your statements to a path of your choosing, as a PDF file ready to print.

Rod
www.sunsetsystems.com

shawnmiller77 wrote on Thursday, February 04, 2010:

Update:

I have configured LPR services for Windows and setup an OKI 320 dot matrix printer with a external HP Jetdirect with the IP address of 10.0.0.200.  I can print out of Windows using the Oki printer with an Epson FX 80 driver.  I still cannot print out any statements and the statements are not being stored in any tmp file to be printed out.  This is my statement.inc.php file.  Can someone please tell me why this is not working? Or why the statements are not being sent to a tmp file so I can print them?

Any help is greatly appreciated.

Thanks

Shawn

?php

// Copyright (C) 2005-2006 Rod Roark <rod@sunsetsystems.com> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version.

//////////////////////////////////////////////////////////////////////
// This is a template for printing patient statements and collection // letters.  You must customize it to suit your practice.  If your // needs are simple then you do not need programming experience to do // this - just read the comments and make appropriate substitutions.
// All you really need to do is replace the .
//////////////////////////////////////////////////////////////////////

// The location/name of a temporary file to hold printable statements.
$STMT_TEMP_FILE = “C:\tmp\openemr”;

// This is the command to be used for printing (without the filename).
// The word following “-P” should be the name of your printer.  This // example is designed for 8.5x11-inch paper with 1-inch margins, // 10 CPI, 6 LPI, 65 columns, 54 lines per page.
$STMT_PRINT_CMD = “lpr -P epson -o cpi=10 -o lpi=6 -o page-left=72 -o page-top=72”;

// This function builds a printable statement or collection letter from // an associative array having the following keys:
//
//  today   = statement date yyyy-mm-dd
//  pid     = patient ID
//  patient = patient name
//  amount  = total amount due
//  to      = array of addressee name/address lines
//  lines   = array of lines, each with the following keys:
//    dos     = date of service yyyy-mm-dd
//    desc    = description
//    amount  = charge less adjustments
//    paid    = amount paid
//    notice  = 1 for first notice, 2 for second, etc.
//    detail  = associative array of details
//
// Each detail array is keyed on a string beginning with a date in // yyyy-mm-dd format, or blanks in the case of the original charge // items.  Its values are associative arrays like this:
//
//  pmt - payment amount as a positive number, only for payments //  src - check number or other source, only for payments //  chg - invoice line item amount amount, only for charges or
//        adjustments (adjustments may be zero)
//  rsn - adjustment reason, only for adjustments // // The returned value is a string that can be sent to a printer.
// This example is plain text, but if you are a hotshot programmer // then you could make a PDF or PostScript or whatever peels your // banana.  These strings are sent in succession, so append a form // feed if that is appropriate.
//
function create_statement($stmt) {
if (! $stmt) return “”; // get out if no data

// This is the text for the top part of the page, up to but not  // including the detail lines.  Some examples of variable fields are:
//  %s    = string with no minimum width
//  %9s   = right-justified string of 9 characters padded with spaces
//  %-25s = left-justified string of 25 characters padded with spaces  // Note that “\n” is a line feed (new line) character.
//
$out = sprintf(
  "             %-23s %s\n" .
  "          Chart Number %s\n" .
  "              Insurance information on file\n" .
  "                               Total amount due: %s\n" .
  “\n” .
  “\n” .
  “ADDRESSEE:                       REMIT TO:\n” .
  “\n” .
  “%-32s \n” .
  “%-32s \n” .
  “%-32s \n” .
  “%-32s If paying by VISA/MC/AMEX/Disc:\n” .
  “\n” .
  “Card#_____________________  Exp______ Signature__________________\n” .
  "              (Return above part with your payment)\n" .
  “-------------------------------------------\n” .
  “\n” .
  “_______________________ STATEMENT SUMMARY _______________________\n” .
  “\n” .
  “Visit Date  Description                                    Amount\n” .
  “\n”,

  // These are the values for the variable fields.  They must appear
  // here in the same order as in the above text!
  //
  $stmt,
  $stmt,
  $stmt,
  $stmt,
  $stmt,
  $stmt,
  $stmt,
  $stmt);

// This must be set to the number of lines generated above.
//
$count = 21;

// This generates the detail lines.  Again, note that the values must  // be specified in the order used.
//
foreach ($stmt as $line) {
  $description = $line;
  $tmp = substr($description, 0, 14);
  if ($tmp == ‘Procedure 9920’ || $tmp == ‘Procedure 9921’)
   $description = ‘Office Visit’;

  $dos = $line;
  ksort($line);

  foreach ($line as $dkey => $ddata) {
   $ddate = substr($dkey, 0, 10);
   if (preg_match(’/^(\d\d\d\d)(\d\d)(\d\d)\s*$/’, $ddate, $matches)) {
    $ddate = $matches . ‘-’ . $matches . ‘-’ . $matches;
   }
   $amount = ‘’;

   if ($ddata) {
    $amount = sprintf("%.2f", 0 - $ddata);
    $desc = “Paid $ddate: " . $ddata;
   } else if ($ddata) {
    if ($ddata) {
     $amount = sprintf(”%.2f", $ddata);
     $desc = “Adj  $ddate: " . $ddata;
    } else {
     $desc = “Note $ddate: " . $ddata;
    }
   } else if ($ddata < 0) {
    $amount = sprintf(”%.2f”, $ddata);
    $desc = “Patient Payment”;
   } else {
    $amount = sprintf("%.2f", $ddata);
    $desc = $description;
   }

   $out .= sprintf("%-10s  %-45s%8s\n", $dos, $desc, $amount);
   $dos = ‘’;
   ++$count;
  }
}

// This generates blank lines until we are at line 42.
//
while ($count++ < 42) $out .= “\n”;

// This is the bottom portion of the page.  You know the drill.
//
$out .= sprintf(
  “Name: %-25s Date: %-10s     Due:%8s\n” .
  “_________________________________________________________________\n” .
  “\n” .
  “Thank you for choosing .\n” .
  “\n” .
  “Please call if any of the above information is incorrect.\n” .
  “We appreciate prompt payment of balances due.\n” .
  “\n” .
  “\n” .
  “Billing Department\n” .
  “” .
  “\014”, // this is a form feed

  $stmt, // values start here
  $stmt,
  $stmt);

return $out;
}
?>

sunsetsystems wrote on Thursday, February 04, 2010:

In a PHP literal the backslash starts an escape sequence.  So instead of:

$STMT_TEMP_FILE = “C:\tmp\openemr”;

do this:

$STMT_TEMP_FILE = “C:/tmp/openemr”;

or:

$STMT_TEMP_FILE = “C:\\tmp\\openemr”;

Rod
www.sunsetsystems.com

shawnmiller77 wrote on Thursday, February 04, 2010:

Hey Rod

I tried the statement temp file both ways and it still does not show anything in tmp directory.

i am at a loss!

Any other ideas?

Shawn

sunsetsystems wrote on Friday, February 05, 2010:

No, I think you’ll need a Windows techie to troubleshoot that one.

Rod
www.sunsetsystems.com

tmccormi wrote on Saturday, February 06, 2010:

Send me a copy of your globals.php file and yoyr statement.inc.php file and I’ll take a look at it.  There is a update to the statements process for 3.2 that will work in 3.1; it  adds the ability to download the resulting output file so you can use wordpad or notepad to print it in more normal windows style.  That might be the real solution.

-Tony
tony@mi-squared.com

juggernautsei wrote on Monday, May 02, 2011:

We are still using 3.2 does 4.0 provide a print function for invoices?

tmccormi wrote on Monday, May 02, 2011:

Nothing around the statement printing process has changed for 4.0.   It works (if configured correctly) for window and Linux.  Both directly off the server or by using the “Download Selected Statements” or “PDF Download Selected Statements” button and printing it from wordpad, or acrobat. 
-Tony

edisonfoster wrote on Monday, May 16, 2011:

Hi Tony,

  I have just installed a fresh 4.0 version of OpenEMR and I don´t find the “Download Selected Statements” or the “PDF Download Selected Statements” buttons. Could you at least explain the navigation steps to get to these buttons. I need to be able to print statements. Thanks.

mukoya wrote on Monday, May 16, 2011:

Disclaimer: The writer of this post is not Tony and his views do not in any way represent the views or beliefs of Tony -:slight_smile:

That said, this is how I usually get there:

Log in with admin or accountant privileges.

Navigate to Fees>Billing.

On the right of the screen, you will see a link “” , Click on this link.

The links you are looking for are now visible.

To print, enter the necessary details and click search. Select the invoice(s) you would like to print by checking the boxes on the right then click the desired button.