Support for ICD10, SNOMED, DSMIV code types.
[openemr.git] / interface / patient_file / encounter / find_code_popup.php
blob4af8ef3df89dab6c31983b0b4f9210bade1fea72
1 <?php
2 // Copyright (C) 2008 Rod Roark <rod@sunsetsystems.com>
3 //
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");
17 $info_msg = "";
18 $codetype = $_REQUEST['codetype'];
19 if (isset($codetype)) {
20 $allowed_codes = split_csv_line($codetype);
23 $form_code_type = $_POST['form_code_type'];
25 <html>
26 <head>
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'>
31 <style>
32 td { font-size:10pt; }
33 </style>
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.') ); ?>');
40 else
41 opener.set_related(codetype, code, selector, codedesc);
42 window.close();
43 return false;
46 </script>
48 </head>
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) ?>'>
54 <?php } else { ?>
55 <form method='post' name='theform' action='find_code_popup.php'>
56 <?php } ?>
58 <center>
60 <table border='0' cellpadding='5' cellspacing='0'>
62 <tr>
63 <td height="1">
64 </td>
65 </tr>
67 <tr bgcolor='#ddddff'>
68 <td>
69 <b>
71 <?php
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";
75 } else {
77 <select name='form_code_type'>
78 <?php
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>
83 <?php
86 </select>
87 <?php
90 else {
91 echo " <select name='form_code_type'";
92 echo ">\n";
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>&nbsp;&nbsp;\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'); ?>' />
108 &nbsp;
109 <input type='submit' name='bn_search' value='<?php echo xla('Search'); ?>' />
110 &nbsp;&nbsp;&nbsp;
111 <input type='button' value='<?php echo xla('Erase'); ?>' onclick="selcode('', '', '', '')" />
112 </b>
113 </td>
114 </tr>
116 <tr>
117 <td height="1">
118 </td>
119 </tr>
121 </table>
123 <?php if ($_REQUEST['bn_search']) { ?>
125 <table border='0'>
126 <tr>
127 <td><b><?php echo xlt('Code'); ?></b></td>
128 <td><b><?php echo xlt('Description'); ?></b></td>
129 </tr>
130 <?php
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\")'>";
140 echo " <tr>";
141 echo " <td>$anchor" . text($drug_id.":".$selector) . "</a></td>\n";
142 echo " <td>$anchor" . text($desc) . "</a></td>\n";
143 echo " </tr>";
146 else {
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\")'>";
152 echo " <tr>";
153 echo " <td>$anchor" . text($itercode) . "</a></td>\n";
154 echo " <td>$anchor" . text($itertext) . "</a></td>\n";
155 echo " </tr>";
159 </table>
161 <?php } ?>
163 </center>
164 </form>
165 </body>
166 </html>