PageRenderTime 57ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/drg/drg-icd10-search.php

https://github.com/timschofield/2.8
PHP | 496 lines | 398 code | 48 blank | 50 comment | 54 complexity | b704c297f8d7b9e0c1debb0d21814ad9 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-2.0
  1. <?php
  2. error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
  3. require('./roots.php');
  4. require('../../include/helpers/inc_environment_global.php');
  5. /**
  6. * CARE2X Integrated Hospital Information System Deployment 2.1 - 2004-10-02
  7. * GNU General Public License
  8. * Copyright 2002,2003,2004,2005 Elpidio Latorilla
  9. * elpidio@care2x.org,
  10. *
  11. * See the file "copy_notice.txt" for the licence notice
  12. */
  13. define('MODULE','drg');
  14. define('LANG_FILE_MODULAR','drg.php');
  15. require_once('drg_inc_local_user.php');
  16. require_once($root_path.'include/helpers/inc_front_chain_lang.php');
  17. //if (!isset($opnr) || !$opnr) {header("Location:".$root_path."language/".$lang."/lang_".$lang."_invalid-access-warning.php"); exit;};
  18. # Create drg object
  19. require_once($root_path.'modules/drg/model/class_drg.php');
  20. $drg=& new DRG;
  21. ///$db->debug=true;
  22. if($saveok){
  23. ?>
  24. <script language="javascript" >
  25. window.opener.location.replace('drg-icd10.php?sid=<?php echo "$sid&lang=$lang&pn=$pn&opnr=$opnr&edit=$edit&ln=$ln&fn=$fn&bd=$bd&group_nr=$group_nr&dept_nr=$dept_nr&oprm=$oprm&y=$y&m=$m&d=$d&display=composite&newsave=1"; ?>');
  26. //window.opener.parent.ICD.location.reload();
  27. window.close();
  28. </script>
  29. <?php
  30. exit;
  31. }
  32. $toggle=0;
  33. $thisfile='drg-icd10-search.php';
  34. if($mode=='save'){
  35. /* Initialiase control elements */
  36. $target='icd10';
  37. $element='icd_code';
  38. $save_related=1;
  39. $element_related='related_icd';
  40. $itemselector='sel';
  41. $hidselector='icd_px';
  42. include('includes/inc_drg_entry_save.php');
  43. }else{
  44. $keyword=trim($keyword);
  45. if(!empty($keyword)){
  46. $fielddata='diagnosis_code,description,sub_level,inclusive,exclusive,notes,remarks,extra_subclass,extra_codes,std_code';
  47. # Search routine starts here
  48. if(strlen($keyword)<3){
  49. # Added the special case of Bosnian (or Serbian) version with the latin description in the "description" field
  50. #and the actual local language version in the "note" field
  51. if($lang=="bs" || $lang == "sr") $sAddWhere= "OR notes $sql_LIKE '$keyword%'";
  52. else $sAddWhere ='';
  53. $sql="SELECT $fielddata FROM $drg->tb_diag_codes WHERE (diagnosis_code $sql_LIKE '%$keyword%' OR description $sql_LIKE '$keyword%' $sAddWhere) AND type <> 'table'";
  54. }else{
  55. # Added the special case of Bosnian (or Serbian) version with the latin description in the "description" field
  56. #and the actual local language version in the "note" field
  57. if($lang=="bs" || $lang == "sr") $sAddWhere= "OR notes $sql_LIKE '%$keyword%'";
  58. else $sAddWhere ='';
  59. $sql="SELECT $fielddata FROM $drg->tb_diag_codes WHERE (diagnosis_code $sql_LIKE '%$keyword%' OR description $sql_LIKE '%$keyword%' $sAddWhere) AND type <> 'table'";
  60. }
  61. //echo $sql;
  62. $ergebnis=$db->SelectLimit($sql,50);
  63. if($ergebnis){
  64. $linecount=0;
  65. if ($linecount=$ergebnis->RecordCount()){
  66. if(strlen($keyword)<3){
  67. $advsql="SELECT sub_level FROM $drg->tb_diag_codes WHERE (diagnosis_code $sql_LIKE '%$keyword%' OR description $sql_LIKE '$keyword%') AND type <> 'table'";
  68. }else{
  69. $advsql="SELECT sub_level FROM $drg->tb_diag_codes WHERE (diagnosis_code $sql_LIKE '%$keyword%' OR description $sql_LIKE '%$keyword%') AND type <> 'table'";
  70. }
  71. $adv=$db->SelectLimit($advsql,50);
  72. }
  73. }else {echo "<p>".$sql."<p>$LDDbNoRead"; };
  74. }
  75. }
  76. /* Load the icon images */
  77. $img['delete']=createComIcon($root_path,'delete2.gif','0','right',TRUE);
  78. $img['arrow']=createComIcon($root_path,'l_arrowgrnsm.gif','0','absmiddle',TRUE);
  79. $img['warn']=createComIcon($root_path,'warn.gif','0','absmiddle',TRUE);
  80. $img['info']=createComIcon($root_path,'button_info.gif','0','absmiddle',TRUE);
  81. $img['bubble']=createComIcon($root_path,'bubble2.gif','0','absmiddle',TRUE);
  82. $img['blue']=createComIcon($root_path,'l2-blue.gif','0','',TRUE);
  83. $img['t2']=createComIcon($root_path,'t2-blue.gif','0','',TRUE);
  84. $img['plus']=createComIcon($root_path,'plus2.gif','0','absmiddle',TRUE);
  85. $img['reset']=createComIcon($root_path,'button_reset.gif','0','absmiddle',TRUE);
  86. ?>
  87. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
  88. <html>
  89. <HEAD>
  90. <TITLE><?php echo $LDIcd10Search ?></TITLE>
  91. <script language="javascript" src="<?php echo $root_path; ?>js/showhide-div.js">
  92. </script>
  93. <script language="javascript">
  94. <!--
  95. function pruf(d)
  96. {
  97. if((d.keyword.value=="")||(d.keyword.value==" ")) return false;
  98. }
  99. function gethelp(x,s,x1,x2,x3)
  100. {
  101. if (!x) x="";
  102. urlholder="help-router.php?lang=<?php echo $lang ?>&helpidx="+x+"&src="+s+"&x1="+x1+"&x2="+x2+"&x3="+x3;
  103. helpwin=window.open(urlholder,"helpwin","width=790,height=540,menubar=no,resizable=yes,scrollbars=yes");
  104. window.helpwin.moveTo(0,0);
  105. }
  106. function subsearch(k)
  107. {
  108. //window.location.href='drg-icd10-search.php?sid=<?php echo "sid=$sid&lang=$lang&pn=$pn&opnr=$opnr&edit=$edit&ln=$ln&fn=$fn&bd=$bd&dept_nr=$dept_nr&oprm=$oprm&display=$display" ?>&keyword='+k;
  109. document.searchdata.keyword.value=k;
  110. document.searchdata.submit();
  111. }
  112. function checkselect(d)
  113. {
  114. var ret=false;
  115. var x=d.lastindex.value;
  116. for(i=0;i<x;i++)
  117. if(eval("d.sel"+i+".checked"))
  118. {
  119. ret=true;
  120. break;
  121. }
  122. return ret;
  123. }
  124. // -->
  125. </script>
  126. <?php
  127. require($root_path.'include/helpers/include_header_css_js.php');
  128. ?>
  129. </HEAD>
  130. <BODY onLoad="if(window.focus) window.focus();
  131. <?php if(!$showonly) : ?> document.searchdata.keyword.select();document.searchdata.keyword.focus();
  132. <?php endif; ?>
  133. "
  134. <?php if (!$cfg['dhtml']){ echo ' link='.$cfg['idx_txtcolor'].' alink='.$cfg['body_alink'].' vlink='.$cfg['idx_txtcolor']; } ?>>
  135. <FONT SIZE=-1 FACE="Arial">
  136. <ul>
  137. <FORM action="drg-icd10-search.php" method="post" name="searchdata" onSubmit="return pruf(this)">
  138. <a href="javascript:window.close()"><img <?php echo createLDImgSrc($root_path,'close2.gif','0') ?> align="right"></a>
  139. <?php if(!$showonly) : ?>
  140. <FONT SIZE=3 FACE="verdana,Arial" color="#0000aa"><b><?php echo $LDIcd10 ?></b>&nbsp;
  141. </font>
  142. <font size=3><INPUT type="text" name="keyword" size="50" maxlength="60" onfocus="this.select()" value="<?php echo $keyword ?>"></font>
  143. <br>
  144. <INPUT type="submit" name="versand" value="<?php echo $LDSearch ?>">
  145. <?php else : ?>
  146. <input type="hidden" name="keyword" value="">
  147. <?php endif; ?>
  148. <input type="hidden" name="sid" value="<?php echo $sid; ?>">
  149. <input type="hidden" name="lang" value="<?php echo $lang; ?>">
  150. <input type="hidden" name="pn" value="<?php echo $pn; ?>">
  151. <input type="hidden" name="opnr" value="<?php echo $opnr; ?>">
  152. <input type="hidden" name="ln" value="<?php echo $ln; ?>">
  153. <input type="hidden" name="fn" value="<?php echo $fn; ?>">
  154. <input type="hidden" name="bd" value="<?php echo $bd; ?>">
  155. <input type="hidden" name="dept_nr" value="<?php echo $dept_nr; ?>">
  156. <input type="hidden" name="group_nr" value="<?php echo $group_nr; ?>">
  157. <input type="hidden" name="edit" value="<?php echo $edit; ?>">
  158. <input type="hidden" name="oprm" value="<?php echo $oprm; ?>">
  159. <input type="hidden" name="display" value="<?php echo $display; ?>">
  160. <input type="hidden" name="showonly" value="<?php echo $showonly; ?>">
  161. <input type="hidden" name="target" value="<?php echo $target; ?>">
  162. </FORM>
  163. <p>
  164. <form name="icd10" onSubmit="return checkselect(this)">
  165. <table border=0 cellpadding=0 cellspacing=0 width='100%'>
  166. <tr bgcolor=#0000aa>
  167. <td width="20">
  168. <?php if(!$showonly) : ?>
  169. <img <?php echo $img['delete'] ?> alt="<?php echo $LDReset ?>" onClick="javascript:document.icd10.reset()">
  170. <?php endif; ?>
  171. </td>
  172. <td><font size=2 color=#ffffff>&nbsp;<b><?php echo $LDIcd10 ?></b>&nbsp;</td>
  173. <td><font size=2 color=#ffffff>&nbsp;<b><?php echo $LDSGBV ?></b>&nbsp;</td>
  174. <td colspan=7><font size=2 color=#ffffff>&nbsp;<b><?php echo $LDDescription ?></b>
  175. </td>
  176. </tr>
  177. <?php
  178. function cleandata(&$buf)
  179. {
  180. return strtr($buf,",.()*+-!","________");
  181. }
  182. function drawAdditional($tag,&$codebuf,&$databuf,$bkcolor,&$alttag)
  183. {
  184. global $LDClose, $img;
  185. //echo '&nbsp;<a href="javascript:ssm(\''.$tag.'_'.cleandata($codebuf).'\'); clearTimeout(timer)"><img src="../img/l_arrowGrnSm.gif" border=0 width=12 height=12 alt="'.$alttag.'" align="absmiddle"></a>';
  186. echo '<DIV id='.$tag.'_'.cleandata($codebuf).'
  187. style=" VISIBILITY: hidden; POSITION: absolute;">
  188. <TABLE cellSpacing=1 cellPadding=0 bgColor="#000000" border=0>
  189. <TR>
  190. <TD>
  191. <TABLE cellSpacing=1 cellPadding=7 width="100%" bgColor="#'.$bkcolor.'" border=0><TBODY>
  192. <TR>
  193. <TD bgColor="#'.$bkcolor.'">
  194. <a href="javascript:hsm()"><img '.$img['delete'].' alt="'.$LDClose.'"></a>
  195. <font size=2><b><font color="#003300">'.$alttag.':</font></b><br>'.$databuf.'
  196. </TD></TR></TABLE></TD></TR></TBODY></TABLE></div>';
  197. }
  198. function drawdata(&$data,&$advdata)
  199. {
  200. global $toggle,$parentcode,$grandcode,$priocolor,$LDInclusive,$LDExclusive,$LDNotes,$LDRemarks,$LDExtraCodes,$LDAddCodes;
  201. global $idx,$parenthref,$showonly,$parentdata,$img;
  202. echo "
  203. <tr class=";
  204. if($priocolor) echo "hilite>";
  205. elseif($toggle) { echo "wardlistrow2>"; $toggle=0;} else {echo "wardlistrow1>"; $toggle=1;};
  206. echo '<td>';
  207. if($priocolor) echo "&nbsp;"; elseif(!$showonly)
  208. {
  209. /* $valbuf="code*$data[diagnosis_code]&cat*$data[std_code]";
  210. if(stristr($data[diagnosis_code],".-")) $valbuf.="&des*$data[description]";
  211. else $valbuf.="&des*$parentdata[description]: <b>$data[description]</b>";
  212. */
  213. echo '<input type="checkbox" name="sel'.$idx.'" value="'.$data['diagnosis_code'].'">
  214. <input type="hidden" name="icd_px'.$idx.'" value="'.$parentdata['diagnosis_code'].'">';
  215. $idx++;
  216. }
  217. echo '
  218. </td>
  219. <td><font size=2><nobr>';
  220. //echo " *$parentcode +$grandcode";
  221. if($parenthref)
  222. echo '<u><a href="javascript:subsearch(\''.substr($data[diagnosis_code],0,strpos($data['diagnosis_code'],"-")-1).'\')">'.$data['diagnosis_code'].'</a></U>';
  223. else echo $data['diagnosis_code'].'&nbsp;';
  224. echo '&nbsp;</nobr>
  225. </td>
  226. <td align="center"><font size=2>'.$data['std_code'].'&nbsp;
  227. </td>';
  228. switch($data['sub_level'])
  229. {
  230. case 0:echo '
  231. <td colspan=7>';
  232. break;
  233. case 1:echo '
  234. <td colspan=7>';
  235. break;
  236. case 2: echo '
  237. <td colspan=2>&nbsp;</td>
  238. <td valign="top">';
  239. echo '<img '.$img['t2'].'>';
  240. echo '
  241. </td><td colspan=4>';
  242. break;
  243. case 3: echo '
  244. <td colspan=3>&nbsp;</td>
  245. <td valign="top">';
  246. if($advdata['sub_level']<$data['sub_level']) echo '<img '.$img['blue'].'>'; else echo '<img '.$img['t2'].'>';
  247. echo '</td>
  248. <td colspan=3>';
  249. break;
  250. case 4: echo '
  251. <td colspan=4>&nbsp;</td>
  252. <td valign="top">';
  253. if($advdata['sub_level']<$data['sub_level']) echo '<img '.$img['blue'].'>'; else echo '<img '.$img['t2'].'>';
  254. echo '</td>
  255. <td colspan=2>&nbsp;';
  256. break;
  257. case 5: echo '
  258. <td colspan=5>&nbsp;</td>
  259. <td valign="top">';
  260. if($advdata['sub_level']<$data['sub_level']) echo '<img '.$img['blue'].'>'; else echo '<img '.$img['t2'].'>';
  261. echo '</td>
  262. <td>&nbsp;';
  263. break;
  264. }
  265. //echo '<font size=2>'.trim($data[description]);
  266. echo '<font size=2>';
  267. if($parenthref) echo '<u><a href="javascript:subsearch(\''.substr($data[diagnosis_code],0,strpos($data[diagnosis_code],"-")-1).'\')">'.$data[description].'</a></U>';
  268. else echo $data['description'].'&nbsp;';
  269. if($data[inclusive])
  270. {
  271. echo '&nbsp;<a href="javascript:ssm(\'i_'.cleandata($data[diagnosis_code]).'\');"><img '.$img['arrow'].' alt="'.$LDInclusive.'"></a>';
  272. drawAdditional("i",$data[diagnosis_code],$data[inclusive],"00ffcc",$LDInclusive);
  273. }
  274. //if($data[inclusive]) echo '<br><font size=2 color="#00aa00">'.$data[inclusive].'</font>';
  275. if($data[exclusive])
  276. {
  277. echo '&nbsp;<a href="javascript:ssm(\'e_'.cleandata($data[diagnosis_code]).'\');"><img '.$img['warn'].' alt="'.$LDExclusive.'"></a>';
  278. drawAdditional("e",$data[diagnosis_code],$data[exclusive],"ffccee",$LDExclusive);
  279. }
  280. if($data[notes])
  281. {
  282. echo '&nbsp;<a href="javascript:ssm(\'n_'.cleandata($data[diagnosis_code]).'\');"><img '.$img['info'].' alt="'.$LDNotes.'"></a>';
  283. drawAdditional("n",$data[diagnosis_code],$data[notes],"ffcc99",$LDNotes);
  284. }
  285. if($data[remarks])
  286. {
  287. echo '&nbsp;<a href="javascript:ssm(\'r_'.cleandata($data[diagnosis_code]).'\');"><img '.$img['bubble'].' alt="'.$LDRemarks.'"></a>';
  288. drawAdditional("r",$data[diagnosis_code],$data[remarks],"cceeff",$LDRemarks);
  289. }
  290. if($data[extra_codes])
  291. {
  292. echo '&nbsp;<a href="javascript:ssm(\'x_'.cleandata($data[diagnosis_code]).'\');"><img '.$img['plus'].' alt="'.$LDExtraCodes.'"></a>';
  293. drawAdditional("x",$data[diagnosis_code],$data[extra_codes],"ffff66",$LDExtraCodes);
  294. }
  295. if($data[extra_subclass])
  296. {
  297. echo '&nbsp;<a href="javascript:ssm(\'s_'.cleandata($data[diagnosis_code]).'\');"><img '.$img['reset'].' alt="'.$LDAddCodes.'"></a>';
  298. drawAdditional("s",$data[diagnosis_code],$data[extra_subclass],"efefef",$LDAddCodes);
  299. }
  300. echo '</td>';
  301. $parenthref=0;
  302. }
  303. if ($linecount>0)
  304. {
  305. $idx=0;
  306. $grandpa=array();
  307. $parent=array();
  308. $advzeile=$adv->FetchRow();
  309. while($zeile=$ergebnis->FetchRow())
  310. {
  311. $advzeile=$adv->FetchRow();
  312. // process code
  313. $strbuf=trim($zeile['diagnosis_code']);
  314. if(stristr($strbuf,".-"))
  315. {
  316. $parentcode=substr($strbuf,0,strpos($strbuf,"."));
  317. $grandcode=substr($parentcode,0,2);
  318. $parent[$parentcode]=1;
  319. $parentdata=$zeile;
  320. //echo "parent";
  321. //$priocolor=1;
  322. }
  323. else
  324. {
  325. if(stristr($strbuf,"-"))
  326. {
  327. //
  328. $parentcode=substr($strbuf,0,3);
  329. $grandcode=substr($parentcode,1,2);
  330. $grandpa[$grandcode]=1;
  331. $priocolor=1;//echo "hello";
  332. $parent[$parentcode]=1;
  333. // echo "grand";
  334. //echo "$grandcode $parentcode";
  335. }
  336. else
  337. {
  338. $parentcode=substr($strbuf,0,3);
  339. $grandcode=substr($parentcode,0,2);
  340. }
  341. }
  342. //echo "#$zeile[diagnosis_code] *$parentcode +$grandcode";
  343. if(!$grandpa[$grandcode])
  344. {
  345. //echo "grand";
  346. $sql="SELECT $fielddata FROM $drg->tb_diag_codes WHERE type <> 'table' AND (diagnosis_code $sql_LIKE '%".$grandcode."0-%' OR diagnosis_code $sql_LIKE '%".$parentcode."-%') ";
  347. $result=$db->SelectLimit($sql,1);
  348. if($result)
  349. {
  350. if($granddata=$result->FetchRow())
  351. {
  352. //mysql_data_seek($result,0);
  353. $priocolor=1;
  354. drawdata($granddata,$zeile);
  355. $grandpa[$grandcode]=1;
  356. }
  357. $priocolor=0;
  358. }
  359. }
  360. if(!$parent[$parentcode])
  361. {
  362. //echo "parent";
  363. $sql="SELECT $fielddata FROM $drg->tb_diag_codes WHERE diagnosis_code $sql_LIKE '".$parentcode.".-%' AND type <> 'table'";
  364. $lines=$db->SelectLimit($sql,1);
  365. if($lines)
  366. {
  367. if($lines->RecordCount())
  368. {
  369. $parenthref=1;
  370. $parentdata=$lines->FetchRow();
  371. drawdata($parentdata,$zeile);
  372. $parent[$parentcode]=1;
  373. //$idx++;
  374. }
  375. }
  376. }
  377. drawdata($zeile,$advzeile);
  378. //$idx++;
  379. echo "</tr>";
  380. $priocolor=0;
  381. }
  382. }
  383. ?>
  384. </table>
  385. <?php
  386. if(!$showonly&&($linecount>0)) {
  387. ?>
  388. <input type="hidden" name="lastindex" value="<?php echo $idx ?>">
  389. <input type="submit" value="<?php echo $LDApplySelection ?>">
  390. <input type="hidden" name="sid" value="<?php echo $sid; ?>">
  391. <input type="hidden" name="lang" value="<?php echo $lang; ?>">
  392. <input type="hidden" name="pn" value="<?php echo $pn; ?>">
  393. <input type="hidden" name="opnr" value="<?php echo $opnr; ?>">
  394. <input type="hidden" name="ln" value="<?php echo $ln; ?>">
  395. <input type="hidden" name="fn" value="<?php echo $fn; ?>">
  396. <input type="hidden" name="bd" value="<?php echo $bd; ?>">
  397. <input type="hidden" name="dept_nr" value="<?php echo $dept_nr; ?>">
  398. <input type="hidden" name="group_nr" value="<?php echo $group_nr; ?>">
  399. <input type="hidden" name="edit" value="<?php echo $edit; ?>">
  400. <input type="hidden" name="oprm" value="<?php echo $oprm; ?>">
  401. <input type="hidden" name="display" value="<?php echo $display; ?>">
  402. <input type="hidden" name="target" value="<?php echo $target; ?>">
  403. <input type="hidden" name="mode" value="save">
  404. <?php
  405. }else{
  406. /*
  407. ?>
  408. <p>
  409. <a href="javascript:window.close()"><img <?php echo createLDImgSrc($root_path,'close2.gif','0') ?>></a>
  410. <?php
  411. */
  412. }
  413. ?>
  414. </form>
  415. <?php if(($linecount>15)&&!$showonly) : ?>
  416. <p>
  417. <FORM action="drg-icd10-search.php" method="post" onSubmit="return pruf(this)" name="form2">
  418. <a href="javascript:window.close()" class="button icon remove danger">Cancel</a>
  419. <font face="Arial,Verdana" color="#000000" size=-1>
  420. <INPUT type="text" name="keyword" size="14" maxlength="25" value="<?php echo $keyword ?>">
  421. <br>
  422. <INPUT type="submit" name="versand" value="<?php echo $LDSearch ?>">
  423. <input type="hidden" name="sid" value="<?php echo $sid; ?>">
  424. <input type="hidden" name="lang" value="<?php echo $lang; ?>">
  425. <input type="hidden" name="pn" value="<?php echo $pn; ?>">
  426. <input type="hidden" name="opnr" value="<?php echo $opnr; ?>">
  427. <input type="hidden" name="ln" value="<?php echo $ln; ?>">
  428. <input type="hidden" name="fn" value="<?php echo $fn; ?>">
  429. <input type="hidden" name="bd" value="<?php echo $bd; ?>">
  430. <input type="hidden" name="dept_nr" value="<?php echo $dept_nr; ?>">
  431. <input type="hidden" name="group_nr" value="<?php echo $group_nr; ?>">
  432. <input type="hidden" name="edit" value="<?php echo $edit; ?>">
  433. <input type="hidden" name="oprm" value="<?php echo $oprm; ?>">
  434. <input type="hidden" name="display" value="<?php echo $display; ?>">
  435. <input type="hidden" name="showonly" value="<?php echo $showonly; ?>">
  436. <input type="hidden" name="target" value="<?php echo $target; ?>">
  437. </font></FORM>
  438. <p>
  439. <?php endif ?>
  440. </ul>
  441. &nbsp;
  442. </FONT>
  443. </FONT>
  444. </BODY>
  445. </HTML>