4 $sanitize_all_escapes=true;
7 //STOP FAKE REGISTER GLOBALS
8 $fake_register_globals=false;
11 include_once("../../globals.php");
12 include_once("$srcdir/lists.inc");
13 include_once("$srcdir/acl.inc");
14 include_once("$srcdir/options.inc.php");
15 include_once("$srcdir/formdata.inc.php");
18 <div id
="patient_stats_summary">
21 $thisauth = acl_check('patients', 'med');
23 $tmp = getPatientData($pid, "squad");
24 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
28 echo "<p>(".htmlspecialchars(xl('Issues not authorized'),ENT_NOQUOTES
).")</p>\n";
29 echo "</body>\n</html>\n";
34 <script type
='text/javascript'>
35 function load_location( location
) {
37 if ( !top
.frames
["RTop"] ) {
38 document
.location
=location
;
40 top
.frames
["RTop"].location
=location
;
45 <table id
="patient_stats_issues">
49 $erx_upload_complete = 0;
50 $old_key="";$display_current_medications_below=1;
51 foreach ($ISSUE_TYPES as $key => $arr) {
52 // $result = getListByType($pid, $key, "id,title,begdate,enddate,returndate,extrainfo", "all", "all", 0);
54 $query = "SELECT * FROM lists WHERE pid = ? AND type = ? AND ";
55 $query .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
56 if($GLOBALS['erx_enable'] && $GLOBALS['erx_medication_display'] && $key=='medication')
57 $query .= "and erx_uploaded != '1' ";
58 if($GLOBALS['erx_enable'] && $GLOBALS['erx_allergy_display'] && $key=='allergy')
59 $query .= "and erx_uploaded != '1' ";
60 $query .= "ORDER BY begdate";
61 $pres = sqlStatement($query, array($pid, $key) );
62 if($old_key=="medication" && $GLOBALS['erx_enable'] && $erx_upload_complete == 1)
64 $display_current_medications_below=0;
67 <table id
="patient_stats_prescriptions">
68 <?php
if($GLOBALS['erx_enable']){ ?
>
70 <?php
if ($_POST['embeddedScreen']) {
72 $widgetTitle = xl('Current Medications');
73 $widgetLabel = "current_prescriptions";
74 $widgetButtonLabel = '';
75 $widgetButtonLink = '';
77 $widgetButtonClass = '';
78 $bodyClass = "summary_item small";
80 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
85 $res=sqlStatement("select * from prescriptions where patient_id=? and active='1'",array($pid));
89 if(sqlNumRows($res)==0)
93 <td
><?php
echo htmlspecialchars(xl('None'), ENT_NOQUOTES
);?
></td
>
97 while($row_currentMed=sqlFetchArray($res))
99 $runit=generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'),htmlspecialchars($row_currentMed['unit'],ENT_NOQUOTES
));
100 $rin=generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'),htmlspecialchars($row_currentMed['form'],ENT_NOQUOTES
));
101 $rroute=generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'),htmlspecialchars($row_currentMed['route'],ENT_NOQUOTES
));
102 $rint=generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'),htmlspecialchars($row_currentMed['interval'],ENT_NOQUOTES
));
105 <td
><?php
echo htmlspecialchars($row_currentMed['drug'],ENT_NOQUOTES
);?
></td
>
108 if($row_currentMed['size']>0)
109 $unit=$row_currentMed['size']." ".$runit." ";
110 echo htmlspecialchars($unit." ".$row_currentMed['dosage']." ".$rin." ".$rroute." ".$rint,ENT_NOQUOTES
);
121 if (sqlNumRows($pres) > 0 ||
$arr[4] == 1) {
123 if ($_POST['embeddedScreen']) {
125 if($GLOBALS['erx_enable'] && $key == "medication"){
126 $query_uploaded = "SELECT * FROM lists WHERE pid = ? AND type = 'medication' AND ";
127 $query_uploaded .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
128 $query_uploaded .= "and erx_uploaded != '1' ";
129 $query_uploaded .= "ORDER BY begdate";
130 $res_uploaded = sqlStatement($query_uploaded, array($pid) );
131 if(sqlNumRows($res_uploaded) == 0){
132 $erx_upload_complete = 1;
138 // Issues expand collapse widget
139 $widgetTitle = $arr[0];
141 if(($key == "allergy" ||
$key == "medication") && $GLOBALS['erx_enable'])
143 $widgetButtonLabel = xl("Add");
144 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/eRx.php?page=medentry\")";
148 $widgetButtonLabel = xl("Edit");
149 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=" . $key . "\")";
151 $widgetButtonClass = "";
152 $linkMethod = "javascript";
153 $bodyClass = "summary_item small";
156 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
159 <tr
class='issuetitle'>
160 <td colspan
='$numcols'>
161 <span
class="text"><b
><?php
echo htmlspecialchars($arr[0],ENT_NOQUOTES
); ?
></b
></span
>
162 <a href
="javascript:;" class="small" onclick
="load_location('stats_full.php?active=all&category=" . $key . "')">
163 (<b
><?php
echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES
); ?
></b
>)
169 if (sqlNumRows($pres) == 0) {
170 if ( getListTouch($pid,$key) ) {
171 // Data entry has happened to this type, so can display an explicit None.
172 echo " <tr><td colspan='$numcols' class='text'> " . htmlspecialchars( xl('None'), ENT_NOQUOTES
) . "</td></tr>\n";
175 // Data entry has not happened to this type, so show 'Nothing Recorded"
176 echo " <tr><td colspan='$numcols' class='text'> " . htmlspecialchars( xl('Nothing Recorded'), ENT_NOQUOTES
) . "</td></tr>\n";
180 while ($row = sqlFetchArray($pres)) {
181 // output each issue for the $ISSUE_TYPE
182 if (!$row['enddate'] && !$row['returndate'])
183 $rowclass="noend_noreturn";
184 else if (!$row['enddate'] && $row['returndate'])
186 else if ($row['enddate'] && !$row['returndate'])
187 $rowclass = "noreturn";
189 echo " <tr class='text $rowclass;'>\n";
191 //turn allergies red and bold and show the reaction (if exist)
192 if ($key == "allergy") {
194 if (!empty($row['reaction'])) {
195 $reaction = " (" . $row['reaction'] . ")";
197 echo " <td colspan='$numcols' style='color:red;font-weight:bold;'> " . htmlspecialchars( $row['title'] . $reaction, ENT_NOQUOTES
) . "</td>\n";
200 echo " <td colspan='$numcols'> " . htmlspecialchars($row['title'],ENT_NOQUOTES
) . "</td>\n";
206 if ($_POST['embeddedScreen']) {
207 echo "</div></td></tr>";
213 </table
> <!-- end patient_stats_issues
-->
215 <table id
="patient_stats_spreadsheets">
218 // Show spreadsheet forms if any are present.
221 foreach (array('treatment_protocols','injury_log') as $formname) {
222 if (sqlNumRows(sqlStatement("SHOW TABLES LIKE ?", array("form_".$formname) )) > 0) {
223 $dres = sqlStatement("SELECT tp.id, tp.value FROM forms, " .
224 "form_" . add_escape_custom($formname) .
225 " AS tp WHERE forms.pid = ? AND " .
226 "forms.formdir = ? AND tp.id = forms.form_id AND " .
227 "tp.rownbr = -1 AND tp.colnbr = -1 AND tp.value LIKE '0%' " .
228 "ORDER BY tp.value DESC", array($pid, $formname) );
229 if (sqlNumRows($dres) > 0 && $need_head) {
232 echo " <td colspan='$numcols' valign='top'>\n";
233 echo " <span class='title'>Injury Log</span>\n";
237 while ($row = sqlFetchArray($dres)) {
238 list($completed, $start_date, $template_name) = explode('|', $row['value'], 3);
240 echo " <td colspan='$numcols'> ";
241 echo "<a class='link' href='javascript:;' ";
242 echo "onclick='load_location(\"../../forms/$formname/new.php?popup=1&id=";
243 echo htmlspecialchars($row['id'],ENT_QUOTES
) . "\")'>" .
244 htmlspecialchars($start_date,ENT_NOQUOTES
) . " " .
245 htmlspecialchars($template_name,ENT_NOQUOTES
) . "</a></td>\n";
251 </table
> <!-- end patient_stats_spreadsheets
-->
253 <?php
if (!$GLOBALS['disable_immunizations'] && !$GLOBALS['weight_loss_clinic']) { ?
>
255 <table id
="patient_stats_imm">
257 <?php
if ($_POST['embeddedScreen']) {
259 // Issues expand collapse widget
260 $widgetTitle = xl('Immunizations');
261 $widgetLabel = "immunizations";
262 $widgetButtonLabel = xl("Edit");
263 $widgetButtonLink = "javascript:load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/immunizations.php\")";
264 $widgetButtonClass = "";
265 $linkMethod = "javascript";
266 $bodyClass = "summary_item small";
269 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
272 <td colspan
='<?php echo $numcols ?>' valign
='top'>
273 <span
class="text"><b
><?php
echo htmlspecialchars(xl('Immunizations', 'e'),ENT_NOQUOTES
); ?
></b
></span
>
274 <a href
="javascript:;" class="small" onclick
="javascript:load_location('immunizations.php')">
275 (<b
><?php
echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES
) ?
></b
>)
282 $sql = "select i1.id as id, i1.immunization_id as immunization_id, i1.cvx_code as cvx_code, c.code_text_short as cvx_text, ".
283 " if (i1.administered_date, concat(i1.administered_date,' - '), substring(i1.note,1,20)) as immunization_data ".
284 " from immunizations i1 ".
285 " left join code_types ct on ct.ct_key = 'CVX' ".
286 " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ".
287 " where i1.patient_id = ? ".
288 " and i1.added_erroneously = 0".
289 " order by i1.administered_date desc";
291 $result = sqlStatement($sql, array($pid) );
293 if (sqlNumRows($result) == 0) {
294 echo " <table><tr>\n";
295 echo " <td colspan='$numcols' class='text'> " . htmlspecialchars( xl('None'), ENT_NOQUOTES
) . "</td>\n";
296 echo " </tr></table>\n";
299 while ($row=sqlFetchArray($result)){
301 echo "<a class='link'";
302 echo "' href='javascript:;' onclick='javascript:load_location(\"immunizations.php?mode=edit&id=".htmlspecialchars($row['id'],ENT_QUOTES
) . "\")'>" .
303 htmlspecialchars($row{'immunization_data'},ENT_NOQUOTES
);
305 // Figure out which name to use (ie. from cvx list or from the custom list)
306 if ($GLOBALS['use_custom_immun_list']) {
307 echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
310 if (!(empty($row['cvx_text']))) {
311 echo htmlspecialchars( xl($row['cvx_text']), ENT_NOQUOTES
);
314 echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
321 <?php
if ($_POST['embeddedScreen']) {
322 echo "</td></tr></div>";
327 </table
> <!-- end patient_stats_imm
-->
331 <?php
if (!$GLOBALS['disable_prescriptions']) { ?
>
333 <table id
="patient_stats_prescriptions">
334 <?php
if($GLOBALS['erx_enable'] && $display_current_medications_below==1){ ?
>
336 <?php
if ($_POST['embeddedScreen']) {
338 $widgetTitle = xl('Current Medications');
339 $widgetLabel = "current_prescriptions";
340 $widgetButtonLabel = '';
341 $widgetButtonLink = '';
343 $widgetButtonClass = '';
344 $bodyClass = "summary_item small";
346 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
351 $res=sqlStatement("select * from prescriptions where patient_id=? and active='1'",array($pid));
355 if(sqlNumRows($res)==0)
359 <td
><?php
echo htmlspecialchars(xl('None'), ENT_NOQUOTES
);?
></td
>
363 while($row_currentMed=sqlFetchArray($res))
365 $runit=generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'),$row_currentMed['unit']);
366 $rin=generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'),$row_currentMed['form']);
367 $rroute=generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'),$row_currentMed['route']);
368 $rint=generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'),$row_currentMed['interval']);
371 <td
><?php
echo $row_currentMed['drug'];?
></td
>
372 <td
><?php
$unit=''; if($row_currentMed['size']>0) $unit=$row_currentMed['size']." ".$runit." "; echo htmlspecialchars($unit." ".$row_currentMed['dosage']." ".$rin." ".$rroute." ".$rint,ENT_NOQUOTES
);?
></td
>
380 <tr
><td colspan
='<?php echo $numcols ?>' class='issuetitle'>
382 <?php
if ($_POST['embeddedScreen']) {
383 // Issues expand collapse widget
384 $widgetLabel = "prescriptions";
385 $linkMethod = "html";
386 if($GLOBALS['erx_enable'])
388 $widgetTitle = xl('Prescription History');
389 $widgetButtonLabel = xl("Add/Edit eRx");
390 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/eRx.php?page=compose";
391 $widgetButtonClass = "";
395 $widgetTitle = xl('Prescription');
396 $widgetButtonLabel = xl("Edit");
397 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/rx_frameset.php";
398 $widgetButtonClass = "iframe rx_modal";
400 $bodyClass = "summary_item small";
403 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
406 <span
class='text'><b
><?php
echo htmlspecialchars(xl('Prescriptions'),ENT_NOQUOTES
); ?
></b
></span
>
414 require_once("library/classes/Controller.class.php");
415 $c = new Controller();
416 echo $c->act(array("prescription" => "", "fragment" => "", "patient_id" => $pid));
419 <?php
if ($_POST['embeddedScreen']) {
427 if($erx_upload_complete == 1){
429 // Old Medication Widget
430 $widgetTitle = "Old Medication";
431 $widgetLabel = "old_medication";
432 $widgetButtonLabel = xl("Edit");
433 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=medication\")";
434 $widgetButtonClass = "";
435 $linkMethod = "javascript";
436 $bodyClass = "summary_item small";
439 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
440 $query_uploaded_old = "SELECT * FROM lists WHERE pid = ? AND type = 'medication' AND ";
441 $query_uploaded_old .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
442 $query_uploaded_old .= "ORDER BY begdate";
443 $res_uploaded_old = sqlStatement($query_uploaded_old, array($pid) );
445 while ($row = sqlFetchArray($res_uploaded_old)) {
446 // output each issue for the $ISSUE_TYPE
447 if (!$row['enddate'] && !$row['returndate'])
448 $rowclass="noend_noreturn";
449 else if (!$row['enddate'] && $row['returndate'])
451 else if ($row['enddate'] && !$row['returndate'])
452 $rowclass = "noreturn";
453 echo " <tr class='text $rowclass;'>\n";
454 echo " <td colspan='$numcols'> " . htmlspecialchars($row['title'],ENT_NOQUOTES
) . "</td>\n";
458 echo "</div></td></tr>";
462 </table
> <!-- end patient_stats_prescriptions
-->
464 </div
> <!-- end patient_stats_summary
-->