<?php
	require_once '../../autoload.php';

	$ins_id 	= -1;

	if ( isset($_GET['ins_id']) )
		$ins_id	= $_GET['ins_id'];

	$institution = ($ins_id == -1)? "" : " and institution.id=".$ins_id;
		
	$conn = get_dbconnection();
	
	$answer = "<radiologists>";
	
	if ( $conn )
	{
		$sql = "select staff_member.id, lastname, firstname, UPPER(lastname) || ' ' || firstname as fullname from staff_member,staff_job, staff_role where staff_member.removed =false and staff_member.id=staff_job.staff_id and staff_job.staff_role_id=staff_role.id and staff_role.name='Radiologue' order by lastname";
		
		if ( $query = pg_query($conn,$sql) )
		{
			while ( $row = pg_fetch_row($query) )
			{
				$row[1]=trim(preg_replace('/[[:cntrl:]]/', '', htmlspecialchars($row[1],ENT_QUOTES)));

				$answer .= "<radiologist id=\"".$row[0]."\" lastname=\"".$row[1]."\" firstname=\"".$row[2]."\" fullname=\"".$row[3]."\" ></radiologist>";
			}
		}
	}
	
	$answer .= "</radiologists>";

	header ('Content-type: text/xml' );
	
	echo $answer;
?>