Display fix: width in manila for demographics (#1909)
[openemr.git] / library / lists.inc
blob2ea49b6e3e47ee907af966c868b1453909849d48
1 <?php
2 /**
3  * Issue list functions and data structure building.
4  *
5  * The data structure is the $ISSUE_TYPES array.
6  * The $ISSUE_TYPES array is built from the issue_types sql table and provides
7  * abstraction of issue types to allow customization.
8  * <pre>Attributes of the $ISSUE_TYPES array are:
9  *  key - The identifier. (Do NOT create element with token 'prescription_erx' since this is reserved by NewCropRx Module that leverages lists_touch table to support MU calculations)
10  *  0   - The plural title.
11  *  1   - The singular title.
12  *  2   - The abbreviated title (one letter abbreviation).
13  *  3   - Style ('0 - Normal; 1 - Simplified: only title, start date, comments and an Active checkbox;no diagnosis, occurrence, end date, referred-by or sports fields.; 2 - Football Injury; 3 and 4 are IPPF specific)
14  *  4   - Force show this issue category in the patient summary screen even if empty (setting to 1 will force it to show and setting it to 0 will turn this off).
15  *  5   - ACO for this type, for example "patients|med".
16  *
17  * Note there is a mechanism to show whether a category is explicitly set to
18  * 'Nothing' via the getListTouch() and setListTouch() functions that store
19  * applicable information in the lists_touch sql table.
20  *
21  *  </pre>
22  *
23  * LICENSE: This program is free software; you can redistribute it and/or
24  * modify it under the terms of the GNU General Public License
25  * as published by the Free Software Foundation; either version 2
26  * of the License, or (at your option) any later version.
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU General Public License for more details.
31  * You should have received a copy of the GNU General Public License
32  * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
33  *
34  * @package OpenEMR
35  * @author  Rod Roark <rod@sunsetsystems.com>
36  * @author  Brady Miller <brady.g.miller@gmail.com>
37  * @author  Teny <teny@zhservices.com>
38  * @link    http://www.open-emr.org
39  */
41 // Build the $ISSUE_TYPE_CATEGORIES array
42 // First, set the hard-coded options
43 $ISSUE_TYPE_CATEGORIES = array(
44   'default' => xl('Default'),             // Normal OpenEMR use
45   'ippf_specific' => xl('IPPF')           // For IPPF use
47 // Second, collect the non hard-coded options and add to the array
48 $res = sqlStatement("SELECT DISTINCT `category` FROM `issue_types`");
49 while ($row = sqlFetchArray($res)) {
50     if (($row['category'] == "default") || ($row['category'] == "ippf_specific")) {
51         continue;
52     }
54     $ISSUE_TYPE_CATEGORIES[$row['category']] = $row['category'];
57 $ISSUE_TYPE_STYLES = array(
58   0 => xl('Standard'),                    // Standard
59   1 => xl('Simplified'),                  // Simplified: only title, start date, comments and an Active checkbox;no diagnosis, occurrence, end date, referred-by or sports fields.
60   2 => xl('Football Injury'),             // Football Injury
61   3 => xl('IPPF Abortion'),               // IPPF specific (abortions issues)
62   4 => xl('IPPF Contraception')           // IPPF specific (contraceptions issues)
65 /**
66  * Will return the current issue type category that is being used.
67  * @return  string  The current issue type category that is being used.
68  */
69 function collect_issue_type_category()
71     if (!empty($GLOBALS['ippf_specific'])) { // IPPF version
72         return "ippf_specific";
73     } else { // Default version
74         return "default";
75     }
78 // Build the $ISSUE_TYPES array (see script header for description)
79 $res = sqlStatement(
80     "SELECT * FROM `issue_types` WHERE active = 1 AND `category`=? ORDER BY `ordering`",
81     array(collect_issue_type_category())
83 while ($row = sqlFetchArray($res)) {
84     $ISSUE_TYPES[$row['type']] = array(
85     xl($row['plural']),
86     xl($row['singular']),
87     xl($row['abbreviation']),
88     $row['style'],
89     $row['force_show'],
90     $row['aco_spec']);
93 $ISSUE_CLASSIFICATIONS = array(
94   0   => xl('Unknown or N/A'),
95   1   => xl('Trauma'),
96   2   => xl('Overuse')
99 function getListById($id, $cols = "*")
101     return sqlQuery("select $cols from lists where id='$id' order by date DESC limit 0,1");
104 function getListByType($pid, $type, $cols = "*", $active = "all", $limit = "all", $offset = "0")
106     if ($active == "all") {
107         $sql = "select $cols from lists where pid='$pid' and type='$type' order by date DESC";
108     } else {
109         $sql = "select $cols from lists where pid='$pid' and type='$type' and activity='$active' order by date DESC";
110     }
112     if ($limit != "all") {
113         $sql .= " limit $offset,$limit";
114     }
115     
116     $res = sqlStatement($sql);
117     for ($iter =0; $row = sqlFetchArray($res); $iter++) {
118         $all[$iter] = $row;
119     }
121     return $all;
124 function addList($pid, $type, $title, $comments, $activity = "1")
126     return sqlInsert("insert into lists (date, pid, type, title, activity, comments, user, groupname) values (NOW(), '$pid', '$type', '$title', '$activity', '$comments', '".$_SESSION['authUser']."', '".$_SESSION['authProvider']."')");
129 function disappearList($id)
131     sqlStatement("update lists set activity = '0' where id='$id'");
132     return true;
135 function reappearList($id)
137     sqlStatement("update lists set activity = '1' where id='$id'");
138     return true;
141 function getListTouch($patient_id, $type)
143     $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type));
145     if (!empty($ret)) {
146         return $ret['date'];
147     } else {
148         return false;
149     }
152 function setListTouch($patient_id, $type)
154     $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type));
156     if (!empty($ret)) {
157                 // Already touched, so can exit
158         return;
159     } else {
160         sqlStatement("INSERT INTO `lists_touch` ( `pid`,`type`,`date` ) VALUES ( ?, ?, NOW() )", array($patient_id,$type));
161     }