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).
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@sparmy.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") ) continue;
51 $ISSUE_TYPE_CATEGORIES[$row['category']] = $row['category'];
54 $ISSUE_TYPE_STYLES = array(
55 0 => xl('Standard'), // Standard
56 1 => xl('Simplified'), // Simplified: only title, start date, comments and an Active checkbox;no diagnosis, occurrence, end date, referred-by or sports fields.
57 2 => xl('Football Injury'), // Football Injury
58 3 => xl('IPPF Abortion'), // IPPF specific (abortions issues)
59 4 => xl('IPPF Contraception') // IPPF specific (contraceptions issues)
63 * Will return the current issue type category that is being used.
64 * @return string The current issue type category that is being used.
66 function collect_issue_type_category() {
67 if (!empty($GLOBALS['ippf_specific'])) { // IPPF version
68 return "ippf_specific";
70 else { // Default version
75 // Build the $ISSUE_TYPES array (see script header for description)
76 $res = sqlStatement("SELECT * FROM `issue_types` WHERE active=1 AND `category`=? ORDER BY `ordering` ASC", array( collect_issue_type_category() ));
77 while($row = sqlFetchArray($res)){
78 $ISSUE_TYPES[$row['type']] = array(xl($row['plural']),xl($row['singular']),xl($row['abbreviation']),$row['style'],$row['force_show']);
81 $ISSUE_CLASSIFICATIONS = array(
82 0 => xl('Unknown or N/A'),
87 function getListById ($id, $cols = "*")
89 return sqlQuery("select $cols from lists where id='$id' order by date DESC limit 0,1");
92 function getListByType ($pid, $type, $cols = "*", $active = "all", $limit = "all", $offset="0")
95 $sql = "select $cols from lists where pid='$pid' and type='$type' order by date DESC";
97 $sql = "select $cols from lists where pid='$pid' and type='$type' and activity='$active' order by date DESC";
99 $sql .= " limit $offset,$limit";
102 $res = sqlStatement($sql);
103 for($iter =0;$row = sqlFetchArray($res);$iter++)
109 function addList ($pid, $type, $title, $comments, $activity = "1")
111 return sqlInsert("insert into lists (date, pid, type, title, activity, comments, user, groupname) values (NOW(), '$pid', '$type', '$title', '$activity', '$comments', '".$_SESSION['authUser']."', '".$_SESSION['authProvider']."')");
114 function disappearList ($id)
116 sqlStatement("update lists set activity = '0' where id='$id'");
120 function reappearList ($id)
122 sqlStatement("update lists set activity = '1' where id='$id'");
126 function getListTouch ($patient_id,$type)
128 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type) );
138 function setListTouch ($patient_id,$type)
140 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type) );
143 // Already touched, so can exit
147 sqlStatement("INSERT INTO `lists_touch` ( `pid`,`type`,`date` ) VALUES ( ?, ?, NOW() )", array($patient_id,$type) );