forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
C_Pharmacy.class.php
75 lines (62 loc) · 2.27 KB
/
C_Pharmacy.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require_once ($GLOBALS['fileroot'] . "/library/classes/Controller.class.php");
require_once($GLOBALS['fileroot'] ."/library/classes/Pharmacy.class.php");
class C_Pharmacy extends Controller {
var $template_mod;
var $pharmacies;
function __construct($template_mod = "general") {
parent::__construct();
$this->pharmacies = array();
$this->template_mod = $template_mod;
$this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . $_SERVER['QUERY_STRING']);
$this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&");
$this->assign("STYLE", $GLOBALS['style']);
$this->assign("WEB_ROOT", $GLOBALS['webroot'] );
}
function default_action() {
return $this->list_action();
}
function edit_action($id = "",$patient_id="",$p_obj = null) {
if ($p_obj != null && get_class($p_obj) == "pharmacy") {
$this->pharmacies[0] = $p_obj;
}
elseif (get_class($this->pharmacies[0]) != "pharmacy" ) {
$this->pharmacies[0] = new Pharmacy($id);
}
if (!empty($patient_id)) {
$this->pharmacies[0]->set_patient_id($patient_id);
$this->pharmacies[0]->set_provider($this->pharmacies[0]->patient->get_provider());
}
$this->assign("pharmacy", $this->pharmacies[0]);
return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_edit.html");
}
function list_action($sort = "") {
if (!empty($sort)) {
$this->assign("pharmacies", Pharmacy::pharmacies_factory("",$sort));
}
else {
$this->assign("pharmacies", Pharmacy::pharmacies_factory());
}
//print_r(Prescription::prescriptions_factory($id));
return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_list.html");
}
function edit_action_process() {
if ($_POST['process'] != "true")
return;
//print_r($_POST);
if (is_numeric($_POST['id'])) {
$this->pharmacies[0] = new Pharmacy($_POST['id']);
}
else {
$this->pharmacies[0] = new Pharmacy();
}
parent::populate_object($this->pharmacies[0]);
//print_r($this->pharmacies[0]);
//echo $this->pharmacies[0]->toString(true);
$this->pharmacies[0]->persist();
//echo "action processeed";
$_POST['process'] = "";
header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H
}
}
?>