2 // Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
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/acl.inc");
14 $issue = $_REQUEST['issue'];
17 $thisauth = acl_check('patients', 'med');
18 if ($issue && $thisauth != 'write') die("Edit is not authorized!");
19 if ($thisauth != 'write' && $thisauth != 'addonly') die("Add is not authorized!");
21 $tmp = getPatientData($pid, "squad");
22 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
23 die("Not authorized for this squad!");
26 0 => 'Unknown or N/A',
30 4 => 'Chronic/Recurrent',
31 5 => 'Acute on Chronic'
34 function QuotedOrNull($fld) {
35 if ($fld) return "'$fld'";
42 <title
><?
echo $issue ?
"Edit" : "Add New" ?
> Issue
</title
>
43 <link rel
=stylesheet href
='<? echo $css_header ?>' type
='text/css'>
46 td
{ font
-size
:10pt
; }
49 <script type
="text/javascript" src
="../../../library/overlib_mini.js"></script
>
50 <script type
="text/javascript" src
="../../../library/calendar.js"></script
>
51 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
53 <script language
="JavaScript">
55 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
57 var aopts
= new Array();
59 // "Clickoptions" is a feature by Mark Leeds that provides for one-click
60 // access to preselected lists of issues in each category. Here we get
61 // the issue titles from the user-customizable file and write JavaScript
62 // statements that will build an array of arrays of Option objects.
64 $clickoptions = array();
65 if (is_file("../../../custom/clickoptions.txt"))
66 $clickoptions = file("../../../custom/clickoptions.txt");
68 foreach ($ISSUE_TYPES as $key => $value) {
69 echo " aopts[$i] = new Array();\n";
70 foreach($clickoptions as $line) {
72 if (substr($line, 0, 1) != "#") {
73 if (strpos($line, $key) !== false) {
74 $text = addslashes(substr($line, strpos($line, "::") +
2));
75 echo " aopts[$i][aopts[$i].length] = new Option('$text', '$text', false, false);\n";
83 // React to selection of an issue type. This loads the associated
84 // shortcuts into the selection list of titles.
85 function newtype(index
) {
86 var theopts
= document
.forms
[0].form_titles
.options
;
88 for (i
= 0; i
< aopts
[index
].length
; ++i
) {
89 theopts
[i
] = aopts
[index
][i
];
93 // If a clickoption title is selected, copy it to the title field.
95 var f
= document
.forms
[0];
96 f
.form_title
.value
= f
.form_titles
.options
[f
.form_titles
.selectedIndex
].text
;
97 f
.form_titles
.selectedIndex
= -1;
104 <body
<?
echo $top_bg_line;?
>>
106 // If we are saving, then save and close the window.
108 if ($_POST['form_save']) {
111 $text_type = "unknown";
112 foreach ($ISSUE_TYPES as $key => $value) {
113 if ($i++
== $_POST['form_type']) $text_type = $key;
116 $form_begin = fixDate($_POST['form_begin'], '');
117 $form_end = fixDate($_POST['form_end'], '');
120 sqlStatement("UPDATE lists SET " .
121 "type = '" . $text_type . "', " .
122 "title = '" . $_POST['form_title'] . "', " .
123 "comments = '" . $_POST['form_comments'] . "', " .
124 "begdate = " . QuotedOrNull($form_begin) . ", " .
125 "enddate = " . QuotedOrNull($form_end) . ", " .
126 "diagnosis = '" . $_POST['form_diagnosis'] . "', " .
127 "occurrence = '" . $_POST['form_occur'] . "', " .
128 "referredby = '" . $_POST['form_referredby'] . "', " .
129 "extrainfo = '" . $_POST['form_missed'] . "' " .
130 "WHERE id = '$issue'");
132 $issue = sqlInsert("INSERT INTO lists ( " .
133 "date, pid, type, title, activity, comments, begdate, enddate, " .
134 "diagnosis, occurrence, referredby, extrainfo, user, groupname " .
138 "'" . $text_type . "', " .
139 "'" . $_POST['form_title'] . "', " .
141 "'" . $_POST['form_comments'] . "', " .
142 QuotedOrNull($form_begin) . ", " .
143 QuotedOrNull($form_end) . ", " .
144 "'" . $_POST['form_diagnosis'] . "', " .
145 "'" . $_POST['form_occur'] . "', " .
146 "'" . $_POST['form_referredby'] . "', " .
147 "'" . $_POST['form_missed'] . "', " .
148 "'" . $
$_SESSION['authUser'] . "', " .
149 "'" . $
$_SESSION['authProvider'] . "' )");
152 $tmp_title = $ISSUE_TYPES[$text_type][2] . ": $form_begin " .
153 substr($_POST['form_title'], 0, 40);
155 // Close this window and redisplay the updated list of issues.
157 echo "<script language='JavaScript'>\n";
158 if ($info_msg) echo " alert('$info_msg');\n";
159 echo " window.close();\n";
160 // echo " opener.location.reload();\n";
161 echo " if (opener.refreshIssue) opener.refreshIssue($issue,'$tmp_title');\n";
162 echo "</script></body></html>\n";
170 $irow = sqlQuery("SELECT * FROM lists WHERE id = $issue");
171 foreach ($ISSUE_TYPES as $key => $value) {
172 if ($key == $irow['type']) break;
175 // Get all of the eligible diagnoses.
176 // We include the pid in this search for better performance,
177 // because it's part of the primary key:
178 $bres = sqlStatement(
179 "SELECT DISTINCT billing.code, billing.code_text " .
180 "FROM issue_encounter, billing WHERE " .
181 "issue_encounter.pid = '$pid' AND " .
182 "issue_encounter.list_id = '$issue' AND " .
183 "billing.encounter = issue_encounter.encounter AND " .
184 "( billing.code_type LIKE 'ICD%' OR " .
185 "billing.code_type LIKE 'OSICS' )"
189 <!-- Required
for the popup date selectors
-->
190 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
192 <form method
='post' name
='theform' action
='add_edit_issue.php?issue=<? echo $issue ?>'>
195 <table border
='0' width
='100%'>
198 <td valign
='top' width
='1%' nowrap
><b
>Type
:</b
></td
>
202 foreach ($ISSUE_TYPES as $value) {
203 echo " <input type='radio' name='form_type' value='$index' onclick='newtype($index)'";
204 if ($index == $type_index) echo " checked";
205 echo " />" . $value[1] . " \n";
213 <td valign
='top' nowrap
><b
>Title
:</b
></td
>
215 <select name
='form_titles' size
='4' onchange
='set_text()' style
='width:100%'>
217 <input type
='text' size
='40' name
='form_title' value
='<? echo $irow['title
'] ?>' style
='width:100%' />
222 <td valign
='top' nowrap
><b
>Begin Date
:</b
></td
>
224 <input type
='text' size
='10' name
='form_begin' value
='<? echo $irow['begdate
'] ?>'
225 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
226 title
='yyyy-mm-dd date of onset, surgery or start of medication' />
227 <a href
="javascript:show_calendar('theform.form_begin')"
228 title
="Click here to choose a date"
229 ><img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
234 <td valign
='top' nowrap
><b
>End Date
:</b
></td
>
236 <input type
='text' size
='10' name
='form_end' value
='<? echo $irow['enddate
'] ?>'
237 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
238 title
='yyyy-mm-dd date of recovery or end of medication' />
239 <a href
="javascript:show_calendar('theform.form_end')"
240 title
="Click here to choose a date"
241 ><img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
242  
;(leave blank
if still active
)
247 <td valign
='top' nowrap
><b
>Diagnosis
:</b
></td
>
249 <select name
='form_diagnosis' title
='Diagnosis must be coded into a linked encounter'>
250 <option value
="">Unknown
or N
/A
</option
>
252 while ($brow = sqlFetchArray($bres)) {
253 echo " <option value='" . $brow['code'] . "'";
254 if ($brow['code'] == $irow['diagnosis']) echo " selected";
255 echo ">" . $brow['code'] . " " . substr($brow['code_text'], 0, 40) . "</option>\n";
263 <td valign
='top' nowrap
><b
>Occurrence
:</b
></td
>
265 <select name
='form_occur'>
267 foreach ($arroccur as $key => $value) {
268 echo " <option value='$key'";
269 if ($key == $irow['occurrence']) echo " selected";
277 <?
if ($GLOBALS['athletic_team']) { ?
>
279 <td valign
='top' nowrap
><b
>Missed
:</b
></td
>
281 <input type
='text' size
='3' name
='form_missed' value
='<? echo $irow['extrainfo
'] ?>'
282 title
='Number of games or events missed, if any' />
288 <td valign
='top' nowrap
><b
>Referred by
:</b
></td
>
290 <input type
='text' size
='40' name
='form_referredby' value
='<? echo $irow['referredby
'] ?>'
291 style
='width:100%' title
='Referring physician and practice' />
297 <td valign
='top' nowrap
><b
>Comments
:</b
></td
>
299 <textarea name
='form_comments' rows
='4' cols
='40' wrap
='virtual' style
='width:100%'><?
echo $irow['comments'] ?
></textarea
>
306 <input type
='submit' name
='form_save' value
='Save' />
308 <input type
='button' value
='Cancel' onclick
='window.close()' />
313 <script language
='JavaScript'>
314 newtype(<?
echo $type_index ?
>);