Highway to PSR2
[openemr.git] / interface / forms / physical_exam / edit_diagnoses.php
blob1873efbe7d5b4b30637bc56bf03b140e1ca79757
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 if ($issue && !acl_check('patients', 'med', '', 'write')) {
16 die("Edit is not authorized!");
19 <html>
20 <head>
21 <?php html_header_show();?>
22 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script>
23 <title><?php xl('Edit Diagnoses for', 'e');?><?php echo $line_id ?></title>
24 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
26 <script language="JavaScript">
27 </script>
29 </head>
31 <body class="body_top">
32 <?php
33 // If we are saving, then save and close the window.
35 if ($_POST['form_save']) {
36 $query = "DELETE FROM form_physical_exam_diagnoses WHERE line_id = '$line_id'";
37 sqlStatement($query);
39 $form_diagnoses = $_POST['form_diagnosis'];
40 $form_orderings = $_POST['form_ordering'];
41 foreach ($form_diagnoses as $i => $diagnosis) {
42 if ($diagnosis) {
43 $ordering = $form_orderings[$i];
44 $query = "INSERT INTO form_physical_exam_diagnoses ( " .
45 "line_id, ordering, diagnosis " .
46 ") VALUES ( " .
47 "'$line_id', '$ordering', '$diagnosis' " .
48 ")";
49 sqlInsert($query);
53 // Close this window and redisplay the updated encounter form.
55 echo "<script language='JavaScript'>\n";
56 if ($info_msg) {
57 echo " alert('$info_msg');\n";
60 echo " window.close();\n";
61 // echo " opener.location.reload();\n";
62 echo " if (opener.refreshme) opener.refreshme();\n";
63 echo "</script></body></html>\n";
64 exit();
67 $dres = sqlStatement(
68 "SELECT * FROM form_physical_exam_diagnoses WHERE " .
69 "line_id = '$line_id' ORDER BY ordering, diagnosis"
72 <form method='post' name='theform' action='edit_diagnoses.php?lineid=<?php echo $line_id ?>'
73 onsubmit='return top.restoreSession()'>
74 <center>
76 <table border='0' width='100%'>
78 <tr>
79 <td width='5%'><?php xl('Order', 'e'); ?></td>
80 <td width='95%'><?php xl('Diagnosis', 'e'); ?></td>
81 </tr>
83 <?php for ($i = 1; $drow = sqlFetchArray($dres); ++$i) { ?>
84 <tr>
85 <td><input type='text' size='3' maxlength='5' name='form_ordering[<?php echo $i?>]' value='<?php echo $i?>' /></td>
86 <td><input type='text' size='20' maxlength='250' name='form_diagnosis[<?php echo $i?>]' value='<?php echo $drow['diagnosis'] ?>' style='width:100%' /></td>
87 </tr>
88 <?php } ?>
90 <?php for ($j = 0; $j < 5; ++$j, ++$i) { ?>
91 <tr>
92 <td><input type='text' size='3' name='form_ordering[<?php echo $i?>]' value='<?php echo $i?>' /></td>
93 <td><input type='text' size='20' name='form_diagnosis[<?php echo $i?>]' style='width:100%' /></td>
94 </tr>
95 <?php } ?>
97 </table>
99 <p>
100 <input type='submit' name='form_save' value='<?php xl('Save', 'e'); ?>' />
102 &nbsp;
103 <input type='button' value='<?php xl('Cancel', 'e'); ?>' onclick='window.close()' />
104 </p>
106 </center>
107 </form>
108 </body>
109 </html>