forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CategoryTree.class.php
52 lines (41 loc) · 1.49 KB
/
CategoryTree.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require_once("Tree.class.php");
/**
* class CategoryTree
* This is a class for storing document categories using the MPTT implementation
*/
class CategoryTree extends Tree {
/*
* This just sits on top of the parent constructor, only a shell so that the _table var gets set
*/
function __construct($root,$root_type = ROOT_TYPE_ID) {
$this->_table = "categories";
parent::__construct($root,$root_type);
}
function _get_categories_array($patient_id) {
$categories = array();
$sql = "SELECT c.id, c.name, d.id AS document_id, d.type, d.url, d.docdate"
. " FROM categories AS c, documents AS d, categories_to_documents AS c2d"
. " WHERE c.id = c2d.category_id"
. " AND c2d.document_id = d.id";
if (is_numeric($patient_id)) {
if ($patient_id == "00") {
// Collect documents that are not assigned to a patient
$sql .= " AND (d.foreign_id = 0 OR d.foreign_id IS NULL) ";
}
else {
// Collect documents for a specific patient
$sql .= " AND d.foreign_id = '" . $patient_id . "'";
}
}
$sql .= " ORDER BY c.id ASC, d.docdate DESC, d.url ASC";
//echo $sql;
$result = $this->_db->Execute($sql);
while ($result && !$result->EOF) {
$categories[$result->fields['id']][$result->fields['document_id']] = $result->fields;
$result->MoveNext();
}
return $categories;
}
}
?>