setting version, preparing ubuntu packages and prepping links for release
[openemr.git] / interface / forms / CAMOS / rx_print.php
blob279d755507cd19de325cc0165f495fa4650bdca6
1 <?php
2 include_once ('../../globals.php');
3 include_once ('../../../library/sql.inc');
4 include_once ('../../../library/classes/Prescription.class.php');
5 include_once("../../../library/formdata.inc.php");
6 //practice data
7 $physician_name = '';
8 $practice_fname = '';
9 $practice_lname = '';
10 $practice_title = '';
11 $practice_address = '';
12 $practice_city = '';
13 $practice_state = '';
14 $practice_zip = '';
15 $practice_phone = '';
16 $practice_fax = '';
17 $practice_license = '';
18 $practice_dea = '';
19 //patient data
20 $patient_name = '';
21 $patient_address = '';
22 $patient_city = '';
23 $patient_state = '';
24 $patient_zip = '';
25 $patient_phone = '';
26 $patient_dob = '';
27 $sigline = array();
28 $sigline['plain'] =
29 "<div class='signature'>"
30 . " ______________________________________________<br/>"
31 . "</div>\n";
32 $sigline['embossed'] =
33 "<div class='signature'>"
34 . " _____________________________________________________<br/>"
35 # . "Signature - Valid for three days and in Broward County only."
36 . "Signature"
37 . "</div>\n";
38 $sigline['signed'] =
39 "<div class='sig'>"
40 . "<img src='./sig.jpg'>"
41 . "</div>\n";
42 $query = sqlStatement("select fname,lname,street,city,state,postal_code,phone_home,DATE_FORMAT(DOB,'%m/%d/%y') as DOB from patient_data where pid =" . $_SESSION['pid']);
43 if ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
44 $patient_name = $result['fname'] . ' ' . $result['lname'];
45 $patient_address = $result['street'];
46 $patient_city = $result['city'];
47 $patient_state = $result['state'];
48 $patient_zip = $result['postal_code'];
49 $patient_phone = $result['phone_home'];
50 $patient_dob = $result['DOB'];
52 //update user information if selected from form
53 if ($_POST['update']) { // OPTION update practice inf
54 $query = "update users set " .
55 "fname = '" . formData('practice_fname') . "', " .
56 "lname = '" . formData('practice_lname') . "', " .
57 "title = '" . formData('practice_title') . "', " .
58 "street = '" . formData('practice_address') . "', " .
59 "city = '" . formData('practice_city') . "', " .
60 "state = '" . formData('practice_state') . "', " .
61 "zip = '" . formData('practice_zip') . "', " .
62 "phone = '" . formData('practice_phone') . "', " .
63 "fax = '" . formData('practice_fax') . "', " .
64 "federaldrugid = '" . formData('practice_dea') . "' " .
65 "where id =" . $_SESSION['authUserID'];
66 sqlInsert($query);
68 //get user information
69 $query = sqlStatement("select * from users where id =" . $_SESSION['authUserID']);
70 if ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
71 $physician_name = $result['fname'] . ' ' . $result['lname'] . ', ' . $result['title'];
72 $practice_fname = $result['fname'];
73 $practice_lname = $result['lname'];
74 $practice_title = $result['title'];
75 $practice_address = $result['street'];
76 $practice_city = $result['city'];
77 $practice_state = $result['state'];
78 $practice_zip = $result['zip'];
79 $practice_phone = $result['phone'];
80 $practice_fax = $result['fax'];
81 $practice_dea = $result['federaldrugid'];
83 if ($_POST['print_pdf'] || $_POST['print_html']) {
84 $camos_content = array();
85 foreach ($_POST as $key => $val) {
86 if (substr($key,0,3) == 'ch_') {
87 $query = sqlStatement("select content from form_CAMOS where id =" .
88 substr($key,3));
89 if ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
90 if ($_POST['print_html']) { //do this change to formatting only for html output
91 $content = preg_replace('|\n|','<br/>', $result['content']);
92 $content = preg_replace('|<br/><br/>|','<br/>', $content);
93 } else {
94 $content = $result['content'];
96 array_push($camos_content,$content);
99 if (substr($key,0,5) == 'chrx_') {
100 $rx = new Prescription(substr($key,5));
101 //$content = $rx->drug.' '.$rx->form.' '.$rx->dosage;
102 $content = ''
103 . $rx->drug . ' '
104 . $rx->size . ''
105 . $rx->unit_array[$rx->unit] . '<br/>'
106 . $rx->quantity. ' '
107 . $rx->form_array[$rx->form]. '<br/>'
108 . $rx->dosage . ' '
109 . $rx->form_array[$rx->form]. ' '
110 . $rx->route_array[$rx->route] . ' '
111 . $rx->interval_array[$rx->interval] . '<br/>'
112 . $rx->note . '<br/>'
113 . 'refills:' . $rx->refills . '';
114 // . $rx->substitute_array[$rx->substitute]. ''
115 // . $rx->per_refill . '';
116 array_push($camos_content,$content);
119 if (!$_GET['letterhead']) { //OPTION print a prescription with css formatting
121 <html>
122 <head>
123 <?php html_header_show();?>
124 <title>
125 <?php xl('CAMOS','e'); ?>
126 </title>
127 <link rel="stylesheet" type="text/css" href="./rx.css" />
128 </head>
129 <body onload='init()'>
130 <img src='./hline.jpg' id='hline'>
131 <img src='./vline.jpg' id='vline'>
132 <?php
133 if ($camos_content[0]) { //decide if we are printing this rx
135 <?php
136 function topHeaderRx() {
137 global $physician_name,$practice_address,$practice_city,$practice_state,$practice_zip,$practice_phone,$practice_fax,$practice_dea;
138 print $physician_name . "<br/>\n";
139 print $practice_address . "<br/>\n";
140 print $practice_city . ", ";
141 print $practice_state . " ";
142 print $practice_zip . "<br/>\n";
143 print xl('Voice') . ': ' . $practice_phone . ' / ' . xl('Fax') . ': ' . $practice_fax . "<br/>\n";
144 print xl('DEA') . ': ' . $practice_dea;
146 function bottomHeaderRx() {
147 global $patient_name,$patient_address,$patient_city,$patient_state,$patient_zip,$patient_phone,$patient_dob;
148 print "<span class='mytagname'> " . xl('Name') . ":</span>\n";
149 print "<span class='mydata'> $patient_name </span>\n";
150 print "<span class='mytagname'> " . xl('Address') . ": </span>\n";
151 print "<span class='mydata'> $patient_address, $patient_city, " .
152 "$patient_state $patient_zip </span><br/>\n";
153 print "<span class='mytagname'>" . xl('Phone') . ":</span>\n";
154 print "<span class='mydata'>$patient_phone</span>\n";
155 print "<span class='mytagname'>" . xl('DOB') . ":</span>\n";
156 print "<span class='mydata'> $patient_dob </span>\n";
157 print "<span class='mytagname'>" . xl('Date') . ":</span>\n";
158 print "<span class='mydata'>" . date("F d, Y") . "</span><br/><br/>\n";
159 print "<div class='symbol'>" . xl('Rx') . "</div><br/>\n";
162 <div id='rx1' class='rx' >
163 <div class='topheader'>
164 <?php
165 topHeaderRx();
167 </div>
168 <hr/>
169 <div class='bottomheader'>
170 <?php
171 bottomHeaderRx();
173 </div>
174 <div class='content'>
175 <?php
176 print $camos_content[0];
178 </div>
179 <?php print $sigline[$_GET[sigline]] ?>
180 </div> <!-- end of rx block -->
181 <?php
182 } // end of deciding if we are printing the above rx block
183 else {
184 print "<img src='./xout.jpg' id='rx1'>\n";
187 <?php
189 if ($camos_content[1]) { //decide if we are printing this rx
191 <div id='rx2' class='rx' >
192 <div class='topheader'>
193 <?php
195 topHeaderRx();
197 </div>
198 <hr/>
199 <div class='bottomheader'>
200 <?php
202 bottomHeaderRx();
204 </div>
205 <div class='content'>
206 <?php
208 print $camos_content[1];
210 </div>
211 <?php print $sigline[$_GET[sigline]] ?>
212 </div> <!-- end of rx block -->
213 <?php
215 } // end of deciding if we are printing the above rx block
216 else {
217 print "<img src='./xout.jpg' id='rx2'>\n";
220 <?php
222 if ($camos_content[2]) { //decide if we are printing this rx
224 <div id='rx3' class='rx' >
225 <div class='topheader'>
226 <?php
228 topHeaderRx();
230 </div>
231 <hr/>
232 <div class='bottomheader'>
233 <?php
235 bottomHeaderRx();
237 </div>
238 <div class='content'>
239 <?php
241 print $camos_content[2];
243 </div>
244 <?php print $sigline[$_GET[sigline]] ?>
245 </div> <!-- end of rx block -->
246 <?php
248 } // end of deciding if we are printing the above rx block
249 else {
250 print "<img src='./xout.jpg' id='rx3'>\n";
253 <?php
255 if ($camos_content[3]) { //decide if we are printing this rx
257 <div id='rx4' class='rx' >
258 <div class='topheader'>
259 <?php
261 topHeaderRx();
263 </div>
264 <hr/>
265 <div class='bottomheader'>
266 <?php
268 bottomHeaderRx();
270 </div>
271 <div class='content'>
272 <?php
274 print $camos_content[3];
276 </div>
277 <?php print $sigline[$_GET[sigline]] ?>
278 </div> <!-- end of rx block -->
279 <?php
281 } // end of deciding if we are printing the above rx block
282 else {
283 print "<img src='./xout.jpg' id='rx4'>\n";
286 </body>
287 </html>
288 <?php
289 }//end of printing to rx not letterhead
290 elseif ($_GET['letterhead']) { //OPTION print to letterhead
291 $content = preg_replace('/PATIENTNAME/i',$patient_name,$camos_content[0]);
292 if($_POST['print_html']) { //print letterhead to html
294 <html>
295 <head>
296 <style>
297 body {
298 font-family: sans-serif;
299 font-weight: normal;
300 font-size: 12pt;
301 background: white;
302 color: black;
304 .paddingdiv {
305 width: 524pt;
306 padding: 0pt;
307 margin-top: 50pt;
309 .navigate {
310 margin-top: 2.5em;
312 @media print {
313 .navigate {
314 display: none;
317 </style>
318 <title><?php xl('Letter','e'); ?></title>
319 </head>
320 <body>
321 <div class='paddingdiv'>
322 <?php
323 //bold
324 print "<div style='font-weight:bold;'>";
325 print $physician_name . "<br/>\n";
326 print $practice_address . "<br/>\n";
327 print $practice_city.', '.$practice_state.' '.$practice_zip . "<br/>\n";
328 print $practice_phone . ' (' . xl('Voice') . ')' . "<br/>\n";
329 print $practice_phone . ' ('. xl('Fax') . ')' . "<br/>\n";
330 print "<br/>\n";
331 print date("l, F jS, Y") . "<br/>\n";
332 print "<br/>\n";
333 print "</div>";
334 //not bold
335 print "<div style='font-size:90%;'>";
336 print $content;
337 print "</div>";
338 //bold
339 print "<div style='font-weight:bold;'>";
340 print "<br/>\n";
341 print "<br/>\n";
342 if ($_GET['signer'] == 'patient') {
343 print "__________________________________________________________________________________" . "<br/>\n";
344 print xl("Print name, sign and date.") . "<br/>\n";
346 elseif ($_GET['signer'] == 'doctor') {
347 print xl('Sincerely,') . "<br/>\n";
348 print "<br/>\n";
349 print "<br/>\n";
350 print $physician_name . "<br/>\n";
352 print "</div>";
354 <script language='JavaScript'>
355 window.print();
356 </script>
357 </div>
358 </body>
359 </html>
360 <?php
361 exit;
363 else { //print letterhead to pdf
364 include_once('../../../library/classes/class.ezpdf.php');
365 $pdf =& new Cezpdf();
366 $pdf->selectFont('../../../library/fonts/Times-Bold');
367 $pdf->ezSetCmMargins(3,1,1,1);
368 $pdf->ezText($physician_name,12);
369 $pdf->ezText($practice_address,12);
370 $pdf->ezText($practice_city.', '.$practice_state.' '.$practice_zip,12);
371 $pdf->ezText($practice_phone . ' (' . xl('Voice') . ')',12);
372 $pdf->ezText($practice_phone . ' ('. xl('Fax') . ')',12);
373 $pdf->ezText('',12);
374 $pdf->ezText(date("l, F jS, Y"),12);
375 $pdf->ezText('',12);
376 $pdf->selectFont('../../../library/fonts/Helvetica');
377 $pdf->ezText($content,10);
378 $pdf->selectFont('../../../library/fonts/Times-Bold');
379 $pdf->ezText('',12);
380 $pdf->ezText('',12);
381 if ($_GET['signer'] == 'patient') {
382 $pdf->ezText("__________________________________________________________________________________",12);
383 $pdf->ezText(xl("Print name, sign and date."),12);
385 elseif ($_GET['signer'] == 'doctor') {
386 $pdf->ezText(xl('Sincerely,'),12);
387 $pdf->ezText('',12);
388 $pdf->ezText('',12);
389 $pdf->ezText($physician_name,12);
391 $pdf->ezStream();
392 } //end of html vs pdf print
394 } //end of if print
395 else { //OPTION selection of what to print
397 <html>
398 <head>
399 <?php html_header_show();?>
400 <title>
401 <?php xl('CAMOS','e'); ?>
402 </title>
403 <script type="text/javascript">
404 //below init function just to demonstrate how to do it.
405 //now need to create 'cycle' function triggered by button to go by fours
406 //through selected types of subcategories.
407 //this is to be very very cool.
408 function init() {}
409 function checkall(){
410 var f = document.forms[0];
411 var x = f.elements.length;
412 var i;
413 for(i=0;i<x;i++) {
414 if (f.elements[i].type == 'checkbox') {
415 f.elements[i].checked = true;
419 function uncheckall(){
420 var f = document.forms[0];
421 var x = f.elements.length;
422 var i;
423 for(i=0;i<x;i++) {
424 if (f.elements[i].type == 'checkbox') {
425 f.elements[i].checked = false;
429 function cycle() {
430 var log = document.getElementById('log');
431 var cboxes = document.getElementById('checkboxes');
432 var cb = cboxes.getElementsByTagName('div');
433 if (cycle_engine(cb,0) == 0) {cycle_engine(cb,1);}
435 function cycle_engine(cb,seed) {
436 //seed determines if we should turn on up to first 4
437 var count_turnon = 0;
438 var count_turnoff = 0;
439 for (var i=0;i<cb.length;i++) {
440 cbc = cb[i].childNodes;
441 if (cbc[2].innerHTML == 'prescriptions') {
442 if (cbc[1].checked == true) {
443 cbc[1].checked = false;
444 count_turnoff++;
445 } else {
446 if ((count_turnoff > 0 || seed == 1) && count_turnon < 4) {
447 cbc[1].checked = true;
448 count_turnon++;
453 return count_turnoff;
456 </script>
457 <link rel="stylesheet" type="text/css" href="./rx.css" />
458 </head>
459 <h1><?php xl('Select CAMOS Entries for Printing','e'); ?></h1>
460 <form method=POST name='pick_items' target=_new>
461 <input type=button name=cyclerx value='<?php xl('Cycle','e'); ?>' onClick='cycle()'><br/>
462 <input type='button' value='<?php xl('Select All','e'); ?>' onClick='checkall()'>
463 <input type='button' value='<?php xl('Unselect All','e'); ?>' onClick='uncheckall()'>
465 <?php if ($_GET['letterhead']) { ?>
466 <input type=submit name='print_pdf' value='<?php xl('Print (PDF)','e'); ?>'>
467 <?php } ?>
469 <input type=submit name='print_html' value='<?php xl('Print (HTML)','e'); ?>'>
470 <?php
472 //check if an encounter is set
473 if ($_SESSION['encounter'] == NULL) {
474 $query = sqlStatement("select x.id as id, x.category, x.subcategory, x.item from " .
475 "form_CAMOS as x join forms as y on (x.id = y.form_id) " .
476 "where y.pid = " . $_SESSION['pid'] .
477 " and y.form_name like 'CAMOS%'" .
478 " and x.activity = 1");
480 else {
481 $query = sqlStatement("select x.id as id, x.category, x.subcategory, x.item from " .
482 "form_CAMOS as x join forms as y on (x.id = y.form_id) " .
483 "where y.encounter = " . $_SESSION['encounter'] .
484 " and y.pid = " . $_SESSION['pid'] .
485 " and y.form_name like 'CAMOS%'" .
486 " and x.activity = 1");
488 $results = array();
489 echo "<div id='checkboxes'>\n";
490 $count = 0;
491 while ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
492 $checked = '';
493 if ($result['category'] == 'prescriptions' && $count < 4) {
494 $count++;
495 $checked = 'checked';
497 echo "<div>\n";
498 echo "<input type=checkbox name='ch_" . $result['id'] . "' $checked><span>" .
499 $result['category'] . '</span>:' . $result['subcategory'] . ':' . $result['item'] . "<br/>\n";
500 echo "</div>\n";
502 echo "</div>\n";
503 echo "<div id='log'>\n";//temp for debugging
504 echo "</div>\n";
505 //create Prescription object for the purpose of drawing data from the Prescription
506 //table for those who wish to do so
507 $rxarray = Prescription::prescriptions_factory($_SESSION['pid']);
508 //now give a choice of drugs from the Prescription table
509 foreach($rxarray as $val) {
510 echo "<input type=checkbox name='chrx_" . $val->id . "'>" .
511 $val->drug . ':' . $val->start_date . "<br/>\n";
515 <?php if ($_GET['letterhead']) { ?>
516 <input type=submit name='print_pdf' value='<?php xl('Print (PDF)','e'); ?>'>
517 <?php } ?>
519 <input type=submit name='print_html' value='<?php xl('Print (HTML)','e'); ?>'>
520 </form>
521 <h1><?php xl('Update User Information','e'); ?></h1>
522 <form method=POST name='pick_items'>
523 <table>
524 <tr>
525 <td> <?php xl('First Name','e'); ?>: </td>
526 <td> <input type=text name=practice_fname value ='<?php echo htmlspecialchars($practice_fname,ENT_QUOTES); ?>'> </td>
527 </tr>
528 <tr>
529 <td> <?php xl('Last Name','e'); ?>: </td>
530 <td> <input type=text name=practice_lname value ='<?php echo htmlspecialchars($practice_lname,ENT_QUOTES); ?>'> </td>
531 </tr>
532 <tr>
533 <td> <?php xl('Title','e'); ?>: </td>
534 <td> <input type=text name=practice_title value ='<?php echo htmlspecialchars($practice_title,ENT_QUOTES); ?>'> </td>
535 </tr>
536 <tr>
537 <td> <?php xl('Street Address','e'); ?>: </td>
538 <td> <input type=text name=practice_address value ='<?php echo htmlspecialchars($practice_address,ENT_QUOTES); ?>'> </td>
539 </tr>
540 <tr>
541 <td> <?php xl('City','e'); ?>: </td>
542 <td> <input type=text name=practice_city value ='<?php echo htmlspecialchars($practice_city,ENT_QUOTES); ?>'> </td>
543 </tr>
544 <tr>
545 <td> <?php xl('State','e'); ?>: </td>
546 <td> <input type=text name=practice_state value ='<?php echo htmlspecialchars($practice_state,ENT_QUOTES); ?>'> </td>
547 </tr>
548 <tr>
549 <td> <?php xl('Zip','e'); ?>: </td>
550 <td> <input type=text name=practice_zip value ='<?php echo htmlspecialchars($practice_zip,ENT_QUOTES); ?>'> </td>
551 </tr>
552 <tr>
553 <td> <?php xl('Phone','e'); ?>: </td>
554 <td> <input type=text name=practice_phone value ='<?php echo htmlspecialchars($practice_phone,ENT_QUOTES); ?>'> </td>
555 </tr>
556 <tr>
557 <td> <?php xl('Fax','e'); ?>: </td>
558 <td> <input type=text name=practice_fax value ='<?php echo htmlspecialchars($practice_fax,ENT_QUOTES); ?>'> </td>
559 </tr>
560 <tr>
561 <td> <?php xl('DEA','e'); ?>: </td>
562 <td> <input type=text name=practice_dea value ='<?php echo htmlspecialchars($practice_dea,ENT_QUOTES); ?>'> </td>
563 </tr>
564 </table>
565 <input type=submit name=update value='<?php xl('Update','e'); ?>'>
566 </form>
567 <?php
568 } //end of else statement
570 </body>
571 </html>