Skip to content

Commit

Permalink
Made the issue query return the group id and more closely match what …
Browse files Browse the repository at this point in the history
…REDCap displays
  • Loading branch information
mmcev106 committed Mar 7, 2019
1 parent a09d8dc commit 560b3e6
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions export.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,24 @@
}

## Get list of status IDs associated with this project/record(s)
$sql1 = "SELECT s.*
FROM redcap_data_quality_status s
WHERE s.project_id = ".$project_id.$recordSql.$userSql.$statusSql;
$sql1 = "
SELECT s.*, g.value as group_id
FROM redcap_data_quality_status s
-- join to metadata to exclude fields that no longer exist (like REDCap does programmatically)
JOIN redcap_metadata m
ON m.project_id = $project_id
AND s.field_name = m.field_name
-- this joins one row per event & instance, requiring the GROUP BY below
LEFT JOIN redcap_data g
ON s.record = g.record
AND g.project_id = $project_id
AND g.field_name = '__GROUPID__'
WHERE s.project_id = ".$project_id.$recordSql.$userSql.$statusSql."
GROUP BY status_id
";

$q = db_query($sql1);

Expand Down

0 comments on commit 560b3e6

Please sign in to comment.