3 require_once("{$GLOBALS['srcdir']}/sql.inc");
5 function getFormById ($id, $cols = "*")
7 $sql = "select $cols from forms where id='$id' order by date DESC limit 0,1";
8 //echo $sql . "<br />";
12 function getFormInfoById ($id, $cols = "*")
14 $sql = "select $cols from forms where id='$id' order by date DESC limit 0,1";
15 //echo $sql . "<br />";
16 $result = sqlQuery($sql);
17 if ($result['formdir'] == "newpatient") {
18 $result['formdir'] = "encounter";
20 $sql = "select * from form_" . $result['formdir'] . " where id='" . $result['form_id'] . "'";
21 //echo $sql . "<br />";
22 $result = sqlQuery($sql);
28 function getFormsByPid ($pid, $cols = "*")
30 return sqlQuery("select $cols from forms where pid ='$pid'");
33 function getFormByEncounter($pid,$encounter, $cols="form_id, form_name", $name="")
35 $sql = "select $cols from forms where encounter = '$encounter' and pid='$pid' ";
37 $sql .= "and form_name='" . $name ."' ";
39 $sql .= "order by date DESC";
41 $res = sqlStatement($sql);
43 for($iter=0; $row=sqlFetchArray($res); $iter++)
50 function addForm($encounter, $form_name, $form_id, $formdir, $pid, $authorized = "0", $date="NOW()")
52 $sql = "insert into forms (date, encounter, form_name, form_id, pid, user, groupname, authorized, formdir) values (";
58 $sql .= ", '$encounter', '$form_name', '$form_id', '$pid', '" . $_SESSION['authUser'] . "', '" . $_SESSION['authProvider'] . "', '$authorized', '$formdir')";
59 return sqlInsert( $sql );
63 function authorizeForm($id, $authorized = "1")
65 sqlQuery("update forms set authorized = '$authorized' where id = '$id'");
69 function getEncounters($pid)
71 $res = sqlStatement("select distinct encounter from forms where pid='$pid' order by date desc;");
73 for($iter=0; $row=sqlFetchArray($res); $iter++)
81 function getEncounterDateByEncounter($encounter)
83 $sql = "select date from forms where encounter='$encounter' order by date";
84 return sqlQuery($sql);
88 function getFormNameByFormdir ($formdir)
90 return sqlQuery("select form_name from forms where formdir='$formdir'");