3 * Issue list functions and data structure building.
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".
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.
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>;.
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
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")) {
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)
66 * Will return the current issue type category that is being used.
67 * @return string The current issue type category that is being used.
69 function collect_issue_type_category()
71 if (!empty($GLOBALS['ippf_specific'])) { // IPPF version
72 return "ippf_specific";
73 } else { // Default version
78 // Build the $ISSUE_TYPES array (see script header for description)
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(
87 xl($row['abbreviation']),
93 $ISSUE_CLASSIFICATIONS = array(
94 0 => xl('Unknown or N/A'),
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";
109 $sql = "select $cols from lists where pid='$pid' and type='$type' and activity='$active' order by date DESC";
112 if ($limit != "all") {
113 $sql .= " limit $offset,$limit";
116 $res = sqlStatement($sql);
117 for ($iter =0; $row = sqlFetchArray($res); $iter++) {
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'");
135 function reappearList($id)
137 sqlStatement("update lists set activity = '1' where id='$id'");
141 function getListTouch($patient_id, $type)
143 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type));
152 function setListTouch($patient_id, $type)
154 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type));
157 // Already touched, so can exit
160 sqlStatement("INSERT INTO `lists_touch` ( `pid`,`type`,`date` ) VALUES ( ?, ?, NOW() )", array($patient_id,$type));