Formatting the statement.inc.php file, fixing the unaligned address in the invoice

growlingflea wrote on Wednesday, July 09, 2014:

Hi everyone. I am a new SW Developer at mi-squared and I recently received a question from a user that may be a common issue. Our user found that in the billing invoice, the format of the statement client address is about three characters too far to the left. Here I will walk the reader through viewing the invoice, reproducing the alignment error and demonstrate how to fix it.

Displaying the Invoice in a PDF Format

  • Make sure that you have the Patient selected. There should be charges and a history.
  • Under the Fees menu, select billing
  • Click on EOB's
  • This should open a new screen which allows you to search. Enter your criteria, press search
  • This will let you select PDF Download Statements Clicking on this will open the invoice. It is here where the "Client Address" is misaligned.

Fixing the Alignment

At the time of this entry, lines 169 - 172 of the statement.inc.php contain the 'sprintf' statements that control the alignment. The location of the file is in the openemr->sites->default folder.

The misaligned code looks like this:

$out .= sprintf("%-30s %-s\n",$label_addressee,$label_remitto);
$out .= sprintf("%-32s %s\n",$stmt[‘to’][0],$remit_name);
$out .= sprintf("%-32s %s\n",$stmt[‘to’][1],$remit_addr);
$out .= sprintf("%-32s %s\n",$stmt[‘to’][2],$remit_csz);

We correct it with this

$out .= sprintf("%-30s %-s\n",$label_addressee,$label_remitto);
$out .= sprintf("%-30s %s\n",$stmt[‘to’][0],$remit_name);
$out .= sprintf("%-30s %s\n",$stmt[‘to’][1],$remit_addr);
$out .= sprintf("%-30s %s\n",$stmt[‘to’][2],$remit_csz);

fr4nkie wrote on Wednesday, July 09, 2014:

Hi Daniel,

Welcome to the project! Funny after processing thousands of these, the misalignment never caught my eye. Looks to me that the clinic billing address is the text that is out of place. If that text was brought to the left a few spaces, it would line up with the patient info above the date below. What do you think?

blankev wrote on Wednesday, July 09, 2014:

Daniel,

welcome and I am looking forward to you explanations. This time I don’t get what you explained. To me the upper part and the correction part are the same as they are in the file…

Copy paste error, or am I missing something?

blankev wrote on Wednesday, July 09, 2014:

Just did some trial and error. I go for the:

$out .= sprintf("%-30s %-s\n",$label_addressee,$label_remitto);
$out .= sprintf("%-30s %s\n",$stmt[‘to’][0],$remit_name);
$out .= sprintf("%-30s %s\n",$stmt[‘to’][1],$remit_addr);
$out .= sprintf("%-30s %s\n",$stmt[‘to’][2],$remit_csz);

Tnx for the lesson and corrections.

blankev wrote on Wednesday, July 09, 2014:

I read on the third line "Total Amount due"and it is empty. Why? Is this on purpose or is it just because the Client has to calculate the rest amount…

fsgl wrote on Wednesday, July 09, 2014:

It may have been Rod’s intention to indent 2 spaces, which mirrors the code. See attachments.

Still good to know how to change it.

The thread about total due found here.

growlingflea wrote on Wednesday, July 09, 2014:

growlingflea wrote on Wednesday, July 09, 2014:

Copy and Paste error. I corrected it. Thanks for the heads up!!!

growlingflea wrote on Wednesday, July 09, 2014:

Yes. The text is out of place. Formating each line with %-30s fixes the issue.

growlingflea wrote on Wednesday, July 09, 2014:

There are two solutions to this and it depends on your preferences. The first bit of code will display the total amount due at the top of the page, filling the empty space with the total value. Note that at the bottom of the invoice, the total bill is redisplayed to the user.

$out  = sprintf("%-30s %-23s %-s\n",$clinic_name,$stmt['patient'],$stmt['today']);
$out .= sprintf("%-30s %s: %-s\n",$clinic_addr,$label_chartnum,$stmt['pid']);
$out .= sprintf("%-30s %-s\n",$clinic_csz,$label_insinfo);
$out .= sprintf("%-30s %s: %-s\n",null,$label_totaldue,$stmt['amount']);
$out .= "\n\n";

The other option is to remove the line containg the variable $label_totaldue, resulting in the total bill being displayed once, instead of twice.
``` $out = sprintf("%-30s %-23s %-s\n",$clinic_name,$stmt['patient'],$stmt['today']); $out .= sprintf("%-30s %s: %-s\n",$clinic_addr,$label_chartnum,$stmt['pid']); $out .= sprintf("%-30s %-s\n",$clinic_csz,$label_insinfo); $out .= "\n\n"; ```