Initial import.
[openemr.git] / interface / patient_file / summary / add_edit_issue.php
blob0144fa696666354cfa740db46a1c8e43a7d0906e
1 <?
2 // Copyright (C) 2005 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/lists.inc");
11 include_once("$srcdir/patient.inc");
12 // include_once("$srcdir/overlib_mini.js");
13 // include_once("$srcdir/calendar.js");
15 $issue = $_REQUEST['issue'];
16 $info_msg = "";
18 $arrtype = array(
19 'medical_problem' => 'Problem',
20 'allergy' => 'Allergy',
21 'medication' => 'Medication',
22 'surgery' => 'Surgery'
25 $arroccur = array(
26 0 => 'Unknown or N/A',
27 1 => 'First',
28 2 => 'Second',
29 3 => 'Third',
30 4 => 'Chronic/Recurrent',
31 5 => 'Acute on Chronic'
34 function QuotedOrNull($fld) {
35 if ($fld) return "'$fld'";
36 return "NULL";
40 <html>
41 <head>
42 <title><? echo $issue ? "Edit" : "Add New" ?> Issue</title>
43 <link rel=stylesheet href='<? echo $css_header ?>' type='text/css'>
45 <style>
46 td { font-size:10pt; }
47 </style>
49 <script type="text/javascript" src="../../../library/overlib_mini.js"></script>
50 <script type="text/javascript" src="../../../library/calendar.js"></script>
52 <script language="JavaScript">
54 var aopts = new Array();
56 // "Clickoptions" is a feature by Mark Leeds that provides for one-click
57 // access to preselected lists of issues in each category. Here we get
58 // the issue titles from the user-customizable file and write JavaScript
59 // statements that will build an array of arrays of Option objects.
61 $clickoptions = array();
62 if (is_file("../../../custom/clickoptions.txt"))
63 $clickoptions = file("../../../custom/clickoptions.txt");
64 $i = 0;
65 foreach ($arrtype as $key => $value) {
66 echo " aopts[$i] = new Array();\n";
67 foreach($clickoptions as $line) {
68 $line = trim($line);
69 if (substr($line, 0, 1) != "#") {
70 if (strpos($line, $key) !== false) {
71 $text = addslashes(substr($line, strpos($line, "::") + 2));
72 echo " aopts[$i][aopts[$i].length] = new Option('$text', '$text', false, false);\n";
76 ++$i;
80 // React to selection of an issue type. This loads the associated
81 // shortcuts into the selection list of titles.
82 function newtype(index) {
83 var theopts = document.forms[0].form_titles.options;
84 theopts.length = 0;
85 for (i = 0; i < aopts[index].length; ++i) {
86 theopts[i] = aopts[index][i];
90 // If a clickoption title is selected, copy it to the title field.
91 function set_text() {
92 var f = document.forms[0];
93 f.form_title.value = f.form_titles.options[f.form_titles.selectedIndex].text;
94 f.form_titles.selectedIndex = -1;
97 </script>
99 </head>
101 <body <?echo $top_bg_line;?>>
103 // If we are saving, then save and close the window.
105 if ($_POST['form_save']) {
107 $i = 0;
108 $text_type = "unknown";
109 foreach ($arrtype as $key => $value) {
110 if ($i++ == $_POST['form_type']) $text_type = $key;
113 if ($issue) {
114 sqlStatement("UPDATE lists SET " .
115 "type = '" . $text_type . "', " .
116 "title = '" . $_POST['form_title'] . "', " .
117 "comments = '" . $_POST['form_comments'] . "', " .
118 "begdate = " . QuotedOrNull(fixDate($_POST['form_begin'], '')) . ", " .
119 "enddate = " . QuotedOrNull(fixDate($_POST['form_end'], '')) . ", " .
120 "occurrence = '" . $_POST['form_occur'] . "', " .
121 "referredby = '" . $_POST['form_referredby'] . "', " .
122 "extrainfo = '" . $_POST['form_missed'] . "' " .
123 "WHERE id = '$issue'");
124 } else {
125 sqlInsert("INSERT INTO lists ( " .
126 "date, pid, type, title, activity, comments, begdate, enddate, " .
127 "occurrence, referredby, extrainfo, user, groupname " .
128 ") VALUES ( " .
129 "NOW(), " .
130 "'$pid', " .
131 "'" . $text_type . "', " .
132 "'" . $_POST['form_title'] . "', " .
133 "1, " .
134 "'" . $_POST['form_comments'] . "', " .
135 QuotedOrNull(fixDate($_POST['form_begin'], '')) . ", " .
136 QuotedOrNull(fixDate($_POST['form_end'], '')) . ", " .
137 "'" . $_POST['form_occur'] . "', " .
138 "'" . $_POST['form_referredby'] . "', " .
139 "'" . $_POST['form_missed'] . "', " .
140 "'" . $$_SESSION['authUser'] . "', " .
141 "'" . $$_SESSION['authProvider'] . "' )");
144 // Close this window and redisplay the updated list of issues.
146 echo "<script language='JavaScript'>\n";
147 if ($info_msg) echo " alert('$info_msg');\n";
148 echo " window.close();\n";
149 echo " opener.location.reload();\n";
150 echo "</script></body></html>\n";
151 exit();
154 $irow = array();
155 $type_index = 0;
156 if ($issue) {
157 $irow = sqlQuery("SELECT * FROM lists WHERE id = $issue");
158 foreach ($arrtype as $key => $value) {
159 if ($key == $irow['type']) break;
160 ++$type_index;
164 <!-- Required for the popup date selectors -->
165 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
167 <form method='post' name='theform' action='add_edit_issue.php?issue=<? echo $issue ?>'>
168 <center>
170 <table border='0' width='100%'>
172 <tr>
173 <td valign='top' width='1%' nowrap><b>Type:</b></td>
174 <td>
176 $index = 0;
177 foreach ($arrtype as $value) {
178 echo " <input type='radio' name='form_type' value='$index' onclick='newtype($index)'";
179 if ($index == $type_index) echo " checked";
180 echo " />$value&nbsp;\n";
181 ++$index;
184 </td>
185 </tr>
187 <tr>
188 <td valign='top' nowrap><b>Title:</b></td>
189 <td>
190 <select name='form_titles' size='4' onchange='set_text()' style='width:100%'>
191 </select><br>
192 <input type='text' size='40' name='form_title' value='<? echo $irow['title'] ?>' style='width:100%' />
193 </td>
194 </tr>
196 <tr>
197 <td valign='top' nowrap><b>Begin Date:</b></td>
198 <td>
199 <input type='text' size='10' name='form_begin' value='<? echo $irow['begdate'] ?>'
200 title='yyyy-mm-dd date of onset, surgery or start of medication' />
201 <a href="javascript:show_calendar('theform.form_begin')"
202 title="Click here to choose a date"
203 ><img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' border='0'></a>
204 </td>
205 </tr>
207 <tr>
208 <td valign='top' nowrap><b>End Date:</b></td>
209 <td>
210 <input type='text' size='10' name='form_end' value='<? echo $irow['enddate'] ?>'
211 title='yyyy-mm-dd date of recovery or end of medication' />
212 <a href="javascript:show_calendar('theform.form_end')"
213 title="Click here to choose a date"
214 ><img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' border='0'></a>
215 &nbsp;(leave blank if still active)
216 </td>
217 </tr>
219 <tr>
220 <td valign='top' nowrap><b>Occurrence:</b></td>
221 <td>
222 <select name='form_occur'>
224 foreach ($arroccur as $key => $value) {
225 echo " <option value='$key'";
226 if ($key == $irow['occurrence']) echo " selected";
227 echo ">$value\n";
230 </select>
231 </td>
232 </tr>
234 <? if ($GLOBALS['athletic_team']) { ?>
235 <tr>
236 <td valign='top' nowrap><b>Missed:</b></td>
237 <td>
238 <input type='text' size='3' name='form_missed' value='<? echo $irow['extrainfo'] ?>'
239 title='Number of games or events missed, if any' />
240 &nbsp;games/events
241 </td>
242 </tr>
243 <? } else { ?>
244 <tr>
245 <td valign='top' nowrap><b>Referred by:</b></td>
246 <td>
247 <input type='text' size='40' name='form_referredby' value='<? echo $irow['referredby'] ?>'
248 style='width:100%' title='Referring physician and practice' />
249 </td>
250 </tr>
251 <? } ?>
253 <tr>
254 <td valign='top' nowrap><b>Comments:</b></td>
255 <td>
256 <textarea name='form_comments' rows='4' cols='40' wrap='virtual' style='width:100%'><? echo $irow['comments'] ?></textarea>
257 </td>
258 </tr>
260 </table>
263 <input type='submit' name='form_save' value='Save' />
264 &nbsp;
265 <input type='button' value='Cancel' onclick='window.close()' />
266 </p>
268 </center>
269 </form>
270 <script language='JavaScript'>
271 newtype(<? echo $type_index ?>);
272 </script>
273 </body>
274 </html>