Ob/Gyn forms contributed by Douglas Crosdale
[openemr.git] / contrib / forms / physician_history / save.php
blob5a870b3cc29e1b7ece68a6ae25d49ff05fbe6879
1 <?php
2 // 2005-03-14
3 // Physician history storage and update module
4 //
6 include_once("../../globals.php");
7 include_once("$srcdir/api.inc");
8 include_once("$srcdir/forms.inc");
10 $flds = sqlListFields("form_physician_history");
11 $flds = array_slice($flds,7);
12 foreach ($flds as $key => $fld){
13 $data[$fld] = '';
17 foreach ($_POST as $k => $var) {
18 $_POST[$k] = mysql_escape_string($var);
19 if (($k != 'pname')&&($k != 'pbdate')&&($k != 'ph_pid')&&($k != 'ph_date')
20 && (substr($k, 0,5)!='oh_ch')){
21 $data[$k] = $_POST[$k];
22 if ($data[$k] == "YYYY-MM-DD") {
23 $data[$k] = '';
26 //echo "$var\n";
28 $ii = 0;
29 while ($ii < 4){
30 $data["oh_ch_rec_".$ii] = $_POST["oh_ch_date_".$ii] . "|~".
31 $_POST["oh_ch_width_".$ii] . "|~".
32 $_POST["oh_ch_sex_".$ii] . "|~".
33 $_POST["oh_ch_weeks_".$ii] . "|~".
34 $_POST["oh_ch_delivery_".$ii] . "|~".
35 $_POST["oh_ch_notes_".$ii];
36 $ii++;
39 if ($_GET["mode"] == "new"){
40 if ($encounter == "") { $encounter = date("Ymd"); }
41 $newid = formSubmit("form_physician_history", $data, $_GET["id"], $userauthorized);
42 addForm($encounter, "Physician history", $newid, "physician_history", $pid, $userauthorized);
43 $_SESSION["encounter"] = $encounter;
44 } elseif ($_GET["mode"] == "update") {
45 $q1 = '';
46 foreach ($data as $key => $val){
47 $q1 .= "$key='$val', ";
49 //print $q1; exit;
50 sqlInsert("update form_physician_history set pid = {$_SESSION["pid"]},groupname='".$_SESSION["authProvider"]."',user='".$_SESSION["authUser"]."',authorized=$userauthorized,activity=1, $q1 date = NOW() where id=$id");
52 sqlInsert("update patient_data set DOB='".$_POST['pbdate']."' where id=$pid");
54 //$_SESSION["pid"] = $pid;
55 formHeader("Redirecting....");
56 formJump();
57 formFooter();