3 require_once("{$GLOBALS['srcdir']}/sql.inc");
5 $GLOBALS['form_exit_url'] = $GLOBALS['concurrent_layout'] ?
6 "$rootdir/patient_file/encounter/encounter_top.php" :
7 "$rootdir/patient_file/encounter/patient_encounter.php";
9 function getFormById ($id, $cols = "*")
11 $sql = "select $cols from forms where id='$id' order by date DESC limit 0,1";
12 //echo $sql . "<br />";
13 return sqlQuery($sql);
16 function getFormInfoById ($id, $cols = "*")
18 $sql = "select $cols from forms where id='$id' order by date DESC limit 0,1";
19 //echo $sql . "<br />";
20 $result = sqlQuery($sql);
21 if ($result['formdir'] == "newpatient") {
22 $result['formdir'] = "encounter";
24 $sql = "select * from form_" . $result['formdir'] . " where id='" . $result['form_id'] . "'";
25 //echo $sql . "<br />";
26 $result = sqlQuery($sql);
31 function getFormsByPid ($pid, $cols = "*")
33 return sqlQuery("select $cols from forms where pid ='$pid'");
36 function getFormByEncounter($pid,$encounter, $cols="form_id, form_name", $name="")
38 $sql = "select $cols from forms where encounter = '$encounter' and pid='$pid' ";
40 $sql .= "and form_name='" . $name ."' ";
42 $sql .= "order by date DESC";
44 $res = sqlStatement($sql);
46 for($iter=0; $row=sqlFetchArray($res); $iter++)
53 function addForm($encounter, $form_name, $form_id, $formdir, $pid,
54 $authorized = "0", $date="NOW()", $user="", $group="")
56 if (!$user) $user = $_SESSION['authUser'];
57 if (!$group) $group = $_SESSION['authProvider'];
58 $sql = "insert into forms (date, encounter, form_name, form_id, pid, " .
59 "user, groupname, authorized, formdir) values (";
64 $sql .= ", '$encounter', '$form_name', '$form_id', '$pid', '$user', " .
65 "'$group', '$authorized', '$formdir')";
66 return sqlInsert( $sql );
69 function authorizeForm($id, $authorized = "1")
71 sqlQuery("update forms set authorized = '$authorized' where id = '$id'");
74 function getEncounters($pid)
76 // $res = sqlStatement("select distinct encounter from forms where pid='$pid' order by date desc;");
78 $res = sqlStatement("select distinct encounter from form_encounter where pid = '$pid' order by date desc;");
80 for($iter=0; $row=sqlFetchArray($res); $iter++)
87 function getEncounterDateByEncounter($encounter)
89 // $sql = "select date from forms where encounter='$encounter' order by date";
90 $sql = "select date from form_encounter where encounter='$encounter' order by date";
91 return sqlQuery($sql);
94 function getFormNameByFormdir ($formdir)
96 return sqlQuery("select form_name from forms where formdir='$formdir'");