Skip to content

Commit

Permalink
Merge branch 'release/2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pbchase committed Jan 7, 2020
2 parents 46df577 + 3538f24 commit f042595
Show file tree
Hide file tree
Showing 6 changed files with 412 additions and 59 deletions.
5 changes: 5 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# AUTHORS

The Auto-Populate Fields module would not be possible without the generous contributions of code, testing, and ideas from the CTS-IT developers, the REDCap Team, and Mike Conlon, Ph.D. We would also like to acknowledge the generous support of Dr. Carl J Pepine's WARRIOR project.

We specifically want to thank our developers Tiago Bember [email protected], Marly Cormar [email protected], Dileep Rajput [email protected], Surya Prasanna [email protected], Prasad Lanka [email protected], Stewart Wehmeyer [email protected], Kyle Chesney [email protected], and Philip Chase [email protected] for their contributions to the project. Taryn Stoffs [email protected] and Jerri Johnston [email protected] provided valuable input into the design and testing of the Auto-Populate Fields module.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
# Change Log
All notable changes to the Auto-Populate Fields project will be documented in this file.


## [2.5.0] - 2020-01-07
### Added
- Add Zenodo doi to README.md (Kyle Chesney)
- Update queries of redcap_log_event tables to support REDCap >= 9.6.0 (Kyle Chesney)
- Add text_project.xml (Philip Chase)
- Add discussion of temporal order and null auto-population in README (Kyle Chesney)
- Create authors.md (Philip Chase)

### Changed
- Fix crashing on mismatched Date formats (Kyle Chesney)
- Update authors in config.json (Philip Chase)

### Removed
- Remove setting project_id as an index in redcap_log_event table project_id is already a composite index (Kyle Chesney)


## [2.4.0] - 2019-10-20
### Added
- Auto populate date fields in the same format they were entered. (Kyle Chesney)
Expand Down
29 changes: 6 additions & 23 deletions ExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,6 @@ function redcap_every_page_top($project_id) {
}
}

/**
* @inheritdoc
*/
function redcap_module_system_enable($version) {
$sql = 'SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS WHERE `table_schema` = DATABASE() AND `table_name` = "redcap_log_event" AND `index_name` = "project_id"';

// Indexing redcap_log_event's project_id column for performance
// reasons.
// TODO: check user priviliges, send message reminding of requirements and disable if not able to alter db
if (($q = $this->query($sql)) && !db_num_rows($q)) {
$this->query('ALTER TABLE `redcap_log_event` ADD INDEX `project_id` (`project_id`)');
}
}

/**
* @inheritdoc
*/
function redcap_module_system_version_change($version, $old_version) {
$this->redcap_module_system_enable($version);
}

/**
* Extends @DEFAULT action tag.
*
Expand Down Expand Up @@ -110,8 +89,10 @@ function setDefaultValues() {
// Getting chronological sequence of events.
$events = array();

$log_event_table = method_exists('\REDCap', 'getLogEventTable') ? \REDCap::getLogEventTable($project_id) : "redcap_log_event";

$sql = '
SELECT MIN(log_event_id), event_id FROM redcap_log_event
SELECT MIN(log_event_id), event_id FROM ' . $log_event_table . '
WHERE pk = "' . db_real_escape_string($_GET['id']) . '" AND
project_id = "' . db_real_escape_string($Proj->project_id) . '"
GROUP BY event_id
Expand Down Expand Up @@ -238,7 +219,9 @@ function setDefaultValues() {
}
if ($in_format !== 'ymd') {
$date = \DateTime::createFromFormat($in_format, $default_value);
$default_value = $date->format($out_format);
// This ternary prevents crashing for mixed source and target formats (e.g. YMD -> DMY)
// users will get validation errors
$default_value = ($date) ? $date->format($out_format) : $default_value;
}
}

Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# REDCap Auto-Populate Fields

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3561117.svg)](https://doi.org/10.5281/zenodo.3561117)

This REDCap module provides rich control of default values for data entry fields via a set of action tags. These action tags allow fields to be populated based on values from an ordered list of fields and static values. The fields can be read from the current event or the previous event in longitudinal projects.

## Prerequisites
Expand All @@ -9,9 +12,6 @@ This REDCap module provides rich control of default values for data entry fields
- Go to **Control Center > Manage External Modules** and enable Auto Populate Fields.
- For each project you want to use this module, go to the project home page, click on **Manage External Modules** link, and then enable Auto Populate Fields for that project.

## Requirements
This module **must** be _enabled_ by a user with alter-table privileges, it will fail to be enabled otherwise.

## Features included

### Default when visible
Expand Down Expand Up @@ -44,7 +44,7 @@ If your events are not necessarily arranged in a chronological order, you can en

### Mixing @DEFAULT_\<N\> and @DEFAULT-FROM-PREVIOUS-EVENT_\<N\>

When using `@DEFAULT_<N>` and `@DEFAULT-FROM-PREVIOUS-EVENT_<N>` together, using unique numbers on each action tag to ensure the desired precendence. E.g.
When using `@DEFAULT_<N>` and `@DEFAULT-FROM-PREVIOUS-EVENT_<N>` together, using unique numbers on each action tag to ensure the desired precedence. E.g.

@DEFAULT-FROM-PREVIOUS-EVENT_1='initial_dose'
@DEFAULT-FROM-PREVIOUS-EVENT_2=intermediate_dose
Expand All @@ -57,3 +57,14 @@ Note that `@DEFAULT` is synonymous with `@DEFAULT_0`. Similarly `@DEFAULT-FROM-

Note that the square brackets, `[]` common to REDCap piping are neither required nor supported in `@DEFAULT-FROM-PREVIOUS-EVENT` and `@DEFAULT-FROM-PREVIOUS-EVENT_<N>`. They _are_ required in `@DEFAULT_<N>` just like `@DEFAULT`.

## Considerations

Please note that when using **Enable chronological previous event detection**, deleting data from a form might change the expected behavior of auto-population.

Though the data is erased, the null value written to the record is still a legitimate value that could be copied to next event filled in. This will only occur in new data entry if the last event in the sequence was deleted. Note that "sequence" here refers to chronological order.

For example, if data is keyed into the _wrong_ event and deleted, the data will not auto-populate when the correct event is opened. That said, if you open the correct event _before_ deleting the data from the wrong event, the data keyed into the wrong event will auto-populate into the correct event.

## Example

An example project that demonstrates some of the features of this module is available in the [examples](examples/) folder.
34 changes: 2 additions & 32 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,9 @@
"institution": "University of Florida - CTSI"
},
{
"name": "Surya Prasanna",
"email": "suryayalla@ufl.edu",
"name": "Kyle Chesney",
"email": "kyle.chesney@ufl.edu",
"institution": "University of Florida - CTSI"
},
{
"name": "Prasad Lanka",
"email": "[email protected]",
"institution": "University of Florida - CTSI"
},
{
"name": "Dileep Rajput",
"email": "[email protected]",
"institution": "University of Florida - CTSI"
},
{
"name": "Stewart Wehmeyer",
"email": "[email protected]",
"institution": "University of Florida - CTSI"
},
{
"name": "Tiago Bember",
"email": "[email protected]",
"institution": "University of Florida - CTSI"
},
{
"name": "Mike Conlon, Ph.D.",
"email": "[email protected]",
"institution": "University of Florida"
},
{
"name": "Carl J Pepine, M.D., MACC",
"email": "",
"institution": "University of Florida"
}
],
"project-settings": [
Expand Down
Loading

0 comments on commit f042595

Please sign in to comment.