BCCHR-IT / data-entry-trigger-builder

An External Module that provides an interface to create a DET between a source and destination project.
MIT License
2 stars 2 forks source link

Error in External Module #1

Closed iris-y-l closed 3 years ago

iris-y-l commented 3 years ago

Hello, I cannot get this EM to work with non-primary unique field as linkage. Below is an email notification I have received when I test the setup.

I used "email_id" (email validation) as linkage between 2 databases, it's currently on a survey but I saved it as a data entry form when I was doing testing. Only data in one field was asked to sync, the triggers were source form was saved as complete and both email_id and vaccine_status (field requires to be sync) aren't blank. Please let me know if there is any other information needed to fix the bug.

The 'data_entry_trigger_builder' module threw the following exception when calling the hook method 'redcap_save_record':

LogicException: Parser did not consume all tokens! tokenIdx: 1, tokens: Array ( [0] => stdClass Object ( [type] => 29 [value] => email_id )

[1] => stdClass Object ( [type] => 14 [value] => == )

) in /var/www/html/redcap_v10.2.0/Classes/LogicParser.php:152 Stack trace:

0 /var/www/html/redcap_v10.2.0/Classes/Records.php(4493): LogicParser->parse('[email_id] = ', Array)

1 /var/www/html/redcap_v10.2.0/Classes/Records.php(1607): Records::applyFilteringLogic('[email_id] = ', Array, Array, '506')

2 /var/www/html/redcap_v10.2.0/Classes/REDCap.php(301): Records::getData('506', 'json', NULL, 'pernr', '', NULL, false, false, false, '[email_id] = ')

3 /var/www/html/modules/data_entry_trigger_builder_v2.0/DataEntryTriggerBuilder.php(766): REDCap::getData('506', 'json', NULL, 'pernr', '', NULL, false, false, false, '[email_id] = ')

4 [internal function]: BCCHR\DataEntryTriggerBuilder\DataEntryTriggerBuilder->redcap_save_record('125', '447956215542', 'ad', '752', NULL, NULL, NULL, 1)

5 /var/www/html/redcap_v10.2.0/ExternalModules/classes/ExternalModules.php(2698): call_user_func_array(Array, Array)

6 /var/www/html/redcap_v10.2.0/ExternalModules/classes/ExternalModules.php(2845): ExternalModules\ExternalModules::startHook('data_entry_trig...', 'v2.0', Array)

7 /var/www/html/redcap_v10.2.0/ExternalModules/classes/ExternalModules.php(2859): ExternalModules\ExternalModules::ExternalModules{closure}('data_entry_trig...', 'v2.0')

8 /var/www/html/redcap_v10.2.0/Classes/Hooks.php(42): ExternalModules\ExternalModules::callHook('save_record', Array)

9 /var/www/html/redcap_v10.2.0/Classes/DataEntry.php(5233): Hooks::call('redcap_save_rec...', Array)

10 /var/www/html/redcap_v10.2.0/DataEntry/index.php(330): DataEntry::saveRecord('447956215542', true, false, false, NULL, true)

11 {main}

BCCHR-IT commented 3 years ago

Hello, I believe you've encountered a bug when linking on a field that isn't the record ID that has the module searching on an empty value. This has been fixed in our current build, but hasn't been released to the REDCap consortium yet. However, if you'd like to implement the fix locally until then, please check the commits on January 19, 2021 at https://github.com/BCCHR-IT/data-entry-trigger-builder/commits/developer. Both commits should contain the fixes.

BCCHR-IT commented 3 years ago

A fix for this issue has been included in the latest release.

iris-y-l commented 3 years ago

Hi, Sorry to trouble you again. It seems that use email address as non-record-id linkage field isn't working, can this be one of the limitation? I have also tried email address with no period in the recipient name section, but the error message still pop, but with Stopped here: @test.org. Please see below error message:

[This message was automatically generated by REDCap]

The 'data_entry_trigger_builder' module threw the following exception when calling the hook method 'redcap_save_record':

LogicException: Unable to find next token in: [email_id] == test.test@test.org Stopped here: .test@test.org in /var/www/html/redcap_v10.8.2/Classes/LogicLexer.php:271 Stack trace:

0 /var/www/html/redcap_v10.8.2/Classes/LogicParser.php(157): LogicLexer::tokenize()

1 /var/www/html/redcap_v10.8.2/Classes/Records.php(4584): LogicParser->parse()

2 /var/www/html/redcap_v10.8.2/Classes/Records.php(1628): Records::applyFilteringLogic()

3 /var/www/html/redcap_v10.8.2/Classes/REDCap.php(322): Records::getData()

4 /var/www/html/modules/data_entry_trigger_builder_v2.1/DataEntryTriggerBuilder.php(616): REDCap::getData()

5 [internal function]: BCCHR\DataEntryTriggerBuilder\DataEntryTriggerBuilder->redcap_save_record()

6 /var/www/html/redcap_v10.8.2/ExternalModules/classes/ExternalModules.php(2778): call_user_func_array()

7 /var/www/html/redcap_v10.8.2/ExternalModules/classes/ExternalModules.php(2918): ExternalModules\ExternalModules::startHook()

8 /var/www/html/redcap_v10.8.2/ExternalModules/classes/ExternalModules.php(2932): ExternalModules\ExternalModules::ExternalModules{closure}()

9 /var/www/html/redcap_v10.8.2/Classes/Hooks.php(42): ExternalModules\ExternalModules::callHook()

10 /var/www/html/redcap_v10.8.2/Classes/DataEntry.php(5385): Hooks::call()

11 /var/www/html/redcap_v10.8.2/Surveys/index.php(1342): DataEntry::saveRecord()

12 /var/www/html/surveys/index.php(9): include('/var/www/html/r...')

13 {main}

URL: https://redcaptest.petermac.org.au/surveys/index.php?s=HWT388CH4A Server: redcaptest.petermac.org.au (vmts-redcap1.unix.petermac.org.au) User: [survey respondent] Module Name: Data Entry Trigger Builder (data_entry_trigger_builder) Module Author(s): alee2@bcchr.ca Run Time: 0 seconds

Thanks for the help!!

BCCHR-IT commented 3 years ago

Hello, I believe you're caught another bug. To fix this locally, could you go to line 615 in DataEntryTrigger.php and replace it with the following:

$filter_logic = "[$link_dest_field] = '$link_dest_value'";

Let me know if that fixes the issue for you.

BCCHR-IT commented 3 years ago

The suggested fix was tested and implemented in the latest release.