-
Notifications
You must be signed in to change notification settings - Fork 186
[redcap] add functionality to parse decimal options #10096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -313,17 +313,33 @@ class RedcapDictionaryRecord | |
|
|
||
| $choices = explode('|', $dictionary); | ||
| $linstChoices = []; | ||
| $pattern = "/^(\s)*([[:alnum:]]+)(\s)*,(.*)$/"; | ||
| $pattern = "/^(\s)*([[:alnum:]._]+)(\s)*,(.*)$/"; | ||
|
|
||
| $index = 1; //Auto-index counter | ||
| foreach ($choices as $choice) { | ||
| $choice = trim($choice); | ||
| if (empty($choice)) { | ||
| continue; | ||
| } | ||
|
Comment on lines
+321
to
+323
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this case ever happen?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it does because look -- Getting metadata from REDCap connection. -- Parsing records... -- Writing LINST/META files. -> writing 'eeget_session_log'
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By "this case", I mean this |
||
|
|
||
| $matches = []; | ||
|
|
||
| if (preg_match($pattern, $choice, $matches) !== 1) { | ||
| throw new \DomainException( | ||
| "Could not parse radio option: '$choice'" | ||
| // Missing code -auto-generate one | ||
| error_log( | ||
| "Warning: Auto-indexing malformed option: | ||
| '$choice' as index $index" | ||
| ); | ||
|
|
||
| $backend = $index; | ||
| $label = $choice; | ||
| $index++; | ||
| } else { | ||
| //Normal parsing | ||
| $backend = $matches[2]; | ||
| $label = trim($matches[4]); | ||
| } | ||
| $backend = $matches[2]; | ||
| $linstFormat = "'$backend'=>'" . trim($matches[4]) . '\''; | ||
|
|
||
| $linstFormat = "'$backend'=>'$label'"; | ||
| $linstChoices[] = $linstFormat; | ||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamdaudrich @MaximeBICMTL Trying to fully understand this case.
Is this only one radio triggering the issue? If so: the idea to normalize on LORIS is good, but as far as I can tell, both metadata and data come from REDCap, so REDCap is the source of truth.
If all other radio contain indices in their declaration (is it the case?), this one must too, and this normalization must happen in REDCap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what happened here was the index was 0.01 => 0.01 and redcap2linst couldn't handle the 0.01 as the index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at the various tests in which it happened