forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
C_AbstractClickmap.php
174 lines (159 loc) · 6.1 KB
/
C_AbstractClickmap.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/*
* Copyright Medical Information Integration,LLC [email protected]
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* @file C_AbstractClickmap.php
*
* @brief This file contains the C_AbstractClickmap class, used to control smarty.
*/
/* for $GLOBALS['concurrent_layout','encounter','fileroot','pid','srcdir','style','webroot']
* remember that include paths are calculated relative to the including script, not this file.
* to lock the path to this script (so if called from different scripts) use the dirname(FILE) variable
*/
require_once('../../globals.php');
/* For Controller, the class we're extending. */
require_once ($GLOBALS['srcdir'] . '/classes/Controller.class.php');
/* For the addform() function */
require_once ($GLOBALS['srcdir'] . '/forms.inc');
/**
* @class C_AbstractClickmap
*
* @brief This class extends the Controller class, which is used to control the smarty templating engine.
*
*/
abstract class C_AbstractClickmap extends Controller {
/**
* the directory to find our template file in.
*
* @var template_dir
*/
var $template_dir;
/**
* @brief Initialize a newly created object belonging to this class
*
* @param template_mod
* template module name, passed to Controller's initializer.
*/
function C_AbstractClickmap($template_mod = "general") {
parent::Controller();
$returnurl = $GLOBALS['concurrent_layout'] ? 'encounter_top.php' : 'patient_encounter.php';
$this->template_mod = $template_mod;
$this->template_dir = $GLOBALS['fileroot'] . "/interface/clickmap/template/";
$this->assign("DONT_SAVE_LINK",$GLOBALS['webroot'] . "/interface/patient_file/encounter/$returnurl");
$this->assign("FORM_ACTION", $GLOBALS['webroot']);
$this->assign("STYLE", $GLOBALS['style']);
}
/**
* @brief Override this abstract function with your implementation of createModel.
*
* @param $form_id
* An optional id of a form, to populate data from.
*
* @return Model
* An AbstractClickmapModel derived Object.
*/
abstract public function createModel($form_id="");
/**
* @brief Override this abstract function with your implememtation of getImage
*
* @return The path to the image backing this form relative to the webroot.
*/
abstract function getImage();
/**
* @brief Override this abstract function to return the label of the optionlists on this form.
*
* @return The label used for all dropdown boxes on this form.
*/
abstract function getOptionsLabel();
/**
* @brief Override this abstract functon to return a hash of the optionlist (key=>value pairs).
*
* @return A hash of key=>value pairs, representing all the possible options in the dropdown boxes on this form.
*/
abstract function getOptionList();
/**
* @brief set up the passed in Model object to model the form.
*/
private function set_context( $model ) {
$root = $GLOBALS['webroot'] . "/interface/clickmap";
$model->saveAction = $GLOBALS['webroot'] . "/interface/forms/" . $model->getCode() . "/save.php";
$model->template_dir = $root . "/template";
$model->image = $this->getImage();
$optionList = $this->getOptionList();
$model->optionList = $optionList != null ? json_encode($optionList) : "null";
$optionsLabel = $this->getOptionsLabel();
$model->optionsLabel = isset($optionsLabel) ? "'" . $optionsLabel . "'" : "null";
$data = $model->get_data();
$model->data = $data != "" ? "'" . $data . "'" : "null";
$model->hideNav = "false";
}
/**
* @brief generate an html document from the 'new form' template
*
* @return the result of smarty's fetch() operation.
*/
function default_action() {
$model = $this->createModel();
$this->assign("form", $model);
$this->set_context($model);
return $this->fetch($this->template_dir . $this->template_mod . "_new.html");
}
/**
* @brief generate an html document from the 'new form' template, populated with form data from the passed in form_id.
*
* @param form_id
* The id of the form to populate data from.
*
* @return the result of smarty's fetch() operation.
*/
function view_action($form_id) {
$model = $this->createModel($form_id);
$this->assign("form",$model);
$this->set_context($model);
return $this->fetch($this->template_dir . $this->template_mod . "_new.html");
}
/**
* @brief generate a fragment of an HTML document from the 'new form' template, populated with form data from the passed in form_id.
*
* @param form_id
* The id of the form to populate data from.
*
* @return the result of smarty's fetch() operation.
*/
function report_action($form_id) {
$model = $this->createModel($form_id);
$this->assign("form",$model);
$this->set_context($model);
$model->hideNav = "true";
return $this->fetch($this->template_dir . $this->template_mod . "_new.html");
}
/**
* @brief called to store the submitted form's contents to the database, adding the form to the encounter if necissary.
*/
function default_action_process() {
if ($_POST['process'] != "true") {
return;
}
$this->model = $this->createModel($_POST['id']);
parent::populate_object($this->model);
$this->model->persist();
if ($GLOBALS['encounter'] == "") {
$GLOBALS['encounter'] = date("Ymd");
}
if(empty($_POST['id'])) {
addForm($GLOBALS['encounter'],
$this->model->getTitle(),
$this->model->id,
$this->model->getCode(),
$GLOBALS['pid'],
$_SESSION['userauthorized']
);
$_POST['process'] = "";
}
}
}
?>