コード例 #1
0
    def main(self, argv):
        """Main method, callable from command line"""
        log.setLevel(logging.FATAL)

        usage_str = "usage: %prog [options]\n"
        parser = OptionParser(usage=usage_str)
        parser.add_option(
            "-s",
            "--startDate",
            dest="startDate",
            metavar="<startDate>",
            help=
            "Date string (e.g., 2011-12-15), if provided, will only run conversion on items with ordering time on or after this date."
        )
        parser.add_option(
            "-e",
            "--endDate",
            dest="endDate",
            metavar="<endDate>",
            help=
            "Date string (e.g., 2011-12-15), if provided, will only run conversion on items with ordering time before this date."
        )
        parser.add_option(
            "-n",
            "--normalizeMixtures",
            dest="normalizeMixtures",
            action="store_true",
            help=
            "If set, when find medication mixtures, will unravel / normalize into separate entries, one for each ingredient"
        )
        parser.add_option(
            "-d",
            "--doseCountLimit",
            dest="doseCountLimit",
            help=
            "Medication orders with a finite number of doses specified less than this limit will be labeled as different items than those without a number specified, or whose number is >= to this limit. Intended to distinguish things like IV single bolus / use vs. continuous infusions and standing medication orders"
        )
        (options, args) = parser.parse_args(argv[1:])

        log.info("Starting: " + str.join(" ", argv))
        timer = time.time()

        conv_options = ConversionOptions()
        conv_options.extract_parser_options(options)

        self.convertAndUpload(conv_options)

        timer = time.time() - timer
        log.info("%.3f seconds to complete", timer)
コード例 #2
0
    def setUp(self):
        log.setLevel(logging.INFO)  # without this no logs are printed
        """Prepare state for test cases"""
        DBTestCase.setUp(self)

        log.info("Sourcing from BigQuery DB")
        ClinicalItemDataLoader.build_clinical_item_psql_schemata()

        self.converter = STARRTreatmentTeamConversion.STARRTreatmentTeamConversion(
        )  # Instance to test on
        self.bqConn = self.converter.bqConn
        self.starrUtil = STARRUtil.StarrCommonUtils(self.converter.bqClient)

        # point the converter to dummy source table
        STARRTreatmentTeamConversion.SOURCE_TABLE = TEST_SOURCE_TABLE
コード例 #3
0
    def setUp(self):
        """Prepare state for test cases"""
        log.setLevel(logging.INFO)  # without this no logs are printed

        DBTestCase.setUp(self)
        ClinicalItemDataLoader.build_clinical_item_psql_schemata()

        # point the converter to dummy source table
        STARRDemographicsConversion.SOURCE_TABLE = TEST_SOURCE_TABLE

        log.info("Generating test source data")
        self.generate_test_and_expected_data(self.TEST_DATA_SIZE)
        self.dump_test_data_to_csv(self.test_data_csv)
        self.upload_test_data_csv_to_bigquery()
        self.dump_patient_ids_to_test_to_csv(self.pat_id_csv)
コード例 #4
0
    def setUp(self):
        log.setLevel(logging.INFO)  # without this no logs are printed
        """Prepare state for test cases"""
        DBTestCase.setUp(self)

        log.info("Sourcing from BigQuery DB")
        ClinicalItemDataLoader.build_clinical_item_psql_schemata()

        self.converter = STARRTreatmentTeamConversion.STARRTreatmentTeamConversion(
        )  # Instance to test on
        self.bqConn = self.converter.bqConn
        self.starrUtil = STARRUtil.StarrCommonUtils(self.converter.bqClient)

        # point the converter to dummy source table
        STARRTreatmentTeamConversion.SOURCE_TABLE = TEST_SOURCE_TABLE

        log.warn(
            "Removing test table, if exists: {}".format(TEST_SOURCE_TABLE))
        bq_cursor = self.bqConn.cursor()
        bq_cursor.execute('DROP TABLE IF EXISTS {};'.format(TEST_SOURCE_TABLE))
コード例 #5
0
    def setUp(self):
        """Prepare state for test cases"""
        log.setLevel(logging.INFO)  # without this no logs are printed

        DBTestCase.setUp(self)
        ClinicalItemDataLoader.build_clinical_item_psql_schemata()

        # point the converter to dummy source table
        STARRDemographicsConversion.SOURCE_TABLE = TEST_SOURCE_TABLE

        log.warn(
            "Removing test table if it exists: {}".format(TEST_SOURCE_TABLE))
        bq_cursor = self.bqConn.cursor()
        bq_cursor.execute('DROP TABLE IF EXISTS {};'.format(TEST_SOURCE_TABLE))

        log.info("Generating test source data")
        self.generate_test_and_expected_data(self.TEST_DATA_SIZE)
        self.starrUtil.dump_test_data_to_csv(self.header, self.test_data,
                                             self.test_data_csv)
        self.starrUtil.upload_csv_to_bigquery('starr_datalake2018',
                                              'demographic', 'test_dataset',
                                              'starr_demographic',
                                              self.test_data_csv, self.header)
        self.dump_patient_ids_to_test_to_csv(self.pat_id_csv)
コード例 #6
0
            where
                pi.clinical_item_id = ci.clinical_item_id and
                ci.clinical_item_category_id = cic.clinical_item_category_id and
                cic.source_table = '%s'
            order by
                pi.external_id desc, ci.external_id desc
            """ % (TEST_DEST_DATASET, TEST_DEST_DATASET, TEST_DEST_DATASET, TEST_SOURCE_TABLE)

        bq_cursor = self.bqConn.cursor()
        bq_cursor.execute(test_query)
        actual_data = [list(row.values()) for row in bq_cursor.fetchall()]
        log.debug('actual data: {}'.format(actual_data))
        log.debug('expected data: {}'.format(self.expected_data))
        self.assertEqualTable(self.expected_data, actual_data)


def suite():
    """Returns the suite of tests to run for this test class / module.
    Use unittest.makeSuite methods which simply extracts all of the
    methods for the given class whose name starts with "test"
    """
    test_suite = unittest.TestSuite()
    test_suite.addTest(unittest.makeSuite(TestSTARRTreatmentTeamConversion))

    return test_suite


if __name__ == "__main__":
    log.setLevel(logging.INFO)  # without this no logs are printed
    unittest.TextTestRunner(verbosity=RUNNER_VERBOSITY).run(suite())