Beispiel #1
0
	function DisplaySubject($id) {

		/* 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 c.*, d.*  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 d.project_id = c.project_id where a.subject_id = '$id' and c.user_id = '$userid' and c.view_phi = 1";
		//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'];
				$phiprojectlist[] = "$projectname ($projectcostcenter)";
			}
			$phiaccess = 1;
		}
		else {
			$phiaccess = 0;
		}
		
		$sqlstring = "select c.*, d.*  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 d.project_id = c.project_id where a.subject_id = '$id' and c.user_id = '$userid' and c.view_data = 1";
		//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;
		}
		
		/* check if they have enrollments for a valid project */
		$sqlstring = "select a.* from enrollment a right join projects b on a.project_id = b.project_id where a.subject_id = $id";
		//PrintSQL($sqlstring);
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		if (mysql_num_rows($result) > 0) {
			$hasenrollments = 1;
		}
		else {
			$hasenrollments = 0;
		}
	
		$urllist['Subject List'] = "subjects.php";
		NavigationBar("Subjects", $urllist, 1, $phiaccess, $dataaccess, $phiprojectlist, $dataprojectlist);

		/* kick them out if they shouldn't be seeing anything on this page */
		//if ((!$phiaccess) && (!$dataaccess) && (!$GLOBALS['isadmin'])) {
		//if ((!$phiaccess) && (!$dataaccess) && ($hasenrollments)) {
		//	return;
		//}

		/* update the mostrecent table */
		UpdateMostRecent($userid, $id,'');
		
		/* get all existing info about this subject */
		$sqlstring = "select * from subjects where subject_id = $id";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$name = $row['name'];
		$dob = $row['birthdate'];
		$gender = $row['gender'];
		$ethnicity1 = $row['ethnicity1'];
		$ethnicity2 = $row['ethnicity2'];
		$handedness = $row['handedness'];
		$education = $row['education'];
		$phone1 = $row['phone1'];
		$email = $row['email'];
		$maritalstatus = $row['marital_status'];
		$smokingstatus = $row['smoking_status'];
		$uid = $row['uid'];
		$guid = $row['guid'];
		$cancontact = $row['cancontact'];

		//print_r($row);
		/* get the family UID */
		$sqlstring = "select b.family_uid, b.family_name from family_members a left join families b on a.family_id = b.family_id where a.subject_id = $id";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$familyuid = $row['family_uid'];
		$familyname = $row['family_name'];
		
		/* get list of alternate subject UIDs */
		$altuids = GetAlternateUIDs($id);

		list($lastname, $firstname) = explode("^",$name);
		list($lname, $fname) = explode("^",$name);
		$name = strtoupper(substr($fname,0,1)) . strtoupper(substr($lname,0,1));

		switch ($gender) {
			case "U": $gender = "Unknown"; break;
			case "F": $gender = "Female"; break;
			case "M": $gender = "Male"; break;
			case "O": $gender = "Other"; break;
		}
					
		switch ($ethnicity1) {
			case "": $ethnicity1 = "Unknown"; break;
			case "hispanic": $ethnicity1 = "Hispanic/Latino"; break;
			case "nothispanic": $ethnicity1 = "Not hispanic/Latino"; break;
		}

		switch ($ethnicity2) {
			case "": $ethnicity2 = "Unknown"; break;
			case "indian": $ethnicity2 = "American Indian/Alaska Native"; break;
			case "asian": $ethnicity2 = "Asian"; break;
			case "black": $ethnicity2 = "Black/African American"; break;
			case "islander": $ethnicity2 = "Hawaiian/Pacific Islander"; break;
			case "white": $ethnicity2 = "White"; break;
		}
		
		switch ($handedness) {
			case "U": $handedness = "Unknown"; break;
			case "R": $handedness = "Right"; break;
			case "L": $handedness = "Left"; break;
			case "A": $handedness = "Ambidextrous"; break;
		}
		
		switch ($education) {
			case 0: $education = "Unknown"; break;
			case 1: $education = "Grade School"; break;
			case 2: $education = "Middle School"; break;
			case 3: $education = "High School/GED"; break;
			case 4: $education = "Trade School"; break;
			case 5: $education = "Associates Degree"; break;
			case 6: $education = "Bachelors Degree"; break;
			case 7: $education = "Masters Degree"; break;
			case 8: $education = "Doctoral Degree"; break;
		}
		
		?>

		<br>
		
		<style>
			details[open] { border: 1px solid #ccc; background-color: #eee}
		</style>
		
		<table width="100%" cellpadding="4">
			<tr>
				<td valign="top" align="center">
				
					<table class="download">
						<tr>
							<td class="title">
								<?php 
echo $uid;
?>
							</td>
						</tr>
						<tr>
							<td align="center" colspan="2" style="border-radius:5px; background-color: white; padding: 5px">
								<div align="left" style="font-weight: bold; font-size: 12pt">Demographics</div>
								<div align="left">
								<? if ($phiaccess) { ?>
								<details>
									<summary class="tiny" style="color:darkred">Edit or delete</summary>
									<div style="padding:5px; font-size:11pt">
									<a href="subjects.php?action=editform&id=<?php 
echo $id;
?>
">Edit Demographics</a>
									<br><br><br>
									<? if ($GLOBALS['isadmin']) { ?>
									<a href="subjects.php?action=deleteconfirm&id=<?php 
echo $id;
?>
"><span style="color: red; text-decoration:underline">Delete</span></a>
									<? } ?>
									</div>
								</details>
								<? } ?>
								</div>
								
								<br>
								<table class="reviewtable">
									<tr>
										<td class="label">Subject initials</td>
										<td class="value"><?php 
echo $name;
?>
</td>
									</tr>
									<tr>
										<td class="label">Date of birth</td>
										<td class="value"><?php 
echo $dob;
?>
</td>
									</tr>
									<tr>
										<td class="label">Gender</td>
										<td class="value"><?php 
echo $gender;
?>
</td>
									</tr>
									<tr>
										<td class="label" style="white-space:nowrap;">Alternate UIDs</td>
										<td class="value">
										<?
											foreach ($altuids as $altid) {
												if (strlen($altid) > 20) {
													echo "<span title='$altid'>" . substr($altid,0,20) . "...</span> ";
												}
												else {
													echo "$altid ";
												}
											}
										?>
										</td>
									</tr>
									<tr>
										<td class="label">Ethnicity1&2</td>
										<td class="value"><?php 
echo $ethnicity1;
?>
, <?php 
echo $ethnicity2;
?>
</td>
									</tr>
									<tr>
										<td class="label">Handedness</td>
										<td class="value"><?php 
echo $handedness;
?>
</td>
									</tr>
									<tr>
										<td class="label">Education</td>
										<td class="value"><?php 
echo $education;
?>
</td>
									</tr>
									<tr>
										<td class="label">Phone</td>
										<td class="value"><?php 
echo $phone1;
?>
</td>
									</tr>
									<tr>
										<td class="label">E-mail</td>
										<td class="value"><?php 
echo $email;
?>
</td>
									</tr>
									<tr>
										<td class="label">Marital Status</td>
										<td class="value"><?php 
echo $maritalstatus;
?>
</td>
									</tr>
									<tr>
										<td class="label">Smoking&nbsp;Status</td>
										<td class="value"><?php 
echo $smokingstatus;
?>
</td>
									</tr>
									<tr>
										<td class="label">GUID</td>
										<td class="value"><?php 
echo $guid;
?>
</td>
									</tr>
									<tr>
										<td class="label">Can contact?</td>
										<td class="value"><?php 
echo $cancontact;
?>
</td>
									</tr>
								</table>
								<br>
								
								<br><br>
								<div align="left" style="font-weight: bold; font-size: 12pt">Family</div>
								<div align="left">
								<? if ($phiaccess) { ?>
								<details>
								<summary class="tiny" style="color:darkred">Add family members</summary>
									<table style="font-size: 10pt">
									<?
										/* display existing subject relations */
										$sqlstring = "select a.*, b.uid from subject_relation a left join subjects b on a.subjectid2 = b.subject_id where a.subjectid1 = $id";
										$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
										while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
											$subjectid2 = $row['subjectid2'];
											$relation = $row['relation'];
											$uid2 = $row['uid'];
											
											switch ($relation) {
												case "siblingf": $relation = "half-sibling (same father)"; break;
												case "siblingm": $relation = "half-sibling (same mother)"; break;
												case "sibling": $relation = "sibling"; break;
												case "parent": $relation = "parent"; break;
												case "child": $relation = "child"; break;
											}
											
											?>
											<tr>
												<td><?php 
echo $uid;
?>
 is the <b><?php 
echo $relation;
?>
</b> of <a href="subjects.php?id=<?php 
echo $subjectid2;
?>
"><?php 
echo $uid2;
?>
</a></td>
											</tr>
											<?
										}
									?>
										<script>
										$(function() {
											$( "#uid2" ).autocomplete({
												source: "autocomplete_uid.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>									
										<tr>
											<form action="subjects.php" method="post">
											<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
											<input type="hidden" name="action" value="addrelation">
											<td>
												<br><br>
												<?php 
echo $uid;
?>
 is the
												<br>
												<select name="relation">
												<option value="siblingm">Half-sibling (same mother)</option>
												<option value="siblingf">Half-sibling (same father)</option>
												<option value="sibling">Sibling</option>
												<option value="parent">Parent</option>
												<option value="child">Child</option>
											</select> of <input type="text" size="10" name="uid2" id="uid2"/>
											<br>
											<input type="checkbox" name="makesymmetric" value="1" checked title="If subject 1 is the parent of subject 2, a corresponding relation will also show subject 2 is a child of subject 1">Make symmetric 
											<input type="submit" value="Add relation"></td>
											</form>
										</tr>
									</table>
								</details>
								<? } ?>
								</div>
								<br>
								<table class="reviewtable">
									<tr>
										<td class="label">Family UID</td>
										<td class="value"><?php 
echo $familyuid;
?>
</td>
									</tr>
									<tr>
										<td class="label">Family name</td>
										<td class="value"><?php 
echo $familyname;
?>
</td>
									</tr>
								</table>
								<br>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" align="center">
					<table class="download">
						<tr>
							<td class="title">
								Projects
							</td>
							<form action="subjects.php" method="post">
							<td align="right" style="color: white">
								<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
								<input type="hidden" name="action" value="enroll">
								<span style="font-size:10pt">Enroll subject in project:</span>
								<select name="projectid">
								<?
									$sqlstring = "select a.*, b.user_fullname from projects a left join users b on a.project_pi = b.user_id where a.project_status = 'active' and a.instance_id = " . $_SESSION['instanceid'] . " order by a.project_name";
									$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
									while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
										$project_id = $row['project_id'];
										$project_name = $row['project_name'];
										$project_costcenter = $row['project_costcenter'];
										$project_enddate = $row['project_enddate'];
										$user_fullname = $row['user_fullname'];
										
										if (strtotime($project_enddate) < strtotime("now")) { $style="color: gray"; } else { $style = ""; }
										//echo "[" . strtotime($project_enddate) . ":" . strtotime("now") . "]<br>";
										?>
										<option value="<?php 
echo $project_id;
?>
" style="<?php 
echo $style;
?>
"><?php 
echo $project_name;
?>
 (<?php 
echo $project_costcenter;
?>
)</option>
										<?
									}
								?>
								</select>
								<input type="submit" value="Enroll">
							</td>
							</form>
						</tr>
						
						<?
							$sqlstringA = "select a.project_id 'projectid', a.*, b.*, enroll_startdate, enroll_enddate from enrollment a left join projects b on a.project_id = b.project_id where a.subject_id = $id";
							//$resultA = mysql_query($sqlstringA) or die("Query failed: " . mysql_error() . "<br><i>$sqlstringA</i><br>");
							$resultA = MySQLQuery($sqlstringA, __FILE__, __LINE__);
							//PrintSQL($sqlstringA);
							while ($rowA = mysql_fetch_array($resultA, MYSQL_ASSOC)) {
								$enrollmentid = $rowA['enrollment_id'];
								$enroll_startdate = $rowA['enroll_startdate'];
								$enroll_enddate = $rowA['enroll_enddate'];
								$enrollgroup = $rowA['enroll_subgroup'];
								$projectid = $rowA['projectid'];
								$project_name = $rowA['project_name'];
								$costcenter = $rowA['project_costcenter'];
								$project_enddate = $rowA['project_enddate'];
								
								$enrolldate = date('M j, Y g:ia',strtotime($enroll_startdate));
								
								if ($row['irb_consent'] != "") { $irb = "Y"; }
								else { $irb = "N"; }
							
								//echo "$enroll_enddate <--> " . date("Y-m-d H:i:s") . "<br>";
								if (($enroll_enddate > date("Y-m-d H:i:s")) || ($enroll_enddate == "0000-00-00 00:00:00")) {
									$enrolled = true;
								}
								else {
									$enrolled = false;
								}
								
								/* check if this user has data access to this project */
								$projectaccess = 1;
								$sqlstring2 = "select view_data from user_project where project_id = $projectid and view_data = 1 and user_id = $userid";
								$result2 = MySQLQuery($sqlstring2, __FILE__, __LINE__);
								if (mysql_num_rows($result2) < 1) {
									$projectaccess = 0;
								}
								
								$subjectaltids = implode2(',',GetAlternateUIDs($id, $enrollmentid));
						?>
						<script type="text/javascript">
							$(document).ready(function(){
								$(".edit_inline<? echo $enrollmentid; ?>").editInPlace({
									url: "group_inlineupdate.php",
									params: "action=editinplace&id=<? echo $enrollmentid; ?>",
									default_text: "<i style='color:#AAAAAA'>Click to add group name...</i>",
									bg_over: "white",
									bg_out: "lightyellow",
								});
							});
						</script>
						<tr>
							<td class="section" colspan="2">
							
								<table class="subdownload" width="100%">
									<tr>
										<td class="label" style="width: 200px; text-align: left; vertical-align: top;">
											<?php 
echo $project_name;
?>
 (<?php 
echo $costcenter;
?>
)<br><br>
											<div style="font-size:10pt; font-weight: normal;">
											Enrolled: <span style="color: darkblue"><?php 
echo $enrolldate;
?>
</span><br>
											<? if ($phiaccess) { ?>
											Group: <span id="enroll_subgroup" class="edit_inline<? echo $enrollmentid; ?>" style="background-color: lightyellow; padding: 1px 3px; font-size: 9pt;"><? echo $enrollgroup; ?></span><br>
											<? } ?>
											<b>ID:</b> <?php 
echo $subjectaltids;
?>
											<br>
											<? if ($enroll_enddate != "0000-00-00 00:00:00") { ?>
											<span style="color: darkred">Un-enroll date: <?php 
echo $enroll_enddate;
?>
</span><br>
											<? } ?>
											<? if ($phiaccess) { ?>
											<!--Project end date: <?php 
echo $project_enddate;
?>
-->
											Project status: <a href="projectreport.php?action=viewreport&enrollmentid=<?php 
echo $enrollmentid;
?>
">View report</a>
											</div>
											<? if (($enrolled) && ($GLOBALS['isadmin'])) { ?>
											<form action="subjects.php" method="post">
											<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
											<input type="hidden" name="action" value="changeproject">
											<input type="hidden" name="enrollmentid" value="<?php 
echo $enrollmentid;
?>
">
											<br>
											<details>
											<summary class="tiny" style="color:darkred; font-weight:normal">Enroll in different project</summary>
											<span style="font-size: 10pt; font-weight: normal;">Un-enroll subject from this project and enroll in this project, moving all imaging, assessments, and measures:</span>
											<select name="newprojectid">
											<?
												$sqlstring = "select a.*, b.user_fullname from projects a left join users b on a.project_pi = b.user_id where a.project_status = 'active' order by a.project_name";
												$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
												while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
													$project_id = $row['project_id'];
													$project_name = $row['project_name'];
													$project_costcenter = $row['project_costcenter'];
													$project_enddate = $row['project_enddate'];
													$user_fullname = $row['user_fullname'];
													
													if (strtotime($project_enddate) < strtotime("now")) { $style="color: gray"; } else { $style = ""; }
													//echo "[" . strtotime($project_enddate) . ":" . strtotime("now") . "]<br>";
													?>
													<option value="<?php 
echo $project_id;
?>
" style="<?php 
echo $style;
?>
"><?php 
echo $project_name;
?>
 (<?php 
echo $project_costcenter;
?>
)</option>
													<?
												}
											?>
											</select>
											<input type="submit" value="Move">
											</form>
											</details>
											<?
												} /* end if phi access */
											} /* end if enrolled */ ?>
										</td>
										<td class="main">
											<?
												if (!$projectaccess) {
													echo "No data access privileges to this project";
												}
												else {
											?>
											<table width="100%">
												<tr>
													<td><b>Imaging studies</b>
													</td>
													<td align="right">
														<? if (!$enrolled) { ?>
														<span style="color: #666">Subject is un-enrolled. Cannot create new studies</span>
														<? } else { ?>
														<!--<a href="subjects.php?action=newstudy&enrollmentid=<?php 
echo $enrollmentid;
?>
&id=<?php 
echo $id;
?>
" style="font-size:11pt">Create new study</a>-->
														
														<form action="subjects.php" method="post">
														<td align="right">
															<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
															<input type="hidden" name="enrollmentid" value="<?php 
echo $enrollmentid;
?>
">
															<input type="hidden" name="action" value="newstudy">
															<span style="font-size:10pt">Create new study:</span>
															<select name="modality">
																<option value="" style="<?php 
echo $style;
?>
">(Select modality)</option>															<?
																$sqlstring = "select * from modalities order by mod_code";
																$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
																while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
																	$mod_code = $row['mod_code'];
																	$mod_desc = $row['mod_desc'];
																	?>
																	<option value="<?php 
echo $mod_code;
?>
" style="<?php 
echo $style;
?>
">[<?php 
echo $mod_code;
?>
] <?php 
echo $mod_desc;
?>
</option>
																	<?
																}
															?>
															</select>
															<input type="submit" value="Create">
														</td>
														</form>														
														
														<? } ?>
													</td>
												</tr>
											</table>
											<?
												$sqlstring = "select a.*, datediff(a.study_datetime, c.birthdate) 'ageatscan' 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 where a.enrollment_id = $enrollmentid order by a.study_datetime desc";
												//$result2 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
												$result2 = MySQLQuery($sqlstring, __FILE__, __LINE__);
												if (mysql_num_rows($result2) > 0) {
												?>
												<table width="100%" class="smalldisplaytable" style="background-color: #FFFFFF; border-radius: 5px; width: 100%; padding:5px">
													<thead>
														<th>#</th>
														<th>Modality</th>
														<th>Date</th>
														<th>Age<span class="tiny">&nbsp;y</span></th>
														<th>Physician</th>
														<th>Operator</th>
														<th>Site</th>
														<th>Study ID</th>
														<th>Visit</th>
														<th>Rad Read</th>
													</thead>
													<tbody>
													<?
													while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
														$study_id = $row2['study_id'];
														$study_num = $row2['study_num'];
														$study_modality = $row2['study_modality'];
														$study_datetime = $row2['study_datetime'];
														$study_ageatscan = $row2['study_ageatscan'];
														$calcage = number_format($row2['ageatscan']/365.25,1);
														$study_operator = $row2['study_operator'];
														$study_performingphysician = $row2['study_performingphysician'];
														$study_site = $row2['study_site'];
														$study_type = $row2['study_type'];
														$study_status = $row2['study_status'];
														$study_doradread = $row2['study_doradread'];
														
														if (trim($study_ageatscan) != 0) {
															$age = $study_ageatscan;
														}
														else {
															$age = $calcage;
														}
														?>
														<tr onMouseOver="this.style.backgroundColor='#9EBDFF'" onMouseOut="this.style.backgroundColor=''">
															<td><a href="studies.php?id=<?php 
echo $study_id;
?>
"><?php 
echo $study_num;
?>
</a></td>
															<td><?php 
echo $study_modality;
?>
</td>
															<td><?php 
echo $study_datetime;
?>
</td>
															<td><?php 
echo number_format($age, 1);
?>
</td>
															<td><?php 
echo $study_performingphysician;
?>
</td>
															<td><?php 
echo $study_operator;
?>
</td>
															<td><?php 
echo $study_site;
?>
</td>
															<td><tt><?php 
echo $uid;
echo $study_num;
?>
</tt></td>
															<td><?php 
echo $study_type;
?>
</td>
															<td><? if ($study_doradread) { echo "&#x2713;"; } ?></td>
														</tr>
														<?
													}
													?>
												</table>
												<?
												}
												else {
													?>
													<div style="font-size: 9pt; background-color:white; text-align: center; border: 1px solid #888; border-radius:5px; padding:3px">No imaging studies</div>
													<?
												}
												?>
											
											<? if ($_SESSION['enablebeta']) { ?>
											<br><br>
											<!-- instruments table -->
											<table width="100%">
												<tr>
													<td><b>Assessments</b> <?php 
echo PrintBeta();
?>
</td>
													<form action="assessments.php" method="post">
													<td align="right">
														<? if (!$enrolled) { $disabled = "disabled"; } else { $disabled = ""; } ?>
														<input type="hidden" name="enrollmentid" value="<?php 
echo $enrollmentid;
?>
">
														<input type="hidden" name="action" value="create">
														<span style="font-size: 10pt">Add assessment:</span>
														<select name="formid" <?php 
echo $disabled;
?>
>
															<option value="">(Select assessment)</option>
														<?
															$sqlstringB = "select * from assessment_forms where form_ispublished = 1 order by form_title";
															//$resultB = mysql_query($sqlstringB) or die("Query failed: " . mysql_error() . "<br><i>$sqlstringB</i><br>");
															$resultB = MySQLQuery($sqlstringB, __FILE__, __LINE__);
															while ($rowB = mysql_fetch_array($resultB, MYSQL_ASSOC)) {
																$form_id = $rowB['form_id'];
																$form_title = $rowB['form_title'];
																?>
																<option value="<?php 
echo $form_id;
?>
" style="<?php 
echo $style;
?>
"><?php 
echo $form_title;
?>
</option>
																<?
															}
														?>
														</select>
														<input type="submit" value="Create"  <?php 
echo $disabled;
?>
>
													</td>
													</form>

												</tr>
											</table>
												<?
												$sqlstring3 = "select a.*, b.form_title from assessments a left join assessment_forms b on a.form_id = b.form_id where a.enrollment_id = $enrollmentid";
												//$result3 = mysql_query($sqlstring3) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring3</i><br>");
												$result3 = MySQLQuery($sqlstring3, __FILE__, __LINE__);
												if (mysql_num_rows($result3) > 0) {
												?>
												<table width="100%" class="smalldisplaytable" style="background-color: #FFFFFF; border-radius: 5px; width: 100%; padding:5px">
													<thead>
														<th>Instrument</th>
														<th>Date</th>
														<th>Experimentor</th>
														<th>Rater</th>
														<th>Complete?</th>
													</thead>
													<tbody>
													<?
													while ($row3 = mysql_fetch_array($result3, MYSQL_ASSOC)) {
														$experiment_id = $row3['experiment_id'];
														$form_title = $row3['form_title'];
														$exp_admindate = $row3['exp_admindate'];
														$experimentor = $row3['experimentor'];
														$rater_username = $row3['rater_username'];
														$iscomplete = $row3['iscomplete'];
														if ($iscomplete) { $action = "view"; } else { $action = "edit"; }
														?>
														<tr onMouseOver="this.style.backgroundColor='#9EBDFF'" onMouseOut="this.style.backgroundColor=''">
															<td><a href="assessments.php?action=<?php 
echo $action;
?>
&experimentid=<?php 
echo $experiment_id;
?>
"><?php 
echo $form_title;
?>
</a></td>
															<td><?php 
echo $exp_admindate;
?>
</td>
															<td><?php 
echo $experimentor;
?>
</td>
															<td><?php 
echo $rater_username;
?>
</td>
															<td><? if ($iscomplete) { echo "&#10004;"; }
															else {
																?>
																<a href="assessments.php?action=completed&experimentid=<?php 
echo $experiment_id;
?>
">Mark as complete</a>
																<?
															}
															?></td>
														</tr>
														<?
													}
													?>
													</table>
													<?
												}
												else {
													?>
													<div style="font-size: 9pt; background-color:white; text-align: center; border: 1px solid gray; border-radius:5px; padding:3px">No assessments</div>
													<?
												}
												?>
											<? } ?>
											<br>
											<!-- phenotypic measures table -->
											<table width="100%">
												<tr>
													<td><b>Phenotypic </b><a href="measures.php?enrollmentid=<?php 
echo $enrollmentid;
?>
">measures</a></td>
												</tr>
											</table>
												<?
												$sqlstring3 = "select * from measures a left join measurenames b on a.measurename_id = b.measurename_id where enrollment_id = $enrollmentid";
												$result3 = MySQLQuery($sqlstring3, __FILE__, __LINE__);
												$numrows = mysql_num_rows($result3);
												if ($numrows > 0) {
												?>
													<div style="-moz-column-count:2; -webkit-column-count:2; column-count:2; width: 100%; font-size:9pt; background-color: white; padding: 4px; border-radius:5px; -moz-column-rule:1px outset #DDD; -webkit-column-rule:1px outset #DDD; column-rule:1px outset #DDD; border:1px solid #888">
													<?
													while ($row3 = mysql_fetch_array($result3, MYSQL_ASSOC)) {
														$measureid = $row3['measure_id'];
														$measure_name = $row3['measure_name'];
														$measure_type = $row3['measure_type'];
														$measure_valuestring = $row3['measure_valuestring'];
														$measure_valuenum = $row3['measure_valuenum'];
														$measure_rater = $row3['measure_rater'];
														$measure_rater2 = $row3['measure_rater2'];
														$measure_isdoubleentered = $row3['measure_isdoubleentered'];
														$measure_datecomplete = $row3['measure_datecomplete'];
														switch ($measure_type) {
															case 's': $value = $measure_valuestring; break;
															case 'n': $value = $measure_valuenum; break;
														}
														if (!$measure_isdoubleentered) {
															$color="red";
														}
														else {
															$color="darkblue";
														}
														?>
														<?php 
echo $measure_name;
?>
 <span style="color: <?php 
echo $color;
?>
"><b><?php 
echo $value;
?>
</b></span><br>
														<?
													}
													?>
													</div>
													<?
												}
												else {
													?>
													<div style="font-size: 9pt; background-color:white; text-align: center; border: 1px solid #888; border-radius:5px; padding:3px">No measures</div>
													<?
												}
											?>
											<? if ($_SESSION['enablebeta']) { ?>
											<br>
											<!-- prescriptions table -->
											<table width="100%">
												<tr>
													<td><a href="prescriptions.php?enrollmentid=<?php 
echo $enrollmentid;
?>
">Prescriptions</a> <span class="tiny">medications/treatments/substance use</span> <?php 
echo PrintBeta();
?>
</td>
												</tr>
											</table>
												<?
												$sqlstring3 = "select *, date_format(rx_startdate,'%Y-%m-%d') 'startdate', date_format(rx_enddate,'%Y-%m-%d') 'enddate' from prescriptions where enrollment_id = $enrollmentid";
												$result3 = MySQLQuery($sqlstring3, __FILE__, __LINE__);
												$numrows = mysql_num_rows($result3);
												if ($numrows > 0) {
													?>
													<details>
													<summary>Prescription list</summary>
													<table>
														<tr>
															<td>Rx</td>
															<td>Route</td>
															<td>Amount</td>
															<td>Dates</td>
														</tr>
													<?
													while ($row3 = mysql_fetch_array($result3, MYSQL_ASSOC)) {
														$rx_id = $row3['rx_id'];
														$startdate = $row3['startdate'];
														$enddate = $row3['enddate'];
														$rx_dose = $row3['rx_doseamount'];
														$rx_dosefreq = $row3['rx_dosefrequency'];
														$rx_route = $row3['rx_route'];
														$rx_name = $row3['rx_name'];
														$rx_group = $row3['rx_group'];
														?>
														<tr>
															<td><?php 
echo $rx_name;
?>
</td>
															<td><?php 
echo $rx_route;
?>
</td>
															<td><?php 
echo $rx_dose;
?>
/<?php 
echo $rx_dosefreq;
?>
</td>
															<td><?php 
echo $startdate;
?>
-<?php 
echo $enddate;
?>
</td>
														</tr>
														<?
													}
													?>
													</table>
													<?
												}
												else {
													?>
													<div style="font-size: 9pt; background-color:white; text-align: center; border: 1px solid #888; border-radius:5px; padding:3px">No prescriptions</div>
													<?
												}
												?>
											<? } ?>
										</td>
										<? } ?>
									</tr>
								</table>
							</td>
						</tr>
						<?
							}
						?>
					</table>
				</td>
			</tr>
		</table>
		<br><br><bR><br><br>
		<?
	}
Beispiel #2
0
	function DisplaySearchForm($searchvars, $action) {
	
		$urllist['New Search'] = "search.php";
		NavigationBar("Search", $urllist);
		
	?>
	<script type="text/javascript">
	$(function() {
		$(".datepick").datepicker({changeMonth: true, changeYear: true, dateFormat: 'yy-mm-dd', minDate: '-130y', maxDate: '+130y'});
	});
	</script>

	<style>
		.sidelabel {
			font-weight: bold;
			font-size: 12pt;
			border-right: solid 1px #CCC;
			border-bottom: solid 1px #CCC;
			padding-right: 15px;
			padding-left: 10px;
			text-align: right;
		}
		.toplabel {
			color: white;
			font-weight: bold;
			font-size: 14pt;
			padding-top: 5px;
			padding-bottom: 5px;
			text-align: center;
			/*border-top-right-radius: 5px;*/
			background-color: #3B5998;
		}
		.tiny {
			font-size: 8pt;
			color: gray;
		}
		.fieldlabel {
			color: darkblue;
			text-align: right;
			vertical-align: top;
		}
		.importantfield {
			border: 1pt solid darkblue;
			background-color: lightyellow;
		}
		.fakelink {
			background-color: #DDD;
			border-right: solid 2px #777
			/*border-top: 2px solid #999;
			border-left: 2px solid #444;
			border-bottom: 2px solid #444;
			border-radius:3px; */
			padding: 1px 4px;
			font-size:9pt;
			font-weight: normal;
			color: black;
			cursor: pointer;
			-moz-transform: rotate(-90deg);
			-o-transform: rotate(-90deg);
			-webkit-transform: rotate(-90deg);
		}
		.advancedhover:hover {
			max-width: 25px;
			background-color: #DDD;
			color: #000;
			border-right: 1px solid #444;
			cursor: pointer;
			align: center;
			vertical-align: middle;
			/*border-top-left-radius: 5px;
			border-bottom-left-radius: 5px;*/
		}
		.advancedhover {
			max-width: 25px;
			background-color: #EEE;
			color: #AAA;
			border-right: 1px solid #AAA;
			cursor: pointer;
			align: center;
			vertical-align: middle;
			/*border-top-left-radius: 5px;
			border-bottom-left-radius: 5px;*/
		}
	</style>
	<script type="text/javascript">
	<!--
		$(document).ready(function() {
			/* default action */
			$('tr.advanced').hide();
			
			$('#searchtoggle').click(function(){
				$('tr.advanced').toggle();
			});
		});
	-->
	</script>
	<script>
		$(function() {
			$( "#s_studyinstitution" ).autocomplete({
				source: "autocomplete_institution.php",
				minLength: 1,
				autoFocus: true
			});
		});
		
		$(document).ready(function(){
			$('#pageloading').hide();
		});
		
		/* changed the results/view output type when a search element is clicked */
		function SwitchOption(option) {
			switch (option) {
				case 'viewpipeline':
					document.getElementById('viewpipeline').checked = true;
					break;
			}
		}
		
	</script>
	
	<? if ($action == "search") { ?>
	<div id="pageloading" align="center" style="font-size:11pt; color:darkblue">
		Searching... <img src="images/loading.gif">
	</div>
	<br>
	<? } ?>
	<div style="padding-left:30px">
	<form action="search.php" method="post" name="searchform">
	<input type="hidden" name="action" value="search">
	
	<table>
		<tr>
			<td>
	<table cellspacing="0" cellpadding="3" style="border: 1px solid #ccc;">
		<tr>
			<td rowspan="9" id="searchtoggle" class="advancedhover" onMouseOver="this.classname='advancedhover';" onMouseOut="this.classname='advancednohover';">
				<span style="display: block; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); writing-mode: rl-bt;">Toggle&nbsp;advanced&nbsp;search</span>
			</td>
		</tr>
		<tr>
			<td class="toplabel" colspan="2">Search</td>

		</tr>
		<tr>
			<td class="sidelabel">Subject</td>
			<td style="border-bottom: 1pt solid #CCC">
				<table width="100%" cellspacing="0" cellpadding="3">
					<tr title="<b>Subject UID(s)</b><br><br>Can be a list of UIDs, separated by commas, spaces, semi-colons, tabs, or Copy&Paste from Excel">
						<td class="fieldlabel">UID(s)</td>
						<td><input type="text" name="s_subjectuid" value="<?php 
echo $searchvars['s_subjectuid'];
?>
" size="50" class="importantfield"></td>
					</tr>
					<tr title="<b>Alternate Subject UID(s)</b><br><br>Can be a list of UIDs, separated by commas, spaces, semi-colons, tabs, or Copy&Paste from Excel">
						<td class="fieldlabel">Alternate UID(s)</td>
						<td><input type="text" name="s_subjectaltuid" value="<?php 
echo $searchvars['s_subjectaltuid'];
?>
" size="50" class="importantfield"></td>
					</tr>
					<tr>
						<td class="fieldlabel" width="150px">Name</td>
						<td><input type="text" name="s_subjectname" value="<?php 
echo $searchvars['s_subjectname'];
?>
" size="50" class="importantfield"></td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel">DOB</td>
						<td>
							<input type="date" name="s_subjectdobstart" value="<?php 
echo $searchvars['s_subjectdobstart'];
?>
" size="12"> to <input type="date" name="s_subjectdobend" value="<?php 
echo $searchvars['s_subjectdobend'];
?>
" size="12">
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel">Gender</td>
						<td>
							<input type="text" name="s_subjectgender" size="1" maxlength="1" value="<?php 
echo $searchvars['s_subjectgender'];
?>
"> <span class="tiny">&nbsp;F, M, O, U</span>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Group</td>
						<td>
						<select name="s_subjectgroupid">
							<option value="">Select a group</option>
						<?
							$sqlstring = "select * from groups where group_type = 'subject' order by group_name";
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								$groupid = $row['group_id'];
								$groupname = $row['group_name'];
								$groupowner = $row['group_owner'];
								
								echo "[[$groupid -- [" . $searchvars['s_subjectgroupid'] . "]]]";
								if ($groupid == $searchvars['s_subjectgroupid']) {
									$selected = "selected";
								}
								else {
									$selected = "";
								}
								?>
								<option value="<?php 
echo $groupid;
?>
" <?php 
echo $selected;
?>
><?php 
echo $groupname;
?>
</option>
								<?
							}
						?>
						</select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td class="sidelabel">Enrollment</td>
			<td style="border-bottom: 1pt solid #CCC">
				<table width="100%" cellspacing="0" cellpadding="3">
					<tr>
						<td class="fieldlabel" width="150px">Project</td>
						<td>
						<select name="s_projectid" class="importantfield">
							<option value="all">All Projects</option>
							<?
								$sqlstring = "select * from projects where instance_id = '" . $_SESSION['instanceid'] . "' order by project_name";
								$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									$project_id = $row['project_id'];
									$project_name = $row['project_name'];
									$project_costcenter = $row['project_costcenter'];
									if ($project_id == $searchvars['s_projectid']) { $selected = "selected"; } else { $selected = ""; }
									?>
									<option value="<?php 
echo $project_id;
?>
" <?php 
echo $selected;
?>
><?php 
echo $project_name;
?>
 (<?php 
echo $project_costcenter;
?>
)</option>
									<?
								}
							?>
						</select>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Enrollment sub-group</td>
						<td>
						<input type="text" name="s_enrollsubgroup" id="s_enrollsubgroup" list="s_enrollsubgroup" value="<?php 
echo $searchvars['s_enrollsubgroup'];
?>
" size="50"></td>
						<datalist id="s_enrollsubgroup">
						<?
							$sqlstring = "select distinct(enroll_subgroup) from enrollment order by enroll_subgroup";
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								?><option value="<?php 
echo $row['enroll_subgroup'];
?>
"><?
							}
						?>
						</datalist>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<? if ($_SESSION['enablebeta']) { ?>
		<tr class="advanced">
			<td class="sidelabel">Phenotype <?php 
echo PrintBeta();
?>
</td>
			<td style="border-bottom: 1pt solid #CCC">
				<table width="100%" cellspacing="0" cellpadding="3">
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Measure Search<br><span class="tiny">Search based on these critera</span></td>
						<td>
							<table style="font-size: 10pt" cellspacing="0" cellpadding="1">
								<tr>
									<td>
									<?
										$sqlstring = "select measure_name from measurenames order by measure_name";
										$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
										while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
											$tags[] = '"' . $row['measure_name'] . '"';
										}
									?>
									<script>
										$(function() {
											var availableTags = [<?php 
echo implode2(',', $tags);
?>
];
											function split( val ) {
												return val.split( /,\s*/ );
											}
											function extractLast( term ) {
												return split( term ).pop();
											}

											$( "#s_measure1" )
												// don't navigate away from the field on tab when selecting an item
												.bind( "keydown", function( event ) {
													if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "ui-autocomplete" ).menu.active ) {
														event.preventDefault();
													}
											})
											$( "#s_measure2" )
												// don't navigate away from the field on tab when selecting an item
												.bind( "keydown", function( event ) {
													if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "ui-autocomplete" ).menu.active ) {
														event.preventDefault();
													}
											})											.autocomplete({
												minLength: 0,
												source: function( request, response ) {
													// delegate back to autocomplete, but extract the last term
													response( $.ui.autocomplete.filter(
													availableTags, extractLast( request.term ) ) );
												},
												focus: function() {
													// prevent value inserted on focus
													return false;
												},
												select: function( event, ui ) {
													var terms = split( this.value );
													// remove the current input
													terms.pop();
													// add the selected item
													terms.push( ui.item.value );
													// add placeholder to get the comma-and-space at the end
													terms.push( "" );
													this.value = terms.join( ", " );
													return false;
												}
											});
										});
									</script>
										<input type="text" id="s_measure1" name="s_measuresearch" value="<?php 
echo $searchvars['s_measuresearch'];
?>
" size="50" maxlength="255"><br><span class="tiny">Example: meas1=4;meas*&lt;50;meas3~value</span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Measure Columns<br><span class="tiny">Show these columns in results</span></td>
						<td>
							<table style="font-size: 10pt" cellspacing="0" cellpadding="1">
								<tr>
									<td>
										<input type="text" id="s_measure2" name="s_measurelist" value="<?php 
echo $searchvars['s_measurelist'];
?>
" size="50" maxlength="255">
										<br><span class="tiny">Example: meas1,meas2,meas3<br>Or * for all measures</span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<? } ?>
		<tr>
			<td class="sidelabel">Study</td>
			<td style="border-bottom: 1pt solid #CCC">
				<table width="100%" cellspacing="0" cellpadding="3">
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Institution</td>
						<td>
						<input type="text" name="s_studyinstitution" id="s_studyinstitution" list="s_studyinstitution" value="<?php 
echo $searchvars['s_studyinstitution'];
?>
" size="50"></td>
						<datalist id="s_studyinstitution">
						<?
							$sqlstring = "select distinct(study_institution) from studies order by study_institution";
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								?><option value="<?php 
echo $row['study_institution'];
?>
"><?
							}
						?>
						</datalist>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Equipment</td>
						<td>
						<select name="s_studyequipment">
							<option value="">Select equipment</option>
						<?
							$sqlstring = "select distinct(study_site) from studies order by study_site";
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								$study_site = $row['study_site'];
								
								if ($study_site != "") {
									if ($study_site == $searchvars['s_studyequipment']) {
										$selected = "selected";
									}
									else {
										$selected = "";
									}
									?>
									<option value="<?php 
echo $study_site;
?>
" <?php 
echo $selected;
?>
><?php 
echo $study_site;
?>
</option>
									<?
								}
							}
						?>
						</select>
						</td>
					</tr>
					<tr>
						<td class="fieldlabel" width="150px">Alternate Scan ID(s)</td>
						<td><input type="text" name="s_studyaltscanid" value="<?php 
echo $searchvars['s_studyaltscanid'];
?>
" size="50" class="importantfield"></td>
					</tr>
					<tr title="<b>Study date</b><br><br>Leave first date blank to search for anything earlier than the second date. Leave the second date blank to search for anything later than the first date">
						<td class="fieldlabel">Date</td>
						<td><input type="date" name="s_studydatestart" value="<?php 
echo $searchvars['s_studydatestart'];
?>
" size="12" class="importantfield"> to <input type="date" name="s_studydateend" value="<?php 
echo $searchvars['s_studydateend'];
?>
" size="12" class="importantfield"></td>
					</tr>
					<tr>
						<td class="fieldlabel">Modality</td>
						<td>
						<select name="s_studymodality" class="importantfield">
						<?
							$sqlstring = "select * from modalities order by mod_desc";
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								$mod_code = $row['mod_code'];
								$mod_desc = $row['mod_desc'];
								
								/* check if the modality table exists */
								$sqlstring2 = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '" . strtolower($mod_code) . "_series'";
								$result2 = MySQLQuery($sqlstring2,__FILE__,__LINE__);
								if (mysql_num_rows($result2) > 0) {
								
									/* if the table does exist, allow the user to search on it */
									if (($mod_code == "MR") && ($searchvars['s_studymodality'] == "")) {
										$selected = "selected";
									}
									else {
										if ($mod_code == $searchvars['s_studymodality']) {
											$selected = "selected";
										}
										else {
											$selected = "";
										}
									}
									?>
									<option value="<?php 
echo $mod_code;
?>
" <?php 
echo $selected;
?>
><?php 
echo $mod_desc;
?>
</option>
									<?
								}
							}
						?>
						</select>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel">Description</td>
						<td>
							<input type="text" name="s_studydesc" list="s_studydesc" value="<?php 
echo $searchvars['s_studydesc'];
?>
" size="50">
							<datalist id="s_studydesc">
							<?
								$sqlstring = "select distinct(study_desc) from studies where study_desc <> '' order by study_desc";
								$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									?><option value="<?php 
echo trim($row['study_desc']);
?>
"><?
								}
							?>
							</datalist>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel">Performing&nbsp;Physician</td>
						<td>
							<input type="text" name="s_studyphysician" list="s_studyphysician" value="<?php 
echo $searchvars['s_studyphysician'];
?>
" size="50">
							<datalist id="s_studyphysician">
							<?
								$sqlstring = "select distinct(study_performingphysician) from studies where study_performingphysician <> '' order by study_performingphysician";
								$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									?><option value="<?php 
echo trim($row['study_performingphysician']);
?>
"><?
								}
							?>
							</datalist>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel">Operator</td>
						<td>
							<input type="text" name="s_studyoperator" list="s_studyoperator" value="<?php 
echo $searchvars['s_studyoperator'];
?>
" size="50">
							<datalist id="s_studyoperator">
							<?
								$sqlstring = "select distinct(study_operator) from studies where study_operator <> '' order by study_operator";
								$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									?><option value="<?php 
echo trim($row['study_operator']);
?>
"><?
								}
							?>
							</datalist>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel">Visit type</td>
						<td>
							<input type="text" name="s_studytype" list="s_studytype" value="<?php 
echo $searchvars['s_studytype'];
?>
" size="50">
							<datalist id="s_studytype">
							<?
								$sqlstring = "select distinct(study_type) from studies where study_type <> '' order by study_type";
								$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									?><option value="<?php 
echo trim($row['study_type']);
?>
"><?
								}
							?>
							</datalist>
						</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Group</td>
						<td>
						<select name="s_studygroupid">
							<option value="">Select a group</option>
						<?
							$sqlstring = "select * from groups where group_type = 'study' order by group_name";
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								$groupid = $row['group_id'];
								$groupname = $row['group_name'];
								$groupowner = $row['group_owner'];
								
								if ($groupid == $searchvars['s_studygroupid']) {
									$selected = "selected";
								}
								else {
									$selected = "";
								}
								?>
								<option value="<?php 
echo $groupid;
?>
" <?php 
echo $selected;
?>
><?php 
echo $groupname;
?>
</option>
								<?
							}
						?>
						</select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td class="sidelabel">Series</td>
			<td style="border-bottom: 1pt solid #CCC">
				<table width="100%" cellspacing="0" cellpadding="3">
					<tr title="<b>Comma separated</b> protocols: search will be an AND<br><b>Semi-colon separated</b> protocols: search will be an OR">
						<td class="fieldlabel" width="150px">Protocol</td>
						<td><input type="text" name="s_seriesdesc" value="<?php 
echo $searchvars['s_seriesdesc'];
?>
" size="50" class="importantfield"></td>
					</tr>
					<tr title="Perform the search using the alternate protocol name, and return the results using the alternate protocol name. The alternate protocol name often groups together series with similar names into one protocol. For example 'MPRAGE', 'Axial T1', and 'T1w_SPC' would all be labeled 'T1'">
						<td class="fieldlabel" width="150px"></td>
						<td><input type="checkbox" name="s_usealtseriesdesc" value="1" class="importantfield" <? if ($searchvars['s_usealtseriesdesc']) { echo "checked"; } ?>>Use alternate protocol name</td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Sequence</td>
						<td><input type="text" name="s_seriessequence" value="<?php 
echo $searchvars['s_seriessequence'];
?>
" size="50"></td>
					</tr>
					<tr class="advanced" title="Comma separated. Use * to indicate wildcards">
						<td class="fieldlabel" width="150px">Image Type</td>
						<td><input type="text" name="s_seriesimagetype" value="<?php 
echo $searchvars['s_seriesimagetype'];
?>
" size="50"></td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Image Comments</td>
						<td><input type="text" name="s_seriesimagecomments" value="<?php 
echo $searchvars['s_seriesimagecomments'];
?>
" size="50"></td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">TR</td>
						<td><input type="text" name="s_seriestr" value="<?php 
echo $searchvars['s_seriestr'];
?>
" title="Repetition time in milliseconds" size="10"> <span class="tiny">ms</span></td>
					</tr>
					<tr class="advanced" title="<b>Must be an integer or a criteria:</b><ul><li>> <i>N</i> (greater than)<li>>= <i>N</i> (greater than or equal to)<li>< <i>N</i> (less than)<li><= <i>N</i> (less than or equal to)<li>~ <i>N</i> (not)</ul>">
						<td class="fieldlabel" width="150px">Series number</td>
						<td><input type="text" name="s_seriesnum" value="<?php 
echo $searchvars['s_seriesnum'];
?>
" size="10"></td>
					</tr>
					<tr class="advanced" title="<b>Must be an integer or a criteria:</b><ul><li>> <i>N</i> (greater than)<li>>= <i>N</i> (greater than or equal to)<li>< <i>N</i> (less than)<li><= <i>N</i> (less than or equal to)<li>~ <i>N</i> (not)</ul>">
						<td class="fieldlabel" width="150px">Number of files</td>
						<td><input type="text" name="s_seriesnumfiles" value="<?php 
echo $searchvars['s_seriesnumfiles'];
?>
" size="10"></td>
					</tr>
					<tr class="advanced">
						<td class="fieldlabel" width="150px">Group</td>
						<td>
						<select name="s_seriesgroupid">
							<option value="">Select a group</option>
						<?
							$sqlstring = "select * from groups where group_type = 'series' order by group_name";
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								$groupid = $row['group_id'];
								$groupname = $row['group_name'];
								$groupowner = $row['group_owner'];
								
								if ($groupid == $searchvars['s_seriesgroupid']) {
									$selected = "selected";
								}
								else {
									$selected = "";
								}
								?>
								<option value="<?php 
echo $groupid;
?>
" <?php 
echo $selected;
?>
><?php 
echo $groupname;
?>
</option>
								<?
							}
						?>
						</select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr class="advanced">
			<td class="sidelabel">Analysis</td>
			<td style="border-bottom: 1pt solid #CCC">
				<table width="100%" cellspacing="0" cellpadding="3">
					<tr>
						<td class="fieldlabel" width="150px">Pipeline</td>
						<td>
						<select name="s_pipelineid" onClick="SwitchOption('viewpipeline')">
							<option value="">Select pipeline</option>
						<?
							$sqlstring2 = "select pipeline_id, pipeline_name from pipelines order by pipeline_name";
							$result2 = MySQLQuery($sqlstring2,__FILE__,__LINE__);
							while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
								$pipelineid = $row2['pipeline_id'];
								$pipelinename = $row2['pipeline_name'];
								?>
								<option value="<?php 
echo $pipelineid;
?>
" <? if ($searchvars['s_pipelineid'] == $pipelineid) { echo "selected"; } ?>><?php 
echo $pipelinename;
?>
</option>
								<?
							}
						?>
						</select>
						</td>
					</tr>
					<tr>
						<td class="fieldlabel" width="150px">Result name</td>
						<td><input type="text" name="s_pipelineresultname" onClick="SwitchOption('viewpipeline')" value="<?php 
echo $searchvars['s_pipelineresultname'];
?>
" size="50" class="importantfield"></td>
					</tr>
					<tr>
						<td class="fieldlabel" width="150px">Result unit</td>
						<td><input type="text" name="s_pipelineresultunit" onClick="SwitchOption('viewpipeline')" value="<?php 
echo $searchvars['s_pipelineresultunit'];
?>
" size="20" maxsize="20" class="importantfield"></td>
					</tr>
					<tr>
						<td class="fieldlabel" width="150px">Result type</td>
						<td>
							<input type="radio" name="s_pipelineresulttype" value="" onClick="SwitchOption('viewpipeline')" <? if ($searchvars['s_pipelineresulttype'] == '') { echo "checked"; } ?>>None<br>
							<input type="radio" name="s_pipelineresulttype" value="v" onClick="SwitchOption('viewpipeline')" <? if ($searchvars['s_pipelineresulttype'] == 'v') { echo "checked"; } ?>>Value<br>
							<input type="radio" name="s_pipelineresulttype" value="i" onClick="SwitchOption('viewpipeline')" <? if ($searchvars['s_pipelineresulttype'] == 'i') { echo "checked"; } ?>>Image<br>
							<input type="radio" name="s_pipelineresulttype" value="f" onClick="SwitchOption('viewpipeline')" <? if ($searchvars['s_pipelineresulttype'] == 'f') { echo "checked"; } ?>>File<br>
							<input type="radio" name="s_pipelineresulttype" value="h" onClick="SwitchOption('viewpipeline')" <? if ($searchvars['s_pipelineresulttype'] == 'h') { echo "checked"; } ?>>HTML<br>
						</td>
					</tr>
					<tr>
						<td class="fieldlabel" width="150px">Result value</td>
						<td valign="top">
							<select name="s_pipelineresultcompare" onClick="SwitchOption('viewpipeline')">
								<option value="=" <? if ($searchvars['s_pipelineresultcompare'] == '=') { echo "selected"; } ?>>=
								<option value=">" <? if ($searchvars['s_pipelineresultcompare'] == '>') { echo "selected"; } ?>>&gt;
								<option value=">=" <? if ($searchvars['s_pipelineresultcompare'] == '>=') { echo "selected"; } ?>>&gt;=
								<option value="<" <? if ($searchvars['s_pipelineresultcompare'] == '<') { echo "selected"; } ?>>&lt;
								<option value="<=" <? if ($searchvars['s_pipelineresultcompare'] == '<=') { echo "selected"; } ?>>&lt;=
							</select>
							<input type="text" name="s_pipelineresultvalue" onClick="SwitchOption('viewpipeline')" value="<?php 
echo $searchvars['s_pipelineresultvalue'];
?>
" size="15" class="smallsearchbox"><br>
							<input type="checkbox" name="s_pipelinecolorize" onClick="SwitchOption('viewpipeline')" value="1" <? if ($searchvars['s_pipelinecolorize'] == 1) { echo "checked"; } ?>>Colorize <span class="tiny">low <img src="images/colorbar.png"> high</span>
							<br>
							<input type="checkbox" name="s_pipelinecormatrix" onClick="SwitchOption('viewpipeline')" value="1" <? if ($searchvars['s_pipelinecormatrix'] == 1) { echo "checked"; } ?>>Display correlation matrix <span class="tiny">Slow for large result sets</span>
							<br>
							<input type="checkbox" name="s_pipelineresultstats" onClick="SwitchOption('viewpipeline')" value="1" <? if ($searchvars['s_pipelineresultstats'] == 1) { echo "checked"; } ?>>Display result statistics
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td class="sidelabel" style="color: gray">Results</td>
			<td style="border-bottom: 1pt solid #CCC">
				<table width="100%" cellspacing="0" cellpadding="3">
					<tr>
						<td class="fieldlabel" width="150px"><!--Results format--></td>
						<td>
							<span style="font-size:10pt; color: darkblue">Download/Export</span><br>
							
							<? if (($searchvars['s_resultorder'] == "subject") || ($action == "")) { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="downloadsubject" value="subject" <?php 
echo $checked;
?>
> Enrollment List<br>
							
							<? if (($searchvars['s_resultorder'] == "uniquesubject") || ($action == "")) { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="downloaduniquesubject" value="uniquesubject" <?php 
echo $checked;
?>
> Subject List<br>
							
							<? if (($searchvars['s_resultorder'] == "study") || ($action == "")) { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="downloadstudy" value="study" <?php 
echo $checked;
?>
> Group by <b>study</b><br>
							
							<? if ($searchvars['s_resultorder'] == "series") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="downloadseries" value="series" <?php 
echo $checked;
?>
> Series List
							
							<br><br>

							<span style="font-size:10pt; color: darkblue">View</span><br>
							<? if ($searchvars['s_resultorder'] == "table") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="viewtable" value="table" <?php 
echo $checked;
?>
> Table<br>
							
							<? if ($searchvars['s_resultorder'] == "csv") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="viewcsv" value="csv" <?php 
echo $checked;
?>
> Spreadsheet <span class="tiny">.csv</span><br>
							
							<? if ($searchvars['s_resultorder'] == "pipeline") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="viewpipeline" value="pipeline" <?php 
echo $checked;
?>
> Pipeline results<br>
							
							<? if ($searchvars['s_resultorder'] == "pipelinecsv") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="viewpipelinecsv" value="pipelinecsv" <?php 
echo $checked;
?>
> Pipeline results <span class="tiny">.csv</span><br>
							
							<? if ($searchvars['s_resultorder'] == "long") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="viewlong" value="long" <?php 
echo $checked;
?>
> Longitudinal<br>

							<? if ($searchvars['s_resultorder'] == "debug") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="viewdebug" value="debug" <?php 
echo $checked;
?>
> Debug <span class="tiny">SQL</span><br>
							
							<? if ($GLOBALS['isadmin']) { ?>
							<? if ($searchvars['s_resultorder'] == "operations") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="radio" name="s_resultorder" id="viewoperations" value="operations" <?php 
echo $checked;
?>
> File operations
							<? } ?>
							
							<br>
							<br>
							
							<? if ($searchvars['s_audit'] == "1") { $checked = "checked"; } else { $checked = ""; }?>
							<input type="checkbox" name="s_audit" value="1" <?php 
echo $checked;
?>
> Audit <span class="tiny">files</span>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center" style="padding-top: 15px;">
				<input type="submit" value="Search">
			</td>
		</tr>
	</table>
			</td>
			<td rowspan="5" width="300px" valign="top" style="padding-left: 150px; color: darkblue; font-size:10pt">
				<details>
				<summary><b>Search Tips:</b></summary>
				<ul>
					<li>Enter as much or as little information as you want
					<li>Put commas between items to search for lists of names, scanids, study descriptions, physicians, operators or protocols
					<li>Use the <a href="http://www.google.com/chrome" class="link">Google Chrome</a> browser if possible
				</ul>
				</details>
			</td>
		</tr>
	</table>
	
	</form>
	</div>
	<?
	}
Beispiel #3
0
	function DisplayImportMenu() {
	
		$urllist['Home'] = "index.php";
		$urllist['Import'] = "import.php";
		$urllist['Import'] = "import.php?action=import";
		NavigationBar("Import", $urllist);
		?>
		<style>
			.gradientsummary {
background: -moz-linear-gradient(left, rgba(151,187,229,1) 0%, rgba(151,187,229,0.99) 1%, rgba(125,185,232,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(151,187,229,1)), color-stop(1%,rgba(151,187,229,0.99)), color-stop(100%,rgba(125,185,232,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(151,187,229,1) 0%,rgba(151,187,229,0.99) 1%,rgba(125,185,232,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(151,187,229,1) 0%,rgba(151,187,229,0.99) 1%,rgba(125,185,232,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(151,187,229,1) 0%,rgba(151,187,229,0.99) 1%,rgba(125,185,232,0) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(151,187,229,1) 0%,rgba(151,187,229,0.99) 1%,rgba(125,185,232,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#97bbe5', endColorstr='#007db9e8',GradientType=1 ); /* IE6-9 */				color: black;
				/*font-weight:bold*/
			}
		</style>
		
		<script>
			function AlphaNumeric(e) {
				var key;
				var keychar;

				if (window.event)
					key = window.event.keyCode;
				else if (e)
					key = e.which;
				else
					return true;
					
				keychar = String.fromCharCode(key);
				keychar = keychar.toLowerCase();

				// control keys
				if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
					return true;
				// alphas and numbers
				else if ((("abcdefghijklmnopqrstuvwxyz0123456789_").indexOf(keychar) > -1))
					return true;
				else
					return false;
			}
		</script>
		
		<div style="font-weight:bold; color: darkblue; font-size:14pt">Upload data to NiDB</div>
		<br>
		<span style="color:#444">Instance <b><?php 
echo $GLOBALS['instancename'];
?>
</b></span>
		<br>
		<br>
		<div style="padding:8px; border: 1px solid #ccc; border-radius:5px">
		<b>Web upload ( < 1GB file size )</b>
		<table width="100%">
			<tr>
				<td>
					<table class="entrytable">
						<form action="import.php" method="post" enctype="multipart/form-data">
						<input type="hidden" name="action" value="uploaddicom">
						<tr>
							<td class="label">Site</td>
							<td>
								<select name="siteid" required>
									<option value="">Select site...</option>
									<?
										$s = GetSiteList();
										foreach ($s as $site) { ?><option value="<?php 
echo $site['id'];
?>
"><?php 
echo $site['name'];
?>
</option><? }
									?>
								</select>
							</td>
						</tr>
						<tr>
							<td class="label">Project</td>
							<td>
								<select name="projectid" required>
									<option value="">Select project...</option>
									<?
										$projects = GetProjectList();
										foreach ($projects as $p) { ?><option value="<?php 
echo $p['projectid'];
?>
"><?php 
echo $p['name'];
?>
 (<?php 
echo $p['costcenter'];
?>
)</option><? }
									?>
								</select>
							</td>
						</tr>
						<? if (!$GLOBALS['cfg']['ispublic']) { ?>
						<tr>
							<td class="label">Anonymize?</td>
							<td><input type="checkbox" name="anonymize" value="1" checked></td>
						</tr>
						<? } ?>
						<tr>
							<td class="label">Select files<br><span class="tiny">DICOM files only. Or any zip<br>file containing DICOM files</span></td>
							<td><input type="file" name="files[]" multiple style="border:none"></td>
						</tr>
						<tr>
							<td colspan="2"><input type="submit" value="Import DICOM"></td>
						</tr>
						</form>
					</table>
				</td>
			</tr>
		</table>
		</div>
		<br>
		<script>
			$(document).ready(function() {

				var MaxInputs       = 8; //maximum input boxes allowed
				var InputsWrapper   = $("#InputsWrapper"); //Input boxes wrapper ID
				var AddButton       = $("#AddMoreFileBox"); //Add button ID

				var x = InputsWrapper.length; //initlal text box count
				var FieldCount=1; //to keep track of text box added

				$(AddButton).click(function (e)  //on add input button click
				{
					if(x <= MaxInputs) //max input box allowed
					{
						FieldCount++; //text box added increment
						//add input box
						$(InputsWrapper).append('<span> / <select name="importdirs[]" id="field_'+ FieldCount +'"><option value="modality">Modality</option><option value="subjectid">Subject ID</option><option value="seriesdesc">Series description</option><option value="seriesnum">Series number</option><option value="studydesc">Study Description</option><option value="studydatetime">Study datetime</option><option value="thefiles">{The files}</option><option value="beh">beh</option></select><a href="#" class="removeclass">&times;</a></span>');
						x++; //text box increment
					}
					return false;
				});

				$("body").on("click",".removeclass", function(e){ //user click on remove text
					if( x > 1 ) {
						$(this).parent('span').remove(); //remove text box
						x--; //decrement textbox
					}
					return false;
				}); 

 				$('#nondicomform').on('submit', function(e) {
					//prevent the default submithandling
					e.preventDefault();
					//send the data of 'this' (the matched form) to yourURL
					var posting = $.post('import.php', $(this).serialize(), function(data) {
						$( "#result" ).empty().append( data );
					});
				});
			});	
		</script>
		<style>
			.removeclass { color: darkred; text-decoration:none; }
			.removeclass:hover { text-decoration:underline; }
			.direxample { font-family: monospace; white-space: pre; font-size:10pt }
			.btn { background-color: #ccc; border: 1px solid gray; color: black; text-decoration: none; padding: 1px 4px; }
			.freelabel {font-weight: bold; text-align: right; padding-right: 10px; vertical-align: top; color: #666666; font-size:12pt; white-space:nowrap; }
		</style>
		
		<details>
			<summary>Import non-DICOM Image Data</summary>
			<form action="import.php" id="nondicomform" method="post">
			<input type="hidden" name="apiaction" value="uploadnondicom">
			<div style="margin-left: 20px; padding:8px;">
			<table width="100%">
				<tr>
					<td>
						<table class="entrytable">
							<tr>
								<td class="label">Site</td>
								<td>
									<select name="siteid" required>
										<option value="">Select site...</option>
										<?
											$s = GetSiteList();
											foreach ($s as $site) { ?><option value="<?php 
echo $site['id'];
?>
"><?php 
echo $site['name'];
?>
</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td class="label">Project</td>
								<td>
									<select name="projectid" required>
										<option value="">Select project...</option>
										<?
											$projects = GetProjectList();
											foreach ($projects as $p) { ?><option value="<?php 
echo $p['projectid'];
?>
"><?php 
echo $p['name'];
?>
 (<?php 
echo $p['costcenter'];
?>
)</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td colspan="2">
									<span class="freelabel">Directory structure</span>
									<br>
									<details>
										<summary style="font-size:10pt">Example directory structures</summary>
										<table>
											<tr>
												<td style="padding:2px 20px;">
													<span class="direxample">/MR/23490802/t1/{files}</span>
												</td>
												<td>&rarr;</td>
												<td style="padding:2px 20px;">
													<span class="direxample">/Modality/SubjectID/SeriesDesc/{The files}</span>
												</td>
											</tr>
											<tr>
												<td style="padding:2px 20px;">
													<span class="direxample">/34890JKP/20140324_120934/5/{files}/beh</span>
												</td>
												<td>&rarr;</td>
												<td style="padding:2px 20px;">
													<span class="direxample">/SubjectID/StudyDatetime/SeriesNum/{The files}/beh</span>
												</td>
											</tr>
										</table>
									</details>
									<br>
									<a href="#" id="AddMoreFileBox" class="btn">Add Directory &rarr;</a>
									<div id="InputsWrapper">
									<span><select name="importdirs[]" id="field_0"><option value="modality">Modality</option><option value="subjectid">Subject ID</option><option value="seriesdesc">Series description</option><option value="seriesnum">Series number</option><option value="studydesc">Study Description</option><option value="studydatetime">Study datetime</option><option value="thefiles"><span style="color: blue">{The files}</span></option><option value="beh">beh</option></select><a href="#" class="removeclass">&times;</a></span>
									</div>
									<br>
								</td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" value="Import non-DICOM"> <div id="result" style="color: darkred"></div></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			</div>
			</form>
		</details>
		
		<br>
		
		<? if ($_SESSION['enablebeta']) { ?>
		<details>
			<summary>Import Subject Demographics <?php 
echo PrintBeta();
?>
</summary>
			<div style="margin-left: 40px; padding:8px; background-color: #e5eeff">
			<table width="100%">
				<tr>
					<td valign="top">
						<table class="entrytable" style="border:1px solid #ccc">
							<form action="import.php" method="post" enctype="multipart/form-data">
							<input type="hidden" name="action" value="importdemographics">
							<tr>
								<td class="label">Site</td>
								<td>
									<select name="siteid" required>
										<option value="">Select site...</option>
										<?
											$s = GetSiteList();
											foreach ($s as $site) { ?><option value="<?php 
echo $site['id'];
?>
"><?php 
echo $site['name'];
?>
</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td class="label">Project</td>
								<td>
									<select name="projectid" required>
										<option value="">Select project...</option>
										<?
											$projects = GetProjectList();
											foreach ($projects as $p) { ?><option value="<?php 
echo $p['projectid'];
?>
"><?php 
echo $p['name'];
?>
 (<?php 
echo $p['costcenter'];
?>
)</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td class="label">Select files<br><span class="tiny">.csv file in<br>NiDB demographics format</span></td>
								<td><input type="file" name="files[]" multiple style="border:none"></td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" value="Import Demographics"></td>
							</tr>
							</form>
						</table>
					</td>
					<td valign="top">
						.csv format
						<div style="border: 1px dashed #ccc;font-family: monospace; white-space: pre; font-size:8pt">
UID, sex, ethnicity, race, weight, height, handedness, education, maritalstatus, smokingstatus
						</div>
						<br>
						<b>Column values</b>
						<ul style="font-size:10pt">
							<li>Sex
								<ul>
									<li>M - Male
									<li>F - Female
									<li>O - Other
									<li>U - Unknown
								</ul>
							<li><b>Ethnicity:</b> hispanic, nothispanic
							<li><b>Race:</b> unknown, asian, black, indian, islander, mixed, white, other
							<li><b>Weight</b> (in kg)
							<li><b>Height</b> (in meters)
							<li>Handedness
								<ul>
									<li>L - Left
									<li>R - Right
									<li>A - Ambidextrous
									<li>U - Unknown
								</ul>
							<li>Education
								<ul>
									<li>0 - Unknown
									<li>1 - Grade school
									<li>2 - Middle school
									<li>3 - High school/GED
									<li>4 - Trade school
									<li>5 - Associates degree
									<li>6 - Bachelors degree
									<li>7 - Masters degree
									<li>8 - Doctoral degree
								</ul>
							<li><b>Marital status:</b> unknown, married, single, divorced, separated, civilunion, cohabitating, widowed
							<li><b>Smoking status:</b> unknown, never, current, past
						</ul>
					</td>
				</tr>
			</table>
			</div>
		</details>
		<br>
		<? } ?>

		<details>
			<summary>Import Assessment Forms</summary>
			<div style="margin-left: 20px; padding:8px;">
			<table width="100%">
				<tr>
					<td valign="top">
						<table class="entrytable">
							<form action="import.php" method="post" enctype="multipart/form-data">
							<input type="hidden" name="action" value="importassessmentform">
							<!--<tr>
								<td class="label">Form Name</td>
								<td><input type="text" name="newformname" maxlength="50" onKeyPress="return AlphaNumeric(event)"></td>
							</tr>-->
							<tr>
								<td class="label">Select files<br><span class="tiny">.csv file in NiDB<br>assessment format</span></td>
								<td><input type="file" name="files[]" multiple style="border:none"></td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" value="Import Assessment Forms"></td>
							</tr>
							</form>
						</table>
					</td>
					<td valign="top">
						.csv format
						<div style="border: 1px dashed #ccc;font-family: monospace; white-space: pre; font-size:8pt; padding: 5px">Title,,,,
description,,,,
question_num, question_text, datatype, values, comment</div>
						First line contains title, second line contains description. The remaining lines contain the questions
						<br><br>
						<b>Datatype</b>
						<ul>
							<li title="<big><b>multichoice Example</b></big><br><br><i>DSM Classification</i><br><br>100.1 - Silly<br>100.2 - Absurd<br>100.3 - Funny<br>100.4 - Humerous">multichoice <span class="tiny">List of pre-selected answers, multiple can be selected</span>
							<li title="<big><b>singlechoice Example</b></big><br><br><i>Handedness</i><br><br>L<br>R<br>B">singlechoice <span class="tiny">List of pre-selected answers, only one can be selected</span>
							<li>string <span class="tiny">Single line of text</span>
							<li>text <span class="tiny">Multiple lines of text</span>
							<li title="<big><b>singlechoice Example</b></big><br><br>3.141592 <i>or</i> 5">number <span class="tiny">Value that must be numeric</span>
							<li title="<big><b>singlechoice Example</b></big><br><br>2014/03/01">date <span class="tiny">A date</span>
							<li title="<big><b>singlechoice Example</b></big><br><br>The following section will assess your well-being">header <span class="tiny">Information, or section separator</span>
						</ul>
				</tr>
			</table>
			</div>
		</details>
		
		<br>

		<? if ($_SESSION['enablebeta']) { ?>
		<details>
			<summary>Import Assessment Data <?php 
echo PrintBeta();
?>
</summary>
			<div style="margin-left: 20px; padding:8px;">
			<table width="100%">
				<tr>
					<td>
						<table class="entrytable">
							<form action="import.php" method="post" enctype="multipart/form-data">
							<input type="hidden" name="action" value="importassessmentdata">
							<tr>
								<td class="label" colspan="2"><a href="import.php?action=viewassessmentforms">View Available Assessment Forms</a></td>
							</tr>
							<tr>
								<td class="label">Site</td>
								<td>
									<select name="siteid" required>
										<option value="">Select site...</option>
										<?
											$s = GetSiteList();
											foreach ($s as $site) { ?><option value="<?php 
echo $site['id'];
?>
"><?php 
echo $site['name'];
?>
</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td class="label">Project</td>
								<td>
									<select name="projectid" required>
										<option value="">Select project...</option>
										<?
											$projects = GetProjectList();
											foreach ($projects as $p) { ?><option value="<?php 
echo $p['projectid'];
?>
"><?php 
echo $p['name'];
?>
 (<?php 
echo $p['costcenter'];
?>
)</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td class="label">Select files<br><span class="tiny">.csv file in NiDB<br>assessment data format</span></td>
								<td><input type="file" name="files[]" multiple style="border:none"></td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" value="Import Assessment Scores"></td>
							</tr>
							</form>
						</table>
					</td>
				</tr>
			</table>
			</div>
		</details>
		<br>
		<? } ?>
		
		<? if ($_SESSION['enablebeta']) { ?>
		<details>
			<summary>Import Measures (name/value pairs only) <?php 
echo PrintBeta();
?>
</summary>
			<div style="margin-left: 20px; padding:8px;">
			<table width="100%">
				<tr>
					<td>
						<table class="entrytable">
							<form action="import.php" method="post" enctype="multipart/form-data">
							<input type="hidden" name="action" value="importmeasures">
							<tr>
								<td class="label">Site</td>
								<td>
									<select name="siteid" required>
										<option value="">Select site...</option>
										<?
											$s = GetSiteList();
											foreach ($s as $site) { ?><option value="<?php 
echo $site['id'];
?>
"><?php 
echo $site['name'];
?>
</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td class="label">Project</td>
								<td>
									<select name="projectid" required>
										<option value="">Select project...</option>
										<?
											$projects = GetProjectList();
											foreach ($projects as $p) { ?><option value="<?php 
echo $p['projectid'];
?>
"><?php 
echo $p['name'];
?>
 (<?php 
echo $p['costcenter'];
?>
)</option><? }
										?>
									</select>
								</td>
							</tr>
							<tr>
								<td class="label">Select .csv files</td>
								<td><input type="file" name="files[]" multiple required style="border:none"></td>
							</tr>
							<tr>
								<td class="label">File format</td>
								<td>
									<table cellspacing="0" cellpadding="0">
										<tr>
											<td valign="top">
												<input type="radio" name="fileformat" value="short" required>Short rows <img src="images/help.gif" title="One row for each measure/value pair, no header">
											</td>
											<td valign="top">
												<details><summary class="tiny">File format example</summary><pre style="font-size:10pt; border: 1px solid #aaa; border-radius:3px; padding: 5px">S1234ABC, instrument1, measure1, value<br>S1234ABC, instrument1, measure2, value<br>S1234ABC, instrument2, measure1, value<br>S1234ABC, instrument2, measure3, value</pre></details>
											</td>
										</tr>
										<tr>
											<td valign="top">
												<input type="radio" name="fileformat" value="long" required>Long rows <img src="images/help.gif" title="One row for each subject, with header">
											</td>
											<td valign="top">
												<details><summary class="tiny">File format example</summary><pre style="font-size:10pt; border: 1px solid #aaa; border-radius:3px; padding: 5px">-,        instrument1, instrument1, instrument2, instrument2, etc<br>UID,      measure1,    measure2,    measure1,    measure3,    etc<br>S1234ABC, value1,      value2,      value3,      value4,      etc<br>S5678LMN, value1,      value2,      value3,      value4,      etc<br>S9292XYZ, value1,      value2,      value3,      value4,      etc</pre></details>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" value="Import Measures"></td>
							</tr>
							</form>
						</table>
					</td>
				</tr>
			</table>
			</div>
		</details>
		<? } ?>
		
		<?
	}