/modules/nursing/nursing-ward-patientdata-custom-tc.php

https://github.com/timschofield/2.8 · PHP · 487 lines · 292 code · 144 blank · 51 comment · 23 complexity · c4ebc90c28f399b93094e49cd915d218 MD5 · raw file

  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. if (file_exists($custom_lang_file)) {include "./lang_en_custom.php";}
  6. /**
  7. * CARE2X Integrated Hospital Information System version deployment 1.1 (mysql) 2004-01-11
  8. * GNU General Public License
  9. * Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
  10. * , elpidio@care2x.org
  11. *
  12. * See the file "copy_notice.txt" for the licence notice
  13. */
  14. define('MODULE','nursing');
  15. define('LANG_FILE_MODULAR','nursing.php');
  16. $local_user='ck_pflege_user';
  17. require_once($root_path.'include/helpers/inc_front_chain_lang.php');
  18. if($edit&&!$_COOKIE[$local_user.$sid]) {header('Location:'.$root_path.'language/'.$lang.'/lang_'.$lang.'_invalid-access-warning.php'); exit;};
  19. $thisfile=basename(__FILE__);
  20. $breakfile="nursing-ward-patientdata.php?sid=$sid&lang=$lang&station=$station&pn=$pn&edit=$edit";
  21. /* Create encounter object */
  22. require_once($root_path.'include/core/class_encounter.php');
  23. $enc_obj= new Encounter;
  24. /* Create nursing notes object */
  25. require_once($root_path.'modules/nursing/model/class_notes_nursing.php');
  26. $report_obj= new NursingNotes;
  27. /* Load global configs */
  28. require_once($root_path.'include/core/class_globalconfig.php');
  29. /**
  30. Load custom file - note that by default we will assume english
  31. **/
  32. $custom_lang_file = $root_path."language/".$lang.'/lang_'.$lang.'_custom.php';
  33. include($custom_lang_file);
  34. $GLOBAL_CONFIG=array();
  35. $glob_obj=new GlobalConfig($GLOBAL_CONFIG);
  36. $glob_obj->getConfig('patient_%');
  37. /* Establish db connection */
  38. if(!isset($db)||!$db) include($root_path.'include/helpers/inc_db_makelink.php');
  39. if($dblink_ok)
  40. {
  41. /* Load date formatter */
  42. include_once($root_path.'include/helpers/inc_date_format_functions.php');
  43. if($mode=='save'){
  44. if(($indatetime_date)){
  45. if ($_POST['editid'] != "") {
  46. // Load the editor functions
  47. include_once($root_path.'modules/news/includes/inc_editor_fx.php');
  48. // Load the visual signalling functions
  49. include_once($root_path.'include/helpers/inc_visual_signalling_fx.php');
  50. // Prepare the date
  51. $indatetime_date=formatDate2STD($indatetime_date,$date_format);
  52. //$indatetime_time=$_POST['indatetime_time'].':00';
  53. $indatetime_time="00:00:00";
  54. $q="update care_encounter_custom_tc set
  55. indatetime='".$indatetime_date." ".$indatetime_time."',
  56. `time` = '".$_POST['turntime']."',
  57. `position` = '".$_POST['pos']."',
  58. createid='".$_SESSION['sess_login_userid']."'
  59. where nr = '".$editid."'
  60. ";
  61. //echo $q;
  62. mysql_query($q);
  63. echo mysql_error();
  64. if (mysql_affected_rows()>0) {$saved=true;}
  65. }else{
  66. // Load the editor functions
  67. include_once($root_path.'modules/news/includes/inc_editor_fx.php');
  68. // Load the visual signalling functions
  69. include_once($root_path.'include/helpers/inc_visual_signalling_fx.php');
  70. // Prepare the date
  71. $indatetime_date=formatDate2STD($indatetime_date,$date_format);
  72. //$indatetime_time=$_POST['indatetime_time'].':00';
  73. $indatetime_time=date("h:i",strtotime($_POST['turntime']));
  74. // first, check if this date has been added before
  75. $q="insert into care_encounter_custom_tc (
  76. encounter_nr,createid,indatetime,time,position
  77. ) values (
  78. '".$pn."',
  79. '".$_SESSION['sess_login_userid']."',
  80. '".$indatetime_date." ".$indatetime_time."',
  81. '".$_POST['turntime']."',
  82. '".$_POST['pos']."'
  83. )";
  84. mysql_query($q);
  85. echo mysql_error();
  86. if (mysql_insert_id()>0) {$saved=true;}
  87. //echo $q;
  88. echo mysql_error();
  89. } // insert of new record
  90. } else {
  91. $saved=false;
  92. echo "<p>$report_obj->sql$LDDbNoSave";
  93. }
  94. if($saved){
  95. header("location:$thisfile?sid=$sid&lang=$lang&saved=1&pn=$pn&station=$station&edit=$edit");
  96. } else {
  97. }
  98. }
  99. }
  100. else{
  101. echo "$LDDbNoLink<br>$sql<br>";
  102. }
  103. # Start Smarty templating here
  104. /**
  105. * LOAD Smarty
  106. */
  107. # Note: it is advisable to load this after the inc_front_chain_lang.php so
  108. # that the smarty script can use the user configured template theme
  109. require_once(CARE_BASE.'/include/helpers/smarty_care.class.php');
  110. $smarty = new smarty_care('nursing');
  111. # Title in toolbar
  112. $smarty->assign('sToolbarTitle',"$TC_title $station");
  113. $smarty->assign('LDBack', $LDBack);
  114. $smarty->assign('LDHelp', $LDHelp);
  115. $smarty->assign('LDClose', $LDClose);
  116. # hide return button
  117. $smarty->assign('pbBack',FALSE);
  118. # href for help button
  119. $smarty->assign('pbHelp',CARE_GUI . "modules/" . MODULE . "/help/" . $lang . "/nursing_report.html");
  120. # href for close button
  121. $smarty->assign('breakfile',$breakfile);
  122. # Window bar title
  123. $smarty->assign('sWindowTitle',"$TC_title $station");
  124. # Body Onload JS
  125. $sOnLoadJs ='onLoad="if (window.focus) window.focus();';
  126. if((($mode=='save')||($saved))&&$edit) $sOnLoadJs =$sOnLoadJs.";window.location.href='#bottom';document.berichtform.indatetime_date.focus()";
  127. $smarty->assign('sOnLoadJs',$sOnLoadJs.'"');
  128. # Collect javascript code
  129. ob_start();
  130. ?>
  131. <style type="text/css">
  132. div.fva2_ml10 {font-size: 12; margin-left: 10;}
  133. div.fa2_ml10 {font-size: 12; margin-left: 10;}
  134. div.fva2_ml3 {font-size: 12; margin-left: 3; }
  135. div.fa2_ml3 {font-size: 12; margin-left: 3; }
  136. </style>
  137. <script language="javascript">
  138. <!--
  139. var urlholder;
  140. var focusflag=0;
  141. var formsaved=0;
  142. function pruf(d){
  143. if(((d.indatetime_date.value)&&(
  144. (document.getElementById('6am_supine').checked)||
  145. (document.getElementById('8am_llat').checked)||
  146. (document.getElementById('10am_rlat').checked)||
  147. (document.getElementById('12am_supine').checked)||
  148. (document.getElementById('2pm_llat').checked)||
  149. (document.getElementById('4pm_rlat').checked)||
  150. (document.getElementById('6pm_supine').checked)||
  151. (document.getElementById('8pm_llat').checked)||
  152. (document.getElementById('10pm_rlat').checked)||
  153. (document.getElementById('12pm_supine').checked)||
  154. (document.getElementById('2am_llat').checked)||
  155. (document.getElementById('4am_rlat').checked)||
  156. (document.getElementById('6am_supine').checked)
  157. ))) return true;
  158. else
  159. {
  160. alert("<?php echo $LDAlertIncomplete ?>");
  161. return false;
  162. }
  163. }
  164. function submitform(){
  165. document.forms[0].submit();
  166. }
  167. function closewindow(){
  168. opener.window.focus();
  169. window.close();
  170. }
  171. function resetinput(){
  172. document.berichtform.reset();
  173. }
  174. function select_this(formtag){
  175. document.berichtform.elements[formtag].select();
  176. }
  177. function getinfo(patientID){
  178. urlholder="nursing-ward.php?sid=<?php echo "$sid&lang=$lang" ?>&route=validroute&patient=" + patientID + "&user=<?php echo $_COOKIE[$local_user.$sid].'"' ?>;
  179. patientwin=window.open(urlholder,patientID,"width=600,height=400,menubar=no,resizable=yes,scrollbars=yes");
  180. }
  181. function sethilite(d){
  182. d.focus();
  183. d.value=d.value+"~";
  184. d.focus();
  185. }
  186. function endhilite(d){
  187. d.focus();
  188. d.value=d.value+"~~";
  189. d.focus();
  190. }
  191. <?php require($root_path.'include/helpers/inc_checkdate_lang.php'); ?>
  192. -->
  193. </script>
  194. <?php
  195. $sTemp = ob_get_contents();
  196. ob_end_clean();
  197. $smarty->append('JavaScript',$sTemp);
  198. # Buffer page output
  199. ob_start();
  200. ?>
  201. <form name="berichtform" method="post" action="<?php echo $thisfile ?>" onSubmit="return pruf(this)">
  202. <table cellpadding="0" cellspacing=1 border="0">
  203. <tr valign="top">
  204. <td colspan=4 bgcolor="#99ccff" width="50%">
  205. <?php
  206. echo '<img src="'.$root_path.'include/imgcreator/barcode_label_single_large.php?sid='.$sid.'&lang='.$lang.'&fen='.$full_en.'&en='.$pn.'" width=282 height=178>';
  207. ?>
  208. </td>
  209. <td colspan=4 bgcolor="#99ccff"><div class=fva2_ml10>
  210. <?php
  211. echo '<font size="7">'.$TC_title.' <p><font size=2>';
  212. ?>
  213. </div></td></tr>
  214. </table>
  215. <script language="JavaScript">
  216. function EditRecord(id,rec) {
  217. editcolor='#FFFF00';
  218. document.getElementById('editid').value=rec;
  219. // prefill date
  220. document.getElementById('indatetime_date').value=eval("document.getElementById('date_'+id).value");
  221. document.getElementById('indatetime_date').style.backgroundColor=editcolor;
  222. // prefill time
  223. document.getElementById('turntime').value=eval("document.getElementById('time_'+id).innerHTML");
  224. document.getElementById('turntime').style.backgroundColor=editcolor;
  225. // prefill turn
  226. thisturn=eval("document.getElementById('pos_"+id+"').innerHTML");
  227. for (i=0;i<document.getElementById('pos_sel').options.length;i++) {
  228. if (document.getElementById('pos_sel').options[i].text == thisturn) {
  229. document.getElementById('pos_sel').options.selectedIndex=i;
  230. }
  231. }
  232. document.getElementById('pos_sel').style.backgroundColor=editcolor;
  233. }
  234. </script>
  235. <table bgcolor='#99ccff' cellpadding=0 cellspacing=0>
  236. <tr>
  237. <td valign="top">
  238. </td>
  239. <?
  240. // now, loop through all records and then show a column representing each day
  241. $res=mysql_query("select * from care_encounter_custom_tc where encounter_nr = '".$pn."' order by DATE(indatetime),time");
  242. while ($resd=mysql_fetch_assoc($res)) {
  243. $thisdate=date("m/d/Y",strtotime($resd['indatetime']));
  244. $alldates[$thisdate][]=$resd['time']."\t".$resd['position']."\t".$resd['nr'];
  245. }
  246. foreach ($alldates as $var => $val) {
  247. ?>
  248. <td valign="top" bgcolor="#99ccff">
  249. <table width=215 style="font-size:9px" bgcolor="#33ccff" cellpadding=0 cellspacing=0>
  250. <tr>
  251. <td height=20 align=center>
  252. <b><?php echo date("d/m/Y",strtotime($var))?></b>
  253. </td>
  254. </tr>
  255. </table>
  256. <?
  257. $days++;
  258. foreach ($alldates[$var] as $var2 => $val2) {
  259. list($time,$pos,$id)=explode("\t",$val2);
  260. $times++;
  261. if (stristr($LDSUPINE,$pos)) {$color="#0000AA";}
  262. if (stristr($LDLEFTLATERAL,$pos)) {$color="#00AA00";}
  263. if (stristr($LDRIGHTLATERAL,$pos)) {$color="#AA0000";}
  264. $tc++;
  265. ?>
  266. <div id="<?php echo $id?>">
  267. <table height=10 width=215 bgcolor="<?php echo $color?>" cellpadding=5 cellspacing=0><tr><td>
  268. <input type=hidden id="date_<?php echo $tc?>" value="<?php echo date("d/m/Y",strtotime($var))?>">
  269. <span style="font-size:9px"><font color=white><b><span id="time_<?php echo $tc?>"><?php echo date("H:i",strtotime($time))?></span> <span><?php echo " (".date("h:i a",strtotime($time)).")"?></span></b> : <span id="pos_<?php echo $tc?>"><?php echo $pos?></span></font></font>
  270. </td><td align=right><span style="background-color:yellow">&nbsp;<a href="javascript:EditRecord('<?php echo $tc?>','<?php echo $id?>')"><?php echo $LDEDIT ?></a>&nbsp;</span></td></tr></table>
  271. </div>
  272. <?
  273. }
  274. ?>
  275. </td>
  276. <?
  277. }
  278. ?>
  279. </tr>
  280. </table>
  281. <br>
  282. <table bgcolor="#99ccff">
  283. <tr>
  284. <td>
  285. <?php echo $LDDate?><br>
  286. <table><tr><td>
  287. <?php
  288. //gjergji : new calendar
  289. require_once ('../../js/jscalendar/calendar.php');
  290. $calendar = new DHTML_Calendar('../../js/jscalendar/', $lang, 'calendar-system', true);
  291. $calendar->load_files();
  292. echo $calendar->show_calendar($calendar,$date_format,'indatetime_date');
  293. //end : gjergji
  294. ?>
  295. </td>
  296. </tr></table>
  297. </td>
  298. <td>
  299. <?php echo $LDTime?><br>
  300. <table><tr><td><input size=10 type=text name=turntime id=turntime maxlength=5></td><td>HH:MM (13:00)</td></tr></table>
  301. </td>
  302. <td>
  303. <?php echo $LDPosition ?><br>
  304. <table><tr><td><select name="pos" id="pos_sel">
  305. <option><?php echo $LDSUPINE ?></option>
  306. <option><?php echo $LDLEFTLATERAL ?></option>
  307. <option><?php echo $LDRIGHTLATERAL ?></option>
  308. </select>
  309. </td></tr></table>
  310. </td>
  311. <td>
  312. <a href='nursing-ward-patientdata-custom-tc.php<?php echo URL_REDIRECT_APPEND?>&station=<?php echo $station?>&pn=<?php echo $pn?>&edit=<?php echo $edit?>'><span style="background-color:yellow"><?php echo $LDEDIT ?></span></a>
  313. </td>
  314. </tr></table>
  315. <p>
  316. <table width="650" cellpadding="0" cellspacing="0">
  317. <tr>
  318. <td>
  319. <input type="image" <?php echo createLDImgSrc($root_path,'savedisc.gif','0') ?> width=99 height=24 alt="<?php echo $LDSave ?>">
  320. </td>
  321. <td>
  322. </td>
  323. </tr>
  324. </table>
  325. <input type=hidden name=editid id=editid value="">
  326. <input type="hidden" name="sid" value="<?php echo $sid ?>">
  327. <input type="hidden" name="lang" value="<?php echo $lang ?>">
  328. <input type="hidden" name="station" value="<?php echo $station ?>">
  329. <input type="hidden" name="pn" value="<?php echo $pn ?>">
  330. <input type="hidden" name="edit" value="<?php echo $edit ?>">
  331. <input type="hidden" name="mode" value="save">
  332. </form>
  333. </ul>
  334. <?php
  335. $sTemp = ob_get_contents();
  336. ob_end_clean();
  337. # Assign page output to the mainframe template
  338. $smarty->assign('sMainFrameBlockData',$sTemp);
  339. /**
  340. * show Template
  341. */
  342. $smarty->display(CARE_BASE . 'main/view/mainframe.tpl');
  343. ?>