Ejemplo n.º 1
0
    def test_research_id_to_redcap_id_converter(self):
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)

        class MockRedcapClient(RedcapClient):
            def __init__(self, context):
                self.__context = context

            def send_data_to_redcap(self, data, overwrite=False):
                raise NotImplementedError()

            def get_data_from_redcap(self,
                                     records_to_fetch=None,
                                     events_to_fetch=None,
                                     fields_to_fetch=None,
                                     forms_to_fetch=None,
                                     return_format='xml'):
                return self.__context.dummy_get_data_from_redcap(
                    records_to_fetch, events_to_fetch, fields_to_fetch,
                    forms_to_fetch, return_format)

        redi.research_id_to_redcap_id_converter(self.data,
                                                MockRedcapClient(self),
                                                self.research_id_to_redcap_id,
                                                self.configuration_directory)
        result = etree.tostring(self.data)
        self.assertEqual(self.expect, result)
 def test_create_empty_event_tree_for_study_for_zero_subjects(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.zero_subjects = """<?xml version='1.0' encoding='US-ASCII'?>
     <study></study>
     """
     self.data_zero_subjects = etree.ElementTree(etree.fromstring(self.zero_subjects))
     self.assertRaises(Exception,redi.create_empty_event_tree_for_study,self.data_zero_subjects,self.data_all_form_events)
Ejemplo n.º 3
0
    def test_empty_event(self):
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)
        logging.info("Running " + __name__ 
            + "#test_empty_event() using study_id: " + `self.CONST_STUDY_ID`)
        # Case 1 input string
        string_1_empty_event = """
<event>
</event>
"""
        out_dict_1 = {'study_id':self.CONST_STUDY_ID}
        etree_1 = etree.ElementTree(etree.fromstring(string_1_empty_event))
        self.assertRaises(Exception, upload.create_import_data_json, out_dict_1, etree_1)
    def test_create_empty_event_tree_for_study_for_one_subjects(self):
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)
        self.one_subject = """<?xml version='1.0' encoding='US-ASCII'?>
            <study>
            <subject lab_id="999-123">
            <NAME>TestSubject</NAME>
            <loinc_code>123456</loinc_code>
            <RESULT>123</RESULT>
            <REFERENCE_LOW>12.3</REFERENCE_LOW>
            <REFERENCE_HIGH>12.3</REFERENCE_HIGH>
            <REFERENCE_UNIT>g/dL</REFERENCE_UNIT>
            <DATE_TIME_STAMP/>
            <STUDY_ID>123</STUDY_ID>
        <timestamp/><redcapFormName>cbc</redcapFormName><eventName/><formDateField>cbc_lbdtc</formDateField><formCompletedFieldName>cbc_complete</formCompletedFieldName><formImportedFieldName>cbc_nximport</formImportedFieldName><redcapFieldNameValue>hemo_lborres</redcapFieldNameValue><redcapFieldNameUnits>hemo_lborresu</redcapFieldNameUnits><redcapFieldNameStatus>hemo_lbstat</redcapFieldNameStatus></subject>
        </study>
            """
        self.data_one_subject= etree.ElementTree(etree.fromstring(self.one_subject))
        
        self.output_one_subject = """
<person_form_event>
    <person lab_id="999-123">
        <study_id>123</study_id>
        <all_form_events>
        <form>
            <name>cbc</name>
            <event>
                <name>1_arm_1</name>
                <field><name>lymce_lborres</name><value/></field><field><name>lymce_lborresu</name><value/></field><field><name>hemo_lborresu</name><value/></field><field><name>cbc_lbdtc</name><value/></field><field><name>cbc_nximport</name><value/></field><field><name>lymce_lbstat</name><value/></field><field><name>cbc_complete</name><value/></field><field><name>hemo_lbstat</name><value/></field><field><name>hemo_lborres</name><value/></field>
            </event>
            </form>
        <form>
            <name>chemistry</name>
            <event>
                <name>1_arm_1</name>
                <field><name>k_lborres</name><value/></field><field><name>chem_lbdtc</name><value/></field><field><name>sodium_lborresu</name><value/></field><field><name>k_lbstat</name><value/></field><field><name>sodium_lbstat</name><value/></field><field><name>chem_nximport</name><value/></field><field><name>chemistry_complete</name><value/></field><field><name>k_lborresu</name><value/></field><field><name>sodium_lborres</name><value/></field>
                </event>
        </form>
        <form>
            <name>inr</name>
            <event>
            <name>1_arm_1</name>
            <field><name>inr_lbdtc</name><value/></field><field><name>inr_complete</name><value/></field><field><name>inr_nximport</name><value/></field></event>
           </form>
        </all_form_events>
    </person>
</person_form_event>
        """
        self.expect_one_subject = etree.tostring(etree.fromstring(self.output_one_subject))
        self.result = etree.tostring(
            redi.create_empty_event_tree_for_study(self.data_one_subject,self.data_all_form_events))
        clean_expected = ''.join(self.expect_one_subject.split())
        clean_result = ''.join(self.result.split())
        self.assertEqual(clean_expected, clean_result)
Ejemplo n.º 5
0
    def test_update_formdatefield(self):
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)
        redi.update_formdatefield(self.data, self.form_events_tree)

        # output raw file to check it
        #redi.write_element_tree_to_file(self.data, 'rawData.xml')

        # initialize a dictionary for the formdatefield
        # [key, value] = [formdatefield, filled or not?(0/1)]
        isFormDateFieldFilled = {}
        for subject in self.data.iter('subject'):
            form_date_field = subject.find('formDateField').text
            if not form_date_field:
                isFormDateFieldFilled[form_date_field] = 1
        status = 1
        for key, value in isFormDateFieldFilled.items():
            if value != status:
                status = 0
                break
        self.assertEqual(status, 1)
Ejemplo n.º 6
0
    def test_update_formdatefield(self):
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)
        redi.update_formdatefield(self.data, self.form_events_tree)

	    # output raw file to check it
        #redi.write_element_tree_to_file(self.data, 'rawData.xml')

        # initialize a dictionary for the formdatefield
        # [key, value] = [formdatefield, filled or not?(0/1)]
        isFormDateFieldFilled = {}
        for subject in self.data.iter('subject'):
            form_date_field = subject.find('formDateField').text
            if not form_date_field:
                isFormDateFieldFilled[form_date_field] = 1
        status=1
        for key,value in isFormDateFieldFilled.items():
            if value != status:
                status = 0
                break
        self.assertEqual(status,1)
Ejemplo n.º 7
0
    def test_log(self):
        import os.path
        file_name = self.file_name
        sys.path.append('log')
        # remove any existing log file in log/ folder

        #if os.path.isfile(file_name):
        #    with open(file_name):
                #print "here"
        #        os.remove(file_name)
                #print os.path.isfile(file_name)

        # call the configure logging function
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)

        #print 'checking if log file was created: ' + file_name
        # check if the file is created
        assert os.path.isfile(file_name) == True

        # remove the file created through testing
        os.remove(file_name)
Ejemplo n.º 8
0
    def test_log(self):
        import os.path
        file_name = self.file_name
        sys.path.append('log')
        # remove any existing log file in log/ folder

        #if os.path.isfile(file_name):
        #    with open(file_name):
        #print "here"
        #        os.remove(file_name)
        #print os.path.isfile(file_name)

        # call the configure logging function
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)

        #print 'checking if log file was created: ' + file_name
        # check if the file is created
        assert os.path.isfile(file_name) == True

        # remove the file created through testing
        os.remove(file_name)
Ejemplo n.º 9
0
    def setUp(self):
        # initialize the data with element tree
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)
        self.test_xml = """<?xml version="1.0" encoding="utf8"?>
<study>
    <subject>
        <NAME>TSH REFLEX</NAME>
        <loinc_code>1552152</loinc_code>
        <RESULT>0.74</RESULT>
        <REFERENCE_LOW>0.27</REFERENCE_LOW>
        <REFERENCE_HIGH>4.20</REFERENCE_HIGH>
        <REFERENCE_UNIT>mIU/L</REFERENCE_UNIT>
        <DATE_TIME_STAMP>1903-11-27 15:13:00</DATE_TIME_STAMP>
        <STUDY_ID>59</STUDY_ID>
    </subject>
    <subject>
        <NAME>HEP C RNA, QUANT REAL-TIME</NAME>
        <loinc_code>740</loinc_code>
        <RESULT>5.8</RESULT>
        <REFERENCE_LOW></REFERENCE_LOW>
        <REFERENCE_HIGH></REFERENCE_HIGH>
        <REFERENCE_UNIT>log IU</REFERENCE_UNIT>
        <DATE_TIME_STAMP>1903-11-27 15:13:00</DATE_TIME_STAMP>
        <STUDY_ID>59</STUDY_ID>
    </subject>
    <subject>
        <NAME>HCV QUANTITATIVE INTERPRETATION</NAME>
        <loinc_code>1534483</loinc_code>
        <RESULT>Detected</RESULT>
        <REFERENCE_LOW></REFERENCE_LOW>
        <REFERENCE_HIGH></REFERENCE_HIGH>
        <REFERENCE_UNIT></REFERENCE_UNIT>
        <DATE_TIME_STAMP>1903-11-27 15:13:00</DATE_TIME_STAMP>
        <STUDY_ID>59</STUDY_ID>
    </subject>
    </study>"""
        self.data = etree.ElementTree(etree.fromstring(self.test_xml))
        self.input_date_format = "%Y-%m-%d %H:%M:%S"
        self.output_date_format = "%Y-%m-%d"
Ejemplo n.º 10
0
    def setUp(self):
        # initialize the data with element tree
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)
        self.test_xml = """<?xml version="1.0" encoding="utf8"?>
<study>
    <subject>
        <NAME>TSH REFLEX</NAME>
        <loinc_code>1552152</loinc_code>
        <RESULT>0.74</RESULT>
        <REFERENCE_LOW>0.27</REFERENCE_LOW>
        <REFERENCE_HIGH>4.20</REFERENCE_HIGH>
        <REFERENCE_UNIT>mIU/L</REFERENCE_UNIT>
        <DATE_TIME_STAMP>1903-11-27 15:13:00</DATE_TIME_STAMP>
        <STUDY_ID>59</STUDY_ID>
    </subject>
    <subject>
        <NAME>HEP C RNA, QUANT REAL-TIME</NAME>
        <loinc_code>740</loinc_code>
        <RESULT>5.8</RESULT>
        <REFERENCE_LOW></REFERENCE_LOW>
        <REFERENCE_HIGH></REFERENCE_HIGH>
        <REFERENCE_UNIT>log IU</REFERENCE_UNIT>
        <DATE_TIME_STAMP>1903-11-27 15:13:00</DATE_TIME_STAMP>
        <STUDY_ID>59</STUDY_ID>
    </subject>
    <subject>
        <NAME>HCV QUANTITATIVE INTERPRETATION</NAME>
        <loinc_code>1534483</loinc_code>
        <RESULT>Detected</RESULT>
        <REFERENCE_LOW></REFERENCE_LOW>
        <REFERENCE_HIGH></REFERENCE_HIGH>
        <REFERENCE_UNIT></REFERENCE_UNIT>
        <DATE_TIME_STAMP>1903-11-27 15:13:00</DATE_TIME_STAMP>
        <STUDY_ID>59</STUDY_ID>
    </subject>
    </study>"""
        self.data = etree.ElementTree(etree.fromstring(self.test_xml))
        self.input_date_format = "%Y-%m-%d %H:%M:%S"
        self.output_date_format = "%Y-%m-%d"
Ejemplo n.º 11
0
    def test_research_id_to_redcap_id_converter(self):
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)

        class MockRedcapClient(RedcapClient):
            def __init__(self, context):
                self.__context = context

            def send_data_to_redcap(self, data, overwrite=False):
                raise NotImplementedError()

            def get_data_from_redcap(self, records_to_fetch=None,
                                     events_to_fetch=None, fields_to_fetch=None,
                                     forms_to_fetch=None, return_format='xml'):
                return self.__context.dummy_get_data_from_redcap(
                    records_to_fetch, events_to_fetch, fields_to_fetch,
                    forms_to_fetch, return_format)

        redi.research_id_to_redcap_id_converter(self.data,
                                                MockRedcapClient(self),
                                                self.research_id_to_redcap_id,
                                                self.configuration_directory)
        result = etree.tostring(self.data)
        self.assertEqual(self.expect, result)
Ejemplo n.º 12
0
    def setUp(self):
        redi.configure_logging('.')
        #redi.logger.setLevel(logging.DEBUG)

        # un-sorted XML file
        self.unsorted = """<?xml version="1.0" encoding="UTF-8"?>
<study>
   <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE></ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-03 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE>123</ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-01 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE> </ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-02 00:00:00</DATE_TIME_STAMP>
    </subject>
</study>
        """

        # we expect the following sorted tree
        self.sorted_tree = """<?xml version="1.0" encoding="UTF-8"?>
<study>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE>123</ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-01 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE> </ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-02 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE></ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-03 00:00:00</DATE_TIME_STAMP>
    </subject>
</study>
        """
        self.dirpath = tempfile.mkdtemp()
Ejemplo n.º 13
0
    def setUp(self):
        redi.configure_logging('.')
        #redi.logger.setLevel(logging.DEBUG)

        # un-sorted XML file
        self.unsorted = """<?xml version="1.0" encoding="UTF-8"?>
<study>
   <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE></ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-03 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE>123</ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-01 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE> </ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-02 00:00:00</DATE_TIME_STAMP>
    </subject>
</study>
        """

        # we expect the following sorted tree
        self.sorted_tree = """<?xml version="1.0" encoding="UTF-8"?>
<study>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE>123</ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-01 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE> </ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-02 00:00:00</DATE_TIME_STAMP>
    </subject>
    <subject>
        <NAME>PLATELET COUNT</NAME>
        <ORD_VALUE></ORD_VALUE>
        <STUDY_ID>999-0262</STUDY_ID>
        <redcapFormName>cbc</redcapFormName>
        <loinc_code>component_A</loinc_code>
        <DATE_TIME_STAMP>2013-12-03 00:00:00</DATE_TIME_STAMP>
    </subject>
</study>
        """
        self.dirpath = tempfile.mkdtemp()
 def test_create_empty_events_for_one_subject_all_fields_input(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.result = etree.tostring(redi.create_empty_events_for_one_subject(self.data1_test1,self.data2_test1))
     self.result = ''.join(self.result.split())
     self.expect_test1 = ''.join(self.expect_test1.split())
     self.assertEqual(self.expect_test1, self.result)
 def test_create_empty_events_for_one_subject_no_fields_input(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.assertRaises(Exception,redi.create_empty_events_for_one_subject,self.data1_test2,self.data2_test2)
Ejemplo n.º 16
0
 def setUp(self):
     # configure logging
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     # start a server in seperate thread
     thread.start_new_thread(self.server_setup,())
Ejemplo n.º 17
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.sampleData = """<rediFieldMap>
Ejemplo n.º 18
0
 def test_update_form_imported(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     redi.update_form_imported_field(self.data, self.form_events_tree, 'undefined')
     result = etree.tostring(self.data)
     self.assertEqual(self.expect, result)
Ejemplo n.º 19
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.study_id = 123
Ejemplo n.º 20
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.CONST_STUDY_ID = 73
     return()
Ejemplo n.º 21
0
 def test_update_event_name(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     redi.update_event_name(self.data, self.form_events_tree, 'undefined')
     result = etree.tostring(self.data)
     self.assertEqual(self.expect, result)
Ejemplo n.º 22
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.study_id = 123
Ejemplo n.º 23
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.test_raw_xml = """<?xml version='1.0' encoding='US-ASCII'?>
Ejemplo n.º 24
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
Ejemplo n.º 25
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.sampleData = """<study>
Ejemplo n.º 26
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     self.test_raw_xml = """<?xml version='1.0' encoding='US-ASCII'?>
Ejemplo n.º 27
0
    def setUp(self):
        """
        Prepare data structures
        """
        redi.configure_logging(DEFAULT_DATA_DIRECTORY)
        self.test_report_params = {
            'project': 'hcvtarget-uf',
            'report_file_path': os.path.join(DEFAULT_DATA_DIRECTORY, 'unittest_report.xml'),
            'redcap_uri': 'https://hostname.org',
            'is_sort_by_lab_id': True,
            }

        self.test_report_data = {
            'total_subjects': 5,
            'form_details': {
                'Total_chemistry_Forms': 22,
                'Total_cbc_Forms': 53
            },
            'subject_details': {
                '60': {'cbc_Forms': 1, 'chemistry_Forms': 1, 'lab_id': '999-0060'},
                '61': {'cbc_Forms': 2, 'chemistry_Forms': 1, 'lab_id': '999-0061'},
                '63': {'cbc_Forms': 11, 'chemistry_Forms': 4, 'lab_id': '999-0063'},
                '59': {'cbc_Forms': 39, 'chemistry_Forms': 16, 'lab_id': '999-0059'}
            },
            'errors' : [],
        }

        self.test_alert_summary = {
            'multiple_values_alert': [
                'This is multiple values alert 1',
                'This is multiple values alert 2',
                'This is multiple values alert 3'],
            'max_event_alert': [
                'This is max event alert 1',
                'This is max event alert 2',
                'This is max event alert 3']
        }

        self.specimen_taken_time_summary = {'total': 15, 'blank': 3}
        self.duration_dict = {
            'all' : {
                'start': "2014-01-01 00:00:00",
                'end': "2014-01-01 00:00:01",
            }
        }

        self.expected_xml = '''
<report>
    <header>
        <project>hcvtarget-uf</project>
        <date>'''+time.strftime("%m/%d/%Y")+'''</date>
        <redcapServerAddress>https://hostname.org</redcapServerAddress>
    </header>
    <summary>
        <subjectCount>5</subjectCount>
        <forms>
            <form>
                <form_name>Total_cbc_Forms</form_name>
                <form_count>53</form_count>
            </form>
            <form>
                <form_name>Total_chemistry_Forms</form_name>
                <form_count>22</form_count>
            </form>
        </forms>
    </summary>
    <alerts>
        <tooManyForms>
        <eventAlert>
            <message>This is max event alert 1</message>
        </eventAlert>
        <eventAlert>
            <message>This is max event alert 2</message>
        </eventAlert>
        <eventAlert>
            <message>This is max event alert 3</message>
        </eventAlert>
        </tooManyForms>
        <tooManyValues>
            <valuesAlert>
                <message>This is multiple values alert 1</message>
            </valuesAlert>
            <valuesAlert>
                <message>This is multiple values alert 2</message>
            </valuesAlert>
            <valuesAlert><message>This is multiple values alert 3</message>
        </valuesAlert></tooManyValues>
    </alerts>
    <subjectsDetails>
        <subject>
        <redcap_id>59</redcap_id>
        <forms>
            <form>
                <form_name>cbc_Forms</form_name>
                <form_count>39</form_count>
            </form>
            <form>
                <form_name>chemistry_Forms</form_name>
                <form_count>16</form_count>
            </form>
        </forms>
        <lab_id>999-0059</lab_id>
        </subject>
        <subject>
            <redcap_id>60</redcap_id>
            <forms>
                <form>
                    <form_name>cbc_Forms</form_name>
                    <form_count>1</form_count></form>
                <form>
                    <form_name>chemistry_Forms</form_name>
                    <form_count>1</form_count>
                </form>
            </forms>
            <lab_id>999-0060</lab_id>
        </subject>
        <subject>
            <redcap_id>61</redcap_id>
            <forms>
                <form>
                    <form_name>cbc_Forms</form_name>
                    <form_count>2</form_count>
                </form>
                <form>
                    <form_name>chemistry_Forms</form_name>
                    <form_count>1</form_count>
                </form>
            </forms>
            <lab_id>999-0061</lab_id>
        </subject>
        <subject>
            <redcap_id>63</redcap_id>
            <forms>
                <form>
                    <form_name>cbc_Forms</form_name>
                    <form_count>11</form_count>
                </form>
                <form>
                    <form_name>chemistry_Forms</form_name>
                    <form_count>4</form_count>
                </form>
            </forms>
            <lab_id>999-0063</lab_id>
        </subject>
    </subjectsDetails>
    <errors/>
    <summaryOfSpecimenTakenTimes>
        <total>15</total>
        <blank>3</blank>
        <percent>20.0</percent>
    </summaryOfSpecimenTakenTimes>
    <sort_details_by>lab_id</sort_details_by>
    <time_all_start>00:00:00</time_all_start>
    <time_all_end>00:00:01</time_all_end>
    <time_all_diff>0:00:01</time_all_diff>
</report>'''

        self.schema_str = StringIO('''\
            <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="report">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="header">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:string" name="project"/>
              <xs:element type="xs:string" name="date"/>
              <xs:element type="xs:string" name="redcapServerAddress"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="summary">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:byte" name="subjectCount"/>
              <xs:element name="forms">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="form" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element type="xs:string" name="form_name"/>
                          <xs:element type="xs:byte" name="form_count"/>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="alerts">
          <xs:complexType>

             <xs:sequence>
              <xs:element name="tooManyForms">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="eventAlert" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element type="xs:string" name="message"/>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>

              <xs:element name="tooManyValues">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="valuesAlert" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element type="xs:string" name="message"/>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="subjectsDetails">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="subject" maxOccurs="unbounded" minOccurs="0">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element type="xs:int" name="redcap_id"/>
                    <xs:element name="forms">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="form" maxOccurs="unbounded" minOccurs="0">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element type="xs:string" name="form_name"/>
                                <xs:element type="xs:byte" name="form_count"/>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element type="xs:string" name="lab_id"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="errors">
        </xs:element>
        <xs:element name="summaryOfSpecimenTakenTimes">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:byte" name="total"/>
              <xs:element type="xs:byte" name="blank"/>
              <xs:element type="xs:float" name="percent"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="sort_details_by"></xs:element>
        <xs:element name="time_all_start"></xs:element>
        <xs:element name="time_all_end"></xs:element>
        <xs:element name="time_all_diff"></xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>''')
        return
Ejemplo n.º 28
0
 def setUp(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
Ejemplo n.º 29
0
 def test_update_event_name_keep_all_events(self):
     redi.configure_logging(DEFAULT_DATA_DIRECTORY)
     redi.update_event_name(self.data, self.form_events_tree, 'undefined')
     result = etree.tostring(self.data)
     self.assertEqual(self.expect, result)