From 6ca95c06d4aa3107f42c7eb4c07e98f9d5466618 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Tue, 7 Jul 2009 20:30:35 +0000 Subject: [PATCH] some general support for printable forms based on layouts, and a blank demographics form for ippf. also sorting lists by title within seq. --- interface/main/left_nav.php | 3 +- .../patient_file/summary/demographics_print.php | 191 ++++++++++++ library/options.inc.php | 327 ++++++++++++++++++++- 3 files changed, 509 insertions(+), 12 deletions(-) create mode 100644 interface/patient_file/summary/demographics_print.php diff --git a/interface/main/left_nav.php b/interface/main/left_nav.php index c46a6e6c8..60d8ee69d 100644 --- a/interface/main/left_nav.php +++ b/interface/main/left_nav.php @@ -1,5 +1,5 @@ + // Copyright (C) 2006-2009 Rod Roark // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -899,6 +899,7 @@ function genPopupsList($style='') {
    • +
    diff --git a/interface/patient_file/summary/demographics_print.php b/interface/patient_file/summary/demographics_print.php new file mode 100644 index 000000000..881709b49 --- /dev/null +++ b/interface/patient_file/summary/demographics_print.php @@ -0,0 +1,191 @@ + +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// Currently this will print only a blank form, but some code was +// preserved here and in options.inc.php to ease future support for +// data for a specified patient. + +require_once("../../globals.php"); +require_once("$srcdir/acl.inc"); +require_once("$srcdir/options.inc.php"); +require_once("$srcdir/patient.inc"); + +$CPR = 4; // cells per row + +/********************************************************************* +$result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD"); +$result2 = getEmployerData($pid); +// Check authorization. +$thisauth = acl_check('patients', 'demo'); +if ($pid) { + if (!$thisauth != 'write') + die(xl('Demographics not authorized.')); + if ($result['squad'] && ! acl_check('squads', $result['squad'])) + die(xl('You are not authorized to access this squad.')); +} +$insurancei = getInsuranceProviders(); +*********************************************************************/ + +$fres = sqlStatement("SELECT * FROM layout_options " . + "WHERE form_id = 'DEM' AND uor > 0 " . + "ORDER BY group_name, seq"); +?> + + + + + + + + +
    + +

    + + 0) { + echo ""; + $item_count = 0; + } +} + +function end_row() { + global $cell_count, $CPR; + end_cell(); + if ($cell_count > 0) { + for (; $cell_count < $CPR; ++$cell_count) echo ""; + echo "\n"; + $cell_count = 0; + } +} + +function end_group() { + global $last_group; + if (strlen($last_group) > 0) { + end_row(); + echo " \n"; + echo "\n"; + } +} + +$last_group = ''; +$cell_count = 0; +$item_count = 0; + +while ($frow = sqlFetchArray($fres)) { + $this_group = $frow['group_name']; + $titlecols = $frow['titlecols']; + $datacols = $frow['datacols']; + $data_type = $frow['data_type']; + $field_id = $frow['field_id']; + $list_id = $frow['list_id']; + $currvalue = ''; + + if (strpos($field_id, 'em_') === 0) { + $tmp = substr($field_id, 3); + // if (isset($result2[$tmp])) $currvalue = $result2[$tmp]; + } + else { + // if (isset($result[$field_id])) $currvalue = $result[$field_id]; + } + + // Handle a data category (group) change. + if (strcmp($this_group, $last_group) != 0) { + end_group(); + if (strlen($last_group) > 0) echo "
    \n"; + $group_name = substr($this_group, 1); + $last_group = $this_group; + echo "" . xl_layout_label($group_name) . "\n"; + + echo "
    \n"; + echo " \n"; + } + + // Handle starting of a new row. + if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) { + end_row(); + echo " "; + } + + if ($item_count == 0 && $titlecols == 0) $titlecols = 1; + + // Handle starting of a new label cell. + if ($titlecols > 0) { + end_cell(); + echo "
    "; + $cell_count += $titlecols; + } + ++$item_count; + + echo ""; + + if ($frow['title']) echo (xl_layout_label($frow['title']) . ":"); else echo " "; + + echo ""; + + // Handle starting of a new data cell. + if ($datacols > 0) { + end_cell(); + echo " 0) echo " style='padding-left:5pt'"; + echo ">"; + $cell_count += $datacols; + } + + ++$item_count; + generate_print_field($frow, $currvalue); +} + +end_group(); +?> + + + + + + + + diff --git a/library/options.inc.php b/library/options.inc.php index 11ca95cf6..a948ecc28 100644 --- a/library/options.inc.php +++ b/library/options.inc.php @@ -1,4 +1,10 @@ +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. // Functions for managing the lists and layouts // @@ -7,7 +13,6 @@ // xl_list_label() and xl_layout_label() and are controlled by the // $GLOBALS['translate_lists'] and $GLOBALS['translate_layout'] // flags in globals.php -// $date_init = ""; @@ -57,7 +62,7 @@ function generate_form_field($frow, $currvalue) { echo ""; while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; @@ -298,7 +303,7 @@ function generate_form_field($frow, $currvalue) { $maxlength = empty($frow['max_length']) ? 255 : $frow['max_length']; $fldlength = empty($frow['fld_length']) ? 20 : $frow['fld_length']; $lres = sqlStatement("SELECT * FROM list_options " . - "WHERE list_id = '$list_id' ORDER BY seq"); + "WHERE list_id = '$list_id' ORDER BY seq, title"); echo "
    "; echo "" . @@ -359,7 +364,7 @@ function generate_form_field($frow, $currvalue) { $maxlength = empty($frow['max_length']) ? 255 : $frow['max_length']; $fldlength = empty($frow['fld_length']) ? 20 : $frow['fld_length']; $lres = sqlStatement("SELECT * FROM list_options " . - "WHERE list_id = '$list_id' ORDER BY seq"); + "WHERE list_id = '$list_id' ORDER BY seq, title"); echo "
     " . xl('N/A') . " " . xl('Nor') . " 
    "; while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; @@ -388,7 +393,7 @@ function generate_form_field($frow, $currvalue) { echo ""; + } + + // long or multi-line text field + else if ($data_type == 3) { + echo "" . + $currescaped . ""; + } + + // date + else if ($data_type == 4) { + echo ""; + } + + // provider list + else if ($data_type == 10 || $data_type == 11) { + $tmp = ''; + if ($currvalue) { + $urow = sqlQuery("SELECT fname, lname, specialty FROM users " . + "WHERE id = '$currvalue'"); + $tmp = ucwords($urow['fname'] . " " . $urow['lname']); + if (empty($tmp)) $tmp = "($currvalue)"; + } + echo ""; + } + + // pharmacy list + else if ($data_type == 12) { + $tmp = ''; + if ($currvalue) { + $pres = get_pharmacies(); + while ($prow = sqlFetchArray($pres)) { + $key = $prow['id']; + if ($currvalue == $key) { + $tmp = $prow['name'] . ' ' . $prow['area_code'] . '-' . + $prow['prefix'] . '-' . $prow['number'] . ' / ' . + $prow['line1'] . ' / ' . $prow['city']; + } + } + if (empty($tmp)) $tmp = "($currvalue)"; + } + echo ""; + } + + // squads + else if ($data_type == 13) { + $tmp = ''; + if ($currvalue) { + $squads = acl_get_squads(); + if ($squads) { + foreach ($squads as $key => $value) { + if ($currvalue == $key) { + $tmp = $value[3]; + } + } + } + if (empty($tmp)) $tmp = "($currvalue)"; + } + echo ""; + } + + // Address book. + else if ($data_type == 14) { + $tmp = ''; + if ($currvalue) { + $urow = sqlQuery("SELECT fname, lname, specialty FROM users " . + "WHERE id = '$currvalue'"); + $uname = $urow['lname']; + if ($urow['fname']) $uname .= ", " . $urow['fname']; + $tmp = $uname; + if (empty($tmp)) $tmp = "($currvalue)"; + } + echo ""; + } + + // a set of labeled checkboxes + else if ($data_type == 21) { + // In this special case, fld_length is the number of columns generated. + $cols = max(1, $fld_length); + $avalue = explode('|', $currvalue); + $lres = sqlStatement("SELECT * FROM list_options " . + "WHERE list_id = '$list_id' ORDER BY seq, title"); + echo "
    "; + $tdpct = (int) (100 / $cols); + for ($count = 0; $lrow = sqlFetchArray($lres); ++$count) { + $option_id = $lrow['option_id']; + if ($count % $cols == 0) { + if ($count) echo ""; + echo ""; + } + echo ""; + } + if ($count) { + echo ""; + if ($count > $cols) { + // Add some space after multiple rows of checkboxes. + echo ""; + } + } + echo "
    "; + echo "" . xl_list_label($lrow['title']); + echo "
    "; + } + + // a set of labeled text input fields + else if ($data_type == 22) { + $tmp = explode('|', $currvalue); + $avalue = array(); + foreach ($tmp as $value) { + if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) { + $avalue[$matches[1]] = $matches[2]; + } + } + $lres = sqlStatement("SELECT * FROM list_options " . + "WHERE list_id = '$list_id' ORDER BY seq, title"); + echo ""; + while ($lrow = sqlFetchArray($lres)) { + $option_id = $lrow['option_id']; + $maxlength = empty($frow['max_length']) ? 255 : $frow['max_length']; + $fldlength = empty($fld_length) ? 20 : $fld_length; + echo ""; + echo ""; + } + echo "
    " . xl_list_label($lrow['title']) . " 
    "; + } + + // a set of exam results; 3 radio buttons and a text field: + else if ($data_type == 23) { + $tmp = explode('|', $currvalue); + $avalue = array(); + foreach ($tmp as $value) { + if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) { + $avalue[$matches[1]] = $matches[2]; + } + } + $maxlength = empty($frow['max_length']) ? 255 : $frow['max_length']; + $fldlength = empty($fld_length) ? 20 : $fld_length; + $lres = sqlStatement("SELECT * FROM list_options " . + "WHERE list_id = '$list_id' ORDER BY seq, title"); + echo ""; + echo "" . + ""; + while ($lrow = sqlFetchArray($lres)) { + $option_id = $lrow['option_id']; + $restype = substr($avalue[$option_id], 0, 1); + $resnote = substr($avalue[$option_id], 2); + echo ""; + for ($i = 0; $i < 3; ++$i) { + echo ""; + } + echo "" . + " class='under'" . + ""; + } + echo "
     " . xl('N/A') . + " " . xl('Nor') . " " . xl('Abn') . " " . + xl('Date/Notes') . "
    " . xl_list_label($lrow['title']) . " 
    "; + } + + // the list of active allergies for the current patient + // this is read-only! + else if ($data_type == 24) { + $query = "SELECT title, comments FROM lists WHERE " . + "pid = '" . $GLOBALS['pid'] . "' AND type = 'allergy' AND enddate IS NULL " . + "ORDER BY begdate"; + $lres = sqlStatement($query); + $count = 0; + while ($lrow = sqlFetchArray($lres)) { + if ($count++) echo "
    "; + echo $lrow['title']; + if ($lrow['comments']) echo ' (' . $lrow['comments'] . ')'; + } + } + + // a set of labeled checkboxes, each with a text field: + else if ($data_type == 25) { + $tmp = explode('|', $currvalue); + $avalue = array(); + foreach ($tmp as $value) { + if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) { + $avalue[$matches[1]] = $matches[2]; + } + } + $maxlength = empty($frow['max_length']) ? 255 : $frow['max_length']; + $fldlength = empty($fld_length) ? 20 : $fld_length; + $lres = sqlStatement("SELECT * FROM list_options " . + "WHERE list_id = '$list_id' ORDER BY seq, title"); + echo ""; + while ($lrow = sqlFetchArray($lres)) { + $option_id = $lrow['option_id']; + $restype = substr($avalue[$option_id], 0, 1); + $resnote = substr($avalue[$option_id], 2); + echo ""; + echo ""; + echo "" . + ""; + } + echo "
    " . xl_list_label($lrow['title']) . "  
    "; + } + +} + function generate_display_field($frow, $currvalue) { $data_type = $frow['data_type']; $field_id = $frow['field_id']; @@ -507,7 +812,7 @@ function generate_display_field($frow, $currvalue) { else if ($data_type == 21) { $avalue = explode('|', $currvalue); $lres = sqlStatement("SELECT * FROM list_options " . - "WHERE list_id = '$list_id' ORDER BY seq"); + "WHERE list_id = '$list_id' ORDER BY seq, title"); $count = 0; while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; @@ -531,7 +836,7 @@ function generate_display_field($frow, $currvalue) { } } $lres = sqlStatement("SELECT * FROM list_options " . - "WHERE list_id = '$list_id' ORDER BY seq"); + "WHERE list_id = '$list_id' ORDER BY seq, title"); $s .= ""; while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; @@ -555,7 +860,7 @@ function generate_display_field($frow, $currvalue) { } } $lres = sqlStatement("SELECT * FROM list_options " . - "WHERE list_id = '$list_id' ORDER BY seq"); + "WHERE list_id = '$list_id' ORDER BY seq, title"); $s .= "
    "; while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; @@ -599,7 +904,7 @@ function generate_display_field($frow, $currvalue) { } } $lres = sqlStatement("SELECT * FROM list_options " . - "WHERE list_id = '$list_id' ORDER BY seq"); + "WHERE list_id = '$list_id' ORDER BY seq, title"); $s .= "
    "; while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; -- 2.11.4.GIT