7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../../globals.php");
14 require_once("../../../custom/code_types.inc.php");
16 use OpenEMR\Common\Csrf\CsrfUtils
;
17 use OpenEMR\Core\Header
;
19 //the maximum number of records to pull out with the search:
22 //the number of records to display before starting a second column:
25 $code_type = $_GET['type'];
30 <?php Header
::setupHeader(); ?
>
33 <body
class="body_bottom">
34 <div id
="patient_search_code">
36 <table
class="table-borderless h-100" cellspacing
='0' cellpadding
='0'>
39 <td
class="align-top">
41 <form name
="search_form" id
="search_form" method
="post" action
="search_code.php?type=<?php echo attr_url($code_type); ?>">
42 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
44 <input type
="hidden" name
="mode" value
="search" />
46 <span
class="title"><?php
echo text($code_type); ?
> <?php
echo xlt('Codes'); ?
></span
><br
/>
48 <input type
="textbox" id
="text" name
="text" size
="15" />
50 <input type
='submit' id
="submitbtn" name
="submitbtn" value
='<?php echo xla('Search
'); ?>' />
51 <!-- TODO
: Use BS4 classes here
!-->
52 <div id
="searchspinner" style
="display: inline; visibility: hidden;"><img src
="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif"></div
>
57 if (isset($_POST["mode"]) && $_POST["mode"] == "search" && $_POST["text"] == "") {
58 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
59 CsrfUtils
::csrfNotVerified();
62 echo "<div id='resultsummary bg-success'>";
63 echo "Enter search criteria above</div>";
66 if (isset($_POST["mode"]) && $_POST["mode"] == "search" && $_POST["text"] != "") {
67 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
68 CsrfUtils
::csrfNotVerified();
71 // $sql = "SELECT * FROM codes WHERE (code_text LIKE '%" . $_POST["text"] .
72 // "%' OR code LIKE '%" . $_POST["text"] . "%') AND code_type = '" .
73 // $code_types[$code_type]['id'] . "' ORDER BY code LIMIT " . ($M + 1);
75 // The above is obsolete now, fees come from the prices table:
76 $sql = "SELECT codes.*, prices.pr_price FROM codes " .
77 "LEFT OUTER JOIN patient_data ON patient_data.pid = ? " .
78 "LEFT OUTER JOIN prices ON prices.pr_id = codes.id AND " .
79 "prices.pr_selector = '' AND " .
80 "prices.pr_level = patient_data.pricelevel " .
81 "WHERE (code_text LIKE ? OR " .
85 " LIMIT " . escape_limit(($M +
1)) .
88 if ($res = sqlStatement($sql, array($pid, "%" . $_POST["text"] . "%", "%" . $_POST["text"] . "%", $code_types[$code_type]['id']))) {
89 for ($iter = 0; $row = sqlFetchArray($res); $iter++
) {
90 $result[$iter] = $row;
93 echo "<div id='resultsummary bg-success'>";
94 if (count($result) > $M) {
95 echo "Showing the first " . text($M) . " results";
96 } elseif (count($result) == 0) {
97 echo "No results found";
99 echo "Showing all " . text(count($result)) . " results";
107 <td
class='align-top'>
113 foreach ($result as $iter) {
115 echo "</td><td class='align-top'>\n";
119 echo "<div class='oneresult' style='padding: 3px 0 3px 0;'>";
120 echo "<a target='" . xla('Diagnosis') . "' href='diagnosis.php?mode=add" .
121 "&type=" . attr_url($code_type) .
122 "&code=" . attr_url($iter["code"]) .
123 "&modifier=" . attr_url($iter["modifier"]) .
124 "&units=" . attr_url($iter["units"]) .
125 // "&fee=" . attr_url($iter["fee"]) .
126 "&fee=" . attr_url($iter['pr_price']) .
127 "&text=" . attr_url($iter["code_text"]) .
128 "&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) .
129 "' onclick='top.restoreSession()'>";
130 echo ucwords("<b>" . text(strtoupper($iter["code"])) . " " . text($iter['modifier']) .
131 "</b>" . " " . text(strtolower($iter["code_text"])));
139 echo "</span><span class='alert-custom'>" . xlt('Some codes were not displayed.') . "</span>\n";
156 </div
> <!-- end large outer patient_search_code DIV
-->
161 // jQuery stuff to make the page a little easier to use
164 $
("#text").trigger("focus");
165 $
(".oneresult").on("mouseover", function() { $
(this
).toggleClass("highlight"); });
166 $
(".oneresult").on("mouseout", function() { $
(this
).toggleClass("highlight"); });
167 //$(".oneresult").click(function() { SelectPatient(this); });
168 $
("#search_form").on("submit", function() { SubmitForm(this
); });
171 // show the 'searching...' status and submit the form
172 var SubmitForm
= function(eObj
) {
173 $
("#submitbtn").attr("disabled", "true");
174 $
("#submitbtn").css("disabled", "true");
175 $
("#searchspinner").css("visibility", "visible");
176 return top
.restoreSession();