PageRenderTime 98ms CodeModel.GetById 27ms RepoModel.GetById 7ms app.codeStats 0ms

/modules/nursing/nursing-ward-patient-release.php

https://github.com/timschofield/2.8
PHP | 288 lines | 200 code | 51 blank | 37 comment | 31 complexity | 4e460cd33188168ce4f9554435c3ea46 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 version deployment 1.1 (mysql) 2004-01-11
  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','nursing');
  14. define('LANG_FILE_MODULAR','nursing.php');
  15. $local_user='ck_pflege_user';
  16. require_once($root_path.'include/helpers/inc_front_chain_lang.php');
  17. require_once($root_path.'global_conf/inc_remoteservers_conf.php');
  18. //$db->debug=true;
  19. if(!$encoder) $encoder=$_COOKIE[$local_user.$sid];
  20. $breakfile="nursing-ward.php".URL_APPEND."&edit=1&station=$station&ward_nr=$ward_nr";
  21. $thisfile=basename(__FILE__);
  22. # Load date formatter
  23. require_once($root_path.'include/helpers/inc_date_format_functions.php');
  24. require_once($root_path.'include/core/class_encounter.php');
  25. $enc_obj=new Encounter;
  26. if( $enc_obj->loadEncounterData($pn)) {
  27. if(($mode=='release')&&!(isset($lock)||$lock)){
  28. $date=(empty($x_date))?date('Y-m-d'):formatDate2STD($x_date,$date_format);
  29. $time=(empty($x_time))?date('H:i:s'):convertTimeToStandard($x_time);
  30. switch($relart)
  31. {
  32. case 1: {}
  33. case 2: {}
  34. case 7: {}
  35. case 3: $released=$enc_obj->Discharge($pn,$relart,$date,$time);
  36. break;
  37. case 4: $released=$enc_obj->DischargeFromWard($pn,$relart,$date,$time);
  38. break;
  39. case 5: $released=$enc_obj->DischargeFromRoom($pn,$relart,$date,$time);
  40. break;
  41. case 6: $released=$enc_obj->DischargeFromBed($pn,$relart,$date,$time);
  42. break;
  43. default: $released=false;
  44. }
  45. if($released){
  46. if(!empty($info)){
  47. $data_array['notes']=$info;
  48. $data_array['encounter_nr']=$pn;
  49. $data_array['date']=$date;
  50. $data_array['time']=$time;
  51. $data_array['staff_name']=$encoder;
  52. $enc_obj->saveDischargeNotesFromArray($data_array);
  53. }
  54. # If patient died
  55. if($relart==7){
  56. include_once($root_path.'include/core/class_person.php');
  57. $person=new Person;
  58. $death['death_date']=$date;
  59. $death['death_encounter_nr']=$pn;
  60. $death['history']=$enc_obj->ConcatHistory("Discharged (cause: death) ".date('Y-m-d H:i:s')." $encoder\n");
  61. $death['modify_id']=$encoder;
  62. $death['modify_time']=date('YmdHis');
  63. @$person->setDeathInfo($enc_obj->PID(),$death);
  64. //echo $person->getLastQuery();
  65. }
  66. //echo ("location:$thisfile?sid=$sid&lang=$lang&pn=$pn&bd=$bd&rm=$rm&pyear=$pyear&pmonth=$pmonth&pday=$pday&mode=$mode&released=1&lock=1&x_date=$x_date&x_time=$x_time&relart=$relart&encoder=".strtr($encoder," ","+")."&info=".strtr($info," ","+")."&station=$station&ward_nr=$ward_nr");
  67. header("location:$thisfile?sid=$sid&lang=$lang&pn=$pn&bd=$bd&rm=$rm&pyear=$pyear&pmonth=$pmonth&pday=$pday&mode=$mode&released=1&lock=1&x_date=$x_date&x_time=$x_time&relart=$relart&encoder=".strtr($encoder," ","+")."&info=".strtr($info," ","+")."&station=$station&ward_nr=$ward_nr");
  68. exit;
  69. }
  70. } // end of if (mode=release)
  71. include_once($root_path.'include/core/class_globalconfig.php');
  72. $GLOBAL_CONFIG=array();
  73. $glob_obj=new GlobalConfig($GLOBAL_CONFIG);
  74. $glob_obj->getConfig('patient_%');
  75. $glob_obj->getConfig('person_%');
  76. $result=&$enc_obj->encounter;
  77. /* Check whether config photo path exists, else use default path */
  78. $default_photo_path='uploads/photos/registration';
  79. $photo_filename=$result['photo_filename'];
  80. $photo_path = (is_dir($root_path.$GLOBAL_CONFIG['person_photo_path'])) ? $GLOBAL_CONFIG['person_photo_path'] : $default_photo_path;
  81. require_once($root_path.'include/helpers/inc_photo_filename_resolve.php');
  82. /* Load the discharge types */
  83. $discharge_types=&$enc_obj->getDischargeTypesData();
  84. $patient_ok=TRUE;
  85. }else{
  86. $patient_ok=FALSE;
  87. }
  88. # Start Smarty templating here
  89. /**
  90. * LOAD Smarty
  91. */
  92. # Note: it is advisable to load this after the inc_front_chain_lang.php so
  93. # that the smarty script can use the user configured template theme
  94. require_once(CARE_BASE.'/include/helpers/smarty_care.class.php');
  95. $smarty = new smarty_care('common');
  96. # Toolbar title
  97. $smarty->assign('sToolbarTitle',$LDReleasePatient);
  98. $smarty->assign('LDBack', $LDBack);
  99. $smarty->assign('LDHelp', $LDHelp);
  100. $smarty->assign('LDClose', $LDClose);
  101. # href for the return button
  102. $smarty->assign('pbBack',FALSE);
  103. # href for the button
  104. $smarty->assign('pbHelp',CARE_GUI . "modules/" . MODULE . "/help/" . $lang . "/inpatient_discharge.html");
  105. $smarty->assign('breakfile',$breakfile);
  106. # Window bar title
  107. $smarty->assign('title',$LDReleasePatient);
  108. # Collect extra javascrit code if patient is not released yet
  109. if(!$released){
  110. ob_start();
  111. ?>
  112. <script language="javascript">
  113. <!--
  114. function pruf(d){
  115. if(!d.sure.checked){
  116. return false;
  117. }else{
  118. if(!d.encoder.value){
  119. alert("<?php echo $LDAlertNoName ?>");
  120. d.encoder.focus();
  121. return false;
  122. }
  123. if (!d.x_date.value){ alert("<?php echo "$LDAlertNoDate ";
  124. $dfbuffer="LD_".strtr($date_format,".-/","phs");
  125. echo $$dfbuffer;
  126. ?>"); d.x_date.focus();return false;}
  127. if (!d.x_time.value){ alert("<?php echo $LDAlertNoTime ?>"); d.x_time.focus();return false;}
  128. // Check if death
  129. if(d.relart[6].checked==true&&d.x_date.value!=""){
  130. if(!confirm("<?php echo $LDDeathDateIs ?> "+d.x_date.value+". <?php echo "$LDIsCorrect $LDProceedSave" ?>")) return false;
  131. }
  132. return true;
  133. }
  134. }
  135. <?php require($root_path.'include/helpers/inc_checkdate_lang.php'); ?>
  136. //-->
  137. </script>
  138. <?php
  139. $sTemp = ob_get_contents();
  140. ob_end_clean();
  141. $smarty->append('JavaScript',$sTemp);
  142. } // End of if !$released
  143. if(($mode=="release")&&($released)){
  144. $smarty->assign('sPrompt',$LDJustReleased);
  145. }
  146. if($patient_ok){
  147. $smarty->assign('thisfile',$thisfile);
  148. $smarty->assign('sBarcodeLabel','<img src="'.$root_path.'include/imgcreator/barcode_label_single_large.php?sid='.$sid.'&lang='.$lang.'&fen='.$full_en.'&en='.$pn.'" width=282 height=178>');
  149. $smarty->assign('img_source','<img '.$img_source.' align="top">');
  150. $smarty->assign('LDLocation',$LDPatListElements[0]);
  151. $smarty->assign('sLocation',$rm.strtoupper(chr($bd+96)));
  152. $smarty->assign('LDDate',$LDDate);
  153. //gjergji : new calendar
  154. require_once ('../../js/jscalendar/calendar.php');
  155. $calendar = new DHTML_Calendar('../../js/jscalendar/', $lang, 'calendar-system', true);
  156. $calendar->load_files();
  157. //end gjergji
  158. if($released){
  159. $smarty->assign('released',TRUE);
  160. $smarty->assign('x_date',nl2br($x_date));
  161. }else{
  162. //gjergji : new calendar
  163. $smarty->assign('sDateMiniCalendar',$calendar->show_calendar($calendar,$date_format,'x_date'));
  164. //end gjergji
  165. }
  166. $smarty->assign('LDClockTime',$LDClockTime);
  167. if($released) $smarty->assign('x_time',nl2br($x_time));
  168. else $smarty->assign('sTimeInput','<input type="text" name="x_time" size=12 maxlength=12 value="'.convertTimeToLocal(date('H:i:s')).'" onKeyUp=setTime(this,\''.$lang.'\')>');
  169. $smarty->assign('LDReleaseType',$LDReleaseType);
  170. $sTemp = '';
  171. if($released){
  172. while($dis_type=$discharge_types->FetchRow()){
  173. if($dis_type['nr']==$relart){
  174. $sTemp = $sTemp.'&nbsp;';
  175. if(isset($$dis_type['LD_var'])&&!empty($$dis_type['LD_var'])) $sTemp = $sTemp.$$dis_type['LD_var'];
  176. else $sTemp = $sTemp.$dis_type['name'];
  177. break;
  178. }
  179. }
  180. }else{
  181. $init=1;
  182. while($dis_type=$discharge_types->FetchRow()){
  183. # We will display only discharge types 1 to 7
  184. if($dis_type['nr']<8){
  185. $sTemp = $sTemp.'&nbsp;';
  186. $sTemp = $sTemp.'<input type="radio" name="relart" value="'.$dis_type['nr'].'"';
  187. if($init){
  188. $sTemp = $sTemp.' checked';
  189. $init=0;
  190. }
  191. $sTemp = $sTemp.'>';
  192. if(isset($$dis_type['LD_var'])&&!empty($$dis_type['LD_var'])) $sTemp = $sTemp.$$dis_type['LD_var'];
  193. else $sTemp = $sTemp.$dis_type['name'];
  194. $sTemp = $sTemp.'<br>';
  195. }
  196. }
  197. }
  198. $smarty->assign('sDischargeTypes',$sTemp);
  199. $smarty->assign('LDNotes',$LDNotes);
  200. if($released) $smarty->assign('info',nl2br($info));
  201. $smarty->assign('LDNurse',$LDNurse);
  202. $smarty->assign('encoder',$encoder);
  203. if(!(($mode=='release')&&($released))) {
  204. $smarty->assign('bShowValidator',TRUE);
  205. $smarty->assign('pbSubmit','<input type="submit" value="'.$LDRelease.'">');
  206. $smarty->assign('sValidatorCheckBox','<input type="checkbox" name="sure" value="1">');
  207. $smarty->assign('LDYesSure',$LDYesSure);
  208. }
  209. $sTemp = '<input type="hidden" name="mode" value="release">';
  210. if(($released)||($lock)) $sTemp = $sTemp.'<input type="hidden" name="lock" value="1">';
  211. $sTemp = $sTemp.'<input type="hidden" name="sid" value="'.$sid.'">
  212. <input type="hidden" name="lang" value="'.$lang.'">
  213. <input type="hidden" name="station" value="'.$station.'">
  214. <input type="hidden" name="ward_nr" value="'.$ward_nr.'">
  215. <input type="hidden" name="dept" value="'.$dept.'">
  216. <input type="hidden" name="dept_nr" value="'.$dept_nr.'">
  217. <input type="hidden" name="pday" value="'.$pday.'">
  218. <input type="hidden" name="pmonth" value="'.$pmonth.'">
  219. <input type="hidden" name="pyear" value="'.$pyear.'">
  220. <input type="hidden" name="rm" value="'.$rm.'">
  221. <input type="hidden" name="bd" value="'.$bd.'">
  222. <input type="hidden" name="pn" value="'.$pn.'">
  223. <input type="hidden" name="s_date" value="'."$pyear-$pmonth-$pday".'">';
  224. $smarty->assign('sHiddenInputs',$sTemp);
  225. }else{
  226. $smarty->assign('sPrompt',"$LDErrorOccured $LDTellEdpIfPersist");
  227. }
  228. if(($mode=='release')&&($released)) $sBreakButton= 'Close';
  229. else $sBreakButton= 'Cancel';
  230. $smarty->assign('pbCancel','<a href="'.$breakfile.'" class="button icon remove danger">'.$sBreakButton.'</a>');
  231. $smarty->assign('sMainBlockIncludeFile',__DIR__ . '/view/discharge_patient_form.tpl');
  232. /**
  233. * show Template
  234. */
  235. $smarty->display(CARE_BASE . 'main/view/mainframe.tpl');
  236. // $smarty->display('debug.tpl');
  237. ?>