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 // This puts vitals first in the list, and newpatient last:
43 $sql .= "ORDER BY FIND_IN_SET(formdir,'vitals') DESC, date DESC";
45 $res = sqlStatement($sql);
47 for($iter=0; $row=sqlFetchArray($res); $iter++)
54 function addForm($encounter, $form_name, $form_id, $formdir, $pid,
55 $authorized = "0", $date="NOW()", $user="", $group="")
57 if (!$user) $user = $_SESSION['authUser'];
58 if (!$group) $group = $_SESSION['authProvider'];
59 $sql = "insert into forms (date, encounter, form_name, form_id, pid, " .
60 "user, groupname, authorized, formdir) values (";
65 $sql .= ", '$encounter', '$form_name', '$form_id', '$pid', '$user', " .
66 "'$group', '$authorized', '$formdir')";
67 return sqlInsert( $sql );
70 function authorizeForm($id, $authorized = "1")
72 sqlQuery("update forms set authorized = '$authorized' where id = '$id'");
75 function getEncounters($pid)
77 // $res = sqlStatement("select distinct encounter from forms where pid='$pid' order by date desc;");
79 $res = sqlStatement("select distinct encounter from form_encounter where pid = '$pid' order by date desc;");
81 for($iter=0; $row=sqlFetchArray($res); $iter++)
88 function getEncounterDateByEncounter($encounter)
90 // $sql = "select date from forms where encounter='$encounter' order by date";
91 $sql = "select date from form_encounter where encounter='$encounter' order by date";
92 return sqlQuery($sql);
95 function getFormNameByFormdir ($formdir)
97 return sqlQuery("select form_name from forms where formdir='$formdir'");