Hide dashboard card 2 (#7423)
[openemr.git] / library / gprelations.inc.php
blob47ac9951d07096d21ea8496ec2a48f4ba5aa258a
1 <?php
3 // Copyright (C) 2009 Rod Roark <rod@sunsetsystems.com>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This module supports use of the gprelations table to maintain
11 // many-to-many relationships (linkings) among the following other
12 // tables. For each, a corresponding type code is assigned:
14 // 1 documents
15 // 2 form_encounter (visits)
16 // 3 immunizations
17 // 4 lists (issues)
18 // 5 openemr_postcalendar_events (appointments)
19 // 6 pnotes
20 // 7 prescriptions
21 // 8 transactions (e.g. referrals)
23 // By convention we require that type1 must be less than or equal to type2.
25 // As of this writing (2009-11-11), only documents-to-pnotes relations are
26 // used. However expansion is anticipated, as well as the opportunity to
27 // obsolete the issue_encounter table.
29 function isGpRelation($type1, $id1, $type2, $id2)
31 $tmp = sqlQuery("SELECT count(*) AS count FROM gprelations WHERE " .
32 "type1 = ? AND id1 = ? AND " .
33 "type2 = ? AND id2 = ?", array($type1, $id1, $type2, $id2));
34 return !empty($tmp['count']);
37 function setGpRelation($type1, $id1, $type2, $id2, $set = true)
39 if (isGpRelation($type1, $id1, $type2, $id2)) {
40 if (!$set) {
41 sqlStatement("DELETE FROM gprelations WHERE " .
42 "type1 = ? AND id1 = ? AND type2 = ? AND id2 = ?", array($type1, $id1, $type2, $id2));
44 } else {
45 if ($set) {
46 sqlStatement("INSERT INTO gprelations " .
47 "( type1, id1, type2, id2 ) VALUES " .
48 "( ?, ?, ?, ? )", array($type1, $id1, $type2, $id2));