4 * FormService refactored getFormByEncounter
7 * @link http://www.open-emr.org
8 * @author <Unknown> Authorship was not listed in encounter.inc.php
9 * @author Stephen Nielson <stephen@nielson.org>
10 * @copyright Copyright (c) 2021 Stephen Nielson <stephen@nielson.org>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 namespace OpenEMR\Services
;
18 public function getFormByEncounter(
21 $cols = "form_id, form_name",
23 $orderby = "FIND_IN_SET(formdir,'vitals') DESC, date DESC"
26 global $attendant_type;
27 $arraySqlBind = array();
28 $sql = "select " . escape_sql_column_name(process_cols_escape($cols), array('forms')) . " from forms where encounter = ? and deleted = 0 ";
29 array_push($arraySqlBind, $encounter);
31 $sql .= "and form_name=? ";
32 array_push($arraySqlBind, $name);
35 if ($attendant_type == 'pid') {
36 $sql .= " and pid=? and therapy_group_id IS NULL ";
38 $sql .= " and therapy_group_id = ? and pid IS NULL ";
41 array_push($arraySqlBind, $attendant_id);
43 // Default $orderby puts vitals first in the list, and newpatient last:
44 $sql .= "ORDER BY $orderby";
46 $res = sqlStatement($sql, $arraySqlBind);
48 for ($iter = 0; $row = sqlFetchArray($res); $iter++
) {