fix: Update patient_tracker.php (#6595)
[openemr.git] / library / classes / CategoryTree.class.php
blob7663f1b2f265f526f4db26683615b106cafa8115
1 <?php
3 /**
4 * class CategoryTree
5 * This is a class for storing document categories using the MPTT implementation
6 */
8 class CategoryTree extends Tree
11 * This just sits on top of the parent constructor, only a shell so that the _table var gets set
13 function __construct($root, $root_type = ROOT_TYPE_ID)
15 $this->_table = "categories";
16 parent::__construct($root, $root_type);
19 public function should_translate_name()
21 return true;
24 public function get_translated_name($name)
26 return xl_document_category($name);
29 function _get_categories_array($patient_id, $user = '')
31 $categories = array();
32 $sqlArray = array();
33 $sql = "SELECT c.id, c.name, c.aco_spec, d.id AS document_id, d.name AS document_name, d.type, d.url, d.docdate"
34 . " FROM categories AS c, documents AS d, categories_to_documents AS c2d"
35 . " WHERE c.id = c2d.category_id"
36 . " AND c2d.document_id = d.id AND d.deleted = 0";
38 if (is_numeric($patient_id)) {
39 if ($patient_id == "00") {
40 // Collect documents that are not assigned to a patient
41 $sql .= " AND (d.foreign_id = 0 OR d.foreign_id IS NULL) ";
42 } else {
43 // Collect documents for a specific patient
44 $sql .= " AND d.foreign_id = ? ";
45 array_push($sqlArray, $patient_id);
49 $sql .= " ORDER BY c.id ASC, d.docdate DESC, d.url ASC";
51 //echo $sql;
52 $result = $this->_db->Execute($sql, $sqlArray);
54 while ($result && !$result->EOF) {
55 $categories[$result->fields['id']][$result->fields['document_id']] = $result->fields;
56 $result->MoveNext();
59 return $categories;