CCDA import merge duplicate fix (#5978)
[openemr.git] / library / lists.inc.php
bloba1a27fb3ade1d7c4cacd27d13c077dd35a7c8f67
1 <?php
3 /**
4 * Issue list functions and data structure building.
6 * The data structure is the $ISSUE_TYPES array.
7 * The $ISSUE_TYPES array is built from the issue_types sql table and provides
8 * abstraction of issue types to allow customization.
9 * <pre>Attributes of the $ISSUE_TYPES array are:
10 * 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)
11 * 0 - The plural title.
12 * 1 - The singular title.
13 * 2 - The abbreviated title (one letter abbreviation).
14 * 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)
15 * 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).
16 * 5 - ACO for this type, for example "patients|med".
18 * Note there is a mechanism to show whether a category is explicitly set to
19 * 'Nothing' via the getListTouch() and setListTouch() functions that store
20 * applicable information in the lists_touch sql table.
22 * </pre>
24 * LICENSE: This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * as published by the Free Software Foundation; either version 2
27 * of the License, or (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
35 * @package OpenEMR
36 * @author Rod Roark <rod@sunsetsystems.com>
37 * @author Brady Miller <brady.g.miller@gmail.com>
38 * @author Teny <teny@zhservices.com>
39 * @link http://www.open-emr.org
42 // Build the $ISSUE_TYPE_CATEGORIES array
43 // First, set the hard-coded options
44 $ISSUE_TYPE_CATEGORIES = array(
45 'default' => xl('Default'), // Normal OpenEMR use
46 'ippf_specific' => xl('IPPF') // For IPPF use
48 // Second, collect the non hard-coded options and add to the array
49 $res = sqlStatement("SELECT DISTINCT `category` FROM `issue_types`");
50 while ($row = sqlFetchArray($res)) {
51 if (($row['category'] == "default") || ($row['category'] == "ippf_specific")) {
52 continue;
55 $ISSUE_TYPE_CATEGORIES[$row['category']] = $row['category'];
58 $ISSUE_TYPE_STYLES = array(
59 0 => xl('Standard'), // Standard
60 1 => xl('Simplified'), // Simplified: only title, start date, comments and an Active checkbox;no diagnosis, occurrence, end date, referred-by or sports fields.
61 2 => xl('Football Injury'), // Football Injury
62 3 => xl('IPPF Abortion'), // IPPF specific (abortions issues)
63 4 => xl('IPPF Contraception') // IPPF specific (contraceptions issues)
66 /**
67 * Will return the current issue type category that is being used.
68 * @return string The current issue type category that is being used.
70 function collect_issue_type_category()
72 if (!empty($GLOBALS['ippf_specific'])) { // IPPF version
73 return "ippf_specific";
74 } else { // Default version
75 return "default";
79 // Build the $ISSUE_TYPES array (see script header for description)
80 $res = sqlStatement(
81 "SELECT * FROM `issue_types` WHERE active = 1 AND `category`=? ORDER BY `ordering`",
82 array(collect_issue_type_category())
84 while ($row = sqlFetchArray($res)) {
85 $ISSUE_TYPES[$row['type']] = array(
86 xl($row['plural']),
87 xl($row['singular']),
88 xl($row['abbreviation']),
89 $row['style'],
90 $row['force_show'],
91 $row['aco_spec']);
94 $ISSUE_CLASSIFICATIONS = array(
95 0 => xl('Unknown or N/A'),
96 1 => xl('Trauma'),
97 2 => xl('Overuse')
100 function getListById($id, $cols = "*")
102 return sqlQuery("select " . escape_sql_column_name(process_cols_escape($cols), array('lists')) . " from lists where id=? order by date DESC limit 0,1", array($id));
106 function addList($pid, $type, $title, $comments, $activity = "1")
108 return sqlInsert("insert into lists (date, pid, type, title, activity, comments, user, groupname) values (NOW(), ?, ?, ?, ?, ?, ?, ?)", array($pid, $type, $title, $activity, $comments, $_SESSION['authUser'], $_SESSION['authProvider']));
111 function disappearList($id)
113 sqlStatement("update lists set activity = '0' where id=?", array($id));
114 return true;
117 function reappearList($id)
119 sqlStatement("update lists set activity = '1' where id=?", array($id));
120 return true;
123 function getListTouch($patient_id, $type)
125 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type));
127 if (!empty($ret)) {
128 return $ret['date'];
129 } else {
130 return false;
134 function setListTouch($patient_id, $type)
136 $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type));
138 if (!empty($ret)) {
139 // Already touched, so can exit
140 return;
141 } else {
142 sqlStatement("INSERT INTO `lists_touch` ( `pid`,`type`,`date` ) VALUES ( ?, ?, NOW() )", array($patient_id,$type));