added physical_exam encounter form
[openemr.git] / interface / forms / physical_exam / edit_diagnoses.php
blobe83dfecb6cef2aeffcd8dfcc53c8cfbc7a3d1dd3
1 <?php
2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 include_once("../../globals.php");
10 include_once("$srcdir/acl.inc");
12 $line_id = $_REQUEST['lineid'];
13 $info_msg = "";
15 $thisauth = acl_check('patients', 'med');
16 if ($issue && $thisauth != 'write') die("Edit is not authorized!");
18 <html>
19 <head>
20 <title>Edit Diagnoses for <?php echo $line_id ?></title>
21 <link rel=stylesheet href='<? echo $css_header ?>' type='text/css'>
23 <script language="JavaScript">
24 </script>
26 </head>
28 <body <?echo $top_bg_line;?>>
29 <?php
30 // If we are saving, then save and close the window.
32 if ($_POST['form_save']) {
33 $query = "DELETE FROM form_physical_exam_diagnoses WHERE line_id = '$line_id'";
34 sqlStatement($query);
36 $form_diagnoses = $_POST['form_diagnosis'];
37 $form_orderings = $_POST['form_ordering'];
38 foreach ($form_diagnoses as $i => $diagnosis) {
39 if ($diagnosis) {
40 $ordering = $form_orderings[$i];
41 $query = "INSERT INTO form_physical_exam_diagnoses ( " .
42 "line_id, ordering, diagnosis " .
43 ") VALUES ( " .
44 "'$line_id', '$ordering', '$diagnosis' " .
45 ")";
46 sqlInsert($query);
50 // Close this window and redisplay the updated encounter form.
52 echo "<script language='JavaScript'>\n";
53 if ($info_msg) echo " alert('$info_msg');\n";
54 echo " window.close();\n";
55 // echo " opener.location.reload();\n";
56 echo " if (opener.refreshme) opener.refreshme();\n";
57 echo "</script></body></html>\n";
58 exit();
61 $dres = sqlStatement(
62 "SELECT * FROM form_physical_exam_diagnoses WHERE " .
63 "line_id = '$line_id' ORDER BY ordering, diagnosis"
66 <form method='post' name='theform' action='edit_diagnoses.php?lineid=<? echo $line_id ?>'>
67 <center>
69 <table border='0' width='100%'>
71 <tr>
72 <td width='5%'>Order</td>
73 <td width='95%'>Diagnosis</td>
74 </tr>
76 <?php for ($i = 1; $drow = sqlFetchArray($dres); ++$i) { ?>
77 <tr>
78 <td><input type='text' size='3' maxlength='5' name='form_ordering[<?php echo $i?>]' value='<?php echo $i?>' /></td>
79 <td><input type='text' size='20' maxlength='250' name='form_diagnosis[<?php echo $i?>]' value='<? echo $drow['diagnosis'] ?>' style='width:100%' /></td>
80 </tr>
81 <?php } ?>
83 <?php for ($j = 0; $j < 5; ++$j, ++$i) { ?>
84 <tr>
85 <td><input type='text' size='3' name='form_ordering[<?php echo $i?>]' value='<?php echo $i?>' /></td>
86 <td><input type='text' size='20' name='form_diagnosis[<?php echo $i?>]' style='width:100%' /></td>
87 </tr>
88 <?php } ?>
90 </table>
92 <p>
93 <input type='submit' name='form_save' value='Save' />
95 &nbsp;
96 <input type='button' value='Cancel' onclick='window.close()' />
97 </p>
99 </center>
100 </form>
101 </body>
102 </html>