예제 #1
0
def main(config):

    setup_logging()
    logger.info('ETL version {}'.format(__version__))

    config = MainConfig(**read_yaml_file(Path(config)))

    # Initialize ETL with configuration parameters
    etl = Wrapper(config)

    etl.run()
예제 #2
0
def main(database, username, password, hostname, port, source, debug,
         skipvocab):
    setup_logging(debug)

    # Test database connection
    uri = f'postgresql://{username}:{password}@{hostname}:{port}/{database}'
    if not Database.can_connect(uri):
        return

    db = Database(uri)
    etl = Wrapper(db, source, './resources/mapping_tables', skipvocab)

    logger.info('ETL version {}'.format(__version__))
    # if etl.is_git_repo():
    #     logger.info('Git HEAD at ' + etl.get_git_tag_or_branch())

    # Run ETL
    try:
        etl.run()
    except Exception as err:
        logger.error('##### FATAL ERROR. TRACEBACK: #####')
        logger.error(traceback.format_exc())
        raise err
예제 #3
0
        else:
            death_datetime = None

        record = Person(
            person_id=int(row['p_id']),
            person_source_value=row['p_id'],
            year_of_birth=int(row['year_birth']),
            death_datetime=death_datetime,
            gender_concept_id=8507,  # Always male
            race_concept_id=0,
            ethnicity_concept_id=0,
            gender_source_concept_id=0,
            race_source_concept_id=0,
            ethnicity_source_concept_id=0)
        records_to_insert.append(record)

    return records_to_insert


if __name__ == '__main__':
    from src.main.python.database.database import Database
    from src.main.python.wrapper import Wrapper

    db = Database(f'postgresql://postgres@localhost:5432/postgres'
                  )  # A mock database object
    w = Wrapper(db, '../../../../resources/source_data',
                '../../../../resources/mapping_tables')

    for x in basedata_to_person(w):
        print(x.__dict__)
예제 #4
0
def cdm_source(wrapper) -> list:

    with wrapper.db.session_scope() as session:
        records_to_insert = []

        # Get vocabulary info
        vocab_info = session.query(Vocabulary).filter_by(
            vocabulary_id='None').one()

        record = CdmSource(
            cdm_source_name='PRIAS',
            cdm_etl_reference='https://github.com/thehyve/ohdsi-etl-prias',
            cdm_release_date=date.today(),
            cdm_version='v6.x',
            vocabulary_version=vocab_info.vocabulary_version)

        records_to_insert.append(record)

    return records_to_insert


if __name__ == '__main__':
    from src.main.python.database.database import Database
    from src.main.python.wrapper import Wrapper

    db = Database(f'postgresql://postgres@localhost:5432/postgres'
                  )  # A mock database object
    w = Wrapper(db, '../../../../resources/source_data')
    for x in cdm_source(w):
        print(x.__dict__)