# Modifying prescription

**URL:** <https://community.open-emr.org/t/modifying-prescription/6445>\
**Category:** OpenEMR Development\
**Created:** [November 13, 2015, 10:55am UTC](https://community.open-emr.org/t/modifying-prescription/6445 "2015-11-13T10:55:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [November 13, 2015, 10:55am UTC](https://community.open-emr.org/t/modifying-prescription/6445/1 "2015-11-13T10:55:23Z")

</div>

**[jhunyan](https://sourceforge.net/u/jhunyan/)** wrote on [Friday, November 13, 2015](https://sourceforge.net/p/openemr/discussion/202506/thread/8d051656/#ef9e):

Hi,

I need some help and advise about modifying prescription. I am able to modify the codes in C.Prescription.class.php so it will be able to suit the way how Australia requires for the prescription to be printed out. However, I have trouble understanding the php code for provider federal drug ID and state license number to appear on the bottom of the page rather than on top. Please looks at line 494 and 507

The codes are as follows:

\<?php // 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. require\_once($GLOBALS['fileroot'] . "/library/classes/Controller.class.php"); require\_once($GLOBALS['fileroot'] . "/library/classes/Prescription.class.php"); require\_once($GLOBALS['fileroot'] . "/library/classes/Provider.class.php"); require\_once($GLOBALS['fileroot'] . "/library/classes/RXList.class.php"); require\_once($GLOBALS['fileroot'] . "/library/registry.inc"); require\_once($GLOBALS['fileroot'] . "/library/amc.php"); class C\_Prescription extends Controller { var $template\_mod; var $pconfig; var $providerid = 0; var $is\_faxing = false; var $is\_print\_to\_fax = false; function C\_Prescription($template\_mod = "general") { parent::Controller(); $this-\>template\_mod = $template\_mod; $this-\>assign("FORM\_ACTION", $GLOBALS['webroot']."/controller.php?" . $\_SERVER['QUERY\_STRING']); $this-\>assign("TOP\_ACTION", $GLOBALS['webroot']."/controller.php?" . "prescription" . "&"); $this-\>assign("STYLE", $GLOBALS['style']); $this-\>assign("WEIGHT\_LOSS\_CLINIC", $GLOBALS['weight\_loss\_clinic']); $this-\>assign("SIMPLIFIED\_PRESCRIPTIONS", $GLOBALS['simplified\_prescriptions']); $this-\>pconfig = $GLOBALS['oer\_config']['prescriptions']; $this-\>assign("CSS\_HEADER", $GLOBALS['css\_header'] ); $this-\>assign("WEB\_ROOT", $GLOBALS['webroot'] ); if ($GLOBALS['inhouse\_pharmacy']) { // Make an array of drug IDs and selectors for the template. $drug\_array\_values = array(0); $drug\_array\_output = array("-- " . xl('or select from inventory') ." --"); $drug\_attributes = ''; // $res = sqlStatement("SELECT \* FROM drugs ORDER BY selector"); $res = sqlStatement("SELECT d.name, d.ndc\_number, d.form, d.size, " . "d.unit, d.route, d.substitute, t.drug\_id, t.selector, t.dosage, " . "t.period, t.quantity, t.refills " . "FROM drug\_templates AS t, drugs AS d WHERE " . "d.drug\_id = t.drug\_id ORDER BY t.selector"); while ($row = sqlFetchArray($res)) { $tmp\_output = $row['selector']; if ($row['ndc\_number']) { $tmp\_output .= ' [' . $row['ndc\_number'] . ']'; } $drug\_array\_values[] = $row['drug\_id']; $drug\_array\_output[] = $tmp\_output; if ($drug\_attributes) $drug\_attributes .= ','; $drug\_attributes .= "['" . $row['name'] . "'," . // 0 $row['form'] . ",'" . // 1 $row['dosage'] . "'," . // 2 $row['size'] . "," . // 3 $row['unit'] . "," . // 4 $row['route'] . "," . // 5 $row['period'] . "," . // 6 $row['substitute'] . "," . // 7 $row['quantity'] . "," . // 8 $row['refills'] . "," . // 9 $row['quantity'] . "]"; // 10 quantity per\_refill } $this-\>assign("DRUG\_ARRAY\_VALUES", $drug\_array\_values); $this-\>assign("DRUG\_ARRAY\_OUTPUT", $drug\_array\_output); $this-\>assign("DRUG\_ATTRIBUTES", $drug\_attributes); } } function default\_action() { $this-\>assign("prescription",$this-\>prescriptions[0]); $this-\>display($GLOBALS['template\_dir'] . "prescription/" . $this-\>template\_mod . "\_edit.html"); } function edit\_action($id = "",$patient\_id="",$p\_obj = null) { if ($p\_obj != null && get\_class($p\_obj) == "prescription") { $this-\>prescriptions[0] = $p\_obj; } elseif (get\_class($this-\>prescriptions[0]) != "prescription" ) { $this-\>prescriptions[0] = new Prescription($id); } if (!empty($patient\_id)) { $this-\>prescriptions[0]-\>set\_patient\_id($patient\_id); } // If quantity to dispense is not already set from a POST, set its // default value. if (! $this-\>get\_template\_vars('DISP\_QUANTITY')) { $this-\>assign('DISP\_QUANTITY', $this-\>prescriptions[0]-\>quantity); } $this-\>default\_action(); } function list\_action($id,$sort = "") { if (empty($id)) { $this-\>function\_argument\_error(); exit; } if (!empty($sort)) { $this-\>assign("prescriptions", Prescription::prescriptions\_factory($id,$sort)); } else { $this-\>assign("prescriptions", Prescription::prescriptions\_factory($id)); } // flag to indicate the CAMOS form is regsitered and active $this-\>assign("CAMOS\_FORM", isRegistered("CAMOS")); $this-\>display($GLOBALS['template\_dir'] . "prescription/" . $this-\>template\_mod . "\_list.html"); } function block\_action($id,$sort = "") { if (empty($id)) { $this-\>function\_argument\_error(); exit; } if (!empty($sort)) { $this-\>assign("prescriptions", Prescription::prescriptions\_factory($id,$sort)); } else { $this-\>assign("prescriptions", Prescription::prescriptions\_factory($id)); } //print\_r(Prescription::prescriptions\_factory($id)); $this-\>display($GLOBALS['template\_dir'] . "prescription/" . $this-\>template\_mod . "\_block.html"); } function fragment\_action($id,$sort = "") { if (empty($id)) { $this-\>function\_argument\_error(); exit; } if (!empty($sort)) { $this-\>assign("prescriptions", Prescription::prescriptions\_factory($id,$sort)); } else { $this-\>assign("prescriptions", Prescription::prescriptions\_factory($id)); } //print\_r(Prescription::prescriptions\_factory($id)); $this-\>display($GLOBALS['template\_dir'] . "prescription/" . $this-\>template\_mod . "\_fragment.html"); } function lookup\_action() { $this-\>do\_lookup(); $this-\>display($GLOBALS['template\_dir'] . "prescription/" . $this-\>template\_mod . "\_lookup.html"); } function edit\_action\_process() { if ($\_POST['process'] != "true") return; //print\_r($\_POST); // Stupid Smarty code treats empty values as not specified values. // Since active is a checkbox, represent the unchecked state as -1. if (empty($\_POST['active'])) $\_POST['active'] = '-1'; $this-\>prescriptions[0] = new Prescription($\_POST['id']); parent::populate\_object($this-\>prescriptions[0]); //echo $this-\>prescriptions[0]-\>toString(true); $this-\>prescriptions[0]-\>persist(); $\_POST['process'] = ""; // If the "Prescribe and Dispense" button was clicked, then // redisplay as in edit\_action() but also replicate the fee and // include a piece of javascript to call dispense(). // if ($\_POST['disp\_button']) { $this-\>assign("DISP\_QUANTITY", $\_POST['disp\_quantity']); $this-\>assign("DISP\_FEE", $\_POST['disp\_fee']); $this-\>assign("ENDING\_JAVASCRIPT", "dispense();"); $this-\>\_state = false; return $this-\>edit\_action($this-\>prescriptions[0]-\>id); } // Set the AMC reporting flag (to record percentage of prescriptions that // are set as e-prescriptions) if (!(empty($\_POST['escribe\_flag']))) { // add the e-prescribe flag processAmcCall('e\_prescribe\_amc', true, 'add', $this-\>prescriptions[0]-\>get\_patient\_id(), 'prescriptions', $this-\>prescriptions[0]-\>id); } else { // remove the e-prescribe flag processAmcCall('e\_prescribe\_amc', true, 'remove', $this-\>prescriptions[0]-\>get\_patient\_id(), 'prescriptions', $this-\>prescriptions[0]-\>id); } // TajEmo Work by CB 2012/05/29 02:58:29 PM to stop from going to send screen. Improves Work Flow // if ($this-\>prescriptions[0]-\>get\_active() \> 0) { // return $this-\>send\_action($this-\>prescriptions[0]-\>id); // } $this-\>list\_action($this-\>prescriptions[0]-\>get\_patient\_id()); exit; } function send\_action($id) { $\_POST['process'] = "true"; if(empty($id)) { $this-\>function\_argument\_error(); } $rx = new Prescription($id); // Populate pharmacy info if the patient has a default pharmacy. // Probably the Prescription object should handle this instead, but // doing it there will require more careful research and testing. $prow = sqlQuery("SELECT pt.pharmacy\_id FROM prescriptions AS rx, " . "patient\_data AS pt WHERE rx.id = '$id' AND pt.pid = rx.patient\_id"); if ($prow['pharmacy\_id']) { $rx-\>pharmacy-\>set\_id($prow['pharmacy\_id']); $rx-\>pharmacy-\>populate(); } $this-\>assign("prescription", $rx); $this-\>\_state = false; return $this-\>fetch($GLOBALS['template\_dir'] . "prescription/" . $this-\>template\_mod . "\_send.html"); } function multiprintfax\_header(& $pdf, $p) { return $this-\>multiprint\_header( $pdf, $p ); } function multiprint\_header(& $pdf, $p) { $this-\>providerid = $p-\>provider-\>id; //print header $pdf-\>ezImage($GLOBALS['oer\_config']['prescriptions']['logo'],'','50','','center',''); $pdf-\>ezColumnsStart(array('num'=\>2, 'gap'=\>10)); $res = sqlQuery("SELECT concat(' **',f.name,'** \n',f.street,'\n',f.city,', ',f.state,' ',f.postal\_code,'\nTel:',f.phone,if(f.fax != '',concat('\nFax: ',f.fax),'')) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id ='" . mysql\_real\_escape\_string($p-\>provider-\>id) . "'"); $pdf-\>ezText($res['addr'],12); $my\_y = $pdf-\>y; $pdf-\>ezNewPage(); $pdf-\>ezText('**' . $p-\>provider-\>get\_name\_display() . '**',12); // A client had a bad experience with a patient misusing a DEA number, so // now the doctors write those in on printed prescriptions and only when // necessary. If you need to change this back, then please make it a // configurable option. Faxed prescriptions were not changed. -- Rod // Now it is configureable. Change value in // Administration-\>Globals-\>Rx if ($GLOBALS['rx\_enable\_DEA']) { if ($this-\>is\_faxing || $GLOBALS['rx\_show\_DEA']) { $pdf-\>ezText('**' . xl('DEA') . ':**' . $p-\>provider-\>federal\_drug\_id, 12); } else { $pdf-\>ezText('**' . xl('DEA') . ':** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_', 12); } } if ($GLOBALS['rx\_enable\_NPI']) { if ($this-\>is\_faxing || $GLOBALS['rx\_show\_NPI']) { $pdf-\>ezText('**' . xl('NPI') . ':**' . $p-\>provider-\>npi, 12); } else { $pdf-\>ezText('**' . xl('NPI') . ':** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_', 12); } } if ($GLOBALS['rx\_enable\_SLN']) { if ($this-\>is\_faxing || $GLOBALS['rx\_show\_SLN']) { $pdf-\>ezText('**' . xl('State Lic. #') . ':**' . $p-\>provider-\>state\_license\_number, 12); } else { $pdf-\>ezText('**' . xl('State Lic. #') . ':** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_', 12); } } $pdf-\>ezColumnsStop(); if ($my\_y \< $pdf-\>y){ $pdf-\>ezSetY($my\_y); } $pdf-\>ezText('',10); $pdf-\>setLineStyle(1); $pdf-\>ezColumnsStart(array('num'=\>2)); $pdf-\>line($pdf-\>ez['leftMargin'],$pdf-\>y,$pdf-\>ez['pageWidth']-$pdf-\>ez['rightMargin'],$pdf-\>y); $pdf-\>ezText('**' . xl('Patient Name & Address') . '**',6); $pdf-\>ezText($p-\>patient-\>get\_name\_display(),10); $res = sqlQuery("SELECT concat(street,'\n',city,', ',state,' ',postal\_code,'\n',if(phone\_home!='',phone\_home,if(phone\_cell!='',phone\_cell,if(phone\_biz!='',phone\_biz,'')))) addr from patient\_data where pid =". mysql\_real\_escape\_string ($p-\>patient-\>id)); $pdf-\>ezText($res['addr']); $my\_y = $pdf-\>y; $pdf-\>ezNewPage(); $pdf-\>line($pdf-\>ez['leftMargin'],$pdf-\>y,$pdf-\>ez['pageWidth']-$pdf-\>ez['rightMargin'],$pdf-\>y); $pdf-\>ezText('**' . xl('Date of Birth') . '**',6); $pdf-\>ezText($p-\>patient-\>date\_of\_birth,10); $pdf-\>ezText(''); $pdf-\>line($pdf-\>ez['leftMargin'],$pdf-\>y,$pdf-\>ez['pageWidth']-$pdf-\>ez['rightMargin'],$pdf-\>y); $pdf-\>ezText('**' . xl('Medical Record #') . '**',6); $pdf-\>ezText(str\_pad($p-\>patient-\>get\_pubpid(), 10, "0", STR\_PAD\_LEFT),10); $pdf-\>ezColumnsStop(); if ($my\_y \< $pdf-\>y){ $pdf-\>ezSetY($my\_y); } $pdf-\>ezText(''); $pdf-\>line($pdf-\>ez['leftMargin'],$pdf-\>y,$pdf-\>ez['pageWidth']-$pdf-\>ez['rightMargin'],$pdf-\>y); $pdf-\>ezText('**' . xl('Prescriptions') . '**',6); $pdf-\>ezText('',10); } function multiprintcss\_header($p) { echo("
\n"); $this-\>providerid = $p-\>provider-\>id; echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("

| \n"); $res = sqlQuery("SELECT concat(' **',f.name,'** \n',f.street,'\n',f.city,', ',f.state,' ',f.postal\_code,'\nTel:',f.phone,if(f.fax != '',concat('\nFax: ',f.fax),'')) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id ='" . mysql\_real\_escape\_string($p-\>provider-\>id) . "'"); $patterns = array ('/\n/','/Tel:/','/Fax:/'); $replace = array ('  
', xl('Tel').':', xl('Fax').':'); $res = preg\_replace($patterns, $replace, $res); echo ('' . $res['addr'] . ''); echo (" | \n"); $res = sqlQuery("SELECT concat(' **',f.name,'** \n',f.street,'\n',f.city,', ',f.state,' ',f.postal\_code,'\nTel:',f.phone,if(f.fax != '',concat('\nFax: ',f.fax),'')) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id ='" . mysql\_real\_escape\_string($p-\>provider-\>id) . "'"); $patterns = array ('/\n/','/Tel:/','/Fax:/'); $replace = array ('  
', xl('Tel').':', xl('Fax').':'); $res = preg\_replace($patterns, $replace, $res); echo ('' . $res['addr'] . ''); echo (" |
|
| |
| \n"); echo ('**' . xl('Patient Name & Address') . '**'. '  
'); echo ($p-\>patient-\>get\_name\_display() . '  
'); $res = sqlQuery("SELECT concat(street,'\n',city,', ',state,' ',postal\_code,'\n',if(phone\_home!='',phone\_home,if(phone\_cell!='',phone\_cell,if(phone\_biz!='',phone\_biz,'')))) addr from patient\_data where pid =". mysql\_real\_escape\_string ($p-\>patient-\>id)); $patterns = array ('/\n/'); $replace = array ('  
'); $res = preg\_replace($patterns, $replace, $res); echo ($res['addr']); echo ('**' . xl('Date of Birth') . '**' . '  
'); echo ($p-\>patient-\>date\_of\_birth . '  
' ); echo (" | \n"); echo ('**' . xl('Patient Name & Address') . '**'. '  
'); echo ($p-\>patient-\>get\_name\_display() . '  
'); $res = sqlQuery("SELECT concat(street,'\n',city,', ',state,' ',postal\_code,'\n',if(phone\_home!='',phone\_home,if(phone\_cell!='',phone\_cell,if(phone\_biz!='',phone\_biz,'')))) addr from patient\_data where pid =". mysql\_real\_escape\_string ($p-\>patient-\>id)); $patterns = array ('/\n/'); $replace = array ('  
'); $res = preg\_replace($patterns, $replace, $res); echo ($res['addr']); echo ('**' . xl('Date of Birth') . '**' . '  
'); echo ($p-\>patient-\>date\_of\_birth ); echo (" |
|
| |
| \n"); echo ('**' . xl('Prescriptions') . '**'); echo (" | \n"); echo ('**' . xl('Prescriptions') . '**'); echo (" |

\n"); } function multiprintcss\_preheader() { // this sets styling and other header information of the multiprint css sheet echo ("\n"); echo ("\n"); echo ("\n"); echo ("div {\n"); echo (" padding: 0;\n"); echo (" margin: 0;\n"); echo ("}\n"); echo ("body {\n"); echo (" font-family: sans-serif;\n"); echo (" font-weight: normal;\n"); echo (" font-size: 10pt;\n"); echo (" background: white;\n"); echo (" color: black;\n"); echo ("}\n"); echo ("span.large {\n"); echo (" font-size: 12pt;\n"); echo ("}\n"); echo ("span.small {\n"); echo (" font-size: 6pt;\n"); echo ("}\n"); echo ("td {\n"); echo (" vertical-align: top;\n"); echo (" width: 50%;\n"); echo (" font-size: 10pt;\n"); echo (" padding-bottom: 8pt;\n"); echo ("}\n"); echo ("td.bordered {\n"); echo (" border-top:1pt solid black;\n"); echo ("}\n"); echo ("div.paddingdiv {\n"); echo (" width: 524pt;\n"); echo (" height: 668pt;\n"); echo ("}\n"); echo ("div.scriptdiv {\n"); echo (" padding-top: 12pt;\n"); echo (" padding-left: 0pt;\n"); echo (" padding-bottom: 22pt;\n"); echo (" float: left;\n"); echo ("}\n"); echo ("div.scriptdiv1 {\n"); echo (" padding-top: 12pt;\n"); echo (" padding-bottom: 22pt;\n"); echo (" padding-left: 35pt;\n"); echo (" float: right;\n"); echo (" padding-right: 54px;\n"); echo ("}\n"); echo ("div.signdiv {\n"); echo (" margin-top: -22px;\n"); echo (" font-size: 15px;\n"); echo (" float: left;\n"); echo ("}\n"); echo ("div.signdiv1 {\n"); echo (" margin-top: -24px;\n"); echo (" padding: 1px;\n"); echo (" float: right;\n"); echo (" margin-right: 13px;\n"); echo (" font-size: 15px;\n"); echo ("}\n"); echo ("\n"); echo ("" . xl('Prescription') . "\n"); echo ("\n"); echo ("\n"); } function multiprintfax\_footer( & $pdf ) { return $this-\>multiprint\_footer( $pdf ); } function multiprint\_footer(& $pdf) { if($this-\>pconfig['use\_signature'] && ( $this-\>is\_faxing || $this-\>is\_print\_to\_fax ) ) { $sigfile = str\_replace('{userid}', $\_SESSION{"authUser"}, $this-\>pconfig['signature']); if (file\_exists($sigfile)) { $pdf-\>ezText( xl('Signature') . ": ",12); // $pdf-\>ezImage($sigfile, "", "", "none", "left"); $pdf-\>ezImage($sigfile, "", "", "none", "center"); $pdf-\>ezText( xl('Date') . ": " . date('Y-m-d'), 12); if ( $this-\>is\_print\_to\_fax ) { $pdf-\>ezText(xl('Please do not accept this prescription unless it was received via facsimile.')); } $addenumFile = $this-\>pconfig['addendum\_file']; if ( file\_exists( $addenumFile ) ) { $pdf-\>ezText(''); $f = fopen($addenumFile, "r"); while ( $line = fgets($f, 1000) ) { $pdf-\>ezText(rtrim($line)); } } return; } } $pdf-\>ezText("\n\n\n\n" . xl('Signature') . ":\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\n" . xl('Date') . ": " . date('Y-m-d'),12); } function multiprintcss\_footer() { echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
\n"); echo (xl('Signature') . ":\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
"); echo ('**'. xl('Date') . ": " . date('Y-m-d'). '  
'); //Need codes for provider federal ID and state license number echo ("**
\n"); echo ("\n"); echo ("\n"); echo ("
\n"); echo (xl('Signature') . ":\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
"); echo ('**'. xl('Date') . ": " . date('Y-m-d'). '  
'); //Need codes for provider federal ID and state license number echo ("**
\n"); echo ("\n"); echo ("\n"); echo ("\n"); } function multiprintcss\_postfooter() { echo("\n"); echo("\n"); echo("\n"); } function get\_prescription\_body\_text($p) { $body = '**' . xl('Rx') . ': ' . $p-\>get\_drug() . ' ' . $p-\>get\_size() . ' ' . $p-\>get\_unit\_display(); if ($p-\>get\_form()) $body .= ' [' . $p-\>form\_array[$p-\>get\_form()] . "]"; $body .= "**_" . $p-\>substitute\_array[$p-\>get\_substitute()] . "_\n" . '**' . xl('Disp #') . ':**' . $p-\>get\_quantity() . "\n" . '**' . xl('Sig') . ':**' . $p-\>get\_dosage() . ' ' . $p-\>form\_array[$p-\>get\_form()] . ' ' . $p-\>route\_array[$p-\>get\_route()] . ' ' . $p-\>interval\_array[$p-\>get\_interval()] . "\n"; if ($p-\>get\_refills() \> 0) { $body .= "\n**" . xl('Refills') . ":**" . $p-\>get\_refills(); if ($p-\>get\_per\_refill()) { $body .= " " . xl('of quantity') . " " . $p-\>get\_per\_refill(); } $body .= "\n"; } else { $body .= "\n**" . xl('Refills') . ":** 0 (" . xl('Zero') . ")\n"; } $note = $p-\>get\_note(); if ($note != '') { $body .= "\n$note\n"; } return $body; } function multiprintfax\_body(& $pdf, $p){ return $this-\>multiprint\_body( $pdf, $p ); } function multiprint\_body(& $pdf, $p){ $pdf-\>ez['leftMargin'] += $pdf-\>ez['leftMargin']; $pdf-\>ez['rightMargin'] += $pdf-\>ez['rightMargin']; $d = $this-\>get\_prescription\_body\_text($p); if ( $pdf-\>ezText($d,10,array(),1) ) { $pdf-\>ez['leftMargin'] -= $pdf-\>ez['leftMargin']; $pdf-\>ez['rightMargin'] -= $pdf-\>ez['rightMargin']; $this-\>multiprint\_footer($pdf); $pdf-\>ezNewPage(); $this-\>multiprint\_header($pdf, $p); $pdf-\>ez['leftMargin'] += $pdf-\>ez['leftMargin']; $pdf-\>ez['rightMargin'] += $pdf-\>ez['rightMargin']; } $my\_y = $pdf-\>y; $pdf-\>ezText($d,10); if($this-\>pconfig['shading']) { $pdf-\>setColor(.9,.9,.9); $pdf-\>filledRectangle($pdf-\>ez['leftMargin'],$pdf-\>y,$pdf-\>ez['pageWidth']-$pdf-\>ez['rightMargin']-$pdf-\>ez['leftMargin'],$my\_y - $pdf-\>y); $pdf-\>setColor(0,0,0); } $pdf-\>ezSetY($my\_y); $pdf-\>ezText($d,10); $pdf-\>ez['leftMargin'] = $GLOBALS['rx\_left\_margin']; $pdf-\>ez['rightMargin'] = $GLOBALS['rx\_right\_margin']; $pdf-\>ezText(''); $pdf-\>line($pdf-\>ez['leftMargin'],$pdf-\>y,$pdf-\>ez['pageWidth']-$pdf-\>ez['rightMargin'],$pdf-\>y); $pdf-\>ezText(''); } function multiprintcss\_body($p){ $d = $this-\>get\_prescription\_body\_text($p); $patterns = array ('/\n/','/ /'); $replace = array ('  
','&nbsp;&nbsp;&nbsp;&nbsp;'); $d = preg\_replace($patterns, $replace, $d); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
\n" . $d . "\n"); echo ("
\n"); echo ("\n"); echo ("\n"); echo ("
\n" . $d . "\n"); echo ("
\n"); echo ("\n"); echo ("\n"); echo ("\n"); } function multiprintfax\_action($id = "") { $this-\>is\_print\_to\_fax=true; return $this-\>multiprint\_action( $id ); } function multiprint\_action($id = "") { $\_POST['process'] = "true"; if(empty($id)) { $this-\>function\_argument\_error(); } require\_once ($GLOBALS['fileroot'] . "/library/classes/class.ezpdf.php"); $pdf =& new Cezpdf($GLOBALS['rx\_paper\_size']); $pdf-\>ezSetMargins($GLOBALS['rx\_top\_margin'] ,$GLOBALS['rx\_bottom\_margin'] ,$GLOBALS['rx\_left\_margin'] ,$GLOBALS['rx\_right\_margin'] ); $pdf-\>selectFont($GLOBALS['fileroot'] . "/library/fonts/Helvetica.afm"); // $print\_header = true; $on\_this\_page = 0; //print prescriptions body $this-\>\_state = false; // Added by Rod - see Controller.class.php $ids = preg\_split('/::/', substr($id,1,strlen($id) - 2), -1, PREG\_SPLIT\_NO\_EMPTY); foreach ($ids as $id) { $p = new Prescription($id); // if ($print\_header == true) { if ($on\_this\_page == 0) { $this-\>multiprint\_header($pdf, $p); } if (++$on\_this\_page \> 3 || $p-\>provider-\>id != $this-\>providerid) { $this-\>multiprint\_footer($pdf); $pdf-\>ezNewPage(); $this-\>multiprint\_header($pdf, $p); // $print\_header = false; $on\_this\_page = 1; } $this-\>multiprint\_body($pdf, $p); } $this-\>multiprint\_footer($pdf); $pdf-\>ezStream(); return; } function multiprintcss\_action($id = "") { $\_POST['process'] = "true"; if(empty($id)) { $this-\>function\_argument\_error(); } $this-\>multiprintcss\_preheader(); $this-\>\_state = false; // Added by Rod - see Controller.class.php $ids = preg\_split('/::/', substr($id,1,strlen($id) - 2), -1, PREG\_SPLIT\_NO\_EMPTY); $on\_this\_page = 0; foreach ($ids as $id) { $p = new Prescription($id); if ($on\_this\_page == 0) { $this-\>multiprintcss\_header($p); } if (++$on\_this\_page \> 3 || $p-\>provider-\>id != $this-\>providerid) { $this-\>multiprintcss\_footer(); $this-\>multiprintcss\_header($p); $on\_this\_page = 1; } $this-\>multiprintcss\_body($p); } $this-\>multiprintcss\_footer(); $this-\>multiprintcss\_postfooter(); return; } function send\_action\_process($id) { $dummy = ""; // Added by Rod to avoid run-time warnings if ($\_POST['process'] != "true") return; if(empty($id)) { $this-\>function\_argument\_error(); } $p = new Prescription($id); switch ($\_POST['submit']) { case (xl("Print")." (".xl("PDF").")"): // The following statement added by Rod. // Looking at Controller.class.php, it appears that \_state is set to false // to indicate that no further HTML is to be generated. $this-\>\_state = false; // Added by Rod - see Controller.class.php return $this-\>\_print\_prescription($p, $dummy); break; case (xl("Print")." (".xl("HTML").")"): $this-\>\_state = false; return $this-\>\_print\_prescription\_css($p, $dummy); break; case xl("Print To Fax"): $this-\>\_state = false; $this-\>is\_print\_to\_fax = true; return $this-\>\_print\_prescription($p, $dummy); break; case xl("Email"): return $this-\>\_email\_prescription($p,$\_POST['email\_to']); break; case xl("Fax"): //this is intended to be the hook for the hylafax code we already have that hasn't worked its way into the tree yet. //$this-\>assign("process\_result","No fax server is currently setup."); return $this-\>\_fax\_prescription($p,$\_POST['fax\_to']); break; case xl("Auto Send"): $pharmacy\_id = $\_POST['pharmacy\_id']; //echo "auto sending to : " . $\_POST['pharmacy\_id']; $phar = new Pharmacy($\_POST['pharmacy\_id']); //print\_r($phar); if ($phar-\>get\_transmit\_method() == TRANSMIT\_PRINT) { return $this-\>\_print\_prescription($p, $dummy); } elseif ($phar-\>get\_transmit\_method() == TRANSMIT\_EMAIL) { $email = $phar-\>get\_email(); if (!empty($email)) { return $this-\>\_email\_prescription($p,$phar-\>get\_email()); } //else print it } elseif ($phar-\>get\_transmit\_method() == TRANSMIT\_FAX) { $faxNum= $phar-\>get\_fax(); if(!empty($faxNum)) { Return $this-\>\_fax\_prescription ($p,$faxNum); } // return $this-\>assign("process\_result","No fax server is currently setup."); // else default is printing, } else { //the pharmacy has no default or default is print return $this-\>\_print\_prescription($p, $dummy); } break; } return; } function \_print\_prescription($p, & $toFile) { require\_once ($GLOBALS['fileroot'] . "/library/classes/class.ezpdf.php"); $pdf =& new Cezpdf($GLOBALS['rx\_paper\_size']); $pdf-\>ezSetMargins($GLOBALS['rx\_top\_margin'] ,$GLOBALS['rx\_bottom\_margin'] ,$GLOBALS['rx\_left\_margin'] ,$GLOBALS['rx\_right\_margin'] ); $pdf-\>selectFont($GLOBALS['fileroot'] . "/library/fonts/Helvetica.afm"); // Signature images are to be used only when faxing. if(!empty($toFile)) $this-\>is\_faxing = true; $this-\>multiprint\_header($pdf, $p); $this-\>multiprint\_body($pdf, $p); $this-\>multiprint\_footer($pdf); if(!empty($toFile)) { $toFile = $pdf-\>ezOutput(); } else { $pdf-\>ezStream(); // $pdf-\>ezStream(array('compress' =\> 0)); // for testing with uncompressed output } return; } function \_print\_prescription\_css($p, & $toFile) { $this-\>multiprintcss\_preheader(); $this-\>multiprintcss\_header($p); $this-\>multiprintcss\_body($p); $this-\>multiprintcss\_footer(); $this-\>multiprintcss\_postfooter(); } function \_print\_prescription\_old($p, & $toFile) { require\_once ($GLOBALS['fileroot'] . "/library/classes/class.ezpdf.php"); $pdf =& new Cezpdf($GLOBALS['rx\_paper\_size']); $pdf-\>ezSetMargins($GLOBALS['rx\_top\_margin'] ,$GLOBALS['rx\_bottom\_margin'] ,$GLOBALS['rx\_left\_margin'] ,$GLOBALS['rx\_right\_margin'] ); $pdf-\>selectFont($GLOBALS['fileroot'] . "/library/fonts/Helvetica.afm"); if(!empty($this-\>pconfig['logo'])) { $pdf-\>ezImage($this-\>pconfig['logo'],"","","none","left"); } $pdf-\>ezText($p-\>get\_prescription\_display(),10); if($this-\>pconfig['use\_signature']) { $pdf-\>ezImage($this-\>pconfig['signature'],"","","none","left"); } else{ $pdf-\>ezText("\n\n\n\nSignature:\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_",10); } if(!empty($toFile)) { $toFile = $pdf-\>ezOutput(); } else { $pdf-\>ezStream(); // $pdf-\>ezStream(array('compress' =\> 0)); // for testing with uncompressed output } return; } function \_email\_prescription($p,$email) { if (empty($email)) { $this-\>assign("process\_result","Email could not be sent, the address supplied: '$email' was empty or invalid."); return; } require($GLOBALS['fileroot'] . "/library/classes/class.phpmailer.php"); $mail = new PHPMailer(); $mail-\>SetLanguage("en",$GLOBALS['fileroot'] . "/library/" ); //this is a temporary config item until the rest of the per practice billing settings make their way in $mail-\>From = $GLOBALS['practice\_return\_email\_path']; $mail-\>FromName = $p-\>provider-\>get\_name\_display(); $mail-\>isMail(); $mail-\>Host = "localhost"; $mail-\>Mailer = "mail"; $text\_body = $p-\>get\_prescription\_display(); $mail-\>Body = $text\_body; $mail-\>Subject = "Prescription for: " . $p-\>patient-\>get\_name\_display(); $mail-\>AddAddress($email); if($mail-\>Send()) { $this-\>assign("process\_result","Email was successfully sent to: " . $email); return; } else { $this-\>assign("process\_result","There has been a mail error sending to " . $\_POST['email\_to'] . " " . $mail-\>ErrorInfo); return; } } function do\_lookup() { if ($\_POST['process'] != "true") { // don't do a lookup $this-\>assign("drug", $\_GET['drug']); return; } // process the lookup $this-\>assign("drug", $\_POST['drug']); $list = array(); if (!empty($\_POST['drug'])) { $list = @RxList::get\_list($\_POST['drug']); } if (is\_array($list)) { $list = array\_flip($list); $this-\>assign("drug\_options",$list); $this-\>assign("drug\_values",array\_keys($list)); } else { $this-\>assign("NO\_RESULTS","No results found for: " .$\_POST['drug'] . "  
"); } //print\_r($\_POST); //$this-\>assign("PROCESS",""); $\_POST['process'] = ""; } function \_fax\_prescription($p,$faxNum) { $err = "Sent fax"; //strip - ,(, ), and ws $faxNum = preg\_replace("/(-\*)(\(\*)(\)\*)(\s\*)/","",$faxNum); //validate the number if(!empty($faxNum) && is\_numeric($faxNum)) { //get the sendfax command and execute it $cmd = $this-\>pconfig['sendfax']; // prepend any prefix to the fax number $pref=$this-\>pconfig['prefix']; $faxNum=$pref.$faxNum; if(empty($cmd)) { $err .= " Send fax not set in includes/config.php"; break; } else { //generate file to fax $faxFile = "Failed"; $this-\>\_print\_prescription($p, $faxFile); if(empty($faxFile)) { $err .= " \_print\_prescription returned empty file"; break; } $fileName = $GLOBALS['OE\_SITE\_DIR'] . "/documents/" . $p-\>get\_id() . $p-\>get\_patient\_id() . "\_fax\_.pdf"; //print "filename is $fileName"; touch($fileName); // php bug $handle = fopen($fileName,"w"); if(!$handle) { $err .= " Failed to open file $fileName to write fax to"; break; } if(fwrite($handle, $faxFile) === false) { $err .= " Failed to write data to $fileName"; break; } fclose($handle); $args = " -n -d $faxNum $fileName"; //print "command is $cmd $args  
"; exec($cmd . $args); } } else { $err = "bad fax number passed to function"; } if($err) { $this-\>assign("process\_result",$err); } } } ?\>

The codes I intend to insert as below.

if ($GLOBALS[‘rx\_enable\_DEA’]) {  
if ($this-\>is\_faxing || $GLOBALS[‘rx\_show\_DEA’]) {  
$pdf-\>ezText(’**’ . xl(‘DEA’) . ‘:**’ . $p-\>provider-\>federal\_drug\_id, 12);  
}  
else {  
$pdf-\>ezText(’**’ . xl(‘DEA’) . ‘:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_’, 12);  
}  
}

```
if ($GLOBALS['rx_enable_NPI']) {
if ($this->is_faxing || $GLOBALS['rx_show_NPI']) {
        $pdf->ezText('<b>' . xl('NPI') . ':</b>' . $p->provider->npi, 12);
    }
else {
    $pdf->ezText('<b>' . xl('NPI') . ':</b> _________________________', 12);
    }
}
if ($GLOBALS['rx_enable_SLN']) {
    if ($this->is_faxing || $GLOBALS['rx_show_SLN']) {
        $pdf->ezText('<b>' . xl('State Lic. #') . ':</b>' . $p->provider->state_license_number, 12);
    }
else {
    $pdf->ezText('<b>' . xl('State Lic. #') . ':</b> ___________________', 12);
    }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [November 13, 2015, 3:36pm UTC](https://community.open-emr.org/t/modifying-prescription/6445/2 "2015-11-13T15:36:51Z")

</div>

**[fsgl](https://sourceforge.net/u/fsgl/)** wrote on [Friday, November 13, 2015](https://sourceforge.net/p/openemr/discussion/202506/thread/8d051656/#fbe3):

Can’t you move DEA & SLN codes from header to footer?

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [November 13, 2015, 7:23pm UTC](https://community.open-emr.org/t/modifying-prescription/6445/3 "2015-11-13T19:23:53Z")

</div>

**[epsdky](https://sourceforge.net/u/epsdky/)** wrote on [Friday, November 13, 2015](https://sourceforge.net/p/openemr/discussion/202506/thread/8d051656/#37f8):

Mixing PDF option code and HTML option code could be a problem

---

<div class="post-metadata">

**Author:** ![sergiors](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@sergiors](https://community.open-emr.org/u/sergiors)\
**Post date:** [October 11, 2021, 2:06pm UTC](https://community.open-emr.org/t/modifying-prescription/6445/4 "2021-10-11T14:06:36Z")

</div>

I also need to modify the prescription format for Ecuador requirements. They want a paper sheet that can be divided in 2 halves, with header in each one. One contains the drugs and it is kept by the pharmacy. The other contains the indications for the patient, and he keeps it.

Does anyone know how to do it?

---

<div class="post-metadata">

**Author:** ![stephenwaite](https://community.open-emr.org/user_avatar/community.open-emr.org/stephenwaite/32/15754_2.png) [@stephenwaite](https://community.open-emr.org/u/stephenwaite)\
**Post date:** [October 11, 2021, 2:13pm UTC](https://community.open-emr.org/t/modifying-prescription/6445/5 "2021-10-11T14:13:39Z")

</div>

hi @sergiors, see [Generate Prescription Rx Order PDF on OpenEMR](https://community.open-emr.org/t/generate-prescription-rx-order-pdf-on-openemr/17118/3)

---

<div class="post-metadata">

**Author:** ![Jen\_Ferrer](https://community.open-emr.org/user_avatar/community.open-emr.org/jen_ferrer/32/17260_2.png) [@Jen\_Ferrer](https://community.open-emr.org/u/Jen_Ferrer)\
**Post date:** [June 21, 2022, 7:30am UTC](https://community.open-emr.org/t/modifying-prescription/6445/6 "2022-06-21T07:30:02Z")

</div>

I also need to modify according to UAE standards but I am not a coder. Can Anyone help me, please? This is a big project and will help.

---

<div class="post-metadata">

**Author:** ![Jen\_Ferrer](https://community.open-emr.org/user_avatar/community.open-emr.org/jen_ferrer/32/17260_2.png) [@Jen\_Ferrer](https://community.open-emr.org/u/Jen_Ferrer)\
**Post date:** [June 21, 2022, 8:05am UTC](https://community.open-emr.org/t/modifying-prescription/6445/7 "2022-06-21T08:05:10Z")

</div>

have you gotten answers? did anyone help

---

<div class="post-metadata">

**Author:** ![gutiersa](https://community.open-emr.org/user_avatar/community.open-emr.org/gutiersa/32/11958_2.png) [@gutiersa](https://community.open-emr.org/u/gutiersa)\
**Post date:** [June 23, 2022, 2:21am UTC](https://community.open-emr.org/t/modifying-prescription/6445/8 "2022-06-23T02:21:19Z")

</div>

have your taken a look here?:

> [@OpenEMR version 5.0.1 programming four different prescription in the system](https://community.open-emr.org/t/openemr-version-5-0-1-programming-four-different-prescription-in-the-system/12066):
>
> I am using OpenEMR version 5.0.1.4 The hospital where i work has 4 different prescriptions. Each of he prescription have their insurance on it. They have their own logo. I have placed 4 radio buttons on the prescription form (general\_edit.html). The doctor can choose between the 4 prescriptions. I don’t know how to proceed. Can you please help me??

and

> [@Generate Prescription Rx Order PDF on OpenEMR](https://community.open-emr.org/t/generate-prescription-rx-order-pdf-on-openemr/17118/3):
>
> There’s a [zend module rx print thread](https://community.open-emr.org/t/openemr-version-5-0-1-programming-four-different-prescription-in-the-system/12066/2). You have to enable the module and then customize the file that’s referenced in the above link.

and

> [@Generate Prescription Rx Order PDF on OpenEMR](https://community.open-emr.org/t/generate-prescription-rx-order-pdf-on-openemr/17118/5):
>
> Add a script for a pt from the dashboard and you’ll find the print button
