-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncVUNets.php
More file actions
44 lines (36 loc) · 1.16 KB
/
syncVUNets.php
File metadata and controls
44 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
use \Vanderbilt\CareerDevLibrary\COEUSConnection;
use \Vanderbilt\CareerDevLibrary\Download;
require_once(dirname(__FILE__)."/classes/OracleConnection.php");
require_once(dirname(__FILE__)."/classes/Download.php");
require_once(dirname(__FILE__)."/charts/baseWeb.php");
echo "<h1>Synching VUNets to COEUS</h1>\n";
$allIds = Download::vunets($token, $server);
echo "<p class='centered'>Downloaded ".count($allIds)." vunets from REDCap</p>\n";
try {
$conn = new COEUSConnection();
$conn->connect();
$alreadyInRows = $conn->getCurrentIds();
$alreadyInIds = array();
foreach ($alreadyInRows as $row) {
$id = $row['CAREER_VUNET'];
array_push($alreadyInIds, $id);
}
echo "<p class='centered'>Found ".count($alreadyInIds)." ids in the Oracle database</p>\n";
# filter
$newIds = array();
foreach ($allIds as $recordId => $id) {
if (!in_array($id, $alreadyInIds)) {
array_push($newIds, $id);
}
}
if (count($newIds) > 0) {
echo "<p class='centered'>Inserting new ids ".implode(", ", $newIds)."</p>\n";
$conn->insertNewIds($newIds);
} else {
echo "<p class='centered'>No new ids</p>\n";
}
$conn->close();
} catch(\Exception $e) {
die($e->getMessage());
}