Skip to content

Commit

Permalink
Merge pull request #4 from Jkat/Generic_Excel_Dump
Browse files Browse the repository at this point in the history
Making excel dump more generic
  • Loading branch information
Jkat committed Mar 3, 2014
2 parents b6d4ed0 + 2c913ee commit b10ebe7
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions tools/excelDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

//Configuration variables for this script, possibly installation dependent.
//$dataDir = "dataDump" . date("dMy");
$dumpName = "IBISdataDump" . date("dMy"); // label for dump
$dumpName = "dataDump" . date("dMy"); // label for dump
$dataDir = $config['paths']['base'] . "tools/$dumpName/"; //temporary working directory
$destinationDir = $config['paths']['base'] . "htdocs/dataDumps"; //temporary working directory
$destinationDir = $config['paths']['base'] . "htdocs/excel_dumps"; //temporary working directory

/*
* Prepare output directory, if needed.
Expand Down Expand Up @@ -68,7 +68,7 @@ function MapSubprojectID(&$results) {
if($Test_name == 'prefrontal_task') {
$query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, 'See validity_of_data field' as Validity, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
} else if ($Test_name == 'radiology_review') {
$query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, 'Site review:', i.*, 'Final Review:', COALESCE(fr.Review_Done, 0) as Review_Done, fr.Final_Review_Results, fr.Final_Exclusionary, fr.SAS, fr.PVS, fr.Final_Incidental_Findings, fre.full_name as Final_Examiner_Name, fr.Final_Review_Results2, fre2.full_name as Final_Examiner2_Name, fr.Final_Exclusionary2, COALESCE(fr.Review_Done2, 0) as Review_Done2, fr.SAS2, fr.PVS2, fr.Final_Incidental_Findings2, fr.Finalized from candidate c, session s, flag f, $Test_name i left join final_radiological_review fr ON (fr.CommentID=i.CommentID) left outer join examiners e on (i.Examiner = e.examinerID) left join examiners fre ON (fr.Final_Examiner=fre.examinerID) left join examiners fre2 ON (fre2.examinerID=fr.Final_Examiner2) where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
$query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, 'Site review:', i.*, 'Final Review:', COALESCE(fr.Review_Done, 0) as Review_Done, fr.Final_Review_Results, fr.Final_Exclusionary, fr.Final_Incidental_Findings, fre.full_name as Final_Examiner_Name, fr.Final_Review_Results2, fre2.full_name as Final_Examiner2_Name, fr.Final_Exclusionary2, COALESCE(fr.Review_Done2, 0) as Review_Done2, fr.Final_Incidental_Findings2, fr.Finalized from candidate c, session s, flag f, $Test_name i left join final_radiological_review fr ON (fr.CommentID=i.CommentID) left outer join examiners e on (i.Examiner = e.examinerID) left join examiners fre ON (fr.Final_Examiner=fre.examinerID) left join examiners fre2 ON (fre2.examinerID=fr.Final_Examiner2) where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
} else {
if (is_file("../project/instruments/NDB_BVL_Instrument_$Test_name.class.inc")) {
$instrument =& NDB_BVL_Instrument::factory($Test_name, '', false);
Expand All @@ -91,18 +91,6 @@ function MapSubprojectID(&$results) {

} //end foreach instrument

/*
* Special figs_year3_relatives query
*/
$Test_name = "figs_year3_relatives";
$query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, fyr.* from candidate c, session s, flag f, figs_year3_relatives fyr where c.PSCID not like 'dcc%' and fyr.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = fyr.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
$DB->select($query, $instrument_table);
if(PEAR::isError($instrument_table)) {
print "Cannot figs_year3_relatives data ".$instrument_table->getMessage()."<br>\n";
die();
}
MapSubprojectID($instrument_table);
writeExcel($Test_name, $instrument_table, $dataDir);

/*
* Candidate Information query
Expand All @@ -123,7 +111,7 @@ function MapSubprojectID(&$results) {
* Data Dictionary construction
* This relies on the quickform_parser and data_dictionary_builder having being recently run
*/
$Test_name = "IBISDataDictionary";
$Test_name = "DataDictionary";
$query = "select Name, Type, Description, SourceField, SourceFrom from parameter_type where SourceField is not null order by SourceFrom";
$DB->select($query, $dictionary);
if (PEAR::isError($dictionary)) {
Expand Down Expand Up @@ -192,7 +180,6 @@ function writeExcel ($Test_name, $instrument_table, $dataDir) {
$headerFormat->setAlign('center');

// Formatting: Freeze only the first worksheet, at the metaCols and header intersection.
// This is not used to be compatible with figs_year3_relatives and the candidate_info.csv files where there are non-standard numbers of columns
// $worksheet =& $worksheets[0];
// $worksheet->freezePanes(array(1, count($metaCols), 1, count($metaCols))); //change after # of cols are decided.

Expand Down

0 comments on commit b10ebe7

Please sign in to comment.