3 // Copyright (C) 2008, 2010 Rod Roark <rod@sunsetsystems.com>
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This is invoked via a jQuery getScript() from fax_dispatch.php.
11 // Its purpose is to return JavaScript that will set up patient-
12 // specific data when a patient is selected. Currently this data
13 // is just the caller's selection list of recent encounters.
16 require_once("../globals.php");
18 use OpenEMR\Common\Csrf\CsrfUtils
;
20 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
21 CsrfUtils
::csrfNotVerified();
24 $res = sqlStatement("SELECT date, encounter, reason FROM form_encounter " .
26 "ORDER BY date DESC, encounter DESC LIMIT 10", array($_GET['p']));
28 echo "var s = document.forms[0].form_copy_sn_visit;\n";
29 echo "s.options.length = 0;\n";
31 while ($row = sqlFetchArray($res)) {
32 echo "s.options[s.options.length] = new Option(" .
33 "'" . attr(substr($row['date'], 0, 10)) . " " .
34 attr(strtr(substr($row['reason'], 0, 40), "\r\n", " ")) . "', " .
35 "'" . attr($row['encounter']) . "'" .