Skip to content

Commit

Permalink
Added support for longitudinal projects
Browse files Browse the repository at this point in the history
  • Loading branch information
steentje34 committed Mar 30, 2023
1 parent cf58dc0 commit 8f5cca4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 21 deletions.
10 changes: 7 additions & 3 deletions DataResolutionDAO.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

namespace uzgent\VerifyClass;

use Logging;

/**
* Description of DataValue
*
Expand All @@ -21,11 +25,11 @@ public function __construct($conn)
$this->conn = $conn;
}

public function fieldHasComments($projectid, $record, $field, $instanceid)
public function fieldHasComments($projectid, $record, $field, $instanceid, $eventid)
{
$sql = "SELECT count(*) as count FROM redcap_data_quality_status WHERE project_id=? AND field_name=? AND instance = ? AND record = ?";
$sql = "SELECT count(*) as count FROM redcap_data_quality_status WHERE project_id=? AND field_name=? AND instance = ? AND record = ? AND event_id=?";
$prepared = mysqli_prepare($this->conn, $sql);
mysqli_stmt_bind_param($prepared, "dsds", $projectid, $field, $instanceid, $record);
mysqli_stmt_bind_param($prepared, "isisi", $projectid, $field, $instanceid, $record, $eventid);
mysqli_stmt_execute($prepared);
mysqli_stmt_bind_result($prepared, $count);
mysqli_stmt_fetch($prepared);
Expand Down
18 changes: 13 additions & 5 deletions MetaDataDAO.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace uzgent\VerifyClass;

/**
* Description of DataValue
*
Expand Down Expand Up @@ -29,15 +31,21 @@ public function __construct($conn)
*/
public function getFieldNames($projectid, $instrument)
{
$sql = "SELECT field_name FROM redcap_metadata WHERE project_id=" . $projectid . " AND form_name='" . $instrument . "'";
$startTreatmentResult = mysqli_query($this->conn, $sql);
$queryResult = mysqli_fetch_assoc($startTreatmentResult);
$sql = "SELECT field_name FROM redcap_metadata WHERE project_id=? AND form_name=?";
$prepared = mysqli_prepare($this->conn, $sql);
mysqli_stmt_bind_param($prepared, "is", $projectid, $instrument);
mysqli_stmt_execute($prepared);
if (mysqli_stmt_error($prepared) != "")
{
throw new Exception("Unable to execute query " . mysqli_stmt_error($prepared) . " $sql");
}
$result = mysqli_stmt_get_result($prepared);
$queryResult = mysqli_fetch_assoc($result);
$names = [];
while ($queryResult !== null) {
$names[] = $queryResult["field_name"];
$queryResult = mysqli_fetch_assoc($startTreatmentResult);
$queryResult = mysqli_fetch_assoc($result);
}
mysqli_free_result($startTreatmentResult);
return $names;
}

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Verify All
This module allows you to verify all fields with one click.
5 changes: 5 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"name": "Lieven Vaneeckhaute",
"email": "redcap@uzgent.be",
"institution": "University Hospital Ghent"
},
{
"name": "Simon Vanderschaeghe",
"email": "redcap@uzgent.be",
"institution": "University Hospital Ghent"
}
],
"documentation" : "howto.html",
Expand Down
52 changes: 39 additions & 13 deletions verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,42 @@
$HtmlPage = new HtmlPage();
$HtmlPage->PrintHeaderExt();

$projectid = $_POST["projectid"];
$record = $_POST["recordid"];
$instrument = $_POST["instrument"];
$eventid = $_POST["eventid"];
$instanceid = $_POST["instanceid"];
$projectid = htmlspecialchars($_POST["projectid"], ENT_QUOTES);
$record = htmlspecialchars($_POST["recordid"], ENT_QUOTES);
$instrument = htmlspecialchars($_POST["instrument"], ENT_QUOTES);
$eventid = htmlspecialchars($_POST["eventid"], ENT_QUOTES);
$instanceid = htmlspecialchars($_POST["instanceid"], ENT_QUOTES);

echo "<h1>Updating for project $projectid on record $record</h1>";

$metadataDao = new MetaDataDAO($conn);
$resolutionDao = new DataResolutionDAO($conn);
echo "<p><a class='btn btn-info' data-toggle='collapse' href='#tableDiv' role='button' aria-expanded='false' aria-controls='tableDiv'>Show details</a></p>";
echo "<div class='collapse' id='tableDiv'>";
echo "<table class='table table-bordered'>";
echo "<tbody>";
echo "<tr>";
echo "<td>project_id</td>";
echo "<td>$projectid</td>";
echo "</tr>";
echo "<tr>";
echo "<td>record</td>";
echo "<td>$record</td>";
echo "</tr>";
echo "<tr>";
echo "<td>event_id</td>";
echo "<td>$eventid</td>";
echo "</tr>";
echo "<tr>";
echo "<td>instrument</td>";
echo "<td>$instrument</td>";
echo "</tr>";
echo "<tr>";
echo "<td>instance</td>";
echo "<td>$instanceid</td>";
echo "</tr>";
echo "</tbody>";
echo "</table>";
echo "</div>";
$metadataDao = new uzgent\VerifyClass\MetaDataDAO($conn);
$resolutionDao = new uzgent\VerifyClass\DataResolutionDAO($conn);

$userInitiator = User::getUserInfo(USERID);
$skipped = [];
Expand All @@ -26,7 +52,7 @@
{
if ($field == "record_id") {
$skipped []= $field;
} else if ($resolutionDao->fieldHasComments($projectid, $record, $field, $instanceid))
} else if ($resolutionDao->fieldHasComments($projectid, $record, $field, $instanceid, $eventid))
{
$skipped []= $field;
} else {
Expand All @@ -37,21 +63,21 @@
}
if (count($verified) > 0)
{
echo "<h2>The following fields have been set to verified: </h2>";
echo "<h3>The following fields have been set to verified: </h3>";
echo "<ul>";
foreach($verified as $verifiedField)
{
echo "<li>$verifiedField</li>";
echo "<li>" . htmlspecialchars($verifiedField, ENT_QUOTES) . "</li>";
}
echo "</ul>";
}
if (count($skipped) > 0)
{
echo "<h2>The following fields have been skipped: </h2>";
echo "<h3>The following fields have been skipped: </h3>";
echo "<ul>";
foreach($skipped as $skippedField)
{
echo "<li>$skippedField</li>";
echo "<li>" . htmlspecialchars($skippedField, ENT_QUOTES) . "</li>";
}
echo "</ul>";
}
Expand Down

0 comments on commit 8f5cca4

Please sign in to comment.