2 // Copyright (C) 2008 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 $fake_register_globals=false;
10 $sanitize_all_escapes=true;
12 require_once("../../globals.php");
13 require_once("$srcdir/patient.inc");
14 require_once("$srcdir/csv_like_join.php");
15 require_once("../../../custom/code_types.inc.php");
18 $codetype = $_REQUEST['codetype'];
19 if (isset($codetype)) {
20 $allowed_codes = split_csv_line($codetype);
23 $form_code_type = $_POST['form_code_type'];
27 <?php
html_header_show(); ?
>
28 <title
><?php
echo xlt('Code Finder'); ?
></title
>
29 <link rel
="stylesheet" href
='<?php echo attr($css_header) ?>' type
='text/css'>
32 td
{ font
-size
:10pt
; }
35 <script language
="JavaScript">
37 function selcode(codetype
, code
, selector
, codedesc
) {
38 if (opener
.closed ||
! opener
.set_related
)
39 alert('<?php echo addslashes( xl('The destination form was closed
; I cannot act on your selection
.') ); ?>');
41 opener
.set_related(codetype
, code
, selector
, codedesc
);
50 <body
class="body_top">
52 <?php
if (isset($allowed_codes)) { ?
>
53 <form method
='post' name
='theform' action
='find_code_popup.php?codetype=<?php echo attr($codetype) ?>'>
55 <form method
='post' name
='theform' action
='find_code_popup.php'>
60 <table border
='0' cellpadding
='5' cellspacing
='0'>
67 <tr bgcolor
='#ddddff'>
72 if (isset($allowed_codes)) {
73 if (count($allowed_codes) === 1) {
74 echo "<input type='text' name='form_code_type' value='" . attr($codetype) . "' size='5' readonly>\n";
77 <select name
='form_code_type'>
79 foreach ($allowed_codes as $code) {
80 $selected_attr = ($form_code_type == $code) ?
" selected='selected'" : '';
82 <option value
='<?php echo attr($code) ?>'<?php
echo $selected_attr?
>><?php
echo xlt($code_types[$code]['label']) ?
></option
>
91 echo " <select name='form_code_type'";
93 foreach ($code_types as $key => $value) {
94 echo " <option value='" . attr($key) . "'";
95 if ($codetype == $key ||
$form_code_type == $key) echo " selected";
96 echo ">" . xlt($value['label']) . "</option>\n";
98 echo " <option value='PROD'";
99 if ($codetype == 'PROD' ||
$form_code_type == 'PROD') echo " selected";
100 echo ">" . xlt("Product") . "</option>\n";
101 echo " </select> \n";
105 <?php
echo xlt('Search for:'); ?
>
106 <input type
='text' name
='search_term' size
='12' value
='<?php echo attr($_REQUEST['search_term
']); ?>'
107 title
='<?php echo xla('Any part of the desired code
or its description
'); ?>' />
109 <input type
='submit' name
='bn_search' value
='<?php echo xla('Search
'); ?>' />
111 <input type
='button' value
='<?php echo xla('Erase
'); ?>' onclick
="selcode('', '', '', '')" />
123 <?php
if ($_REQUEST['bn_search']) { ?
>
127 <td
><b
><?php
echo xlt('Code'); ?
></b
></td
>
128 <td
><b
><?php
echo xlt('Description'); ?
></b
></td
>
131 $search_term = $_REQUEST['search_term'];
132 $res = code_set_search($form_code_type,$search_term);
133 if ($form_code_type == 'PROD') { // Special case that displays search for products/drugs
134 while ($row = sqlFetchArray($res)) {
135 $drug_id = addslashes($row['drug_id']);
136 $selector = addslashes($row['selector']);
137 $desc = addslashes($row['name']);
138 $anchor = "<a href='' " .
139 "onclick='return selcode(\"PROD\", \"$drug_id\", \"$selector\", \"$desc\")'>";
141 echo " <td>$anchor" . text($drug_id.":".$selector) . "</a></td>\n";
142 echo " <td>$anchor" . text($desc) . "</a></td>\n";
147 while ($row = sqlFetchArray($res)) { // Display normal search
148 $itercode = addslashes($row['code']);
149 $itertext = addslashes(trim($row['code_text']));
150 $anchor = "<a href='' " .
151 "onclick='return selcode(\"" . addslashes($form_code_type) . "\", \"$itercode\", \"\", \"$itertext\")'>";
153 echo " <td>$anchor" . text($itercode) . "</a></td>\n";
154 echo " <td>$anchor" . text($itertext) . "</a></td>\n";