コード例 #1
0
/**
 * Adds the missing instruments based on the visit_label
 *
 * @param Array  $result      containing visit_label info
 * @param String $visit_label The name of the visit
 *
 * @return NULL
 */
function populateVisitLabel($result, $visit_label)
{
    global $argv, $confirm;
    // create a new battery object && new battery
    $battery = new NDB_BVL_Battery();
    // select a specific time point (sessionID) for the battery
    $battery->selectBattery($result['ID']);
    $timePoint = TimePoint::singleton($result['ID']);
    $DB = Database::singleton();
    $candidate = Candidate::singleton($result['CandID']);
    $result_firstVisit = $candidate->getFirstVisit();
    $isFirstVisit = false;
    //adding check for first visit
    if ($result_firstVisit == $visit_label) {
        $isFirstVisit = true;
    }
    //To assign missing instruments to all sessions, sent to DCC or not.
    $defined_battery = $battery->lookupBattery($battery->age, $result['subprojectID'], $timePoint->getCurrentStage(), $visit_label, $timePoint->getCenterID(), $isFirstVisit);
    $actual_battery = $battery->getBattery($timePoint->getCurrentStage(), $result['subprojectID'], $visit_label);
    $diff = array_diff($defined_battery, $actual_battery);
    if (!empty($diff)) {
        echo "\n CandID: " . $timePoint->getCandID() . "  Visit Label:  " . $timePoint->getVisitLabel() . "\nMissing Instruments:\n";
        print_r($diff);
    }
    if ($confirm === true) {
        foreach ($diff as $test_name) {
            $battery->addInstrument($test_name);
        }
    }
    unset($battery);
    unset($timePoint);
}
コード例 #2
0
ファイル: main.php プロジェクト: spaiva/Loris
    }
}
//--------------------------------------------------
// get candidate data
if (!empty($_REQUEST['candID'])) {
    try {
        $candidate =& Candidate::singleton($_REQUEST['candID']);
        $tpl_data['candidate'] = $candidate->getData();
    } catch (Exception $e) {
        $tpl_data['error_message'][] = $e->getMessage();
    }
}
// get time point data
if (!empty($_REQUEST['sessionID'])) {
    try {
        $timePoint =& TimePoint::singleton($_REQUEST['sessionID']);
        if ($config->getSetting("SupplementalSessionStatus")) {
            $tpl_data['SupplementalSessionStatuses'] = true;
        }
        $tpl_data['timePoint'] = $timePoint->getData();
    } catch (Exception $e) {
        $tpl_data['error_message'][] = "TimePoint Error (" . $_REQUEST['sessionID'] . "): " . $e->getMessage();
    }
}
//--------------------------------------------------
// load the menu or instrument
try {
    $caller =& NDB_Caller::singleton();
    $workspace = $caller->load($TestName, $subtest);
    if (isset($caller->page->FormAction)) {
        $tpl_data['FormAction'] = $caller->page->FormAction;
コード例 #3
0
/**
 * returns an array of missing instruments for the timepoint
 *
 * @param  int valid timepoint's sessionID, field session.ID
 * @param  string dateType, type of date to change
 * @param  string date, new date to use to define the battery
 * @return array list of missing instruments
 * @throws PEAR error
 */
function diagnose($sessionID, $dateType = null, $newDate = null)
{
    // check args: sessionID
    if (empty($sessionID)) {
        return PEAR::raiseError("Error, SessionID missing!");
    }
    // check args: dateType and newDate
    if (!empty($dateType) || !empty($newDate)) {
        // check the args
        if (empty($dateType) || !in_array($dateType, array('dob', 'edc', 'screening', 'visit')) || empty($newDate) || in_array($dateType, array('screening', 'visit')) && empty($sessionID)) {
            return PEAR::raiseError("Please pass a valid set of arguments\n");
        }
        // check the date format (redundant)
        $dateArray = explode('-', $newDate);
        if (!is_array($dateArray) || !checkdate($dateArray[1], $dateArray[2], $dateArray[0])) {
            return PEAR::raiseError("Invalid Date! Please use the following format: YYYY-MM-DD \n");
        }
        unset($dateArray);
    }
    // create timepoint object
    $timePoint =& TimePoint::singleton($sessionID);
    if (PEAR::isError($timePoint)) {
        return PEAR::raiseError("Failed to create timepoint object: " . $timePoint->getMessage());
    }
    // candidate object - needed to get the dob/edc
    //    $candidate =& Candidate::singleton($timePoint->getCandID());
    //    if (PEAR::isError($candidate)) {
    //        return PEAR::raiseError("Error, failed to create candidate object:\n".$candidate->getMessage());
    //    }
    // get the statuses and dates of the screening and visit stages to decide what to do w/ each of them
    $stageList['screening']['status'] = $timePoint->getScreeningStatus();
    $stageList['screening']['date'] = $timePoint->getDateOfScreening();
    $stageList['visit']['status'] = $timePoint->getVisitStatus();
    $stageList['visit']['date'] = $timePoint->getDateOfVisit();
    $subProjectID = $timePoint->getSubprojectID();
    // define the date of birth to use (dob or edc)
    if ($dateType == 'dob' && $subProjectID == 1 || $dateType == 'edc' && $subProjectID == 2) {
        $dateBirth = $newDate;
    } else {
        $dateBirth = $timePoint->getEffectiveDateOfBirth();
    }
    // check if the timepoint is started before attempting to make changes to it
    if ($timePoint->getCurrentStage() == 'Not Started' || empty($stageList['screening']['status'])) {
        return PEAR::raiseError("Error: Cannot diagnose the non-started timepoints!");
    }
    // check the subProjectID
    if (empty($subProjectID)) {
        return PEAR::raiseError("SubProjectID ({$subProjectID}) is empty for timepoint ({$sessionID})");
    }
    // initialize the array
    $missingInstruments = array();
    // check/diagnose the battery for each stage
    foreach ($stageList as $stage => $stageData) {
        // if the stage is started
        if (!empty($stageData['status'])) {
            $dateOfStage = !empty($newDate) && strtolower($dateType) == $stage ? $newDate : $stageList[$stage]['date'];
            // compute subject age for the current stage
            $ageArray = Utility::calculateAge($dateBirth, $dateOfStage);
            $age = ($ageArray['year'] * 12 + $ageArray['mon']) * 30 + $ageArray['day'];
            if ($age < 0) {
                $age = 0;
            }
            unset($ageArray);
            fwrite(STDERR, "Age at {$stage}: {$age} [ {$dateBirth} {$dateOfStage}]\n");
            // create battery object
            $battery =& new NDB_BVL_Battery();
            if (PEAR::isError($battery)) {
                return PEAR::raiseError("Failed to create battery object:\n" . $battery->getMessage());
            }
            // set the SessionID for the battery
            $success = $battery->selectBattery($sessionID);
            if (PEAR::isError($success)) {
                return PEAR::raiseError("Error, failed to setup the battery for '{$sessionID}': " . $success->getMessage());
            }
            // get the existing battery for the stage
            $existingTests = $battery->getBattery($stage);
            if (PEAR::isError($existingTests)) {
                return PEAR::raiseError("Error, failed to get the existing battery: " . $existingTests->getMessage());
            }
            // determine the correct list of instruments
            $neededTests = Utility::lookupBattery($age, $stage);
            if (PEAR::isError($neededTests)) {
                return PEAR::raiseError("Error, failed to get the needed battery: " . $neededTests->getMessage());
            }
            // get the differnce between the two batteries
            $difference = array_diff($neededTests, $existingTests);
            // add to array to missing instruments
            $missingInstruments = array_merge($missingInstruments, $difference);
            // unset vars and objects
            unset($battery);
            unset($neededTests);
            unset($existingTests);
            unset($age);
            unset($difference);
        }
    }
    // end foreach
    return $missingInstruments;
}
コード例 #4
0
ファイル: Date.php プロジェクト: rouffj/timemachine
 public function during(Duration $duration)
 {
     $begin = new TimePoint($this->year, $this->month, $this->day, 0, 0);
     $end = $begin->plus($duration);
     return new DateInterval($begin->getDate(), $end->getDate());
 }
コード例 #5
0
ファイル: TimePoint.php プロジェクト: rouffj/timemachine
 public function isEquals(TimePoint $point)
 {
     return $this->date->isEquals($point->getDate()) && $this->time->isEquals($point->getTimeOfDay());
 }
コード例 #6
0
ファイル: Visit.php プロジェクト: frankbiospective/Loris
 /**
  * Create a new timepoint
  *
  * This is a wrapper around the Timepoint::createNew function
  * that can be stubbed out for testing.
  *
  * @param integer $CandID       The candidate with the visit
  * @param integer $subprojectID The subproject for the new visit
  * @param string  $VL           The visit label of the visit to
  *                              be created
  *
  * @return none
  */
 function createNew($CandID, $subprojectID, $VL)
 {
     \TimePoint::createNew($CandID, $subprojectID, $VL);
 }
コード例 #7
0
 /**
  * Compares the TimePoint with another instance.
  * The comparison is made in this order:
  * - reference
  * - target
  * - timestamp
  * - type
  * 
  * CAUTION!: The result order is not based on chronological order. 
  * Its goal is to gather TimePoint by reference and target, then sort by type and timestamp.
  * 
  * @param TimePoint $point
  * @return int
  */
 public function compare(TimePoint $point)
 {
     $diff = strcmp($this->getRef(), $point->getRef());
     if ($diff == 0) {
         $diff = $this->getTarget() - $point->getTarget();
         if ($diff == 0) {
             $diff = $this->getNormalizedTimestamp() - $point->getNormalizedTimestamp();
             if ($diff == 0) {
                 $diff = $this->getType() - $point->getType();
             }
         }
     }
     return $diff;
 }