3 * Copyright Medical Information Integration,LLC info@mi-squared.com
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * @file C_AbstractClickmap.php
11 * @brief This file contains the C_AbstractClickmap class, used to control smarty.
14 /* for encounter','fileroot','pid','srcdir','style','webroot']
15 * remember that include paths are calculated relative to the including script, not this file.
16 * to lock the path to this script (so if called from different scripts) use the dirname(FILE) variable
18 require_once(dirname(__FILE__
).'/../globals.php');
20 /* For the addform() function */
21 require_once($GLOBALS['srcdir'] . '/forms.inc');
24 * @class C_AbstractClickmap
26 * @brief This class extends the Controller class, which is used to control the smarty templating engine.
29 abstract class C_AbstractClickmap
extends Controller
32 * the directory to find our template file in.
39 * @brief Initialize a newly created object belonging to this class
42 * template module name, passed to Controller's initializer.
44 function __construct($template_mod = "general")
46 parent
::__construct();
47 $returnurl = 'encounter_top.php';
48 $this->template_mod
= $template_mod;
49 $this->template_dir
= $GLOBALS['fileroot'] . "/interface/clickmap/template/";
50 $this->assign("DONT_SAVE_LINK", $GLOBALS['webroot'] . "/interface/patient_file/encounter/$returnurl");
51 $this->assign("FORM_ACTION", $GLOBALS['webroot']);
52 $this->assign("STYLE", $GLOBALS['style']);
56 * @brief Override this abstract function with your implementation of createModel.
59 * An optional id of a form, to populate data from.
62 * An AbstractClickmapModel derived Object.
64 abstract public function createModel($form_id = "");
67 * @brief Override this abstract function with your implememtation of getImage
69 * @return The path to the image backing this form relative to the webroot.
71 abstract function getImage();
74 * @brief Override this abstract function to return the label of the optionlists on this form.
76 * @return The label used for all dropdown boxes on this form.
78 abstract function getOptionsLabel();
81 * @brief Override this abstract functon to return a hash of the optionlist (key=>value pairs).
83 * @return A hash of key=>value pairs, representing all the possible options in the dropdown boxes on this form.
85 abstract function getOptionList();
88 * @brief set up the passed in Model object to model the form.
90 private function set_context($model)
92 $root = $GLOBALS['webroot'] . "/interface/clickmap";
93 $model->saveAction
= $GLOBALS['webroot'] . "/interface/forms/" . $model->getCode() . "/save.php";
94 $model->template_dir
= $root . "/template";
95 $model->image
= $this->getImage();
96 $optionList = $this->getOptionList();
97 $model->optionList
= $optionList != null ?
json_encode($optionList) : "null";
98 $optionsLabel = $this->getOptionsLabel();
99 $model->optionsLabel
= isset($optionsLabel) ?
"'" . $optionsLabel . "'" : "null";
101 $data = $model->get_data();
102 $model->data
= $data != "" ?
"'" . $data . "'" : "null";
103 $model->hideNav
= "false";
107 * @brief generate an html document from the 'new form' template
109 * @return the result of smarty's fetch() operation.
111 function default_action()
113 $model = $this->createModel();
114 $this->assign("form", $model);
115 $this->set_context($model);
116 return $this->fetch($this->template_dir
. $this->template_mod
. "_new.html");
120 * @brief generate an html document from the 'new form' template, populated with form data from the passed in form_id.
123 * The id of the form to populate data from.
125 * @return the result of smarty's fetch() operation.
127 function view_action($form_id)
129 $model = $this->createModel($form_id);
130 $this->assign("form", $model);
131 $this->set_context($model);
132 return $this->fetch($this->template_dir
. $this->template_mod
. "_new.html");
136 * @brief generate a fragment of an HTML document from the 'new form' template, populated with form data from the passed in form_id.
139 * The id of the form to populate data from.
141 * @return the result of smarty's fetch() operation.
143 function report_action($form_id)
145 $model = $this->createModel($form_id);
146 $this->assign("form", $model);
147 $this->set_context($model);
148 $model->hideNav
= "true";
149 return $this->fetch($this->template_dir
. $this->template_mod
. "_new.html");
153 * @brief called to store the submitted form's contents to the database, adding the form to the encounter if necissary.
155 function default_action_process()
157 if ($_POST['process'] != "true") {
161 $this->model
= $this->createModel($_POST['id']);
162 parent
::populate_object($this->model
);
163 $this->model
->persist();
164 if ($GLOBALS['encounter'] == "") {
165 $GLOBALS['encounter'] = date("Ymd");
168 if (empty($_POST['id'])) {
170 $GLOBALS['encounter'],
171 $this->model
->getTitle(),
173 $this->model
->getCode(),
175 $_SESSION['userauthorized']
177 $_POST['process'] = "";