Fixed php short tags
[openemr.git] / contrib / forms / well_child_care / save.php
blob3a615f1f839911d24087f2c379ff09df820ff75b
1 <?php
2 //
4 include_once("../../globals.php");
5 include_once("$srcdir/api.inc");
6 include_once("$srcdir/forms.inc");
8 foreach ($_POST as $k => $var) {
9 $_POST[$k] = mysql_escape_string($var);
10 echo "$var\n";
13 // calculate body mass index bmi=k/(m**2)
14 $k=$_POST["weight"]/2.2;
15 $w=$_POST["height"]/39.4;
16 $_POST["BMI"]=round ( ($k/($w*$w)),2);
17 /*
18 bmi for children needs to be adjusted acording a table,
19 this status calculation won't work as for adults
20 $bmi=$_POST["BMI"];
21 if ( $bmi > 42 ) { $_POST["BMI_status"]='Obesity III'; }
22 elseif ( $bmi > 34 ) { $_POST["BMI_status"]='Obesity II'; }
23 elseif ( $bmi > 30 ) { $_POST["BMI_status"]='Obesity I'; }
24 elseif ( $bmi > 27 ) { $_POST["BMI_status"]='Overweight'; }
25 elseif ( $bmi > 25 ) { $_POST["BMI_status"]='Normal BL'; }
26 elseif ( $bmi > 18.5 ) { $_POST["BMI_status"]='Normal'; }
27 elseif ( $bmi > 10 ) { $_POST["BMI_status"]='Underweight'; }
30 if ($encounter == "") $encounter = date("Ymd");
32 if ($_GET["mode"] == "new"){
33 $newid = formSubmit("form_well_child_care", $_POST, $_GET["id"], $userauthorized);
34 addForm($encounter, "Well Child Care", $newid, "well_child_care", $pid, $userauthorized);
35 } elseif ($_GET["mode"] == "update") {
36 $insert="update form_well_child_care set `pid` = {$_SESSION["pid"]},
37 `groupname`='".$_SESSION["authProvider"]."',
38 `user`='".$_SESSION["authUser"]."',
39 `authorized`=$userauthorized,
40 `activity`=1,
41 `date` = NOW(), ";
43 foreach ($_POST as $k => $var) {
44 $insert.="`$k`='$var',";
46 $insert=substr ($insert,0,-1);
47 $insert.="WHERE id=$id";
48 sqlInsert($insert);
51 $_SESSION["encounter"] = $encounter;
53 formHeader("Redirecting....");
54 formJump();
55 formFooter();