3 // Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 //////////////////////////////////////////////////////////////////////
11 // This is a template for printing patient statements and collection
12 // letters. You must customize it to suit your practice. If your
13 // needs are simple then you do not need programming experience to do
14 // this - just read the comments and make appropriate substitutions.
15 //////////////////////////////////////////////////////////////////////
17 // The location/name of a temporary file to hold printable statements.
19 $STMT_TEMP_FILE = "/tmp/openemr_statements.txt";
21 // This is the command to be used for printing (without the filename).
22 // The word following "-P" should be the name of your printer. This
23 // example is designed for 8.5x11-inch paper with 1-inch margins,
24 // 10 CPI, 6 LPI, 65 columns, 54 lines per page.
26 $STMT_PRINT_CMD = "lpr -P SuperScript-870 -o cpi=10 -o lpi=6 -o page-left=72 -o page-top=72";
28 // This function builds a printable statement or collection letter from
29 // an associative array having the following keys:
31 // today = statement date yyyy-mm-dd
33 // patient = patient name
34 // amount = total amount due
35 // to = array of addressee name/address lines
36 // lines = array of lines, each with the following keys:
37 // dos = date of service yyyy-mm-dd
39 // amount = charge less adjustments
41 // notice = 1 for first notice, 2 for second, etc.
43 // The returned value is a string that can be sent to a printer.
44 // This example is plain text, but if you are a hotshot programmer
45 // then you could make a PDF or PostScript or whatever peels your
46 // banana. These strings are sent in succession, so append a form
47 // feed if that is appropriate.
49 function create_statement($stmt) {
50 if (! $stmt['pid']) return ""; // get out if no data
52 // This is the text for the top part of the page, up to but not
53 // including the detail lines. Some examples of variable fields are:
54 // %s = string with no minimum width
55 // %9s = right-justified string of 9 characters padded with spaces
56 // %-25s = left-justified string of 25 characters padded with spaces
57 // Note that "\n" is a line feed (new line) character.
60 "Your Business Name %-25s %s\n" .
61 "Address Line 1 Insurance information on file\n" .
63 "City
, State Zip Total amount due
: %s\n
" .
66 "ADDRESSEE
: REMIT TO
:\n" .
68 "%
-32s Your Remit
-To Name\n
" .
69 "%
-32s Your Remit
-To Address\n
" .
70 "%
-32s City
, State Zip\n
" .
74 " (Return above part with your payment by check
or money order
)\n" .
75 "-----------------------------------------------------------------\n" .
77 "_______________________ STATEMENT SUMMARY _______________________\n
" .
79 "Date of Service Description Charge Paid\n
" .
82 // These are the values for the variable fields. They must appear
83 // here in the same order as in the above text!
93 // This must be set to the number of lines generated above.
97 // This generates the detail lines. Again, note that the values must
98 // be specified in the order used.
100 foreach ($stmt['lines'] as $line) {
102 $out .= sprintf("%
-16s %
-30s%9s%9s\n
",
103 $line['dos'], // values start here
109 // This generates blank lines until we are at line 42.
111 while ($count++ < 42) $out .= "\n
";
113 // This is the bottom portion of the page. You know the drill.
116 "Name
: %
-25s Date
: %
-10s Due
:%8s\n
" .
117 "_________________________________________________________________\n
" .
119 "Thank you
for choosing
[Clinic name here
].\n" .
121 "Please call
if any of the above information is incorrect
.\n" .
122 "We appreciate prompt payment of balances due
.\n" .
124 "[Insert some name here
]\n" .
125 "Practice Manager\n
" .
126 "[Insert phone number here
]" .
127 "\014
", // this is a form feed
129 $stmt['patient'], // values start here