update
[openemr.git] / interface / forms / CAMOS / rx_print.php
blobe0dfe0fc805b69f91fa21971f14b4bf1f9321564
1 <?php
2 include_once ('../../globals.php');
3 include_once ('../../../library/sql.inc');
4 include_once ('../../../library/classes/Prescription.class.php');
5 //practice data
6 $physician_name = '';
7 $practice_fname = '';
8 $practice_lname = '';
9 $practice_title = '';
10 $practice_address = '';
11 $practice_city = '';
12 $practice_state = '';
13 $practice_zip = '';
14 $practice_phone = '';
15 $practice_fax = '';
16 $practice_license = '';
17 $practice_dea = '';
18 //patient data
19 $patient_name = '';
20 $patient_address = '';
21 $patient_city = '';
22 $patient_state = '';
23 $patient_zip = '';
24 $patient_phone = '';
25 $patient_dob = '';
26 $sigline = array();
27 $sigline['plain'] =
28 "<div class='signature'>"
29 . " ______________________________________________<br/>"
30 . "</div>\n";
31 $sigline['embossed'] =
32 "<div class='signature'>"
33 . " _____________________________________________________<br/>"
34 # . "Signature - Valid for three days and in Broward County only."
35 . "Signature"
36 . "</div>\n";
37 $sigline['signed'] =
38 "<div class='sig'>"
39 . "<img src='./sig.jpg'>"
40 . "</div>\n";
41 $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']);
42 if ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
43 $patient_name = $result['fname'] . ' ' . $result['lname'];
44 $patient_address = $result['street'];
45 $patient_city = $result['city'];
46 $patient_state = $result['state'];
47 $patient_zip = $result['postal_code'];
48 $patient_phone = $result['phone_home'];
49 $patient_dob = $result['DOB'];
51 //update user information if selected from form
52 if ($_POST['update']) { // OPTION update practice inf
53 $query = "update users set " .
54 "fname = '" . $_POST['practice_fname'] . "', " .
55 "lname = '" . $_POST['practice_lname'] . "', " .
56 "title = '" . $_POST['practice_title'] . "', " .
57 "street = '" . $_POST['practice_address'] . "', " .
58 "city = '" . $_POST['practice_city'] . "', " .
59 "state = '" . $_POST['practice_state'] . "', " .
60 "zip = '" . $_POST['practice_zip'] . "', " .
61 "phone = '" . $_POST['practice_phone'] . "', " .
62 "fax = '" . $_POST['practice_fax'] . "', " .
63 "federaldrugid = '" . $_POST['practice_dea'] . "' " .
64 "where id =" . $_SESSION['authUserID'];
65 sqlInsert($query);
67 //get user information
68 $query = sqlStatement("select * from users where id =" . $_SESSION['authUserID']);
69 if ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
70 $physician_name = $result['fname'] . ' ' . $result['lname'] . ', ' . $result['title'];
71 $practice_fname = $result['fname'];
72 $practice_lname = $result['lname'];
73 $practice_title = $result['title'];
74 $practice_address = $result['street'];
75 $practice_city = $result['city'];
76 $practice_state = $result['state'];
77 $practice_zip = $result['zip'];
78 $practice_phone = $result['phone'];
79 $practice_fax = $result['fax'];
80 $practice_dea = $result['federaldrugid'];
82 if ($_POST['print']) {
83 $camos_content = array();
84 foreach ($_POST as $key => $val) {
85 if (substr($key,0,3) == 'ch_') {
86 $query = sqlStatement("select content from form_CAMOS where id =" .
87 substr($key,3));
88 if ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
89 if (!$_GET['letterhead']) { //do this change to formatting only for web output (rx output)
90 $content = preg_replace('|\n|','<br/>', $result['content']);
91 $content = preg_replace('|<br/><br/>|','<br/>', $content);
92 } else {
93 $content = $result['content'];
95 array_push($camos_content,$content);
98 if (substr($key,0,5) == 'chrx_') {
99 $rx = new Prescription(substr($key,5));
100 //$content = $rx->drug.' '.$rx->form.' '.$rx->dosage;
101 $content = ''
102 . $rx->drug . ' '
103 . $rx->size . ''
104 . $rx->unit_array[$rx->unit] . '<br/>'
105 . $rx->quantity. ' '
106 . $rx->form_array[$rx->form]. '<br/>'
107 . $rx->dosage . ' '
108 . $rx->form_array[$rx->form]. ' '
109 . $rx->route_array[$rx->route] . ' '
110 . $rx->interval_array[$rx->interval] . '<br/>'
111 . 'refills:' . $rx->refills . '';
112 // . $rx->substitute_array[$rx->substitute]. ''
113 // . $rx->per_refill . '';
114 array_push($camos_content,$content);
117 if (!$_GET['letterhead']) { //OPTION print a prescription with css formatting
119 <html>
120 <head>
121 <? html_header_show();?>
122 <title>
123 Four Pane Prescription Printer
124 </title>
125 <link rel="stylesheet" type="text/css" href="./rx.css" />
126 </head>
127 <body onload='init()'>
128 <img src='./hline.jpg' id='hline'>
129 <img src='./vline.jpg' id='vline'>
131 if ($camos_content[0]) { //decide if we are printing this rx
133 <div id='rx1' class='rx' >
134 <div class='topheader'>
136 print $physician_name . "<br/>\n";
137 print $practice_address . "<br/>\n";
138 print $practice_city . ", ";
139 print $practice_state . " ";
140 print $practice_zip . "<br/>\n";
141 print 'voice: ' . $practice_phone . ' / fax: ' . $practice_fax . "<br/>\n";
142 print 'DEA: ' . $practice_dea;
144 </div>
145 <hr/>
146 <div class='bottomheader'>
148 print "<span class='mytagname'> Name:</span>\n";
149 print "<span class='mydata'> $patient_name </span>\n";
150 print "<span class='mytagname'> 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'>Phone:</span>\n";
154 print "<span class='mydata'>$patient_phone</span>\n";
155 print "<span class='mytagname'>DOB:</span>\n";
156 print "<span class='mydata'> $patient_dob </span>\n";
157 print "<span class='mytagname'>Date:</span>\n";
158 print "<span class='mydata'>" . date("F d, Y") . "</span><br/><br/>\n";
159 print "<div class='symbol'>Rx</div><br/>\n";
161 </div>
162 <div class='content'>
164 print $camos_content[0];
166 </div>
167 <? print $sigline[$_GET[sigline]] ?>
168 </div> <!-- end of rx block -->
170 } // end of deciding if we are printing the above rx block
171 else {
172 print "<img src='./xout.jpg' id='rx1'>\n";
176 if ($camos_content[1]) { //decide if we are printing this rx
178 <div id='rx2' class='rx' >
179 <div class='topheader'>
181 print $physician_name . "<br/>\n";
182 print $practice_address . "<br/>\n";
183 print $practice_city . ", ";
184 print $practice_state . " ";
185 print $practice_zip . "<br/>\n";
186 //print $practice_phone . "<br/>\n";
187 print 'voice: ' . $practice_phone . ' / fax: ' . $practice_fax . "<br/>\n";
188 print 'DEA: ' . $practice_dea;
190 </div>
191 <hr/>
192 <div class='bottomheader'>
194 print "<span class='mytagname'> Name:</span>\n";
195 print "<span class='mydata'> $patient_name </span>\n";
196 print "<span class='mytagname'> Address: </span>\n";
197 print "<span class='mydata'> $patient_address, $patient_city, " .
198 "$patient_state $patient_zip </span><br/>\n";
199 print "<span class='mytagname'>Phone:</span>\n";
200 print "<span class='mydata'>$patient_phone</span>\n";
201 print "<span class='mytagname'>DOB:</span>\n";
202 print "<span class='mydata'> $patient_dob </span>\n";
203 print "<span class='mytagname'>Date:</span>\n";
204 print "<span class='mydata'>" . date("F d, Y") . "</span><br/><br/>\n";
205 print "<div class='symbol'>Rx</div><br/>\n";
207 </div>
208 <div class='content'>
210 print $camos_content[1];
212 </div>
213 <? print $sigline[$_GET[sigline]] ?>
214 </div> <!-- end of rx block -->
216 } // end of deciding if we are printing the above rx block
217 else {
218 print "<img src='./xout.jpg' id='rx2'>\n";
222 if ($camos_content[2]) { //decide if we are printing this rx
224 <div id='rx3' class='rx' >
225 <div class='topheader'>
227 print $physician_name . "<br/>\n";
228 print $practice_address . "<br/>\n";
229 print $practice_city . ", ";
230 print $practice_state . " ";
231 print $practice_zip . "<br/>\n";
232 //print $practice_phone . "<br/>\n";
233 print 'voice: ' . $practice_phone . ' / fax: ' . $practice_fax . "<br/>\n";
234 print 'DEA: ' . $practice_dea;
236 </div>
237 <hr/>
238 <div class='bottomheader'>
240 print "<span class='mytagname'> Name:</span>\n";
241 print "<span class='mydata'> $patient_name </span>\n";
242 print "<span class='mytagname'> Address: </span>\n";
243 print "<span class='mydata'> $patient_address, $patient_city, " .
244 "$patient_state $patient_zip </span><br/>\n";
245 print "<span class='mytagname'>Phone:</span>\n";
246 print "<span class='mydata'>$patient_phone</span>\n";
247 print "<span class='mytagname'>DOB:</span>\n";
248 print "<span class='mydata'> $patient_dob </span>\n";
249 print "<span class='mytagname'>Date:</span>\n";
250 print "<span class='mydata'>" . date("F d, Y") . "</span><br/><br/>\n";
251 print "<div class='symbol'>Rx</div><br/>\n";
253 </div>
254 <div class='content'>
256 print $camos_content[2];
258 </div>
259 <? print $sigline[$_GET[sigline]] ?>
260 </div> <!-- end of rx block -->
262 } // end of deciding if we are printing the above rx block
263 else {
264 print "<img src='./xout.jpg' id='rx3'>\n";
268 if ($camos_content[3]) { //decide if we are printing this rx
270 <div id='rx4' class='rx' >
271 <div class='topheader'>
273 print $physician_name . "<br/>\n";
274 print $practice_address . "<br/>\n";
275 print $practice_city . ", ";
276 print $practice_state . " ";
277 print $practice_zip . "<br/>\n";
278 //print $practice_phone . "<br/>\n";
279 print 'voice: ' . $practice_phone . ' / fax: ' . $practice_fax . "<br/>\n";
280 print 'DEA: ' . $practice_dea;
282 </div>
283 <hr/>
284 <div class='bottomheader'>
286 print "<span class='mytagname'> Name:</span>\n";
287 print "<span class='mydata'> $patient_name </span>\n";
288 print "<span class='mytagname'> Address: </span>\n";
289 print "<span class='mydata'> $patient_address, $patient_city, " .
290 "$patient_state $patient_zip </span><br/>\n";
291 print "<span class='mytagname'>Phone:</span>\n";
292 print "<span class='mydata'>$patient_phone</span>\n";
293 print "<span class='mytagname'>DOB:</span>\n";
294 print "<span class='mydata'> $patient_dob </span>\n";
295 print "<span class='mytagname'>Date:</span>\n";
296 print "<span class='mydata'>" . date("F d, Y") . "</span><br/><br/>\n";
297 print "<div class='symbol'>Rx</div><br/>\n";
299 </div>
300 <div class='content'>
302 print $camos_content[3];
304 </div>
305 <? print $sigline[$_GET[sigline]] ?>
306 </div> <!-- end of rx block -->
308 } // end of deciding if we are printing the above rx block
309 else {
310 print "<img src='./xout.jpg' id='rx4'>\n";
313 </body>
314 </html>
315 <?php
316 }//end of printing to rx not letterhead
317 elseif ($_GET['letterhead']) { //OPTION print to pdf letterhead
318 $content = preg_replace('/PATIENTNAME/i',$patient_name,$camos_content[0]);
319 include_once('../../../library/classes/class.ezpdf.php');
320 $pdf =& new Cezpdf();
321 $pdf->selectFont('../../../library/fonts/Times-Bold');
322 $pdf->ezSetCmMargins(3,1,1,1);
323 $pdf->ezText($physician_name,12);
324 $pdf->ezText($practice_address,12);
325 $pdf->ezText($practice_city.', '.$practice_state.' '.$practice_zip,12);
326 $pdf->ezText($practice_phone . ' (voice)',12);
327 $pdf->ezText($practice_phone . ' (fax)',12);
328 $pdf->ezText('',12);
329 $pdf->ezText(date("l, F jS, Y"),12);
330 $pdf->ezText('',12);
331 $pdf->selectFont('../../../library/fonts/Helvetica');
332 $pdf->ezText($content,10);
333 $pdf->selectFont('../../../library/fonts/Times-Bold');
334 $pdf->ezText('',12);
335 $pdf->ezText('',12);
336 if ($_GET['signer'] == 'patient') {
337 $pdf->ezText("__________________________________________________________________________________",12);
338 $pdf->ezText("Print name, sign and date.",12);
340 elseif ($_GET['signer'] == 'doctor') {
341 $pdf->ezText('Sincerely,',12);
342 $pdf->ezText('',12);
343 $pdf->ezText('',12);
344 $pdf->ezText($physician_name,12);
346 $pdf->ezStream();
348 } //end of if print
349 else { //OPTION selection of what to print
351 <html>
352 <head>
353 <? html_header_show();?>
354 <title>
355 Four Pane Prescription Printer
356 </title>
357 <script type="text/javascript">
358 //below init function just to demonstrate how to do it.
359 //now need to create 'cycle' function triggered by button to go by fours
360 //through selected types of subcategories.
361 //this is to be very very cool.
362 function init() {}
363 function checkall(){
364 var f = document.forms[0];
365 var x = f.elements.length;
366 var i;
367 for(i=0;i<x;i++) {
368 if (f.elements[i].type == 'checkbox') {
369 f.elements[i].checked = true;
373 function uncheckall(){
374 var f = document.forms[0];
375 var x = f.elements.length;
376 var i;
377 for(i=0;i<x;i++) {
378 if (f.elements[i].type == 'checkbox') {
379 f.elements[i].checked = false;
383 function cycle() {
384 var log = document.getElementById('log');
385 var cboxes = document.getElementById('checkboxes');
386 var cb = cboxes.getElementsByTagName('div');
387 if (cycle_engine(cb,0) == 0) {cycle_engine(cb,1);}
389 function cycle_engine(cb,seed) {
390 //seed determines if we should turn on up to first 4
391 var count_turnon = 0;
392 var count_turnoff = 0;
393 for (var i=0;i<cb.length;i++) {
394 cbc = cb[i].childNodes;
395 if (cbc[2].innerHTML == 'prescriptions') {
396 if (cbc[1].checked == true) {
397 cbc[1].checked = false;
398 count_turnoff++;
399 } else {
400 if ((count_turnoff > 0 || seed == 1) && count_turnon < 4) {
401 cbc[1].checked = true;
402 count_turnon++;
407 return count_turnoff;
410 </script>
411 <link rel="stylesheet" type="text/css" href="./rx.css" />
412 </head>
413 <h1>Select CAMOS Entries for printing</h1>
414 <form method=POST name='pick_items' target=_new>
415 <input type=button name=cyclerx value='cycle' onClick='cycle()'><br/>
416 <input type='button' value='check all' onClick='checkall()'>
417 <input type='button' value='uncheck all' onClick='uncheckall()'>
418 <input type=submit name=print value=print>
420 $query = sqlStatement("select x.id as id, x.category, x.subcategory, x.item from " .
421 "form_CAMOS as x join forms as y on (x.id = y.form_id) " .
422 "where y.encounter = " . $_SESSION['encounter'] .
423 " and y.pid = " . $_SESSION['pid'] .
424 " and y.form_name like 'CAMOS%'" .
425 " and x.activity = 1");
426 $results = array();
427 echo "<div id='checkboxes'>\n";
428 $count = 0;
429 while ($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
430 $checked = '';
431 if ($result['category'] == 'prescriptions' && $count < 4) {
432 $count++;
433 $checked = 'checked';
435 echo "<div>\n";
436 echo "<input type=checkbox name='ch_" . $result['id'] . "' $checked><span>" .
437 $result['category'] . '</span>:' . $result['subcategory'] . ':' . $result['item'] . "<br/>\n";
438 echo "</div>\n";
440 echo "</div>\n";
441 echo "<div id='log'>\n";//temp for debugging
442 echo "</div>\n";
443 //create Prescription object for the purpose of drawing data from the Prescription
444 //table for those who wish to do so
445 $rxarray = Prescription::prescriptions_factory($_SESSION['pid']);
446 //now give a choice of drugs from the Prescription table
447 foreach($rxarray as $val) {
448 echo "<input type=checkbox name='chrx_" . $val->id . "'>" .
449 $val->drug . ':' . $val->start_date . "<br/>\n";
452 <input type=submit name=print value=print>
453 </form>
454 <h1>Update User Information</h1>
455 <form method=POST name='pick_items'>
456 <table>
457 <tr>
458 <td> First Name: </td>
459 <td> <input type=text name=practice_fname value ='<? echo $practice_fname; ?>'> </td>
460 </tr>
461 <tr>
462 <td> Last Name: </td>
463 <td> <input type=text name=practice_lname value ='<? echo $practice_lname; ?>'> </td>
464 </tr>
465 <tr>
466 <td> Title: </td>
467 <td> <input type=text name=practice_title value ='<? echo $practice_title; ?>'> </td>
468 </tr>
469 <tr>
470 <td> Street Address: </td>
471 <td> <input type=text name=practice_address value ='<? echo $practice_address; ?>'> </td>
472 </tr>
473 <tr>
474 <td> City: </td>
475 <td> <input type=text name=practice_city value ='<? echo $practice_city; ?>'> </td>
476 </tr>
477 <tr>
478 <td> State: </td>
479 <td> <input type=text name=practice_state value ='<? echo $practice_state; ?>'> </td>
480 </tr>
481 <tr>
482 <td> Zip: </td>
483 <td> <input type=text name=practice_zip value ='<? echo $practice_zip; ?>'> </td>
484 </tr>
485 <tr>
486 <td> Phone: </td>
487 <td> <input type=text name=practice_phone value ='<? echo $practice_phone; ?>'> </td>
488 </tr>
489 <tr>
490 <td> Fax: </td>
491 <td> <input type=text name=practice_fax value ='<? echo $practice_fax; ?>'> </td>
492 </tr>
493 <tr>
494 <td> DEA: </td>
495 <td> <input type=text name=practice_dea value ='<? echo $practice_dea; ?>'> </td>
496 </tr>
497 </table>
498 <input type=submit name=update value=update>
499 </form>
500 <?php
501 } //end of else statement
503 </body>
504 </html>