2 include_once("../../globals.php");
3 include_once("$srcdir/forms.inc");
4 include_once("$srcdir/sql.inc");
5 include_once("$srcdir/encounter.inc");
6 include_once("$srcdir/acl.inc");
8 foreach ($_POST as $k => $var) {
10 $_POST[$k] = mysql_escape_string($var);
14 $conn = $GLOBALS['adodb']['db'];
16 // $date = $_POST["year"]."-".$_POST["month"]."-".$_POST["day"];
17 // $onset_date = $_POST["onset_year"]."-".$_POST["onset_month"]."-".$_POST["onset_day"];
19 $date = $_POST['form_date'];
20 $onset_date = $_POST['form_onset_date'];
24 $encounter = $conn->GenID("sequences");
25 addForm($encounter, "New Patient Encounter",
26 sqlInsert("INSERT INTO form_encounter SET " .
28 "onset_date = '$onset_date', " .
29 "reason = '$reason', " .
30 "facility = '$facility', " .
32 "encounter = '$encounter'"),
33 "newpatient", $pid, $userauthorized, $date);
35 else if ($mode == 'update')
37 $id = $_REQUEST['id'];
38 $result = sqlQuery("SELECT encounter FROM form_encounter WHERE id = '$id'");
39 $encounter = $result['encounter'];
40 // See view.php to allow or disallow updates of the encounter date.
41 // $datepart = $_POST["day"] ? "date = '$date', " : "";
42 $datepart = acl_check('encounters', 'date_a') ?
"date = '$date', " : "";
44 sqlStatement("update form_encounter set " .
46 "onset_date = '$onset_date', " .
47 "reason = '$reason', " .
48 "facility = '$facility' " .
52 setencounter($encounter);
54 // Update the list of issues associated with this encounter.
55 sqlStatement("DELETE FROM issue_encounter WHERE " .
56 "pid = '$pid' AND encounter = '$encounter'");
57 if (is_array($_POST['issues'])) {
58 foreach ($_POST['issues'] as $issue) {
59 $query = "INSERT INTO issue_encounter ( " .
60 "pid, list_id, encounter " .
62 "'$pid', '$issue', '$encounter'" .
70 <script language
="Javascript">
71 window
.location
="<?echo "$rootdir/patient_file
/encounter
/patient_encounter
.php
";?>";