5 * Sponsored by David Eschelbacher, MD
8 * @link http://www.open-emr.org
9 * @author Rod Roark <rod@sunsetsystems.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @author Jerry Padgett <sjpadgett@gmail.com>
12 * @copyright Copyright (c) 2012-2016 Rod Roark <rod@sunsetsystems.com>
13 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
14 * @copyright Copyright (c) 2019 Jerry Padgett <sjpadgett@gmail.com>
15 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
19 require_once(dirname(__FILE__
) . "/../../globals.php");
20 require_once "$srcdir/user.inc";
21 require_once "$srcdir/options.inc.php";
22 use OpenEMR\Core\Header
;
24 $uspfx = 'patient_finder.'; //substr(__FILE__, strlen($webserver_root)) . '.';
25 $patient_finder_exact_search = prevSetting($uspfx, 'patient_finder_exact_search', 'patient_finder_exact_search', ' ');
27 $popup = empty($_REQUEST['popup']) ?
0 : 1;
28 $searchAny = empty($_GET['search_any']) ?
"" : $_GET['search_any'];
29 unset($_GET['search_any']);
30 // Generate some code based on the list of columns.
36 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
37 "list_id = 'ptlistcols' AND activity = 1 ORDER BY seq, title");
38 while ($row = sqlFetchArray($res)) {
39 $colname = $row['option_id'];
40 $title = xl_list_label($row['title']);
41 $title1 = ($title == xl('Full Name'))?
xl('Name'): $title;
43 $header .= text($title);
45 $header0 .= " <td ><input type='text' size='20' ";
46 $header0 .= "value='' class='search_init' placeholder='".xla("Search by"). " " . $title1 ."'/></td>\n";
50 $coljson .= "{\"sName\": \"" . addcslashes($colname, "\t\r\n\"\\") . "\"}";
53 $loading = "<i class='fa fa-refresh fa-2x fa-spin'></i>";
57 <?php Header
::setupHeader();?
>
58 <title
><?php
echo xlt("Patient Finder"); ?
></title
>
59 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-dt/css/jquery.dataTables.css" type
="text/css">
60 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-colreorder-dt/css/colReorder.dataTables.css" type
="text/css">
61 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net/js/jquery.dataTables.js"></script
>
62 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-colreorder/js/dataTables.colReorder.js"></script
>
64 /* Finder Processing style */
65 div
.dataTables_wrapper div
.dataTables_processing
{
70 transform
: translateX(-50%
);
73 <script language
="JavaScript">
75 var uspfx
= '<?php echo attr($uspfx); ?>';
78 // Initializing the DataTable.
80 let serverUrl
= "dynamic_finder_ajax.php?csrf_token_form=" +
<?php
echo js_url(collectCsrfToken()); ?
>;
81 let srcAny
= <?php
echo js_url($searchAny); ?
>;
83 serverUrl +
= "&search_any=" + srcAny
;
85 var oTable
= $
('#pt_table').dataTable({
87 // next 2 lines invoke server side processing
89 // NOTE kept the legacy command 'sAjaxSource' here for now since was unable to get
90 // the new 'ajax' command to work.
91 "sAjaxSource": serverUrl
,
92 "fnServerParams": function (aoData
) {
93 var searchType
= $
("#setting_search_type:checked").length
> 0;
94 aoData
.push({"name": "searchType", "value": searchType
});
96 // dom invokes ColReorderWithResize and allows inclusion of a custom div
97 "dom": 'Rlfrt<"mytopdiv">ip',
98 // These column names come over as $_GET['sColumns'], a comma-separated list of the names.
99 // See: http://datatables.net/usage/columns and
100 // http://datatables.net/release-datatables/extras/ColReorder/server_side.html
101 "columns": [ <?php
echo $coljson; ?
> ],
102 "lengthMenu": [10, 25, 50, 100],
103 "pageLength": <?php
echo empty($GLOBALS['gbl_pt_list_page_size']) ?
'10' : $GLOBALS['gbl_pt_list_page_size']; ?
>,
104 <?php
// Bring in the translations ?>
105 <?php
$translationsDatatablesOverride = array('search' => (xla('Search all columns') . ':')); ?
>
106 <?php
$translationsDatatablesOverride = array('processing' => $loading); ?
>
107 <?php
require($GLOBALS['srcdir'] . '/js/xl/datatables-net.js.php'); ?
>
111 $
("div.mytopdiv").html("<form name='myform'><label for='form_new_window' id='form_new_window_label'><input type='checkbox' id='form_new_window' name='form_new_window' value='1'<?php
112 if (!empty($GLOBALS['gbl_pt_list_new_window'])) {
115 ?> /><?php echo xlt('Open in New Window'); ?></label><label for='setting_search_type' id='setting_search_type_label'><input type='checkbox' name='setting_search_type' id='setting_search_type' onchange='persistCriteria(this, event)' value='<?php echo attr($patient_finder_exact_search); ?>'<?php echo text($patient_finder_exact_search); ?>/><?php echo xlt('Search with exact method'); ?></label></form>");
117 // This is to support column-specific search fields.
118 // Borrowed from the multi_filter.html example.
119 $
("thead input").keyup(function () {
120 // Filter on the column (the index) of this element
121 oTable
.fnFilter(this
.value
, $
("thead input").index(this
));
123 // OnClick handler for the rows
124 $
('#pt_table').on('click', 'tbody tr', function () {
125 // ID of a row element is pid_{value}
126 var newpid
= this
.id
.substring(4);
127 // If the pid is invalid, then don't attempt to set
128 // The row display for "No matching records found" has no valid ID, but is
129 // otherwise clickable. (Matches this CSS selector). This prevents an invalid
130 // state for the PID to be set.
131 if (newpid
.length
=== 0) {
134 if (document
.myform
.form_new_window
.checked
) {
135 openNewTopWindow(newpid
);
138 top
.restoreSession();
139 top
.RTop
.location
= "../../patient_file/summary/demographics.php?set_pid=" +
encodeURIComponent(newpid
);
144 function openNewTopWindow(pid
) {
145 document
.fnew
.patientID
.value
= pid
;
146 top
.restoreSession();
147 document
.fnew
.submit();
150 function persistCriteria(el
, e
) {
152 let target
= uspfx +
"patient_finder_exact_search";
153 let val
= el
.checked ?
' checked' : ' ';
154 $
.post("../../../library/ajax/user_settings.php",
158 csrf_token_form
: "<?php echo attr(collectCsrfToken()); ?>"
165 //to determine and set the page to open in the desired state - expanded or centered, any selection the user makes will
166 //become the user-specific default for that page. collectAndOrganizeExpandSetting() takes a single indexed array as an
167 //argument, containing one or more elements, the name of the current file is the first element, if there are linked
168 //files they should be listed thereafter, please add _xpd suffix to the file name
169 $arr_files_php = array("dynamic_finder_xpd");
170 $current_state = collectAndOrganizeExpandSetting($arr_files_php);
171 require_once("$srcdir/expand_contract_inc.php");
174 <?php
require_once("$include_root/expand_contract_js.php");//jQuery to provide expand/contract icon toggle if page is expandable ?>
178 <body
class="body_top">
179 <div
class="<?php echo $container;?> expandable">
181 <div
class="col-sm-10">
183 <?php
echo xlt('Patient Finder') ?
> <i id
="exp_cont_icon" class="fa <?php echo attr($expand_icon_class);?> oe-superscript-small expand_contract"
184 title
="<?php echo attr($expand_title); ?>" aria
-hidden
="true"></i
> <i id
="show_hide" class="fa fa-search-plus fa-2x small" title
="<?php echo xla('Click to show advanced search'); ?>"></i
>
187 <div
class="col-sm-2">
188 <?php
if (acl_check('patients', 'demo', '', array('write','addonly'))) { ?
>
189 <button id
="create_patient_btn" onclick
="top.restoreSession();top.RTop.location = '<?php echo $web_root ?>/interface/new/new.php'"><?php
echo xlt('Create Patient'); ?
></button
>
195 <div
class="col-sm-12">
196 <div id
="dynamic"><!-- TBD
: id seems unused
, is this div required?
-->
197 <!-- Class "display" is defined in demo_table
.css
-->
198 <table border
="0" cellpadding
="0" cellspacing
="0" class="display" id
="pt_table">
200 <tr id
="advanced_search" class="hideaway" style
="display: none;">
201 <?php
echo $header0; ?
>
204 <?php
echo $header; ?
>
209 <!-- Class "dataTables_empty" is defined in jquery
.dataTables
.css
-->
210 <td
class="dataTables_empty" colspan
="<?php echo attr($colcount); ?>">...</td
>
218 <div
class="col-sm-12">
219 <!-- form used to open a
new top level window when a patient row is clicked
-->
220 <form name
='fnew' method
='post' target
='_blank' action
='../main_screen.php?auth=login&site=<?php echo attr_url($_SESSION['site_id
']); ?>'>
221 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
222 <input type
='hidden' name
='patientID' value
='0'/>
226 </div
><!--end of container div
-->
229 $
("#pt_table").removeAttr("style");
230 $
("#exp_cont_icon").click(function () {
231 $
("#pt_table").removeAttr("style");
236 $
('#show_hide').click(function () {
237 var elementTitle
= $
('#show_hide').prop('title');
238 var hideTitle
= '<?php echo xla('Click to hide advanced search
'); ?>';
239 var showTitle
= '<?php echo xla('Click to show advanced search
'); ?>';
240 $
('.hideaway').toggle();
241 $
(this
).toggleClass('fa-search-plus fa-search-minus');
242 if (elementTitle
== hideTitle
) {
243 elementTitle
= showTitle
;
244 } else if (elementTitle
== showTitle
) {
245 elementTitle
= hideTitle
;
247 $
('#show_hide').prop('title', elementTitle
);