3 define('LAB_MAX_DAY_DISPLAY',7); # define the max number or days displayed at one time
5 error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
);
6 require('./roots.php');
7 require($root_path.'include/inc_environment_global.php');
9 * CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10
10 * GNU General Public License
11 * Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
14 * See the file "copy_notice.txt" for the licence notice
17 $lang_tables=array('chemlab_groups.php','chemlab_params.php');
18 define('LANG_FILE','lab.php');
19 define('NO_2LEVEL_CHK',1);
20 require_once($root_path.'include/inc_front_chain_lang.php');
22 if($user_origin=='lab'||
$user_origin=='lab_mgmt'){
23 $local_user='ck_lab_user';
24 if(isset($from)&&$from=='input') $breakfile=$root_path.'modules/laboratory/labor_datalist_noedit.php'.URL_APPEND
.'&encounter_nr='.$encounter_nr.'&job_id='.$job_id.'¶meterselect='.$parameterselect.'&allow_update='.$allow_update.'&user_origin='.$user_origin.'&from=input';
25 else $breakfile=$root_path.'modules/laboratory/labor_datalist_noedit.php'.URL_APPEND
.'&encounter_nr='.$encounter_nr.'&user_origin='.$user_origin;
27 $local_user='ck_pflege_user';
28 $breakfile=$root_path.'modules/laboratory/labor_datalist_noedit.php'.URL_APPEND
.'&pn='.$encounter_nr.'&user_origin='.$user_origin.'&edit='.$edit;
31 if(!$HTTP_COOKIE_VARS[$local_user.$sid]) {header("Location:".$root_path."language/".$lang."/lang_".$lang."_invalid-access-warning.php"); exit;};
33 if(!$encounter_nr) header("location:".$root_path."modules/laboratory/labor_data_patient_such.php?sid=$sid&lang=$lang");
34 require_once($root_path.'include/inc_config_color.php');
36 $thisfile=basename(__FILE__
);
38 /* Create encounter object */
39 require_once($root_path.'include/care_api_classes/class_lab.php');
40 $enc_obj= new Encounter($encounter_nr);
41 $lab_obj=new Lab($encounter_nr);
44 //diff for the date of birth
45 function dateDiff($dformat, $endDate, $beginDate){
46 $date_parts1=explode($dformat, $beginDate);
47 $date_parts2=explode($dformat, $endDate);
48 $start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
49 $end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
50 return $end_date - $start_date;
53 //display the median values
54 function medianValue($paramValue,$pName){
57 $diff = dateDiff("-", date("Y-m-d"), $patient['date_birth']);
59 case ( ($diff >= 1) and ($diff <= 30 ) ) :
60 if($pName['lo_bound_n']!=null&&$pName['hi_bound_n']!=null) $txt.=htmlspecialchars($pName['hi_bound_n'])."<p><br>".htmlspecialchars($pName['lo_bound_n']);
62 case ( ($diff >= 31) and ($diff <= 360 ) ) :
63 if($pName['lo_bound__y']&&$pName['hi_bound_y']) $txt.=htmlspecialchars($pName['hi_bound_y'])."<p><br>".htmlspecialchars($pName['lo_bound_y']);
65 case ( $diff >= 361) and ($diff <= 5040 ) :
66 if($pName['lo_bound_c']&&$pName['hi_bound_c']) $txt.=htmlspecialchars($pName['hi_bound_c'])."<p><br>".htmlspecialchars($pName['lo_bound_c']);
69 if($patient['sex']=='m')
70 if($pName['lo_bound']&&$pName['hi_bound']) $txt.=htmlspecialchars($pName['hi_bound'])."<p><br>".htmlspecialchars($pName['lo_bound']);
71 elseif($patient['sex']=='f')
72 if($pName['lo_bound_f']&&$pName['hi_bound_f']) $txt.=htmlspecialchars($pName['hi_bound_f'])."<p><br>".htmlspecialchars($pName['lo_bound_f']);
80 function doGraph($paramValue,$pName,$valueBuff,$cols=1){
81 global $patient,$root_path,$sid,$lang,$sessbuf;
83 $diff = dateDiff("-", date("Y-m-d"), $patient['date_birth']);
85 case ( ($diff >= 1) and ($diff <= 30 ) ) :
86 echo $txt.'<img src="'.$root_path.'main/imgcreator/labor-datacurve.php?sid='.$sid.'&lang='.$lang.'&cols='.$cols.'&lo='.$pName['lo_bound_n'].'&hi='.$pName['hi_bound_n'].'&d='.$valueBuff.'" border=0>';
88 case ( ($diff >= 31) and ($diff <= 360 ) ) :
89 echo $txt.'<img src="'.$root_path.'main/imgcreator/labor-datacurve.php?sid='.$sid.'&lang='.$lang.'&cols='.$cols.'&lo='.$pName['lo_bound_y'].'&hi='.$pName['hi_bound_y'].'&d='.$valueBuff.'" border=0>';
91 case ( $diff >= 361) and ($diff <= 5040 ) :
92 echo $txt.'<img src="'.$root_path.'main/imgcreator/labor-datacurve.php?sid='.$sid.'&lang='.$lang.'&cols='.$cols.'&lo='.$pName['lo_bound_c'].'&hi='.$pName['hi_bound_c'].'&d='.$valueBuff.'" border=0>';
95 if($patient['sex']=='m')
96 echo $txt.'<img src="'.$root_path.'main/imgcreator/labor-datacurve.php?sid='.$sid.'&lang='.$lang.'&cols='.$cols.'&lo='.$pName['lo_bound'].'&hi='.$pName['hi_bound'].'&d='.$valueBuff.'" border=0>';
97 elseif($patient['sex']=='f')
98 echo $txt.'<img src="'.$root_path.'main/imgcreator/labor-datacurve.php?sid='.$sid.'&lang='.$lang.'&cols='.$cols.'&lo='.$pName['lo_bound_f'].'&hi='.$pName['hi_bound_f'].'&d='.$valueBuff.'" border=0>';
104 require($root_path.'include/inc_labor_param_group.php');
106 if($nostat) $ret=$root_path."modules/laboratory/labor_data_patient_such.php?sid=$sid&lang=$lang&versand=1&keyword=$pn";
107 else $ret=$root_path."modules/nursing/nursing-station-patientdaten.php?sid=$sid&lang=$lang&station=$station&pn=$pn";
109 # Load the date formatter
110 require_once($root_path.'include/inc_date_format_functions.php');
112 $enc_obj->setWhereCondition("encounter_nr='$encounter_nr'");
114 if($encounter=$enc_obj->getBasic4Data($encounter_nr)) {
116 $patient=$encounter->FetchRow();
118 $recs=&$lab_obj->getAllResults($encounter_nr);
120 if ($rows=$lab_obj->LastRecordCount()){
121 # Merge the records to common date key
124 while($buffer=$recs->FetchRow()){
125 $records[$buffer['job_id']]=unserialize($buffer['serial_value']);
126 $tdate[$buffer['job_id']]=&$buffer['test_date'];
127 $ttime[$buffer['job_id']]=&$buffer['test_time'];
130 //reverse date from past to current
131 //had to use $tdatePrint for the array_reverse() to work...
132 $tdatePrint = array_reverse($tdate,true);
133 $tdate = array_reverse($tdate);
134 $ttime = array_reverse($ttime);
135 $records = array_reverse($records,true);
137 if($nostat) header("location:".$root_path."modules/laboratory/labor-nodatafound.php?sid=$sid&lang=$lang&patnum=$pn&ln=$result[name]&fn=$result[vorname]&nodoc=labor");
138 else header("location:".$root_path."modules/nursing/nursing-station-patientdaten-nolabreport.php?sid=$sid&lang=$lang&edit=$edit&station=$station&pn=$pn&nodoc=labor&user_origin=$user_origin");
142 echo "<p>".$lab_obj->getLastQuery()."sql$LDDbNoRead";
146 # Start Smarty templating here
150 # Note: it is advisable to load this after the inc_front_chain_lang.php so
151 # that the smarty script can use the user configured template theme
153 require_once($root_path.'gui/smarty_template/smarty_care.class.php');
154 $smarty = new smarty_care('common');
157 $smarty->assign('sToolbarTitle',"$LDLabReport - $LDGraph");
159 # href for help button
160 $smarty->assign('pbHelp',"javascript:gethelp('lab_list.php','graph','','','$LDGraph')");
163 $smarty->assign('pbBack',FALSE);
165 # href for close button
166 $smarty->assign('breakfile',$breakfile);
169 $smarty->assign('sWindowTitle',"$LDLabReport - $LDGraph");
171 # collect extra javascript code
175 <style type
="text/css" name
="1">
176 .va12_n
{font
-family
:verdana
,arial
; font
-size
:12; color
:#000099}
177 .a10_b
{font
-family
:arial
; font
-size
:10; color
:#000000}
178 .a10_n
{font
-family
:arial
; font
-size
:10; color
:#000099}
179 .a12_b
{font
-family
:arial
; font
-size
:12; color
:#000000}
180 .j
{font
-family
:verdana
; font
-size
:12; color
:#000000}
185 $sTemp = ob_get_contents();
188 $smarty->append('JavaScript',$sTemp);
190 # Assign patient basic elements
191 $smarty->assign('LDCaseNr',$LDCaseNr);
192 $smarty->assign('LDLastName',$LDLastName);
193 $smarty->assign('LDName',$LDName);
194 $smarty->assign('LDBday',LDBday
);
196 # Assign patient basic data
197 $smarty->assign('encounter_nr',$encounter_nr);
198 $smarty->assign('sLastName',$patient['name_last']);
199 $smarty->assign('sName',$patient['name_first']);
200 $smarty->assign('sBday',formatDate2Local($patient['date_birth'],$date_format));
206 <form action="labor-data-makegraph.php" method="post" name="labdata">
207 <table border=0 cellpadding=0 cellspacing=1 class="frame">';
209 # Get the number of colums
210 $cols=sizeof($tdate);
212 <tr bgcolor="#dd0000" >
213 <td class="va12_n"><font color="#ffffff"> <b>'.$LDParameter.'</b>
215 <td class="j"><font color="#ffffff"> <b>'.$LDNormalValue.'</b> </td>
216 <td class="j"><font color="#ffffff"> <b>'.$LDMsrUnit.'</b> </td>';
217 while(list($x,$v)=each($tdatePrint))
219 <td class="a12_b"><font color="#ffffff" width="100px"> <b>'.formatDate2Local($v,$date_format).'<br> '.$x.'</b> </td>';
225 <tr bgcolor="#ffddee" >
226 <td class="va12_n"><font color="#ffffff"> </td>
227 <td class="va12_n"><font color="#ffffff"> </td>
228 <td class="j"><font color="#ffffff"> </td>';
231 while(list($x,$v)=each($ttime))
233 <td class="a12_b" width="100px"><font color="#0000cc"> <b>'.convertTimeToLocal($v).'</b> '.$LDOClock.' </td>';
239 # Prepare the graph values
240 $tparam=explode('~',$HTTP_POST_VARS['params']);
242 $requestData=array();
245 while (list($job_id,$paramgroupvalue)=each($records)) {
246 $jIDArray[] = $job_id;
247 while(list($paramgroup,$paramvalue)=each($paramgroupvalue)) {
248 $ext = substr(stristr($paramgroup, '__'), 2);
249 $requestData[$ext][$paramgroup][$job_id] = $paramvalue;
254 $class='wardlistrow1';
258 while (list($groupId,$paramEnc)=each($requestData)) {
260 $gName = $lab_obj->getGroupName($groupId) ;
261 echo "<tr><td class=\"va12_n\" colspan=\"".($cols +
3)."\"><b>" .$gName->fields
['name'] . "</b></td></tr>";
262 while (list($paramId,$encounterNr)=each($paramEnc)) {
263 $pName = $lab_obj->TestParamsDetails($paramId);
265 echo "<td class=\"" . $class ."\">" . $pName['name'] . "</td>";
266 echo "<td class=\"" . $class ."\">" . medianValue($paramValue,$pName) . "</td>";
267 echo "<td class=\"" . $class ."\">" . $pName['msr_unit'] . "</td>";
268 for($i=0;$i<count($jIDArray);$i++
) {
269 if(array_key_exists($jIDArray[$i],$encounterNr)) {
270 $valueBuff == '' ?
($valueBuff = $encounterNr[$jIDArray[$i]]) : ($valueBuff .= '~' . $encounterNr[$jIDArray[$i]]);
274 $valueBuff == '' ?
($valueBuff = '0') : ($valueBuff .= '~'.'0');
279 if($cols != $columns)
280 echo "<td align=\"right\" colspan=\"". ($cols - $columns) ."\" class=\"" . $class ."\"> </td>";
281 echo "<td align=\"right\" colspan=\"". $columns ."\" class=\"" . $class ."\">";
282 echo doGraph($paramValue,$pName,$valueBuff,$columns)."</td>";
285 $class=='wardlistrow1' ?
$class='wardlistrow2' : $class='wardlistrow1';
293 $sTemp = ob_get_contents();
296 $smarty->assign('sLabResultsGraphTable',$sTemp);
298 $smarty->assign('sClose','<a href="'.$breakfile.'"><img '.createLDImgSrc($root_path,'close2.gif','0','absmiddle').' alt="'.$LDClose.'"></a>');
300 # Assign the include file to main frame template
302 $smarty->assign('sMainBlockIncludeFile','laboratory/chemlab_data_results_graph.tpl');
307 $smarty->display('common/mainframe.tpl');