Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,4 @@ dicom_archive: $(filter modules/dicom_archive/%,$(MOFILES)) $(filter modules/dic
target=dicom_archive npm run compile

redcap: $(filter modules/redcap/%,$(MOFILES)) $(filter modules/redcap/%,$(I18NJSONFILES))
target=redcap npm run compile
target=redcap npm run compile
4 changes: 2 additions & 2 deletions SQL/New_patches/2025-07-10_REDCap_front_end_permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ INSERT INTO permissions (code, description, moduleID, categoryID)
INSERT INTO perm_perm_action_rel (permID, actionID)
VALUES (
(SELECT permID FROM permissions WHERE code = 'redcap_ui_view'),
(SELECT ID FROM permisssions_action WHERE name = 'View')
(SELECT ID FROM permissions_action WHERE name = 'View')
);

-- adds the redcap dictionary table
Expand All @@ -35,4 +35,4 @@ CREATE TABLE `redcap_dictionary` (
MatrixRanking varchar(50),
FieldAnnotation text,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='All REDCap instrument fields and variables';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='All REDCap instrument fields and variables';
1 change: 1 addition & 0 deletions modules/redcap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js/
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class RedcapDictionaryRecord
{
return [
'FieldName' => $this->field_name,
'FormName' => $this->form_name,
'InstrumentName' => $this->form_name,
'SectionHeader' => $this->section_header,
'FieldType' => $this->field_type,
'FieldLabel' => $this->field_label,
Expand All @@ -269,7 +269,7 @@ class RedcapDictionaryRecord
'TextValidationMax' => $this->text_validation_max,
'Identifier' => $this->identifier,
'BranchingLogic' => $this->branching_logic,
'FieldRequired' => $this->required_field,
'FieldRequired' => (int) $this->required_field,
'CustomAlignment' => $this->custom_alignment,
'QuestionNumber' => $this->question_number,
'MatrixGroupName' => $this->matrix_group_name,
Expand Down
18 changes: 9 additions & 9 deletions modules/redcap/php/redcapqueries.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ class RedcapQueries
public function instrumentExistsInREDCapDictionary(string $instrument_name): bool
{
$dictionary_entry = $this->_db->pselectOne(
"SELECT DISTINCT FormName
"SELECT DISTINCT InstrumentName
FROM redcap_dictionary
WHERE FormName = :fn
WHERE InstrumentName = :instrument_name
",
["fn" => $instrument_name]
["instrument_name" => $instrument_name]
);
return $dictionary_entry !== null;
}
Expand All @@ -387,7 +387,7 @@ class RedcapQueries
$dictionary_entry = $this->_db->pselectRow(
"SELECT
FieldName,
FormName,
InstrumentName,
SectionHeader,
FieldType,
FieldLabel,
Expand All @@ -405,12 +405,12 @@ class RedcapQueries
MatrixRanking,
FieldAnnotation
FROM redcap_dictionary
WHERE FormName = :form_name
WHERE InstrumentName = :instrument_name
AND FieldName = :field_name
",
[
"form_name" => $form_name,
"field_name" => $field_name
"instrument_name" => $form_name,
"field_name" => $field_name
]
);

Expand Down Expand Up @@ -458,8 +458,8 @@ class RedcapQueries
'redcap_dictionary',
$dictionary_entry->toDatabaseArray(),
[
"FormName" => $dictionary_entry->form_name,
"FieldName" => $dictionary_entry->field_name
"InstrumentName" => $dictionary_entry->form_name,
"FieldName" => $dictionary_entry->field_name
]
);
}
Expand Down
26 changes: 14 additions & 12 deletions tools/redcap2linst.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@
exit(1);
}

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

use LORIS\redcap\client\RedcapHttpClient;
use LORIS\redcap\client\models\RedcapDictionaryRecord;
use LORIS\redcap\client\models\RedcapInstrument;
use LORIS\redcap\config\RedcapConfigParser;
use LORIS\redcap\Queries;
use LORIS\redcap\RedcapQueries;

// options
$opts = getopt(
Expand Down Expand Up @@ -90,21 +86,26 @@
$output_dir = $options['outputDir'];

// back-end name/title instrument mapping
$redcap_intruments_map = ($options['redcapConnection'])->getInstruments(true);
$redcap_intruments_map = ($options['redcapConnection'])->getInstruments();

// write instrument
fwrite(STDOUT, "\n-- Writing LINST/META files.\n\n");
foreach ($instruments as $instrument_name => $fields) {
$instrument = array_find(
$redcap_intruments_map,
fn($instrument) => $instrument->name === $instrument_name
);

writeLINSTFile(
$options['outputDir'],
$redcap_intruments_map[$instrument_name],
$instrument,
$fields
);
}

// update the db redcap_dictionary table per instrument
fwrite(STDOUT, "\n-- Writing entries to database 'redcap_dictionary' table.\n\n");
$queries = new Queries($lorisInstance);
$queries = new RedcapQueries($lorisInstance);
$nbEntriesCount = [
'created' => 0,
'updated' => 0,
Expand Down Expand Up @@ -137,14 +138,15 @@
/**
* Updates the redcap_diciotnary table in db.
*
* @param LORIS\redcap\Queries $queries queries object
* @param string $instrument_name the instrument name to update
* @param RedcapDictionaryRecord[] $redcap_dictionary the redcap dictionary
* @param LORIS\redcap\RedcapQueries $queries queries object
* @param string $instrument_name the instrument name to
* update
* @param RedcapDictionaryRecord[] $redcap_dictionary the redcap dictionary
*
* @return int[] an array of #created and #updated entries for this instrument
*/
function updateREDCapDictionaryInstrumentEntries(
Queries $queries,
RedcapQueries $queries,
string $instrument_name,
array $redcap_dictionary
): array {
Expand Down
Loading