Index: /trunk/Care2007/include/inc_vars_resolve.php
===================================================================
--- /trunk/Care2007/include/inc_vars_resolve.php (revision 6130)
+++ /trunk/Care2007/include/inc_vars_resolve.php (revision 6193)
@@ -123,4 +123,5 @@
 */
 
+
 //$HTTP_SESSION_VARS=&importGlobalVariable('session');
 
Index: /trunk/Care2007/include/inc_date_format_functions.php
===================================================================
--- /trunk/Care2007/include/inc_date_format_functions.php (revision 6130)
+++ /trunk/Care2007/include/inc_date_format_functions.php (revision 6193)
@@ -61,5 +61,5 @@
 * therefore a validation routine must be done at the client side
 */
-function formatDate2Local($stdDate, $localFormat, $retTime=FALSE, $timeOnly=FALSE)
+function formatDate2Local($stdDate, $localFormat, $retTime=FALSE, $timeOnly=FALSE, &$sepChars)
 {
    global $lang;
Index: /trunk/Care2007/include/inc_rightcolumn_menu.php
===================================================================
--- /trunk/Care2007/include/inc_rightcolumn_menu.php (revision 6130)
+++ /trunk/Care2007/include/inc_rightcolumn_menu.php (revision 6193)
@@ -16,12 +16,15 @@
 $url_mgmt="newscolumns.php".URL_APPEND."&dept_nr=28&user_origin=dept";
 $url_dept="".$root_path.'modules/news/'."departments.php".URL_APPEND;
-$url_cafe="http://www.paginesanitarie.com/skfarmaci/farmacialfaba.htm".URL_APPEND;
-$url_adm="http://www.paginesanitarie.com/glossarioa.htm".URL_APPEND;
-$url_exh="http://www.paginesanitarie.com/homeinformazione.htm".URL_APPEND;
-$url_tips="http://www.paginesanitarie.com/ticket.htm".URL_APPEND;
+$url_cafe="".$root_path.'modules/cafeteria/'."cafenews.php".URL_APPEND;
+$url_adm="newscolumns.php".URL_APPEND."&dept_nr=33&user_origin=dept";
+$url_exh="newscolumns.php".URL_APPEND."&dept_nr=29&user_origin=dept";
+$url_edu="newscolumns.php".URL_APPEND."&dept_nr=30&user_origin=dept";
+$url_stud="newscolumns.php".URL_APPEND."&dept_nr=31&user_origin=dept";
+$url_phys="newscolumns.php".URL_APPEND."&dept_nr=10&user_origin=dept";
+$url_tips="newscolumns.php".URL_APPEND."&dept_nr=32&user_origin=dept";
 $url_calendar=$root_path."modules/calendar/calendar.php".URL_APPEND."&retpath=home";
 $url_jshelp="javascript:gethelp()";
-
-
+$url_news="editor-pass.php".URL_APPEND;
+$url_jscredits="javascript:openCreditsWindow()";
 
 $TP_com_img_path=$root_path.'gui/img/common';
Index: /trunk/Care2007/include/inc_products_db_save_mod.php
===================================================================
--- /trunk/Care2007/include/inc_products_db_save_mod.php (revision 5995)
+++ /trunk/Care2007/include/inc_products_db_save_mod.php (revision 6193)
@@ -103,4 +103,5 @@
 							'picfile'=>$picfilename,
 							'packing'=>$pack,
+							'dose'=>$dose,
 							'minorder'=>$minorder,
 							'maxorder'=>$maxorder,
@@ -128,4 +129,5 @@
 							description='$besc',
 							packing='$pack',
+							dose='$dose',
 							minorder='$minorder',
 							maxorder='$maxorder',
Index: /trunk/Care2007/include/inc_test_request_printout_patho.php
===================================================================
--- /trunk/Care2007/include/inc_test_request_printout_patho.php (revision 6067)
+++ /trunk/Care2007/include/inc_test_request_printout_patho.php (revision 6193)
@@ -93,5 +93,5 @@
 
 if($stored_request['quick_diagnosis']) $smarty->assign('input_quick_diagnosis','<img '.createComIcon($root_path,'chkbox_chk.gif','0','absmiddle').'>');
-	else $smarty->assign('input_quick_diagnosis', '<img '.createComIcon($root_path,'chkbox_blk.gif','0','absmiddle').'>');
+else $smarty->assign('input_quick_diagnosis', '<img '.createComIcon($root_path,'chkbox_blk.gif','0','absmiddle').'>');
 
 $smarty->assign('LDSpeedTest',$LDSpeedTest);
Index: /trunk/Care2007/include/inc_db_makelink.php
===================================================================
--- /trunk/Care2007/include/inc_db_makelink.php (revision 5995)
+++ /trunk/Care2007/include/inc_db_makelink.php (revision 6193)
@@ -34,4 +34,5 @@
 # Set the "no-date" value based on the dbtype, Values defined at include/inc_environment_global.php
 switch($dbtype){
+	case 'mysqli':
 	case 'mysql':
                     $dbf_nodate=NODATE_MYSQL;
@@ -93,5 +94,5 @@
 
 # Set dbtype to mysql if not set or empty
-if(!isset($dbtype)||empty($dbtype)) $dbtype='mysql';
+if(!isset($dbtype)||empty($dbtype)) $dbtype='mysqli';
 
 # ADODB connection
Index: /trunk/Care2007/include/inc_visual_signalling_fx.php
===================================================================
--- /trunk/Care2007/include/inc_visual_signalling_fx.php (revision 6130)
+++ /trunk/Care2007/include/inc_visual_signalling_fx.php (revision 6193)
@@ -30,4 +30,6 @@
 define('SIGNAL_COLOR_DIAGNOSTICS_REQUEST','blue_pale');   // color to be set for signalling a diagnostic/consult request 
 
+define('SIGNAL_COLOR_BLOOD_REQUEST','red'); //color to be set for blood request / transfusion
+
 define('SIGNAL_COLOR_QUERY_DOCTOR','yellow');    // color to be set for signalling a query to the doctor
 define('SIGNAL_COLOR_DOCTOR_INFO','black');             // color to be set for signalling a doctor's instruction or answer
@@ -37,5 +39,5 @@
 define('SIGNAL_COLOR_DIURETIC','yellow_pale');             // color to be set for signalling the prescription of diuretics
 define('SIGNAL_COLOR_ANTICOAG','violet');             // color to be set for signalling the prescription of anticoagulants
-define('SIGNAL_COLOR_IV','pink');             // color to be set for signalling the prescription of anticoagulants
+define('SIGNAL_COLOR_IV','pink');             // color to be set for signalling the prescription of IV
 //gjergji :
 //pink modified to show the hour to do the prescription
@@ -55,4 +57,5 @@
    		if($ergebnis->RecordCount()){
    			$sql="UPDATE $event_table SET $color ='$status' WHERE encounter_nr=$pn";
+   			//echo $sql;
 			$db->Execute($sql);
 			if(!$db->Affected_Rows()){
Index: /trunk/Care2007/include/inc_init_main.php
===================================================================
--- /trunk/Care2007/include/inc_init_main.php (revision 6130)
+++ /trunk/Care2007/include/inc_init_main.php (revision 6193)
@@ -1,5 +1,5 @@
 <?php
 # This is the database name
-$dbname='';
+$dbname='care2x';
 
 # Database user name, default is root or httpd for mysql, or postgres for postgresql
@@ -13,11 +13,11 @@
 
 # First key used for simple chaining protection of scripts
-$key='563254446804';
+$key='780037249824';
 
 # Second key used for accessing modules
-$key_2level='2.92627035181E+013';
+$key_2level='25589275216800';
 
 # 3rd key for encrypting cookie information
-$key_login='2.23730670774E+013';
+$key_login='173730971606';
 
 # Main host address or domain
@@ -31,4 +31,4 @@
 
 # Set this to your database type. For details refer to ADODB manual or goto http://php.weblogs.com/ADODB/
-$dbtype='mysql';
+$dbtype='mysqli';
 ?>
Index: /trunk/Care2007/include/inc_test_findings_form_baclabor.php
===================================================================
--- /trunk/Care2007/include/inc_test_findings_form_baclabor.php (revision 6067)
+++ /trunk/Care2007/include/inc_test_findings_form_baclabor.php (revision 6193)
@@ -6,5 +6,5 @@
 if(file_exists($root_path.'language/'.$lang.'/lang_'.$lang.'_konsil_baclabor.php')) include_once($root_path.'language/'.$lang.'/lang_'.$lang.'_konsil_baclabor.php');
   else include_once($root_path.'language/'.LANG_DEFAULT.'/lang_'.LANG_DEFAULT.'_konsil_baclabor.php');
-?>
+  ?>
 
 <table>
@@ -42,5 +42,4 @@
 	   <tr>
 	   <td>';
-	   
 	   if($edit) echo '<a href="javascript:setM(\''.$x.'\')">';
 	   
@@ -64,5 +63,4 @@
 	   
 	   echo 'border=0 width=18 height=6 align="absmiddle" id="'.$x.'">';
-	   
 	   if($edit) echo '</a><input type="hidden" name="'.$x.'" value="'.$inp_v.'">';
 	   echo '</td>
@@ -157,5 +155,4 @@
 	     echo '<img src="b.gif" ';
 	   }
-	   
 	   echo 'border=0 width=18 height=6 align="absmiddle" id="'.$x4.'">';
 	   if($edit) echo '</a><input type="hidden" name="'.$x4.'" value="'.$inp_v.'">';
@@ -515,5 +512,5 @@
 	 	  <table border=0 class="lab" cellpadding=0 cellspacing=0 bgcolor="<?php echo $bgc1 ?>"> 	
 <?php
-   /* The 2nd column group of resistance test ANaerobes*/
+   /* The 2nd column group of resistance test Anaerobes*/
    	while(list($x,$v)=each($lab_ResistANaerobAcro))
 	{
@@ -562,5 +559,5 @@
 	 	  <table border=0 class="lab" cellpadding=0 cellspacing=0 bgcolor="<?php echo $bgc1 ?>"> 	
 <?php
-   /* The 3rd column group of resistance test ANaerobes*/
+   /* The 3rd column group of resistance test Anaerobes*/
    	while(list($x,$v)=each($lab_ResistANaerobAcro))
 	{
@@ -647,9 +644,10 @@
 	
 	echo $LDDate.'&nbsp;';
-	
     if($edit_findings)
 	 {
-	    if($stored_findings['rec_date'] && $stored_findings['rec_date']!='0000-00-00') $dateRec = formatDate2Local($stored_findings['rec_date'],$date_format);
-		  else $dateRec = formatDate2Local(date('Y-m-d'),$date_format);
+	    if($stored_findings['rec_date'] && $stored_findings['rec_date']!='0000-00-00')  //#147
+	    	$dateRec = $stored_findings['rec_date'];
+		else 
+			$dateRec = date('Y-m-d');
 		//gjergji : new calendar
 		require_once ('../../js/jscalendar/calendar.php');
@@ -659,7 +657,5 @@
 		echo $calendar->show_calendar($calendar,$date_format,'rec_date',$dateRec);
 		//end gjergji
-	 }
-	 else
-	 {
+	 } else { 
 	    if($stored_findings['rec_date']) echo  formatDate2Local($stored_findings['rec_date'],$date_format);
 	  }
Index: /trunk/Care2007/include/inc_environment_global.php
===================================================================
--- /trunk/Care2007/include/inc_environment_global.php (revision 6175)
+++ /trunk/Care2007/include/inc_environment_global.php (revision 6193)
@@ -4,5 +4,5 @@
 # define to 1 to measure page generation time
 #
-define('USE_PAGE_GEN_TIME',1);
+define('USE_PAGE_GEN_TIME',0);
 
 #
@@ -37,5 +37,5 @@
 # Define to TRUE for extended tabs mode
 #
-define('ADMISSION_EXT_TABS',FALSE);
+define('ADMISSION_EXT_TABS',TRUE);
 
 #
@@ -80,5 +80,5 @@
 	if(session_id()) session_destroy();
 	# Set sessions handler to "user"
-	ini_set('session.save_handler','user');
+	ini_set('session.save_handler','files');
 	# Set transparent session id
 	if(!ini_get('session.use_trans_sid')) ini_set('session.use_trans_sid',1);
Index: /trunk/Care2007/include/inc_front_chain_lang.php
===================================================================
--- /trunk/Care2007/include/inc_front_chain_lang.php (revision 5995)
+++ /trunk/Care2007/include/inc_front_chain_lang.php (revision 6193)
@@ -25,10 +25,8 @@
 # return = 1 if language table exists 
 
-function getLang($chk_file) 
-{
+function getLang($chk_file) {
    global $lang, $root_path, $sid;
    
-   if(!isset($lang)||empty($lang))
-   {
+   if(!isset($lang)||empty($lang))   {
 	  $ck_lang_buffer='ck_lang'.$sid;
       if(!isset($HTTP_COOKIE_VARS[$ck_lang_buffer])||empty($HTTP_COOKIE_VARS[$ck_lang_buffer])) include($root_path.'chklang.php');
Index: /trunk/Care2007/include/inc_test_request_lister_fx.php
===================================================================
--- /trunk/Care2007/include/inc_test_request_lister_fx.php (revision 6130)
+++ /trunk/Care2007/include/inc_test_request_lister_fx.php (revision 6193)
@@ -104,9 +104,9 @@
   	 $result=$enc_obj->encounter;
   	 //gjergji ... urgent is available only for chamlabor
-  	 //if($subtarget == trim('chemlabor') ) {
-	 // 	 $urgent = $lab_obj->GetTestUrgent($test_request['batch_nr']);
-	 // 	 $tmp = $urgent->FetchRow();
-	 // 	 if($tmp['urgent'] == 1) $bgcolor="red"; else $bgcolor = "#D3E3F6";
-  	 //}
+  	 if($subtarget == trim('chemlabor') ) {
+	  	 $urgent = $lab_obj->GetTestUrgent($test_request['batch_nr']);
+	  	 $tmp = $urgent->FetchRow();
+	  	 if($tmp['urgent'] == 1) $bgcolor="red"; else $bgcolor = "#D3E3F6";
+  	 }
   	 $info = $result['name_last']. " " . $result['name_first'] . "<br>" . $result['encounter_date'] . "<br>" . $result['pid'];
   } 
Index: /trunk/Care2007/include/inc_test_findings_form_patho.php
===================================================================
--- /trunk/Care2007/include/inc_test_findings_form_patho.php (revision 6067)
+++ /trunk/Care2007/include/inc_test_findings_form_patho.php (revision 6193)
@@ -1,25 +1,26 @@
 <?php
 
-function createDataBlock($param){
-    global $stored_findings, $edit;
+function createDataBlock ( $param ) {
+	global $stored_findings, $edit ;
 	
-	if ($edit){
+	if ($edit) {
 		echo '
-	 		<textarea name="'.$param.'" cols=82 rows=4 wrap="physical">'.stripslashes($stored_findings[$param]).'</textarea>';
-	}else{
+	 		<textarea name="' . $param . '" cols=82 rows=4 wrap="physical">' . stripslashes ( $stored_findings [ $param ] ) . '</textarea>' ;
+	} else {
 		echo '
-			<blockquote><font color="#000000" size=2>'.nl2br(stripslashes($stored_findings[$param])).'</font></blockquote>';
+			<blockquote><font color="#000000" size=2>' . nl2br ( stripslashes ( $stored_findings [ $param ] ) ) . '</font></blockquote>' ;
      }
 }
 
-function createInputBlock($param, $value){
-    global $stored_findings, $date_format, $edit, $lang;
+function createInputBlock ( $param , $value ) {
+	global $stored_findings, $date_format, $edit, $lang ;
 	
-	if ($edit){
-		echo '&nbsp;<input type="text" name="'.$param.'"  value="'.$value.'" size=';
-		if ($param=="doctor_id") echo '35 maxlength=35>';
-			else echo '10 maxlength=10 onBlur="IsValidDate(this,\''.$date_format.'\')"  onKeyUp="setDate(this,\''.$date_format.'\',\''. $lang.'\')">';
-	}else{
-		echo '&nbsp;<font color="#000000" size=2>'.$value.'</font><br>&nbsp;';
+	if ($edit) {
+		echo '&nbsp;<input type="text" name="' . $param . '"  value="' . $value . '" size=' ;
+		if ($param == "doctor_id")
+			echo '35 maxlength=35>' ; else
+			echo '10 maxlength=10 onBlur="IsValidDate(this,\'' . $date_format . '\')"  onKeyUp="setDate(this,\'' . $date_format . '\',\'' . $lang . '\')">' ;
+	} else {
+		echo '&nbsp;<font color="#000000" size=2>' . $value . '</font><br>&nbsp;' ;
      }
 }
@@ -27,30 +28,34 @@
 
 <table   cellpadding="0" cellspacing=1 border="0" width=700>
-	<tr  valign="top" bgcolor="<?php echo $bgc1 ?>">
-		<td width=35%><div class="fva2_ml10">
-		<font size=5 color="#0000ff">
-		<b><?php echo $LDTestFindings ?></b></font><br>
-	     <font size=3 color="#000099"><b><?php echo $formtitle ?></b></font><br>
-	     <font size=1 color="#000099"><?php echo $global_address[$subtarget].'<br>'.$LDTel.'&nbsp;'.$global_phone[$subtarget] ?></font>
+	<tr valign="top" bgcolor="<?php
+	echo $bgc1 ?>">
+		<td width=35%>
+		<div class="fva2_ml10"><font size=5 color="#0000ff"> <b><?php
+		echo $LDTestFindings ?></b></font><br>
+		<font size=3 color="#000099"><b><?php
+		echo $formtitle ?></b></font><br>
+		<font size=1 color="#000099"><?php
+		echo $global_address [ $subtarget ] . '<br>' . $LDTel . '&nbsp;' . $global_phone [ $subtarget ] ?></font>
+		
 	   </td> 
-		<td align="right" width=65%>
-		 <font size=1 color="#000099">
+		<td align="right" width=65%><font size=1 color="#000099">
 	    <?php 
-	      echo $batch_nr.'&nbsp;&nbsp;<br>';
-          echo "<img src='".$root_path."classes/barcode/image.php?code=$batch_nr&style=68&type=I25&width=145&height=40&xres=2&font=5' border=0>";
+					echo $batch_nr . '&nbsp;&nbsp;<br>' ;
+					echo "<img src='" . $root_path . "classes/barcode/image.php?code=$batch_nr&style=68&type=I25&width=145&height=40&xres=2&font=5' border=0>" ;
          ?>&nbsp;&nbsp;<br>
 		 <?php 
 		     
-			 echo $LDEntryDate.'&nbsp;&nbsp;<br>';
-			 if($entry_date!="0000-00-00")   echo formatDate2Local($entry_date,$date_format);
+			echo $LDEntryDate . '&nbsp;&nbsp;<br>' ;
+			if ($entry_date != "0000-00-00")
+				echo formatDate2Local ( $entry_date, $date_format ) ;
 			 
-		  ?>&nbsp;&nbsp;</font>
-		</td>
+			?>&nbsp;&nbsp;</font></td>
 	</tr>
 
-	<tr bgcolor="<?php echo $bgc1 ?>">
+	<tr bgcolor="<?php
+	echo $bgc1 ?>">
 		<td  valign="top" align="right"><font color="#000099" size=2>
 		<?php
-		  echo $LDCaseNr.'<br>'.$LDFamilyName.'<br>'.$LDName.'<br>'.$LDBDay;
+		echo $LDCaseNr . '<br>' . $LDFamilyName . '<br>' . $LDName . '<br>' . $LDBDay ;
 		 ?>
         </td>
@@ -58,5 +63,5 @@
 		<div class="fva0_ml10"><font color="#000000" size=2>
 		<?php
-		   echo $full_en.'<br>'.$result['name_last'].'<br>'.$result['name_first'].'<br>'.formatDate2Local($result['date_birth'],$date_format);
+		echo $full_en . '<br>' . $result [ 'name_last' ] . '<br>' . $result [ 'name_first' ] . '<br>' . formatDate2Local ( $result [ 'date_birth' ], $date_format ) ;
 		 ?>
 		 </div>
@@ -64,67 +69,95 @@
 	</tr>
 
-	<tr bgcolor="<?php echo $bgc1 ?>">
-		<td  valign="top" colspan=2><div class="fva0_ml10"><font color="#000099">
-		<?php echo $LDMaterial ?><br>
-		<?php createDataBlock('material') ?>
+	<tr bgcolor="<?php
+	echo $bgc1 ?>">
+		<td valign="top" colspan=2>
+		<div class="fva0_ml10"><font color="#000099">
+		<?php
+		echo $LDMaterial ?><br>
+		<?php
+		createDataBlock ( 'material' ) ?>
 		</div>
 		</td>
 	</tr>
 
-	<tr bgcolor="<?php echo $bgc1 ?>">
-		<td  valign="top" colspan=2 ><div class=fva0_ml10><font color="#000099">
-		<?php echo $LDMACROFindings ?><br>
-		<?php createDataBlock('macro') ?>
+	<tr bgcolor="<?php
+	echo $bgc1 ?>">
+		<td valign="top" colspan=2>
+		<div class=fva0_ml10><font color="#000099">
+		<?php
+		echo $LDMACROFindings ?><br>
+		<?php
+		createDataBlock ( 'macro' ) ?>
 		</div>
 		</td>
 	</tr>
 
-	<tr bgcolor="<?php echo $bgc1 ?>">
-		<td  valign="top" colspan=2 ><div class=fva0_ml10><font color="#000099">
-		<?php echo $LDMicroFindings ?><br>
-		<?php createDataBlock('micro') ?>
+	<tr bgcolor="<?php
+	echo $bgc1 ?>">
+		<td valign="top" colspan=2>
+		<div class=fva0_ml10><font color="#000099">
+		<?php
+		echo $LDMicroFindings ?><br>
+		<?php
+		createDataBlock ( 'micro' ) ?>
 		</div>
 		</td>
 	</tr>
 
-	<tr bgcolor="<?php echo $bgc1 ?>">
-		<td  valign="top" colspan=2 ><div class=fva0_ml10><font color="#000099">
-		<?php echo $LDAddFindings ?><br>
-		<?php createDataBlock('findings') ?>
+	<tr bgcolor="<?php
+	echo $bgc1 ?>">
+		<td valign="top" colspan=2>
+		<div class=fva0_ml10><font color="#000099">
+		<?php
+		echo $LDAddFindings ?><br>
+		<?php
+		createDataBlock ( 'findings' ) ?>
 		</div>
 		</td>
 	</tr>
 
-	<tr bgcolor="<?php echo $bgc1 ?>">
-		<td  valign="top" colspan=2 ><div class=fva0_ml10><font color="#000099">
-		<?php echo $LDDiagnosis ?><br>
-		<?php createDataBlock('diagnosis') ?>
+	<tr bgcolor="<?php
+	echo $bgc1 ?>">
+		<td valign="top" colspan=2>
+		<div class=fva0_ml10><font color="#000099">
+		<?php
+		echo $LDDiagnosis ?><br>
+		<?php
+		createDataBlock ( 'diagnosis' ) ?>
 		</div>
 		</td>
 	</tr>
-
-	<tr bgcolor="<?php echo $bgc1 ?>">
-		<td ><div class=fva2_ml10><font color="#000099">
-		 <?php echo $LDDate ?>:
+<?php
+//#170
+//gjergji : new calendar
+require_once ('../../js/jscalendar/calendar.php');
+$calendar = new DHTML_Calendar('../../js/jscalendar/', $lang, 'calendar-system', true);
+$calendar->load_files();
+//end gjergji
+?>
+	<tr bgcolor="<?php
+	echo $bgc1 ?>">
+		<td>
+		<div class=fva2_ml10><font color="#000099">
 		 <?php
-
-		     //$fdate=formatDate2Local($stored_findings['findings_date'],$date_format);
-
-			//createInputBlock('findings_date',$fdate);
-
-			if($edit){
+			echo $LDDate ?>:
+		 <?php
+			//#170
 				//gjergji : new calendar
-				require_once ('../../js/jscalendar/calendar.php');
-				$calendar = new DHTML_Calendar('../../js/jscalendar/', $lang, 'calendar-system', true);
-				$calendar->load_files();
-		
-				echo $calendar->show_calendar($calendar,$date_format,'findings_date',$stored_findings['findings_date']);
-				//end gjergji
+			if ($edit) {
+				echo $calendar->show_calendar($calendar,$date_format,'findings_date',$stored_findings ['findings_date']);
+			} else {
+				echo @formatDate2Local($stored_findings ['findings_date'],$date_format) ;
 		  }
 		  ?>
-            </div></td>
-			<td align="right"><div class=fva2_ml10><font color="#000099">
-		<?php echo $LDReportingDoc ?>:
-		<?php createInputBlock('doctor_id',$stored_findings['doctor_id']); ?>
+            </div>
+		</td>
+		<td align="right">
+		<div class=fva2_ml10><font color="#000099">
+		<?php
+		echo $LDReportingDoc ?>:
+		<?php
+		createInputBlock ( 'doctor_id', $stored_findings [ 'doctor_id' ] ) ;
+		?>
         &nbsp;&nbsp;
 		</div>
Index: /trunk/Care2007/include/care_api_classes/class_diagnostics.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_diagnostics.php (revision 5995)
+++ /trunk/Care2007/include/care_api_classes/class_diagnostics.php (revision 6193)
@@ -22,8 +22,28 @@
     var $tb_req_chem='care_test_request_chemlabor';
 	/**
+	* Table name for chemical lab test request lab parameters
+	* @var string
+	*/
+    var $tb_req_chem_sub='care_test_request_chemlabor_sub';
+	/**
 	* Table name for bacteriology lab test request
 	* @var string
 	*/
     var $tb_req_bac='care_test_request_baclabor';
+	/**
+	* Table name for bacteriology lab test findings
+	* @var string
+	*/
+    var $tb_find_bac_sub='care_test_findings_baclabor_sub';
+	/**
+	* Table name for bacteriology lab test findings
+	* @var string
+	*/
+    var $tb_find_bac='care_test_findings_baclabor';
+	/**
+	* Table name for bacteriology lab test request
+	* @var string
+	*/
+    var $tb_req_bac_sub='care_test_request_baclabor_sub';
 	/**
 	* Table name for blood bank request
@@ -67,4 +87,81 @@
 									'sample_weekday',
 									'status',
+							'urgent',
+							'history',
+							'modify_id',
+							'modify_time',
+							'create_id',
+							'create_time');
+	/**
+	* Field names of care_test_request_chemlabor_sub
+	* @var array
+	*/
+	var $chemlabor_sub=array('batch_nr',
+							'encounter_nr',
+							'paramater_name',
+							'parameter_value');
+	
+	/**
+	* Field names of care_test_request_baclabor
+	* @var array
+	*/
+	var $baclabor=array('batch_nr',
+							'encounter_nr',
+							'dept_nr',
+							'material',
+							'test_type',
+							'material_note',
+							'diagnosis_note',
+							'immune_supp',
+							'send_date',
+							'sample_date',
+							'status',
+							'history',
+							'create_id',
+							'create_time');	
+	/**
+	* Field names of care_test_request_baclabor_sub
+	* @var array
+	*/
+	var $baclabor_sub=array('batch_nr',
+							'encounter_nr',
+							'test_type',
+							'test_type_value',
+							'material',
+							'material_value');
+	/**
+	* Field names of care_test_findings_baclabor
+	* @var array
+	*/
+	var $baclaborFindings=array('batch_nr',
+							'encounter_nr',
+							'room_nr',
+							'dept_nr',
+							'notes',
+							'findings_init',
+							'findings_current',
+							'findings_final',
+							'entry_nr',
+							'rec_date',
+							'doctor_id',
+							'status',
+							'history',
+							'modify_id',
+							'modify_time',
+							'create_id',
+							'create_time');
+	/**
+	* Field names of care_test_findings_baclabor_sub
+	* @var array
+	*/
+	var $baclaborFindings_sub=array('batch_nr',
+							'encounter_nr',
+							'type_general',
+							'resist_anaerob',
+							'resist_aerob',
+							'findings',
+							'findings_date',
+							'findings_time',
+							'status',
 									'history',
 									'modify_id',
@@ -80,4 +177,48 @@
 		$this->setRefArray($this->chemlabor);
 	}			
+	
+	/**
+	* Sets the core to point to the care_test_request_chemlabor_sub table
+	* @access public
+	*/
+	function useChemLabRequestSubTable(){
+		$this->setTable($this->tb_req_chem_sub);
+		$this->setRefArray($this->chemlabor_sub);
+	}
+	/**
+	* Sets the core to point to the care_test_request_baclabor table
+	* @access public
+	*/
+	function useBacLabRequestTable(){
+		$this->setTable($this->tb_req_bac);
+		$this->setRefArray($this->baclabor);
+	}
+	
+	/**
+	* Sets the core to point to the care_test_request_baclabor_sub table
+	* @access public
+	*/
+	function useBacLabRequestSubTable(){
+		$this->setTable($this->tb_req_bac_sub);
+		$this->setRefArray($this->baclabor_sub);
+	}
+	/**
+	* Sets the core to point to the care_test_findings_baclabor table
+	* @access public
+	*/
+	function useBacLabFindingsTable(){
+		$this->setTable($this->tb_find_bac);
+		$this->setRefArray($this->baclaborFindings);
+	}
+	
+	/**
+	* Sets the core to point to the care_test_findings_baclabor_sub table
+	* @access public
+	*/
+	function useBacLabFindingsSubTable(){
+		$this->setTable($this->tb_find_bac_sub);
+		$this->setRefArray($this->baclaborFindings_sub);
+	}
+	
 	/**
 	* Sets the core to point to the a care_test_request_????? table.
Index: /trunk/Care2007/include/care_api_classes/class_gui_person_show.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_gui_person_show.php (revision 6130)
+++ /trunk/Care2007/include/care_api_classes/class_gui_person_show.php (revision 6193)
@@ -4,6 +4,4 @@
 */
 
-/**
-*/
 /**
 *  GUI person registration data show methods.
@@ -23,5 +21,5 @@
 	# Language files to be loaded
 	var $langfiles=array('prompt.php','person.php','aufnahme.php');
-
+	
 	# Filename of script to run in fallback state (when something goes wrong)
 	var $fallbackfile = '';
@@ -36,8 +34,8 @@
 	# The text holder in front of output block
 	var $pretext='';
-
+	
 	# The text holder after the output block
 	var $posttext='';
-
+	
 	# Current encounter number
 	var $current_encounter=0;
@@ -62,6 +60,6 @@
 	
 	/**
-	* Constructor
-	*/
+	 * Constructor
+	 */
 	function GuiPersonShow($pid=0, $filename='', $fallbackfile=''){
 		global $thisfile, $root_path;
@@ -80,12 +78,12 @@
 	}
 	/**
-	* Sets the file name of the script to run when something goes wrong
-	*/
+	 * Sets the file name of the script to run when something goes wrong
+	 */
 	function setFallbackFile($target){
 		$this->fallbackfile = $target;
 	}
 	/**
-	* Sets the PID value
-	*/
+	 * Sets the PID value
+	 */
 	function setPID($nr){
 		$this->pid = $nr;
@@ -94,6 +92,6 @@
 	}
 	/**
-	* Returns the death data
-	*/
+	 * Returns the death data
+	 */
 	function DeathDate(){
 		if($this->data['death_date']) return $this->data['death_date'];
@@ -101,6 +99,6 @@
 	}
 	/**
-	*  Gets the encounter number if person is currently admitted
-	*/
+	 *  Gets the encounter number if person is currently admitted
+	 */
 	function CurrentEncounter(){
 		global $root_path;
@@ -112,9 +110,9 @@
 	}
 	/**
-	* (pre)Loads the person registration data.
-	*
-	* Can be checked if data is loaded with the $this->is_loaded variable
-	* @access private
-	*/
+	 * (pre)Loads the person registration data.
+	 *
+	 * Can be checked if data is loaded with the $this->is_loaded variable
+	 * @access private
+	 */
 	function _load(){
 		if($this->data_obj=&$this->person_obj->getAllInfoObject()){
@@ -126,8 +124,8 @@
 	}
 	/**
-	* Function to generate demographic data dynamically depending on the global config
-	*/
+	 * Function to generate demographic data dynamically depending on the global config
+	 */
 	function createTR($ld_text, $input_val, $colspan = 1, $vidata = FALSE){
-
+		
 		ob_start();
 			if($vidata) $input_val="<div class=\"vi_data\">$input_val</div>";
@@ -139,7 +137,7 @@
 			$sBuffer = ob_get_contents();
 		ob_end_clean();
-
+		
 		//$this->toggle=!$this->toggle;
-
+		
 		return $sBuffer;
 /*
@@ -151,37 +149,37 @@
 			</tr>';*/
 	}
-
-	/**
-	* Displays the GUI showing the data
-	*/
+	
+	/**
+	 * Displays the GUI showing the data
+	 */
 	function display($pid=0){
 		global $HTTP_SESSION_VARS, $root_path, $dbf_nodate, $newdata, $kb_other_his_array, $lang;
-
+		
 		$validdata = TRUE;
-
+		
 		if(!empty($pid)) $this->pid=$pid;
-
+			
 		# Load the language tables
 		$lang_tables =$this->langfiles;
 		include($root_path.'include/inc_load_lang_tables.php');
-
+		
 		# Load the other hospitals array
 		include_once($root_path.'global_conf/other_hospitals.php');
-
+		
 		include_once($root_path.'include/inc_date_format_functions.php');
-
+		
 		include_once($root_path.'include/care_api_classes/class_insurance.php');
 		$pinsure_obj=new PersonInsurance($this->pid);
-
+		
 		# Get the global config for personŽs registration form
 		include_once($root_path.'include/care_api_classes/class_globalconfig.php');
-
+		
 		$GLOBAL_CONFIG = array();
-
+		
 		$glob_obj=new GlobalConfig($GLOBAL_CONFIG);
 		$glob_obj->getConfig('person_%');
-
+		
 		//extract($GLOBAL_CONFIG);
-
+		
 		if(empty($this->pid)) {
 			
@@ -189,13 +187,13 @@
 		
 		}else{
-
+			
 			//if($data_obj=&$this->person_obj->getAllInfoObject()){
 			//	$this->data=$data_obj->FetchRow();
 			if($this->is_loaded){
 				extract($this->data);
-
+				
 				# Get related insurance data
 				$p_insurance=&$pinsure_obj->getPersonInsuranceObject($this->pid);
-
+				
 				if($p_insurance==FALSE) {
 					$insurance_show=true;
@@ -206,5 +204,5 @@
 						$buffer= $p_insurance->FetchRow();
 						extract($buffer);
-
+						
 						$insurance_show=true;
 						# Get insurace firm name
@@ -218,40 +216,40 @@
 				# Check if person is currently admitted
 				$this->current_encounter=$this->person_obj->CurrentEncounter($this->pid);
-
+				
 				# update the recordŽs history
 				if(empty($newdata)) @$this->person_obj->setHistorySeen($HTTP_SESSION_VARS['sess_user_name']);
-			
+					
 				# Check whether config foto path exists, else use default path
 				$photo_path = (is_dir($root_path.$GLOBAL_CONFIG['person_foto_path'])) ? $GLOBAL_CONFIG['person_foto_path'] : $this->default_photo_path;
-
+			
 			}else{
 				$validdata = FALSE;
 			}
-
-		}
-
+		
+		}
+		
 		if($validdata){
-
+			
 		include_once($root_path.'include/inc_photo_filename_resolve.php');
-
-		############ Here starts the GUI output ##################
-
-		# Start Smarty templating here
-		# Create smarty object without initiliazing the GUI (2nd param = FALSE)
-
+			
+			############ Here starts the GUI output ##################
+			
+			# Start Smarty templating here
+			# Create smarty object without initiliazing the GUI (2nd param = FALSE)
+			
 		include_once($root_path.'gui/smarty_template/smarty_care.class.php');
 		$this->smarty = new smarty_care('common',FALSE);
-		
-		# Set from width
+			
+			# Set from width
 		$this->smarty->assign('sFormWidth','width="100%"');
-
+			
 		$img_male=createComIcon($root_path,'spm.gif','0');
 		$img_female=createComIcon($root_path,'spf.gif','0');
-
+			
 		if(!empty($this->pretext)) $this->smarty->assign('pretext',$this->pretext);
-
+			
 		$this->smarty->assign('LDRegistryNr',$LDRegistryNr);
 		$this->smarty->assign('pid',$pid);
-
+			
 		if(file_exists($root_path.'cache/barcodes/pn_'.$pid.'.png')){
 			$this->smarty->assign('sBarcodeImg','<img src="'.$root_path.'cache/barcodes/pn_'.$pid.'.png" border=0 width=180 height=35>');
@@ -259,26 +257,32 @@
 			$this->smarty->assign('sBarcodeImg',"<img src='".$root_path."classes/barcode/image.php?code=".$pid."&style=68&type=I25&width=180&height=50&xres=2&font=5&label=2&form_file=pn' border=0 width=0 height=0>");
 			$this->smarty->assign('sBarcodeImg',"<img src='".$root_path."classes/barcode/image.php?code=".$pid."&style=68&type=I25&width=180&height=50&xres=2&font=5' border=0 width=180  height=35>");
-		}
-
+			}
+			
 		$this->smarty->assign('img_source',$img_source);
-		
-		# iRowSpanCount counts the rows on the left of the photo image. Begin with 5 because there are 5 static rows.
-		$iRowSpanCount = 5;
-
+			
+			//gjergji
+		if ($photo_filename=='' || $photo_filename=='nopic' || !file_exists($root_path.$photo_path.'/'.$photo_filename)){
+			$this->smarty->assign('sFileBrowserInput','<input name="photo_filename" type="file" size="15"   onChange="showpic(this)" value="'.$pfile.'">');
+			}
+			//end : gjergji
+			
+			# iRowSpanCount counts the rows on the left of the photo image. Begin with 5 because there are 5 static rows.
+			$iRowSpanCount = 5;
+			
 		$this->smarty->assign('LDRegDate',$LDRegDate);
 		$this->smarty->assign('sRegDate',@formatDate2Local($date_reg,$date_format).'<input name="date_reg" type="hidden" value="'.$date_reg.'"');
-
-		//$iRowSpanCount++;
+			
+			//$iRowSpanCount++;
 		$this->smarty->assign('LDRegTime',$LDRegTime);
 		$this->smarty->assign('sRegTime',convertTimeToLocal(@formatDate2Local($date_reg,$date_format,0,1)));
-
+			
 		if (!$GLOBAL_CONFIG['person_title_hide']){
 			$this->smarty->assign('sPersonTitle',$this->createTR( $LDTitle, $title));
 			$iRowSpanCount++;
-		}
-
+			}
+			
 		$this->smarty->assign('sNameLast',$this->createTR($LDLastName,$name_last,1,TRUE));
-		//$iRowSpanCount++;
-
+			//$iRowSpanCount++;
+			
 		# If person is dead show a black cross
 		if($death_date&&$death_date!=$dbf_nodate) $sCross = '&nbsp;<img '.createComIcon($root_path,'blackcross_sm.gif','0','',TRUE).'>';
@@ -306,32 +310,32 @@
 			$this->smarty->assign('sNameOthers',$this->createTR($LDNameOthers,$name_others));
 			$iRowSpanCount++;
-		}
-		
-		# Set the rowspan value for the photo image <td>
+			}
+			
+			# Set the rowspan value for the photo image <td>
 		$this->smarty->assign('sPicTdRowSpan',"rowspan=$iRowSpanCount");
-
-		$this->smarty->assign('LDBday',"$LDBday");
-
+			
+		$this->smarty->assign('LDBday',"$LDBday:");
+			
 		if($death_date&&$death_date!=$dbf_nodate){
 			$this->smarty->assign('sCrossImg',$sCross);
 			$this->smarty->assign('sDeathDate','<font color="#000000">'.@formatDate2Local($death_date,$date_format).'</font>');
-		}
+			}
 		$this->smarty->assign('sBdayInput','<div class="vi_data">'.@formatDate2Local($date_birth,$date_format).'</div>');
-		
-		$this->smarty->assign('LDSex', "$LDSex");
-
+			
+		$this->smarty->assign('LDSex', "$LDSex:");
+			
 		if($sex=="m") $this->smarty->assign('LDMale','<div class="vi_data">'.$LDMale.'</div>');
 			elseif($sex=="f") $this->smarty->assign('LDFemale','<div class="vi_data">'.$LDFemale.'</div>');
-
+			
 		if (!$GLOBAL_CONFIG['person_bloodgroup_hide'] && trim($blood_group)) {
-			// KB: make blood group hideable
+				// KB: make blood group hideable
 			$this->smarty->assign('LDBloodGroup',$LDBloodGroup);
 			$buf='LD'.trim($blood_group);
 			$this->smarty->assign('sBGAInput',$$buf);
-		}
-
+			}
+			
 		if (!$GLOBAL_CONFIG['person_civilstatus_hide'] && trim($civil_status)) {
 			$this->smarty->assign('LDCivilStatus',$LDCivilStatus);
-
+				
 			if($civil_status=="single") $sCSBuffer =  $LDSingle;
 				elseif($civil_status=="married") $sCSBuffer =  $LDMarried;
@@ -339,106 +343,106 @@
 						elseif($civil_status=="widowed") $sCSBuffer = $LDWidowed;
 							elseif($civil_status=="separated") $sCSBuffer =  $LDSeparated;
-
+				
 			$this->smarty->assign('sCSSingleInput',$sCSBuffer);
-		}
-		
-		$this->smarty->assign('LDAddress',"$LDAddress");
-
-		$this->smarty->assign('LDStreet',"$LDStreet");
-
+			}
+			
+		$this->smarty->assign('LDAddress',"$LDAddress:");
+			
+		$this->smarty->assign('LDStreet',"$LDStreet:");
+			
 		$this->smarty->assign('sStreetInput',$addr_str);
-
-		$this->smarty->assign('LDStreetNr',"$LDStreetNr");
-
+			
+		$this->smarty->assign('LDStreetNr',"$LDStreetNr:");
+			
 		$this->smarty->assign('sStreetNrInput',$addr_str_nr);
-
-		$this->smarty->assign('LDTownCity',"$LDTownCity");
+			
+		$this->smarty->assign('LDTownCity',"$LDTownCity:");
 		$this->smarty->assign('sTownCityInput',$addr_citytown_name);
 
-		$this->smarty->assign('LDZipCode',"$LDZipCode ");
+		$this->smarty->assign('LDZipCode',"$LDZipCode :");
 		$this->smarty->assign('sZipCodeInput',$addr_zip);
-
+			
 		if (!$GLOBAL_CONFIG['person_insurance_hide']) {
 			if (!$GLOBAL_CONFIG['person_insurance_1_nr_hide']&&$insurance_show&&$insurance_nr){
-				
+			
 				$this->smarty->assign('bShowInsurance',TRUE);
-
+					
 				$this->smarty->assign('sInsuranceNr',$this->createTR($LDInsuranceNr,$insurance_nr,2));
-
+					
 				$buffer=$insurance_class_info['LD_var'];
 				if(isset($$buffer)&&!empty($$buffer)) $this->smarty->append('sInsClasses',$$buffer);
     				else $this->smarty->append('sInsClasses',$insurance_class_info['name']);
-
+					
 				$this->smarty->assign('LDInsuranceCo',$LDInsuranceCo);
 				$this->smarty->assign('sInsCoNameInput',$insurance_firm_name);
-
+					
 				$this->createTR($LDInsuranceCo.' 1',$insurance_firm_name,2);
-			}
-		}
+				}
+			}
 		if (!$GLOBAL_CONFIG['person_phone_1_nr_hide']&&$phone_1_nr){
 			$this->smarty->assign('sPhone1',$this->createTR($LDPhone.' 1',$phone_1_nr,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_phone_2_nr_hide']&&$phone_2_nr){
 			$this->smarty->assign('sPhone2',$this->createTR($LDPhone.' 2',$phone_2_nr,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_cellphone_1_nr_hide']&&$cellphone_1_nr){
 			$this->smarty->assign('sCellPhone1',$this->createTR($LDCellPhone.' 1',$cellphone_1_nr,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_cellphone_2_nr_hide']&&$cellphone_2_nr){
 			$this->smarty->assign('sCellPhone2',$this->createTR($LDCellPhone.' 2',$cellphone_2_nr,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_fax_hide']&&$fax){
 			$this->smarty->assign('sFax',$this->createTR($LDFax,$fax,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_email_hide']&&$email){
 			$this->smarty->assign('sEmail',$this->createTR($LDEmail,"<a href=\"mailto:$email\">$email</a>",2));
-		}
-
+			}
+			
 		if (!$GLOBAL_CONFIG['person_citizenship_hide']&&$citizenship){
 			$this->smarty->assign('sCitzenship',$this->createTR($LDCitizenship,$citizenship,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_sss_nr_hide']&&$sss_nr){
 			$this->smarty->assign('sSSSNr',$this->createTR($LDSSSNr,$sss_nr,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_nat_id_nr_hide']&&$nat_id_nr){
 			$this->smarty->assign('sNatIdNr',$this->createTR($LDNatIdNr,$nat_id_nr,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_religion_hide']&&$religion){
 			$this->smarty->assign('sReligion',$this->createTR($LDReligion,$religion,2));
-		}
+			}
 		if (!$GLOBAL_CONFIG['person_ethnic_orig_hide']&&$ethnic_orig){
 			$this->smarty->assign('LDEthnicOrig',$LDEthnicOrigin);
 			$this->smarty->assign('sEthnicOrigInput',$ethnic_orig_txt);
-		}
-
+			}
+			
 		if (!$GLOBAL_CONFIG['person_other_his_nr_hide']){
 			$other_hosp_list = $this->person_obj->OtherHospNrList();
 			$iHospCount = sizeof($other_hosp_list);
-			
+				
 			if($iHospCount) {
 				$this->smarty->assign('bShowOtherHospNr',TRUE);
-
+					
 				$this->smarty->assign('LDOtherHospitalNr',$LDOtherHospitalNr);
-
+					
 				$sOtherNrBuffer='';
 				if(is_array($other_hosp_list) && $iHospCount){
-
+						
 					foreach( $other_hosp_list as $k=>$v ){
 						$sOtherNrBuffer.="<b>".$kb_other_his_array[$k].":</b> ".$v."<br />\n";
+						}
 					}
+				$this->smarty->assign('sOtherNr',$sOtherNrBuffer);
 				}
-				$this->smarty->assign('sOtherNr',$sOtherNrBuffer);
-			}
-		}
-		
+			}
+			
 		$this->smarty->assign('LDRegBy',$LDRegBy);
 		if(empty($modify_id)) $buffer=$create_id; else $buffer=$modify_id;
-
+			
 		$this->smarty->assign('sRegByInput',$buffer);
-
+		
 		}else{
 			$this->smarty->assign('pretext','Invalid PID number or the data is not available from the databank! Please report this to <a  href="mailto:info@care2x.org">info@care2x.org</a>. Thank you.');
 		}
-
+		
         /* SalvoRossitto 27/11/2007 */
         if ($errorrelative) $this->smarty->assign('LDRelative',"<font color=red>$LDRelative</font>");
@@ -463,6 +467,6 @@
 	
 	/**
-	* Creates the  data but returns it as a string instead of outputting it
-	*/
+	 * Creates the  data but returns it as a string instead of outputting it
+	 */
 	function create(){
 		$this->bReturnOnly=TRUE;
Index: /trunk/Care2007/include/care_api_classes/class_product.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_product.php (revision 6144)
+++ /trunk/Care2007/include/care_api_classes/class_product.php (revision 6193)
@@ -260,5 +260,4 @@
 		if(empty($type)||empty($bestellnum)) return false;
 		$this->useOrderCatalog($type);
-		//TODO ndryshue ci me marre simas emnit te farmacise...nuk e di a me kalon ne kete nivel
 		$this->sql="SELECT * FROM care_pharma_products_main_sub WHERE bestellnum='$bestellnum' AND pcs > 0  AND idcare_pharma = $pharma ORDER BY skadenca ASC";
 		if($this->res['aoc']=$db->Execute($this->sql)) {
Index: /trunk/Care2007/include/care_api_classes/class_immunization.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_immunization.php (revision 6130)
+++ /trunk/Care2007/include/care_api_classes/class_immunization.php (revision 6193)
@@ -17,9 +17,4 @@
 */
 class Immunization extends Core {
-	/**
-	* Database table for encounter's immunization data
-	* @var string
-	*/
-	var $tb='care_encounter_immunization'; // table name
 	/**
 	* Database table for encounter's immunization data
Index: /trunk/Care2007/include/care_api_classes/class_insurance.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_insurance.php (revision 5995)
+++ /trunk/Care2007/include/care_api_classes/class_insurance.php (revision 6193)
@@ -135,10 +135,9 @@
     
 	    global $db;
-	
-        if ($this->res['gicio']=$db->Execute("SELECT $items  FROM $this->tb_class")) {
+        if ($this->res['gicio']=$db->Execute("SELECT $items  FROM $this->tb_class WHERE status='active'")) {
             if ($this->res['gicio']->RecordCount()) {
                 return $this->res['gicio'];
             } else {return FALSE;}
-		} else {return FALSE; }
+				} else {return FALSE; }
     }
 	/**
Index: /trunk/Care2007/include/care_api_classes/class_core.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_core.php (revision 6067)
+++ /trunk/Care2007/include/care_api_classes/class_core.php (revision 6193)
@@ -186,4 +186,6 @@
 		$x='';
 		$v='';
+		reset($this->ref_array);
+		reset($this->data_array);
 		while(list($x,$v)=each($this->ref_array)) {	
 			// Gjergj Sheldija : 
@@ -343,5 +345,5 @@
 		while(list($x,$v)=each($array)) {
 			# use backquoting for mysql and no-quoting for other dbs 
-			if ($dbtype=='mysql') $index.="`$x`,";
+			if ($dbtype=='mysql' || $dbtype=='mysqli') $index.="`$x`,";
 				else $index.="$x,";
 				
@@ -378,5 +380,5 @@
 		while(list($x,$v)=each($array)) {
 			# use backquoting for mysql and no-quoting for other dbs. 
-			if ($dbtype=='mysql') $elems.="`$x`=";
+			if ($dbtype=='mysql' || $dbtype=='mysqli') $elems.="`$x`=";
 				else $elems.="$x=";
 			
@@ -505,4 +507,18 @@
 		return $this->Transact();
 	}
+	/**
+	* Deletes data from a database table based on the job_id and
+	* batch_nr. Used in the update action for the laboratory tables
+	* ( chemlabor and baclabor )
+	* @access public
+	* @param varchar $batch_nr
+	* @param varchar $job_id
+	* @return boolean
+	*/
+	function deleteOldValues($batch_nr, $encounter_nr){
+		if(empty($batch_nr) || empty($encounter_nr)) return FALSE;
+		$this->sql="DELETE  FROM $this->coretable WHERE batch_nr = '$batch_nr' AND encounter_nr = '$encounter_nr'";
+		return $this->Transact();
+	}	
 	/**
 	* Returns the  core field names of the core table in an array.
@@ -592,4 +608,5 @@
 		}else{
 			switch($dbtype){
+				case 'mysqli':
 				case 'mysql': return $oid;
 					break;
@@ -614,4 +631,5 @@
 
 		switch($dbtype){
+			case 'mysqli':
 			case 'mysql': return "CONCAT($fieldname,'$str')";
 				break;
@@ -656,4 +674,5 @@
 
 		switch($dbtype){
+			case 'mysqli' :
 			case 'mysql': return "REPLACE($fieldname,'$str1','$str2')";
 				break;
Index: /trunk/Care2007/include/care_api_classes/class_notes.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_notes.php (revision 6130)
+++ /trunk/Care2007/include/care_api_classes/class_notes.php (revision 6193)
@@ -117,5 +117,5 @@
 		if(empty($sort)) $sort=" ORDER BY nr";
 			else $sort=" ORDER BY $sort";
-	    if ($this->result=$db->Execute("SELECT nr,type,name,LD_var AS \"LD_var\" FROM $this->tb_types  $sort")) {
+	    if ($this->result=$db->Execute("SELECT nr,type,name,LD_var AS \"LD_var\" FROM $this->tb_types WHERE status NOT IN ($this->dead_stat) $sort")) {
 		    if ($this->result->RecordCount()) {
 		        return $this->result->GetArray();
Index: /trunk/Care2007/include/care_api_classes/class_gui_input_person.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_gui_input_person.php (revision 6130)
+++ /trunk/Care2007/include/care_api_classes/class_gui_input_person.php (revision 6193)
@@ -4,7 +4,7 @@
 */
 
-/**
-*/
-//require_once($root_path.'include/care_api_classes/class_core.php');
+
+require_once($root_path.'include/care_api_classes/class_core.php');
+
 /**
 *  GUI input form for person registration methods.
@@ -84,8 +84,12 @@
 	*/
 	function createTR($error_handler, $input_name, $ld_text, $input_val, $colspan = 1, $input_size = 35,$red=FALSE){
-
 		ob_start();
-			if ($error_handler || $red) $sBuffer="<font color=\"$this->error_fontcolor\">$ld_text</font>";
+		    $this->smarty->assign('must','');
+			if ($error_handler || $red) {
+			    $sBuffer="<font color=\"$this->error_fontcolor\">* $ld_text</font>";
+			    $this->smarty->assign('must',1);
+			}
 				else $sBuffer=$ld_text;
+			//$this->smarty->assign('must',1);
 			$this->smarty->assign('sItem',$sBuffer);
 			$this->smarty->assign('sColSpan2',"colspan=$colspan");
@@ -99,5 +103,4 @@
 		return $sBuffer;
 	}
-
 	/**
 	* Displays the GUI input form
@@ -154,7 +157,7 @@
 			if($mode!='forcesave') {
 				# clean and check input data variables
-				if(trim($encoder)=='') $encoder=$aufnahme_user;
+				if (trim($encoder)=='') $encoder=$aufnahme_user;
 				if (trim($name_last)=='') { $errornamelast=1; $error++;}
-				if(trim($name_first)=='') { $errornamefirst=1; $error++; }
+				if (trim($name_first)=='') { $errornamefirst=1; $error++; }
 				if (trim($date_birth)=='') { $errordatebirth=1; $error++;}
 				if (trim($addr_str)=='') { $errorstreet=1; $error++;}
@@ -187,5 +190,5 @@
 
 					//echo formatDate2STD($geburtsdatum,$date_format);
-					$sql.="UPDATE $dbtable SET
+					$sql="UPDATE $dbtable SET
 							 title='$title',
 							 name_last='$name_last',
@@ -217,5 +220,4 @@
 							 date_update='".date('Y-m-d H:i:s')."',";
 
-					//if ($old_fn!=$photo_filename){
 					if ($valid_image){
 						# Compose the new filename
@@ -296,5 +298,5 @@
 						# However, the sequence generator must be configured during db creation to start at
 						# the initial value set in the global config
-						if($dbtype=='mysql'){
+						if($dbtype=='mysql' || $dbtype=='mysqli'){
 							$HTTP_POST_VARS['pid']=$GLOBAL_CONFIG['person_id_nr_init'];
 						}
@@ -422,5 +424,5 @@
 ?>
 		<script  language="javascript">
-		<!--
+		
 			function forceSave(){
 			document.aufnahmeform.mode.value="forcesave";
@@ -458,12 +460,4 @@
 				d.addr_str.focus();
 				return false;
-			}else if(d.addr_str_nr.value==""){
-				alert("<?php echo $LDPlsEnterBldgNr; ?>");
-				d.addr_str_nr.focus();
-				return false;
-           }else if(d.addr_citytown_name.value==""){
-				alert("<?php echo $LDPlsEnterCityTown; ?>");
-				d.addr_citytown_name.focus();
-				return false;
 			}else if(d.addr_zip.value==""){
 				alert("<?php echo $LDPlsEnterZip; ?>");
@@ -474,8 +468,4 @@
 				d.user_id.focus();
 				return false;
-           }else if(d.sss_nr.value==""){
-				alert("<?php echo $LDPlsEnterSss_nr; ?>");
-				d.sss_nr.focus();
-				return false;
 			}else{
 				return true;
@@ -486,5 +476,4 @@
 		require($root_path.'include/inc_checkdate_lang.php'); 
 ?>
-		-->
 		</script>
 <?php
@@ -588,12 +577,5 @@
 		//$iRowSpanCount++;
         
-        /* Begin SalvoRossitto 26/11/2007 */
-        if ($errorrelative) $this->smarty->assign('LDRelative',"<font color=red>$LDRelative</font>");
-			else $this->smarty->assign('LDRelative',"$LDRelative");
-        $this->smarty->assign('sRelativeNameLast',$this->createTR($errorrelativenamelast, 'relative_name_last', $LDLastName,$relative_name_last,2,35,FALSE));
-		$this->smarty->assign('sRelativeNameFirst',$this->createTR($errorrelativenamefirst, 'relative_name_first', $LDFirstName,$relative_name_first,2,35,FALSE));
-		$this->smarty->assign('sRelativePhone',$this->createTR($errorrelativephone, 'relative_phone', $LDPhone,$relative_phone,2,35,FALSE));
-        /* Begin SalvoRossitto 26/11/2007 */
-        
+      
         
 		if (!$GLOBAL_CONFIG['person_name_2_hide']){
@@ -625,18 +607,6 @@
 		$this->smarty->assign('sPicTdRowSpan',"rowspan=$iRowSpanCount");
 
-
-		if ($errordatebirth) $this->smarty->assign('LDBday',"<font color=red>$LDBday</font>");
-			else $this->smarty->assign('LDBday',"<font color=red></font> $LDBday");
-			
-		//gjergji : new calendar
-/*		if($date_birth){
-			if($mode=='save'||$error||$error_person_exists) $sBdayBuffer = $date_birth;
-				else $sBdayBuffer = formatDate2Local($date_birth,$date_format);
-		}*/
-		# Uncomment the following when the current date must be inserted
-		# automatically at the start of each document
-		/*else{
-			$sBdayBuffer = formatDate2Local(date('Y-m-d'),$date_format);
-		}*/
+		if ($errordatebirth) $this->smarty->assign('LDBday',"<font color=red>* $LDBday</font>:");
+		else $this->smarty->assign('LDBday',"<font color=red>*</font> $LDBday:");
 		
 		//gjergji : new calendar
@@ -644,6 +614,6 @@
 		//end gjergji
 		
-		if ($errorsex) $this->smarty->assign('LDSex', "<font color=#ff0000>$LDSex</font>:");
-			else $this->smarty->assign('LDSex', "<font color=#ff0000></font> $LDSex");
+		if ($errorsex) $this->smarty->assign('LDSex', "<font color=#ff0000>* $LDSex</font>:");
+		else $this->smarty->assign('LDSex', "<font color=#ff0000>*</font> $LDSex:");
 
 		$sSexMBuffer='<input name="sex" type="radio" value="m"  ';
@@ -728,25 +698,35 @@
 		}
 		
-		if ($erroraddress) $this->smarty->assign('LDAddress',"<font color=red>$LDAddress</font>");
-			else $this->smarty->assign('LDAddress',"$LDAddress");
-
-		if ($errorstreet) $this->smarty->assign('LDStreet',"<font color=red><font color=#ff0000></font> $LDStreet</font>");
-			else $this->smarty->assign('LDStreet',"<font color=#ff0000></font> $LDStreet");
+		if ($erroraddress) $this->smarty->assign('LDAddress',"<font color=red>$LDAddress</font>:");
+			else $this->smarty->assign('LDAddress',"$LDAddress:");
+
+		if ($errorstreet) $this->smarty->assign('LDStreet',"<font color=red><font color=#ff0000>*</font> $LDStreet</font>:");
+			else $this->smarty->assign('LDStreet',"<font color=#ff0000>*</font> $LDStreet:");
 
 		$this->smarty->assign('sStreetInput','<input name="addr_str" type="text" size="35" value="'.$addr_str.'">');
 
-		if ($errorstreetnr) $this->smarty->assign('LDStreetNr',"<font color=red><font color=#ff0000></font> $LDStreetNr</font>");
-				else $this->smarty->assign('LDStreetNr',"<font color=#ff0000></font> $LDStreetNr");
+		if ($errorstreetnr) $this->smarty->assign('LDStreetNr',"<font color=red> $LDStreetNr</font>:");
+				else $this->smarty->assign('LDStreetNr'," $LDStreetNr:");
 
 		$this->smarty->assign('sStreetNrInput','<input name="addr_str_nr" type="text" size="10" value="'.$addr_str_nr.'">');
 
-		if ($errortown) $this->smarty->assign('LDStreet',"<font color=red>$LDTownCity</font>");
-			else $this->smarty->assign('LDTownCity',"$LDTownCity");
-		$this->smarty->assign('sTownCityInput','<input name="addr_citytown_name" type="text" size="35" value="'.$addr_citytown_name.'">');
-		$this->smarty->assign('sTownCityMiniCalendar',"<a href=\"javascript:popSearchWin('citytown','aufnahmeform.addr_citytown_nr','aufnahmeform.addr_citytown_name')\"><img ".createComIcon($root_path,'b-write_addr.gif','0')."></a>");
-
-		 if ($errorzip) $this->smarty->assign('LDZipCode',"<font color=red><font color=#ff0000></font> $LDZipCode</font> ");
-		 	else  $this->smarty->assign('LDZipCode',"<font color=#ff0000></font> $LDZipCode ");
-		 $this->smarty->assign('sZipCodeInput','<input name="addr_zip" type="text" size="10" value="'.$addr_zip.'">');
+		if ($errortown) $this->smarty->assign('LDStreet',"<font color=red>$LDTownCity</font>:");
+		else $this->smarty->assign('LDTownCity',"$LDTownCity:");
+				
+		require_once($root_path.'include/care_api_classes/class_address.php');
+		$sAddress = '<select name="addr_citytown_name"><option  onclick="document.getElementById(\'addr_zip\').value=\'\'"></option>';
+		$address_obj=new Address;
+		$address = $address_obj->getAllActiveCityTown();
+		while($addr=$address->FetchRow()){
+		    $sAddress .= '<option onclick="document.getElementById(\'addr_zip\').value=\'' . $addr['zip_code'].'\'" value="' . $addr['name'] . '">' . $addr['name'] . '</option>';
+		}
+		$sAddress .= '</select>';
+		$this->smarty->assign('sTownCityInput',$sAddress);
+		//$this->smarty->assign('sTownCityInput','<input name="addr_citytown_name" type="text" size="35" value="'.$addr_citytown_name.'">');
+		//$this->smarty->assign('sTownCityMiniCalendar',"<a href=\"javascript:popSearchWin('citytown','aufnahmeform.addr_citytown_nr','aufnahmeform.addr_citytown_name')\"><img ".createComIcon($root_path,'b-write_addr.gif','0')."></a>");
+
+		 if ($errorzip) $this->smarty->assign('LDZipCode',"<font color=red> $LDZipCode</font> :");
+		 	else  $this->smarty->assign('LDZipCode'," $LDZipCode :");
+		 $this->smarty->assign('sZipCodeInput','<input id="addr_zip" name="addr_zip" type="text" size="10" value="'.$addr_zip.'">');
 
 
@@ -758,5 +738,5 @@
 					$this->smarty->assign('bShowInsurance',TRUE);
 
-					$this->smarty->assign('sInsuranceNr',$this->createTR($errorinsurancenr, 'insurance_nr', $LDInsuranceNr.' 1',$insurance_nr,2));
+					$this->smarty->assign('sInsuranceNr',$this->createTR($errorinsurancenr, 'insurance_nr', $LDInsuranceNr.' 1',$insurance_nr,2,35,true));
 
 					if ($errorinsuranceclass) $this->smarty->assign('sErrorInsClass',"<font color=\"$error_fontcolor\">");
@@ -766,5 +746,5 @@
 						while($result=$insurance_classes->FetchRow()) {
 
-							$sInsClassBuffer.='<input name="insurance_class_nr" type="radio"  value="'.$result['class_nr'].'" ';
+							$sInsClassBuffer.='<input class="reg_input_must" name="insurance_class_nr" type="radio"  value="'.$result['class_nr'].'" ';
 							if($insurance_class_nr==$result['class_nr']) $sInsClassBuffer.='checked';
 							$sInsClassBuffer.='>';
@@ -778,10 +758,11 @@
 
 					} else {
-						$this->smarty->assign('sInsClasses','no insurance class');
+						$this->smarty->assign('sInsClasses','No insurance classes defined');
 					}
 					
 					if ($errorinsurancecoid) $this->smarty->assign('LDInsuranceCo',"<font color=red>$LDInsuranceCo</font> :");
 						else  $this->smarty->assign('LDInsuranceCo',"$LDInsuranceCo :");
-
+					//gjergji mod for insurance
+					$insurance_firm_name = $pinsure_obj->getFirmName($GLOBAL_CONFIG['person_insurace_firm_default_id']);  
 					$this->smarty->assign('sInsCoNameInput','<input name="insurance_firm_name" type="text" size="35" value="'.$insurance_firm_name.'">');
 					$this->smarty->assign('sInsCoMiniCalendar',"<a href=\"javascript:popSearchWin('insurance','aufnahmeform.insurance_firm_id','aufnahmeform.insurance_firm_name')\"><img ".createComIcon($root_path,'b-write_addr.gif','0')."></a>");
@@ -876,5 +857,5 @@
 			<input type="hidden" name="addr_citytown_nr" value="<?php echo $addr_citytown_nr; ?>">
 			<input type="hidden" name="insurance_item_nr" value="<?php echo $insurance_item_nr; ?>">
-			<input type="hidden" name="insurance_firm_id" value="<?php echo $insurance_firm_id; ?>">
+			<input type="hidden" name="insurance_firm_id" value="<?php echo $GLOBAL_CONFIG['person_insurace_firm_default_id']; ?>">
 			<input type="hidden" name="insurance_show" value="<?php echo $insurance_show; ?>">
 			<input type="hidden" name="ethnic_orig" value="<?php echo $ethnic_orig; ?>">
Index: /trunk/Care2007/include/care_api_classes/class_ward.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_ward.php (revision 6130)
+++ /trunk/Care2007/include/care_api_classes/class_ward.php (revision 6193)
@@ -139,5 +139,4 @@
 			while (list($key, $val) = each($dept_nr)) {
 				$tmp .= "dept_nr = " . $val . " OR ";
-	
 			}
 			$this->sql .= substr($tmp,0,-4) ;
@@ -145,11 +144,11 @@
 	    }
         //echo $this->sql;
-        if($this->res['gawio']=$db->Execute($this->sql)) {
+    if($this->res['gawio']=$db->Execute($this->sql)) {
             if($this->rec_count=$this->res['gawio']->RecordCount()) {
-				 return $this->res['gawio'];	 
-			} else { return false; }
-		} else { return false; }
-	}
-	/**
+    		return $this->res['gawio'];	 
+   		} else { return false; }
+		} else { return false; }
+	}
+  /**
 	* Returns all wards data.
 	* 
@@ -404,4 +403,5 @@
 		global $dbtype;
 		switch ($dbtype){
+			case 'mysqli':
 			case 'mysql': $this->sql="UPDATE $this->tb_room SET closed_beds=".$this->ReplaceFieldString("closed_beds","$bed_nr/","")." WHERE type_nr=1 AND room_nr=$room_nr AND ward_nr=$ward_nr";
 				break;
Index: /trunk/Care2007/include/care_api_classes/class_department.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_department.php (revision 6130)
+++ /trunk/Care2007/include/care_api_classes/class_department.php (revision 6193)
@@ -164,6 +164,14 @@
 	* @return mixed boolean or adodb record object or assoc array
 	*/
-	function getAllActive() {
+	function getAllActive($dept_nr) {
 		return $this->_getalldata("is_inactive='0'");
+	}
+	/**
+	* Gets all ACTIVE sub - departments. The result is assoc array sorted by departments formal name
+	* @access public
+	* @return mixed boolean or adodb record object or assoc array
+	*/
+	function getAllSubDepts($dept_nr) {
+		return $this->_getalldata('is_inactive=\'0\' AND parent_dept_nr='.$dept_nr);
 	}
 	/**
@@ -190,5 +198,5 @@
 	*/
 	function getAllActiveSort($sort='') {
-		return $this->_getalldata("is_inactive='0'",$sort);
+		return $this->_getalldata("parent_dept_nr='0' AND is_inactive='0'",$sort);
 	}
 	/**
Index: /trunk/Care2007/include/care_api_classes/class_address.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_address.php (revision 5995)
+++ /trunk/Care2007/include/care_api_classes/class_address.php (revision 6193)
@@ -31,4 +31,5 @@
 									'unece_locode',
 									'name',
+							'zip_code',
 									'iso_country_id',
 									'unece_locode_type',
Index: /trunk/Care2007/include/care_api_classes/class_lab.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_lab.php (revision 6081)
+++ /trunk/Care2007/include/care_api_classes/class_lab.php (revision 6193)
@@ -23,4 +23,9 @@
 	var $tb_find_chemlab='care_test_findings_chemlab';
 	/**
+	* Table name for test findings for chemical lab paramters
+	* @var string
+	*/
+	var $tb_find_chemlab_sub='care_test_findings_chemlabor_sub';
+	/**
 	* Table name for test paramaters
 	* @var string
@@ -66,4 +71,19 @@
 				'modify_id',
 				'modify_time',
+				'create_id',
+				'create_time');
+	/**
+	* Field names for care_test_findings_chemlab_sub table
+	* @var array
+	*/
+	var $fld_find_chemlab_sub=array(
+				'batch_nr',
+				'job_id',
+				'encounter_nr',
+				'paramater_name',
+				'parameter_value',
+				'test_date',
+				'test_time',
+				'history',
 				'create_id',
 				'create_time');
@@ -127,10 +147,16 @@
 	* @param int Encounter number
 	*/
-	function Lab($enc_nr=''){
+	function Lab($enc_nr='', $subTable = false){
 		if(!empty($enc_nr)) $this->enc_nr=$enc_nr;
+		if($subTable == true) {
+			$this->setTable($this->tb_find_chemlab_sub);
+			$this->setRefArray($this->fld_find_chemlab_sub);
+		} else {
 		$this->setTable($this->tb_find_chemlab);
 		$this->setRefArray($this->fld_find_chemlab);
+		}
 		//$this->en_prepend=date('Y')*1000000;
 	}
+
 	/**
 	* Sets the core table name and field names to the care_test_param table.
@@ -192,11 +218,10 @@
 	* @param int Encounter number
 	* @param int Job (test request) id
-	* @param int Test group id
 	* @return boolean
 	*/
-	function hideResultIfExists($enc_nr,$job_id,$grp_id){
+	function hideResultIfExists($enc_nr,$job_id){
 		global $HTTP_SESSION_VARS;
-		$this->sql="UPDATE $this->tb_find_chemlab SET status='hidden',history=".$this->ConcatHistory("Hide ".date('Y-m-d H:i:s')." ".$HTTP_SESSION_VARS['sess_user_name']."\n")."
-								WHERE encounter_nr='$enc_nr' AND job_id='$job_id' AND group_id='$grp_id' AND status NOT IN ($this->dead_stat)";
+		$this->sql="UPDATE $this->tb_find_chemlab_sub SET status='hidden',history=".$this->ConcatHistory("Hide ".date('Y-m-d H:i:s')." ".$HTTP_SESSION_VARS['sess_user_name']."\n")."
+								WHERE encounter_nr='$enc_nr' AND job_id='$job_id' AND status NOT IN ($this->dead_stat)";
 		return $this->Transact();
 	}
@@ -212,5 +237,7 @@
 	function getBatchResult($bn){
 		global $db;
-		$this->sql="SELECT * FROM $this->tb_find_chemlab WHERE batch_nr=$bn";
+		$this->sql  = "SELECT * FROM $this->tb_find_chemlab INNER JOIN $this->tb_find_chemlab_sub ";
+		$this->sql .= "ON ($this->tb_find_chemlab.job_id = $this->tb_find_chemlab_sub.job_id) ";
+		$this->sql .= "WHERE $this->tb_find_chemlab.batch_nr=$bn";
 		if($this->result=$db->Execute($this->sql)){
 		    if($this->rec_count=$this->result->RecordCount()) {
@@ -233,5 +260,7 @@
 		global $db;
 		if(!$this->internResolveEncounterNr($enc_nr)) return FALSE;
-		$this->sql="SELECT * FROM $this->tb_find_chemlab WHERE encounter_nr='$this->enc_nr' AND job_id='$job_id' AND group_id='$grp_id' AND status<>'hidden'";
+		$this->sql  = "SELECT * FROM $this->tb_find_chemlab INNER JOIN $this->tb_find_chemlab_sub ";
+		$this->sql .= "ON ($this->tb_find_chemlab.job_id = $this->tb_find_chemlab_sub.job_id) ";
+		$this->sql .= "WHERE $this->tb_find_chemlab.encounter_nr='$this->enc_nr' AND $this->tb_find_chemlab.job_id='$job_id' AND $this->tb_find_chemlab.group_id='$grp_id' AND $this->tb_find_chemlab.status<>'hidden'";
 		if($this->result=$db->Execute($this->sql)){
 		    if($this->rec_count=$this->result->RecordCount()) {
@@ -252,5 +281,7 @@
 		global $db;
 		if(!$this->internResolveEncounterNr($enc_nr)) return FALSE;
-		$this->sql="SELECT * FROM $this->tb_find_chemlab WHERE encounter_nr='$this->enc_nr' AND status NOT IN ($this->dead_stat) ORDER BY test_date";
+		$this->sql  = "SELECT * FROM $this->tb_find_chemlab INNER JOIN $this->tb_find_chemlab_sub ";
+		$this->sql .= "ON ($this->tb_find_chemlab.job_id = $this->tb_find_chemlab_sub.job_id) ";
+		$this->sql .= "WHERE $this->tb_find_chemlab.encounter_nr='$this->enc_nr' AND $this->tb_find_chemlab.status NOT IN ($this->dead_stat) ORDER BY $this->tb_find_chemlab_sub.test_date";
 		if($this->result=$db->Execute($this->sql)){
 		    if($this->rec_count=$this->result->RecordCount()) {
@@ -314,5 +345,6 @@
 		if(empty($id)) $cond='';
 			else $cond="batch_nr='$id'";
-		$this->sql="SELECT parameters FROM $this->tb_req_chemlab WHERE $cond";
+			$sub = "_sub";
+		$this->sql  = "SELECT paramater_name, parameter_value FROM $this->tb_req_chemlab$sub  WHERE $cond";
 		if($this->tparams=$db->Execute($this->sql)){
 		    if($this->rec_count=$this->tparams->RecordCount()) {
Index: /trunk/Care2007/include/care_api_classes/class_encounter.php
===================================================================
--- /trunk/Care2007/include/care_api_classes/class_encounter.php (revision 6130)
+++ /trunk/Care2007/include/care_api_classes/class_encounter.php (revision 6193)
@@ -82,4 +82,9 @@
 	var $tb_appt='care_appointment';
 	/**
+	* Table name for encounter type
+	* @var string
+	*/
+	var $tb_enc_type='care_type_encounter';	
+	/**
 	* Current encounter number
 	* @var int
@@ -162,5 +167,6 @@
 							   'referrer_institution',
 							   'referrer_notes',
-                               'regional_code',
+							   'admit_type',
+							   'triage',
 							   'financial_class',
 							   'insurance_nr',
@@ -664,5 +670,5 @@
 		$this->sql="SELECT e.*, p.pid, p.title,p.name_last, p.name_first, p.date_birth, p.sex,
 									p.addr_str,p.addr_str_nr,p.addr_zip, p.blood_group,
-									p.photo_filename, t.name AS citytown_name,p.death_date,p.sss_nr
+									p.photo_filename, t.name AS citytown_name,p.death_date
 							FROM $this->tb_enc AS e, 
 									 $this->tb_person AS p
@@ -1275,4 +1281,28 @@
 		}
 	}
+	/**
+	* Gets the encounter type 
+	*
+	* The returned array contains data with following index keys:
+	* - <b>type_nr</b> = the class id (alphanumeric)
+	* - <b>name</b> = the class name
+	* - <b>LD_var</b> = the variable's name for the language dependent version of the class name
+	*
+	*
+	* @access public
+	* @return mixed array or boolean
+	*/
+	function getEncounterType(){
+	    global $db;
+		$this->sql="SELECT type_nr,type,name, LD_var AS \"LD_var\" FROM $this->tb_enc_type";
+		if($this->result=$db->Execute($this->sql)){
+		    if($this->result->RecordCount()) {
+			    $this->row=$this->result;
+				return $this->row;
+			} else return FALSE;
+		}else {
+		    return FALSE;
+		}
+	}	
 	/**
 	* Gets the insurance class' information based on its class_nr key.
Index: /trunk/Care2007/include/inc_test_request_printout_chemlabor.php
===================================================================
--- /trunk/Care2007/include/inc_test_request_printout_chemlabor.php (revision 6081)
+++ /trunk/Care2007/include/inc_test_request_printout_chemlabor.php (revision 6193)
@@ -437,5 +437,4 @@
  <?php
 # Start buffering output
-
 ob_start();
 for($i=0;$i<=$max_row;$i++) {
@@ -448,6 +447,11 @@
 					echo '<td>';
 					if($edit) {
+						if( isset($stored_param[$LD_Elements[$j][$i]['id']]) && !empty($stored_param[$LD_Elements[$j][$i]['id']])) {
+							echo '<input type="hidden" name="'.$LD_Elements[$j][$i]['id'].'" value="1">
+							<a href="javascript:setM(\''.$LD_Elements[$j][$i]['id'].'\')">';
+						} else {
 						echo '<input type="hidden" name="'.$LD_Elements[$j][$i]['id'].'" value="0">
 						<a href="javascript:setM(\''.$LD_Elements[$j][$i]['id'].'\')">';
+					}
 					}
 					if( isset($stored_param[$LD_Elements[$j][$i]['id']]) && !empty($stored_param[$LD_Elements[$j][$i]['id']])) {
@@ -455,5 +459,6 @@
 					} else {
 						echo '<img src="b.gif" border=0 width=18 height=6 id="'.$LD_Elements[$j][$i]['id'].'">';
-					} if($edit) {
+					} 
+					if($edit) {
 						echo '</a>';
 					}
Index: /trunk/Care2007/include/inc_test_request_printout_baclabor.php
===================================================================
--- /trunk/Care2007/include/inc_test_request_printout_baclabor.php (revision 6081)
+++ /trunk/Care2007/include/inc_test_request_printout_baclabor.php (revision 6193)
@@ -24,6 +24,5 @@
   
 <?php
-  while(list($x,$v)=each($LDBacLabMaterialType))
-	{
+ while(list($x,$v)=each($LDBacLabMaterialType)){
 	   list($x2,$v2)=each($LDBacLabMaterialType); 
 	   echo '
@@ -40,5 +39,5 @@
 	   if($edit_form || $read_form )
 	   {
-	      if($stored_material[$x])
+	      if($stored_param[$x])
 		  {
 		     echo '<img src="../img/filled_pink_block.gif" ';
@@ -66,5 +65,5 @@
 	   if($edit_form || $read_form )
 	   {
-	      if($stored_material[$x2])
+	      if($stored_param[$x2])
 		  {
 		     echo '<img src="../img/filled_pink_block.gif" ';
@@ -112,5 +111,5 @@
 	   if($edit_form || $read_form )
 	   {
-	      if($stored_test_type[$x3])
+	      if($stored_param[$x3])
 		  {
 		     echo '<img src="../img/filled_pink_block.gif" ';
@@ -138,5 +137,5 @@
 	   if($edit_form || $read_form )
 	   {
-	      if($stored_test_type[$x4])
+	      if($stored_param[$x4])
 		  {
 		     echo '<img src="../img/filled_pink_block.gif" ';
