Code type module improvements:
[openemr.git] / library / lists.inc
blob8170a7ea588c41ff9c40bf1e6c396860d05e32a9
1 <?php
2 // Note there is a mechanism to show whether a category is explicitly set to 
3 // 'Nothing' via the getListTouch() and setListTouch() functions that store
4 // applicable information in the lists_touch sql table.
5 //
6 // Do not create a category id with the token 'prescription_erx', since this
7 // has been reserved by the NewCropRx Module (it requires use of the lists_touch
8 // table to support Meaningful Use Reporting). (if you do this, then you would
9 // break the calculations and support for setting the category to 'Nothing')
12 require_once("{$GLOBALS['srcdir']}/sql.inc");
14 if (!empty($GLOBALS['ippf_specific'])) {
15   $ISSUE_TYPES = array(
16     // table type, plural, singular, abbrev, style, force show patient summary screen
17     'medical_problem' => array(xl('Medical Problems'),xl('Problem')      ,xl('P'),0,1),
18     'allergy'         => array(xl('Allergies')       ,xl('Allergy')      ,xl('Y'),0,1),
19     'medication'      => array(xl('Medications')     ,xl('Medication')   ,xl('M'),0,1),
20     'surgery'         => array(xl('Surgeries')       ,xl('Surgery')      ,xl('S'),0,0),
21     'ippf_gcac'       => array(xl('Abortions')       ,xl('Abortion')     ,xl('A'),3,0),
22     'contraceptive'   => array(xl('Contraception')   ,xl('Contraception'),xl('C'),4,0),
23 //  'ippf_srh'        => array(xl('SRH')             ,xl('SRH')          ,xl('R'),5),
24   );
26 else if (!empty($GLOBALS['athletic_team'])) {
27   $ISSUE_TYPES = array(
28     'football_injury' => array(xl('Football Injuries'),xl('Injury') ,xl('I'),2,1),
29     'medical_problem' => array(xl('Medical Problems') ,xl('Medical'),xl('P'),0,0),
30     'allergy'         => array(xl('Allergies')        ,xl('Allergy'),xl('A'),1,0),
31     'general'         => array(xl('General')          ,xl('General'),xl('G'),1,0),
32   );
34 else { // default version
35   $ISSUE_TYPES = array(
36     // table type, plural, singular, abbrev, style, force show patient summary screen
37     'medical_problem' => array(xl('Medical Problems'),xl('Problem')   ,xl('P'),0,1),
38     'allergy'         => array(xl('Allergies')       ,xl('Allergy')   ,xl('A'),0,1),
39     'medication'      => array(xl('Medications')     ,xl('Medication'),xl('M'),0,1),
40     'surgery'         => array(xl('Surgeries')       ,xl('Surgery')   ,xl('S'),0,0),
41     'dental'          => array(xl('Dental Issues')   ,xl('Dental')    ,xl('D'),0,0),
42     //
43     // Styles are:
44     // 0 - Normal, as in 2.8.1.
45     // 1 - Simplified: only title, start date, comments and an Active checkbox;
46     //     no diagnosis, occurrence, end date, referred-by or sports fields.
47     //     Internally we'll still use a null end date to indicate active.
48     // 2 - Football Injury.
49     //
50     // force show patient summary screen is:
51     // 0 - Do not show this category on the patient summary screen if there have
52     //     been no issues entered in for this category.
53     // 1 - Show this category on the patient summary screen even if no issues have
54     //     been entered for this category.
55     //
56   );
60 // 06/2009 - BM Migrated the ISSUE_OCCURRENCES to list_options
63 $ISSUE_CLASSIFICATIONS = array(
64   0   => xl('Unknown or N/A'),
65   1   => xl('Trauma'),
66   2   => xl('Overuse')
69 function getListById ($id, $cols = "*")
71         return sqlQuery("select $cols from lists where id='$id' order by date DESC limit 0,1");
74 function getListByType ($pid, $type, $cols = "*", $active = "all", $limit = "all", $offset="0")
76         if($active == "all")
77                 $sql = "select $cols from lists where pid='$pid' and type='$type' order by date DESC";
78         else
79                 $sql = "select $cols from lists where pid='$pid' and type='$type' and activity='$active' order by date DESC";
80         if ($limit != "all")
81                 $sql .= " limit $offset,$limit";
82         
84         $res = sqlStatement($sql);
85         for($iter =0;$row = sqlFetchArray($res);$iter++)
86                 $all[$iter] = $row;
87         return $all;
91 function addList ($pid, $type, $title, $comments, $activity = "1")
93         return sqlInsert("insert into lists (date, pid, type, title, activity, comments, user, groupname) values (NOW(), '$pid', '$type', '$title', '$activity', '$comments', '".$_SESSION['authUser']."', '".$_SESSION['authProvider']."')");
96 function disappearList ($id)
98         sqlStatement("update lists set activity = '0' where id='$id'");
99         return true;
102 function reappearList ($id)
104         sqlStatement("update lists set activity = '1' where id='$id'");
105         return true;
108 function getListTouch ($patient_id,$type)
110         $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type) );
112         if (!empty($ret)) {
113                 return $ret['date'];
114         }
115         else {
116                 return false;
117         }
120 function setListTouch ($patient_id,$type)
122         $ret = sqlQuery("SELECT `date` FROM `lists_touch` WHERE pid=? AND type=?", array($patient_id,$type) );
124         if (!empty($ret)) {
125                 // Already touched, so can exit
126                 return;
127         }
128         else {
129                 sqlStatement("INSERT INTO `lists_touch` ( `pid`,`type`,`date` ) VALUES ( ?, ?, NOW() )", array($patient_id,$type) );
130         }