2 define('ROW_MAX',2); # define here the maximum number of rows for displaying the parameters
4 error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
);
5 require('./roots.php');
6 require($root_path.'include/inc_environment_global.php');
8 * CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10
9 * GNU General Public License
10 * Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
13 * See the file "copy_notice.txt" for the licence notice
15 //$lang_tables=array('chemlab_groups.php','chemlab_params.php');
16 define('LANG_FILE','lab.php');
17 $local_user='ck_lab_user';
18 require_once($root_path.'include/inc_front_chain_lang.php');
20 if(!$encounter_nr) {header('Location:'.$root_path.'language/'.$lang.'/lang_'.$lang.'_invalid-access-warning.php'); exit;};
22 if(!isset($user_origin)||
empty($user_origin)) $user_origin='lab';
24 # Create encounter object
25 require_once($root_path.'include/care_api_classes/class_encounter.php');
26 $encounter=new Encounter($encounter_nr);
30 $thisfile='labor_datainput.php';
33 require_once($root_path.'include/care_api_classes/class_lab.php');
34 $lab_obj=new Lab($encounter_nr);
36 # Load the date formatter
37 include_once($root_path.'include/inc_date_format_functions.php');
42 # Prepare parameter values and serialize
44 // chaged the serialization for the lab
45 while (list($z,$y)=each($HTTP_POST_VARS)) {
47 if($result_tests = $lab_obj->GetTestsToDo($job_id))
48 while($row_tests = $result_tests->FetchRow()) {
49 parse_str($row_tests['parameters'], $arr_tasks);
50 if(isset($arr_tasks[$z])&&!empty($arr_tasks[$z])){
56 $dbuf['group_id']=$parameterselect;
57 $dbuf['serial_value']=serialize($nbuf);
58 $dbuf['job_id']=$job_id;
59 $dbuf['encounter_nr']=$encounter_nr;
62 $dbuf['modify_id']=$HTTP_SESSION_VARS['sess_user_name'];
63 $dbuf['modify_time']=date('YmdHis');
65 # Recheck the date, ! bug pat $dbuf['modify_id']=$HTTP_SESSION_VARS['sess_user_name'];ch
66 if($HTTP_POST_VARS['std_date']==DBF_NODATE
) $dbuf['test_date']=date('Y-m-d');
68 $lab_obj->setDataArray($dbuf);
70 $lab_obj->setWhereCondition("batch_nr='$batch_nr'");
71 if($lab_obj->updateDataFromInternalArray($batch_nr)){
73 }else{echo "<p>".$lab_obj->getLastQuery()."$LDDbNoSave";}
77 # Hide old job record if it exists
78 $lab_obj->hideResultIfExists($encounter_nr,$job_id,$parameterselect);
79 # Convert date to standard format
81 if($HTTP_POST_VARS['std_date']==DBF_NODATE
) $dbuf['test_date']=date('Y-m-d');
82 else $dbuf['test_date']=$HTTP_POST_VARS['std_date'];
84 $dbuf['test_date']=formatDate2STD($HTTP_POST_VARS['test_date'],$date_format);
86 $dbuf['test_time']=date('H:i:s');
88 $dbuf['history']="Create ".date('Y-m-d H:i:s')." ".$HTTP_SESSION_VARS['sess_user_name']."\n";
89 $dbuf['create_id']=$HTTP_SESSION_VARS['sess_user_name'];
90 $dbuf['create_time']=date('YmdHis');
91 # Insert new job record
92 $lab_obj->setDataArray($dbuf);
93 if($lab_obj->insertDataFromInternalArray()){
94 //echo $sql." new insert <br>";
96 $pk_nr=$db->Insert_ID();
97 $batch_nr=$lab_obj->LastInsertPK('batch_nr',$pk_nr);
99 }else{echo "<p>".$lab_obj->getLastQuery()."$LDDbNoSave";}
102 # If save successful, jump to display values
104 include_once($root_path.'include/inc_visual_signalling_fx.php');
105 # Set the visual signal
106 setEventSignalColor($encounter_nr,SIGNAL_COLOR_DIAGNOSTICS_REPORT
);
107 header("location:$thisfile?sid=$sid&lang=$lang&saved=1&batch_nr=$batch_nr&encounter_nr=$encounter_nr&job_id=$job_id¶meterselect=$parameterselect&allow_update=1&user_origin=$user_origin");
109 # end of if(mode==save)
110 } else { #If mode is not "save" then get the basic personal data
112 # Create encounter object
113 //include_once($root_path.'include/care_api_classes/class_encounter.php');
114 $enc_obj=new Encounter($encounter_nr);
115 if($encounter=&$enc_obj->getBasic4Data($encounter_nr)){
116 $patient=$encounter->FetchRow();
118 # If previously saved, get the values
121 if($result=&$lab_obj->getBatchResult($batch_nr)){
122 $row=$result->FetchRow();
123 $pdata=unserialize($row['serial_value']);
126 if($result=&$lab_obj->getResult($job_id,$parameterselect)){
127 $row=$result->FetchRow();
128 $pdata=unserialize($row['serial_value']);
130 # disallow update if group does not exist yet
135 # Get the test test groups
136 $tgroups=&$lab_obj->TestActiveGroups();
137 # Get the test parameter values
138 //gjergji : take all the params for this group...
139 //$tparams=&$lab_obj->TestParams($parameterselect);
140 $tparams=&$lab_obj->TestParams();
142 # Set the return file
143 if(isset($job_id)&&$job_id){
144 switch($user_origin){
145 case 'lab_mgmt': $breakfile="labor_test_request_admin_chemlabor.php".URL_APPEND
."&pn=$encounter_nr&batch_nr=$job_id&user_origin=lab";
147 default: $breakfile="labor_data_check_arch.php".URL_APPEND
."&versand=1&encounter_nr=$encounter_nr";
150 $breakfile="labor_data_patient_such.php".URL_APPEND
."&mode=edit";
154 // echo "from table ".$linecount;
155 if($saved ||
$row['test_date']) $std_date=$row['test_date'];
158 if($update) $sTitle="$LDLabReport - $LDEdit";
159 else $sTitle= "$LDNew $LDLabReport";
161 # Start Smarty templating here
165 # Note: it is advisable to load this after the inc_front_chain_lang.php so
166 # that the smarty script can use the user configured template theme
168 require_once($root_path.'gui/smarty_template/smarty_care.class.php');
169 $smarty = new smarty_care('common');
172 $smarty->assign('sToolbarTitle',$sTitle);
174 # href for help button
175 $smarty->assign('pbHelp',"javascript:gethelp('lab.php','input','main','$job_id')");
178 $smarty->assign('pbBack',FALSE);
180 # href for close button
181 $smarty->assign('breakfile',$breakfile);
184 $smarty->assign('sWindowTitle',$sTitle);
186 # collect extra javascript code
190 <style type
="text/css" name
="1">
191 .va12_n
{font
-family
:verdana
,arial
; font
-size
:12; color
:#000099}
192 .a10_b
{font
-family
:arial
; font
-size
:10; color
:#000000}
193 .a10_n
{font
-family
:arial
; font
-size
:10; color
:#000099}
196 <script language
="javascript" name
="j1">
201 { alert("<?php echo $LDAlertJobId ?>");
208 if(!d
.test_date
.value
)
209 { alert("<?php echo $LDAlertTestDate ?>");
217 function chkselect(d
)
219 if(d
.parameterselect
.value
=="<?php echo $parameterselect ?>"){
223 function labReport(){
224 window
.location
.replace("<?php echo 'labor_datalist_noedit.php'.URL_REDIRECT_APPEND.'&encounter_nr='.$encounter_nr.'&noexpand=1&from=input&job_id='.$job_id.'¶meterselect='.$parameterselect.'&allow_update='.$allow_update.'&nostat=1&user_origin=lab'; ?>");
226 <?php
require($root_path.'include/inc_checkdate_lang.php'); ?
>
231 $sTemp = ob_get_contents();
234 $smarty->append('JavaScript',$sTemp);
235 //gjergji : new calendar
236 require_once ('../../js/jscalendar/calendar.php');
237 $calendar = new DHTML_Calendar('../../js/jscalendar/', $lang, 'calendar-system', true);
238 $calendar->load_files();
240 # Assign patient basic elements
241 $smarty->assign('LDCaseNr',$LDCaseNr);
242 $smarty->assign('LDLastName',$LDLastName);
243 $smarty->assign('LDName',$LDName);
244 $smarty->assign('LDBday',$LDBday);
245 $smarty->assign('LDJobIdNr',$LDJobIdNr);
246 $smarty->assign('LDExamDate',$LDExamDate);
248 # Assign patient basic data
249 $smarty->assign('encounter_nr',$encounter_nr);
250 $smarty->assign('sLastName',$patient['name_last']);
251 $smarty->assign('sName',$patient['name_first']);
252 $smarty->assign('sBday',formatDate2Local($patient['date_birth'],$date_format));
254 if($saved||
$job_id) $smarty->assign('sJobIdNr',$job_id.'<input type=hidden name=job_id value="'.$job_id.'">');
255 else $smarty->assign('sJobIdNr','<input name="job_id" type="text" size="14">');
257 $smarty->assign('sExamDate',$LDExamDate);
259 if($saved||
$row['test_date']||
$std_date){
260 $smarty->assign('sExamDate',formatDate2Local($std_date,$date_format).'<input type=hidden name="std_date" value="'.$std_date.'">');
262 //gjergji : new calendar
263 $smarty->assign('sMiniCalendar',$calendar->show_calendar($calendar,$date_format,'test_date'));
267 # Assign parameter elements
269 $smarty->assign('sParamGroup',strtr($parametergruppe[$parameterselect],"_","-"));
271 $smarty->assign('pbSave','<input type="image" '.createLDImgSrc($root_path,'savedisc.gif','0').'>');
272 $smarty->assign('pbShowReport','<a href="labor_datalist_noedit.php'.URL_APPEND
.'&encounter_nr='.$encounter_nr.'&noexpand=1&from=input&job_id='.$job_id.'¶meterselect='.$parameterselect.'&allow_update='.$allow_update.'&nostat=1&user_origin='.$user_origin.'"><img '.createLDImgSrc($root_path,'showreport.gif','0','absmiddle').' alt="'.$LDClk2See.'"></a>');
274 if($saved) $sCancelBut='<img '.createLDImgSrc($root_path,'close2.gif','0','absmiddle').'>';
275 else $sCancelBut='<img '.createLDImgSrc($root_path,'cancel.gif','0','absmiddle').'>';
277 $smarty->assign('pbCancel',"<a href=\"$breakfile\">$sCancelBut</a>");
279 $smarty->assign('sAskIcon',"<img ".createComIcon($root_path,'small_help.gif','0').">");
281 $smarty->assign('sFormAction',$thisfile);
283 # Buffer parameter items generation
288 <?php
if($error) : ?
>
290 <td colspan
=4><center
>
291 <font face
=arial color
=#7700ff size=4>
292 In
<font color
=red
>rot
</font
> gekennzeichnet
<?php
if ($errornum>1) echo "en"; else echo "em"; ?
> 
;
293 Feld
<?php
if ($errornum>1) echo "ern"; ?
> 
;
294 fehl
<?php
if ($errornum>1) echo "en"; else echo "t eine"; ?
> 
;
295 Information
<?php
if ($errornum>1) echo "en"; ?
>!
303 $paramnum=sizeof($parameters);
309 for($j=0;$j<$pcols;$j++
){
311 <td class="a10_n"> '.$LDParameter.'</td>
312 <td class="a10_n"> '.$LDValue.'</td>';
318 //order the params according to groups
320 $requestData=array();
321 if($result_tests = $lab_obj->GetTestsToDo($job_id)) {
322 if($row_tests = $result_tests->FetchRow()) {
323 parse_str($row_tests['parameters'], $arr_tasks);
324 while(list($x,$v)=each($arr_tasks)) {
326 $ext = substr(stristr($x, '__'), 2);
327 $requestData[$ext][$x] = 1;
332 //print_r($requestData);
338 while(list($group,$pm)=each($requestData)) {
339 $gName = $lab_obj->getGroupName($group ) ;
342 echo '<td bgcolor="#ffffee" class="a10_a"><nobr> <b>';
343 echo $gName->fields
['name'];
344 echo '</b> </nobr>';
347 while(list($pId,$not)=each($pm)) {
348 $pName = $lab_obj->TestParamsDetails($pId);
349 echo '<td bgcolor="#ffffee" class="a10_b">';
350 echo $pName['name'] . '</td>';
353 echo '<input name="'.$pId.'" type="text" size="8" ';
355 if(isset($pdata[$pId])&&!empty($pdata[$pId])) echo trim($pdata[$pId]);
368 # Assign parameter output
370 $sTemp = ob_get_contents();
373 $smarty->assign('sParameters',$sTemp);
375 # Collect hidden inputs for the parameters form
380 <input type
=hidden name
="encounter_nr" value
="<?php echo $encounter_nr; ?>">
381 <input type
=hidden name
="sid" value
="<?php echo $sid; ?>">
382 <input type
=hidden name
="lang" value
="<?php echo $lang; ?>">
383 <input type
=hidden name
="update" value
="<?php echo $update; ?>">
384 <input type
=hidden name
="allow_update" value
="<?php if(isset($allow_update)) echo $allow_update; ?>">
385 <input type
=hidden name
="batch_nr" value
="<?php if(isset($row['batch_nr'])) echo $row['batch_nr']; ?>">
386 <input type
=hidden name
="newid" value
="<?php echo $newid; ?>">
387 <input type
=hidden name
="user_origin" value
="<?php echo $user_origin; ?>">
388 <input type
=hidden name
="mode" value
="save">
391 $sTemp = ob_get_contents();
393 $smarty->assign('sSaveParamHiddenInputs',$sTemp);
395 # Collect hidden inputs for the parameter group selector
398 <input type
=hidden name
="encounter_nr" value
="<?php echo $encounter_nr; ?>">
399 <input type
=hidden name
="job_id" value
="<?php echo $job_id; ?>">
400 <input type
=hidden name
="sid" value
="<?php echo $sid; ?>">
401 <input type
=hidden name
="lang" value
="<?php echo $lang; ?>">
402 <input type
=hidden name
="update" value
="<?php echo $update; ?>">
403 <input type
=hidden name
="allow_update" value
="<?php if( isset($allow_update)) echo $allow_update; ?>">
404 <input type
=hidden name
="batch_nr" value
="<?php if(isset($row['batch_nr'])) echo $row['batch_nr']; ?>">
405 <input type
=hidden name
="newid" value
="<?php echo $newid; ?>">
406 <input type
=hidden name
="std_date" value
="<?php echo $std_date; ?>">
407 <input type
=hidden name
="user_origin" value
="<?php echo $user_origin; ?>">
408 <input type
=hidden name
="changegroup" value
="1">
409 <input type
=hidden name
="saved" value
="0">
412 $sTemp = ob_get_contents();
415 $smarty->assign('sSelectGroupHiddenInputs',$sTemp);
419 $smarty->assign('LDParamNoSee',"<a href=\"Javascript:gethelp('lab.php','input','param')\">$LDParamNoSee</a>");
420 $smarty->assign('LDOnlyPair',"<a href=\"Javascript:gethelp('lab.php','input','few')\">$LDOnlyPair</a>");
421 $smarty->assign('LDHow2Save',"<a href=\"Javascript:gethelp('lab.php','input','save')\">$LDHow2Save</a>");
422 $smarty->assign('LDWrongValueHow',"<a href=\"Javascript:gethelp('lab.php','input','correct')\">$LDWrongValueHow</a>");
423 $smarty->assign('LDVal2Note',"<a href=\"Javascript:gethelp('lab.php','input','note')\">$LDVal2Note</a>");
424 $smarty->assign('LDImDone',"<a href=\"Javascript:gethelp('lab.php','input','done')\">$LDImDone</a>");
426 # Assign the include file to mainframe
428 $smarty->assign('sMainBlockIncludeFile','laboratory/chemlab_data_results.tpl');
433 $smarty->display('common/mainframe.tpl');