Exemple #1
0
	function DisplaySubjectList($searchuid, $searchaltuid, $searchname, $searchgender, $searchdob, $searchactive) {
	
		$searchuid = mysql_real_escape_string($searchuid);
		$searchaltuid = mysql_real_escape_string($searchaltuid);
		$searchname = mysql_real_escape_string($searchname);
		$searchgender = mysql_real_escape_string($searchgender);
		$searchdob = mysql_real_escape_string($searchdob);
		$searchactive = mysql_real_escape_string($searchactive);
	?>
	<script>
		$(document).ready(function() {
			$('#newsubjecttext').hide();
			
			$('#newsubject').hover(
				function () { $('#newsubjecttext').show(); }, 
				function () { $('#newsubjecttext').hide(); }
			);
		});
	</script>
	
	<table width="100%" cellspacing="0" class="headertable">
		<tbody>
			<tr>
				<td class="header1">Subjects</td>
				<td class="header2" align="right">
					<a href="subjects.php">Subject List</a> &gt; 
					<a href="subjects.php?action=addform" id="newsubject"> New Subject </a><br>
					<div align="right" id="newsubjecttext" style="color:darkred; background-color: yellow; font-size:9pt; border: 1px solid red; padding:5px; border-radius:5px"><b>Search on this page before creating a new subject</b><br>to make sure they do not already exist!</div>
				</td>
			</tr>
		</tbody>
	</table>

	<br><bR>
	<script>
	$(function() {
		$( "#searchuid" ).autocomplete({
			source: "autocomplete_uid.php",
			minLength: 2,
			autoFocus: true
		});
	});
	</script>
	<style>
	.ui-autocomplete {
		max-height: 150px;
		overflow-y: auto;
		/* prevent horizontal scrollbar */
		overflow-x: hidden;
		/* add padding to account for vertical scrollbar */
		padding-right: 25px;
	}
	/* IE 6 doesn't support max-height
	 * we use height instead, but this forces the menu to always be this tall
	 */
	* html .ui-autocomplete {
		height: 150px;
	}
	</style>
	
	<table class="graydisplaytable" width="100%">
		<thead>
			<tr>
				<th align="left">&nbsp;</th>
				<th>UID<br><span class="tiny">S1234ABC</span></th>
				<th>Alternate UID</th>
				<th>Name</th>
				<th>Sex<br><span class="tiny">M,F,O,U</span></th>
				<th>DOB<br><span class="tiny">YYYY-MM-DD</span></th>
				<th>Projects</th>
				<th>Active?</th>
				<th>Activity date</th>
				<? if ($GLOBALS['isadmin']) { ?>
				<!--<th>Delete</td>-->
				<? } ?>
				<th>&nbsp;</th>
				<th>&nbsp;</th>
			</tr>
		</thead>
		<script type="text/javascript">
		$(document).ready(function() {
			$("#rightcheckall").click(function() {
				var checked_status = this.checked;
				$(".rightcheck").find("input[type='checkbox']").each(function() {
					this.checked = checked_status;
				});
			});
		});
		</script>
		<tbody>
			<form method="post" action="subjects.php">
			<input type="hidden" name="action" value="search">
			<tr>
				<td>&nbsp;</td>
				<td align="left"><input type="text" placeholder="UID" name="searchuid" id="searchuid" value="<?php 
echo $searchuid;
?>
" size="15" autofocus="autofocus"></td>
				<td align="left"><input type="text" placeholder="Alternate UID" name="searchaltuid" value="<?php 
echo $searchaltuid;
?>
" size="20"></td>
				<td align="left"><input type="text" placeholder="Name" name="searchname" value="<?php 
echo $searchname;
?>
" size="40"></td>
				<td align="left"><input type="text" placeholder="Sex" name="searchgender" value="<?php 
echo $searchgender;
?>
" size="2" maxlength="2"></td>
				<td align="left"><input type="text" placeholder="YYYY-MM-DD" name="searchdob" value="<?php 
echo $searchdob;
?>
" size="10"></td>
				<td> - </td>
				<td align="left"><input type="checkbox" name="searchactive" <? if ($searchactive == '1') { echo "checked"; } ?> value="1"></td>
				<td> - </td>
				<td align="left"><input type="submit" value="Search"></td>
				<? if ($GLOBALS['isadmin']) { ?>
				<td><input type="checkbox" id="rightcheckall"></td>
				<? } ?>
			</tr>
			</form>
			
			<form method="post" name="subjectlist" action="subjects.php">
			<input type="hidden" name="action" value="merge">
			<?
				$subjectsfound = 0;
				/* if all the fields are blank, only display the most recent subjects */
				if ( ($searchuid == "") && ($searchaltuid == "") && ($searchname == "") && ($searchgender == "") && ($searchdob == "") ) {
					$sqlstring = "select a.* from subjects a left join enrollment b on a.subject_id = b.subject_id left join user_project c on b.project_id = c.project_id left join projects d on c.project_id = d.project_id where a.isactive = 1 group by a.uid order by a.lastupdate desc limit 0,25";
					//PrintSQL($sqlstring);
					?>
						<tr>
							<td colspan="11" align="center" style="color: #555555; padding:8px; font-size:10pt">
								No search criteria specified
							</td>
						</tr>
					<?
				}
				else {
					$sqlstring = "select a.*, b.altuid, d.view_phi from subjects a left join subject_altuid b on a.subject_id = b.subject_id left join enrollment c on a.subject_id = c.subject_id left join user_project d on c.project_id = d.project_id left join projects e on c.project_id = e.project_id left join studies f on c.enrollment_id = f.enrollment_id where a.uid like '%$searchuid%'";
					if ($searchaltuid != "") { $sqlstring .= " and (b.altuid like '%$searchaltuid%' or b.altuid = sha1('$searchaltuid') or b.altuid = sha1(upper('$searchaltuid')) or b.altuid = sha1(lower('$searchaltuid')) or f.study_alternateid = '$searchaltuid' or f.study_alternateid like '%$searchaltuid%' or f.study_alternateid = sha1('$searchaltuid') or f.study_alternateid = sha1(upper('$searchaltuid')) or f.study_alternateid = sha1(lower('$searchaltuid')) )"; }
					if ($searchname != "") { $sqlstring .= " and (a." . MakeSQLorList($searchname,'name') . ")"; }
					if ($searchgender != "") { $sqlstring .= " and a.`gender` like '%$searchgender%'"; }
					if ($searchdob != "") { $sqlstring .= " and a.`birthdate` like '%$searchdob%'"; }
					$sqlstring .= "and a.isactive = '$searchactive' group by a.uid order by a.name asc";
					//PrintSQL($sqlstring);
					$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
					if (mysql_num_rows($result) > 0) {
						while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
							$id = $row['subject_id'];
							$name = $row['name'];
							$dob = $row['birthdate'];
							$gender = $row['gender'];
							$uid = $row['uid'];
							$isactive = $row['isactive'];
							$lastupdate = date('M j, Y g:ia',strtotime($row['lastupdate']));
							$viewphi = $row['view_phi'];

							if (!$viewphi) {
								$dob = substr($dob,0,4) . "-00-00";
							}
							if ($isactive) { $isactivecheck = "&#x2713;"; }
							else { $isactivecheck = ""; }
							
							$altuids = GetAlternateUIDs($id);
							
							if (strpos($name,'^') !== false) {
								list($lname, $fname) = explode("^",$name);
								$name = strtoupper(substr($fname,0,1)) . strtoupper(substr($lname,0,1));
							}
							
							/* get project enrollment list */
							$sqlstringA = "SELECT d.*, e.* FROM subjects a LEFT JOIN enrollment b on a.subject_id = b.subject_id LEFT JOIN projects d on d.project_id = b.project_id LEFT JOIN instance e on d.instance_id = e.instance_id WHERE a.subject_id = '$id' GROUP BY d.project_id";
							//PrintSQL($sqlstringA);
							unset($enrolllist);
							$resultA = MySQLQuery($sqlstringA, __FILE__, __LINE__);
							if (mysql_num_rows($resultA) > 0) {
								while ($rowA = mysql_fetch_array($resultA, MYSQL_ASSOC)) {
									$projectid = $rowA['project_id'];
									$projectname = $rowA['project_name'];
									$projectcostcenter = $rowA['project_costcenter'];
									if ($projectid != "") {
										$enrolllist[$projectid] = "$projectname ($projectcostcenter)";
									}
								}
							}
							
							if ($isactive == 0) { ?><tr style="background-image:url('images/deleted.png')"><? } else { ?><tr><? } ?>
							
								<td><input type="checkbox" name="uids[]" value="<?php 
echo $uid;
?>
"></td>
								<!--<input type="hidden" name="uidids[]" value="<?php 
echo $id;
?>
">-->
								<td><a href="subjects.php?action=display&id=<?php 
echo $id;
?>
"><?php 
echo FormatUID($uid);
?>
</a></td>
								<td><?php 
echo implode2(', ', $altuids);
?>
</td>
								<td><?php 
echo $name;
?>
</td>
								<td><?php 
echo $gender;
?>
</td>
								<td><?php 
echo $dob;
?>
</td>
								<td>
									<? if (count($enrolllist) > 0) { ?>
									<details style="font-size:8pt; color: gray">
									<summary>Enrolled projects</summary>
									<?
										//PrintVariable($enrolllist);
										foreach ($enrolllist as $projectid => $val) {
											$sqlstringA = "select * from user_project where project_id = '$projectid' and user_id = (select user_id from users where username = '******'username'] . "')";
											$resultA = MySQLQuery($sqlstringA, __FILE__, __LINE__);
											$viewphi = 0;
											if (mysql_num_rows($resultA) > 0) {
												$rowA = mysql_fetch_array($resultA, MYSQL_ASSOC);
												$viewphi = $rowA['view_phi'];
											}
											if ($viewphi) {
												?><span style="color:#238217; white-space:nowrap;" title="You have access to <?php 
echo $val;
?>
">&#8226; <?php 
echo $val;
?>
</span><br><?
											}
											else {
												?><span style="color:#8b0000; white-space:nowrap;" title="You <b>do not</b> have access to <?php 
echo $val;
?>
">&#8226; <?php 
echo $val;
?>
</span><br><?
											}
										}
									?>
									</details>
									<?
									}
									else {
										?><span style="font-size:8pt; color: darkred">Not enrolled</span><?
									}
									?>
								</td>
								<td><?php 
echo $isactivecheck;
?>
</td>
								<td><?php 
echo $lastupdate;
?>
</td>
								<? if ($GLOBALS['isadmin']) { ?>
								<!--<td><a href="subjects.php?action=deleteconfirm&id=<?php 
echo $id;
?>
"><div class="adminbutton" style="padding: 0px; margin; 0px;">X</div></a></td>-->
								<? } ?>
								<td></td>
								<? if ($GLOBALS['issiteadmin']) { ?>
								<td class="rightcheck"><input type="checkbox" name="ids[]" value="<?php 
echo $id;
?>
"></td>
								<? } ?>
							</tr>
							<? 
						}
						$subjectsfound = 1;
					}
				?>
				<tr>
					<td colspan="8">
						<? if ($GLOBALS['issiteadmin']) {?>
						<input type="submit" name="merge" value="Merge selected subjects" style="border: 1px solid red; background-color: pink; width:150px; margin:4px" onclick="document.subjectlist.action='subjects.php';document.subjectlist.action.value='merge'" title="Merges all studies from the selected subjects">
						<? } ?>
						<br><br>
						<select name="subjectgroupid">
							<?
								$sqlstring = "select user_id from users where username = '******'username'] . "'";
								$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
								$row = mysql_fetch_array($result, MYSQL_ASSOC);
								$userid = $row['user_id'];
							
								$sqlstring = "select * from groups where group_type = 'subject' and group_owner = '$userid'";
								$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									$groupid = $row['group_id'];
									$groupname = $row['group_name'];
									?>
									<option value="<?php 
echo $groupid;
?>
"><?php 
echo $groupname;
?>
									<?
								}
							?>
						</select>
						<input type="submit" name="addtogroup" value="Add to group" onclick="document.subjectlist.action='groups.php';document.subjectlist.action.value='addsubjectstogroup'">
					</td>
					<td colspan="3" align="right">
						<? if ($GLOBALS['issiteadmin']) {?>
						<input type="submit" style="border: 1px solid red; background-color: pink; width:150px; margin:4px" name="obliterate" value="Obliterate subjects" title="Remove all database entries for the subject and move their data to a /deleted directory" onclick="document.subjectlist.action='subjects.php';document.subjectlist.action.value='obliterate'"><br>
						<? } ?>
					</td>
				</tr>
				<?
				}
				?>
			</table>
			</form>
		</tbody>
	</table>
	<?
	}
Exemple #2
0
	function DisplayStudy($id, $audit, $fix, $search_pipelineid, $search_name, $search_compare, $search_value, $search_type, $search_swversion, $imgperline) {
	
		$id = mysql_real_escape_string($id);
		
		$sqlstring = "select a.*, c.uid, d.project_costcenter, d.project_id, c.subject_id from studies a left join enrollment b on a.enrollment_id = b.enrollment_id left join subjects c on b.subject_id = c.subject_id left join projects d on b.project_id = d.project_id where a.study_id = '$id'";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		if (mysql_num_rows($result) > 0) {
			$row = mysql_fetch_array($result, MYSQL_ASSOC);
			$study_id = $row['study_id'];
			$enrollmentid = $row['enrollment_id'];
			//$equipmentid = $row['equipment_id'];
			$study_num = $row['study_num'];
			$study_alternateid = $row['study_alternateid'];
			$study_modality = $row['study_modality'];
			$study_datetime = $row['study_datetime'];
			$study_ageatscan = $row['study_ageatscan'];
			$study_height = $row['study_height'];
			$study_weight = $row['study_weight'];
			$study_type = $row['study_type'];
			$study_operator = $row['study_operator'];
			$study_physician = $row['study_performingphysician'];
			$study_site = $row['study_site'];
			$study_notes = $row['study_notes'];
			$study_doradread = $row['study_doradread'];
			$study_radreaddate = $row['study_radreaddate'];
			$study_radreadfindings = $row['study_radreadfindings'];
			$study_etsnellenchart = $row['study_etsnellenchart'];
			$study_etvergence = $row['study_etvergence'];
			$study_ettracking = $row['study_ettracking'];
			$study_snpchip = $row['study_snpchip'];
			$study_status = $row['study_status'];
			$study_alternateid = $row['study_alternateid'];
			$study_experimenter = $row['study_experimenter'];
			$study_desc = $row['study_desc'];
			$study_createdby = $row['study_createdby'];
			$uid = $row['uid'];
			$subjectid = $row['subject_id'];
			$costcenter = $row['project_costcenter'];
			$projectid = $row['project_id'];
			
			$ft1 = floor($study_height/0.3048);
			$ft2 = (($study_height/0.3048)-$ft1)*12;
			$in = number_format($ft2,1);
			
			if (($study_height == 0) || ($study_weight == 0)) {
				$bmi = 0;
			}
			else {
				$bmi = $study_weight / ( $study_height * $study_height);
			}
			
			$study_heightft = "$ft1' $in\"";
		}
		else {
			?>
			Study [<?php 
echo $id;
?>
] does not exist
			<?
			return;
		}
		
		if ($study_modality == "") { $study_modality = "Missing modality"; $class="missing"; }
		else { $class = "value"; }

		$study_datetime = date("F j, Y g:ia",strtotime($study_datetime));
		$study_radreaddate = date("F j, Y g:ia",strtotime($study_radreaddate));

		
		/* get privacy information */
		$username = $_SESSION['username'];
		$sqlstring = "select user_id from users where username = '******'";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$userid = $row['user_id'];

		$sqlstring = "select b.* from user_project a left join projects b on a.project_id = b.project_id where a.project_id = $projectid and a.view_data = 1 and a.user_id = '$userid'";
		//PrintSQL($sqlstring);
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		if (mysql_num_rows($result) > 0) {
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$projectname = $row['project_name'];
				$projectcostcenter = $row['project_costcenter'];
				$dataprojectlist[] = "$projectname ($projectcostcenter)";
			}
			$dataaccess = 1;
		}
		else {
			$dataaccess = 0;
		}
		
		$urllist['Subject List'] = "subjects.php";
		$urllist[$uid] = "subjects.php?action=display&id=$subjectid";
		$urllist["Study " . $study_num] = "studies.php?id=$id";
		NavigationBar("Studies", $urllist, 1, null, $dataaccess, null, $dataprojectlist);

		if (!$dataaccess) {
			echo "You do not have data access to this project. Consult your NiDB administrator";
			return;
		}
		
		/* update the mostrecent table */
		UpdateMostRecent($userid, '', $id);

		?>
		<div align="center">
		<span class="uid"><?php 
echo FormatUID($uid);
?>
</span>
		</div>
		<br>
		
		<style>
		#preview{
			position:absolute;
			border:1px solid #ccc;
			background:gray;
			padding:0px;
			display:none;
			color:#fff;
			}
		</style>
		<script type="text/javascript">
			$(document).ready(function() {
				//$('a.basic').cluetip({width: 275});
				//$('a.wide').cluetip({width: 800, clickThrough:true});
				//$('a.iframe').fancybox({width:1100, height: 1000, transitionIn: 'none', transitionOut: 'none', speedIn: 0, speedOut: 0, type: 'iframe'});
			});
		</script>

		<table class="bluerounded">
			<tr>
				<td class="title"><span style="margin-left:15px">Study Information</span>
				</td>
			</tr>
			<tr>
				<td class="body">
					<table class="reviewtable" width="100%">
						<tr>
							<td colspan="2" align="center">
							</td>
						</tr>
						<tr>
							<td class="label">Study number</td>
							<td class="value"><?php 
echo $study_num;
?>
</td>
						</tr>
						<tr>
							<td class="label">Study ID</td>
							<td class="value"><tt><?php 
echo $uid;
echo $study_num;
?>
</tt></td>
						</tr>
						<tr>
							<td class="label">Alternate Study ID</td>
							<td class="value"><tt><?php 
echo $study_alternateid;
?>
</tt></td>
						</tr>
						<tr>
							<td class="label">Modality</td>
							<td class="<?php 
echo $class;
?>
"><?php 
echo $study_modality;
?>
</td>
						</tr>
						<tr>
							<td class="label">Date/time</td>
							<td class="value"><?php 
echo $study_datetime;
?>
</td>
						</tr>
						<tr>
							<td class="label">Age at scan</td>
							<td class="value"><?php 
echo number_format($study_ageatscan, 1);
?>
 y</td>
						</tr>
						<tr>
							<td class="label">Height</td>
							<td class="value"><?php 
echo number_format($study_height, 2);
?>
 m <span class="tiny">(<?php 
echo $study_heightft;
?>
)</span></td>
						</tr>
						<tr>
							<td class="label">Weight</td>
							<td class="value"><?php 
echo number_format($study_weight, 1);
?>
 kg <span class="tiny">(<?php 
echo number_format($study_weight * 2.20462, 1);
?>
 lbs)</span></td>
						</tr>
						<tr>
							<td class="label">BMI</td>
							<td class="value"><?php 
echo number_format($bmi, 1);
?>
 <span class="tiny">kg/m<sup>2</sup></span></td>
						</tr>
						<tr>
							<td class="label">Visit type</td>
							<td class="value"><?php 
echo $study_type;
?>
</td>
						</tr>
						<tr>
							<td class="label">Description</td>
							<td class="value"><?php 
echo $study_desc;
?>
</td>
						</tr>
						<tr>
							<td class="label">Operator</td>
							<td class="value"><?php 
echo $study_operator;
?>
</td>
						</tr>
						<tr>
							<td class="label">Performing physician</td>
							<td class="value"><?php 
echo $study_physician;
?>
</td>
						</tr>
						<tr>
							<td class="label">Site</td>
							<td class="value"><?php 
echo $study_site;
?>
</td>
						</tr>
						<tr>
							<td class="label">Notes</td>
							<td class="value"><?php 
echo $study_notes;
?>
</td>
						</tr>
						<? if (strtolower($study_modality) == "mr") { ?>
							<tr>
								<td class="label">Radiological read?</td>
								<td class="value"><? if ($study_doradread) { echo "Yes"; } else { echo "No"; } ?></td>
							</tr>
							<tr>
								<td class="label">Rad. read date</td>
								<td class="value"><?php 
echo $study_radreaddate;
?>
</td>
							</tr>
							<tr>
								<td class="label">Rad. read findings</td>
								<td class="value"><?php 
echo $study_radreadfindings;
?>
</td>
							</tr>
						<? } elseif (strtolower($study_modality) == "et") { ?>
							<tr>
								<td class="label">Snellen chart</td>
								<td class="value"><?php 
echo $study_etsnellenchart;
?>
</td>
							</tr>
							<tr>
								<td class="label">Vergence</td>
								<td class="value"><?php 
echo $study_etvergence;
?>
</td>
							</tr>
							<tr>
								<td class="label">Tracking</td>
								<td class="value"><?php 
echo $study_ettracking;
?>
</td>
							</tr>
						<? } elseif (strtolower($study_modality) == "snp") { ?>
							<tr>
								<td class="label">SNP chip</td>
								<td class="value"><?php 
echo $study_snpchip;
?>
</td>
							</tr>
						<? } ?>
						<tr>
							<td class="label">Status</td>
							<td class="value"><?php 
echo $study_status;
?>
</td>
						</tr>
						<tr>
							<td class="label">Created by</td>
							<td class="value"><?php 
echo $study_createdby;
?>
</td>
						</tr>
						<tr>
							<td class="label">Experimenter</td>
							<td class="value"><?php 
echo $study_experimenter;
?>
</td>
						</tr>
						<tr>
							<td colspan="2" align="center">
								<br>
								<a href="studies.php?action=editform&id=<?php 
echo $id;
?>
">Edit</a>
							</td>
						</tr>
					</table>

					<? if ($GLOBALS['isadmin']) { ?>
						<details>
							<summary style="color:darkred" class="tiny">Admin Functions</summary>
							<br><br>
						
							<span align="center" style="background-color: darkred; color: white; padding: 1px 5px; border-radius:2px; font-weight: bold; font-size: 11pt">Delete this study:</span> <a href="studies.php?action=deleteconfirm&id=<?php 
echo $id;
?>
"><span class="adminbutton" style="padding: 3px; margin; 3px;">X</span></a>
						
							<script>
							$(function() {
								$( "#newuid" ).autocomplete({
									source: "subjectlist.php",
									minLength: 2,
									autoFocus: true
								});
							});
							</script>
							<style>
							.ui-autocomplete {
								max-height: 100px;
								overflow-y: auto;
								/* prevent horizontal scrollbar */
								overflow-x: hidden;
								/* add padding to account for vertical scrollbar */
								padding-right: 20px;
							}
							/* IE 6 doesn't support max-height
							 * we use height instead, but this forces the menu to always be this tall
							 */
							* html .ui-autocomplete {
								height: 100px;
							}
							</style>									
							<form action="studies.php" method="post">
							<input type="hidden" name="studyid" value="<?php 
echo $study_id;
?>
">
							<input type="hidden" name="action" value="movestudytosubject">
							<input type="hidden" name="enrollmentid" value="<?php 
echo $enrollmentid;
?>
">
							<br>
							<span align="center" style="background-color: darkred; color: white; padding: 1px 5px; border-radius:2px; font-weight: bold; font-size: 11pt">Move study to subject:</span> <input type="text" size="10" name="newuid" id="newuid"/>
							<input type="submit" value="Move">
							</form>
							<form action="studies.php" method="post">
							<input type="hidden" name="studyid" value="<?php 
echo $study_id;
?>
">
							<input type="hidden" name="action" value="movestudytoproject">
							<input type="hidden" name="enrollmentid" value="<?php 
echo $enrollmentid;
?>
">
							<input type="hidden" name="subjectid" value="<?php 
echo $subjectid;
?>
">
							<br>
							<span align="center" style="background-color: darkred; color: white; padding: 1px 5px; border-radius:2px; font-weight: bold; font-size: 11pt">Move study to project:</span>
							<select name="newprojectid">
							<?
								$sqlstringB = "select a.project_id, b.project_name, b.project_costcenter from enrollment a left join projects b on a.project_id = b.project_id where a.subject_id = $subjectid";
								echo $sqlstringB;
								$resultB = MySQLQuery($sqlstringB, __FILE__, __LINE__);
								while ($rowB = mysql_fetch_array($resultB, MYSQL_ASSOC)) {
									$project_id = $rowB['project_id'];
									$project_name = $rowB['project_name'];
									$project_costcenter = $rowB['project_costcenter'];
									?>
									<option value="<?php 
echo $project_id;
?>
"><?php 
echo $project_name;
?>
 (<?php 
echo $project_costcenter;
?>
)</option>
									<?
								}
							?>
							</select>
							<input type="submit" value="Move">
							</form>
							
							<br>
							
							<? if (!$audit) { ?>
							<a href="studies.php?id=<?php 
echo $id;
?>
&audit=1">Perform file audit</a> - compares all dicom files to the nidb database entries. Can be very slow<br><br>
							<? } else { ?>
							<a href="studies.php?id=<?php 
echo $id;
?>
&audit=1&fix=1">Fix file errors</a> - Removes duplicates and errant files, resets file count in nidb database. Can be very slow<br><br>
						</details>
					<? } ?>
					
					<? } ?>				
				</td>
			</tr>
		</table>


		<br><br>

		<?
			if ($study_modality == "MR") {
				DisplayMRSeries($id, $study_num, $uid, $audit, $fix);
			}
			elseif ($study_modality == "CT") {
				DisplayCTSeries($id, $study_num, $uid, $audit, $fix);
			}
			else {
				DisplayGenericSeries($id, $study_modality);
			}
		?>
		<br><br><br><br><br><br>
		<?
			DisplayAnalyses($id, $search_pipelineid, $search_name, $search_compare, $search_value, $search_type, $search_swversion, $imgperline);
		?>
		<br><br><br><br><br><br>
		<?
	}
	function ShowGroup($groupid, $page) {
		
		if ($page == "") { $page = 1; }
		
		$sqlstring = "select distinct(req_modality) from data_requests where req_groupid = $groupid";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$modality = $row['req_modality'];

		$sqlstring = "select a.*, b.*, d.project_name, d.project_costcenter, e.uid, f.* from $modality" . "_series a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join projects d on c.project_id = d.project_id left join subjects e on e.subject_id = c.subject_id left join data_requests f on f.req_seriesid = a.$modality" . "series_id where f.req_groupid = $groupid order by req_groupid, uid, study_num, series_num";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$numrows = mysql_num_rows($result);

		$numperpage = 500;
		$limit = $numperpage * ($page-1);
		
		$sqlstring = "select a.*, b.*, d.project_name, d.project_costcenter, e.uid, f.* from $modality" . "_series a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join projects d on c.project_id = d.project_id left join subjects e on e.subject_id = c.subject_id left join data_requests f on f.req_seriesid = a.$modality" . "series_id where f.req_groupid = $groupid order by req_groupid, uid, study_num, series_num";
		//PrintSQL($sqlstring);
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
	?>
		<b>Showing <?php 
echo $numrows;
?>
 requests from the last 7 days</b>
		<br>
		<?php 
echo $numperpage;
?>
/page: 
		<?
			$remainder = $numrows;
			$pg = 1;
			while (($remainder+$numperpage) > $numperpage) {
				if ($pg == $page) {
				?><a href="requeststatus.php?page=<?php 
echo $pg;
?>
" style="color: red"><?php 
echo $pg;
?>
</a> <span style="color:lightgray">|</span> <?
				}
				else {
				?><a href="requeststatus.php?page=<?php 
echo $pg;
?>
" style="color: blue"><?php 
echo $pg;
?>
</a> <span style="color:lightgray">|</span> <?
				}
				
				$remainder -= $numperpage;
				$pg++;
			}
		?>
		<HR>
		<table width="100%" cellspacing="0" cellpadding="2">
			<tr>
				<td style="font-weight:bold; border-bottom: solid 2pt black">UID</td>
				<td style="font-weight:bold; border-bottom: solid 2pt black">Study Date</td>
				<td style="font-weight:bold; border-bottom: solid 2pt black">Destination type</td>
				<td style="font-weight:bold; border-bottom: solid 2pt black">FTP</td>
				<td style="font-weight:bold; border-bottom: solid 2pt black">Study Num</td>
				<td style="font-weight:bold; border-bottom: solid 2pt black">Format</td>
				<td style="font-weight:bold; border-bottom: solid 2pt black">Status</td>
			</tr>
		<?
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$requestid = $row['request_id'];
				$series_id = $row[$modality . 'series_id'];
				$series_desc = $row['series_desc'];
				$series_num = $row['series_num'];
				$study_id = $row['study_id'];
				$study_num = $row['study_num'];
				$study_datetime = $row['study_datetime'];
				$uid = $row['uid'];
				$series_size = $row['series_size'];
				$project_name = $row['project_name'];
				$project_costcenter = $row['project_costcenter'];
				$status = $row['req_status'];
				$format = $row['req_filetype'];
				$cpu = $row['req_cputime'];
				$destinationtype = $row['req_destinationtype'];
				
				if ($status == "complete") { $color = "#009933"; }
				if ($status == "processing") { $color = "#0000FF"; }
				if ($status == "pending") { $color = "#0000FF"; }
				if ($status == "problem") { $color = "#FF0000"; }
				
				?>
				<tr style="font-size:10pt">
					<td style="border-bottom: solid 1pt gray; border-right: solid 1pt lightgray"><?php 
echo FormatUID($uid);
?>
&nbsp;</td>
					<td style="border-bottom: solid 1pt gray; border-right: solid 1pt lightgray"><?php 
echo $study_datetime;
?>
&nbsp;</td>
					<td style="border-bottom: solid 1pt gray; border-right: solid 1pt lightgray"><? echo $destinationtype; ?>&nbsp;</td>
					<td style="border-bottom: solid 1pt gray; border-right: solid 1pt lightgray"><? echo "$remoteftpserver$destinationpath"; ?>&nbsp;</td>
					<td style="border-bottom: solid 1pt gray; border-right: solid 1pt lightgray"><a href="studies.php?id=<? echo $study_id; ?>"><span style="color: darkblue; text-decoration:underline"><?php 
echo $uid;
echo $study_num;
?>
</span></a>&nbsp;</td>
					<td style="border-bottom: solid 1pt gray; border-right: solid 1pt lightgray"><? echo $format; ?>&nbsp;</td>
					<td style="border-bottom: solid 1pt gray; border-right: solid 1pt lightgray">
						<a href="requeststatus.php?action=viewdetails&requestid=<? echo $requestid; ?>"><span style="color:<? echo $color; ?>"><u><? echo $status; ?></u></span></a>&nbsp;
					</td>
				</tr>
				<?
			}
		?>
		</table>
	<?
	}