3 * Interactive code finder.
4 * For DataTables documentation see: http://legacy.datatables.net/
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @copyright Copyright (c) 2015-2017 Rod Roark <rod@sunsetsystems.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once('../../globals.php');
14 require_once($GLOBALS['srcdir'] . '/patient.inc');
15 require_once($GLOBALS['srcdir'] . '/csv_like_join.php');
16 require_once($GLOBALS['fileroot'] . '/custom/code_types.inc.php');
20 // What we are picking from: codes, fields, lists or groups
21 $what = empty($_GET['what']) ?
'codes' : $_GET['what'];
24 $codetype = empty($_GET['codetype']) ?
'' : $_GET['codetype'];
25 if (!empty($codetype)) {
26 $allowed_codes = split_csv_line($codetype);
28 // This is the html element of the target script where the selected code will be stored.
29 $target_element = empty($_GET['target_element']) ?
'' : $_GET['target_element'];
32 $source = empty($_GET['source']) ?
'D' : $_GET['source'];
35 $layout_id = empty($_GET['layout_id']) ?
'' : $_GET['layout_id'];
39 <?php
html_header_show(); ?
>
40 <title
><?php
echo xlt('Code Finder'); ?
></title
>
41 <link rel
="stylesheet" href
='<?php echo attr($css_header) ?>' type
='text/css'>
43 <style type
="text/css">
46 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-dt-1-10-13/css/jquery.dataTables.min.css" type
="text/css">
47 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-colreorder-dt-1-3-2/css/colReorder.dataTables.min.css" type
="text/css">
49 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
50 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-1-10-13/js/jquery.dataTables.min.js"></script
>
51 <script type
="text/javascript" src
="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script
>
53 <script language
="JavaScript">
57 // Keeps track of which items have been selected during this session.
60 $
(document
).ready(function() {
62 // Initializing the DataTable.
63 oTable
= $
('#my_data_table').dataTable({
65 // Next 2 lines invoke server side processing
67 "sAjaxSource": "find_code_dynamic_ajax.php",
68 // Vertical length options and their default
69 "aLengthMenu": [ 15, 25, 50, 100 ],
71 // Specify a width for the first column.
72 "aoColumns": [{"sWidth":"10%"}, null],
73 // This callback function passes some form data on each call to the ajax handler.
74 "fnServerParams": function (aoData
) {
75 aoData
.push({"name": "what", "value": "<?php echo attr($what); ?>"});
76 <?php
if ($what == 'codes') { ?
>
77 aoData
.push({"name": "codetype", "value": document
.forms
[0].form_code_type
.value
});
78 aoData
.push({"name": "inactive", "value": (document
.forms
[0].form_include_inactive
.checked ?
1 : 0)});
79 <?php
} else if ($what == 'fields') { ?
>
80 aoData
.push({"name": "source", "value": "<?php echo attr($source); ?>"});
81 <?php
} else if ($what == 'groups') { ?
>
82 aoData
.push({"name": "layout_id", "value": "<?php echo attr($layout_id); ?>"});
85 // Drawing a row, apply styling if it is previously selected.
86 "fnCreatedRow": function (nRow
, aData
, iDataIndex
) {
87 if (oChosenIDs
[nRow
.id
]) {
88 nRow
.style
.fontWeight
= 'bold';
91 // Language strings are included so we can translate them
93 "sSearch" : "<?php echo xla('Search for'); ?>:",
94 "sLengthMenu" : "<?php echo xla('Show') . ' _MENU_ ' . xla('entries'); ?>",
95 "sZeroRecords" : "<?php echo xla('No matching records found'); ?>",
96 "sInfo" : "<?php echo xla('Showing') . ' _START_ ' . xla('to{{range}}') . ' _END_ ' . xla('of') . ' _TOTAL_ ' . xla('entries'); ?>",
97 "sInfoEmpty" : "<?php echo xla('Nothing to show'); ?>",
98 "sInfoFiltered": "(<?php echo xla('filtered from') . ' _MAX_ ' . xla('total entries'); ?>)",
100 "sFirst" : "<?php echo xla('First'); ?>",
101 "sPrevious" : "<?php echo xla('Previous'); ?>",
102 "sNext" : "<?php echo xla('Next'); ?>",
103 "sLast" : "<?php echo xla('Last'); ?>"
108 // OnClick handler for the rows
109 $
('#my_data_table').on('click', 'tbody tr', function () {
110 var jobj
= JSON
.parse(this
.id
.substring(4));
112 this
.style
.fontWeight
= 'bold';
113 oChosenIDs
[this
.id
] = 1;
115 <?php
if ($what == 'codes') { ?
>
116 // this.id is of the form "CID|jsonstring".
117 var codesel
= jobj
['code'].split('|');
118 selcode(jobj
['codetype'], codesel
[0], codesel
[1], jobj
['description']);
119 <?php
} else if ($what == 'fields') { ?
>
121 <?php
} else if ($what == 'lists') { ?
>
123 <?php
} else if ($what == 'groups') { ?
>
129 <?php
if ($what == 'codes') { ?
>
130 // Initialize the selector of codes that can be deleted.
131 if (opener
.get_related
) {
132 var acodes
= opener
.get_related();
133 var sel
= document
.forms
[0].form_delcodes
;
134 if (acodes
.length
> 1) {
135 for (var i
= 0; i
< acodes
.length
; ++i
) {
136 sel
.options
[sel
.options
.length
] = new Option(acodes
[i
], acodes
[i
]);
140 sel
.style
.display
= 'none';
147 <?php
if ($what == 'codes') { ?
>
149 // Pass info back to the opener and close this window. Specific to billing/product codes.
150 function selcode(codetype
, code
, selector
, codedesc
) {
151 if (opener
.closed ||
! opener
.set_related
) {
152 alert('<?php echo xls('The destination form was closed
; I cannot act on your selection
.'); ?>');
155 var msg
= opener
.set_related(codetype
, code
, selector
, codedesc
);
161 // Function to call the opener to delete all or one related code. Specific to billing/product codes.
163 if (opener
.closed ||
! opener
.del_related
) {
164 alert('<?php echo xls('The destination form was closed
; I cannot act on your selection
.'); ?>');
167 var sel
= document
.forms
[0].form_delcodes
;
168 opener
.del_related(sel
.value
);
176 <?php
} else if ($what == 'fields') { ?
>
178 function selectField(jobj
) {
179 if (opener
.closed ||
! opener
.SetField
) {
180 alert('The destination form was closed; I cannot act on your selection.');
183 opener
.SetField(jobj
['field_id'], jobj
['title'], jobj
['data_type'], jobj
['uor'], jobj
['fld_length'],
184 jobj
['max_length'], jobj
['list_id'], jobj
['titlecols'], jobj
['datacols'], jobj
['edit_options'],
185 jobj
['description'], jobj
['fld_rows']);
190 function newField() {
192 "field_id" : document
.forms
[0].new_field_id
.value
,
207 <?php
} else if ($what == 'lists') { ?
>
209 function SelectList(jobj
) {
210 if (opener
.closed ||
! opener
.SetList
)
211 alert('The destination form was closed; I cannot act on your selection.');
213 opener
.SetList(jobj
['code']);
218 <?php
} else if ($what == 'groups') { ?
>
220 var SelectItem
= function(jobj
) {
222 alert('The destination form was closed; I cannot act on your selection.');
224 opener
.MoveFields(jobj
['code']);
235 <body
class="body_top">
238 $string_target_element = empty($target_element) ?
'?' : "?target_element=" . rawurlencode($target_element) . "&";
241 <form method
='post' name
='theform'>
245 if ($what == 'codes') {
246 if (isset($allowed_codes)) {
247 if (count($allowed_codes) == 1) {
248 echo "<input type='text' name='form_code_type' value='" . attr($codetype) . "' size='5' readonly>\n";
250 echo "<select name='form_code_type' onchange='oTable.fnDraw()'>\n";
251 foreach ($allowed_codes as $code) {
252 echo " <option value='" . attr($code) . "'>" . xlt($code_types[$code]['label']) . "</option>\n";
257 echo "<select name='form_code_type' onchange='oTable.fnDraw()'>\n";
258 foreach ($code_types as $key => $value) {
259 echo " <option value='" . attr($key) . "'";
260 echo ">" . xlt($value['label']) . "</option>\n";
262 echo " <option value='PROD'";
263 echo ">" . xlt("Product") . "</option>\n";
266 echo " \n";
267 echo "<input type='checkbox' name='form_include_inactive' value='1' onclick='oTable.fnDraw()' />" .
268 xlt('Include Inactive') . "\n";
269 echo " \n";
270 echo "<input type='button' value='" . xla('Delete') . "' onclick='delcode()' />\n";
271 echo "<select name='form_delcodes'>\n";
272 echo " <option value=''>" . xlt('All') . "</option>\n";
274 echo " \n";
275 echo "<input type='button' value='" . xla('Close') . "' onclick='window.close()' />\n";
277 if ($what == 'lists') {
278 echo "<input type='button' value='" . xla('Delete') . "' onclick='SelectList({\"code\":\"\"})' />\n";
283 <!-- Class "display" is defined in demo_table
.css
-->
284 <table cellpadding
="0" cellspacing
="0" border
="0" class="display" id
="my_data_table">
287 <th
><?php
echo xlt('Code'); ?
></th
>
288 <th
><?php
echo xlt('Description'); ?
></th
>
293 <!-- Class "dataTables_empty" is defined in jquery
.dataTables
.css
-->
294 <td colspan
="2" class="dataTables_empty">...</td
>
299 <?php
if ($what == 'fields' && $source == 'E') { ?
>
302 <input type
='text' name
='new_field_id' size
='20' /> 
;
303 <input type
='button' value
='<?php echo xla('Or create this
new field ID
') ?>' onclick
='newField()' />