added metric version of the vitals form
[openemr.git] / interface / forms / vitalsM / C_FormVitalsM.class.php
blob1114a5e961f3456f76c765caafcf744391f655fc
1 <?php
3 require_once ($GLOBALS['fileroot'] . "/library/classes/Controller.class.php");
4 require_once ($GLOBALS['fileroot'] . "/library/forms.inc");
5 require_once("FormVitalsM.class.php");
7 class C_FormVitalsM extends Controller {
9 var $template_dir;
11 function C_FormVitalsM($template_mod = "general") {
12 parent::Controller();
13 $returnurl = $GLOBALS['concurrent_layout'] ? 'encounter_top.php' : 'patient_encounter.php';
14 $this->template_mod = $template_mod;
15 $this->template_dir = dirname(__FILE__) . "/templates/vitalsM/";
16 $this->assign("FORM_ACTION", $GLOBALS['web_root']);
17 $this->assign("DONT_SAVE_LINK",$GLOBALS['webroot'] . "/interface/patient_file/encounter/$returnurl");
18 $this->assign("STYLE", $GLOBALS['style']);
21 function default_action_old() {
22 $vitals = new FormVitalsM();
23 $this->assign("vitals",$vitals);
24 $this->assign("results", $results);
25 return $this->fetch($this->template_dir . $this->template_mod . "_new.html");
28 function default_action($form_id) {
30 if (is_numeric($form_id)) {
31 $vitals = new FormVitalsM($form_id);
33 else {
34 $vitals = new FormVitalsM();
37 $dbconn = $GLOBALS['adodb']['db'];
38 $sql = "SELECT * from form_vitalsM where id != $form_id and pid = ".$GLOBALS['pid'];
39 $result = $dbconn->Execute($sql);
41 $i = 1;
42 while($result && !$result->EOF)
44 $results[$i]['id'] = $result->fields['id'];
45 $results[$i]['date'] = $result->fields['date'];
46 $results[$i]['activity'] = $result->fields['activity'];
47 $results[$i]['bps'] = $result->fields['bps'];
48 $results[$i]['bpd'] = $result->fields['bpd'];
49 $results[$i]['weight'] = $result->fields['weight'];
50 $results[$i]['height'] = $result->fields['height'];
51 $results[$i]['temperature'] = $result->fields['temperature'];
52 $results[$i]['temp_method'] = $result->fields['temp_method'];
53 $results[$i]['pulse'] = $result->fields['pulse'];
54 $results[$i]['respiration'] = $result->fields['respiration'];
55 $results[$i]['BMI'] = $result->fields['BMI'];
56 $results[$i]['BMI_status'] = $result->fields['BMI_status'];
57 $results[$i]['note'] = $result->fields['note'];
58 $results[$i]['waist_circ'] = $result->fields['waist_circ'];
59 $results[$i]['head_circ'] = $result->fields['head_circ'];
60 $results[$i++]['oxygen_saturation'] = $result->fields['oxygen_saturation'];
61 $result->MoveNext();
63 $this->assign("vitals",$vitals);
64 $this->assign("results", $results);
65 $this->assign("VIEW",true);
66 return $this->fetch($this->template_dir . $this->template_mod . "_new.html");
69 function default_action_process() {
70 if ($_POST['process'] != "true")
71 return;
73 $weight = $_POST["weight"];
74 $height = $_POST["height"];
75 if ($weight > 0 && $height > 0) {
76 $_POST["BMI"] = ($weight/$height/$height)*10000;
78 if ( $_POST["BMI"] > 42 ) $_POST["BMI_status"] = 'Obesity III';
79 elseif ( $_POST["BMI"] > 34 ) $_POST["BMI_status"] = 'Obesity II';
80 elseif ( $_POST["BMI"] > 30 ) $_POST["BMI_status"] = 'Obesity I';
81 elseif ( $_POST["BMI"] > 27 ) $_POST["BMI_status"] = 'Overweight';
82 elseif ( $_POST["BMI"] > 25 ) $_POST["BMI_status"] = 'Normal BL';
83 elseif ( $_POST["BMI"] > 18.5 ) $_POST["BMI_status"] = 'Normal';
84 elseif ( $_POST["BMI"] > 10 ) $_POST["BMI_status"] = 'Underweight';
85 $temperature = $_POST["temperature"];
86 if ($temperature == '0' || $temperature == '') {
87 $_POST["temp_method"] = "";
90 $this->vitals = new FormVitalsM($_POST['id']);
92 parent::populate_object($this->vitals);
94 $this->vitals->persist();
95 if ($GLOBALS['encounter'] < 1) {
96 $GLOBALS['encounter'] = date("Ymd");
98 if(empty($_POST['id']))
100 addForm($GLOBALS['encounter'], "Vitals (Metric)", $this->vitals->id, "vitalsM", $GLOBALS['pid'], $_SESSION['userauthorized']);
101 $_POST['process'] = "";
103 return;