$instruments_q = $DB->pselect("SELECT Test_name FROM test_names", array()); $instruments = array(); foreach ($instruments_q as $row) { if (isset($row['Test_name'])) { $instruments[$row['Test_name']] = $row['Test_name']; } } } else { $instruments = array($instrument => $instrument); } foreach ($instruments as $instrument) { if (isset($instrument)) { include_once $paths['base'] . "project/instruments/NDB_BVL_Instrument_{$instrument}.class.inc"; print "instrument is {$instrument} \n"; //Run the script for all the instruments $commentids = getCommentIDs($instrument, $visit_label); //check to make sure that the commentids are set if (isset($commentids)) { //get the current conflicts $current_conflicts = getCurrentUnresolvedConflicts($instrument, $visit_label); $detected_conflicts = detectConflicts($instrument, $commentids, $current_conflicts); $new_conflicts = getNewConflicts($current_conflicts, $detected_conflicts); $conflicts_to_be_excluded = detectConflictsTobeExcluded($instrument, $commentids, $current_conflicts); /** * Only Create report for the confliclits 1) that should be inserted into the conflicts_unresolved table 2) that should be deleted from the conflicts_unresolved table */ if (!$change && !$change_all) { //just show the conflicts print "This will only display the conflicts needed to\n be inserted \n";
//get all subprojectids $subprojectids = $DB->pselect("SELECT DISTINCT subprojectid FROM session", array()); foreach ($instruments as $instrument => $full_name) { if (isset($instrument) && hasData($instrument)) { print "instrument is {$instrument} \n"; $commentids = array(); foreach ($candidates as $candidate) { $candid = $candidate['CandID']; $pscid = $candidate['PSCID']; foreach ($subprojectids as $subprojectid) { $session_info = $DB->pselectRow("SELECT DISTINCT s.Visit_label,s.ID from session s\n JOIN candidate c on (c.candid=s.candid)\n JOIN flag f on (f.sessionid=s.id)\n WHERE s.candID = :cid AND f.test_name = :fname AND\n s.subprojectid = :subid", array('cid' => $candid, 'fname' => $instrument, 'subid' => $subprojectid['subprojectid'])); if ($session_info != null && !empty($session_info)) { $sessionid = $session_info['ID']; $visit_label = $session_info['Visit_label']; if ($sessionid != null) { $commentid = getCommentIDs($instrument, $visit_label, $sessionid, $candid, $pscid, $subprojectid['subprojectid']); $size = sizeof($commentid); if ($size >= 2) { $commentids[] = $commentid; } } } } } if (empty($commentids)) { print "No duplicated Data detected for {$instrument} \n"; } writeCSV($commentids, $dataDir, $instrument, "detect_duplicated_commentids"); } } /**