Modifying the prescriptions' pagination

avantsys wrote on Monday, August 25, 2014:

We’re facing an unprecedented (at least for us) requirement w.r.t. the way prescriptions are printed. As far as we’ve seen until now, OpenEMR allows for up to three or four medications (depending on the size of the provider’s logo) to be put on the same page of a prescription’s printout. If more medications are prescribed, then the remaining medications are placed on a new page, which includes (of course) the provider’s logo and data. That way, it looks as if it’s two separate prescriptions.

Now, as the entire project is coming to an end, our client has turned and said that this is undesirable. They want the prescription’s printout to include more medications (five, six, maybe more), because they view this as wasteful (in paper) and confusing (as it makes the patient think they were given two separate prescriptions). These are exactly the words of our client’s representative. I have to point out that the paper size used is A4.

Has anyone else faced such an issue? If yes, what changes did you make to the controllers/C_Prescription.class.php file in order to fit more medications on the same prescription page?

avantsys wrote on Monday, August 25, 2014:

For more information, here’s what we’ve encountered.

In line 451 of the controllers/C_Prescription.class.php file, there’s a function named get_prescription_body_text.

Now, although we’ve experimented with deleting a number of line breaks, this didn’t allow us to fit more than three medications on one prescription page (even after replacing the provider’s logo with an extremely small - 32 pixels high - version of it, or even omitting it entirely); the fourth, fifth and sixth medications were still put on a second page. The seventh, eighth, and ninth medications were put on the third page. And so on. Also, these experimentations simply led us to get more blank space on the bottom of the page.

So, this is what we’ve seen with the way prescriptions are printed. Any ideas on how to fit more (let’s say up to 10) medications on one prescription page and make better use of the available space on an A4 sheet (and satisfy the client’s new demand)?

blankev wrote on Monday, August 25, 2014:

If this explanation will do the job, you are ok. If not, you might ask Epdsky for help.

A great job done helping me out for small A6 prescriptions for the same provider name with clients getting prescriptions from different providers and printjob on pdf output.

Epdsky OpenEMR Medico-Developer 6-7-2014
T0: blankev@users.sf.net CC: epsdky@users.sf.net

Download the files from:

C_Prescription.class.php and general_list.html

files to…

C_Prescription.classOrig.php and general_listOrig.html

(where they are)

Then download archive file from Gist (Github) from
“Download Gist” link (top right) which has both my modified files in it…

(C_Prescription.classD2F1.php and general_listD2F2.html)

unzip and move to their directories and rename with the original filenames on the first part…

(Clear smarty cache)

Let us know if you came up with the A4 solution, it should be working, at least you will get the impression where to make changes.

avantsys wrote on Monday, August 25, 2014:

Thank you. We’ll try it out first thing in the morning. Right now we’re already way past our working hours. If we run into problems, I’ll let you know, but I hope everything will work out well. Thanks again.

avantsys wrote on Tuesday, August 26, 2014:

The pointers provided helped a lot. We tested them and they work properly; we managed to fit 7 medications in one prescription page. Thanks again.

blankev wrote on Tuesday, August 26, 2014:

If you put most of the recipe text next to each other with a space you must be able to get more than that ion one page.

Just don’t follow the ordinary Recipe format but make an efficient one:

Rx Paracetamol 500 mg; dtd 20; S/ 3 dd 1 (Don’t repeat)

Rx Broomhexine elixer 8mg/5ml; dtd 150 ml; 3 dd 5ml (don’t repeat, no substitution)

etc… (replace “\n” or
with apropiate characters.)

It is very unusual to have more than 10 prescriptions per patient.

avantsys wrote on Wednesday, August 27, 2014:

While experimenting with the solution proposed, we also found the following solution, which is the one we adopted in the end. I’m posting it here, in case anyone finds it useful. First of all, the part of the file that needed tweaking was the HTML. We adjusted all the margines, paddings and sizes accordingly. The “\n” bits suggested by Pieter were, of course, replaced.

Then, we went to line 581, where one can find the pagination functions. It was:

if (++$on_this_page > 3 || $p->provider->id != $this->providerid) {

This basically tells OpenEMR to allow up to 3 medications to be listed in one prescription page.

We changed it to

if (++$on_this_page > 7 || $p->provider->id != $this->providerid) {

That way, it now fits 7 medications on one printed page. To be honest, I think it’d be highly unlikely for anyone to prescribe more than 7 medications in one go. We also tried with higher values (8 and up), but the end results didn’t look good.

So, thanks again for the help, and here are our own findings and solutions as well.

blankev wrote on Wednesday, August 27, 2014:

I have one computer and two different printers. One printer for A4 paper and another printer with A6 paper.

Anybody with an idea to make software-matic a choice between printers for the A4 or A6 paper size printer. Just not to make the choice during printer after the PDF screen is shown, but automatic sofware-wise.

Any advise appreciated!