Skip to content

Commit

Permalink
5.12.9
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjpearson committed Aug 11, 2023
1 parent 367e7e8 commit cbc8158
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 969 deletions.
2 changes: 1 addition & 1 deletion CareerDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CareerDev {
public static $passedModule = NULL;

public static function getVersion() {
return "5.12.8";
return "5.12.9";
}

public static function getLockFile($pid) {
Expand Down
1 change: 0 additions & 1 deletion addNewScholar.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
$uploadRow[$field] = REDCapManagement::sanitize($_POST[$field]);
}
$feedback = Upload::oneRow($uploadRow, $token, $server);
\Vanderbilt\FlightTrackerExternalModule\queueUpInitialEmail($recordId);
Application::refreshRecordSummary($token, $server, $pid, $recordId);
if ($feedback['error']) {
echo "<div class='red padded'>ERROR! " . $feedback['error'] . "</div>\n";
Expand Down
29 changes: 15 additions & 14 deletions charts/timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
echo "<p style='text-align: center;'><a href='$timelineLink&record=$nextRecord&next'>Next Record</a></p>\n";
}

$suffix = $pid."_".time();
foreach ($classes as $c) {
$divHeader = "";
$divFooter = "";
Expand Down Expand Up @@ -189,8 +190,8 @@
echo implode("<td>&nbsp;</td>", $cells);
echo "</tr></tbody></table>";
}
echo "<div id='visualization{$pid}_$c' class='visualization'></div>";
echo "<div class='alignright'><button onclick='html2canvas(document.getElementById(\"visualization{$pid}_$c\"), { onrendered: (canvas) => { downloadCanvas(canvas, \"timeline.png\"); } }); return false;' class='smallest'>Save</button></div>";
echo "<div id='visualization{$suffix}_$c' class='visualization'></div>";
echo "<div class='alignright'><button onclick='html2canvas(document.getElementById(\"visualization{$suffix}_$c\"), { onrendered: (canvas) => { downloadCanvas(canvas, \"timeline.png\"); } }); return false;' class='smallest'>Save</button></div>";
echo $divFooter;
}

Expand All @@ -206,10 +207,10 @@ function runTimeoutToTurnOffEvents(el) {
}, 2000);
}

const container_<?= $pid ?> = {};
const items_<?= $pid ?> = {};
const options_<?= $pid ?> = {};
const timeline_<?= $pid ?> = {};
const container_<?= $suffix ?> = {};
const items_<?= $suffix ?> = {};
const options_<?= $suffix ?> = {};
const timeline_<?= $suffix ?> = {};
$(document).ready(() => {
<?php
foreach ($classes as $c) {
Expand All @@ -218,11 +219,11 @@ function runTimeoutToTurnOffEvents(el) {
$endDate = json_encode(date("Y-m-d", (int) $maxTs[$c]));

echo "
container_".$pid."['$c'] = document.getElementById('visualization".$pid."_$c');
items_".$pid."['$c'] = new vis.DataSet($dataset);
options_".$pid."['$c'] = { start: $startDate, end: $endDate };
container_".$suffix."['$c'] = document.getElementById('visualization".$suffix."_$c');
items_".$suffix."['$c'] = new vis.DataSet($dataset);
options_".$suffix."['$c'] = { start: $startDate, end: $endDate };
";
echo getJSToLaunchTimeline($pid, $c)."\n";
echo getJSToLaunchTimeline($suffix, $c)."\n";
}
?>
});
Expand Down Expand Up @@ -440,10 +441,10 @@ function makePubDots($rows, $token, $server, &$id, &$minTs, &$maxTs) {
return $grantsAndPubs;
}

function getJSToLaunchTimeline($pid, $c) {
function getJSToLaunchTimeline($suffix, $c) {
$lines = [];
$lines[] = "timeline_".$pid."[\"$c\"] = new vis.Timeline(container_".$pid."[\"$c\"], items_".$pid."[\"$c\"], options_".$pid."[\"$c\"]);";
$lines[] = "$(timeline_".$pid."[\"$c\"]).unbind(\"mousewheel\");";
$lines[] = "runTimeoutToTurnOffEvents(container_".$pid."[\"$c\"]);";
$lines[] = "timeline_".$suffix."[\"$c\"] = new vis.Timeline(container_".$suffix."[\"$c\"], items_".$suffix."[\"$c\"], options_".$suffix."[\"$c\"]);";
$lines[] = "$(timeline_".$suffix."[\"$c\"]).unbind(\"mousewheel\");";
$lines[] = "runTimeoutToTurnOffEvents(container_".$suffix."[\"$c\"]);";
return implode("", $lines);
}
11 changes: 6 additions & 5 deletions charts/vis.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions classes/DateManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public static function REDCapTsToPHPTs($redcapTs) {
return strtotime("$year-$month-$day");
}

public static function PHPTsToREDCapTs($phpTs) {
return date("YmdHis", $phpTs);
}

public static function getLatestDate($dates) {
$latestTs = 0;
$latestDate = "";
Expand Down
3 changes: 3 additions & 0 deletions classes/ERIC.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public static function process($docs, $metadata, $recordId, $listOfPriorIds, $li
$prefix."last_update" => date("Y-m-d"),
$prefix."link" => "https://eric.ed.gov/?id=$id",
];
if (in_array($prefix."created", $ericFields)) {
$uploadRow[$prefix."created"] = date("Y-m-d");
}
$hasData = FALSE;
foreach ($ericFields as $ericField) {
$value = $entry[$ericField] ?? "";
Expand Down
4 changes: 4 additions & 0 deletions classes/Grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,10 @@ private function getCurrentType()
if (self::getShowDebug()) { Application::log($awardNo.": pi_flag is N"); }
return "N/A";
}
if (isset($specs['type']) && ($specs['type'] !== "")) {
if (self::getShowDebug()) { Application::log($awardNo.": preset type ".$specs['type']); }
return $specs['type'];
}

if (self::getShowDebug()) { Application::log($awardNo.": First Pass"); }
if ($type = $this->lexicallyTranslate($awardNo)) {
Expand Down
7 changes: 6 additions & 1 deletion classes/Grants.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class Grants {
const FLAGGED_GRANTS_SETTING = "flagged_grants";
const SPREADSHEET_SOURCES = ["data", "sheet2", "new2017", ];

public function __construct($token, $server, $metadata = []) {
$this->token = $token;
Expand Down Expand Up @@ -1562,7 +1563,11 @@ private static function combineGrants($grants) {

$currEndTs = strtotime($currGrant->getVariable("end"));
$grantEndTs = strtotime($basisGrant->getVariable("end"));
if ($currEndTs > $grantEndTs) {
if (in_array($basisGrant->getVariable("source"), self::SPREADSHEET_SOURCES)) {
$basisGrant->setVariable("end", self::makeDate($currEndTs));
} else if (in_array($currGrant->getVariable("source"), self::SPREADSHEET_SOURCES)) {
$basisGrant->setVariable("end", self::makeDate($grantEndTs));
} else if ($currEndTs > $grantEndTs) {
$basisGrant->setVariable("end", self::makeDate($currEndTs));
}

Expand Down
3 changes: 3 additions & 0 deletions classes/PatentsView.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public function patents2REDCap($patents, $maxInstance) {
$row['patent_assignees'] = implode(", ", $assignees["names"]);
$row['patent_assignee_ids'] = implode(", ", $assignees["ids"]);
$row['patent_last_update'] = date("Y-m-d");
if (in_array("patent_created", $metadataFields)) {
$row['patent_created'] = date("Y-m-d");
}
$row['patent_complete'] = "2";
$rows[] = $row;
}
Expand Down
3 changes: 3 additions & 0 deletions classes/Publications.php
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,9 @@ private static function xml2REDCap($xml, $recordId, &$instance, $src, $confirmed
if (in_array("citation_last_update", $metadataFields)) {
$row["citation_last_update"] = date("Y-m-d");
}
if (in_array("citation_created", $metadataFields)) {
$row["citation_created"] = date("Y-m-d");
}
if (in_array("citation_flagged", $metadataFields)) {
$row["citation_flagged"] = "";
}
Expand Down
4 changes: 4 additions & 0 deletions classes/RePORTER.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ private function getNIHUploadRows(&$max, &$existingGrants) {
$dateFields = ["project_start_date", "project_end_date", "init_encumbrance_date", "award_notice_date",];
$skip = ["spending_categories", "organization_type", ];
$upload = [];
$metadataFields = Download::metadataFieldsByPid($this->pid);

foreach ($this->getData() as $item) {
if (!in_array($item['project_num'], $existingGrants)) {
Expand All @@ -295,6 +296,9 @@ private function getNIHUploadRows(&$max, &$existingGrants) {
"nih_reporter_complete" => "2",
"nih_last_update" => date("Y-m-d"),
];
if (in_array("nih_created", $metadataFields)) {
$uploadRow["nih_created"] = date("Y-m-d");
}
foreach ($item as $key => $value) {
if (!in_array($key, $skip)) {
$newField = "nih_" . strtolower($key);
Expand Down
14 changes: 11 additions & 3 deletions drivers/19_updateNewCoeus.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,23 @@ function updateCoeusGeneric($token, $server, $pid, $records, $instrument, $award
Application::log("Record $recordId has ".count($matchedData)." matches for $instrument", $pid);
$uniqueFields = [];
$timestampField = "";
$dateCreatedField = "";
if ($instrument == "coeus") {
$uniqueFields[] = "coeus_award_no";
$uniqueFields[] = "coeus_award_seq";
$timestampField = "coeus_update_timestamp";
$dateCreatedField = "coeus_created";
} else if ($instrument == "coeus_submission") {
$uniqueFields[] = "coeussubmission_ip_number";
$uniqueFields[] = "coeussubmission_ip_seq";
$timestampField = "coeussubmission_update_timestamp";
$dateCreatedField = "coeussubmission_created";
} else {
Application::log("No unique fields set => automatically including.", $pid);
}
$timestampFields = $timestampField ? [$timestampField] : [];
$redcapData = Download::fieldsForRecords($token, $server, array_merge(["record_id"], $uniqueFields, $timestampFields), [$recordId]);
$dateCreateds = $dateCreatedField ? Download::oneFieldWithInstances($token, $server, $dateCreatedField) : [];
$maxInstance = REDCapManagement::getMaxInstance($redcapData, $instrument, $recordId);
$uniqueValues = [];
foreach ($uniqueFields as $uniqueField) {
Expand Down Expand Up @@ -171,13 +175,13 @@ function updateCoeusGeneric($token, $server, $pid, $records, $instrument, $award
)
&& !in_array($instance, $uploadInstances)
) {
$upload[] = makeUploadRowForCOEUS($dataRow, $recordId, $instrument, $instance, $prefix, $metadataFields);
$upload[] = makeUploadRowForCOEUS($dataRow, $recordId, $instrument, $instance, $prefix, $metadataFields, $dateCreateds);
}
}
}
} else {
$maxInstance++;
$upload[] = makeUploadRowForCOEUS($dataRow, $recordId, $instrument, $maxInstance, $prefix, $metadataFields);
$upload[] = makeUploadRowForCOEUS($dataRow, $recordId, $instrument, $maxInstance, $prefix, $metadataFields, $dateCreateds);
}
}
if (!empty($upload)) {
Expand Down Expand Up @@ -250,14 +254,18 @@ function dedupCOEUS($token, $server, $pid, $recordId, $instrument, $prefix, $uni
}
}

function makeUploadRowForCOEUS($dataRow, $recordId, $instrument, $instance, $prefix, $metadataFields) {
function makeUploadRowForCOEUS($dataRow, $recordId, $instrument, $instance, $prefix, $metadataFields, $dateCreateds) {
$uploadRow = [
"record_id" => $recordId,
"redcap_repeat_instrument" => $instrument,
"redcap_repeat_instance" => $instance,
$prefix."last_update" => date("Y-m-d"),
$instrument."_complete" => "2",
];
$dateCreated = $dateCreateds[$recordId][$instance] ?? "";
if (!$dateCreated) {
$uploadRow[$prefix."created"] = date("Y-m-d");
}
foreach ($dataRow as $dataField => $value) {
if ($value) {
$field = $prefix.strtolower($dataField);
Expand Down
4 changes: 4 additions & 0 deletions drivers/20_nsf.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ function transformIntoREDCap($recordMatches, $token, $server) {

$errors = [];
$totalAwards = 0;
$metadataFields = Download::metadataFields($token, $server);
foreach ($recordMatches as $recordId => $awards) {
if (!empty($awards)) {
$totalAwards += count($awards);
Expand All @@ -198,6 +199,9 @@ function transformIntoREDCap($recordMatches, $token, $server) {
"nsf_last_update" => date("Y-m-d"),
$instrument."_complete" => "2",
];
if (in_array("nsf_created", $metadataFields)) {
$uploadRow["nsf_created"] = date("Y-m-d");
}
foreach ($fields as $field) {
if (!isset($award[$field])) {
continue;
Expand Down
3 changes: 3 additions & 0 deletions drivers/24_getIES.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ function matchNamesWithExcel($excelData, $token, $server, $pid) {
"redcap_repeat_instance" => $maxInstance[$recordId] + 1,
"ies_grant_complete" => "2",
];
if (in_array("ies_created", $metadataFields)) {
$uploadRow["ies_created"] = date("Y-m-d");
}
$originalCount = count($uploadRow);
makeREDCapForIES($uploadRow, $spreadsheet->getActiveSheet(), $headerRow, $rowNum, $prefix, $metadataFields);
if (
Expand Down
24 changes: 19 additions & 5 deletions drivers/25_emailHighlights.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ function sendEmailHighlights($token, $server, $pid, $records, $allPids = FALSE)
$pmidsIdentified = [];
$pidsCitationRecordsAndInstances = [];
$pidsGrantRecordsAndInstances = [];
$fields = ["record_id", "citation_authors", "citation_pmid", "citation_ts", "citation_include", "citation_rcr", "citation_altmetric_score", "coeus_last_update", "nih_last_update", "vera_last_update"];
$fields = ["record_id", "citation_authors", "citation_pmid", "citation_ts", "citation_include", "citation_rcr", "citation_altmetric_score",];
$grantInstrumentsAndPrefices = [
"nih_reporter" => "nih",
"nsf" => "nsf",
"coeus" => "coeus",
"vera" => "vera",
"custom_grant" => "custom",
"ies_grant" => "ies",
];
foreach(array_values($grantInstrumentsAndPrefices) as $prefix) {
$fields[] = $prefix."_last_update";
$fields[] = $prefix."_created";
}
$fields = array_unique($fields);
$names = [];
$emails = [];
$allMetadata = [];
Expand Down Expand Up @@ -142,9 +148,17 @@ function sendEmailHighlights($token, $server, $pid, $records, $allPids = FALSE)
$prefix = $grantInstrumentsAndPrefices[$instrument];
$instance = $row['redcap_repeat_instance'];
$lastUpdate = $row[$prefix.'_last_update'];
$dateCreated = $row[$prefix.'_created'] ?? "";
if (
$lastUpdate
&& (strtotime($lastUpdate) > $warningTs)
(
$dateCreated
&& (strtotime($dateCreated) > $warningTs)
)
|| (
!$dateCreated
&& $lastUpdate
&& (strtotime($lastUpdate) > $warningTs)
)
) {
enrollNewInstance($pidsGrantRecordsAndInstances, $currPid, $recordId, $instance, $instrument);
}
Expand Down Expand Up @@ -294,7 +308,7 @@ function sendEmailHighlights($token, $server, $pid, $records, $allPids = FALSE)
for ($i = 0; $i < count($requestedGrants); $i++) {
$requestedGrants[$i] = Grant::translateToBaseAwardNumber($requestedGrants[$i]);
}
$htmlRows = ["<h2>Publications After $thresholdDate</h2>"];
$htmlRows = ["<h2>All Publications After $thresholdDate</h2>"];
$performanceRows = ["<h2>Publications With Newly Altmetric &gt; " . Altmetric::THRESHOLD_SCORE . " or RCR &gt; " . iCite::THRESHOLD_SCORE . "</h2>"];
$publicationPids = array_unique(array_merge(array_keys($scholarsIdentified), array_keys($pidsCitationRecordsAndInstances)));
if (!empty($publicationPids)) {
Expand Down Expand Up @@ -705,4 +719,4 @@ function filterForInstitution(&$records, $token, $server, $pid, $metadata) {
}
}
$records = $filteredRecords;
}
}
Loading

0 comments on commit cbc8158

Please sign in to comment.