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");
17 <div id
="patient_stats_summary">
20 $thisauth = acl_check('patients', 'med');
22 $tmp = getPatientData($pid, "squad");
23 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
27 echo "<p>(".htmlspecialchars(xl('Issues not authorized'),ENT_NOQUOTES
).")</p>\n";
28 echo "</body>\n</html>\n";
33 <script type
='text/javascript'>
34 function load_location( location
) {
36 if ( !top
.frames
["RTop"] ) {
37 document
.location
=location
;
39 top
.frames
["RTop"].location
=location
;
44 <table id
="patient_stats_issues">
48 $erx_upload_complete = 0;
49 $old_key="";$display_current_medications_below=1;
50 foreach ($ISSUE_TYPES as $key => $arr) {
51 // $result = getListByType($pid, $key, "id,title,begdate,enddate,returndate,extrainfo", "all", "all", 0);
53 $query = "SELECT * FROM lists WHERE pid = ? AND type = ? AND ";
54 $query .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
55 if($GLOBALS['erx_enable'] && $GLOBALS['erx_medication_display'] && $key=='medication')
56 $query .= "and erx_uploaded != '1' ";
57 if($GLOBALS['erx_enable'] && $GLOBALS['erx_allergy_display'] && $key=='allergy')
58 $query .= "and erx_uploaded != '1' ";
59 $query .= "ORDER BY begdate";
60 $pres = sqlStatement($query, array($pid, $key) );
61 if($old_key=="medication" && $GLOBALS['erx_enable'] && $erx_upload_complete == 1)
63 $display_current_medications_below=0;
66 <table id
="patient_stats_prescriptions">
67 <?php
if($GLOBALS['erx_enable']){ ?
>
69 <?php
if ($_POST['embeddedScreen']) {
71 $widgetTitle = xl('Current Medications');
72 $widgetLabel = "current_prescriptions";
73 $widgetButtonLabel = '';
74 $widgetButtonLink = '';
76 $widgetButtonClass = '';
77 $bodyClass = "summary_item small";
79 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
84 $res=sqlStatement("select * from prescriptions where patient_id=? and active='1'",array($pid));
88 if(sqlNumRows($res)==0)
92 <td
><?php
echo htmlspecialchars(xl('None'), ENT_NOQUOTES
);?
></td
>
96 while($row_currentMed=sqlFetchArray($res))
98 $runit=generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'),htmlspecialchars($row_currentMed['unit'],ENT_NOQUOTES
));
99 $rin=generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'),htmlspecialchars($row_currentMed['form'],ENT_NOQUOTES
));
100 $rroute=generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'),htmlspecialchars($row_currentMed['route'],ENT_NOQUOTES
));
101 $rint=generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'),htmlspecialchars($row_currentMed['interval'],ENT_NOQUOTES
));
104 <td
><?php
echo htmlspecialchars($row_currentMed['drug'],ENT_NOQUOTES
);?
></td
>
107 if($row_currentMed['size']>0)
108 $unit=$row_currentMed['size']." ".$runit." ";
109 echo htmlspecialchars($unit." ".$row_currentMed['dosage']." ".$rin." ".$rroute." ".$rint,ENT_NOQUOTES
);
120 if (sqlNumRows($pres) > 0 ||
$arr[4] == 1) {
122 if ($_POST['embeddedScreen']) {
124 if($GLOBALS['erx_enable'] && $key == "medication"){
125 $query_uploaded = "SELECT * FROM lists WHERE pid = ? AND type = 'medication' AND ";
126 $query_uploaded .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
127 $query_uploaded .= "and erx_uploaded != '1' ";
128 $query_uploaded .= "ORDER BY begdate";
129 $res_uploaded = sqlStatement($query_uploaded, array($pid) );
130 if(sqlNumRows($res_uploaded) == 0){
131 $erx_upload_complete = 1;
137 // Issues expand collapse widget
138 $widgetTitle = $arr[0];
140 if(($key == "allergy" ||
$key == "medication") && $GLOBALS['erx_enable'])
142 $widgetButtonLabel = xl("Add");
143 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/eRx.php?page=medentry\")";
147 $widgetButtonLabel = xl("Edit");
148 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=" . $key . "\")";
150 $widgetButtonClass = "";
151 $linkMethod = "javascript";
152 $bodyClass = "summary_item small";
155 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
158 <tr
class='issuetitle'>
159 <td colspan
='$numcols'>
160 <span
class="text"><b
><?php
echo htmlspecialchars($arr[0],ENT_NOQUOTES
); ?
></b
></span
>
161 <a href
="javascript:;" class="small" onclick
="load_location('stats_full.php?active=all&category=" . $key . "')">
162 (<b
><?php
echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES
); ?
></b
>)
168 if (sqlNumRows($pres) == 0) {
169 if ( getListTouch($pid,$key) ) {
170 // Data entry has happened to this type, so can display an explicit None.
171 echo " <tr><td colspan='$numcols' class='text'> " . htmlspecialchars( xl('None'), ENT_NOQUOTES
) . "</td></tr>\n";
174 // Data entry has not happened to this type, so show 'Nothing Recorded"
175 echo " <tr><td colspan='$numcols' class='text'> " . htmlspecialchars( xl('Nothing Recorded'), ENT_NOQUOTES
) . "</td></tr>\n";
179 while ($row = sqlFetchArray($pres)) {
180 // output each issue for the $ISSUE_TYPE
181 if (!$row['enddate'] && !$row['returndate'])
182 $rowclass="noend_noreturn";
183 else if (!$row['enddate'] && $row['returndate'])
185 else if ($row['enddate'] && !$row['returndate'])
186 $rowclass = "noreturn";
188 echo " <tr class='text $rowclass;'>\n";
190 //turn allergies red and bold and show the reaction (if exist)
191 if ($key == "allergy") {
193 if (!empty($row['reaction'])) {
194 $reaction = " (" . $row['reaction'] . ")";
196 echo " <td colspan='$numcols' style='color:red;font-weight:bold;'> " . htmlspecialchars( $row['title'] . $reaction, ENT_NOQUOTES
) . "</td>\n";
199 echo " <td colspan='$numcols'> " . htmlspecialchars($row['title'],ENT_NOQUOTES
) . "</td>\n";
205 if ($_POST['embeddedScreen']) {
206 echo "</div></td></tr>";
212 </table
> <!-- end patient_stats_issues
-->
214 <table id
="patient_stats_spreadsheets">
217 // Show spreadsheet forms if any are present.
220 foreach (array('treatment_protocols','injury_log') as $formname) {
221 if (sqlNumRows(sqlStatement("SHOW TABLES LIKE ?", array("form_".$formname) )) > 0) {
222 $dres = sqlStatement("SELECT tp.id, tp.value FROM forms, " .
223 "form_" . add_escape_custom($formname) .
224 " AS tp WHERE forms.pid = ? AND " .
225 "forms.formdir = ? AND tp.id = forms.form_id AND " .
226 "tp.rownbr = -1 AND tp.colnbr = -1 AND tp.value LIKE '0%' " .
227 "ORDER BY tp.value DESC", array($pid, $formname) );
228 if (sqlNumRows($dres) > 0 && $need_head) {
231 echo " <td colspan='$numcols' valign='top'>\n";
232 echo " <span class='title'>Injury Log</span>\n";
236 while ($row = sqlFetchArray($dres)) {
237 list($completed, $start_date, $template_name) = explode('|', $row['value'], 3);
239 echo " <td colspan='$numcols'> ";
240 echo "<a class='link' href='javascript:;' ";
241 echo "onclick='load_location(\"../../forms/$formname/new.php?popup=1&id=";
242 echo htmlspecialchars($row['id'],ENT_QUOTES
) . "\")'>" .
243 htmlspecialchars($start_date,ENT_NOQUOTES
) . " " .
244 htmlspecialchars($template_name,ENT_NOQUOTES
) . "</a></td>\n";
250 </table
> <!-- end patient_stats_spreadsheets
-->
252 <?php
if (!$GLOBALS['disable_immunizations'] && !$GLOBALS['weight_loss_clinic']) { ?
>
254 <table id
="patient_stats_imm">
256 <?php
if ($_POST['embeddedScreen']) {
258 // Issues expand collapse widget
259 $widgetTitle = xl('Immunizations');
260 $widgetLabel = "immunizations";
261 $widgetButtonLabel = xl("Edit");
262 $widgetButtonLink = "javascript:load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/immunizations.php\")";
263 $widgetButtonClass = "";
264 $linkMethod = "javascript";
265 $bodyClass = "summary_item small";
268 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
271 <td colspan
='<?php echo $numcols ?>' valign
='top'>
272 <span
class="text"><b
><?php
echo htmlspecialchars(xl('Immunizations', 'e'),ENT_NOQUOTES
); ?
></b
></span
>
273 <a href
="javascript:;" class="small" onclick
="javascript:load_location('immunizations.php')">
274 (<b
><?php
echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES
) ?
></b
>)
281 $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, ".
282 " if (i1.administered_date, concat(i1.administered_date,' - ',c.code_text_short), IF(i1.note,substring(i1.note,1,20),c.code_text_short)) as immunization_data ".
283 " from immunizations i1 ".
284 " left join code_types ct on ct.ct_key = 'CVX' ".
285 " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ".
286 " where i1.patient_id = ? ".
287 " and i1.added_erroneously = 0".
288 " order by i1.administered_date desc";
290 $result = sqlStatement($sql, array($pid) );
292 if (sqlNumRows($result) == 0) {
293 echo " <table><tr>\n";
294 echo " <td colspan='$numcols' class='text'> " . htmlspecialchars( xl('None'), ENT_NOQUOTES
) . "</td>\n";
295 echo " </tr></table>\n";
298 while ($row=sqlFetchArray($result)){
300 echo "<a class='link'";
301 echo "' href='javascript:;' onclick='javascript:load_location(\"immunizations.php?mode=edit&id=".htmlspecialchars($row['id'],ENT_QUOTES
) . "\")'>" .
302 htmlspecialchars($row{'immunization_data'},ENT_NOQUOTES
);
304 // Figure out which name to use (ie. from cvx list or from the custom list)
305 if ($GLOBALS['use_custom_immun_list']) {
306 echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
309 if (!(empty($row['cvx_text']))) {
310 echo htmlspecialchars( xl($row['cvx_text']), ENT_NOQUOTES
);
313 echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
320 <?php
if ($_POST['embeddedScreen']) {
321 echo "</td></tr></div>";
326 </table
> <!-- end patient_stats_imm
-->
330 <?php
if (!$GLOBALS['disable_prescriptions']) { ?
>
332 <table id
="patient_stats_prescriptions">
333 <?php
if($GLOBALS['erx_enable'] && $display_current_medications_below==1){ ?
>
335 <?php
if ($_POST['embeddedScreen']) {
337 $widgetTitle = xl('Current Medications');
338 $widgetLabel = "current_prescriptions";
339 $widgetButtonLabel = '';
340 $widgetButtonLink = '';
342 $widgetButtonClass = '';
343 $bodyClass = "summary_item small";
345 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
350 $res=sqlStatement("select * from prescriptions where patient_id=? and active='1'",array($pid));
354 if(sqlNumRows($res)==0)
358 <td
><?php
echo htmlspecialchars(xl('None'), ENT_NOQUOTES
);?
></td
>
362 while($row_currentMed=sqlFetchArray($res))
364 $runit=generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'),$row_currentMed['unit']);
365 $rin=generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'),$row_currentMed['form']);
366 $rroute=generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'),$row_currentMed['route']);
367 $rint=generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'),$row_currentMed['interval']);
370 <td
><?php
echo $row_currentMed['drug'];?
></td
>
371 <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
>
379 <tr
><td colspan
='<?php echo $numcols ?>' class='issuetitle'>
381 <?php
if ($_POST['embeddedScreen']) {
382 // Issues expand collapse widget
383 $widgetLabel = "prescriptions";
384 $linkMethod = "html";
385 if($GLOBALS['erx_enable'])
387 $widgetTitle = xl('Prescription History');
388 $widgetButtonLabel = xl("Add/Edit eRx");
389 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/eRx.php?page=compose";
390 $widgetButtonClass = "";
394 $widgetTitle = xl('Prescription');
395 $widgetButtonLabel = xl("Edit");
396 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/rx_frameset.php";
397 $widgetButtonClass = "iframe rx_modal";
399 $bodyClass = "summary_item small";
402 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
405 <span
class='text'><b
><?php
echo htmlspecialchars(xl('Prescriptions'),ENT_NOQUOTES
); ?
></b
></span
>
413 $c = new Controller();
414 echo $c->act(array("prescription" => "", "fragment" => "", "patient_id" => $pid));
417 <?php
if ($_POST['embeddedScreen']) {
425 if($erx_upload_complete == 1){
427 // Old Medication Widget
428 $widgetTitle = "Old Medication";
429 $widgetLabel = "old_medication";
430 $widgetButtonLabel = xl("Edit");
431 $widgetButtonLink = "load_location(\"${GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=medication\")";
432 $widgetButtonClass = "";
433 $linkMethod = "javascript";
434 $bodyClass = "summary_item small";
437 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
438 $query_uploaded_old = "SELECT * FROM lists WHERE pid = ? AND type = 'medication' AND ";
439 $query_uploaded_old .= "(enddate is null or enddate = '' or enddate = '0000-00-00') ";
440 $query_uploaded_old .= "ORDER BY begdate";
441 $res_uploaded_old = sqlStatement($query_uploaded_old, array($pid) );
443 while ($row = sqlFetchArray($res_uploaded_old)) {
444 // output each issue for the $ISSUE_TYPE
445 if (!$row['enddate'] && !$row['returndate'])
446 $rowclass="noend_noreturn";
447 else if (!$row['enddate'] && $row['returndate'])
449 else if ($row['enddate'] && !$row['returndate'])
450 $rowclass = "noreturn";
451 echo " <tr class='text $rowclass;'>\n";
452 echo " <td colspan='$numcols'> " . htmlspecialchars($row['title'],ENT_NOQUOTES
) . "</td>\n";
456 echo "</div></td></tr>";
460 </table
> <!-- end patient_stats_prescriptions
-->
462 </div
> <!-- end patient_stats_summary
-->