PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/registration_admission/admission_data_show.php

https://github.com/timschofield/2.8
PHP | 491 lines | 315 code | 114 blank | 62 comment | 83 complexity | 61bff210bd143a8bc4b4634cbbe06fe1 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 Information System beta 2.0.1 - 2004-07-04 for Hospitals and Health Care Organizations and Services
  7. Copyright (C) 2002,2003,2004,2005 Elpidio Latorilla & Intellin.org
  8. GNU GPL.
  9. For details read file "copy_notice.txt".
  10. */
  11. define('MODULE','registration_admission');
  12. define('LANG_FILE_MODULAR','registration_admission.php');
  13. $local_user='aufnahme_user';
  14. require_once($root_path.'include/helpers/inc_front_chain_lang.php');
  15. require_once($root_path.'include/core/class_encounter.php');
  16. require_once($root_path.'include/core/class_person.php');
  17. require_once($root_path.'modules/insurance_co/model/class_insurance.php');
  18. require_once($root_path.'include/core/class_ward.php');
  19. require_once($root_path.'include/core/class_globalconfig.php');
  20. require_once($root_path.'modules/ecombill/model/class_ecombill.php');
  21. require_once($root_path.'modules/staff_admin/model/class_staff.php');
  22. if(!isset($_SESSION['sess_parent_mod'])) $_SESSION['sess_parent_mod'] = "";
  23. # Create objects
  24. $encounter_obj=new Encounter($encounter_nr);
  25. $person_obj=new Person();
  26. $insurance_obj=new Insurance;
  27. $eComBill_obj = new eComBill;
  28. $staff_obj = new staff;
  29. $thisfile=basename(__FILE__);
  30. if($_COOKIE['ck_login_logged'.$sid]) $breakfile=$root_path.'modules/news/start_page.php'.URL_APPEND;
  31. else $breakfile='admission_pass.php'.URL_APPEND.'&target=entry';
  32. //$breakfile='admission_pass.php'.URL_APPEND;
  33. $GLOBAL_CONFIG=array();
  34. $glob_obj=new GlobalConfig($GLOBAL_CONFIG);
  35. /* Get the patient global configs */
  36. $glob_obj->getConfig('patient_%');
  37. $glob_obj->getConfig('person_photo_path');
  38. $glob_obj->getConfig('show_billable_items');
  39. $glob_obj->getConfig('show_doctors_list');
  40. $updatefile='admission_start.php';
  41. /* Default path for photos. Make sure that this directory exists! */
  42. $default_photo_path=$root_path.'uploads/photos/registration';
  43. $photo_filename='nopic';
  44. $dbtable='care_encounter';
  45. //$db->debug=1;
  46. if(!empty($GLOBAL_CONFIG['patient_financial_class_single_result'])) $encounter_obj->setSingleResult(true);
  47. if(!$GLOBAL_CONFIG['patient_service_care_hide']){
  48. /* Get the care service classes*/
  49. $care_service=$encounter_obj->AllCareServiceClassesObject();
  50. if($buff=&$encounter_obj->CareServiceClass()){
  51. $care_class=$buff->FetchRow();
  52. extract($care_class);
  53. reset($care_class);
  54. }
  55. }
  56. if(!$GLOBAL_CONFIG['patient_service_room_hide']){
  57. /* Get the room service classes */
  58. $room_service=$encounter_obj->AllRoomServiceClassesObject();
  59. if($buff=&$encounter_obj->RoomServiceClass()){
  60. $room_class=$buff->FetchRow();
  61. extract($room_class);
  62. reset($room_class);
  63. }
  64. }
  65. if(!$GLOBAL_CONFIG['patient_service_att_dr_hide']){
  66. /* Get the attending doctor service classes */
  67. $att_dr_service=$encounter_obj->AllAttDrServiceClassesObject();
  68. if($buff=&$encounter_obj->AttDrServiceClass()){
  69. $att_dr_class=$buff->FetchRow();
  70. //while(list($x,$v)=each($att_dr_class)) $$x=$v;
  71. extract($att_dr_class);
  72. reset($att_dr_class);
  73. }
  74. }
  75. $encounter_obj->loadEncounterData();
  76. if($encounter_obj->is_loaded) {
  77. $row=&$encounter_obj->encounter;
  78. //load data
  79. extract($row);
  80. # Set edit mode
  81. if(!$is_discharged) $edit=true;
  82. else $edit=false;
  83. # Fetch insurance and encounter classes
  84. $insurance_class=&$encounter_obj->getInsuranceClassInfo($insurance_class_nr);
  85. $encounter_class=&$encounter_obj->getEncounterClassInfo($encounter_class_nr);
  86. //if($data_obj=&$person_obj->getAllInfoObject($pid))
  87. $list='title,name_first,name_last,name_2,name_3,name_middle,name_maiden,name_others,date_birth,
  88. sex,addr_str,addr_str_nr,addr_zip,addr_citytown_nr,photo_filename';
  89. $person_obj->setPID($pid);
  90. if($row=&$person_obj->getValueByList($list)) {
  91. extract($row);
  92. }
  93. $addr_citytown_name=$person_obj->CityTownName($addr_citytown_nr);
  94. $encoder=$encounter_obj->RecordModifierID();
  95. # Get current encounter to check if current encounter is this encounter nr
  96. $current_encounter=$person_obj->CurrentEncounter($pid);
  97. # Get the overall status
  98. if($stat=&$encounter_obj->AllStatus($encounter_nr)){
  99. $enc_status=$stat->FetchRow();
  100. }
  101. # Get ward or department infos
  102. if($encounter_class_nr==1){
  103. # Get ward name
  104. include_once($root_path.'include/core/class_ward.php');
  105. $ward_obj=new Ward;
  106. $current_ward_name=$ward_obj->WardName($current_ward_nr);
  107. }elseif($encounter_class_nr==2){
  108. # Get ward name
  109. include_once($root_path.'modules/dept_admin/model/class_department.php');
  110. $dept_obj=new Department;
  111. //$current_dept_name=$dept_obj->FormalName($current_dept_nr);
  112. $current_dept_LDvar=$dept_obj->LDvar($current_dept_nr);
  113. if(isset($$current_dept_LDvar)&&!empty($$current_dept_LDvar)) $current_dept_name=$$current_dept_LDvar;
  114. else $current_dept_name=$dept_obj->FormalName($current_dept_nr);
  115. }
  116. }
  117. include_once($root_path.'include/helpers/inc_date_format_functions.php');
  118. /* Update History */
  119. if(!$newdata) $encounter_obj->setHistorySeen($_SESSION['sess_user_name'],$encounter_nr);
  120. /* Get insurance firm name*/
  121. $insurance_firm_name=$insurance_obj->getFirmName($insurance_firm_id);
  122. /* Check whether config path exists, else use default path */
  123. $photo_path = (is_dir($root_path.$GLOBAL_CONFIG['person_photo_path'])) ? $GLOBAL_CONFIG['person_photo_path'] : $default_photo_path;
  124. /* Prepare text and resolve the numbers */
  125. require_once($root_path.'include/helpers/inc_patient_encounter_type.php');
  126. /* Save encounter nrs to session */
  127. $_SESSION['sess_pid']=$pid;
  128. $_SESSION['sess_en']=$encounter_nr;
  129. $_SESSION['sess_full_en']=$full_en;
  130. $_SESSION['sess_parent_mod']='admission';
  131. $_SESSION['sess_user_origin']='admission';
  132. $_SESSION['sess_file_return']=$thisfile;
  133. /* Prepare the photo filename */
  134. require_once($root_path.'include/helpers/inc_photo_filename_resolve.php');
  135. # Start Smarty templating here
  136. /**
  137. * LOAD Smarty
  138. */
  139. # Note: it is advisable to load this after the inc_front_chain_lang.php so
  140. # that the smarty script can use the user configured template theme
  141. require_once(CARE_BASE.'/include/helpers/smarty_care.class.php');
  142. $smarty = new smarty_care('common');
  143. # Title in the toolbar
  144. $smarty->assign('sToolbarTitle',$LDPatientData.' ('.$encounter_nr.')');
  145. $smarty->assign('LDBack', $LDBack);
  146. $smarty->assign('LDHelp', $LDHelp);
  147. $smarty->assign('LDClose', $LDClose);
  148. # href for help button
  149. $smarty->assign('pbHelp',CARE_GUI . "modules/" . MODULE . "/help/" . $lang . "/admission_how2new.html");
  150. $smarty->assign('breakfile',$breakfile);
  151. # Window bar title
  152. $smarty->assign('title',$LDPatientData.' ('.$encounter_nr.')');
  153. # href for help button
  154. $smarty->assign('pbHelp',CARE_GUI . "modules/" . MODULE . "/help/" . $lang . "/admission_show.html");
  155. # Hide the return button
  156. $smarty->assign('pbBack',FALSE);
  157. # Collect extra javascript
  158. ob_start();
  159. require($root_path.'include/imgcreator/inc_js_barcode_wristband_popwin.php');
  160. require('./include/js_poprecordhistorywindow.inc.php');
  161. $sTemp = ob_get_contents();
  162. ob_end_clean();
  163. $smarty->append('JavaScript',$sTemp);
  164. # Load tabs
  165. $parent_admit = TRUE;
  166. //$target='entry';
  167. include('./gui_bridge/default/gui_tabs_patadmit.php');
  168. if($is_discharged){
  169. $smarty->assign('is_discharged',TRUE);
  170. $smarty->assign('sWarnIcon',"<img ".createComIcon($root_path,'warn.gif','0','absmiddle').">");
  171. if($current_encounter) $smarty->assign('sDischarged',$LDEncounterClosed);
  172. else $smarty->assign('sDischarged',$LDPatientIsDischarged);
  173. }
  174. $smarty->assign('LDCaseNr',$LDCaseNr);
  175. $smarty->assign('encounter_nr',$encounter_nr);
  176. # Create the encounter barcode image
  177. if(file_exists($root_path.'cache/barcodes/en_'.$encounter_nr.'.png')) {
  178. $smarty->assign('sEncBarcode','<img src="'.$root_path.'cache/barcodes/en_'.$encounter_nr.'.png" border=0 width=180 height=35>');
  179. }else{
  180. $smarty->assign('sHiddenBarcode',"<img src='".$root_path."classes/barcode/image.php?code=".$encounter_nr."&style=68&type=I25&width=180&height=50&xres=2&font=5&label=2&form_file=en' border=0 width=0 height=0>");
  181. $smarty->assign('sEncBarcode',"<img src='".$root_path."classes/barcode/image.php?code=".$encounter_nr."&style=68&type=I25&width=180&height=40&xres=2&font=5' border=0>");
  182. }
  183. $smarty->assign('img_source',"<img $img_source>");
  184. $smarty->assign('LDAdmitDate',$LDAdmitDate);
  185. $smarty->assign('sAdmitDate', @formatDate2Local($encounter_date,$date_format));
  186. $smarty->assign('LDAdmitTime',$LDAdmitTime);
  187. $smarty->assign('sAdmitTime',@formatDate2Local($encounter_date,$date_format,1,1));
  188. $smarty->assign('LDTitle',$LDTitle);
  189. $smarty->assign('title',$title);
  190. $smarty->assign('LDLastName',$LDLastName);
  191. $smarty->assign('name_last',$name_last);
  192. $smarty->assign('LDFirstName',$LDFirstName);
  193. $smarty->assign('name_first',$name_first);
  194. # If person is dead show a black cross and assign death date
  195. if($death_date && $death_date != DBF_NODATE){
  196. $smarty->assign('sCrossImg','<img '.createComIcon($root_path,'blackcross_sm.gif','0').'>');
  197. $smarty->assign('sDeathDate',@formatDate2Local($death_date,$date_format));
  198. }
  199. # Set a row span counter, initialize with 6
  200. $iRowSpan = 6;
  201. if($GLOBAL_CONFIG['patient_name_2_show']&&$name_2){
  202. $smarty->assign('LDName2',$LDName2);
  203. $smarty->assign('name_2',$name_2);
  204. $iRowSpan++;
  205. }
  206. if($GLOBAL_CONFIG['patient_name_3_show']&&$name_3){
  207. $smarty->assign('LDName3',$LDName3);
  208. $smarty->assign('name_3',$name_3);
  209. $iRowSpan++;
  210. }
  211. if($GLOBAL_CONFIG['patient_name_middle_show']&&$name_middle){
  212. $smarty->assign('LDNameMid',$LDNameMid);
  213. $smarty->assign('name_middle',$name_middle);
  214. $iRowSpan++;
  215. }
  216. $smarty->assign('sRowSpan',"rowspan=\"$iRowSpan\"");
  217. $smarty->assign('LDBday',$LDBday);
  218. $smarty->assign('sBdayDate',@formatDate2Local($date_birth,$date_format));
  219. $smarty->assign('LDSex',$LDSex);
  220. if($sex=='m') $smarty->assign('sSexType',$LDMale);
  221. elseif($sex=='f') $smarty->assign('sSexType',$LDFemale);
  222. $smarty->assign('LDBloodGroup',$LDBloodGroup);
  223. if($blood_group){
  224. $buf='LD'.$blood_group;
  225. $smarty->assign('blood_group',$$buf);
  226. }
  227. $smarty->assign('LDAddress',$LDAddress);
  228. $smarty->assign('addr_str',$addr_str);
  229. $smarty->assign('addr_str_nr',$addr_str_nr);
  230. $smarty->assign('addr_zip',$addr_zip);
  231. $smarty->assign('addr_citytown',$addr_citytown_name);
  232. //start gjergji
  233. //simple admission type, how the patietnt came in
  234. $enc_type = $encounter_obj->getEncounterType();
  235. while( $typeResults = $enc_type->FetchRow()) {
  236. if($typeResults['type_nr'] == $admit_type )$sTemp = $typeResults['name'] ;
  237. }
  238. $smarty->assign('LDAdmitShowTypeInput',$LDAdmitShowTypeInput);
  239. $smarty->assign('sAdmitShowTypeInput',$sTemp);
  240. //start simple triage
  241. if($triage == 'white') { $smarty->assign('sAdmitTriageWhite',$sAdmitTriageWhite); }
  242. elseif($triage == 'green') { $smarty->assign('sAdmitTriageGreen',$sAdmitTriageGreen); }
  243. elseif ($triage == 'yellow') { $smarty->assign('sAdmitTriageYellow',$sAdmitTriageYellow); }
  244. elseif ($triage == 'red') { $smarty->assign('sAdmitTriageRed',$sAdmitTriageRed); }
  245. $smarty->assign('LDShowTriageData','-');
  246. //end simple triage
  247. //end : gjergji
  248. $smarty->assign('LDAdmitClass',$LDAdmitClass);
  249. # Suggested by Dr. Sarat Nayak to emphasize the OUTPATIENT encounter type
  250. if (isset($$encounter_class['LD_var']) && !empty($$encounter_class['LD_var'])){
  251. $eclass=$$encounter_class['LD_var'];
  252. //$fcolor='red';
  253. }else{
  254. $eclass= $encounter_class['name'];
  255. }
  256. if($encounter_class_nr==1){
  257. $fcolor='black';
  258. }else{
  259. $fcolor='red';
  260. $eclass='<b>'.strtoupper($eclass).'</b>';
  261. }
  262. $smarty->assign('sAdmitClassInput',"<font color=$fcolor>$eclass</font>");
  263. if($encounter_class_nr==1){
  264. $smarty->assign('LDWard',$LDWard);
  265. $smarty->assign('sWardInput','<a href="'.$root_path.'modules/nursing/'.strtr('nursing-ward-pass.php'.URL_APPEND.'&rt=pflege&edit=1&station='.$current_ward_name.'&location_id='.$current_ward_name.'&ward_nr='.$current_ward_nr,' ',' ').'">'.$current_ward_name.'</a>');
  266. }elseif($encounter_class_nr==2){
  267. $smarty->assign('LDWard',"$LDClinic/$LDDepartment");
  268. $smarty->assign('sWardInput','<a href="'.$root_path.'modules/ambulatory/'.strtr('amb_clinic_patients_pass.php'.URL_APPEND.'&rt=pflege&edit=1&dept='.$$current_dept_LDvar.'&location_id='.$$current_dept_LDvar.'&dept_nr='.$current_dept_nr,' ',' ').'">'.$current_dept_name.'</a>');
  269. }
  270. $smarty->assign('LDDiagnosis',$LDDiagnosis);
  271. $smarty->assign('referrer_diagnosis',$referrer_diagnosis);
  272. $smarty->assign('LDRecBy',$LDRecBy);
  273. $smarty->assign('referrer_dr',$referrer_dr);
  274. $smarty->assign('LDTherapy',$LDTherapy);
  275. $smarty->assign('referrer_recom_therapy',$referrer_recom_therapy);
  276. $smarty->assign('LDSpecials',$LDSpecials);
  277. $smarty->assign('referrer_notes',$referrer_notes);
  278. $smarty->assign('LDBillType',$LDBillType);
  279. if (isset($$insurance_class['LD_var'])&&!empty($$insurance_class['LD_var'])) $smarty->assign('sBillTypeInput',$$insurance_class['LD_var']);
  280. else $smarty->assign('sBillTypeInput',$insurance_class['name']);
  281. $smarty->assign('LDInsuranceNr',$LDInsuranceNr);
  282. if(isset($insurance_nr)&&$insurance_nr) $smarty->assign('insurance_nr',$insurance_nr);
  283. $smarty->assign('LDInsuranceCo',$LDInsuranceCo);
  284. $smarty->assign('insurance_firm_name',$insurance_firm_name);
  285. $smarty->assign('LDFrom',$LDFrom);
  286. $smarty->assign('LDTo',$LDTo);
  287. if(!$GLOBAL_CONFIG['patient_service_care_hide'] && $sc_care_class_nr){
  288. $smarty->assign('LDCareServiceClass',$LDCareServiceClass);
  289. while($buffer=$care_service->FetchRow()){
  290. if($sc_care_class_nr==$buffer['class_nr']){
  291. if(empty($$buffer['LD_var'])) $smarty->assign('sCareServiceInput',$buffer['name']);
  292. else $smarty->assign('sCareServiceInput',$$buffer['LD_var']);
  293. break;
  294. }
  295. }
  296. if($sc_care_start && $sc_care_start != DBF_NODATE){
  297. $smarty->assign('sCSFromInput',' [ '.@formatDate2Local($sc_care_start,$date_format).' ] ');
  298. $smarty->assign('sCSToInput',' [ '.@formatDate2Local($sc_care_end,$date_format).' ]');
  299. }
  300. }
  301. if(!$GLOBAL_CONFIG['patient_service_room_hide'] && $sc_room_class_nr){
  302. $smarty->assign('LDRoomServiceClass',$LDRoomServiceClass);
  303. while($buffer=$room_service->FetchRow()){
  304. if($sc_room_class_nr==$buffer['class_nr']){
  305. if(empty($$buffer['LD_var'])) $smarty->assign('sCareRoomInput',$buffer['name']);
  306. else $smarty->assign('sCareRoomInput',$$buffer['LD_var']);
  307. break;
  308. }
  309. }
  310. if($sc_room_start && $sc_room_start != DBF_NODATE){
  311. $smarty->assign('sRSFromInput',' [ '.@formatDate2Local($sc_room_start,$date_format).' ] ');
  312. $smarty->assign('sRSToInput',' [ '.@formatDate2Local($sc_room_end,$date_format).' ]');
  313. }
  314. }
  315. if(!$GLOBAL_CONFIG['patient_service_att_dr_hide'] && $sc_att_dr_class_nr){
  316. $smarty->assign('LDAttDrServiceClass',$LDAttDrServiceClass);
  317. while($buffer=$att_dr_service->FetchRow()){
  318. if($sc_att_dr_class_nr==$buffer['class_nr']){
  319. if(empty($$buffer['LD_var'])) $smarty->assign('sCareDrInput',$buffer['name']);
  320. else $smarty->assign('sCareDrInput',$$buffer['LD_var']);
  321. break;
  322. }
  323. }
  324. if($sc_att_dr_start && $sc_att_dr_start != DBF_NODATE){
  325. $smarty->assign('sDSFromInput',' [ '.@formatDate2Local($sc_att_dr_start,$date_format).' ] ');
  326. $smarty->assign('sDSToInput',' [ '.@formatDate2Local($sc_att_dr_end,$date_format).' ]');
  327. }
  328. }
  329. //gjergji : billable items list
  330. if($GLOBAL_CONFIG['show_billable_items'] && $encounter_class_nr == 2){
  331. $smarty->assign('LDAdmitBillItem',$LDAdmitBillItem);
  332. if($att_bill_item = $eComBill_obj->checkBillExist($encounter_nr)) {
  333. $bufferBill=$att_bill_item->FetchRow();
  334. $smarty->assign('sAdmitBillItem',$bufferBill['bill_item_code']);
  335. } else {
  336. $smarty->assign('sAdmitBillItem',"----");
  337. }
  338. }
  339. //gjergji : refered to doctor
  340. if($GLOBAL_CONFIG['show_doctors_list'] && $encounter_class_nr == 2){
  341. $smarty->assign('LDAdmitDoctorRefered',$LDAdmitDoctorRefered);
  342. $bufferBill = $encounter_obj->ReferredDoctor($encounter_nr);
  343. if(!empty($bufferBill) && isset($bufferBill))
  344. $staffNr = $bufferBill->Fields("referred_dr");
  345. if($att_doctor = $staff_obj->_getstaffById($staffNr)) {
  346. //TODO : gjergji : change to list appointments by doctor...
  347. $smarty->assign('sAdmitDoctorRefered','<a href="'.$root_path.'modules/staff_admin/'.strtr('staff_register_show.php'.URL_APPEND.'&from=such&target=staff_search&staff_nr=' .$att_doctor->Fields("staff_nr") .'&sem=1',' ',' ').'">'.$att_doctor->Fields("name_first") . ' ' .$att_doctor->Fields("name_last") .'</a>');
  348. } else {
  349. $smarty->assign('sAdmitDoctorRefered',"----");
  350. }
  351. }
  352. //end gjergji : refered to doctor
  353. $smarty->assign('LDAdmitBy',$LDAdmitBy);
  354. if (empty($encoder)) $encoder = $_COOKIE[$local_user.$sid];
  355. $smarty->assign('encoder',$encoder);
  356. # Buffer the options block
  357. ob_start();
  358. require('./gui_bridge/default/gui_patient_encounter_showdata_options.php');
  359. $sTemp = ob_get_contents();
  360. ob_end_clean();
  361. $smarty->assign('sAdmitOptions',$sTemp);
  362. $sTemp = '';
  363. if(!$is_discharged){
  364. # Buffer the control buttons
  365. ob_start();
  366. include('./include/bottom_controls_admission.inc.php');
  367. $sTemp = ob_get_contents();
  368. ob_end_clean();
  369. $smarty->assign('sAdmitBottomControls',$sTemp);
  370. }
  371. $smarty->assign('pbBottomClose','<a href="'.$breakfile.'"><img '.createLDImgSrc($root_path,'close2.gif','0').' title="'.$LDCancel.'" align="absmiddle"></a>');
  372. $smarty->assign('sAdmitLink','<img '.createComIcon($root_path,'varrow.gif','0').'> <a href="admission_start.php'.URL_APPEND.'&mode=?">'.$LDAdmWantEntry.'</a>');
  373. $smarty->assign('sSearchLink','<img '.createComIcon($root_path,'varrow.gif','0').'> <a href="admission_data_search.php'.URL_APPEND.'">'.$LDAdmWantSearch.'</a>');
  374. $smarty->assign('sArchiveLink','<img '.createComIcon($root_path,'varrow.gif','0').'> <a href="admission_list.php'.URL_APPEND.'&newdata=1">'.$LDAdmWantArchive.'</a>');
  375. $smarty->assign('sMainBlockIncludeFile',__DIR__ . '/view/admit_show.tpl');
  376. $smarty->display(CARE_BASE . 'main/view/mainframe.tpl');
  377. ?>