Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 181a1ef

Browse files
author
Roy Keyes
committed
Merge branch 'release/0.15.3'
2 parents fb61162 + 0a9529e commit 181a1ef

File tree

9 files changed

+225
-37
lines changed

9 files changed

+225
-37
lines changed

Diff for: CHANGELOG

+38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
2016-05-19 v0.15.3
2+
3+
* modify TestSortElementTree to test for new commandline switch for keeping all results that bypasses the compress events functions (Christopher Barnes)
4+
* Updating GetTheDocs URL in README.md (Nicholas Rejack)
5+
* Allow setuptools_scm to set the version when it's importing redi.py (Nicholas Rejack)
6+
* docs/conf.py needs to get the version from one directory up. (Nicholas Rejack)
7+
* Adding 2 necessary elements to validate formEvents with HCV RNA forms. Fixing whitespace. (Nicholas Rejack)
8+
* Adding setuptools_scm to docs/conf.py. Now using dynamically-set version number (based on Git tag) (Nicholas Rejack)
9+
* Adding setuptools_scm to redi.py. Now using dynamically-set version number (based on Git tag) (Nicholas Rejack)
10+
* Adding setuptools_scm to setup.py. Now using dynamically-set version number (based on Git tag) (Nicholas Rejack)
11+
* Fixing broken test by reordering XML statements so they validate. (Nicholas Rejack)
12+
* Modifying redi/redi.py to add validation for XSD for formEvents.xml (Nicholas Rejack)
13+
* Added redi/utils/formEvents.xsd to validate formEvents.xml (Nicholas Rejack)
14+
* add info on tests needed before I can make a pull request, to TODO (Christopher Barnes)
15+
* comment out test for --keep-all, add TODO to fix this later (Christopher Barnes)
16+
* Add 2 TODOs that cover issues with the timestamp and how it affects conmeds. (Buck72)
17+
* take the -keep-all logic out of get_key_date (Christopher Barnes)
18+
* take the -keep-all logic out of get_key_date (Christopher Barnes)
19+
* add keep-all-results logic to get_key_dates (Christopher Barnes)
20+
* add keep-all-results logic to get_key_dates (Christopher Barnes)
21+
* mod TestSortElementTree.py to have test keep-all results inputs (Christopher Barnes)
22+
* mod TestSortElementTree.py to have correct number of args(3) to handle new input keep-all (Christopher Barnes)
23+
* fixed incorrect ref to input_file to input_file_path on line 400 in _run (Christopher Barnes)
24+
* set flase correctly in sort elements to turn OFF compression (Christopher Barnes)
25+
* add keep all to create person xml func (Christopher Barnes)
26+
* add keep all to create person xml func (Christopher Barnes)
27+
* add keep all to create person xml func (Christopher Barnes)
28+
* change all refs to --kepp all to use true and false (Christopher Barnes)
29+
* fix inputs to sort_element_tree, pass in keep all results (Christopher Barnes)
30+
* fix inputs to _run, change inputfilename to input_file_path (Christopher Barnes)
31+
* fix inputs to _run, added -K and -f args and set defaults to none (Christopher Barnes)
32+
* process raw file correctly as part of keep all results (Christopher Barnes)
33+
* process raw file correctly as part of keep all results (Christopher Barnes)
34+
* cleanup -K keep all switch (Christopher Barnes)
35+
* cleanup -K keep all switch (Christopher Barnes)
36+
* cleanup -K keep all switch (Christopher Barnes)
37+
* add switch to keep all results (Christopher Barnes)
38+
139
2016-03-17 v0.15.2
240

341
* Summary: Hotfix to fix logging behavior when input file is not present.

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ You can view a presentation of the RED-I tool in action on
2828
[youtube](https://www.youtube.com/watch?v=0x04y5SNPL8&feature=youtu.be)
2929

3030
For the official documentation please refer to
31-
[http://redi.readthedocs.org](http://redi.readthedocs.org) or
31+
[http://redi.readthedocs.io](http://redi.readthedocs.io) or
3232
[RED-I Project](https://github.com/ctsit/redi/blob/master/docs/about.rst).

Diff for: docs/conf.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import sys
1616
import os
17+
from setuptools_scm import get_version
1718

1819
# If extensions (or modules to document with autodoc) are in another directory,
1920
# add these directories to sys.path here. If the directory is relative to the
@@ -61,9 +62,9 @@
6162
# built documents.
6263
#
6364
# The short X.Y version.
64-
version = '0.15.2'
65+
version = get_version(root='..', relative_to=__file__)
6566
# The full version, including alpha/beta/rc tags.
66-
release = '0.15.2'
67+
release = version
6768

6869
# The language for content autogenerated by Sphinx. Refer to documentation
6970
# for a list of supported languages.

Diff for: redi/TODO.md

+13
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,16 @@
2424
TODO: make tests requirement- msg=sudo easy_install sftpserver
2525
TODO: make all settings files pythonic aka config.yml .. etc using YAML standard
2626
TODO: take NOT_DONE examples for values without units data points out of vagrant/redi_out_reference.csv for hcv examples
27+
<<<<<<< HEAD
28+
# TODO: -K 'keep all results' fail if in the settings.ini doesn't have Y-M-D H:M:S
29+
30+
31+
32+
# TODO: Modify dates on ConMeds forms to validate for H:M:S.
33+
=======
34+
35+
** TODO: To be able to make pull request for keep-all switch . Write unit test(s) for all the functions touched by the keep-all commandline switch.
36+
** TODO: TO be able to make a pull request for keep-all switch. Write end-to-end tests to take in fake conmeds data, call the sithc, pass in the file, use redcap api to query out the data and compare to input csv. Use N Rejack scripts to create test data.
37+
** TODO: change install redcap setting to enable table based authentication.
38+
** TODO: find out why sometimes redcap can't talk to mysql. restart mysql fixes. may need to add this to the bootstrap to restart apache and mysql right at the e nd.
39+
>>>>>>> afd8c4190fafc4092152fcfb7c5dcee57cd5eb47

Diff for: redi/redi.py

+41-21
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
Usage:
2424
redi.py -h | --help
25-
redi.py [-v] [-V] [-k] [-e] [-d] [-f=<path>] [-r] [-c=<path>] [-D=<datadir>] [-s] [-b]
25+
redi.py [-v] [-V] [-k] [-e] [-d] [-f=<path>] [-r] [-c=<path>] [-D=<datadir>] [-s] [-b] [-K]
2626
2727
Options:
2828
-h --help Show this help message and exit
@@ -52,10 +52,9 @@
5252
[default:False]
5353
-b --bulk-send-blanks Send blank events in bulk instead of
5454
individually [default:False]
55+
-K --keep-all Keep all results, do not compress by date
5556
"""
56-
5757
__author__ = "University of Florida CTS-IT Team"
58-
__version__ = "0.15.0"
5958
__email__ = "[email protected]"
6059
__status__ = "Development"
6160

@@ -90,12 +89,19 @@
9089
import utils.SimpleConfigParser as SimpleConfigParser
9190
import utils.GetEmrData as GetEmrData
9291
from utils.GetEmrData import EmrFileAccessDetails
92+
from setuptools_scm import get_version
9393

9494
#from memory_profiler import profile
9595

96+
# set the version using setuptools_scm
97+
# allow for setting the version when redi is imported
98+
try:
99+
__version__ = get_version()
100+
except:
101+
__version__ = get_version(root='..', relative_to=__file__)
102+
96103
# Command line default argument values
97104
_person_form_events_service = None
98-
99105
translational_table_tree = None
100106

101107
DEFAULT_DATA_DIRECTORY = os.getcwd()
@@ -136,15 +142,16 @@ def main():
136142
- write the Final ElementTree to EAV
137143
"""
138144

139-
140145
# TODO: UPDATE COMMENT HERE
141146
global _person_form_events_service
142147

143148
# obtaining command line arguments for path to configuration directory
144149
args = docopt(__doc__, help=True)
145150

146-
151+
# capture any cli args passed in that are needed to pass into other funcs.
147152
data_directory = args['--datadir']
153+
keep_all_results = args['--keep-all']
154+
148155
if data_directory is None:
149156
data_directory = DEFAULT_DATA_DIRECTORY
150157

@@ -262,7 +269,7 @@ def main():
262269
_run(config_file, configuration_directory, do_keep_gen_files, dry_run,
263270
get_emr_data, settings, output_files, db_path, raw_txt_file, redcap_client,
264271
report_courier, report_creator, args['--resume'],
265-
args['--skip-blanks'], args['--bulk-send-blanks'])
272+
args['--skip-blanks'], args['--bulk-send-blanks'], keep_all_results, input_file_path)
266273

267274
# TODO: post processing will go here
268275

@@ -351,7 +358,7 @@ def connect_to_redcap(email_settings, redcap_settings, dry_run=False):
351358
def _run(config_file, configuration_directory, do_keep_gen_files, dry_run,
352359
get_emr_data, settings, data_folder, database_path, raw_txt_file, redcap_client,
353360
report_courier, report_creator, resume=False, skip_blanks=False,
354-
bulk_send_blanks=False):
361+
bulk_send_blanks=False, keep_all_results=False, input_file_path=None):
355362
global translational_table_tree
356363

357364
assert _person_form_events_service is not None
@@ -391,6 +398,15 @@ def _run(config_file, configuration_directory, do_keep_gen_files, dry_run,
391398
# delete rawEscaped.txt
392399
GetEmrData.cleanup(escaped_file)
393400

401+
# TODO: clean this up as well was the get_emr_ stuff above
402+
403+
# if either -K or -f are specifed run the steps to make raw.xml
404+
if (keep_all_results != False or input_file_path != None):
405+
GetEmrData.data_preprocessing(raw_txt_file, escaped_file)
406+
GetEmrData.generate_xml(escaped_file, raw_xml_file)
407+
GetEmrData.cleanup(escaped_file)
408+
409+
394410

395411
raw_xml_file = os.path.join(configuration_directory, settings.raw_xml_file)
396412
email_settings = get_email_settings(settings)
@@ -416,7 +432,7 @@ def _run(config_file, configuration_directory, do_keep_gen_files, dry_run,
416432
_create_person_form_event_tree_with_data(
417433
config_file, configuration_directory, redcap_client,
418434
form_events_file, raw_xml_file, rules, settings, data_folder,
419-
translation_table_file)
435+
translation_table_file, keep_all_results)
420436

421437
_store_run_data(data_folder, alert_summary,
422438
person_form_event_tree_with_data, rule_errors,
@@ -495,7 +511,7 @@ def _run(config_file, configuration_directory, do_keep_gen_files, dry_run,
495511

496512
def _create_person_form_event_tree_with_data(
497513
config_file, configuration_directory, redcap_client, form_events_file,
498-
raw_xml_file, rules, settings, data_folder, translation_table_file):
514+
raw_xml_file, rules, settings, data_folder, translation_table_file, keep_all_results):
499515

500516
global translational_table_tree
501517
# parse the raw.xml file and fill the etree rawElementTree
@@ -602,7 +618,7 @@ def _create_person_form_event_tree_with_data(
602618
data,
603619
os.path.join(data_folder, 'rawDataWithDatumAndUnitsFieldNames.xml'))
604620
# sort the data tree and compress
605-
sort_element_tree(data, data_folder)
621+
sort_element_tree(data, data_folder, keep_all_results)
606622
write_element_tree_to_file(data, os.path.join(data_folder, \
607623
'rawDataSortedAfterCompression.xml'))
608624
# update eventName element
@@ -702,6 +718,8 @@ def parse_form_events(form_events_file):
702718
logger.info("Form events file contains {} lines." \
703719
.format(str(sum(1 for line in raw))))
704720

721+
validate_xml_file_and_extract_data(form_events_file, pkg_resources.resource_filename(
722+
'redi', 'utils/formEvents.xsd'))
705723
data = etree.parse(form_events_file)
706724
event_sum = len(data.findall(".//event"))
707725
logger.debug(str(event_sum) + " total events read into tree.")
@@ -856,7 +874,7 @@ def update_redcap_form(data, lookup_data, undefined):
856874
undefined)
857875

858876

859-
def sort_element_tree(data, data_folder):
877+
def sort_element_tree(data, data_folder, keep_all_results):
860878
"""
861879
Sort element tree based on three given indices.
862880
@see #update_time_stamp()
@@ -876,7 +894,15 @@ def sort_element_tree(data, data_folder):
876894
write_element_tree_to_file(data, os.path.join(data_folder,
877895
"rawDataSortedBeforeCompression.xml"))
878896

879-
compress_data_using_study_form_date(data)
897+
# TODO: look at adding a switch to RED-I, that will need to be caught here, that
898+
# will allow another behavioe here that will let us keep all results vs
899+
# the current behavior of sorting the events by timestamp and keeping only
900+
# the first one to occur on a given day. Example: whne this feature is
901+
# implemented red-i will be able to keep only 1 data point for each day
902+
# for 50 days or keep 50 data points that may occur on the same day and
903+
# map the 50 into 50 event slots in redcap.
904+
if (keep_all_results == False):
905+
compress_data_using_study_form_date(data)
880906

881907
#batch.printxml(container)
882908

@@ -949,13 +975,7 @@ def compress_data_using_study_form_date(data):
949975
logger.debug("Remove duplicate result using key: {}".format(key_debug))
950976
subj.getparent().remove(subj)
951977

952-
# TODO: look at adding a switch to RED-I, that will need to be caught here, that
953-
# will allow another behavioe here that will let us keep all results vs
954-
# the current behavior of sorting the events by timestamp and keeping only
955-
# the first one to occur on a given day. Example: whne this feature is
956-
# implemented red-i will be able to keep only 1 data point for each day
957-
# for 50 days or keep 50 data points that may occur on the same day and
958-
# map the 50 into 50 event slots in redcap.
978+
959979

960980
filt = dict()
961981

@@ -1003,7 +1023,7 @@ def get_key_timestamp(ele):
10031023
return (study_id, form_name, timestamp)
10041024

10051025

1006-
def get_key_date(ele):
1026+
def get_key_date(ele,keep_all_results=False):
10071027
"""
10081028
Helper function for #compress_data_using_study_form_date()
10091029

Diff for: redi/utils/formEvents.xsd

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version ="1.0"?>
2+
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<xs:element name="redcapProject">
4+
<xs:complexType>
5+
<xs:sequence>
6+
<xs:element name="name" type="xs:string" />
7+
<xs:element name="form" maxOccurs="unbounded">
8+
<xs:complexType>
9+
<xs:sequence>
10+
<xs:element name="name" type="xs:string"/>
11+
<xs:element name="formDateField" type="xs:string"/>
12+
<xs:element name="formFieldDetected" type="xs:string" minOccurs="0"/>
13+
<xs:element name="formQuantifiedField" type="xs:string" minOccurs="0"/>
14+
<xs:element name="formCompletedFieldName" type="xs:string"/>
15+
<xs:element name="formCompletedFieldValue" type="xs:int"/>
16+
<xs:element name="formImportedFieldName" type="xs:string" minOccurs="0"/>
17+
<xs:element name="formImportedFieldValue" type="xs:string" minOccurs="0"/>
18+
<xs:element name="formFieldNotes" type="xs:string" minOccurs="0"/>
19+
<xs:element name="formFieldVerbatim" type="xs:string" minOccurs="0"/>
20+
<xs:element name="event" maxOccurs="unbounded">
21+
<xs:complexType>
22+
<xs:sequence>
23+
<xs:element name="name" type="xs:string"/>
24+
</xs:sequence>
25+
</xs:complexType>
26+
</xs:element>
27+
</xs:sequence>
28+
</xs:complexType>
29+
</xs:element>
30+
</xs:sequence>
31+
</xs:complexType>
32+
</xs:element>
33+
</xs:schema>

Diff for: setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
setup(
2020
name='redi',
21-
version='0.15.2',
21+
use_scm_version=True,
2222
author='https://www.ctsi.ufl.edu/research/study-development/informatics-consulting/',
2323
author_email='[email protected]',
2424
packages=find_packages(exclude=['test']),
@@ -27,7 +27,7 @@
2727
'redi': ['utils/*.xsl', 'utils/*.xsd']
2828
},
2929
url='https://github.com/ctsit/redi',
30-
download_url = 'https://github.com/ctsit/redi/releases/tag/0.15.1',
30+
download_url = 'https://github.com/ctsit/redi/releases/tag/0.15.3',
3131
keywords = ['EMR', 'EHR', 'REDCap', 'Clinical Data'],
3232
license='BSD 3-Clause',
3333
description='REDCap Electronic Data Importer',
@@ -54,5 +54,6 @@
5454
setup_requires=[
5555
"nose >= 1.0",
5656
"nosexcover >= 1.0.10",
57+
"setuptools_scm >= 1.10.1"
5758
],
5859
)

Diff for: test/TestParseAll.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def test_parse_form_events(self):
4545
<name>cbc</name>
4646
<formDateField>cbc_lbdtc</formDateField>
4747
<formCompletedFieldName>cbc_complete</formCompletedFieldName>
48-
<formImportedFieldName>cbc_nximport</formImportedFieldName>
4948
<formCompletedFieldValue>2</formCompletedFieldValue>
49+
<formImportedFieldName>cbc_nximport</formImportedFieldName>
5050
<formImportedFieldValue>Y</formImportedFieldValue>
5151
<event>
5252
<name>1_arm_1</name>
@@ -62,8 +62,8 @@ def test_parse_form_events(self):
6262
<name>chemistry</name>
6363
<formDateField>chem_lbdtc</formDateField>
6464
<formCompletedFieldName>chemistry_complete</formCompletedFieldName>
65-
<formImportedFieldName>chem_nximport</formImportedFieldName>
6665
<formCompletedFieldValue>2</formCompletedFieldValue>
66+
<formImportedFieldName>chem_nximport</formImportedFieldName>
6767
<formImportedFieldValue>Y</formImportedFieldValue>
6868
<event>
6969
<name>1_arm_1</name>

0 commit comments

Comments
 (0)