def LochnessMetadataInitialized(args_and_Lochness): args, Lochness = args_and_Lochness # before initializing metadata for study in args.studies: phoenix_path = Path(Lochness['phoenix_root']) general_path = phoenix_path / 'GENERAL' metadata = general_path / study / f"{study}_metadata.csv" initialize_metadata(Lochness, study, 'record_id1', 'cons_date') return Lochness
def test_initialize_metadata_update_when_initialized_again( LochnessMetadataInitialized): args = Args('tmp_lochness') for study in args.studies: phoenix_path = Path(LochnessMetadataInitialized['phoenix_root']) general_path = phoenix_path / 'GENERAL' metadata = general_path / study / f"{study}_metadata.csv" prev_st_mtime = metadata.stat().st_mtime initialize_metadata(LochnessMetadataInitialized, study, 'record_id1', 'cons_date') post_st_mtime = metadata.stat().st_mtime assert prev_st_mtime < post_st_mtime
def test_initialize_metadata_then_sync(args_and_Lochness): args, Lochness = args_and_Lochness # before initializing metadata for study in args.studies: phoenix_path = Path(Lochness['phoenix_root']) general_path = phoenix_path / 'GENERAL' metadata = general_path / study / f"{study}_metadata.csv" initialize_metadata(Lochness, study, 'record_id1', 'cons_date') for subject in lochness.read_phoenix_metadata(Lochness, studies=['StudyA']): sync(Lochness, subject, False) show_tree_then_delete('tmp_lochness')
def test_initialize_metadata_function_adding_new_data_to_csv( args_and_Lochness): args, Lochness = args_and_Lochness # before initializing metadata for study in args.studies: phoenix_path = Path(Lochness['phoenix_root']) general_path = phoenix_path / 'GENERAL' metadata = general_path / study / f"{study}_metadata.csv" assert len(pd.read_csv(metadata)) == 1 initialize_metadata(Lochness, study, 'record_id1', 'cons_date') assert len(pd.read_csv(metadata)) > 3 rmtree('tmp_lochness')
def initialize_metadata(Lochness, args) -> None: '''Create (overwrite) metadata.csv using either REDCap or RPMS database''' for study_name in args.studies: # if 'redcap' or 'rpms' is in the sources, create (overwrite) if 'redcap' in args.sources: id_fieldname = 'record_id1' consent_fieldname = 'Consent' REDCap.initialize_metadata( Lochness, study_name, id_fieldname, consent_fieldname) elif 'rpms' in args.sources: # metadata.csv id_fieldname = 'record_id1' consent_fieldname = 'Consent' RPMS.initialize_metadata( Lochness, study_name, id_fieldname, consent_fieldname) else: pass