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('Drug Finder'); ?
></title
>
29 <?php Header
::setupHeader(); ?
>
32 td
{ font
-size
:10pt
; }
36 //pass value selected to the parent window
37 function window_submit(chk
)
41 if (len
==undefined
&& chk
.checked
==1)
50 for (pr
= 0; pr
< chk
.length
; pr++
)
52 if(chk
[pr
].checked
== 1)
57 str
= str+
"#"+chk
[pr
].value
;
62 alert(<?php
echo xlj("Select Drug");?
>);
63 if (opener
.closed ||
! opener
.set_related
)
64 alert(<?php
echo xlj('The destination form was closed')?
>);
66 opener
.set_related(str
,"drugs");
72 function window_close(chk
)
77 function chkbox_select_none(chk
)
80 if (len
==undefined
) {chk
.checked
=false;}
83 for (pr
= 0; pr
< chk
.length
; pr++
)
85 chk
[pr
].checked
=false;
90 function chkbox_select_all(chk
)
93 if (len
==undefined
) {chk
.checked
=true;}
96 for (pr
= 0; pr
< chk
.length
; pr++
)
103 function check_search_str()
105 var search_str
= document
.getElementById('search_term').value
;
106 if(search_str
.length
< 3)
108 alert(<?php
echo xlj("Search string should have at least three characters");?
>);
111 top
.restoreSession();
117 <body
class="body_top">
118 <form method
='post' name
='theform' action
='find_drug_popup.php' onsubmit
="return check_search_str();">
119 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
121 <input type
="hidden" name
="search_status" id
="search_status" value
=1;>
122 <table border
='0' cellpadding
='5' cellspacing
='0'>
130 <?php
echo xlt('Search for'); ?
>
131 <input type
='text' name
='search_term' id
='search_term' size
='12' value
='<?php echo attr($_REQUEST['search_term
']); ?>'
132 title
='<?php echo xla('Any part of the drug id
or drug name
'); ?>' />
134 <input type
='submit' name
='bn_search' id
='bn_search' value
='<?php echo xla('Search
'); ?>' />
145 <form method
='post' name
='select_drug'>
149 <?php
if ($_REQUEST['bn_search']) {
150 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
151 CsrfUtils
::csrfNotVerified();
154 $search_term = $_REQUEST['search_term'];
156 $query = "SELECT count(*) as count FROM drugs " .
157 "WHERE (drug_id LIKE ? OR " .
159 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
160 if ($row = sqlFetchArray($res)) {
161 $no_of_items = $row['count'];
162 if ($no_of_items < 1) {
165 alert(<?php
echo xlj('Search string does not match with list in database'); ?
> +
'\n' +
<?php
echo xlj('Please enter new search string'); ?
>);
166 document
.theform
.search_term
.value
=" ";
167 document
.theform
.search_term
.focus();
172 $query = "SELECT drug_id, name FROM drugs " .
173 "WHERE (drug_id LIKE ? OR " .
176 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
178 while ($row = sqlFetchArray($res)) {
179 $row_count = $row_count +
1;
180 $itercode = $row['drug_id'];
181 $itertext = ucfirst(strtolower(trim($row['name'])));
183 <input type
="checkbox" id
="chkbox" name
="chkbox" value
= "<?php echo attr($itercode) . "-" . attr($itertext); ?>" > <?php
echo text($itercode) . " " . text($itertext) . "<br />";
193 <input type
='button' name
='select_all' value
='<?php echo xla('Select All
'); ?>' onclick
="chkbox_select_all(document.select_drug.chkbox);"/>
195 <input type
='button' name
='unselect_all' value
='<?php echo xla('Unselect All
'); ?>' onclick
="chkbox_select_none(document.select_drug.chkbox);"/>
197 <input type
='button' name
='submit' value
='<?php echo xla('Submit
'); ?>' onclick
="window_submit(document.select_drug.chkbox);"/>
199 <input type
='button' name
='cancel' value
='<?php echo xla('Cancel
'); ?>' onclick
="window_close();"/>