Openemr fhir observations for vitals and smoking status (#4460)
[openemr.git] / controllers / C_Pharmacy.class.php
blobcc317428a101680b9bab00b417ddf946d9c78eca
1 <?php
3 /**
4 * C_Pharmacy class
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 class C_Pharmacy extends Controller
17 var $template_mod;
18 var $pharmacies;
19 public $totalpages;
21 function __construct($template_mod = "general")
23 parent::__construct();
24 $this->pharmacies = array();
25 $this->template_mod = $template_mod;
26 $this->assign("FORM_ACTION", $GLOBALS['webroot'] . "/controller.php?" . attr($_SERVER['QUERY_STRING']));
27 $this->assign("CURRENT_ACTION", $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&pharmacy&");
28 $this->assign("STYLE", $GLOBALS['style']);
29 $this->Pharmacy = new Pharmacy();
30 $this->totalpages = $this->Pharmacy->totalPages();
31 $this->pageno = $this->Pharmacy->getPageno();
34 function default_action()
36 return $this->list_action();
39 function edit_action($id = "", $patient_id = "", $p_obj = null)
41 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
42 $this->pharmacies[0] = $p_obj;
43 } elseif (empty($this->pharmacies[0]) || !is_object($this->pharmacies[0]) || get_class($this->pharmacies[0]) != "pharmacy") {
44 $this->pharmacies[0] = new Pharmacy($id);
47 if (!empty($patient_id)) {
48 $this->pharmacies[0]->set_patient_id($patient_id);
49 $this->pharmacies[0]->set_provider($this->pharmacies[0]->patient->get_provider());
52 $this->assign("pharmacy", $this->pharmacies[0]);
53 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_edit.html");
56 function list_action($sort = "")
59 if (!empty($sort)) {
60 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory("", $sort));
61 } else {
62 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory());
65 //print_r(Prescription::prescriptions_factory($id));
66 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_list.html");
70 function edit_action_process()
72 if ($_POST['process'] != "true") {
73 return;
76 //print_r($_POST);
77 if (is_numeric($_POST['id'])) {
78 $this->pharmacies[0] = new Pharmacy($_POST['id']);
79 } else {
80 $this->pharmacies[0] = new Pharmacy();
83 parent::populate_object($this->pharmacies[0]);
84 //print_r($this->pharmacies[0]);
85 //echo $this->pharmacies[0]->toString(true);
86 $this->pharmacies[0]->persist();
87 //echo "action processeed";
88 $_POST['process'] = "";
89 header('Location:' . $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H