Пример #1
0
function DisplaySingleTransaction($transactionid)
{
    $sqlstring = "select * from import_requests where import_transactionid = {$transactionid}";
    $result = MySQLQuery($sqlstring, __FILE__, __LINE__);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $groupids[] = $row['importrequest_id'];
    }
    $grouplist = implode2(',', $groupids);
    $sqlstring = "select *, timediff(max(importstartdate), min(importstartdate)) 'importtime', date_format(max(importstartdate), '%b %e, %Y %T') 'maximportdatetime', date_format(studydatetime_orig, '%b %e, %Y %T') 'studydatetime', date_format(seriesdatetime_orig, '%b %e, %Y %T') 'seriesdatetime', count(*) 'numfiles' from importlogs where importgroupid in ({$grouplist}) group by stationname_orig, studydatetime_orig, seriesnumber_orig order by studydatetime_orig desc, seriesdatetime_orig";
    //$sqlstring = "select * from importlogs where importgroupid in ($grouplist)";
    ?>
		
<style>
.text {
   position:relative;
   width:20px;
   height:170px;
   /*border:1px solid rgba(0,0,0,0.5);*/
   /*border-radius:7px; */
   /*margin:20px auto; */
   /*background-color:rgb(255,255,255); */
   /*box-shadow:inset 0 0 10px rgba(0,0,0,0.6),
                    0 0 10px rgba(0,0,0,0.6);*/
  }
.text span {
   position:absolute;
   width:170px;
   line-height:20px;
   left:0;
   top:100%;
   transform:rotate(-90deg); 
   -webkit-transform:rotate(-90deg); 
   transform-origin:0 0;
   -webkit-transform-origin:0 0;
   text-align:left;
   vertical-align: middle;
  }
</style>		
		<table class="smallgraydisplaytable">
			<thead>
				<tr>
					<th valign="bottom">Initials</th>
					<th>Patient ID</th>
					<!--<th>Institution</th>-->
					<th>Equipment</th>
					<th>Modality</th>
					<th>Study date</th>
					<th>Series date</th>
					<th>Series Num</th>
					<th>Num files</th>
					<th> </th>
					<th>New UID</th>
					<th>Study Num</th>
					<th>Project</th>
					<th>Import time<br><span class="tiny">HH:MM:SS</span></th>
					<th>Import complete</th>
					<th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created subject</span></div></th>
					<th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created family</span></div></th>
					<th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created enrollment</span></div></th>
					<th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created study</span></div></th>
					<th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created series</span></div></th>
					<th><div class="text"><span style="font-size:10pt; font-weight:normal;">Overwrote existing data</span></div></th>
				</tr>
			</thead>
			<tbody>
		<?php 
    $result = MySQLQuery($sqlstring, __FILE__, __LINE__);
    //PrintSQLTable($result,"importlog.php?action=displaylog",$orderby,8);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $patientid = $row['patientid_orig'];
        $patientname = $row['patientname_orig'];
        $institution = $row['institution_orig'];
        $equipment = $row['stationname_orig'];
        $modality = $row['modality_orig'];
        //$studydatetime = date('M j g:ia',strtotime($row['studydatetime_orig']));
        $studydatetime = $row['studydatetime'];
        //$seriesdatetime = date('M j g:ia',strtotime($row['seriesdatetime_orig']));
        $seriesdatetime = $row['seriesdatetime'];
        $seriesnum = $row['seriesnumber_orig'];
        $numfiles = $row['numfiles'];
        $importtime = $row['importtime'];
        $minimportdatetime = $row['minimportdatetime'];
        $maximportdatetime = $row['maximportdatetime'];
        $subjectid = $row['subjectid'];
        $newuid = $row['subject_uid'];
        $newstudynum = $row['study_num'];
        $project = $row['project_number'];
        $subjectcreated = $row['subject_created'];
        $familycreated = $row['family_created'];
        $enrollmentcreated = $row['enrollment_created'];
        $studycreated = $row['study_created'];
        $seriescreated = $row['series_created'];
        $overwroteexisting = $row['overwrote_existing'];
        /* fix patient name, to only show initials */
        $parts = preg_split("/(\\s\\s+|\\^)/", $patientname);
        //print_r($parts);
        $displayname = '';
        foreach ($parts as $part) {
            $displayname = substr($part, 0, 1) . $displayname;
        }
        if ($subjectcreated) {
            $subjectcreated = "&#x2713;";
        } else {
            $subjectcreated = "";
        }
        if ($familycreated) {
            $familycreated = "&#x2713;";
        } else {
            $familycreated = "";
        }
        if ($enrollmentcreated) {
            $enrollmentcreated = "&#x2713;";
        } else {
            $enrollmentcreated = "";
        }
        if ($studycreated) {
            $studycreated = "&#x2713;";
        } else {
            $studycreated = "";
        }
        if ($seriescreated) {
            $seriescreated = "&#x2713;";
        } else {
            $seriescreated = "";
        }
        if ($overwroteexisting) {
            $overwroteexisting = "&#x2713;";
        } else {
            $overwroteexisting = "";
        }
        ?>
			<tr>
				<td><?php 
        echo $displayname;
        ?>
</td>
				<td title="PatientID (from file)"><?php 
        echo $patientid;
        ?>
</td>
				<!--<td style="font-size:8pt"><?php 
        echo $institution;
        ?>
</td>-->
				<td style="font-size:8pt"><?php 
        echo $equipment;
        ?>
</td>
				<td><?php 
        echo $modality;
        ?>
</td>
				<td title="Study date/time" style="font-size:8pt; white-space: nowrap;"><?php 
        echo $studydatetime;
        ?>
</td>
				<td title="Series date/time" style="font-size:8pt; white-space: nowrap;"><?php 
        echo $seriesdatetime;
        ?>
</td>
				<td title="Series number"><?php 
        echo $seriesnum;
        ?>
</td>
				<td title="Number of files"><?php 
        echo $numfiles;
        ?>
</td>
				<td style="font-size:16pt; padding-left:20px; padding-right:20px; color:darkred; -webkit-transform:scale(1.5,1);">&#10137;</td>
				<td><a href="subjects.php?id=<?php 
        echo $subjectid;
        ?>
"><?php 
        echo $newuid;
        ?>
</a></td>
				<td title="Study number"><?php 
        echo $newstudynum;
        ?>
</td>
				<td title="Project number"><?php 
        echo $project;
        ?>
</td>
				<td title="Import time" style="font-size:8pt;"><?php 
        echo $importtime;
        ?>
</td>
				<td title="Import completed date/time" style="font-size:8pt;"><?php 
        echo $maximportdatetime;
        ?>
</td>
				<td title="Subject created"><?php 
        echo $subjectcreated;
        ?>
</td>
				<td title="Family created"><?php 
        echo $familycreated;
        ?>
</td>
				<td title="Enrollment created"><?php 
        echo $enrollmentcreated;
        ?>
</td>
				<td title="Study created"><?php 
        echo $studycreated;
        ?>
</td>
				<td title="Series created"><?php 
        echo $seriescreated;
        ?>
</td>
				<td title="Overwrote existing"><?php 
        echo $overwroteexisting;
        ?>
</td>
			</tr>
			<?php 
    }
    ?>
			</tbody>
		</table>
		<?php 
}
Пример #2
0
	function DisplayChart($data, $label, $height, $id) {
		$colors = GenerateColorGradient();
		?>
			<table class="grayrounded" width="100%">
				<tr>
					<td class="title"><?php 
echo $label;
?>
</td>
				</tr>
				<tr>
					<td class="body">
						<script>
							$(function() {
									var data = [
										{
										label: "<?php 
echo $label;
?>
",
										hoverable: true,
										clickable: true,
										data: [<?
										foreach ($data as $date => $item) {
											$value = $data[$date]['value'];
											$date = $date*1000;
											if (($date > 0) && ($value > 0)) {
												$jsonstrings[] .= "['$date', $value]";
												#$jsonstrings[] .= "['$date', " . number_format($value,1,'.','') . "]";
											}
										}
									?><?php 
echo implode2(',', $jsonstrings);
?>
]
										}
								];
							
								var options = {
									series: {
										lines: { show: true, fill: false },
										points: { show: true }
									},
									legend: { noColumns: 6 },
									xaxis: { mode: "time", timeformat: "%Y-%m-%d" },
									yaxis: { min: 0, tickDecimals: 1 },
									selection: { mode: "x" },
								};
								var placeholder = $("#placeholder<?php 
echo $id;
?>
");
								var plot = $.plot(placeholder, data, options);									
							});
						</script>
						<div id="placeholder<?php 
echo $id;
?>
" style="height:<?php 
echo $height;
?>
px;" align="center"></div>
					</td>
				</tr>
				<tr>
					<td class="body">
						<table class="tinytable">
							<thead>
								<th>Date</th>
								<th>Subject</th>
								<th>Study</th>
								<th>Value</th>
							</thead>
							<tbody>
						<?
							// get min, max
							$min = $data[0];
							$max = $data[0];
							foreach ($data as $date => $value) {
								$value = $data[$date]['value'];
								if ($value > $max) { $max = $value; }
								if ($value < $min) { $min = $value; }
							}
							$range = $max - $min;
							
							foreach ($data as $date => $value) {
								$value = $data[$date]['value'];
								$uid = $data[$date]['uid'];
								$studynum = $data[$date]['studynum'];
								$subjectid = $data[$date]['subjectid'];
								$studyid = $data[$date]['studyid'];
								if (($value > 0) && ($range > 0)) {
									$cindex = round((($value - $min)/$range)*100);
									if ($cindex > 100) { $cindex = 100; }
								}
								$date = $date;
								$date = date("D, d M Y", $date);
								?>
								<tr>
									<td><?php 
echo $date;
?>
</td>
									<td><a href="subjects.php?id=<?php 
echo $subjectid;
?>
"><?php 
echo $uid;
?>
</a></td>
									<td><a href="subjects.php?id=<?php 
echo $studyid;
?>
"><?php 
echo $uid;
echo $studynum;
?>
</a></td>
									<td align="right" bgcolor="<?php 
echo $colors[$cindex];
?>
"><tt><?php 
echo $value;
?>
<tt></td>
								</tr>
								<?
							}
						?>
							</tbody>
						</table>
					</td>
				</tr>
			</table>
		<?
	}
Пример #3
0
	function ViewGroup($id, $measures, $columns, $groupmeasures) {
	
		$urllist['Group List'] = "groups.php";
		NavigationBar("Groups", $urllist,0,'','','','');
		
		/* get the general group information */
		$sqlstring = "select * from groups where group_id = $id";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$groupname = $row['group_name'];
		$grouptype = $row['group_type'];

		?>
		<script>
			$(document).ready(function()
				{
					$("#studytable").tablesorter();
				}
			); 
		</script>
		
		<div align="center"><span style="color:darkblue;font-size:15pt;font-weight:bold"><?php 
echo $groupname;
?>
</span> - <i><?php 
echo $grouptype;
?>
</i> level group</div>
		<br><br>
		<?
		/* (subject level) group statistics */
		$totalage = 0;
		$numage = 0;
		$totalweight = 0;
		$numweight = 0;
		$n = 0;
		
		//print_r(get_defined_vars());
		
		/* ------------------ subject group type ------------------- */
		if ($grouptype == "subject") {
			/* get the actual group data (subject level) */
			$sqlstring = "select a.subjectgroup_id, b.*, (datediff(now(), birthdate)/365.25) 'age' from group_data a left join subjects b on a.data_id = b.subject_id where a.group_id = $id";
			$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$subjectid = $row['subject_id'];
				$name = $row['name'];
				$birthdate = $row['birthdate'];
				$age = $row['age'];
				$gender = $row['gender'];
				$ethnicity1 = $row['ethnicity1'];
				$ethnicity2 = $row['ethnicity2'];
				$weight = $row['weight'];
				$handedness = $row['handedness'];
				$education = $row['education'];
				$uid = $row['uid'];
				
				/* do some demographics calculations */
				$n++;
				if ($age > 0) {
					$totalage += $age;
					$numage++;
					$ages[] = $age;
				}
				if ($weight > 0) {
					$totalweight += $weight;
					$numweight++;
					$weights[] = $weight;
				}
				$genders{$gender}++;
				$educations{$education}++;
				$ethnicity1s{$ethnicity1}++;
				$ethnicity2s{$ethnicity2}++;
				$handednesses{$handedness}++;
			}
			if ($numage > 0) { $avgage = $totalage/$numage; } else { $avgage = 0; }
			if (count($ages) > 0) { $varage = sd($ages); } else { $varage = 0; }
			if ($numweight > 0) { $avgweight = $totalweight/$numweight; } else { $avgweight = 0; }
			if (count($weights) > 0) { $varweight = sd($weights); } else { $varweight = 0; }
			
			?>
			<table>
				<tr>
					<td valign="top" style="padding-right:20px">
						<?
						DisplayDemographicsTable($n,$avgage,$varage,$genders,$ethnicity1s,$ethnicity2s,$educations,$handednesses,$avgweight,$varweight);
						?>
					</td>
				</tr>
				<tr>
					<td valign="top" style="padding-right:20px">
						<details>
						<summary>SQL</summary>
						<?php 
echo PrintSQL($sqlstring);
?>
						</details>
					</td>
				</tr>
				<tr>
					<td valign="top">
						<form action="groups.php" method="post">
						<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
						<input type="hidden" name="action" value="removegroupitem">
						<table class="smallgraydisplaytable">
							<th>Initials</th>
							<th>UID</th>
							<th>Age<br><span class="tiny">current</span></th>
							<th>Sex</th>
							<th>Ethnicity 1</th>
							<th>Ethnicity 2</th>
							<th>Weight</th>
							<th>Handedness</th>
							<th>Education</th>
							<th>Alt UIDs</th>
							<th>Remove<br>from group</th>
						<?
						/* reset the result pointer to 0 to iterate through the results again */
						mysql_data_seek($result,0);
						while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
							$itemid = $row['subjectgroup_id'];
							$subjectid = $row['subject_id'];
							$name = $row['name'];
							$birthdate = $row['birthdate'];
							$age = $row['age'];
							$gender = $row['gender'];
							$ethnicity1 = $row['ethnicity1'];
							$ethnicity2 = $row['ethnicity2'];
							$weight = $row['weight'];
							$handedness = $row['handedness'];
							$education = $row['education'];
							$uid = $row['uid'];
							
							/* get list of alternate subject UIDs */
							$altuids = GetAlternateUIDs($subjectid);
							
							$parts = explode("^",$name);
							$name = substr($parts[1],0,1) . substr($parts[0],0,1);
							?>
							<tr>
								<td><?php 
echo $name;
?>
</td>
								<td><a href="subjects.php?id=<?php 
echo $subjectid;
?>
"><?php 
echo $uid;
?>
</a></td>
								<? if ($age <= 0) {$color = "red";} else {$color="black";} ?>
								<td style="color:<?php 
echo $color;
?>
"><?php 
echo number_format($age, 1);
?>
Y</td>
								<? if (!in_array(strtoupper($gender),array('M','F','O'))) {$color = "red";} else {$color="black";} ?>
								<td style="color:<?php 
echo $color;
?>
"><?php 
echo $gender;
?>
</td>
								<td><?php 
echo $ethnicitiy1;
?>
</td>
								<td><?php 
echo $ethnicitiy1;
?>
</td>
								<td><?php 
echo number_format($weight, 1);
?>
kg</td>
								<td><?php 
echo $handedness;
?>
</td>
								<td><?php 
echo $education;
?>
</td>
								<td><?php 
echo implode(', ', $altuids);
?>
</td>
								<!--<td><a href="groups.php?action=removegroupitem&itemid=<?php 
echo $itemid;
?>
&id=<?php 
echo $id;
?>
" style="color:red">X</a></td>-->
								<td><input type="checkbox" name="itemid[]" value="<?php 
echo $itemid;
?>
"></td>
							</tr>
							<?
						}
						?>
							<tr>
								<td colspan="100" align="right">
									<input type="submit" value="Remove">
									</form>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<?
		}
		
		/* ------------------ study group type ------------------- */
		if ($grouptype == "study") {
			$csv = "";
			
			/* get the demographics (study level) */
			$sqlstring = "select c.enroll_subgroup,d.*, (datediff(b.study_datetime, d.birthdate)/365.25) 'age' from group_data a left join studies b on a.data_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.group_id = $id group by d.uid order by d.uid,b.study_num";
			$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$studyid = $row['study_id'];
				$studynum = $row['study_num'];
				$studydesc = $row['study_desc'];
				$studyalternateid = $row['study_alternateid'];
				$studymodality = $row['study_modality'];
				$studydatetime = $row['study_datetime'];
				$studyoperator = $row['study_operator'];
				$studyperformingphysician = $row['study_performingphysician'];
				$studysite = $row['study_site'];
				$studyinstitution = $row['study_institution'];
				$studynotes = $row['study_notes'];
				$subgroup = $row['enroll_subgroup'];

				$subjectid = $row['subject_id'];
				$name = $row['name'];
				$birthdate = $row['birthdate'];
				$age = $row['age'];
				$gender = $row['gender'];
				$ethnicity1 = $row['ethnicity1'];
				$ethnicity2 = $row['ethnicity2'];
				$weight = $row['weight'];
				$handedness = $row['handedness'];
				$education = $row['education'];
				$uid = $row['uid'];

				$subjectids[] = $subjectid;
				/* do some demographics calculations */
				$n++;
				if ($age > 0) {
					$totalage += $age;
					$numage++;
					$ages[] = $age;
				}
				if ($weight > 0) {
					$totalweight += $weight;
					$numweight++;
					$weights[] = $weight;
				}
				$genders{$gender}++;
				$educations{$education}++;
				$ethnicity1s{$ethnicity1}++;
				$ethnicity2s{$ethnicity2}++;
				$handednesses{$handedness}++;
			}
			if ($numage > 0) { $avgage = $totalage/$numage; } else { $avgage = 0; }
			if (count($ages) > 0) { $varage = sd($ages); } else { $varage = 0; }
			if ($numweight > 0) { $avgweight = $totalweight/$numweight; } else { $avgweight = 0; }
			if (count($weights) > 0) { $varweight = sd($weights); } else { $varweight = 0; }
			
			if ($measures == "all") {
				$sqlstringD = "select a.subject_id, b.enrollment_id, c.*, d.measure_name from measures c join measurenames d on c.measurename_id = d.measurename_id left join enrollment b on c.enrollment_id = b.enrollment_id join subjects a on a.subject_id = b.subject_id where a.subject_id in (" . implode2(",", $subjectids) . ")";
				//PrintSQL($sqlstringD);
				$resultD = MySQLQuery($sqlstringD,__FILE__,__LINE__);
				
				if ($groupmeasures == "byvalue") {
					$mnames = array('ANTDX','AVDDX','AX1Com1_Code','AX1Com2_Code','AX1Com3_Code','AX1Com4_Code','AX1Com5_Code','AX1Com6_Code','AX1Com7_Code','AX1Pri_Code','AXIIDX','BRDDX','DPNDX','DSM-Axis','DSM-Axis1','DSM-Axis2','DSM-Axis295.3','DSM-Axis304.3','DSM-AxisV71.09','DSM_IV_TR','DXGROUP_1','DX_GROUP','MiniDxn','MiniDxnFollowUp','NARDX','OBCDX','PARDX','ProbandGroup','Psychosis','relnm1','SAsubtype','SCZDX','status','SubjectType','SZTDX');
					while ($rowD = mysql_fetch_array($resultD, MYSQL_ASSOC)) {
						$subjectid = $rowD['subject_id'];
						$measurename = $rowD['measure_name'];

						if (in_array($measurename,$mnames)) {
							if ($rowD['measure_type'] == 's') {
								$value = strtolower(trim($rowD['measure_valuestring']));
							}
							else {
								$value = strtolower(trim($rowD['measure_valuenum']));
							}
							
							if (is_numeric(substr($value,0,6))) {
								//echo "$value --6--> ";
								$value = substr($value,0,6);
								//echo "$value<br>";
							}
							elseif (is_numeric(substr($value,0,5))) {
								//echo "$value --5--> ";
								$value = substr($value,0,5);
								//echo "$value<br>";
							}
							elseif (is_numeric(substr($value,0,4))) {
								$value = substr($value,0,4);
							}
							elseif (is_numeric(substr($value,0,3))) {
								$value = substr($value,0,3);
							}
							elseif (is_numeric(substr($value,1,5))) {
								$value = substr($value,1,5);
							}
							elseif (substr($value,0,3) == "xxx") {
								$value = "xxx";
							}
							
							$measuredata[$subjectid][$value] = 1;
							$measurenames[] = $value;
						}
					}
					$measurenames = array_unique($measurenames);
					natsort($measurenames);
				}
				else {
					while ($rowD = mysql_fetch_array($resultD, MYSQL_ASSOC)) {
						if ($rowD['measure_type'] == 's') {
							$measuredata[$rowD['subject_id']][$rowD['measure_name']]['value'][] = $rowD['measure_valuestring'];
						}
						else {
							$measuredata[$rowD['subject_id']][$rowD['measure_name']]['value'][] = $rowD['measure_valuenum'];
						}
						$measuredata[$rowD['subject_id']][$rowD['measure_name']]['notes'][] = $rowD['measure_notes'];
						$measurenames[] = $rowD['measure_name'];
						//$i++;
					}
					$measurenames = array_unique($measurenames);
					natcasesort($measurenames);
				}
				//PrintVariable($measurenames, 'MeasureNames');
				//PrintVariable($measuredata, 'MeasureData');
			}
			
			/* setup the CSV header */
			if ($columns == "min") {
				$csv = "UID";
			}
			else {
				$csv = "Initials,UID,AgeAtStudy,Sex,Ethnicity,Race,SubGroup,Weight,Handedness,Education,AltUIDs,StudyID,Description,AltStudyID,Modality,StudyDate,Operator,Physician,Site";
			}
			
			?>
			<table>
				<tr>
					<td valign="top" style="padding-right:20px">
						<?
						DisplayDemographicsTable($n,$avgage,$varage,$genders,$ethnicity1s,$ethnicity2s,$educations,$handednesses,$avgweight,$varweight);
						?>
					</td>
				</tr>
				<tr>
					<td valign="top" style="padding-right:20px">
						<details>
						<summary>SQL</summary>
						<?php 
echo PrintSQL($sqlstring);
?>
						</details>
					</td>
				</tr>
				<tr>
					<td valign="top">
						<a href="groups.php?action=viewgroup&id=<?php 
echo $id;
?>
&measures=all">Include measures</a><br>
						<a href="groups.php?action=viewgroup&id=<?php 
echo $id;
?>
&measures=all&columns=min">Include measures and only UID</a><br>
						<a href="groups.php?action=viewgroup&id=<?php 
echo $id;
?>
&measures=all&columns=min&groupmeasures=byvalue">Include measures and only UID and group measures by value</a>
						<br><br>
						<span class="tiny">Click columns to sort. May be slow for large tables</span>

						<form action="groups.php" method="post">
						<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
						<input type="hidden" name="action" value="removegroupitem">
						
						<table id="studytable" class="tablesorter">
							<thead>
								<tr>
									<? if ($columns != "min") { ?>
									<th>Initials</th>
									<? } ?>
									<th>UID</th>
									<? if ($columns != "min") { ?>
									<th>Age<br><span class="tiny">at study</span></th>
									<th>Sex</th>
									<th>Ethnicities</th>
									<th>SubGroup</th>
									<th>Weight</th>
									<th>Handedness</th>
									<th>Education</th>
									<th>Alt UIDs</th>
									<th>Study ID</th>
									<th>Description</th>
									<th>Alternate Study ID</th>
									<th>Modality</th>
									<th>Date/time</th>
									<th>Operator</th>
									<th>Physician</th>
									<th>Site</th>
									<? } ?>
									<?
										if (count($measurenames) > 0) {
											foreach ($measurenames as $measurename) {
												echo "<th>$measurename</th>";
												$csv .= ",\"$measurename\"";
											}
										}
									?>
									<th>Remove<br>from group</th>
								</tr>
							</thead>
							<tbody>
						<?

						/* reset the result pointer to 0 to iterate through the results again */
						$sqlstring = "select a.subjectgroup_id, c.enroll_subgroup, b.*, d.*, (datediff(b.study_datetime, d.birthdate)/365.25) 'age' from group_data a left join studies b on a.data_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.group_id = $id order by d.uid,b.study_num";
						$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
						//mysql_data_seek($result,0);
						while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
							$studyid = $row['study_id'];
							$studynum = $row['study_num'];
							$studydesc = $row['study_desc'];
							$studyalternateid = $row['study_alternateid'];
							$studymodality = $row['study_modality'];
							$studydatetime = $row['study_datetime'];
							$studyoperator = $row['study_operator'];
							$studyperformingphysician = $row['study_performingphysician'];
							$studysite = $row['study_site'];
							$studyinstitution = $row['study_institution'];
							$studynotes = $row['study_notes'];
							$subgroup = $row['enroll_subgroup'];
							
							$itemid = $row['subjectgroup_id'];
							$subjectid = $row['subject_id'];
							$name = $row['name'];
							$birthdate = $row['birthdate'];
							$age = $row['age'];
							$gender = $row['gender'];
							$ethnicity1 = $row['ethnicity1'];
							$ethnicity2 = $row['ethnicity2'];
							$weight = $row['weight'];
							$handedness = $row['handedness'];
							$education = $row['education'];
							$uid = $row['uid'];

							/* get list of alternate subject UIDs */
							$altuids = GetAlternateUIDs($subjectid);
							
							$parts = explode("^",$name);
							$name = substr($parts[1],0,1) . substr($parts[0],0,1);
							
							if ($columns == "min") {
								$csv .= "\n\"$uid\"";
							}
							else {
								$csv .= "\n\"$name\",\"$uid\",\"$age\",\"$gender\",\"$ethnicity1\",\"$ethnicity2\",\"$subgroup\",\"$weight\",\"$handedness\",\"$education\",\"" . implode2(', ',$altuids) . "\",\"$uid$studynum\",\"$studydesc\",\"$studyalternateid\",\"$studymodality\",\"$studydatetime\",\"$studyoperator\",\"$studyperformingphysician\",\"$studysite\"";
							}
							?>
							<tr>
								<? if ($columns != "min") { ?>
								<td><?php 
echo $name;
?>
</td>
								<? } ?>
								<td><a href="subjects.php?id=<?php 
echo $subjectid;
?>
"><?php 
echo $uid;
?>
</a></td>
								<? if ($columns != "min") { ?>
								<? if ($age <= 0) {$color = "red";} else {$color="black";} ?>
								<td style="color:<?php 
echo $color;
?>
"><?php 
echo number_format($age, 1);
?>
Y</td>
								<? if (!in_array(strtoupper($gender),array('M','F','O'))) {$color = "red";} else {$color="black";} ?>
								<td style="color:<?php 
echo $color;
?>
"><?php 
echo $gender;
?>
</td>
								<td style="font-size:8pt"><?php 
echo $ethnicity1;
?>
 <?php 
echo $ethnicity2;
?>
</td>
								<td style="font-size:8pt"><?php 
echo $subgroup;
?>
</td>
								<? if ($weight <= 0) {$color = "red";} else {$color="black";} ?>
								<td style="color:<?php 
echo $color;
?>
"><?php 
echo number_format($weight, 1);
?>
kg</td>
								<td><?php 
echo $handedness;
?>
</td>
								<td><?php 
echo $education;
?>
</td>
								<td style="font-size:8pt"><?php 
echo implode2(', ', $altuids);
?>
</td>
								<td><a href="studies.php?id=<?php 
echo $studyid;
?>
"><?php 
echo $uid;
echo $studynum;
?>
</a></td>
								<td style="font-size:8pt"><?php 
echo $studydesc;
?>
</td>
								<td><?php 
echo $studyalternateid;
?>
</td>
								<td><?php 
echo $studymodality;
?>
</td>
								<td><?php 
echo $studydatetime;
?>
</td>
								<td><?php 
echo $studyoperator;
?>
</td>
								<td><?php 
echo $studyperformingphysician;
?>
</td>
								<td style="font-size:8pt"><?php 
echo $studysite;
?>
</td>
								<? } ?>
								<?
									if (count($measurenames) > 0) {
										if ($groupmeasures == "byvalue") {
											foreach ($measurenames as $measurename) {
												$csv .= ",\"" . $measuredata[$subjectid][$measurename] . "\"";
											?>
											<td class="seriesrow">
												<?
													if (isset($measuredata[$subjectid][$measurename])) {
														echo $measuredata[$subjectid][$measurename];
													}
												?>
											</td>
											<?
											}
										}
										else {
											foreach ($measurenames as $measure) {
												$csv .= ",\"" . $measuredata[$subjectid][$measure]['value'] . "\"";
												?>
												<td class="seriesrow">
													<?
														if (isset($measuredata[$subjectid][$measure]['value'])) {
															foreach ($measuredata[$subjectid][$measure]['value'] as $value) {
																echo "$value<br>";
															}
														}
													?>
												</td>
												<?
											}
										}
									}
								?>
								<!--<td><a href="groups.php?action=removegroupitem&itemid=<?php 
echo $itemid;
?>
&id=<?php 
echo $id;
?>
" style="color:red">X</a></td>-->
								<td><input type="checkbox" name="itemid[]" value="<?php 
echo $itemid;
?>
"></td>
							</tr>
							<?
						}
						?>
							<tr>
								<td colspan="100" align="right">
									<input type="submit" value="Remove">
									</form>
								</td>
							</tr>
							</tbody>
						</table>
					</td>
				</tr>
			</table>
			<?
			
				/* ---------- generate csv file ---------- */
				$filename = $groupname . "_" . GenerateRandomString(10) . ".csv";
				file_put_contents("/tmp/" . $filename, $csv);
				?>
				<div width="50%" align="center" style="background-color: #FAF8CC; padding: 5px;">
				Download .csv file <a href="download.php?type=file&filename=<?php 
echo "/tmp/{$filename}";
?>
"><img src="images/download16.png"></a>
				</div>
				<?
		}
		
		/* ------------------ series group type ------------------- */
		if ($grouptype == "series") {
			/* get a distinct list of modalities... then get a list of series for each modality */
			$sqlstring = "select distinct(modality) from group_data where group_id = $id order by modality";
			$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$modalities[] = $row['modality'];
			}
			
			foreach ($modalities as $modality) {
				$modality = strtolower($modality);
				/* get the demographics (series level) */
				$sqlstring = "select b.*,c.enroll_subgroup, e.*, (datediff(b.series_datetime, e.birthdate)/365.25) 'age' from group_data a left join ".$modality."_series b on a.data_id = b.".$modality."series_id left join studies c on b.study_id = c.study_id left join enrollment d on c.enrollment_id = d.enrollment_id left join subjects e on d.subject_id = e.subject_id where a.group_id = 3 and a.modality = '".$modality."' and e.subject_id is not null group by e.uid";
				$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
				while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
					$studyid = $row['study_id'];
					$studynum = $row['study_num'];
					$studydesc = $row['study_desc'];
					$studyalternateid = $row['study_alternateid'];
					$studymodality = $row['study_modality'];
					$studydatetime = $row['study_datetime'];
					$studyoperator = $row['study_operator'];
					$studyperformingphysician = $row['study_performingphysician'];
					$studysite = $row['study_site'];
					$studyinstitution = $row['study_institution'];
					$studynotes = $row['study_notes'];

					$subgroup = $row['enroll_subgroup'];
					
					$subjectid = $row['subject_id'];
					$name = $row['name'];
					$birthdate = $row['birthdate'];
					$age = $row['age'];
					$gender = $row['gender'];
					$ethnicity1 = $row['ethnicity1'];
					$ethnicity2 = $row['ethnicity2'];
					$weight = $row['weight'];
					$handedness = $row['handedness'];
					$education = $row['education'];
					$uid = $row['uid'];
					
					/* do some demographics calculations */
					$n++;
					if ($age > 0) {
						$totalage += $age;
						$numage++;
						$ages[] = $age;
					}
					if ($weight > 0) {
						$totalweight += $weight;
						$numweight++;
						$weights[] = $weight;
					}
					$genders{$gender}++;
					$educations{$education}++;
					$ethnicity1s{$ethnicity1}++;
					$ethnicity2s{$ethnicity2}++;
					$handednesses{$handedness}++;
				}
			}
			/* calculate some stats */
			if ($numage > 0) { $avgage = $totalage/$numage; } else { $avgage = 0; }
			if (count($ages) > 0) { $varage = sd($ages); } else { $varage = 0; }
			if ($numweight > 0) { $avgweight = $totalweight/$numweight; } else { $avgweight = 0; }
			if (count($weights) > 0) { $varweight = sd($weights); } else { $varweight = 0; }
			
			?>
			<table>
				<tr>
					<td valign="top" style="padding-right:20px">
						<?
						DisplayDemographicsTable($n,$avgage,$varage,$genders,$ethnicity1s,$ethnicity2s,$educations,$handednesses,$avgweight,$varweight);
						?>
					</td>
					<td valign="top" style="padding-right:20px">
						<details>
						<summary>SQL</summary>
						<?php 
echo PrintSQL($sqlstring);
?>
						</details>
					</td>
					<td valign="top">
						<table class="smallgraydisplaytable">
							<th>Initials</th>
							<th>UID</th>
							<th>Age<br><span class="tiny">at study</span></th>
							<th>Sex</th>
							<th>Ethnicities</th>
							<th>SubGroup</th>
							<th>Weight</th>
							<th>Handedness</th>
							<th>Education</th>
							<th>Alt UIDs</th>
							<th>Study ID</th>
							<th>Description/Protocol</th>
							<th>Modality</th>
							<th>Date/time</th>
							<th>Series #</th>
							<th>Remove<br>from group</th>
						<?
						/* get a distinct list of modalities... then get a list of series for each modality */
						
						/* reset the result pointer to 0 to iterate through the results again */
						foreach ($modalities as $modality) {
							$modality = strtolower($modality);
							/* get the demographics (series level) */
							$sqlstring = "select b.*, c.study_num, e.*, (datediff(b.series_datetime, e.birthdate)/365.25) 'age' from group_data a left join ".$modality."_series b on a.data_id = b.".$modality."series_id left join studies c on b.study_id = c.study_id left join enrollment d on c.enrollment_id = d.enrollment_id left join subjects e on d.subject_id = e.subject_id where a.group_id = 3 and a.modality = '".$modality."' and e.subject_id is not null";
							//print "[$sqlstring]<br>";
							$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
							mysql_data_seek($result,0);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								$seriesdesc = $row['series_desc'];
								$seriesprotocol = $row['series_protocol'];
								$seriesdatetime = $row['series_datetime'];
								$seriesnum = $row['series_num'];
								$studynum = $row['study_num'];
								$seriesmodality = strtoupper($modality);
								
								$itemid = $row['subjectgroup_id'];
								$subjectid = $row['subject_id'];
								$name = $row['name'];
								$birthdate = $row['birthdate'];
								$age = $row['age'];
								$gender = $row['gender'];
								$ethnicity1 = $row['ethnicity1'];
								$ethnicity2 = $row['ethnicity2'];
								$weight = $row['weight'];
								$handedness = $row['handedness'];
								$education = $row['education'];
								$uid = $row['uid'];

								/* get list of alternate subject UIDs */
								$altuids = GetAlternateUIDs($subjectid);
								
								$parts = explode("^",$name);
								$name = substr($parts[1],0,1) . substr($parts[0],0,1);
								?>
								<tr>
									<td><?php 
echo $name;
?>
</td>
									<td><a href="subjects.php?id=<?php 
echo $subjectid;
?>
"><?php 
echo $uid;
?>
</a></td>
									<? if ($age <= 0) {$color = "red";} else {$color="black";} ?>
									<td style="color:<?php 
echo $color;
?>
"><?php 
echo number_format($age, 1);
?>
Y</td>
									<? if (!in_array(strtoupper($gender),array('M','F','O'))) {$color = "red";} else {$color="black";} ?>
									<td style="color:<?php 
echo $color;
?>
"><?php 
echo $gender;
?>
</td>
									<td style="font-size:8pt"><?php 
echo $ethnicitiy1;
?>
 <?php 
echo $ethnicitiy1;
?>
</td>
									<td style="font-size:8pt"><?php 
echo $subgroup;
?>
</td>
									<? if ($weight <= 0) {$color = "red";} else {$color="black";} ?>
									<td style="color:<?php 
echo $color;
?>
"><?php 
echo number_format($weight, 1);
?>
kg</td>
									<td><?php 
echo $handedness;
?>
</td>
									<td><?php 
echo $education;
?>
</td>
									<td style="font-size:8pt"><?php 
echo implode2(', ', $altuids);
?>
</td>
									<td><a href="studies.php?id=<?php 
echo $studyid;
?>
"><?php 
echo $uid;
echo $studynum;
?>
</a></td>
									<td style="font-size:8pt"><?php 
echo $seriesdesc;
?>
 <?php 
echo $seriesprotocol;
?>
</td>
									<td><?php 
echo $seriesmodality;
?>
</td>
									<td style="font-size:8pt"><?php 
echo $seriesdatetime;
?>
</td>
									<td><?php 
echo $seriesnum;
?>
</td>
									<td><a href="groups.php?action=removegroupitem&itemid=<?php 
echo $itemid;
?>
&id=<?php 
echo $id;
?>
" style="color:red">X</a></td>
								</tr>
								<?
							}
						}
						?>
						</table>
					</td>
				</tr>
			</table>
			<?
		}
	}
Пример #4
0
function AddPipeline($pipelinetitle, $pipelinedesc, $pipelinegroup, $pipelinenumproc, $pipelinesubmithost, $pipelinequeue, $pipelineremovedata, $pipelinedirectory, $pipelineusetmpdir, $pipelinetmpdir, $pipelinenotes, $username, $completefiles, $dependency, $deplevel, $depdir, $deplinktype, $groupid, $dynamicgroupid, $level, $ishidden)
{
    /* perform data checks */
    $pipelinetitle = mysql_real_escape_string($pipelinetitle);
    $pipelinedesc = mysql_real_escape_string($pipelinedesc);
    $pipelinegroup = mysql_real_escape_string($pipelinegroup);
    $pipelinenumproc = mysql_real_escape_string($pipelinenumproc);
    $pipelinesubmithost = mysql_real_escape_string($pipelinesubmithost);
    $pipelinequeue = mysql_real_escape_string($pipelinequeue);
    $pipelineremovedata = mysql_real_escape_string($pipelineremovedata);
    $pipelineresultsscript = mysql_real_escape_string($pipelineresultsscript);
    $pipelinedirectory = mysql_real_escape_string($pipelinedirectory);
    $pipelineusetmpdir = mysql_real_escape_string($pipelineusetmpdir);
    $pipelinetmpdir = mysql_real_escape_string($pipelinetmpdir);
    $pipelinenotes = mysql_real_escape_string($pipelinenotes);
    $completefiles = mysql_real_escape_string($completefiles);
    $deplevel = mysql_real_escape_string($deplevel);
    $depdir = mysql_real_escape_string($depdir);
    $deplinktype = mysql_real_escape_string($deplinktype);
    $ishidden = mysql_real_escape_string($ishidden);
    if (is_array($dependency)) {
        $dependencies = implode(",", $dependency);
    }
    if (is_array($groupid)) {
        $groupids = implode2(",", $groupid);
    }
    if (is_array($dynamicgroupids)) {
        $dynamicgroupids = implode2(",", $dynamicgroupid);
    }
    /* get userid */
    $sqlstring = "select user_id from users where username = '******'";
    $result = MySQLiQuery($sqlstring, __FILE__, __LINE__);
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    $userid = $row['user_id'];
    /* insert the new form */
    $sqlstring = "insert into pipelines (pipeline_name, pipeline_desc, pipeline_group, pipeline_admin, pipeline_createdate, pipeline_status, pipeline_numproc, pipeline_submithost, pipeline_queue, pipeline_removedata, pipeline_resultsscript, pipeline_completefiles, pipeline_dependency, pipeline_dependencylevel, pipeline_dependencydir, pipeline_deplinktype, pipeline_groupid, pipeline_dynamicgroupid, pipeline_level, pipeline_directory, pipeline_usetmpdir, pipeline_tmpdir, pipeline_notes, pipeline_ishidden) values ('{$pipelinetitle}', '{$pipelinedesc}', '{$pipelinegroup}', '{$userid}', now(), 'stopped', '{$pipelinenumproc}', '{$pipelinesubmithost}', '{$pipelinequeue}', '{$pipelineremovedata}', '{$pipelineresultsscript}', '{$completefiles}', '{$dependencies}', '{$deplevel}', '{$depdir}', '{$deplinktype}', '{$groupids}', '{$dynamicgroupids}', '{$level}', '{$pipelinedirectory}', '{$pipelineusetmpdir}', '{$pipelinetmpdir}', '{$pipelinenotes}', '{$ishidden}')";
    //PrintSQL($sqlstring);
    $result = MySQLiQuery($sqlstring, __FILE__, __LINE__);
    ?>
<div align="center"><span class="message"><?php 
    echo $formtitle;
    ?>
 added</span></div><?php 
}
Пример #5
0
function ObliterateStudy($studyids)
{
    /* delete all information about this SUBJECT from the database */
    foreach ($studyids as $id) {
        $sqlstring = "insert into fileio_requests (fileio_operation, data_type, data_id, username, requestdate) values ('delete', 'study', {$id},'" . $GLOBALS['username'] . "', now())";
        PrintSQL($sqlstring);
        $result = MySQLQuery($sqlstring, __FILE__, __LINE__);
    }
    //PrintVariable($ids,'ids');
    //PrintVariable($uids,'uids');
    //PrintVariable($uidstudynums,'uidstudynums');
    ?>
		<div align="center" class="message">Studies [<?php 
    echo implode2(', ', $studyids);
    ?>
] queued for obliteration</div>
		<?php 
}
Пример #6
0
	function ParseMeasureResultList($str, $field) {

		$parts = explode(',',$str);
		foreach ($parts as $part) {
			if (strpos($part,'*') !== false) {
				$part = str_replace('*','%',$part);
				$part = "$field like '$part'";
			}
			else {
				$part = "$field = '$part'";
			}
			$newparts[] = $part;
		}
		return implode2(" or ", $newparts);
	}
Пример #7
0
	function DisplayStats() {
	
		$urllist['Statistics'] = "stats.php";
		NavigationBar("Stats", $urllist);

		$currentyear = date("Y");
		
		$sqlstring = "select count(*) count from subjects where isactive = 1";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numsubjects = number_format($row['count']);
		$numtotalsubjects = $row['count'];

		$sqlstring = "select count(*) count from studies";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numstudies = $row['count'];

		$totalseries = 0;
		$totalsize = 0;
		$sqlstring = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '%\_series'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			//print_r($row);
			$tablename = $row['Tables_in_' . $GLOBALS['cfg']['mysqldatabase'] . ' (%\_series)'];
			//echo $tablename;
			$parts = explode("_", $tablename);
			$modality = $parts[0];
			
			$sqlstring2 = "select count(*) 'count', sum(series_size) 'size' from $modality" . "_series";
			$result2 = MySQLQuery($sqlstring2,__LINE__,__FILE__);
			$row2 = mysql_fetch_array($result2, MYSQL_ASSOC);
			$totalseries += $row2['count'];
			$totalsize += $row2['size'];
			$seriescounts[$modality] = number_format($row2['count']);
			$seriessize[$modality] = HumanReadableFilesize($row2['size']);

			$sqlstring2 = "select sum(b.series_size) 'totalbytes' from data_requests a left join $modality" . "_series b on a.req_seriesid = b.$modality" . "series_id";
			//PrintSQL($sqlstring);
			$result2 = MySQLQuery($sqlstring2,__LINE__,__FILE__);
			$row2 = mysql_fetch_array($result2, MYSQL_ASSOC);
			$seriesreqsize[$modality] = HumanReadableFilesize($row2['totalbytes']);
			$totalreqbytes += $row2['totalbytes'];
		}
		//print_r($seriescounts);
		
		/* total series qa time */
		$sqlstring = "select sum(cputime) totalcpu from mr_qa";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalcpu'];
		$totalseriesqacpu = FormatCountdown($diff);

		/* total study qa time */
		$sqlstring = "select sum(cputime) totalcpu from mr_studyqa";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalcpu'];
		$totalstudyqacpu = FormatCountdown($diff);
		
		/* total request processing time */
		$sqlstring = "select sum(req_cputime) totalrequestcpu from data_requests";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalrequestcpu'];
		$totalrequestcpu = FormatCountdown($diff);
		
		/* mean request time */
		$sqlstring = "SELECT avg(time_to_sec(timediff(req_completedate, req_date))) avgtime FROM `data_requests` where req_completedate > '000-00-00 00:00:00'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['avgtime'];
		$avgrequesttime = FormatCountdown($diff);

		/* median request time */
		$sqlstring = "SELECT * FROM `data_requests` where req_completedate > '0000-00-00 00:00:00'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$numrows = mysql_num_rows($result);
		$med = round($numrows/2);
		
		$sqlstring = "SELECT time_to_sec(timediff(req_completedate, req_date)) avgtime FROM `data_requests` where req_completedate > '0000-00-00 00:00:00' order by avgtime limit $med,1";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['avgtime'];
		$medianrequesttime = FormatCountdown($diff);
		
		$uptime = shell_exec('uptime');
		
		/* subject demographics */
		$sqlstring = "select (select count(*) from subjects where gender = 'F') 'numfemales', (select count(*) from subjects where gender = 'M') 'nummales', (select count(*) from subjects where gender = 'O') 'numother', (select count(*) from subjects where gender = 'U') 'numunknown', (select count(*) from subjects where gender not in ('F','M','O','U')) 'numnotspec'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numfemales = $row['numfemales'];
		$nummales = $row['nummales'];
		$numother = $row['numother'];
		$numunknown = $row['numunknown'];
		$numnotspec = $row['numnotspec'];
		
		?>
		
		<table width="100%">
			<tr>
				<td valign="top" width="50%">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Series Info</td>
						</tr>
						<tr>
							<td class="body">
								<span style="font-size:10pt;">
								<b>Available Data:</b><br>
								<?php 
echo $numsubjects;
?>
 subjects<br>
								<?php 
echo number_format($numstudies);
?>
 studies<br>
								<br>
								<table class="smalldisplaytable">
									<tr>
										<th><b>Series</b></th>
										<th align="right"><b>Count</b></th>
										<th align="right"><b>Size</b></th>
										<th align="right"><b>Request Data</b></th>
									</tr>
								<?
									foreach ($seriescounts as $modality => $count) {
										?>
										<tr>
											<td><?php 
echo strtoupper($modality);
?>
</td>
											<td align="right"><?php 
echo $count;
?>
</td>
											<td align="right"><?php 
echo $seriessize[$modality];
?>
</td>
											<td align="right"><?php 
echo $seriesreqsize[$modality];
?>
</td>
										</tr>
										<?
									}
								?>
									<tr style="color: #5882FA; font-weight: bold">
										<td>Total</td>
										<td align="right"><?php 
echo number_format($totalseries);
?>
</td>
										<td align="right"><?php 
echo HumanReadableFilesize($totalsize);
?>
</td>
										<td align="right"><?php 
echo HumanReadableFilesize($totalreqbytes);
?>
</td>
									</tr>
								</table>
								</span>
							</td>
						</tr>
					</table>
					
					<br>
					
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">System Info</td>
						</tr>
						<tr>
							<td class="body">
								<span class="header">Uptime</span><br>
								<?php 
echo $uptime;
?>
								<br><bR>
								<span class="header">Data Requests</span><br>
								<b>CPU time:</b> <?php 
echo $totalrequestcpu;
?>
<br>
								<b>Mean request time:</b> <?php 
echo $avgrequesttime;
?>
<br>
								<b>Median request time:</b> <?php 
echo $medianrequesttime;
?>
<br>
							</td>
						</tr>
					</table>
					
					<br>
					
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Subject Demographics</td>
						</tr>
						<tr>
							<td class="body">
								<table class="reviewtable">
									<tr>
										<td class="label"># females</td>
										<td class="value"><?php 
echo $numfemales;
?>
 (<?php 
echo number_format($numfemales / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># males</td>
										<td class="value"><?php 
echo $nummales;
?>
 (<?php 
echo number_format($nummales / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># other</td>
										<td class="value"><?php 
echo $numother;
?>
 (<?php 
echo number_format($numother / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># unknown</td>
										<td class="value"><?php 
echo $numunknown;
?>
 (<?php 
echo number_format($numunknown / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># not specified</td>
										<td class="value"><?php 
echo $numnotspec;
?>
 (<?php 
echo number_format($numnotspec / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>					
				</td>
				<td valign="top" width="50%">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">MR</td>
						</tr>
						<tr>
							<td class="body">
								<span class="header">CPU time</span><br>
								<b>Total series QA CPU time:</b> <?php 
echo $totalseriesqacpu;
?>
<br>
								<b>Total study QA CPU time:</b> <?php 
echo $totalstudyqacpu;
?>
<br>
							</td>
						</tr>
						<tr>
							<td class="body">
								<table cellspacing="0" cellpadding="2" style="font-size:10pt">
									<tr>
										<td colspan="24" align="center"><span class="header">Total # MR studies starting at time...</span></td>
									</tr>
									<tr>
										<td colspan="12" align="center" style="border-bottom: 1px solid gray; border-right: 1pt solid gray">AM</td>
										<td colspan="12" align="center" style="border-bottom: 1px solid gray">PM</td>
									</tr>
									<tr style="font-size:10pt">
										<?
											for ($hour=0;$hour<24;$hour++) {
												if ($hour == 0){
													?><td align="center" style="border-left: solid 1px #CCCCCC; border-right: solid 1px #CCCCCC;">12</td><?
												}
												else {
													if ($hour < 12) {
														?><td align="center" style="border-right: solid 1px #CCCCCC;"><?php 
echo $hour;
?>
</td><?
													}
													else {
														$hr = $hour;
														if ($hour != 12) {
															$hr = $hr - 12;
														}
														?><td align="center" style="border-right: solid 1px #CCCCCC;"><?php 
echo $hr;
?>
</td><?
													}
												}
											}
										?>
									</tr>
									<tr>
								<?
									for ($hour=0;$hour<24;$hour++) {
										$sqlstring = "select count(*) count from studies where hour(study_datetime) = $hour and study_modality = 'MR'";
										#echo "$sqlstring<br>";
										$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
										$row = mysql_fetch_array($result, MYSQL_ASSOC);
										$count = $row['count'];
										$percent = round(($count/$numstudies)*100);
										$counts[$hour] = $count;
										//echo "[$count] [$numstudies] [$percent]";
										#echo "<td align=right>$percent%&nbsp;</td>";
										?>
										<td valign="bottom" align="center" style="border-right: solid 1px #CCCCCC;">
											<table height="<? echo $percent*2; ?>px" cellpadding=0 cellspacing=0 width="15px">
												<tr>
													<td bgcolor="red" style="font-size: 0px">&nbsp;</td>
												</tr>
											</table>
										</td>
										<?
									}
									?> </tr><tr style="font-size:8pt"> <?
									for ($hour=0;$hour<24;$hour++) {
										echo "<td align=center>$counts[$hour]</td>";
									}
								?>
									</tr>
								</table>
								<br><br>
								<table cellspacing="0" cellpadding="2" style="font-size:10pt">
									<tr>
										<td colspan="13" align="center" style="border-bottom: 1pt solid darkgray"><span class="header">Scan History (# sessions per month)</span></td>
									</tr>
									<tr>
										<td>Year</td>
										<td>Jan</td>
										<td>Feb</td>
										<td>Mar</td>
										<td>Apr</td>
										<td>May</td>
										<td>Jun</td>
										<td>Jul</td>
										<td>Aug</td>
										<td>Sep</td>
										<td>Oct</td>
										<td>Nov</td>
										<td>Dec</td>
									</tr>
								<?
								
									$sqlstring = "select year(min(study_datetime)) firstyear from studies where study_datetime > '0000-00-00 00:00:01' and study_modality = 'MR'";
									$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
									$row = mysql_fetch_array($result, MYSQL_ASSOC);
									$firstyear = $row['firstyear'];
									
									$numyears = $currentyear - $firstyear;
									
									for ($year=$firstyear;$year<=$currentyear;$year++) {
										?>
										<tr>
											<td>
												<a href="reports.php?action=yearstudy&year=<?php 
echo $year;
?>
&modality=MR"><b><?php 
echo $year;
?>
</b></a>
											</td>
										<?
										for ($month=1;$month<=12;$month++) {
											$sqlstring = "select count(*) count from studies where year(study_datetime) = $year and month(study_datetime) = $month and study_modality = 'MR'";
											#echo "$sqlstring<br>";
											$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
											$row = mysql_fetch_array($result, MYSQL_ASSOC);
											$count = $row['count'];
											echo "<td align=right>$count &nbsp;</td>";
										}
										?>
										</tr>
										<?
									}
								?>
								</table>
								
							</td>
						</tr>
						<tr>
							<td class="body">
							<?
								$sqlstring = "SELECT (move_maxx-move_minx + move_maxy-move_miny + move_maxz-move_minz) 'totalmovement', datediff(c.study_datetime, e.birthdate) 'ageatscan', e.gender FROM mr_qa a left join mr_series b on a.mrseries_id = b.mrseries_id left join studies c on b.study_id = c.study_id left join enrollment d on c.enrollment_id = d.enrollment_id left join subjects e on d.subject_id = e.subject_id where datediff(c.study_datetime, e.birthdate) < 45656 and e.gender in ('M','F')";
								$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
								$i=0;
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									if (($row['totalmovement'] > 0) && ($row['totalmovement'] < 50)) {
										//print_r($row);
										$y[] = number_format($row['totalmovement'],2);
										$x[] = number_format($row['ageatscan']/365.25,2);
										if ($row['gender'] == 'F')
											$c[] = 'FF0000'; //$c[] = 'FFC0CB';
										elseif ($row['gender'] == 'M')
											$c[] = '0000FF'; //$c[] = '4169E1';
										else
											$c[] = '888888';
										$i++;
									}
									//if ($i>100) break;
								}
								//print_r($x);
								$chd = implode(",",$x) . "|" . implode(",",$y);
								$chco = implode("|",$c);
								
								$x = implode(",",$x);
								$y = implode(",",$y);
								$c = implode(",",$c);
								
								$chartfilename = DrawScatterPlot(600,300,$x,$y,$c);
							?>
							<b>Age vs movement</b><br>
							<img src="data:image/png;base64,<?php 
echo base64_encode(file_get_contents($chartfilename));
?>
">
							<?
								/* image data should've been sent to the browser, so delete the temp image */
								unlink($chartfilename);
							?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Cumulative Data Storage by Site</td>
						</tr>
						<tr>
							<td class="body">
								<?
									unset($sites);
									/* get the list of possible study sites (equipments) */
									//$sqlstring = "select distinct(study_site) 'site' from studies";
									$sqlstring = "select distinct(study_site) 'site' from studies where study_site in ('hhntMRC20107','AWP45351','WHSKYRA-01')";
									$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
									while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
										$sites[] = $row['site'];
									}
									
									natcasesort($sites);
									//PrintVariable($sites,'sites');
									
								?>
								<script>
									$(function() {
											var data2 = [
									<?
										foreach ($sites as $site) {
											unset($jsonstrings);
											$cumtotal = 0;
											?>
												{
												label: "<?php 
echo $site;
?>
",
												data: [<?
											$sqlstring = "SELECT unix_timestamp(DATE(a.study_datetime)) Date, a.study_site, COUNT(DISTINCT a.study_datetime) totalCount, sum(b.series_size) 'totalsize' FROM studies a left join mr_series b on a.study_id = b.study_id where a.study_site = '$site' GROUP BY DATE(a.study_datetime) order by Date";
											$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
											while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
											//$row = mysql_fetch_array($result, MYSQL_ASSOC);
												$date = $row['Date']*1000;
												if ($date > 0) {
													$totalsize = $row['totalsize']/1000/1000/1000;
													$totalcount = $row['totalCount'];
													$cumtotal += $totalsize;
													//$studysites[$site][$date]['size'] = $totalsize;
													//$studysites[$site][$date]['count'] = $totalcount;
													
													//$jsonstrings[] .= "['$date', $totalsize]";
													$jsonstrings[] .= "['$date', " . number_format($cumtotal,1,'.','') . "]";
												}
											}
											?><?php 
echo implode2(',', $jsonstrings);
?>
]
												},
											<?
											
										}
										//PrintVariable($studysites,'StudySites');
									?>
										];
									
										var options2 = {
											series: {
												lines: {
													show: true,
													fill: true
												},
												points: {
													show: false
												}
											},
											legend: {
												noColumns: 6
											},
											xaxis: {
												mode: "time",
												timeformat: "%Y-%m-%d"
											},
											yaxis: {
												min: 0,
												tickDecimals: 1
											},
											selection: {
												mode: "x"
											}
										};

										var placeholder2 = $("#placeholder2");

										var plot2 = $.plot(placeholder2, data2, options2);
									});
								</script>
								
								<div class='flot-y-axis'>
									<div class='flot-tick-label'>GB</div>
								</div>
								<div id="placeholder2" style="width:1100px;height:600px;"></div>
							</td>
						</tr>
					</table>
					<br><Br>
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Data Storage by Day by Site</td>
						</tr>
						<tr>
							<td class="body">
								<?
									unset($sites);
									/* get the list of possible study sites (equipments) */
									$sqlstring = "select distinct(study_site) 'site' from studies where study_site in ('hhntMRC20107','AWP45351','WHSKYRA-01')";
									$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
									while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
										$sites[] = $row['site'];
									}
									
									natcasesort($sites);
									//PrintVariable($sites,'sites');
									
								?>
								<script>
									$(function() {
											var data = [
									<?
										foreach ($sites as $site) {
											unset($jsonstrings);
											?>
												{
												label: "<?php 
echo $site;
?>
",
												data: [<?
											$sqlstring = "SELECT unix_timestamp(DATE(a.study_datetime)) Date, a.study_site, COUNT(DISTINCT a.study_datetime) totalCount, sum(b.series_size) 'totalsize' FROM studies a left join mr_series b on a.study_id = b.study_id where a.study_site = '$site' GROUP BY DATE(a.study_datetime) order by Date";
											$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
											while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
											//$row = mysql_fetch_array($result, MYSQL_ASSOC);
												$date = $row['Date']*1000;
												if ($date > 0) {
													$totalsize = $row['totalsize']/1000/1000/1000;
													$totalcount = $row['totalCount'];
													//$cumtotal += $totalsize;
													//$studysites[$site][$date]['size'] = $totalsize;
													//$studysites[$site][$date]['count'] = $totalcount;
													
													$jsonstrings[] .= "['$date', " . number_format($totalsize,1,'.','') . "]";
													//$jsonstrings[] .= "['$date', $cumtotal]";
												}
											}
											?><?php 
echo implode2(',', $jsonstrings);
?>
]
												},
											<?
											
										}
										//PrintVariable($studysites,'StudySites');
									?>
										];
									
										var options = {
											series: {
												lines: {
													show: true,
													fill: true
												},
												points: {
													show: false
												}
											},
											legend: {
												noColumns: 6
											},
											xaxis: {
												mode: "time",
												timeformat: "%Y-%m-%d"
											},
											yaxis: {
												min: 0,
												tickDecimals: 1
											},
											selection: {
												mode: "x"
											}
										};

										var placeholder = $("#placeholder");

										var plot = $.plot(placeholder, data, options);									
									});
								</script>
								
								<div class='flot-y-axis'>
									<div class='flot-tick-label'>GB</div>
								</div>
								<div id="placeholder" style="width:1100px;height:600px;"></div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<?
	}
Пример #8
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>
	<?
	}
Пример #9
0
 public function testImplode2()
 {
     $arr = array('ONE', 'TWO', 'THREE');
     $ret = implode2($arr, 'SEP1', 'SEP2');
     $this->assertEquals($ret, 'SEP1ONESEP2SEP1TWOSEP2SEP1THREESEP2');
 }