function DisplayStats() { $urllist['Statistics'] = "stats.php"; NavigationBar("Stats", $urllist); $currentyear = date("Y"); $sqlstring = "select count(*) count from subjects where isactive = 1"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numsubjects = number_format($row['count']); $numtotalsubjects = $row['count']; $sqlstring = "select count(*) count from studies"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numstudies = $row['count']; $totalseries = 0; $totalsize = 0; $sqlstring = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '%_series'"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); 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 = mysql_query($sqlstring2) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring2</i><br>"); $row2 = mysql_fetch_array($result2, MYSQL_ASSOC); $totalseries += $row2['count']; $totalsize += $row2['size']; $seriescounts[$modality] = number_format($row2['count']); $seriessize[$modality] = HumanReadableFilesize($row2['size']); } /* total series qa time */ $sqlstring = "select sum(cputime) totalcpu from mr_qa"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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> </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> </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> </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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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% </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"> </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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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 = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $row = mysql_fetch_array($result, MYSQL_ASSOC); $count = $row['count']; echo "<td align=right>$count </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"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $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,400,$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> </table> <? }
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% </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"> </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 </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> <? }