This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
177 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*.pyc | ||
*.pyo | ||
*.egg-info/ | ||
.coveralls.yml | ||
config-example/vagrant-data/redcap.zip | ||
formData.xml | ||
rawData.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# add post-processing rules here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python | ||
|
||
# Contributors: | ||
# Nicholas Rejack <[email protected]> | ||
# Kevin Hanson <[email protected]> | ||
# Copyright (c) 2014-2015, University of Florida | ||
# All rights reserved. | ||
# | ||
# Distributed under the BSD 3-Clause License | ||
# For full text of the BSD 3-Clause License see http://opensource.org/licenses/BSD-3-Clause | ||
|
||
# preprocessing rules go here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
# Taeber Rapczak <[email protected]> | ||
# Nicholas Rejack <[email protected]> | ||
# Josh Hanna <[email protected]> | ||
# Kevin Hanson <[email protected]> | ||
# Copyright (c) 2014-2015, University of Florida | ||
# All rights reserved. | ||
# | ||
|
@@ -125,6 +126,9 @@ def main(): | |
- write the Final ElementTree to EAV | ||
""" | ||
|
||
|
||
# TODO: UPDATE COMMENT HERE | ||
global _person_form_events_service | ||
|
||
# obtaining command line arguments for path to configuration directory | ||
|
@@ -191,11 +195,14 @@ def main(): | |
report_courier = report.ReportFileWriter(os.path.join(output_files, | ||
settings.report_file_path2), logger) | ||
|
||
# This is the run that loads the data | ||
_run(config_file, configuration_directory, do_keep_gen_files, dry_run, | ||
get_emr_data, settings, output_files, db_path, redcap_client, | ||
report_courier, report_creator, args['--resume'], | ||
args['--skip-blanks'], args['--bulk-send-blanks']) | ||
|
||
# TODO: post processing will go here | ||
|
||
|
||
def get_db_path(batch_info_database, database_path): | ||
if not os.path.exists(database_path): | ||
|
@@ -297,7 +304,8 @@ def _run(config_file, configuration_directory, do_keep_gen_files, dry_run, | |
settings.emr_sftp_server_private_key_pass, | ||
) | ||
GetEmrData.get_emr_data(configuration_directory, connection_details) | ||
|
||
# load custom pre-processing filters | ||
pre_filters = load_preproc(settings.preprocessors, configuration_directory) | ||
# load custom post-processing rules | ||
rules = load_rules(settings.rules, configuration_directory) | ||
|
||
|
@@ -318,6 +326,10 @@ def _run(config_file, configuration_directory, do_keep_gen_files, dry_run, | |
if not resume: | ||
_delete_last_runs_data(data_folder) | ||
|
||
errors = run_preproc(pre_filters, settings) | ||
map(logger.warning, errors) | ||
# TODO: Add preproc errors to report | ||
|
||
alert_summary, person_form_event_tree_with_data, rule_errors, \ | ||
collection_date_summary_dict, bad_ids =\ | ||
_create_person_form_event_tree_with_data( | ||
|
@@ -1937,6 +1949,55 @@ def run_rules(data): | |
return loaded_rules | ||
|
||
|
||
def load_preproc(preprocessors, root='./'): | ||
""" | ||
Copied and modified version of load_rules function. | ||
TODO: fix load_rules and load_prerules for better parallelism | ||
""" | ||
if not preprocessors: | ||
return {} | ||
|
||
loaded = {} | ||
|
||
for (preprocessor, path) in ast.literal_eval(preprocessors).iteritems(): | ||
module = None | ||
if os.path.exists(path): | ||
module = imp.load_source(preprocessor, path) | ||
elif os.path.exists(os.path.join(root, path)): | ||
module = imp.load_source(preprocessor, os.path.join(root, path)) | ||
|
||
assert module is not None | ||
assert module.run_processing is not None | ||
|
||
loaded[preprocessor] = module | ||
|
||
logger.info("Loaded {} pre-processing script{}".format( | ||
len(loaded), 's' if len(loaded) != 1 else 0)) | ||
return loaded | ||
|
||
|
||
def run_preproc(preprocessors, settings): | ||
# TODO figure out if this creates a sub process or not | ||
# TODO need to check for program exe3cution otherwise give error | ||
logger.info("Running preprocessing rules") | ||
errors = [] | ||
|
||
for (preprocessor, module) in preprocessors.iteritems(): | ||
try: | ||
module.run_processing(settings, redi=sys.modules[__name__], | ||
logger=logging) | ||
except Exception as e: | ||
message_format = 'Error processing rule "{0}". {1}' | ||
if not hasattr(e, 'errors'): | ||
errors.append(message_format.format(preprocessor, e.message)) | ||
continue | ||
for error in e.errors: | ||
errors.append(message_format.format(preprocessor, error)) | ||
|
||
return errors | ||
|
||
|
||
def run_rules(rules, person_form_event_tree_with_data): | ||
errors = [] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,7 @@ | |
"sender_email": "[email protected]", | ||
"project": "DEFAULT_PROJECT", | ||
"rules": {}, | ||
"preprocessors": {}, | ||
"batch_warning_days": 13, | ||
"rate_limiter_value_in_redcap": 600, | ||
"batch_info_database": "redi.db", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
|
||
setup( | ||
name='redi', | ||
version='0.14.0', | ||
version='0.14.1', | ||
author='https://www.ctsi.ufl.edu/research/study-development/informatics-consulting/', | ||
author_email='[email protected]', | ||
packages=find_packages(exclude=['test']), | ||
|
@@ -27,13 +27,13 @@ | |
'redi': ['utils/*.xsl', 'utils/*.xsd'] | ||
}, | ||
url='https://github.com/ctsit/redi', | ||
download_url = 'https://github.com/ctsit/redi/releases/tag/0.14.0', | ||
download_url = 'https://github.com/ctsit/redi/releases/tag/0.14.1', | ||
keywords = ['EMR', 'EHR', 'REDCap', 'Clinical Data'], | ||
license='BSD 3-Clause', | ||
description='REDCap Electronic Data Importer', | ||
long_description=open('README.md').read(), | ||
install_requires=[ | ||
"requests >= 2.2.1", | ||
"requests >= 2.5.1", | ||
"lxml >= 3.3.5", | ||
"PyCap >= 1.0", | ||
"pysftp >= 0.2.8", | ||
|