External database import utility.
[openemr.git] / interface / forms / physical_exam / edit_diagnoses.php
blobe82c47aa940497140841bab024750791ee115194
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 <?php html_header_show();?>
21 <title><?php xl('Edit Diagnoses for','e');?><?php echo $line_id ?></title>
22 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
24 <script language="JavaScript">
25 </script>
27 </head>
29 <body class="body_top">
30 <?php
31 // If we are saving, then save and close the window.
33 if ($_POST['form_save']) {
34 $query = "DELETE FROM form_physical_exam_diagnoses WHERE line_id = '$line_id'";
35 sqlStatement($query);
37 $form_diagnoses = $_POST['form_diagnosis'];
38 $form_orderings = $_POST['form_ordering'];
39 foreach ($form_diagnoses as $i => $diagnosis) {
40 if ($diagnosis) {
41 $ordering = $form_orderings[$i];
42 $query = "INSERT INTO form_physical_exam_diagnoses ( " .
43 "line_id, ordering, diagnosis " .
44 ") VALUES ( " .
45 "'$line_id', '$ordering', '$diagnosis' " .
46 ")";
47 sqlInsert($query);
51 // Close this window and redisplay the updated encounter form.
53 echo "<script language='JavaScript'>\n";
54 if ($info_msg) echo " alert('$info_msg');\n";
55 echo " window.close();\n";
56 // echo " opener.location.reload();\n";
57 echo " if (opener.refreshme) opener.refreshme();\n";
58 echo "</script></body></html>\n";
59 exit();
62 $dres = sqlStatement(
63 "SELECT * FROM form_physical_exam_diagnoses WHERE " .
64 "line_id = '$line_id' ORDER BY ordering, diagnosis"
67 <form method='post' name='theform' action='edit_diagnoses.php?lineid=<?php echo $line_id ?>'
68 onsubmit='return top.restoreSession()'>
69 <center>
71 <table border='0' width='100%'>
73 <tr>
74 <td width='5%'><?php xl('Order','e'); ?></td>
75 <td width='95%'><?php xl('Diagnosis','e'); ?></td>
76 </tr>
78 <?php for ($i = 1; $drow = sqlFetchArray($dres); ++$i) { ?>
79 <tr>
80 <td><input type='text' size='3' maxlength='5' name='form_ordering[<?php echo $i?>]' value='<?php echo $i?>' /></td>
81 <td><input type='text' size='20' maxlength='250' name='form_diagnosis[<?php echo $i?>]' value='<?php echo $drow['diagnosis'] ?>' style='width:100%' /></td>
82 </tr>
83 <?php } ?>
85 <?php for ($j = 0; $j < 5; ++$j, ++$i) { ?>
86 <tr>
87 <td><input type='text' size='3' name='form_ordering[<?php echo $i?>]' value='<?php echo $i?>' /></td>
88 <td><input type='text' size='20' name='form_diagnosis[<?php echo $i?>]' style='width:100%' /></td>
89 </tr>
90 <?php } ?>
92 </table>
94 <p>
95 <input type='submit' name='form_save' value='<?php xl('Save','e'); ?>' />
97 &nbsp;
98 <input type='button' value='<?php xl('Cancel','e'); ?>' onclick='window.close()' />
99 </p>
101 </center>
102 </form>
103 </body>
104 </html>