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!");
22 'medical_problem' => 'Problem',
23 'allergy' => 'Allergy',
24 'medication' => 'Medication',
25 'surgery' => 'Surgery'
29 0 => 'Unknown or N/A',
33 4 => 'Chronic/Recurrent',
34 5 => 'Acute on Chronic'
37 function QuotedOrNull($fld) {
38 if ($fld) return "'$fld'";
45 <title
><?
echo $issue ?
"Edit" : "Add New" ?
> Issue
</title
>
46 <link rel
=stylesheet href
='<? echo $css_header ?>' type
='text/css'>
49 td
{ font
-size
:10pt
; }
52 <script type
="text/javascript" src
="../../../library/overlib_mini.js"></script
>
53 <script type
="text/javascript" src
="../../../library/calendar.js"></script
>
54 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
56 <script language
="JavaScript">
58 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
60 var aopts
= new Array();
62 // "Clickoptions" is a feature by Mark Leeds that provides for one-click
63 // access to preselected lists of issues in each category. Here we get
64 // the issue titles from the user-customizable file and write JavaScript
65 // statements that will build an array of arrays of Option objects.
67 $clickoptions = array();
68 if (is_file("../../../custom/clickoptions.txt"))
69 $clickoptions = file("../../../custom/clickoptions.txt");
71 foreach ($arrtype as $key => $value) {
72 echo " aopts[$i] = new Array();\n";
73 foreach($clickoptions as $line) {
75 if (substr($line, 0, 1) != "#") {
76 if (strpos($line, $key) !== false) {
77 $text = addslashes(substr($line, strpos($line, "::") +
2));
78 echo " aopts[$i][aopts[$i].length] = new Option('$text', '$text', false, false);\n";
86 // React to selection of an issue type. This loads the associated
87 // shortcuts into the selection list of titles.
88 function newtype(index
) {
89 var theopts
= document
.forms
[0].form_titles
.options
;
91 for (i
= 0; i
< aopts
[index
].length
; ++i
) {
92 theopts
[i
] = aopts
[index
][i
];
96 // If a clickoption title is selected, copy it to the title field.
98 var f
= document
.forms
[0];
99 f
.form_title
.value
= f
.form_titles
.options
[f
.form_titles
.selectedIndex
].text
;
100 f
.form_titles
.selectedIndex
= -1;
107 <body
<?
echo $top_bg_line;?
>>
109 // If we are saving, then save and close the window.
111 if ($_POST['form_save']) {
114 $text_type = "unknown";
115 foreach ($arrtype as $key => $value) {
116 if ($i++
== $_POST['form_type']) $text_type = $key;
119 $form_begin = fixDate($_POST['form_begin'], '');
120 $form_end = fixDate($_POST['form_end'], '');
123 sqlStatement("UPDATE lists SET " .
124 "type = '" . $text_type . "', " .
125 "title = '" . $_POST['form_title'] . "', " .
126 "comments = '" . $_POST['form_comments'] . "', " .
127 "begdate = " . QuotedOrNull($form_begin) . ", " .
128 "enddate = " . QuotedOrNull($form_end) . ", " .
129 "diagnosis = '" . $_POST['form_diagnosis'] . "', " .
130 "occurrence = '" . $_POST['form_occur'] . "', " .
131 "referredby = '" . $_POST['form_referredby'] . "', " .
132 "extrainfo = '" . $_POST['form_missed'] . "' " .
133 "WHERE id = '$issue'");
135 $issue = sqlInsert("INSERT INTO lists ( " .
136 "date, pid, type, title, activity, comments, begdate, enddate, " .
137 "diagnosis, occurrence, referredby, extrainfo, user, groupname " .
141 "'" . $text_type . "', " .
142 "'" . $_POST['form_title'] . "', " .
144 "'" . $_POST['form_comments'] . "', " .
145 QuotedOrNull($form_begin) . ", " .
146 QuotedOrNull($form_end) . ", " .
147 "'" . $_POST['form_diagnosis'] . "', " .
148 "'" . $_POST['form_occur'] . "', " .
149 "'" . $_POST['form_referredby'] . "', " .
150 "'" . $_POST['form_missed'] . "', " .
151 "'" . $
$_SESSION['authUser'] . "', " .
152 "'" . $
$_SESSION['authProvider'] . "' )");
155 $tmp_title = substr($arrtype[$text_type], 0, 1) . ": $form_begin " .
156 substr($_POST['form_title'], 0, 40);
158 // Close this window and redisplay the updated list of issues.
160 echo "<script language='JavaScript'>\n";
161 if ($info_msg) echo " alert('$info_msg');\n";
162 echo " window.close();\n";
163 // echo " opener.location.reload();\n";
164 echo " if (opener.refreshIssue) opener.refreshIssue($issue,'$tmp_title');\n";
165 echo "</script></body></html>\n";
173 $irow = sqlQuery("SELECT * FROM lists WHERE id = $issue");
174 foreach ($arrtype as $key => $value) {
175 if ($key == $irow['type']) break;
178 // Get all of the eligible diagnoses.
179 // We include the pid in this search for better performance,
180 // because it's part of the primary key:
181 $bres = sqlStatement(
182 "SELECT DISTINCT billing.code, billing.code_text " .
183 "FROM issue_encounter, billing WHERE " .
184 "issue_encounter.pid = '$pid' AND " .
185 "issue_encounter.list_id = '$issue' AND " .
186 "billing.encounter = issue_encounter.encounter AND " .
187 "( billing.code_type LIKE 'ICD%' OR " .
188 "billing.code_type LIKE 'OSICS' )"
192 <!-- Required
for the popup date selectors
-->
193 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
195 <form method
='post' name
='theform' action
='add_edit_issue.php?issue=<? echo $issue ?>'>
198 <table border
='0' width
='100%'>
201 <td valign
='top' width
='1%' nowrap
><b
>Type
:</b
></td
>
205 foreach ($arrtype as $value) {
206 echo " <input type='radio' name='form_type' value='$index' onclick='newtype($index)'";
207 if ($index == $type_index) echo " checked";
208 echo " />$value \n";
216 <td valign
='top' nowrap
><b
>Title
:</b
></td
>
218 <select name
='form_titles' size
='4' onchange
='set_text()' style
='width:100%'>
220 <input type
='text' size
='40' name
='form_title' value
='<? echo $irow['title
'] ?>' style
='width:100%' />
225 <td valign
='top' nowrap
><b
>Begin Date
:</b
></td
>
227 <input type
='text' size
='10' name
='form_begin' value
='<? echo $irow['begdate
'] ?>'
228 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
229 title
='yyyy-mm-dd date of onset, surgery or start of medication' />
230 <a href
="javascript:show_calendar('theform.form_begin')"
231 title
="Click here to choose a date"
232 ><img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
237 <td valign
='top' nowrap
><b
>End Date
:</b
></td
>
239 <input type
='text' size
='10' name
='form_end' value
='<? echo $irow['enddate
'] ?>'
240 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
241 title
='yyyy-mm-dd date of recovery or end of medication' />
242 <a href
="javascript:show_calendar('theform.form_end')"
243 title
="Click here to choose a date"
244 ><img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
245  
;(leave blank
if still active
)
250 <td valign
='top' nowrap
><b
>Diagnosis
:</b
></td
>
252 <select name
='form_diagnosis' title
='Diagnosis must be coded into a linked encounter'>
253 <option value
="">Unknown
or N
/A
</option
>
255 while ($brow = sqlFetchArray($bres)) {
256 echo " <option value='" . $brow['code'] . "'";
257 if ($brow['code'] == $irow['diagnosis']) echo " selected";
258 echo ">" . $brow['code'] . " " . substr($brow['code_text'], 0, 40) . "</option>\n";
266 <td valign
='top' nowrap
><b
>Occurrence
:</b
></td
>
268 <select name
='form_occur'>
270 foreach ($arroccur as $key => $value) {
271 echo " <option value='$key'";
272 if ($key == $irow['occurrence']) echo " selected";
280 <?
if ($GLOBALS['athletic_team']) { ?
>
282 <td valign
='top' nowrap
><b
>Missed
:</b
></td
>
284 <input type
='text' size
='3' name
='form_missed' value
='<? echo $irow['extrainfo
'] ?>'
285 title
='Number of games or events missed, if any' />
291 <td valign
='top' nowrap
><b
>Referred by
:</b
></td
>
293 <input type
='text' size
='40' name
='form_referredby' value
='<? echo $irow['referredby
'] ?>'
294 style
='width:100%' title
='Referring physician and practice' />
300 <td valign
='top' nowrap
><b
>Comments
:</b
></td
>
302 <textarea name
='form_comments' rows
='4' cols
='40' wrap
='virtual' style
='width:100%'><?
echo $irow['comments'] ?
></textarea
>
309 <input type
='submit' name
='form_save' value
='Save' />
311 <input type
='button' value
='Cancel' onclick
='window.close()' />
316 <script language
='JavaScript'>
317 newtype(<?
echo $type_index ?
>);