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 $ISSUE_TYPE_CATEGORIES = array(
42 'default' => xl('Default'), // Normal OpenEMR use
43 'athletic_team' => xl('Athletic Team'), // For Sports Team use
44 'ippf_specific' => xl('IPPF') // For IPPF use
47 $ISSUE_TYPE_STYLES = array(
48 0 => xl('Standard'), // Standard
49 1 => xl('Simplified'), // Simplified: only title, start date, comments and an Active checkbox;no diagnosis, occurrence, end date, referred-by or sports fields.
50 2 => xl('Football Injury'), // Football Injury
51 3 => xl('IPPF Abortion'), // IPPF specific (abortions issues)
52 4 => xl('IPPF Contraception') // IPPF specific (contraceptions issues)
56 * Will return the current issue type category that is being used.
57 * @return string The current issue type category that is being used.
59 function collect_issue_type_category() {
60 if (!empty($GLOBALS['ippf_specific'])) { // IPPF version
61 return "ippf_specific";
63 else if (!empty($GLOBALS['athletic_team'])) { // Athletic team version
64 return "athletic_team";
66 else { // Default version
71 // Build the $ISSUE_TYPES array (see script header for description)
72 $res = sqlStatement("SELECT * FROM `issue_types` WHERE active=1 AND `category`=? ORDER BY `ordering` ASC", array( collect_issue_type_category() ));
73 while($row = sqlFetchArray($res)){
74 $ISSUE_TYPES[$row['type']] = array(xl($row['plural']),xl($row['singular']),xl($row['abbreviation']),$row['style'],$row['force_show']);
77 $ISSUE_CLASSIFICATIONS = array(
78 0 => xl('Unknown or N/A'),
83 function getListById ($id, $cols = "*")
85 return sqlQuery("select $cols from lists where id='$id' order by date DESC limit 0,1");
88 function getListByType ($pid, $type, $cols = "*", $active = "all", $limit = "all", $offset="0")
91 $sql = "select $cols from lists where pid='$pid' and type='$type' order by date DESC";
93 $sql = "select $cols from lists where pid='$pid' and type='$type' and activity='$active' order by date DESC";
95 $sql .= " limit $offset,$limit";
98 $res = sqlStatement($sql);
99 for($iter =0;$row = sqlFetchArray($res);$iter++)
105 function addList ($pid, $type, $title, $comments, $activity = "1")
107 return sqlInsert("insert into lists (date, pid, type, title, activity, comments, user, groupname) values (NOW(), '$pid', '$type', '$title', '$activity', '$comments', '".$_SESSION['authUser']."', '".$_SESSION['authProvider']."')");
110 function disappearList ($id)
112 sqlStatement("update lists set activity = '0' where id='$id'");
116 function reappearList ($id)
118 sqlStatement("update lists set activity = '1' where id='$id'");
122 function getListTouch ($patient_id,$type)
124 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type) );
134 function setListTouch ($patient_id,$type)
136 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type) );
139 // Already touched, so can exit
143 sqlStatement("INSERT INTO `lists_touch` ( `pid`,`type`,`date` ) VALUES ( ?, ?, NOW() )", array($patient_id,$type) );