From fce2cc35c31aea2774ad599b65b2418ea6091d5a Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Sun, 18 Jan 2026 16:25:56 +0000 Subject: [PATCH] bug fixes from testing --- Makefile | 2 +- ...2025-07-10_REDCap_front_end_permission.sql | 4 +-- modules/redcap/.gitignore | 1 + .../models/redcapdictionaryrecord.class.inc | 4 +-- modules/redcap/php/redcapqueries.class.inc | 18 ++++++------- tools/redcap2linst.php | 26 ++++++++++--------- 6 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 modules/redcap/.gitignore diff --git a/Makefile b/Makefile index 61fe245c35a..06d839fcf61 100755 --- a/Makefile +++ b/Makefile @@ -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 \ No newline at end of file + target=redcap npm run compile diff --git a/SQL/New_patches/2025-07-10_REDCap_front_end_permission.sql b/SQL/New_patches/2025-07-10_REDCap_front_end_permission.sql index 1d4534695b5..3761cff8404 100644 --- a/SQL/New_patches/2025-07-10_REDCap_front_end_permission.sql +++ b/SQL/New_patches/2025-07-10_REDCap_front_end_permission.sql @@ -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 @@ -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'; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='All REDCap instrument fields and variables'; diff --git a/modules/redcap/.gitignore b/modules/redcap/.gitignore new file mode 100644 index 00000000000..6a63c9d5138 --- /dev/null +++ b/modules/redcap/.gitignore @@ -0,0 +1 @@ +js/ diff --git a/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc b/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc index d621dfc4a6f..e1df97b7f37 100644 --- a/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc +++ b/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc @@ -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, @@ -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, diff --git a/modules/redcap/php/redcapqueries.class.inc b/modules/redcap/php/redcapqueries.class.inc index 2567fa2004e..71c8932585a 100644 --- a/modules/redcap/php/redcapqueries.class.inc +++ b/modules/redcap/php/redcapqueries.class.inc @@ -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; } @@ -387,7 +387,7 @@ class RedcapQueries $dictionary_entry = $this->_db->pselectRow( "SELECT FieldName, - FormName, + InstrumentName, SectionHeader, FieldType, FieldLabel, @@ -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 ] ); @@ -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 ] ); } diff --git a/tools/redcap2linst.php b/tools/redcap2linst.php index c30f8458125..3b0214ca175 100644 --- a/tools/redcap2linst.php +++ b/tools/redcap2linst.php @@ -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( @@ -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, @@ -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 {