Example #1
0
def prepare_mysql_metadata_stage5(
        transaction: RedcapTransaction) -> RedcapTransaction:
    """
    Prepare mysql metadata. (Stage 5)
    *** Sometime some metadata are missing. Ex : Stage 4 is adding caseid, motherid etc and metadata is not updated.
    This fonction will add the missing metadata to allow us to export all the data to mysql.
    :param transaction: RedcapTransaction (Stage 4)
    :return: Updated RedcapTransaction (stage 5)
    """

    # Get entries to create.  (Group by table name - get_mysql_tablename return the tablename to use)
    entrieslist_redcap_queue = groupby(
        transaction.redcap_queue,
        lambda f: get_mysql_tablename(transaction.redcap_metadata, f[0]),
    )

    # For each table - (insert entries/lines).
    for tablename_redcap_queue, entries_redcap_queue in entrieslist_redcap_queue:

        # Get the list of metadata for a specific tablename - x[3] is the tablename.
        table_redcap_metadata = [
            x for x in transaction.redcap_metadata
            if x[3] == tablename_redcap_queue
        ]

        # For each entries / lines to add inside the database.
        for fields in entries_redcap_queue:

            # For each field we need to check if it's already inside the metadata.
            for fieldname, fieldvalue in fields[0].items():

                # Preparing vars.
                found = False

                # For each field inside the current metadata, check if the field already exist.
                for field in table_redcap_metadata:

                    # If this is the current field that we are looking for. (Flag found to true and exit loop)
                    if field[0] == fieldname:
                        found = True
                        break

                # If not found, then we need to add metadata.
                if found == False:
                    data = [
                        fieldname,
                        convert_redcap_to_mysql_fieldtype("text"),
                        fieldname,
                        tablename_redcap_queue,
                    ]
                    table_redcap_metadata.append(data)
                    transaction.redcap_metadata.append(data)

    # We need to order the redcap_metadata using tablename - f[3]
    # Otherwise group will not work.
    transaction.redcap_metadata = sorted(transaction.redcap_metadata,
                                         key=lambda f: f[3])

    # Return the updated repcap transaction (stage 5)
    return transaction
Example #2
0
def load_metadata(transaction: RedcapTransaction) -> RedcapTransaction:
    """
    Get all information about REDCap form names and fields.
    :return: RedcapTransaction
    """
    transaction.redcap_metadata = []

    # For each REDCap project
    for p in Project:

        # Get all metadata rows.
        payload = {
            "token": get_project_token(p.name),
            "format": "json",
            "content": "metadata",
        }
        response = post(redcap_api_url, data=payload)
        metadata = response.json()

        # Add each metadata row to a local list.
        for field in metadata:
            transaction.redcap_metadata.append([
                field["field_name"],
                field["field_type"],
                field["field_label"],
                field["form_name"],
            ])

    return transaction
Example #3
0
def get_data_rows_for_patient_table(table_info,
                                    transaction: RedcapTransaction) -> list:
    """
    Gets all rows of data for a specific patient table.
    :param table_info: Table Information
    :param transaction: RedcapTransaction
    :return: List of all the rows obtained from the query or None if table not found.
    """
    if table_info is None:
        return None

    if table_info[DATABASE_TABLE_NAME] == "":
        return None

    primary_key_filter_name = str(
        get_primary_key_name(table_info[PRIMARY_KEY_NAME]))
    primary_key_filter_value = str(
        transaction.get_primary_key_value(table_info[PRIMARY_KEY_VALUE]))
    primary_key_data_type = get_primary_key_data_type(
        table_info[PRIMARY_KEY_VALUE])

    if (primary_key_filter_name == "" or primary_key_filter_value == ""
            or primary_key_filter_value == "None"):
        return None

    if primary_key_data_type == DataType.String.value:
        select_statement = ("SELECT * FROM [" +
                            table_info[DATABASE_TABLE_NAME] + "] WHERE [" +
                            primary_key_filter_name + "] = '" +
                            primary_key_filter_value + "'")
    elif primary_key_data_type == DataType.Integer.value:
        select_statement = ("SELECT * FROM [" +
                            table_info[DATABASE_TABLE_NAME] + "] WHERE [" +
                            primary_key_filter_name + "] = " +
                            primary_key_filter_value)
    else:
        select_statement = ""

    if select_statement != "":

        conn = pyodbc.connect(get_connection_string(table_info[DATABASE]))
        odbc_cursor = conn.cursor()

        odbc_cursor.execute(select_statement)

        data = odbc_cursor.fetchall()

        odbc_cursor.close()
        conn.close

        return data

    else:
        return None
Example #4
0
def send_data(transaction: RedcapTransaction) -> (bool, str):
    """
    Sends all records in the queue to REDCap.
    :return: Successful or not and reason
    """

    # If there is at least one record in the queue waiting to be sent to REDCap
    if not len(transaction.redcap_queue) > 0:
        return False, "REDCap queue is empty."

    # Sort record queue by second column ascending (project).
    transaction.redcap_queue = sorted(transaction.redcap_queue,
                                      key=itemgetter(1))

    # For each REDCap project
    for p in Project:

        batch_of_records = []

        # For each record in the global queue
        for index_record in range(len(transaction.redcap_queue)):

            # If the current record belongs to the current project
            if transaction.redcap_queue[index_record][1] == p.value:

                # We add this record to the batch of records to send.
                batch_of_records.append(
                    transaction.redcap_queue[index_record][0])

                # If the maximum number of records per batch has been reached
            if (len(batch_of_records)
                ) % environment.NUMBER_OF_RECORDS_PER_BATCH == 0:
                # Send the batch of records to REDCap.
                import_records(batch_of_records, get_project_token(p.name))

        # Send the batch of records to REDCap.
        import_records(batch_of_records, get_project_token(p.name))

    return True, "All REDCap data in queue has been sent. "
Example #5
0
def get_case_ids(transaction: RedcapTransaction) -> List[int]:
    """
    Get Case Ids
    :param transaction: RedcapTransaction
    :return: List of all the case ids related to the current hospital record number or None if table not found.
    """

    case_ids = []

    primary_key_filter_name = Field.HospitalRecordNumber.name
    primary_key_filter_value = str(
        transaction.get_primary_key_value(Field.HospitalRecordNumber.value))

    if (primary_key_filter_name == "" or primary_key_filter_value == ""
            or primary_key_filter_value == "None"):
        return None

    select_statement = ("SELECT [CaseId] FROM [Admission] WHERE [" +
                        primary_key_filter_name + "] = '" +
                        primary_key_filter_value + "'")

    conn = pyodbc.connect(get_connection_string(1))
    odbc_cursor = conn.cursor()

    odbc_cursor.execute(select_statement)

    data = odbc_cursor.fetchall()

    for index_case_id in range(len(data)):

        # Add Case Id to list of Case Ids.
        case_ids.append(data[index_case_id][0])

    odbc_cursor.close()
    conn.close

    return case_ids
Example #6
0
def prepare_patient_tables(transaction: RedcapTransaction) -> RedcapTransaction:
    """
    Creates REDCap records for of all patient tables and adds them to the global queue (only for each hospital record
    number loaded).
    :param transaction: RedcapTransaction
    :return: RedcapTransaction
    """

    # For each hospital record number
    for index_hospital_record_number in range(len(transaction.hospital_record_numbers)):

        # Set hospital record number.
        transaction.set_hospital_record_number(index_hospital_record_number)

        # Set any additional id that has a 1 to 1 relationship with the hospital record number.
        transaction.set_cnbp_id(get_CNBP(transaction.HospitalRecordNumber))

        # Get all case ids related to this Hospital Record Number
        cases = get_case_ids(transaction)

        # If no data was retrieved from the database, skip.
        if cases is None:
            return

        # Record caseIDs
        set_CNNIDs(transaction.HospitalRecordNumber, cases)

        # For each case related to this Hospital Record Number
        for index_case in range(len(cases)):

            # Set case id.
            transaction.set_case_id(cases[index_case])

            process_case(transaction)

    return transaction
Example #7
0
def update_redcap_data() -> None:
    """
    This method is the main method of this script. It calls all methods necessary to transfer CNN and CNFUN data
    to REDCap.
    :return: None
    """

    # Indicate that the script is started.
    logger.info("Update REDCap Data Started: " + str(datetime.datetime.now()))

    # Initialize the RedcapTransaction class object to be past and returned each step of the way.
    transaction_stage0 = RedcapTransaction()

    # Load data import configuration matrix.
    logger.info("Loading Data Import Configuration...")
    transaction_stage1_initialized = initialize_import_configuration(
        transaction_stage0)
    logger.info("Done.")

    # Check if we have something to export.
    if not mysql_export_enabled and not redcap_export_enabled:
        logger.info(
            "Nothing need to be exported! REDCAP_EXPORT_ENABLED & MYSQL_EXPORT_ENABLED is false. Please check your configuration file."
        )
        return

    # Get all information about REDCap table names and fields.
    logger.info("Loading REDCap Metadata...")
    transaction_stage2_meta_added = load_metadata(
        transaction_stage1_initialized)
    logger.info("Done.")

    # Get all hospital record numbers.
    logger.info("Loading Hospital Record Numbers...")
    # Change this flag in environment module or here to force local of DB loading.
    transaction_stage2_meta_added.hospital_record_numbers = load_hospital_record_numbers(
        environment.USE_LOCAL_HOSPITAL_RECORD_NUMBERS_LIST)
    logger.info("Done.")

    # Prepare Reference Data.
    logger.info("Preparing Reference Data Transfer...")
    transaction_stage3_references_added = prepare_reference_tables(
        transaction_stage2_meta_added)
    logger.info("Done.")

    # Prepare Patient Data.
    logger.info("Preparing Patient Data Transfer...")
    transaction_stage4_patients_added = prepare_patient_tables(
        transaction_stage3_references_added)
    logger.info("Done.")

    # If Redcap export is enabled, then we need to export the data.
    if redcap_export_enabled:

        # Indicate that the script is started.
        logger.info("Update REDCap Data Started: " +
                    str(datetime.datetime.now()))

        # Wipe all existing data from REDCap.
        logger.info("Wiping ALL existing data from REDCap...")
        wipe_all_redcap_data()
        logger.info("Done.")

        # Send data to REDCap.
        logger.info("Sending ALL data to REDCap...")
        send_data(transaction_stage4_patients_added)
        logger.info("Done.")

        # Indicate that the script is completed.
        logger.info("Update REDCap Data Completed: " +
                    str(datetime.datetime.now()))

    # If MySQL export is enabled, then we need to export the data to MySQL.
    if mysql_export_enabled:

        # Wiping old MySQL data.
        logger.info("Wiping ALL existing data from MySQL...")
        wipe_all_mysql_data()
        logger.info("Done.")

        # Preparing mysql metadata.
        logger.info("Preparing mysql metadata...")
        transaction_stage_5_metadata = prepare_mysql_metadata_stage5(
            transaction_stage4_patients_added)
        logger.info("Done.")

        # Send data to MySQL.
        logger.info("Sending ALL data to MySQL...")
        send_mysql_data(transaction_stage_5_metadata)
        logger.info("Done.")

    return
Example #8
0
    def test_load_metadata() -> None:
        from DICOMTransit.redcap.transaction import RedcapTransaction
        from DICOMTransit.redcap.query import load_metadata

        transact = RedcapTransaction()
        load_metadata(transact)
Example #9
0
def initialize_import_configuration(
        transaction: RedcapTransaction) -> RedcapTransaction:
    """
    Initialize the data import configuration matrix.
    Columns:
        0  IMPORT_SEQUENCE,
        1  IS_IMPORT_ENABLED,
        2  IS_REFERENCE_TABLE,
        3  REDCAP_PROJECT,
        4  DATABASE_TABLE_NAME,
        5  DATABASE,
        6  PRIMARY_KEY_NAME,
        7  PRIMARY_KEY_VALUE,
        8  AUTHORITY_ON_IDS,
        9  IS_REPEATABLE_INSTRUMENT,
        10 REDCAP_FORM_NAME
    :return: RedcapTransaction
    """

    transaction.data_import_configuration = [
        [1, 1, 0, 1, "admission", 1, 2, 2, [3], 0, "admission"],
        [2, 1, 0, 1, "admissionChart", 1, 2, 2, None, 1, "admissionChart"],
        [3, 1, 0, 1, "admissionstate", 1, 2, 2, None, 1, "admissionstate"],
        [4, 1, 0, 1, "Born", 1, 2, 2, None, 1, "Born"],
        [5, 1, 0, 1, "Borndiagnosis", 1, 2, 2, None, 1, "Borndiagnosis"],
        [6, 1, 0, 1, "Caffeine", 1, 2, 2, None, 1, "Caffeine"],
        [
            7, 1, 0, 1, "Congenitalanomalies", 1, 2, 2, None, 1,
            "Congenitalanomalies"
        ],
        [
            8, 1, 0, 1, "Culturestransfusions", 1, 2, 2, None, 1,
            "Culturestransfusions"
        ],
        [
            9, 1, 0, 1, "Diagnosisofinfection", 1, 2, 2, None, 1,
            "Diagnosisofinfection"
        ],
        [
            10, 1, 0, 1, "Diagnosisprocedures", 1, 2, 2, None, 1,
            "Diagnosisprocedures"
        ],
        [11, 1, 0, 1, "Discharge", 1, 2, 2, None, 1, "Discharge"],
        [12, 1, 0, 1, "Encephalopathy", 1, 2, 2, None, 1, "Encephalopathy"],
        [13, 1, 0, 1, "Eol", 1, 2, 2, None, 1, "Eol"],
        [
            14, 1, 0, 1, "Epiqcentrallines", 1, 2, 2, None, 1,
            "Epiqcentrallines"
        ],
        [15, 1, 0, 1, "Formreviewed", 1, 2, 2, None, 1, "Formreviewed"],
        [16, 1, 0, 1, "Ivh", 1, 2, 2, None, 1, "Ivh"],
        [17, 1, 0, 1, "Nropexams", 1, 2, 2, None, 1, "Nropexams"],
        [18, 1, 0, 1, "Nroptreatments", 1, 2, 2, None, 1, "Nroptreatments"],
        [19, 1, 0, 1, "Ntiss1", 1, 2, 2, None, 1, "Ntiss1"],
        [20, 1, 0, 1, "Ntiss3", 1, 2, 2, None, 1, "Ntiss3"],
        [21, 1, 0, 1, "Otherdiagnosis", 1, 2, 2, None, 1, "Otherdiagnosis"],
        [22, 1, 0, 1, "Pdatreatment", 1, 2, 2, None, 1, "Pdatreatment"],
        [
            23, 1, 0, 1, "Posbloodcsfcultures", 1, 2, 2, None, 1,
            "Posbloodcsfcultures"
        ],
        [
            24, 1, 0, 1, "Postnatalsteroids", 1, 2, 2, None, 1,
            "Postnatalsteroids"
        ],
        [25, 1, 0, 1, "Posttransfer", 1, 2, 2, None, 1, "Posttransfer"],
        [26, 1, 0, 1, "Rop", 1, 2, 2, None, 1, "Rop"],
        [27, 1, 0, 1, "Screenlog", 1, 2, 2, None, 1, "Screenlog"],
        [28, 1, 0, 1, "Snap", 1, 2, 2, None, 1, "Snap"],
        [29, 1, 0, 1, "Surfactant", 1, 2, 2, None, 1, "Surfactant"],
        [30, 1, 0, 1, "Transport", 1, 2, 2, None, 1, "Transport"],
        [31, 1, 0, 1, "Trips", 1, 2, 2, None, 1, "Trips"],
        [32, 1, 0, 1, "Validate", 1, 2, 2, None, 1, "Validate"],
        [33, 1, 0, 2, "Baby", 1, 3, 3, [4, 5], 0, "Baby"],
        [34, 1, 0, 2, "Bornbaby", 1, 3, 3, None, 1, "Bornbaby"],
        [35, 1, 0, 2, "Epiq", 1, 3, 3, None, 1, "Epiq"],
        [36, 1, 0, 2, "Resuscitation", 1, 3, 3, None, 1, "Resuscitation"],
        [
            37,
            1,
            0,
            2,
            "Antenatalinterventions",
            1,
            3,
            3,
            None,
            1,
            "Antenatalinterventions",
        ],
        [38, 1, 0, 3, "Mother", 1, 4, 4, None, 0, "Mother"],
        [
            39,
            1,
            0,
            3,
            "Antenatalintervention",
            1,
            4,
            4,
            None,
            1,
            "Antenatalintervention",
        ],
        [40, 1, 0, 3, "Bornmother", 1, 4, 4, None, 1, "Bornmother"],
        [41, 1, 0, 4, "Patients", 2, 6, 5, [7], 0, "Patients"],
        [
            42,
            1,
            0,
            4,
            "18MonthAssessments",
            2,
            7,
            7,
            None,
            1,
            "EighteenMonthAssessments",
        ],
        [
            43,
            1,
            0,
            4,
            "36MonthAssessments",
            2,
            7,
            7,
            None,
            1,
            "ThirtySixMonthAssessments",
        ],
        [
            44, 1, 0, 4, "36MonthStatus", 2, 7, 7, None, 1,
            "ThirtySixMonthStatus"
        ],
        [
            45,
            1,
            0,
            4,
            "3YearAuditoryAssessments",
            2,
            7,
            7,
            None,
            1,
            "ThreeYearAuditoryAssessments",
        ],
        [
            46, 1, 0, 4, "3YearFamilyInfo", 2, 7, 7, None, 1,
            "ThreeYearFamilyInfo"
        ],
        [
            47,
            1,
            0,
            4,
            "3YearMedicalHistories",
            2,
            7,
            7,
            None,
            1,
            "ThreeYearMedicalHistories",
        ],
        [
            48,
            1,
            0,
            4,
            "3YearPrimaryCaregivers",
            2,
            7,
            7,
            None,
            1,
            "ThreeYearPrimaryCaregivers",
        ],
        [
            49,
            1,
            0,
            4,
            "3YearVisionAssessments",
            2,
            7,
            7,
            None,
            1,
            "ThreeYearVisionAssessments",
        ],
        [
            50, 1, 0, 4, "AuditoryAssessments", 2, 7, 7, None, 1,
            "AuditoryAssessments"
        ],
        [51, 1, 0, 4, "FamilyInfo", 2, 7, 7, None, 1, "FamilyInfo"],
        [52, 1, 0, 4, "FollowupReasons", 2, 7, 7, None, 1, "FollowupReasons"],
        [
            53, 1, 0, 4, "MedicalHistories", 2, 7, 7, None, 1,
            "MedicalHistories"
        ],
        [
            54, 1, 0, 4, "PrimaryCaregivers", 2, 7, 7, None, 1,
            "PrimaryCaregivers"
        ],
        [
            55,
            1,
            0,
            4,
            "PsychologicalExaminations",
            2,
            7,
            7,
            None,
            1,
            "PsychologicalExaminations",
        ],
        [
            56, 1, 0, 4, "VisionAssessments", 2, 7, 7, None, 1,
            "VisionAssessments"
        ],
        [
            57, 1, 1, 5, "mstadmissioncasetype", 1, 8, 8, None, 1,
            "mstadmissioncasetype"
        ],
        [
            58,
            1,
            1,
            5,
            "mstadmissioninfantsex",
            1,
            8,
            8,
            None,
            1,
            "mstadmissioninfantsex",
        ],
        [
            59, 1, 1, 5, "mstadmissioninternal", 1, 8, 8, None, 1,
            "mstadmissioninternal"
        ],
        [
            60, 1, 1, 5, "mstadmissionpayor", 1, 8, 8, None, 1,
            "mstadmissionpayor"
        ],
        [
            61, 1, 1, 5, "mstadmissionstat", 1, 8, 8, None, 1,
            "mstadmissionstat"
        ],
        [
            62,
            1,
            1,
            5,
            "mstborncordbloodteststatus",
            1,
            8,
            8,
            None,
            1,
            "mstborncordbloodteststatus",
        ],
        [
            63, 1, 1, 5, "mstborncountries", 1, 8, 8, None, 1,
            "mstborncountries"
        ],
        [
            64,
            1,
            1,
            5,
            "mstborndrugscreenresult",
            1,
            8,
            8,
            None,
            1,
            "mstborndrugscreenresult",
        ],
        [
            65,
            1,
            1,
            5,
            "mstbornhealthcardtype",
            1,
            8,
            8,
            None,
            1,
            "mstbornhealthcardtype",
        ],
        [
            66,
            1,
            1,
            5,
            "mstbornnewbornfeeding",
            1,
            8,
            8,
            None,
            1,
            "mstbornnewbornfeeding",
        ],
        [
            67,
            1,
            1,
            5,
            "mstbornscreeningoffered",
            1,
            8,
            8,
            None,
            1,
            "mstbornscreeningoffered",
        ],
        [68, 1, 1, 5, "mstbornynu", 1, 8, 8, None, 1, "mstbornynu"],
        [69, 1, 1, 5, "mstbpdgrade", 1, 8, 8, None, 1, "mstbpdgrade"],
        [70, 1, 1, 5, "mstcities", 1, 8, 8, None, 1, "mstcities"],
        [71, 1, 1, 5, "mstcitygroups", 1, 8, 8, None, 1, "mstcitygroups"],
        [
            72, 1, 1, 5, "mstcnfunhospitallist", 1, 8, 8, None, 1,
            "mstcnfunhospitallist"
        ],
        [
            73, 1, 1, 5, "mstculturesculture", 1, 8, 8, None, 1,
            "mstculturesculture"
        ],
        [
            74, 1, 1, 5, "mstculturesdiagnosis", 1, 8, 8, None, 1,
            "mstculturesdiagnosis"
        ],
        [
            75, 1, 1, 5, "mstculturesorganism", 1, 8, 8, None, 1,
            "mstculturesorganism"
        ],
        [
            76,
            1,
            1,
            5,
            "mstdiagnosiscongenitaltype",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosiscongenitaltype",
        ],
        [
            77,
            1,
            1,
            5,
            "mstdiagnosisdiagnosistype",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosisdiagnosistype",
        ],
        [78, 1, 1, 5, "mstdiagnosishie", 1, 8, 8, None, 1, "mstdiagnosishie"],
        [
            79,
            1,
            1,
            5,
            "mstdiagnosisintperforation",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosisintperforation",
        ],
        [
            80,
            1,
            1,
            5,
            "mstdiagnosisnecstages",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosisnecstages",
        ],
        [
            81, 1, 1, 5, "mstdiagnosispdayes", 1, 8, 8, None, 1,
            "mstdiagnosispdayes"
        ],
        [82, 1, 1, 5, "mstdiagnosisrds", 1, 8, 8, None, 1, "mstdiagnosisrds"],
        [
            83, 1, 1, 5, "mstdiagnosisseizures", 1, 8, 8, None, 1,
            "mstdiagnosisseizures"
        ],
        [
            84,
            1,
            1,
            5,
            "mstdiagnosisthrombosislocationarterial",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosisthrombosislocationarterial",
        ],
        [
            85,
            1,
            1,
            5,
            "mstdiagnosisthrombosislocationvenous",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosisthrombosislocationvenous",
        ],
        [
            86,
            1,
            1,
            5,
            "mstdiagnosisthrombosismethod",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosisthrombosismethod",
        ],
        [
            87,
            1,
            1,
            5,
            "mstdiagnosisthrombosistreatment",
            1,
            8,
            8,
            None,
            1,
            "mstdiagnosisthrombosistreatment",
        ],
        [
            88,
            1,
            1,
            5,
            "mstdischargedestination",
            1,
            8,
            8,
            None,
            1,
            "mstdischargedestination",
        ],
        [
            89,
            1,
            1,
            5,
            "mstdischargeinpatientarea",
            1,
            8,
            8,
            None,
            1,
            "mstdischargeinpatientarea",
        ],
        [
            90, 1, 1, 5, "mstdischargeresult", 1, 8, 8, None, 1,
            "mstdischargeresult"
        ],
        [
            91,
            1,
            1,
            5,
            "mstencephalopathyclinicalstatus",
            1,
            8,
            8,
            None,
            1,
            "mstencephalopathyclinicalstatus",
        ],
        [
            92,
            1,
            1,
            5,
            "mstencephalopathyclinicalstatusatcompletion",
            1,
            8,
            8,
            None,
            1,
            "mstencephalopathyclinicalstatusatcompletion",
        ],
        [
            93,
            1,
            1,
            5,
            "mstencephalopathymethod",
            1,
            8,
            8,
            None,
            1,
            "mstencephalopathymethod",
        ],
        [
            94,
            1,
            1,
            5,
            "mstencephalopathyreasonxprematurediscont",
            1,
            8,
            8,
            None,
            1,
            "mstencephalopathyreasonxprematurediscont",
        ],
        [
            95,
            1,
            1,
            5,
            "mstencephalopathytargettemp",
            1,
            8,
            8,
            None,
            1,
            "mstencephalopathytargettemp",
        ],
        [96, 1, 1, 5, "msteol", 1, 8, 8, None, 1, "msteol"],
        [
            97, 1, 1, 5, "mstepiqchecklistused", 1, 8, 8, None, 1,
            "mstepiqchecklistused"
        ],
        [98, 1, 1, 5, "mstfacilitytype", 1, 8, 8, None, 1, "mstfacilitytype"],
        [99, 1, 1, 5, "msthospitals", 1, 8, 8, None, 1, "msthospitals"],
        [100, 1, 1, 5, "mstivhresponse", 1, 8, 8, None, 1, "mstivhresponse"],
        [
            101, 1, 1, 5, "mstivhventricular", 1, 8, 8, None, 1,
            "mstivhventricular"
        ],
        [
            102, 1, 1, 5, "mstmotherantecort", 1, 8, 8, None, 1,
            "mstmotherantecort"
        ],
        [
            103,
            1,
            1,
            5,
            "mstmotheranteintervention",
            1,
            8,
            8,
            None,
            1,
            "mstmotheranteintervention",
        ],
        [
            104,
            1,
            1,
            5,
            "mstmotherdeliverytype",
            1,
            8,
            8,
            None,
            1,
            "mstmotherdeliverytype",
        ],
        [
            105, 1, 1, 5, "mstmotherdiabetes", 1, 8, 8, None, 1,
            "mstmotherdiabetes"
        ],
        [
            106, 1, 1, 5, "mstmotherethnicity", 1, 8, 8, None, 1,
            "mstmotherethnicity"
        ],
        [
            107,
            1,
            1,
            5,
            "mstmotherhypertension",
            1,
            8,
            8,
            None,
            1,
            "mstmotherhypertension",
        ],
        [
            108, 1, 1, 5, "mstmotherlabourinit", 1, 8, 8, None, 1,
            "mstmotherlabourinit"
        ],
        [
            109,
            1,
            1,
            5,
            "mstmotherpresentation",
            1,
            8,
            8,
            None,
            1,
            "mstmotherpresentation",
        ],
        [110, 1, 1, 5, "mstmotherrom", 1, 8, 8, None, 1, "mstmotherrom"],
        [
            111,
            1,
            1,
            5,
            "mstmothertotalacgiven",
            1,
            8,
            8,
            None,
            1,
            "mstmothertotalacgiven",
        ],
        [
            112,
            1,
            1,
            5,
            "mstnropcomplications",
            1,
            8,
            8,
            None,
            1,
            "mstnropcomplications",
        ],
        [
            113, 1, 1, 5, "mstnropdurations", 1, 8, 8, None, 1,
            "mstnropdurations"
        ],
        [114, 1, 1, 5, "mstnropfollowup", 1, 8, 8, None, 1, "mstnropfollowup"],
        [115, 1, 1, 5, "mstnropplus", 1, 8, 8, None, 1, "mstnropplus"],
        [116, 1, 1, 5, "mstnropstage", 1, 8, 8, None, 1, "mstnropstage"],
        [
            117,
            1,
            1,
            5,
            "mstnroptreatmenteyes",
            1,
            8,
            8,
            None,
            1,
            "mstnroptreatmenteyes",
        ],
        [
            118,
            1,
            1,
            5,
            "mstnroptreatmentlocations",
            1,
            8,
            8,
            None,
            1,
            "mstnroptreatmentlocations",
        ],
        [
            119,
            1,
            1,
            5,
            "mstnroptreatmenttypes",
            1,
            8,
            8,
            None,
            1,
            "mstnroptreatmenttypes",
        ],
        [120, 1, 1, 5, "mstnropzone", 1, 8, 8, None, 1, "mstnropzone"],
        [
            121, 1, 1, 5, "mstntissantibiotics", 1, 8, 8, None, 1,
            "mstntissantibiotics"
        ],
        [
            122, 1, 1, 5, "mstntisschesttube", 1, 8, 8, None, 1,
            "mstntisschesttube"
        ],
        [
            123, 1, 1, 5, "mstntisspacemaker", 1, 8, 8, None, 1,
            "mstntisspacemaker"
        ],
        [
            124,
            1,
            1,
            5,
            "mstntisstracheostomy",
            1,
            8,
            8,
            None,
            1,
            "mstntisstracheostomy",
        ],
        [125, 1, 1, 5, "mstpatientchart", 1, 8, 8, None, 1, "mstpatientchart"],
        [126, 1, 1, 5, "mstpdatreatment", 1, 8, 8, None, 1, "mstpdatreatment"],
        [
            127,
            1,
            1,
            5,
            "mstpostnatalsteroidsindication",
            1,
            8,
            8,
            None,
            1,
            "mstpostnatalsteroidsindication",
        ],
        [
            128,
            1,
            1,
            5,
            "mstpostnatalsteroidsroute",
            1,
            8,
            8,
            None,
            1,
            "mstpostnatalsteroidsroute",
        ],
        [
            129,
            1,
            1,
            5,
            "mstpostnatalsteroidstype",
            1,
            8,
            8,
            None,
            1,
            "mstpostnatalsteroidstype",
        ],
        [
            130,
            1,
            1,
            5,
            "mstpostnatalsteroidstypeindication",
            1,
            8,
            8,
            None,
            1,
            "mstpostnatalsteroidstypeindication",
        ],
        [
            131, 1, 1, 5, "mstposttransferdest", 1, 8, 8, None, 1,
            "mstposttransferdest"
        ],
        [132, 1, 1, 5, "mstprovinces", 1, 8, 8, None, 1, "mstprovinces"],
        [133, 1, 1, 5, "mstresponse", 1, 8, 8, None, 1, "mstresponse"],
        [
            134,
            1,
            1,
            5,
            "mstresponsetostimuli",
            1,
            8,
            8,
            None,
            1,
            "mstresponsetostimuli",
        ],
        [135, 1, 1, 5, "mstrespstatus", 1, 8, 8, None, 1, "mstrespstatus"],
        [
            136,
            1,
            1,
            5,
            "mstresuscitationinitialgas",
            1,
            8,
            8,
            None,
            1,
            "mstresuscitationinitialgas",
        ],
        [137, 1, 1, 5, "mstropplus", 1, 8, 8, None, 1, "mstropplus"],
        [138, 1, 1, 5, "mstropstage", 1, 8, 8, None, 1, "mstropstage"],
        [
            139, 1, 1, 5, "mstroptreatmenteye", 1, 8, 8, None, 1,
            "mstroptreatmenteye"
        ],
        [
            140, 1, 1, 5, "mstroptreatmenttype", 1, 8, 8, None, 1,
            "mstroptreatmenttype"
        ],
        [141, 1, 1, 5, "mstropzone", 1, 8, 8, None, 1, "mstropzone"],
        [
            142,
            1,
            1,
            5,
            "mstsearchgridcolumns",
            1,
            8,
            8,
            None,
            1,
            "mstsearchgridcolumns",
        ],
        [
            143,
            1,
            1,
            5,
            "mstsnapeffectivefio2",
            1,
            8,
            8,
            None,
            1,
            "mstsnapeffectivefio2",
        ],
        [144, 1, 1, 5, "mstsnapfactor", 1, 8, 8, None, 1, "mstsnapfactor"],
        [145, 1, 1, 5, "mstsnapseizures", 1, 8, 8, None, 1, "mstsnapseizures"],
        [
            146, 1, 1, 5, "mstsurfactanttype", 1, 8, 8, None, 1,
            "mstsurfactanttype"
        ],
        [147, 1, 1, 5, "mstsystolicbp", 1, 8, 8, None, 1, "mstsystolicbp"],
        [148, 1, 1, 5, "msttemperature", 1, 8, 8, None, 1, "msttemperature"],
        [149, 1, 1, 5, "mstvegfdrugs", 1, 8, 8, None, 1, "mstvegfdrugs"],
    ]

    # Sort data import configuration matrix by first column ascending (import sequence).
    transaction.data_import_configuration = sorted(
        transaction.data_import_configuration, key=itemgetter(0))

    return transaction
Example #10
0
    def test_send_mysql_data() -> None:

        # Test empty / no redcap transaction.
        assert send_mysql_data(RedcapTransaction())[0] is False