Skip to content

Commit

Permalink
2.31.1
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjpearson committed Feb 19, 2021
1 parent 79ea682 commit 76c6906
Show file tree
Hide file tree
Showing 22 changed files with 772 additions and 215 deletions.
23 changes: 22 additions & 1 deletion CareerDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CareerDev {
public static $passedModule = NULL;

public static function getVersion() {
return "2.31.0";
return "2.31.1";
}

public static function getLockFile($pid) {
Expand Down Expand Up @@ -555,6 +555,27 @@ public static function isTestGroup($pid) {
return (SERVER_NAME == "redcap.vanderbilt.edu") && in_array($pid, [105963, 101785]);
}

public static function duplicateAllSettings($srcPid, $destPid, $defaultSettings = []) {
if ($srcPid && $destPid) {
self::setPid($srcPid);
$module = self::getModule();
$srcSettings = $module->getProjectSettings($srcPid);
$destSettings = $defaultSettings;
foreach ($srcSettings as $setting => $value) {
if (!$destSettings[$setting] && $value) {
$destSettings[$setting] = $value;
}
}

foreach ($destSettings as $setting => $value) {
self::saveSetting($setting, $value, $destPid);
}
self::log("Copied ".count($destSettings)." settings from $srcPid to $destPid");
} else {
throw new \Exception("Could not find source PID $srcPid or destination PID $destPid");
}
}

public static function getMenu($menuName) {
global $pid;
$r = self::getREDCapDir();
Expand Down
6 changes: 4 additions & 2 deletions FlightTrackerExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ private function copyFormData(&$completes, &$pidsUpdated, $forms, $sourceInfo, $
}

function cron() {
\System::increaseMaxExecTime(14400); // 4 hours
\System::increaseMaxExecTime(28800); // 8 hours

$this->setupApplication();
$pids = $this->framework->getProjectsWithModuleEnabled();
Expand All @@ -555,10 +555,11 @@ function cron() {
$server = $this->getProjectSetting("server", $pid);
$tokenName = $this->getProjectSetting("tokenName", $pid);
$adminEmail = $this->getProjectSetting("admin_email", $pid);
$turnOffSet = $this->getProjectSetting("turn_off", $pid);
$GLOBALS['namesForMatch'] = array();
CareerDev::setPid($pid);
CareerDev::log("Using $tokenName $adminEmail", $pid);
if ($token && $server) {
if ($token && $server && !$turnOffSet) {
# only have token and server in initialized projects
$mgr = new CronManager($token, $server, $pid);
if ($this->getProjectSetting("run_tonight", $pid)) {
Expand All @@ -573,6 +574,7 @@ function cron() {
CareerDev::log($this->getName().": cron run complete for pid $pid", $pid);
}
}
REDCapManagement::cleanupDirectory(APP_PATH_TEMP, "/RePORTER_PRJ/");
}

function setupApplication() {
Expand Down
8 changes: 6 additions & 2 deletions classes/Citation.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,15 @@ public function toHTML($citationClass) {
}

public function hasAuthor($name) {
list($firstName, $lastName) = NameMatcher::splitName($name);
list($firstName, $lastName) = NameMatcher::splitName($name, 2, isset($_GET['test']));
if ($lastName) {
$authorList = $this->getAuthorList();
foreach ($authorList as $author) {
list($currFirstName, $currLastName) = NameMatcher::splitName($author, 2, isset($_GET['test']));
list($currFirstName, $currLastName) = NameMatcher::splitName($author);
if (isset($_GET['test'])) {
Application::log("Comparing $firstName $lastName against $currFirstName $currLastName");
}
if (NameMatcher::matchByInitials($currLastName, $currFirstName, $lastName, $firstName)) {
return TRUE;
}
Expand Down Expand Up @@ -283,7 +287,7 @@ private function isAuthorIdx($pos, $name) {
}
$author = $authorList[$idx];
list($authorFirstName, $authorLastName) = NameMatcher::splitName($author);
if (NameMatcher::matchByInitials($authorFirstName, $authorLastName, $lastName, $firstName)) {
if (NameMatcher::matchByInitials($authorLastName, $authorFirstName, $lastName, $firstName)) {
return TRUE;
}
return FALSE;
Expand Down
4 changes: 4 additions & 0 deletions classes/Cohorts.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public function __construct($token, $server, $moduleOrMetadata) {
$this->configs = $this->getConfigs();
}

public function makeCohortsSelect($defaultCohort, $onchangeJS = "", $displayAllOption = FALSE) {
return $this->makeCohortSelect($defaultCohort, $onchangeJS, $displayAllOption);
}

public function makeCohortSelect($defaultCohort, $onchangeJS = "", $displayAllOption = FALSE) {
$html = "<label for='cohort'>Cohort:</label> <select id='cohort' name='cohort'";
if ($onchangeJS) {
Expand Down
18 changes: 16 additions & 2 deletions classes/Crons.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,23 @@ public function run($adminEmail = "", $tokenName = "", $additionalEmailText = ""
Application::log("Looking in ".$this->getNumberOfCrons()." cron jobs");
$run = [];
$toRun = [];
$makeSummaryCronJob = FALSE;
foreach ($keys as $key) {
if (isset($this->crons[$key])) {
if (isset($this->crons[$key])) {
foreach ($this->crons[$key] as $cronjob) {
$toRun[] = $cronjob;
if ($cronjob->getMethod() == "makeSummary") {
# set as last
$makeSummaryCronJob = $cronjob;
} else {
$toRun[] = $cronjob;
}
}
}
}
if ($makeSummaryCronJob !== FALSE) {
# set as last
$toRun[] = $makeSummaryCronJob;
}

register_shutdown_function(["CronManager", "reportCronErrors"]);

Expand Down Expand Up @@ -240,6 +250,10 @@ public function getTitle() {
return $this->file.": ".$this->method;
}

public function getMethod() {
return $this->method;
}

public function run($passedToken, $passedServer, $passedPid, $records) {
if (!$passedToken || !$passedServer || !$passedPid) {
throw new \Exception("In cronjob at beginning, could not find token '$passedToken' and/or server '$passedServer' and/or pid '$passedPid'");
Expand Down
24 changes: 18 additions & 6 deletions classes/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ public static function formMetadata($token, $server, $forms = array()) {
}

public static function metadata($token, $server, $fields = array()) {
Application::log("Download::metadata");
if (isset($_GET['test'])) {
Application::log("Download::metadata");
}
$data = array(
'token' => $token,
'content' => 'metadata',
Expand Down Expand Up @@ -578,7 +580,9 @@ public static function names($token, $server) {
}

public static function recordIds($token, $server) {
Application::log("Download::recordIds");
if (isset($_GET['test'])) {
Application::log("Download::recordIds");
}
$data = array(
'token' => $token,
'content' => 'record',
Expand All @@ -605,7 +609,9 @@ public static function recordIds($token, $server) {
public static function fieldsWithConfig($token, $server, $metadata, $fields, $cohortConfig) {
$filter = new Filter($token, $server, $metadata);
$records = $filter->getRecords($cohortConfig);
Application::log("Download::fieldsWithFilter ".count($records)." records; ".count($fields)." fields");
if (isset($_GET['test'])) {
Application::log("Download::fieldsWithFilter ".count($records)." records; ".count($fields)." fields");
}
return Download::fieldsForRecords($token, $server, $fields, $records);
}

Expand All @@ -614,7 +620,9 @@ public static function fields($token, $server, $fields) {
Application::log("Error! Download::fields blank ".json_encode(debug_backtrace()));
return [];
}
Application::log("Download::fields ".count($fields)." fields");
if (isset($_GET['test'])) {
Application::log("Download::fields ".count($fields)." fields");
}
$data = array(
'token' => $token,
'content' => 'record',
Expand Down Expand Up @@ -668,7 +676,9 @@ public function downloads_test($tester) {
}

public static function fieldsForRecords($token, $server, $fields, $records) {
Application::log("Download::fieldsForRecords ".count($fields)." fields with ".json_encode($records));
if (isset($_GET['test'])) {
Application::log("Download::fieldsForRecords ".count($fields)." fields with ".json_encode($records));
}
$data = array(
'token' => $token,
'content' => 'record',
Expand All @@ -691,7 +701,9 @@ public static function records($token, $server, $records = NULL) {
# assume recordIds was meant if $records null
return Download::recordIds($token, $server);
}
Application::log("Download::records ".json_encode($records));
if (isset($_GET['test'])) {
Application::log("Download::records ".json_encode($records));
}
$data = array(
'token' => $token,
'content' => 'record',
Expand Down
27 changes: 27 additions & 0 deletions classes/Grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,9 @@ private static function getApplicationType($awardNo) {

public function isFederal() {
$src = $this->getVariable("source");
if ($this->isNIH()) {
return TRUE;
}
if (in_array($src, array("exporter", "reporter"))) {
return TRUE;
} else if ($src == "coeus") {
Expand Down Expand Up @@ -1164,38 +1167,62 @@ public function isFederal() {
"National Institutes of Health/Unknown",
"National Institutes of Health/Office of the Director",
"National Institute on Minority Health and Health Disparities",
"National Institute on Minority Health & Health Disparities",
"National Institute on Drug Abuse",
"National Institute on Deafness and Communication Disorders",
"National Institute on Deafness and Other Communication Disor",
"National Institute on Deafness and Other Communication Disorders",
"National Institute on Alcohol Abuse and Alcoholism",
"National Institute on Alcohol Abuse & Alcoholism",
"National Institute on Aging",
"National Institute of Nursing Research",
"National Institute of Neurological Disorders and Stroke",
"National Institute of Neurological Disorders & Stroke",
"National Institute of Mental Health",
"National Institute of General Medical Sciences",
"National Institute of Environmental Health Sciences",
"National Institute of Diabetes & Digestive & Kidney Disease",
"National Institute of Diabetes and Digestive and Kidney Disease",
"National Institute of Child Health and Human Development",
"National Institute of Child Health & Human Development",
"National Institute of Dental and Craniofacial Research",
"National Institute of Dental & Craniofacial Research",
"National Institute of Biomedical Imaging and Bioengineering",
"National Institute of Biomedical Imaging & Bioengineering",
"National Institute of Arthritis, Musculoskeletal and Skin",
"National Institute of Arthritis and Musculoskeletal and Skin Diseases",
"National Institute of Arthritis & Musculoskeletal & Skin Diseases",
"National Institute of Allergy and Infectious Diseases",
"National Institute of Allergy & Infectious Diseases",
"National Human Genome Research Institute",
"National Heart, Lung, and Blood Institute",
"National Heart, Lung, & Blood Institute",
"National Eye Institute",
"National Center for Research Resources",
"National Center for Complementary and Integrative Health",
"National Center for Complementary & Integrative Health",
"National Center for Advancing Translational Sciences",
"National Cancer Institute",
"NIH Clinical Center",
"Center for Information Technology",
"Center for Scientific Review",
"Fogarty International Center",
"Food and Drug Administration/Other",
"Food and Drug Administration",
"Food & Drug Administration",
"Department of Defense",
"Congressionally Directed Medical Research Programs",
"Centers for Medicare and Medicaid Services",
"Centers for Medicare & Medicaid Services",
"Centers For Disease Control and Prevention (CDC)",
"Centers For Disease Control and Prevention",
"Agency for Healthcare Research and Quality",
"Agency for Healthcare Research & Quality",
"Department of Health and Human Services",
"Department of Health & Human Services",
"NIH National Research Service Award",
"NIH Office of the Director",

];
if (in_array($agency, $federalAgencies) && ($agency != "State of Tennessee")) {
return TRUE;
Expand Down
15 changes: 12 additions & 3 deletions classes/NameMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public static function explodeLastName($last) {
$newNodes = [$last];
$i = 0;
$suffixesInUpper = ["I", "II", "III", "IV", "JR", "JR.", "SR", "SR."];
$prefixesInLower = ["van", "von", "de"];
$prefixesInLower = ["van", "von", "de", "der"];
foreach ($nodes as $node) {
if (in_array(strtoupper($node), $suffixesInUpper) && ($i == 1)) {
return [$nodes[0]." ".$nodes[1]];
Expand All @@ -262,6 +262,9 @@ public static function explodeLastName($last) {
public static function downloadNamesForMatch($token, $server) {
Application::log("Downloading new names for pid ".Application::getPID($token));
self::$namesForMatch = Download::fields($token, $server, array("record_id", "identifier_first_name", "identifier_last_name"));
if (self::$namesForMatch === NULL) {
self::$namesForMatch = [[]];
}
Application::log("Downloaded ".count(self::$namesForMatch)." rows");
self::$currToken = $token;
return self::$namesForMatch;
Expand Down Expand Up @@ -495,8 +498,14 @@ public static function splitName($name, $parts = 2, $loggingOn = FALSE) {
$changed = FALSE;
if ($loggingOn) { echo "In do-while with ".count($nodes)." nodes<br>"; }
if (count($nodes) == $parts) {
if ($loggingOn) { echo "Do-while A<br>"; }
return $nodes;
if (strlen($nodes[1]) <= 2) {
# Initials
if ($loggingOn) { echo "Do-while A Initials<br>"; }
return [$nodes[1], $nodes[0]];
} else {
if ($loggingOn) { echo "Do-while A<br>"; }
return $nodes;
}
} else if ((count($nodes) == 3) && (self::isInitial($nodes[0]) || self::isInitial($nodes[1]))) {
if ($loggingOn) { echo "Do-while B<br>"; }
if ($parts == 2) {
Expand Down
Loading

0 comments on commit 76c6906

Please sign in to comment.