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 }
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> <? } }
function Anonymize($r, $username) { $seriesids = $r['seriesid']; $modality = $r['modality']; $dicomtags = mysql_real_escape_string($r['dicomtags']); if (($seriesids == "") && ($enrollmentids == "")) { echo "You didn't select any series or subjects to download/export! Go back and select something<br>"; return; } foreach ($seriesids as $seriesid) { $sqlstring = "insert into fileio_requests (fileio_operation, data_type, data_id, modality, anonymize_fields, request_status, username, requestdate) values ('anonymize','series',$seriesid,'$modality','$dicomtags','pending','$username',now())"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring,__FILE__,__LINE__); } }
function UpdateSchema($display) { global $taboptarray, $tables, $indexes; $ds =& ADONewConnection(DBF_TYPE); if (!$ds) { echo "Invalid database driver selected<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } $ds->debug = DBF_DEBUG; $tmp = error_reporting(0); if (!$ds->Connect(DBF_HOST, DBF_USER, DBF_PASSWORD, DBF_NAME)) { echo "Failed to connect to database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } error_reporting($tmp); $ds->SetFetchMode(ADODB_FETCH_ASSOC); // check mysql version if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql") { $result =& $ds->Execute("SELECT version() AS version"); $row = $result->FetchRow(); $version = $row["version"]; if ($version < "3.23.15") { //die("You need mysql version 3.23.15 or later"); } if ($version >= "5.1") { // database TYPE= changed to ENGINE= $taboptarray = str_replace("TYPE=", "ENGINE=", $taboptarray); } } // get schema version // schema is reserved word in mssql and mysql 5 if (DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') { // version upgrade before schema 18 using table called 'schema' if (in_array("schema", $ds->MetaTables())) { $result =& $ds->Execute("SELECT version\n FROM `schema`"); } else { $result =& $ds->Execute("SELECT version\n FROM version"); } } else { if (DBF_TYPE == "mssql" or DBF_TYPE == "ado_mssql" or DBF_TYPE == "odbc_mssql") { $result =& $ds->Execute("SELECT version\n FROM version"); } else { $result =& $ds->Execute("SELECT version\n FROM schema"); } } // could not read version number - probably hit upgrade button // for new install if (!$result) { die("<p>Could not determine IPplan version number - probably a database permission problem, the wrong database was selected or this is actually a new installation and not an upgrade!"); } // could return error if schema table does not exist! $row = $result->FetchRow(); $version = $row["version"]; //$version=18; // for testing // schema version did not change if ($version == SCHEMA) { return; } else { if (SCHEMA < $version) { echo "You are trying to downgrade IPplan - impossible"; exit; } } // Then create a data dictionary object, using this connection // this is crap - $dict should be passed to DoSQL too? $dict = NewDataDictionary($ds); $sqlarray = array(); $sqlarrayt = array(); switch ($version) { case 0: if (DBF_TYPE == "mssql" or DBF_TYPE == "ado_mssql" or DBF_TYPE == "odbc_mssql") { DoSQL($ds, $display, "version", $tables["version"]); } else { DoSQL($ds, $display, "schema", $tables["schema"]); } case 1: DoSQL($ds, $display, "custinfo", $tables["custinfo"]); DoSQL($ds, $display, "revdns", $tables["revdns"]); // should be NOT NULL, but this fails on broken databases like PGSQL $sqlarray = $dict->AddColumnSQL("grp", array(array('createcust', 'C', '1', 'DEFAULT' => 'N'))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 2: $sqlarray = $dict->AlterColumnSQL("base", array(array('customer', (DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') ? 'SMALLINT UNSIGNED' : 'I4', 'DEFAULT' => 0))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } // should be NOT NULL, but this fails on broken databases like PGSQL $sqlarray = $dict->AddColumnSQL("base", array(array('lastmod', 'T', 'DEFTIMESTAMP'), array('userid', 'C', '40', 'DEFAULT' => ''))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } // should be NOT NULL, but this fails on broken databases like PGSQL $sqlarray = $dict->AddColumnSQL("base", array(array('lastmod', 'T', 'DEFTIMESTAMP'), array('userid', 'C', '40', 'DEFAULT' => ''), array('swipmod', 'T'))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 3: DoSQL($ds, $display, "bounds", $tables["bounds"]); case 4: // cannot rename columns so create new column, copy data, delete old $sqlarray = $dict->AddColumnSQL("ipaddr", array(array('userinf', 'C', '80', 'DEFAULT' => ''))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } $sqlarray = $dict->DropColumnSQL("ipaddr", array('user')); $sqlarray[] = "ALTER TABLE `user` RENAME `users`"; foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 5: $sqlarray = $dict->AddColumnSQL("grp", array(array('grpopt', (DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') ? 'INT UNSIGNED' : 'I8', 'DEFAULT' => 0))); $sqlarray[] = 'UPDATE grp SET grpopt=1'; foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 6: DoSQL($ds, $display, "ipaddradd", $tables["ipaddradd"]); case 7: // don't add column if we did no 6 if ($version >= 7) { $sqlarray = $dict->AddColumnSQL("ipaddradd", array(array('infobinfn', 'C', '255', 'DEFAULT' => ''))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } } case 8: DoSQL($ds, $display, "fwdzone", $tables["fwdzone"]); DoSQL($ds, $display, "fwdzonerec", $tables["fwdzonerec"]); DoSQL($ds, $display, "fwddns", $tables["fwddns"]); DoSQL($ds, $display, "zones", $tables["zones"]); DoSQL($ds, $display, "zonedns", $tables["zonedns"]); case 9: // should be NOT NULL, but this fails on broken databases like PGSQL $sqlarray = $dict->AddColumnSQL("ipaddr", array(array('hname', 'C', '100', 'DEFAULT' => ''))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 10: // don't add column if we did no 6 if ($version >= 9) { // should be NOT NULL, but this fails on broken databases like PGSQL $sqlarray = $dict->AddColumnSQL("fwdzone", array(array('lastmod', 'T', 'DEFAULT' => '', 'Null'))); $sqlarrayt = $dict->DropColumnSQL("fwdzone", array('mod')); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("fwdzonerec", array(array('lastmod', 'T', 'DEFAULT' => '', 'Null'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->DropColumnSQL("fwdzonerec", array('mod')); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("zones", array(array('lastmod', 'T', 'DEFAULT' => '', 'Null'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->DropColumnSQL("zones", array('mod')); $sqlarray = array_merge($sqlarray, $sqlarrayt); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } } case 11: // should be NOT NULL, but this fails on broken databases like PGSQL $sqlarray = $dict->AddColumnSQL("auditlog", array(array('userid', 'C', '40', 'DEFAULT' => ''))); // postgres cannot change a column definition - not my problem!!! if (DBF_TYPE == "postgres7") { if ($display) { $sqlarray[] = "# Postgres cannot change a column definition - I suggest using a database that can"; $sqlarray[] = "# I WILL NOW DROP AND ADD THE COLUMN AGAIN - THIS WILL CAUSE DATA TO BE LOST IN THE AUDITLOG"; $sqlarray[] = "# I CANNOT WRITE THE SQL FOR YOU AS IT DOES NOT EXIST - SORRY!"; } $sqlarrayt = $dict->DropColumnSQL("auditlog", array('action')); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("auditlog", array(array('action', 'C', '254', 'DEFAULT' => ''))); $sqlarray = array_merge($sqlarray, $sqlarrayt); } else { $sqlarrayt = $dict->AlterColumnSQL("auditlog", array(array('action', 'C', '254'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); } if ($version >= 9) { $sqlarrayt = $dict->AddColumnSQL("fwdzone", array(array('userid', 'C', '40', 'DEFAULT' => ''))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("fwdzonerec", array(array('userid', 'C', '40', 'DEFAULT' => ''))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("zones", array(array('userid', 'C', '40', 'DEFAULT' => ''))); $sqlarray = array_merge($sqlarray, $sqlarrayt); } foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 12: // don't add column if we did no 6 if ($version >= 9) { // should be NOT NULL, but this fails on broken databases like PGSQL $sqlarray = $dict->AddColumnSQL("fwdzone", array(array('slaveonly', 'C', '1', 'DEFAULT' => 'N'))); $sqlarrayt = $dict->AddColumnSQL("zones", array(array('slaveonly', 'C', '1', 'DEFAULT' => 'N'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } } case 13: $sqlarray = $dict->AddColumnSQL("ipaddr", array(array('lastpol', 'T'))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 14: DoSQL($ds, $display, "baseadd", $tables["baseadd"]); DoSQL($ds, $display, "custadd", $tables["custadd"]); case 15: $sqlarrayt = $dict->AddColumnSQL("ipaddr", array(array('macaddr', 'C', '12', 'DEFAULT' => ''))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("base", array(array('baseopt', (DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') ? 'INT UNSIGNED' : 'I8', 'DEFAULT' => 0))); $sqlarray = array_merge($sqlarray, $sqlarrayt); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 16: DoSQL($ds, $display, "requestip", $tables["requestip"]); case 17: $sqlarray = $dict->AddColumnSQL("grp", array(array('resaddr', (DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') ? 'SMALLINT UNSIGNED' : 'I4', 'DEFAULT' => 0))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 18: // change table name from schema to version for mysql 5 compat if (DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') { $sqlarray = array("RENAME TABLE `schema` TO `version`"); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } } case 19: DoSQL($ds, $display, "fwdzoneadd", $tables["fwdzoneadd"]); DoSQL($ds, $display, "ipaddrlnk", $tables["ipaddrlnk"]); $sqlarrayt = $dict->AddColumnSQL("customer", array(array('crm', 'C', '20', 'DEFAULT' => ''))); $sqlarray = array_merge($sqlarray, $sqlarrayt); if ($version >= 9) { $sqlarrayt = $dict->AddColumnSQL("fwdzone", array(array('createmod', 'D', 'DEFAULT' => '', 'Null'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("fwdzone", array(array('expiremod', 'D', 'DEFAULT' => '', 'Null'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("fwdzone", array(array('regmod', 'D', 'DEFAULT' => '', 'Null'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("fwdzone", array(array('lastexp', 'T', 'DEFAULT' => '', 'Null'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("zones", array(array('lastexp', 'T', 'DEFAULT' => '', 'Null'))); $sqlarray = array_merge($sqlarray, $sqlarrayt); $sqlarrayt = $dict->AddColumnSQL("zones", array(array('error_message', 'C', '100', 'DEFAULT' => ''))); $sqlarray = array_merge($sqlarray, $sqlarrayt); } $sqlarrayt = $dict->CreateIndexSQL('customer_crm', 'customer', 'crm'); $sqlarray = array_merge($sqlarray, $sqlarrayt); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 20: $sqlarray = $dict->RenameTableSQL("range", "netrange"); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } case 21: $sqlarray = $dict->AddColumnSQL("users", array(array('useremail', 'C', '64', 'DEFAULT' => '', 'Null'))); foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } // end switch } $sqlarray = array(); if (DBF_TRANSACTIONS) { if (DBF_TYPE == "mssql" or DBF_TYPE == "ado_mssql" or DBF_TYPE == "odbc_mssql") { $sqlarray[] = 'BEGIN TRANSACTION'; } else { if (DBF_TYPE == "oci8po") { # do nothing } else { $sqlarray[] = 'BEGIN'; } } } if (DBF_TYPE == "mssql" or DBF_TYPE == "ado_mssql" or DBF_TYPE == "odbc_mssql" or DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') { $sqlarray[] = 'UPDATE version SET version=' . SCHEMA; } else { $sqlarray[] = 'UPDATE schema SET version=' . SCHEMA; } if (DBF_TYPE != "mysql") { $sqlarray[] = 'COMMIT'; } foreach ($sqlarray as $value) { if (!$display) { if (!$ds->Execute($value)) { PrintSQL($value); echo "Failed to execute above statement against database<p>"; echo "<b>" . $ds->ErrorMsg() . "</b>"; exit; } } else { PrintSQL($value); } } }
function ResetQA($seriesid) { $seriesid = mysql_real_escape_string($seriesid); if ((is_numeric($seriesid)) && ($seriesid != "")) { /* delete from the mr_qa table */ $sqlstring = "delete from mr_qa where mrseries_id = $seriesid"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); /* delete from the qc* tables */ $sqlstring = "select qcmoduleseries_id from qc_moduleseries where series_id = $seriesid and modality = 'mr'"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $qcmoduleseriesid = $row['qcmoduleseries_id']; if ($qcmoduleseriesid != "") { $sqlstring = "delete from qc_results where qcmoduleseries_id = $qcmoduleseriesid"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $sqlstring = "delete from qc_moduleseries where qcmoduleseries_id = $qcmoduleseriesid"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); ?><div align="center"><span class="message">QC deleted</span></div><br><br><? } } else { ?><div align="center"><span class="message">Invalid MR series</span></div><br><br><? } }
function AddSubject($lastname, $firstname, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone, $email, $maritalstatus, $smokingstatus, $cancontact, $altuid, $guid) { if ($GLOBALS['debug']) { print "$fullname, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone, $email, $maritalstatus, $smokingstatus, $cancontact, $altuid, $guid"; } /* perform data checks */ $name = mysql_real_escape_string("$lastname^$firstname"); $dob = mysql_real_escape_string($dob); $gender = mysql_real_escape_string($gender); $ethnicity1 = mysql_real_escape_string($ethnicity1); $ethnicity2 = mysql_real_escape_string($ethnicity2); $handedness = mysql_real_escape_string($handedness); $education = mysql_real_escape_string($education); $phone = mysql_real_escape_string($phone); $email = mysql_real_escape_string($email); $maritalstatus = mysql_real_escape_string($maritalstatus); $smokingstatus = mysql_real_escape_string($smokingstatus); $cancontact = mysql_real_escape_string($cancontact); $altuid = mysql_real_escape_string($altuid); $guid = mysql_real_escape_string($guid); $altuids = explode(',',$altuid); # create a new uid do { $uid = NIDB\CreateUID('S',3); $sqlstring = "SELECT * FROM `subjects` WHERE uid = '$uid'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $count = mysql_num_rows($result); } while ($count > 0); # create a new family uid do { $familyuid = NIDB\CreateUID('F'); $sqlstring = "SELECT * FROM `families` WHERE family_uid = '$familyuid'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $count = mysql_num_rows($result); } while ($count > 0); /* insert the new subject */ $sqlstring = "insert into subjects (name, birthdate, gender, ethnicity1, ethnicity2, handedness, education, phone1, email, marital_status, smoking_status, uid, uuid, guid, cancontact) values ('$name', '$dob', '$gender', '$ethnicity1', '$ethnicity2', '$handedness', '$education', '$phone', '$email', '$maritalstatus', '$smokingstatus', '$uid', ucase(md5(concat(RemoveNonAlphaNumericChars('$name'), RemoveNonAlphaNumericChars('$dob'),RemoveNonAlphaNumericChars('$gender')))), '$guid', '$cancontact')"; if ($GLOBALS['debug']) { PrintSQL($sqlstring); } $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $dbid = mysql_insert_id(); # create familyRowID if it doesn't exist $sqlstring2 = "insert into families (family_uid, family_createdate, family_name) values ('$familyuid', now(), 'Proband-$uid')"; if ($GLOBALS['debug']) { PrintSQL($sqlstring2); } $result2 = MySQLQuery($sqlstring2,__FILE__,__LINE__); $familyRowID = mysql_insert_id(); $sqlstring3 = "insert into family_members (family_id, subject_id, fm_createdate) values ($familyRowID, $dbid, now())"; if ($GLOBALS['debug']) { PrintSQL($sqlstring3); } $result3 = MySQLQuery($sqlstring3,__FILE__,__LINE__); //$sqlstring = "select uid from subjects where subject_id = $dbid"; //$result = MySQLQuery($sqlstring, __FILE__, __LINE__); //$row = mysql_fetch_array($result, MYSQL_ASSOC); //$uid = $row['uid']; foreach ($altuids as $altuid) { $altuid = trim($altuid); $sqlstring = "insert ignore into subject_altuid (subject_id, altuid) values ($dbid, '$altuid')"; if ($GLOBALS['debug']) { PrintSQL($sqlstring); } $result = MySQLQuery($sqlstring, __FILE__, __LINE__); } ?><div align="center"><span style="background-color: darkred; color: white"><?php echo $subjectname; ?> added <span class="uid"><?php echo FormatUID($uid); ?> </span></span></div><br><br><? }
function InsertAssessmentForm($f) { /* open the file and check some fields */ $lines = file($f); $parts = str_getcsv($lines[0]); $formtitle = mysql_real_escape_string(trim($parts[0])); $parts = str_getcsv($lines[1]); $formdesc = mysql_real_escape_string(trim($parts[0])); $sqlstring = "insert into assessment_forms (form_title, form_desc, form_creator, form_createdate) values ('$formtitle','$formdesc','" . $GLOBALS['username'] . "',now())"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $assessmentID = mysql_insert_id(); for ($i=2;$i<=count($lines);$i++) { $line = $lines[$i]; $parts = str_getcsv($line); $c = count($parts); /* separate out the columns */ $qnum = mysql_real_escape_string(trim($parts[0])); $question = mysql_real_escape_string(trim($parts[1])); $type = mysql_real_escape_string(trim($parts[2])); if ($c > 3) { $values = mysql_real_escape_string(trim($parts[3])); if ($c > 4) { $comment = mysql_real_escape_string(trim($parts[4])); } } $sqlstring = "insert into assessment_formfields (form_id, formfield_desc, formfield_values, formfield_datatype, formfield_order) values ($assessmentID,'$question','$values','$type','$qnum')"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); } $sqlstring = "update assessment_forms set form_ispublished = 1 where form_id = $assessmentID"; PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); }