From 8f5cca40166f618845e3ca2bafbf223f95a8b0e5 Mon Sep 17 00:00:00 2001 From: steentje34 Date: Thu, 30 Mar 2023 11:40:52 +0200 Subject: [PATCH] Added support for longitudinal projects --- DataResolutionDAO.php | 10 ++++++--- MetaDataDAO.php | 18 ++++++++++----- README.md | 2 ++ config.json | 5 +++++ verify.php | 52 ++++++++++++++++++++++++++++++++----------- 5 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 README.md diff --git a/DataResolutionDAO.php b/DataResolutionDAO.php index 2c99767..e2fcf8f 100644 --- a/DataResolutionDAO.php +++ b/DataResolutionDAO.php @@ -1,5 +1,9 @@ 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); diff --git a/MetaDataDAO.php b/MetaDataDAO.php index 19e096d..e6c98e7 100644 --- a/MetaDataDAO.php +++ b/MetaDataDAO.php @@ -1,5 +1,7 @@ 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; } diff --git a/README.md b/README.md new file mode 100644 index 0000000..faee486 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Verify All +This module allows you to verify all fields with one click. diff --git a/config.json b/config.json index 08ce927..3068424 100644 --- a/config.json +++ b/config.json @@ -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", diff --git a/verify.php b/verify.php index 8293ba7..a4e7b94 100644 --- a/verify.php +++ b/verify.php @@ -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 "

Updating for project $projectid on record $record

"; - -$metadataDao = new MetaDataDAO($conn); -$resolutionDao = new DataResolutionDAO($conn); +echo "

"; +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
project_id$projectid
record$record
event_id$eventid
instrument$instrument
instance$instanceid
"; +echo "
"; +$metadataDao = new uzgent\VerifyClass\MetaDataDAO($conn); +$resolutionDao = new uzgent\VerifyClass\DataResolutionDAO($conn); $userInitiator = User::getUserInfo(USERID); $skipped = []; @@ -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 { @@ -37,21 +63,21 @@ } if (count($verified) > 0) { - echo "

The following fields have been set to verified:

"; + echo "

The following fields have been set to verified:

"; echo ""; } if (count($skipped) > 0) { - echo "

The following fields have been skipped:

"; + echo "

The following fields have been skipped:

"; echo ""; }