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 * @copyright Copyright (c) 2012-2016 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../../globals.php");
18 require_once "$srcdir/user.inc";
19 require_once "$srcdir/options.inc.php";
20 use OpenEMR\Core\Header
;
22 $uspfx = 'patient_finder.'; //substr(__FILE__, strlen($webserver_root)) . '.';
23 $patient_finder_exact_search = prevSetting($uspfx, 'patient_finder_exact_search', 'patient_finder_exact_search', ' ');
25 $popup = empty($_REQUEST['popup']) ?
0 : 1;
27 // Generate some code based on the list of columns.
33 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
34 "list_id = 'ptlistcols' AND activity = 1 ORDER BY seq, title");
35 while ($row = sqlFetchArray($res)) {
36 $colname = $row['option_id'];
37 $title = xl_list_label($row['title']);
38 $title1 = ($title == xl('Full Name'))?
xl('Name'): $title;
40 $header .= text($title);
42 $header0 .= " <td ><input type='text' size='20' ";
43 $header0 .= "value='' class='search_init' placeholder='".xla("Search by"). " " . $title1 ."'/></td>\n";
47 $coljson .= "{\"sName\": \"" . addcslashes($colname, "\t\r\n\"\\") . "\"}";
53 <?php Header
::setupHeader();?
>
54 <title
><?php
echo xlt("Patient Finder"); ?
></title
>
55 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-dt/css/jquery.dataTables.css" type
="text/css">
56 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-colreorder-dt/css/colReorder.dataTables.css" type
="text/css">
57 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net/js/jquery.dataTables.js"></script
>
58 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-colreorder/js/dataTables.colReorder.js"></script
>
60 <script language
="JavaScript">
62 var uspfx
= '<?php echo attr($uspfx); ?>';
64 $
(document
).ready(function () {
66 // Initializing the DataTable.
68 var oTable
= $
('#pt_table').dataTable({
70 // next 2 lines invoke server side processing
72 // NOTE kept the legacy command 'sAjaxSource' here for now since was unable to get
73 // the new 'ajax' command to work.
74 "sAjaxSource": "dynamic_finder_ajax.php?csrf_token_form=" +
<?php
echo js_escape(urlencode(collectCsrfToken())); ?
>,
75 "fnServerParams": function (aoData
) {
76 var searchType
= $
("#setting_search_type:checked").length
> 0;
77 aoData
.push({"name": "searchType", "value": searchType
});
79 // dom invokes ColReorderWithResize and allows inclusion of a custom div
80 "dom": 'Rlfrt<"mytopdiv">ip',
81 // These column names come over as $_GET['sColumns'], a comma-separated list of the names.
82 // See: http://datatables.net/usage/columns and
83 // http://datatables.net/release-datatables/extras/ColReorder/server_side.html
84 "columns": [ <?php
echo $coljson; ?
> ],
85 "lengthMenu": [10, 25, 50, 100],
86 "pageLength": <?php
echo empty($GLOBALS['gbl_pt_list_page_size']) ?
'10' : $GLOBALS['gbl_pt_list_page_size']; ?
>,
87 <?php
// Bring in the translations ?>
88 <?php
$translationsDatatablesOverride = array('search' => (xla('Search all columns') . ':')); ?
>
89 <?php
require($GLOBALS['srcdir'] . '/js/xl/datatables-net.js.php'); ?
>
93 $
("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
94 if (!empty($GLOBALS['gbl_pt_list_new_window'])) {
97 ?> /><?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>");
99 // This is to support column-specific search fields.
100 // Borrowed from the multi_filter.html example.
101 $
("thead input").keyup(function () {
102 // Filter on the column (the index) of this element
103 oTable
.fnFilter(this
.value
, $
("thead input").index(this
));
105 // OnClick handler for the rows
106 $
('#pt_table').on('click', 'tbody tr', function () {
107 // ID of a row element is pid_{value}
108 var newpid
= this
.id
.substring(4);
109 // If the pid is invalid, then don't attempt to set
110 // The row display for "No matching records found" has no valid ID, but is
111 // otherwise clickable. (Matches this CSS selector). This prevents an invalid
112 // state for the PID to be set.
113 if (newpid
.length
=== 0) {
116 if (document
.myform
.form_new_window
.checked
) {
117 openNewTopWindow(newpid
);
120 top
.restoreSession();
121 top
.RTop
.location
= "../../patient_file/summary/demographics.php?set_pid=" +
encodeURIComponent(newpid
);
126 function openNewTopWindow(pid
) {
127 document
.fnew
.patientID
.value
= pid
;
128 top
.restoreSession();
129 document
.fnew
.submit();
132 function persistCriteria(el
, e
){
134 let target
= uspfx +
"patient_finder_exact_search";
135 let val
= el
.checked ?
' checked' : ' ';
136 $
.post( "../../../library/ajax/user_settings.php",
140 csrf_token_form
: "<?php echo attr(collectCsrfToken()); ?>"
147 //to determine and set the page to open in the desired state - expanded or centered, any selection the user makes will
148 //become the user-specific default for that page. collectAndOrganizeExpandSetting() takes a single indexed array as an
149 //argument, containing one or more elements, the name of the current file is the first element, if there are linked
150 //files they should be listed thereafter, please add _xpd suffix to the file name
151 $arr_files_php = array("dynamic_finder_xpd");
152 $current_state = collectAndOrganizeExpandSetting($arr_files_php);
153 require_once("$srcdir/expand_contract_inc.php");
156 <?php
require_once("$include_root/expand_contract_js.php");//jQuery to provide expand/contract icon toggle if page is expandable ?>
160 <body
class="body_top">
161 <div
class="<?php echo $container;?> expandable">
163 <div
class="col-sm-12">
165 <?php
echo xlt('Patient Finder') ?
> <i id
="exp_cont_icon" class="fa <?php echo attr($expand_icon_class);?> oe-superscript-small expand_contract"
166 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
>
172 <div
class="col-sm-12">
173 <div id
="dynamic"><!-- TBD
: id seems unused
, is this div required?
-->
174 <!-- Class "display" is defined in demo_table
.css
-->
175 <table border
="0" cellpadding
="0" cellspacing
="0" class="display" id
="pt_table">
177 <tr id
="advanced_search" class="hideaway" style
="display: none;">
178 <?php
echo $header0; ?
>
181 <?php
echo $header; ?
>
186 <!-- Class "dataTables_empty" is defined in jquery
.dataTables
.css
-->
187 <td
class="dataTables_empty" colspan
="<?php echo attr($colcount); ?>">...</td
>
195 <div
class="col-sm-12">
196 <!-- form used to open a
new top level window when a patient row is clicked
-->
197 <form name
='fnew' method
='post' target
='_blank' action
='../main_screen.php?auth=login&site=<?php echo attr_url($_SESSION['site_id
']); ?>'>
198 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
199 <input type
='hidden' name
='patientID' value
='0'/>
203 </div
><!--end of container div
-->
205 $
(document
).ready(function(){
206 $
("#pt_table").removeAttr("style");
207 $
("#exp_cont_icon").click(function(){
208 $
("#pt_table").removeAttr("style");
213 $
('#show_hide').click(function () {
214 var elementTitle
= $
('#show_hide').prop('title');
215 var hideTitle
= '<?php echo xla('Click to hide advanced search
'); ?>';
216 var showTitle
= '<?php echo xla('Click to show advanced search
'); ?>';
217 $
('.hideaway').toggle();
218 $
(this
).toggleClass('fa-search-plus fa-search-minus');
219 if (elementTitle
== hideTitle
) {
220 elementTitle
= showTitle
;
221 } else if (elementTitle
== showTitle
) {
222 elementTitle
= hideTitle
;
224 $
('#show_hide').prop('title', elementTitle
);