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">
50 $erx_upload_complete = 0;
51 $old_key="";$display_current_medications_below=1;
52 foreach ($ISSUE_TYPES as $key => $arr) {
53 // $result = getListByType($pid, $key, "id,title,begdate,enddate,returndate,extrainfo", "all", "all", 0);
55 $query = "SELECT * FROM lists WHERE pid = ? AND type = ? AND ";
56 $query .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
57 if($GLOBALS['erx_enable'] && $GLOBALS['erx_medication_display'] && $key=='medication')
58 $query .= "and erx_uploaded != '1' ";
59 if($GLOBALS['erx_enable'] && $GLOBALS['erx_allergy_display'] && $key=='allergy')
60 $query .= "and erx_uploaded != '1' ";
61 $query .= "ORDER BY begdate";
62 $pres = sqlStatement($query, array($pid, $key) );
63 if($old_key=="medication" && $GLOBALS['erx_enable'] && $erx_upload_complete == 1)
65 $display_current_medications_below=0;
68 <table id
="patient_stats_prescriptions">
69 <?php
if($GLOBALS['erx_enable']){ ?
>
71 <?php
if ($_POST['embeddedScreen']) {
73 $widgetTitle = xl('Current Medications');
74 $widgetLabel = "current_prescriptions";
75 $widgetButtonLabel = '';
76 $widgetButtonLink = '';
78 $widgetButtonClass = '';
79 $bodyClass = "summary_item small";
81 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
86 $res=sqlStatement("select * from prescriptions where patient_id=? and active='1'",array($pid));
90 if(sqlNumRows($res)==0)
94 <td
><?php
echo htmlspecialchars(xl('None'), ENT_NOQUOTES
);?
></td
>
98 while($row_currentMed=sqlFetchArray($res))
100 $runit=generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'),htmlspecialchars($row_currentMed['unit'],ENT_NOQUOTES
));
101 $rin=generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'),htmlspecialchars($row_currentMed['form'],ENT_NOQUOTES
));
102 $rroute=generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'),htmlspecialchars($row_currentMed['route'],ENT_NOQUOTES
));
103 $rint=generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'),htmlspecialchars($row_currentMed['interval'],ENT_NOQUOTES
));
106 <td
><?php
echo htmlspecialchars($row_currentMed['drug'],ENT_NOQUOTES
);?
></td
>
109 if($row_currentMed['size']>0)
110 $unit=$row_currentMed['size']." ".$runit." ";
111 echo htmlspecialchars($unit." ".$row_currentMed['dosage']." ".$rin." ".$rroute." ".$rint,ENT_NOQUOTES
);
122 if (sqlNumRows($pres) > 0 ||
$ix == 0 ||
$key == "allergy" ||
$key == "medication") {
124 if ($_POST['embeddedScreen']) {
126 if($GLOBALS['erx_enable'] && $key == "medication"){
127 $query_uploaded = "SELECT * FROM lists WHERE pid = ? AND type = 'medication' AND ";
128 $query_uploaded .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
129 $query_uploaded .= "and erx_uploaded != '1' ";
130 $query_uploaded .= "ORDER BY begdate";
131 $res_uploaded = sqlStatement($query_uploaded, array($pid) );
132 if(sqlNumRows($res_uploaded) == 0){
133 $erx_upload_complete = 1;
139 // Issues expand collapse widget
140 $widgetTitle = $arr[0];
142 if(($key == "allergy" ||
$key == "medication") && $GLOBALS['erx_enable'])
144 $widgetButtonLabel = xl("Add");
145 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/eRx.php?page=medentry\")";
149 $widgetButtonLabel = xl("Edit");
150 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=" . $key . "\")";
152 $widgetButtonClass = "";
153 $linkMethod = "javascript";
154 $bodyClass = "summary_item small";
157 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
160 <tr
class='issuetitle'>
161 <td colspan
='$numcols'>
162 <span
class="text"><b
><?php
echo htmlspecialchars($arr[0],ENT_NOQUOTES
); ?
></b
></span
>
163 <a href
="javascript:;" class="small" onclick
="load_location('stats_full.php?active=all&category=" . $key . "')">
164 (<b
><?php
echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES
); ?
></b
>)
170 if (sqlNumRows($pres) == 0) {
171 if ( getListTouch($pid,$key) ) {
172 // Data entry has happened to this type, so can display an explicit None.
173 echo " <tr><td colspan='$numcols' class='text'> " . htmlspecialchars( xl('None'), ENT_NOQUOTES
) . "</td></tr>\n";
176 // Data entry has not happened to this type, so show 'Nothing Recorded"
177 echo " <tr><td colspan='$numcols' class='text'> " . htmlspecialchars( xl('Nothing Recorded'), ENT_NOQUOTES
) . "</td></tr>\n";
181 while ($row = sqlFetchArray($pres)) {
182 // output each issue for the $ISSUE_TYPE
183 if (!$row['enddate'] && !$row['returndate'])
184 $rowclass="noend_noreturn";
185 else if (!$row['enddate'] && $row['returndate'])
187 else if ($row['enddate'] && !$row['returndate'])
188 $rowclass = "noreturn";
190 echo " <tr class='text $rowclass;'>\n";
192 //turn allergies red and bold and show the reaction (if exist)
193 if ($key == "allergy") {
195 if (!empty($row['reaction'])) {
196 $reaction = " (" . $row['reaction'] . ")";
198 echo " <td colspan='$numcols' style='color:red;font-weight:bold;'> " . htmlspecialchars( $row['title'] . $reaction, ENT_NOQUOTES
) . "</td>\n";
201 echo " <td colspan='$numcols'> " . htmlspecialchars($row['title'],ENT_NOQUOTES
) . "</td>\n";
207 if ($_POST['embeddedScreen']) {
208 echo "</div></td></tr>";
215 </table
> <!-- end patient_stats_issues
-->
217 <table id
="patient_stats_spreadsheets">
220 // Show spreadsheet forms if any are present.
223 foreach (array('treatment_protocols','injury_log') as $formname) {
224 if (sqlNumRows(sqlStatement("SHOW TABLES LIKE ?", array("form_".$formname) )) > 0) {
225 $dres = sqlStatement("SELECT tp.id, tp.value FROM forms, " .
226 "form_" . add_escape_custom($formname) .
227 " AS tp WHERE forms.pid = ? AND " .
228 "forms.formdir = ? AND tp.id = forms.form_id AND " .
229 "tp.rownbr = -1 AND tp.colnbr = -1 AND tp.value LIKE '0%' " .
230 "ORDER BY tp.value DESC", array($pid, $formname) );
231 if (sqlNumRows($dres) > 0 && $need_head) {
234 echo " <td colspan='$numcols' valign='top'>\n";
235 echo " <span class='title'>Injury Log</span>\n";
239 while ($row = sqlFetchArray($dres)) {
240 list($completed, $start_date, $template_name) = explode('|', $row['value'], 3);
242 echo " <td colspan='$numcols'> ";
243 echo "<a class='link' href='javascript:;' ";
244 echo "onclick='load_location(\"../../forms/$formname/new.php?popup=1&id=";
245 echo htmlspecialchars($row['id'],ENT_QUOTES
) . "\")'>" .
246 htmlspecialchars($start_date,ENT_NOQUOTES
) . " " .
247 htmlspecialchars($template_name,ENT_NOQUOTES
) . "</a></td>\n";
253 </table
> <!-- end patient_stats_spreadsheets
-->
255 <?php
if (!$GLOBALS['disable_immunizations'] && !$GLOBALS['weight_loss_clinic']) { ?
>
257 <table id
="patient_stats_imm">
259 <?php
if ($_POST['embeddedScreen']) {
261 // Issues expand collapse widget
262 $widgetTitle = xl('Immunizations');
263 $widgetLabel = "immunizations";
264 $widgetButtonLabel = xl("Edit");
265 $widgetButtonLink = "javascript:load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/immunizations.php\")";
266 $widgetButtonClass = "";
267 $linkMethod = "javascript";
268 $bodyClass = "summary_item small";
271 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
274 <td colspan
='<?php echo $numcols ?>' valign
='top'>
275 <span
class="text"><b
><?php
echo htmlspecialchars(xl('Immunizations', 'e'),ENT_NOQUOTES
); ?
></b
></span
>
276 <a href
="javascript:;" class="small" onclick
="javascript:load_location('immunizations.php')">
277 (<b
><?php
echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES
) ?
></b
>)
284 $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, ".
285 " if (i1.administered_date, concat(i1.administered_date,' - '), substring(i1.note,1,20)) as immunization_data ".
286 " from immunizations i1 ".
287 " left join codes c on CAST(IFNULL(i1.cvx_code,0) AS CHAR) = c.code ".
288 " left join code_types ct on c.code_type = ct.ct_id ".
289 " where i1.patient_id = ? ".
290 " AND (( i1.cvx_code = '0' OR i1.cvx_code IS NULL ) OR ".
291 " ( ( i1.cvx_code != '0' AND i1.cvx_code IS NOT NULL ) AND ct.ct_key = 'CVX') ) ".
292 " order by i1.administered_date desc";
294 $result = sqlStatement($sql, array($pid) );
296 if (sqlNumRows($result) == 0) {
297 echo " <table><tr>\n";
298 echo " <td colspan='$numcols' class='text'> " . htmlspecialchars( xl('None'), ENT_NOQUOTES
) . "</td>\n";
299 echo " </tr></table>\n";
302 while ($row=sqlFetchArray($result)){
304 echo "<a class='link'";
305 echo "' href='javascript:;' onclick='javascript:load_location(\"immunizations.php?mode=edit&id=".htmlspecialchars($row['id'],ENT_QUOTES
) . "\")'>" .
306 htmlspecialchars($row{'immunization_data'},ENT_NOQUOTES
);
308 // Figure out which name to use (ie. from cvx list or from the custom list)
309 if ($GLOBALS['use_custom_immun_list']) {
310 echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
313 if (!(empty($row['cvx_text']))) {
314 echo htmlspecialchars( xl($row['cvx_text']), ENT_NOQUOTES
);
317 echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
324 <?php
if ($_POST['embeddedScreen']) {
325 echo "</td></tr></div>";
330 </table
> <!-- end patient_stats_imm
-->
334 <?php
if (!$GLOBALS['disable_prescriptions']) { ?
>
336 <table id
="patient_stats_prescriptions">
337 <?php
if($GLOBALS['erx_enable'] && $display_current_medications_below==1){ ?
>
339 <?php
if ($_POST['embeddedScreen']) {
341 $widgetTitle = xl('Current Medications');
342 $widgetLabel = "current_prescriptions";
343 $widgetButtonLabel = '';
344 $widgetButtonLink = '';
346 $widgetButtonClass = '';
347 $bodyClass = "summary_item small";
349 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
354 $res=sqlStatement("select * from prescriptions where patient_id=? and active='1'",array($pid));
358 if(sqlNumRows($res)==0)
362 <td
><?php
echo htmlspecialchars(xl('None'), ENT_NOQUOTES
);?
></td
>
366 while($row_currentMed=sqlFetchArray($res))
368 $runit=generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'),$row_currentMed['unit']);
369 $rin=generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'),$row_currentMed['form']);
370 $rroute=generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'),$row_currentMed['route']);
371 $rint=generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'),$row_currentMed['interval']);
374 <td
><?php
echo $row_currentMed['drug'];?
></td
>
375 <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
>
383 <tr
><td colspan
='<?php echo $numcols ?>' class='issuetitle'>
385 <?php
if ($_POST['embeddedScreen']) {
386 // Issues expand collapse widget
387 $widgetLabel = "prescriptions";
388 $linkMethod = "html";
389 if($GLOBALS['erx_enable'])
391 $widgetTitle = xl('Prescription History');
392 $widgetButtonLabel = xl("Add/Edit eRx");
393 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/eRx.php?page=compose";
394 $widgetButtonClass = "";
398 $widgetTitle = xl('Prescription');
399 $widgetButtonLabel = xl("Edit");
400 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/rx_frameset.php";
401 $widgetButtonClass = "iframe rx_modal";
403 $bodyClass = "summary_item small";
406 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
409 <span
class='text'><b
><?php
echo htmlspecialchars(xl('Prescriptions'),ENT_NOQUOTES
); ?
></b
></span
>
417 require_once("library/classes/Controller.class.php");
418 $c = new Controller();
419 echo $c->act(array("prescription" => "", "fragment" => "", "patient_id" => $pid));
422 <?php
if ($_POST['embeddedScreen']) {
430 if($erx_upload_complete == 1){
432 // Old Medication Widget
433 $widgetTitle = "Old Medication";
434 $widgetLabel = "old_medication";
435 $widgetButtonLabel = xl("Edit");
436 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=medication\")";
437 $widgetButtonClass = "";
438 $linkMethod = "javascript";
439 $bodyClass = "summary_item small";
442 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
443 $query_uploaded_old = "SELECT * FROM lists WHERE pid = ? AND type = 'medication' AND ";
444 $query_uploaded_old .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
445 $query_uploaded_old .= "ORDER BY begdate";
446 $res_uploaded_old = sqlStatement($query_uploaded_old, array($pid) );
448 while ($row = sqlFetchArray($res_uploaded_old)) {
449 // output each issue for the $ISSUE_TYPE
450 if (!$row['enddate'] && !$row['returndate'])
451 $rowclass="noend_noreturn";
452 else if (!$row['enddate'] && $row['returndate'])
454 else if ($row['enddate'] && !$row['returndate'])
455 $rowclass = "noreturn";
456 echo " <tr class='text $rowclass;'>\n";
457 echo " <td colspan='$numcols'> " . htmlspecialchars($row['title'],ENT_NOQUOTES
) . "</td>\n";
461 echo "</div></td></tr>";
465 </table
> <!-- end patient_stats_prescriptions
-->
467 </div
> <!-- end patient_stats_summary
-->