7 * @link http://www.open-emr.org
8 * @author Visolve <vicareplus_engg@visolve.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2010 ViCarePlus, Visolve <vicareplus_engg@visolve.com>
11 * @copyright Copyright (c) 2018-2019 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc.php");
17 require_once("../../custom/code_types.inc.php");
19 use OpenEMR\Common\Csrf\CsrfUtils
;
20 use OpenEMR\Core\Header
;
23 $codetype = $_REQUEST['codetype'];
24 $form_code_type = $_POST['form_code_type'];
28 <title
><?php
echo xlt('Code Finder'); ?
></title
>
30 <?php Header
::setupHeader(); ?
>
39 //pass value selected to the parent window
40 function window_submit(chk
)
44 if (len
==undefined
&& chk
.checked
==1)
53 for (pr
= 0; pr
< chk
.length
; pr++
)
55 if(chk
[pr
].checked
== 1)
60 str
= str+
"#"+chk
[pr
].value
;
65 alert(<?php
echo xlj("Select Diagnosis"); ?
>);
66 if (opener
.closed ||
! opener
.set_related
)
67 alert(<?php
echo xlj('The destination form was closed'); ?
>);
69 opener
.set_related(str
,"diagnosis");
75 function window_close(chk
)
80 function chkbox_select_none(chk
)
83 if (len
==undefined
) {chk
.checked
=false;}
86 for (pr
= 0; pr
< chk
.length
; pr++
)
88 chk
[pr
].checked
=false;
93 function chkbox_select_all(chk
)
96 if (len
==undefined
) {chk
.checked
=true;}
99 for (pr
= 0; pr
< chk
.length
; pr++
)
101 chk
[pr
].checked
=true;
106 function check_search_str()
108 var search_str
= document
.getElementById('search_term').value
;
109 if(search_str
.length
< 3)
111 alert(<?php
echo xlj("Search string should have at least three characters");?
>);
114 top
.restoreSession();
120 <body
class="body_top">
121 <form method
='post' name
='theform' action
='find_code_popup.php' onsubmit
="return check_search_str();">
122 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
124 <input type
="hidden" name
="search_status" id
="search_status" value
=1;>
125 <table
class="border-0" cellpadding
='5' cellspacing
='0'>
135 echo "<input type='text' name='form_code_type' value='" . attr($codetype) . "' size='5' readonly>\n";
137 echo " <select name='form_code_type'";
139 foreach ($code_types as $key => $value) {
140 echo " <option value='" . attr($key) . "'";
141 if ($codetype == $key ||
$form_code_type == $key) {
145 echo ">" . text($key) . "</option>\n";
148 echo " <option value='PROD'";
149 if ($codetype == 'PROD' ||
$form_code_type == 'PROD') {
153 echo ">Product</option>\n";
154 echo " </select> \n";
157 <?php
echo xlt('Search for'); ?
>
158 <input type
='text' name
='search_term' id
='search_term' size
='12' value
='<?php echo attr($_REQUEST['search_term
']); ?>'
159 title
='<?php xla('Any part of the desired code
or its description
'); ?>' />
161 <input type
='submit' name
='bn_search' id
='bn_search' value
='<?php echo xla('Search
'); ?>' />
172 <form method
='post' name
='select_diagonsis'>
173 <table
class='border-0'>
176 <?php
if ($_REQUEST['bn_search']) {
177 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
178 CsrfUtils
::csrfNotVerified();
181 $search_term = $_REQUEST['search_term'];
182 if ($form_code_type == 'PROD') {
183 $query = "SELECT dt.drug_id, dt.selector, d.name " .
184 "FROM drug_templates AS dt, drugs AS d WHERE " .
185 "( d.name LIKE ? OR " .
186 "dt.selector LIKE ? ) " .
187 "AND d.drug_id = dt.drug_id " .
188 "ORDER BY d.name, dt.selector, dt.drug_id";
189 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
191 while ($row = sqlFetchArray($res)) {
192 $row_count = $row_count +
1;
193 $drug_id = $row['drug_id'];
194 $selector = $row['selector'];
195 $desc = $row['name'];
197 <input type
="checkbox" name
="diagnosis[row_count]" value
="<?php echo attr($desc); ?>" > <?php
echo text($drug_id) . " " . text($selector) . " " . text($desc) . "<br />";
200 $query = "SELECT count(*) as count FROM codes " .
201 "WHERE (code_text LIKE ? OR " .
203 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
204 if ($row = sqlFetchArray($res)) {
205 $no_of_items = $row['count'];
206 if ($no_of_items < 1) {
209 alert(<?php
echo xlj('Search string does not match with list in database'); ?
> +
'\n' +
<?php
echo xlj('Please enter new search string');?
>);
210 document
.theform
.search_term
.value
=" ";
211 document
.theform
.search_term
.focus();
216 $query = "SELECT code_type, code, modifier, code_text FROM codes " .
217 "WHERE (code_text LIKE ? OR " .
220 // echo "\n<!-- $query -->\n"; // debugging
221 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
223 while ($row = sqlFetchArray($res)) {
224 $row_count = $row_count +
1;
225 $itercode = $row['code'];
226 $itertext = ucfirst(strtolower(trim($row['code_text'])));
228 <input type
="checkbox" id
="chkbox" value
= "<?php echo attr($form_code_type) . ":" . attr($itercode) . "-" . attr($itertext); ?>" > <?php
echo text($itercode) . " " . text($itertext) . "<br />";
238 <div
class="btn-group">
239 <input type
='button' class="btn btn-primary" id
='select_all' value
='<?php echo xla('Select All
'); ?>' onclick
="chkbox_select_all(document.select_diagonsis.chkbox);"/>
241 <input type
='button' class="btn btn-primary" id
='unselect_all' value
='<?php echo xla('Unselect All
'); ?>' onclick
="chkbox_select_none(document.select_diagonsis.chkbox);"/>
243 <input type
='button' class="btn btn-primary" id
='submit' value
='<?php echo xla('Submit
'); ?>' onclick
="window_submit(document.select_diagonsis.chkbox);"/>
245 <input type
='button' class="btn btn-primary" id
='cancel' value
='<?php echo xla('Cancel
'); ?>' onclick
="window_close();"/>