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 $arraySqlBind = array();
39 $sql = "select $cols from forms where encounter = ? and pid=? ";
40 array_push($arraySqlBind,$encounter,$pid);
42 $sql .= "and form_name=? ";
43 array_push($arraySqlBind,$name);
45 // This puts vitals first in the list, and newpatient last:
46 $sql .= "ORDER BY FIND_IN_SET(formdir,'vitals') DESC, date DESC";
48 $res = sqlStatement($sql,$arraySqlBind);
50 for($iter=0; $row=sqlFetchArray($res); $iter++)
57 function addForm($encounter, $form_name, $form_id, $formdir, $pid,
58 $authorized = "0", $date="NOW()", $user="", $group="")
60 if (!$user) $user = $_SESSION['authUser'];
61 if (!$group) $group = $_SESSION['authProvider'];
62 $sql = "insert into forms (date, encounter, form_name, form_id, pid, " .
63 "user, groupname, authorized, formdir) values (";
68 $sql .= ", '$encounter', '$form_name', '$form_id', '$pid', '$user', " .
69 "'$group', '$authorized', '$formdir')";
70 return sqlInsert( $sql );
73 function authorizeForm($id, $authorized = "1")
75 sqlQuery("update forms set authorized = '$authorized' where id = '$id'");
78 function getEncounters($pid)
81 $res = sqlStatement("select distinct encounter from form_encounter where pid = ? order by date desc;", array($pid) );
83 for($iter=0; $row=sqlFetchArray($res); $iter++)
90 function getEncounterDateByEncounter($encounter)
92 // $sql = "select date from forms where encounter='$encounter' order by date";
93 $sql = "select date from form_encounter where encounter='$encounter' order by date";
94 return sqlQuery($sql);
97 function getFormNameByFormdirAndFormid ($formdir,$form_id)
99 return sqlQuery("select form_name from forms where formdir='$formdir' and form_id='$form_id'");
102 function getFormNameByFormdir ($formdir)
104 return sqlQuery("select form_name from forms where formdir='$formdir'");