コード例 #1
0
ファイル: test_unit.py プロジェクト: hchauvin/rwd_analytics
 def test_observation_period(self):
     cohort_definition = {
         'demographic_criteria': {
             'min_year_of_birth': None,
             'max_year_of_birth': None,
             'gender_concept_id': None
         },
         'criteria_list': [{
             'concept_type': 'condition_occurrence',
             'concept_id': [44831230],
             'is_excluded': 0,
             'get_descendants': 0,
             'occurrence_start_date': None,
             'occurrence_end_date': None,
             'min_occurrence': None,
             'min_duration': None,
             'is_before_previous_criteria': None,
             'is_after_previous_criteria': None
         }],
         'observation_period_criteria': {
             'before_index': 365,
             'after_index': None
         }
     }
     output = CohortBuilder(cohort_definition, omop_tables)()
     output = output.reset_index(drop=True)
     expected = pd.DataFrame({
         'person_id': [1],
         'index_date': [pd.to_datetime('2017-12-10')]
     })
     pd.testing.assert_frame_equal(output, expected)
コード例 #2
0
ファイル: test_unit.py プロジェクト: hchauvin/rwd_analytics
    def test_attributes_min_length(self):
        drug_exposure = pd.DataFrame({
            'person_id': [1, 1, 1, 1, 2, 2],
            'drug_concept_id': [10, 10, 30, 40, 10, 20],
            'drug_exposure_start_datetime': [
                pd.to_datetime('2018-12-10'),
                pd.to_datetime('2017-12-10'),
                pd.to_datetime('2017-12-10'),
                pd.to_datetime('2017-12-10'),
                pd.to_datetime('2017-12-10'),
                pd.to_datetime('2017-12-10'),
            ]
        })
        drug_exposure = dd.from_pandas(drug_exposure,
                                       npartitions=1).set_index('person_id')
        cohort_definition = {
            'demographic_criteria': {
                'min_year_of_birth': None,
                'max_year_of_birth': None,
                'gender_concept_id': None
            },
            'criteria_list': [{
                'concept_type': 'drug_exposure',
                'concept_id': [10],
                'is_excluded': 0,
                'get_descendants': 0,
                'occurrence_start_date': None,
                'occurrence_end_date': None,
                'min_occurrence': None,
                'min_duration': 100,
                'is_before_previous_criteria': None,
                'is_after_previous_criteria': None
            }],
            'observation_period_criteria': {
                'before_index': None,
                'after_index': None
            }
        }

        omop_tables = {
            'person': person,
            'condition_occurrence': condition_occurrence,
            'procedure_occurrence': procedure,
            'drug_exposure': drug_exposure,
            'visit_occurrence': visit_occurrence,
            'observation_period': observation_period,
            'measurement': measurement
        }
        output = CohortBuilder(cohort_definition, omop_tables)()
        expected = pd.DataFrame({
            'person_id': [1],
            'index_date': [pd.to_datetime('2017-12-10')]
        })
        pd.testing.assert_frame_equal(output, expected)
コード例 #3
0
ファイル: test_unit.py プロジェクト: hchauvin/rwd_analytics
 def test_year_of_birth(self):
     cohort_definition = {
         'demographic_criteria': {
             'min_year_of_birth': 1970,
             'max_year_of_birth': 2000,
             'gender_concept_id': None
         },
         'criteria_list': []
     }
     output = CohortBuilder(cohort_definition, omop_tables)()
     output = output.reset_index(drop=True)
     expected = pd.DataFrame({
         'person_id': [1, 2, 4],
         'index_date': [
             pd.to_datetime('1970-01-01'),
             pd.to_datetime('1970-01-01'),
             pd.to_datetime('1970-01-01')
         ]
     })
     pd.testing.assert_frame_equal(output, expected)
コード例 #4
0
ファイル: test_unit.py プロジェクト: hchauvin/rwd_analytics
 def test_condition(self):
     cohort_definition = {
         'criteria_list': [{
             'concept_type': 'condition_occurrence',
             'concept_id': [3]
         }],
         'observation_period_criteria': {
             'before_index': None,
             'after_index': None
         }
     }
     output = CohortBuilder(cohort_definition, omop_tables)()
     expected = pd.DataFrame({
         'person_id': [1],
         'index_date': [pd.to_datetime('2017-12-10')]
     })
     pd.testing.assert_frame_equal(output, expected)