def setUp(self): """Prepare state for test cases.""" DBTestCase.setUp(self) StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata() self._deleteTestRecords() self._insertTestRecords()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self); self.manager = SimManager(); # Instance to test on from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader; ClinicalItemDataLoader.build_clinical_item_psql_schemata(); self.manager.buildCPOESimSchema(); log.info("Populate the database with test data") #### Basically import a bunch of rigged CSV or TSV files that have realistic simulating case and grading data # Get that data into the test database dataTextStr = \ """sim_result_id;name;description;group_string;priority -10;Temp;Temperature (F);Flowsheet>Vitals;10 -20;Pulse;Pulse / Heart Rate (HR);Flowsheet>Vitals;20 -30;SBP;Blood Pressure, Systolic (SBP);Flowsheet>Vitals;30 -40;DBP;Blood Pressure, Diastolic (DBP);Flowsheet>Vitals;40 -50;Resp;Respirations (RR);Flowsheet>Vitals;50 -60;FiO2;Fraction Inspired Oxygen;Flowsheet>Vitals;60 -70;Urine;Urine Output (UOP);Flowsheet>Vitals;70 """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_result", delim=";");
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) ClinicalItemDataLoader.build_clinical_item_psql_schemata() log.info("Sourcing from BigQuery DB") self.patientIds = [ 'JCd5ef6e', 'JCce317d', 'JCe83f82', 'JCe5fc81', 'JCdb8fe4', 'JCcdc6a0', 'JCd37637', 'JCdbb57e', 'JCcebdef', 'JCcc41b3', 'JCe160b3', 'JCe8415d', 'JCdb1735', 'JCeb8fe9', 'JCe362b1', 'JCcca36e', 'JCddddf4', 'JCe683c1', 'JCe74388', 'JCd30ac4', 'JCd1bb22', 'JCe3397c', 'JCccb16c', 'JCd5da6d', 'JCd6f915', 'JCe3e96d', 'JCd43db0', 'JCe5a52f', 'JCd9f7b5', 'JCd60bb3', 'JCe66004', 'JCe4a6c2', 'JCceb239', 'JCda9846', 'JCce3176', 'JCe098ca', 'JCd31af1', 'JCe796fd', 'JCcc9243', 'JCd05308', 'JCea3982', 'JCd99619', 'JCd99366', 'JCdb087f', 'JCd9f2b3', 'JCe8a2d4', 'JCd19201', 'JCcdc146', 'JCe05414', 'JCd98ef5' ] self.pat_id_csv = '/tmp/tmp_test_pat_id.csv' with open(self.pat_id_csv, 'wb') as f: for id in ['rit_uid'] + self.patientIds: f.write("%s\n" % id) self.bqConn = bigQueryUtil.connection() self.converter = STARRDemographicsConversion() # Instance to test on
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Sourcing from BigQuery DB") ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.converter = STARRTreatmentTeamConversion() # Instance to test on self.bqConn = self.converter.bqConn self.starrUtil = STARRUtil.StarrCommonUtils(self.converter.bqClient)
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.orderProcIdStrList = list() headers = [ "order_proc_id", "pat_id", "pat_enc_csn_id", "order_type", "proc_id", "proc_code", "description", "order_time", "instantiated_time", "stand_interval" ] dataModels = \ [ # Deliberately design dates in far future to facilitate isolated testing RowItemModel( [ -417974686, "380873", 111, "Nursing", 1453, "NUR1043", "NURSING PULSE OXIMETRY", "2111-12-10", None, "CONTINUOUS"], headers ), RowItemModel( [ -419697343, "3042640", 222, "Point of Care Testing", 1001, "LABPOCGLU", "GLUCOSE BY METER", "2112-01-13", None, "Q6H"], headers ), RowItemModel( [ -418928388, "-1612899", 333, "Point of Care Testing", 1001, "LABPOCGLU", "GLUCOSE BY METER", "2111-12-28", None, "ONCE"], headers ), RowItemModel( [ -418928399, "-1612899", 333, "Point of Care Testing", 1001, "LABPOCGLU", "GLUCOSE BY METER", "2111-12-28", None, "DAILY"], headers ), # Ignore repeast when consider unique by patient, item, date RowItemModel( [ -418928378, "-1612899", 333, "Point of Care Testing", 1001, "LABPOCGLU", "GLUCOSE BY METER", "2111-12-18", None, "PRN"], headers ), # PRN orders should be ignored RowItemModel( [ -418045499, "2087083", 444, "Nursing", 1428, "NUR1018", "MONITOR INTAKE AND OUTPUT", "2111-12-11", None, None], headers ), RowItemModel( [ -417843774, "2648748", 555, "Nursing", 1508, "NUR1068", "WEIGHT", "2111-12-08", None, "ONCE"], headers ), RowItemModel( [ -419268931, "3039254", 666, "Lab", 1721, "LABPTT", "PTT PARTIAL THROMBOPLASTIN TIME", "2112-01-04", None, "DAILY"], headers ), RowItemModel( [ -419268231, "3039254", 666, "Lab", 1721, "LABPTT", "PTT PARTIAL THROMBOPLASTIN TIME", "2112-01-04", "2112-01-06", "Q6H PRN"], headers ), # Ignore instantiated / spawned child orders RowItemModel( [ -419268937, "3039254", 666, "Lab", 9991721, "LABPTT", "PTT (PARTIAL THROMBOPLASTIN TIME)", "2112-01-05", None, "DAILY"], headers ), # Different proc_id, but same proc_Code. Treat like the same RowItemModel( [ -419268935, "3039254", 777, "Lab", 1721, "LABPTT", "PTT PARTIAL THROMBOPLASTIN TIME", "2112-01-04", "2112-01-07", "ONCE"], headers ), # Primarily only interested in the decision point with the original order ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_order_proc", dataModel, retrieveCol="order_proc_id") self.orderProcIdStrList.append(str(dataItemId)) # Certain items drawn from order sets headers = [ "order_proc_id", "protocol_id", "protocol_name", "section_name", "smart_group" ] dataModels = \ [ RowItemModel( [ -418928388, -222, "ER General", "Testing", "PoC",], headers ), RowItemModel( [ -418928378, -222, "ER General", "Testing", "PoC",], headers ), RowItemModel( [ -418045499, -111, "General Admit", "Nursing", "Monitoring",], headers ), RowItemModel( [ -419268931, -111, "General Admit", "Lab", "Coag",], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_orderset_order_proc", dataModel, retrieveCol="order_proc_id") self.converter = STRIDEOrderProcConversion()
def setUp(self): """Prepare state for test cases.""" DBTestCase.setUp(self) StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata() self._deleteTestRecords() self._insertTestRecords() self.factory = FeatureMatrixFactory() self.connection = DBUtil.connection()
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
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)
def setUp(self): """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))
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) ClinicalItemDataLoader.build_clinical_item_psql_schemata() # point the converter to dummy source table STARRDemographicsConversion.SOURCE_TABLE = TEST_SOURCE_TABLE log.warning( "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)
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata() ###### PREPARE SOME FAKE INPUT DATA TO BE CONVERTED ############## ###### PREPARE SOME FAKE INPUT DATA TO BE CONVERTED ############## ###### PREPARE SOME FAKE INPUT DATA TO BE CONVERTED ############## ###### PREPARE SOME FAKE INPUT DATA TO BE CONVERTED ############## ###### PREPARE SOME FAKE INPUT DATA TO BE CONVERTED ############## dataTextStr = \ """order_proc_anon_id,pat_anon_id,pat_enc_csn_anon_id,proc_code,organism_name,antibiotic_name,suseptibility,shifted_result_time -10,1,2,LABBLC,BACTEROIDES FRAGILIS,Clindamycin,Intermediate,9/10/2111 13:15 -11,2,3,LABBLC,COAG NEGATIVE STAPHYLOCOCCUS,Vancomycin,Susceptible,4/26/2109 9:49 -12,3,4,LABBLC,COAG NEGATIVE STAPHYLOCOCCUS,Oxacillin,Resistant,4/18/2109 4:48 -13,4,5,LABBLC,COAG NEGATIVE STAPHYLOCOCCUS,Vancomycin,Susceptible,3/28/2109 23:21 -14,5,6,LABBLC,ENTEROCOCCUS FAECALIS,Amoxicillin/Clavulanic Acid,Susceptible,6/3/2109 17:07 -14,5,6,LABBLC,ENTEROCOCCUS FAECALIS,Amoxicillin/Clavulanic Acid,Susceptible,6/3/2109 17:07 -20,10,11,LABBLC,ENTEROCOCCUS FAECALIS,Method,,6/10/2109 17:07 -15,6,7,LABBLC2,,,,6/4/2109 17:07 -16,7,8,LABBLC2,,,, -17,10,10,LABBLC2,ENTEROCOCCUS FAECALIS,Penicillin,,6/8/2109 17:07 -17,10,10,LABBLC2,ENTEROCOCCUS FAECALIS,,Intermediate,6/11/2109 17:07 -18,11,11,LABBLC2,ENTEROCOCCUS FAECALIS,Amikacin,Positive,6/11/2111 18:07 """ # Parse into DB insertion object # DBUtil.insertFile( StringIO(dataTextStr), "stride_culture_micro", delim=" ", dateColFormats={"trtmnt_tm_begin_date": None, "trtmnt_tm_end_date": None} ); DBUtil.insertFile(StringIO(dataTextStr), "stride_culture_micro", delim=",", dateColFormats={"shifted_result_time": None}) self.converter = STRIDECultureMicroConversion()
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 = STARROrderProcConversion.STARROrderProcConversion( ) # Instance to test on self.bqConn = self.converter.bqConn self.starrUtil = STARRUtil.StarrCommonUtils(self.converter.bqClient) # point the converter to dummy source table STARROrderProcConversion.SOURCE_TABLE = TEST_SOURCE_TABLE STARROrderProcConversion.ORDERSET_TABLE = TEST_ORDERSET_TABLE STARROrderProcConversion.TARGET_DATASET_ID = TEST_DEST_DATASET log.warn("Removing test tables, if they exist: {} and {}".format( TEST_SOURCE_TABLE, TEST_ORDERSET_TABLE)) bq_cursor = self.bqConn.cursor() bq_cursor.execute('DROP TABLE IF EXISTS {};'.format(TEST_SOURCE_TABLE)) bq_cursor.execute( 'DROP TABLE IF EXISTS {};'.format(TEST_ORDERSET_TABLE))
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() log.info("Populate the database with test data") self.clinicalItemCategoryIdStrList = list() headers = ["clinical_item_category_id", "source_table"] dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) self.clinicalItemCategoryIdStrList.append(str(dataItemId)) headers = ["clinical_item_id", "clinical_item_category_id", "name"] dataModels = \ [ RowItemModel( [-1, -1, "CBC"], headers ), RowItemModel( [-2, -1, "BMP"], headers ), RowItemModel( [-3, -1, "Hepatic Panel"], headers ), RowItemModel( [-4, -1, "Cardiac Enzymes"], headers ), RowItemModel( [-5, -2, "CXR"], headers ), RowItemModel( [-6, -2, "RUQ Ultrasound"], headers ), RowItemModel( [-7, -2, "CT Abdomen/Pelvis"], headers ), RowItemModel( [-8, -2, "CT PE Thorax"], headers ), RowItemModel( [-9, -3, "Acetaminophen"], headers ), RowItemModel( [-10, -3, "Carvedilol"], headers ), RowItemModel( [-11, -3, "Enoxaparin"], headers ), RowItemModel( [-12, -3, "Warfarin"], headers ), RowItemModel( [-13, -3, "Ceftriaxone"], headers ), RowItemModel( [-14, -4, "Foley Catheter"], headers ), RowItemModel( [-15, -4, "Strict I&O"], headers ), RowItemModel( [-16, -4, "Fall Precautions"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) headers = [ "patient_item_id", "patient_id", "clinical_item_id", "item_date", "analyze_date" ] dataModels = \ [ RowItemModel( [-1, -11111, -4, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-2, -11111, -10, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-3, -11111, -8, datetime(2000, 1, 1, 2), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-4, -11111, -10, datetime(2000, 1, 2, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-5, -11111, -12, datetime(2000, 2, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-10, -22222, -7, datetime(2000, 1, 5, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-12, -22222, -6, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-13, -22222, -11, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-14, -33333, -6, datetime(2000, 2, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-15, -33333, -2, datetime(2000, 2,11, 0), datetime(2010, 1, 1, 0)], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel) dataTextStr = \ """item_collection_id;external_id;name;section;subgroup -1;-1;Test Order Set - 1;Meds;TreatmentMeds -2;-1;Test Order Set - 1;Meds;SymptomsMeds -3;-1;Test Order Set - 1;Labs;GeneralLabs -4;-2;Test Order Set - 2;Labs;GeneralLabs -5;-2;Test Order Set - 2;Imaging;Xrays -6;-2;Test Order Set - 2;Imaging;AdvancedImaging -7;-3;Test Order Set - 3;Imaging;GeneralImaging -8;-3;Test Order Set - 3;Nursing;GeneralNursing """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "item_collection", delim=";") dataTextStr = \ """item_collection_item_id;item_collection_id;clinical_item_id;collection_type_id -1;-1;-12;4 -2;-1;-13;4 -3;-2;-11;4 -4;-2;-10;4 -5;-3;-1;4 -6;-3;-2;4 -7;-4;-2;4 -8;-4;-3;4 -9;-5;-5;4 -10;-6;-6;4 -11;-6;-7;4 -12;-6;-8;4 -13;-7;-5;4 -14;-7;-6;4 -15;-8;-14;4 -16;-8;-15;4 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "item_collection_item", delim=";") self.recommender = OrderSetRecommender()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) self.manager = SimManager() # Instance to test on from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.manager.buildCPOESimSchema() log.info("Populate the database with test data") # Basically import a bunch of rigged CSV or TSV files that have realistic simulating case and grading data # Get that data into the test database clinical_item_category_str = \ """clinical_item_category_id;source_table 1;source_table """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_category_str), "clinical_item_category", delim=";") clinical_item_str = \ """clinical_item_id;clinical_item_category_id;name 1;1;Clinical item 1 2;1;Clinical item 2 3;1;Clinical item 3 4;1;Clinical item 4 5;1;Clinical item 5 6;1;Clinical item 6 7;1;Clinical item 7 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_str), "clinical_item", delim=";") clinical_item_str = \ """sim_user_id;name 0;Default user 1;Jonathan Chen 2;User 2 3;User 3 4;User 4 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_str), "sim_user", delim=";") sim_patient_str = \ """sim_patient_id;name;age_years;gender 1;Patient One;40;Male 2;Patient Two;50;Female 3;Patient Three;60;Male 4;Patient Four;70;Female 5;Patient Five;80;Male 6;Patient Six;90;Female 7;Patient Seven;100;Male """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_patient_str), "sim_patient", delim=";") sim_state_str = \ """sim_state_id;name 1;Sim state 1 2;Sim state 2 3;Sim state 3 4;Sim state 4 5;Sim state 5 6;Sim state 6 7;Sim state 7 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_state_str), "sim_state", delim=";") sim_patient_order_str = \ """sim_patient_order_id;sim_user_id;sim_patient_id;clinical_item_id;relative_time_start;sim_state_id 1;0;1;1;1;1 2;1;1;2;2;2 3;1;1;3;3;3 4;1;1;4;4;4 5;1;1;5;5;5 6;1;1;6;6;6 7;1;1;7;7;7 8;2;2;1;1;1 9;3;2;2;2;1 10;3;2;3;3;2 11;2;3;1;1;1 12;3;3;2;2;2 13;3;3;3;3;3 14;1;4;1;1;2 15;1;4;2;2;3 16;2;5;1;1;3 17;2;5;2;2;4 18;3;6;4;1;1 19;3;6;4;2;2 20;3;6;4;3;3 21;4;7;5;1;1 22;4;7;5;2;2 23;4;7;5;3;3 24;4;7;5;4;4 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_patient_order_str), "sim_patient_order", delim=";") sim_grading_key_str = \ """sim_grader_id;sim_state_id;clinical_item_id;score;group_name Jonathan Chen;1;1;1;g1 Jonathan Chen;2;2;1;g2 Jonathan Chen;3;3;1;g3 Jonathan Chen;4;4;1; Jonathan Chen;5;5;1;g5 Jonathan Chen;6;6;1; Jonathan Chen;7;7;1;g7 Jonathan Chen;3;1;1;g8 Jonathan Chen;4;2;1;g8 Jonathan Chen;1;4;-1000; Jonathan Chen;2;4;10; Jonathan Chen;3;4;2000; Jonathan Chen;1;5;-1000;g9 Jonathan Chen;2;5;-1; Jonathan Chen;3;5;0;g10 Jonathan Chen;3;5;-500; """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_grading_key_str), "sim_grading_key", delim=";") self.expected_grades_by_patient_id = [ { "total_score": 6, # Default user (id = 0) is ignored and NULL group_names are counted separately "sim_patient_id": 1, "most_graded_user_id": 1, "most_active_user_id": 1, "sim_grader_id": "Jonathan Chen" }, { "total_score": 1, # Ungraded (clinical_item_id, sim_state_id) keys are omitted from summation "sim_patient_id": 2, "most_graded_user_id": 2, # Most graded user is User 2 (even though most active is User 3) "most_active_user_id": 3, "sim_grader_id": "Jonathan Chen" }, { "total_score": 3, "sim_patient_id": 3, "most_graded_user_id": 3, # Most graded user is the most active one "most_active_user_id": 3, "sim_grader_id": "Jonathan Chen" }, # 4: No grading available for the existing case { "total_score": 1, # Scores in the same group g8 are counted only once "sim_patient_id": 5, "most_graded_user_id": 2, "most_active_user_id": 2, "sim_grader_id": "Jonathan Chen" }, { "total_score": 1010, # Non-uniform scores (i.e., not all scores = 1) "sim_patient_id": 6, "most_graded_user_id": 3, "most_active_user_id": 3, "sim_grader_id": "Jonathan Chen" }, { "total_score": -1501, # All negative and one 0 score results in negative score "sim_patient_id": 7, "most_graded_user_id": 4, "most_active_user_id": 4, "sim_grader_id": "Jonathan Chen" } # 8: Case doesn't exist ]
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.patientIdStrList = list() headers = [ "pat_id", "pat_enc_csn_id", "noted_date", "resolved_date", "dx_icd9_code", "dx_icd9_code_list", "dx_icd10_code_list", "data_source" ] dataModels = \ [ RowItemModel( ["-126500", -131017780655, "2111-10-14", None, "-431.00", "-431.00,-432","","PROBLEM_LIST"], headers ), RowItemModel( ["-126268", -131015534571, "2111-05-04", None, "-0285", "-0285,-0286","","PROBLEM_LIST"], headers ), RowItemModel( ["-126268", -131015534571, None, None, "-272.4", "-272.4,-273","","PROBLEM_LIST"], headers ), RowItemModel( ["-126268", -131015534571, None, None, "-309.9", "-309.9,-310","","ENC_Dx"], headers ), RowItemModel( ["-126268", -131015534571, "2111-05-18", None, "-785", "-785,-786","","ADMIT_DX"], headers ), RowItemModel( ["-126472", -131015404439, None, None, "-719.46", "-719.46,-720","","ENC_Dx"], headers ), # Repeat, but under different encounter, should be ignored, just base on noted date RowItemModel( ["-126500", -131000000000, "2111-10-14", None, "-431.00", "-431.00,-432","","PROBLEM_LIST"], headers ), RowItemModel( ["-126798", -131014753610, None, None, "-482.9", "-482.9,-483","","ENC_Dx"], headers ), RowItemModel( ["-126798", -131014753610, "2111-03-08", None, "-780", "-780,-781","","ADMIT_DX"], headers ), RowItemModel( ["-126798", -131016557370, "2111-07-26", None, "-780.97", "-780.97,-781","","ADMIT_DX"], headers ), # No matching diagnosis code, will just make up a label then # Different patient, but using ICD9 list instead of ICD9 code # If there is no ICD9 list, and only ICD10 list, we will need # to add special logic and decide whether to try to # cross-reference with ICD9-based Dx'es RowItemModel( ["-2126500", -135000000000, "2111-10-14", None, "", "-431.00,-432","-10431.00,-10432","PROBLEM_LIST"], headers ), RowItemModel( ["-2126798", -135014753610, "2111-06-06", None, "", "-482.9,-483","-10482.9,-10483","PROBLEM_LIST"], headers ), RowItemModel( ["-2126798", -135014753610, "2111-03-08", None, "", "-780","-10780","ADMIT_DX"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_dx_list", dataModel, retrieveCol="pat_id") self.patientIdStrList.append(str(dataItemId)) self.icd9CUIdStrList = list() headers = ["cui", "ispref", "aui", "tty", "code", "str", "suppress"] dataModels = \ [ RowItemModel( ["-C1", "Y", "-A1", "PT", "-0285", "Diagnosis 1","N"], headers ), RowItemModel( ["-C2b","Y", "-A2b","PT", "-431.0", "Diagnosis 2b","N"], headers ), # Parent diagnoses RowItemModel( ["-C2", "Y", "-A2", "PT", "-431.00", "Diagnosis 2","N"], headers ), RowItemModel( ["-C3", "N", "-A3", "AB", "-431.00", "Diagnosis 3","N"], headers ), # Repeat, but not preferred RowItemModel( ["-C4", "N", "-A4", "HT", "-785", "Diagnosis 4","N"], headers ), RowItemModel( ["-C5", "Y", "-A5", "HT", "-780", "Diagnosis 5","N"], headers ), RowItemModel( ["-C6a","Y", "-A6a","PT", "-780.9", "Diagnosis 6a","N"], headers ), RowItemModel( ["-C6", "Y", "-A6", "PT", "-780.97", "Diagnosis 6","N"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_icd9_cm", dataModel, retrieveCol="cui") self.icd9CUIdStrList.append(str(dataItemId)) self.icd10_order_number_str_list = list() headers = [ 'order_number', 'icd10', 'hipaa_covered', 'short_description', 'full_description', 'icd10_code' ] data_models = [ RowItemModel([ -1, '-1043100', 1, 'Diagnosis 2', 'Diagnosis 2 Full', '-10431.00' ], headers), RowItemModel([ -2, '-104310', 0, 'Diagnosis 2b', 'Diagnosis 2b Full', '-10431.0' ], headers), RowItemModel( [-6, '-10780', 0, 'Diagnosis 5', 'Diagnosis 5 Full', '-10780'], headers) ] for data_model in data_models: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_icd10_cm", data_model, retrieveCol='order_number') self.icd10_order_number_str_list.append(str(dataItemId)) self.converter = STRIDEDxListConversion()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.clinicalItemCategoryIdStrList = list() headers = ["clinical_item_category_id", "source_table"] dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) self.clinicalItemCategoryIdStrList.append(str(dataItemId)) headers = [ "clinical_item_id", "clinical_item_category_id", "name", "analysis_status" ] dataModels = \ [ RowItemModel( [-1, -1, "CBC",1], headers ), RowItemModel( [-2, -1, "BMP",0], headers ), # Clear analysis status, so this will be ignored unless changed RowItemModel( [-3, -1, "Hepatic Panel",1], headers ), RowItemModel( [-4, -1, "Cardiac Enzymes",1], headers ), RowItemModel( [-5, -2, "CXR",1], headers ), RowItemModel( [-6, -2, "RUQ Ultrasound",1], headers ), RowItemModel( [-7, -2, "CT Abdomen/Pelvis",1], headers ), RowItemModel( [-8, -2, "CT PE Thorax",1], headers ), RowItemModel( [-9, -3, "Acetaminophen",1], headers ), RowItemModel( [-10, -3, "Carvedilol",1], headers ), RowItemModel( [-11, -3, "Enoxaparin",1], headers ), RowItemModel( [-12, -3, "Warfarin",1], headers ), RowItemModel( [-13, -3, "Ceftriaxone",1], headers ), RowItemModel( [-14, -4, "Foley Catheter",1], headers ), RowItemModel( [-15, -4, "Strict I&O",1], headers ), RowItemModel( [-16, -4, "Fall Precautions",1], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) headers = [ "patient_item_id", "encounter_id", "patient_id", "clinical_item_id", "item_date" ] dataModels = \ [ RowItemModel( [-1, -111, -11111, -4, datetime(2000, 1, 1, 0)], headers ), RowItemModel( [-2, -111, -11111, -10, datetime(2000, 1, 1, 0)], headers ), RowItemModel( [-3, -111, -11111, -8, datetime(2000, 1, 1, 2)], headers ), RowItemModel( [-4, -112, -11111, -10, datetime(2000, 1, 2, 0)], headers ), RowItemModel( [-5, -112, -11111, -12, datetime(2000, 2, 1, 0)], headers ), RowItemModel( [-10, -222, -22222, -7, datetime(2000, 1, 5, 0)], headers ), RowItemModel( [-12, -222, -22222, -6, datetime(2000, 1, 9, 0)], headers ), RowItemModel( [-13, -222, -22222, -11, datetime(2000, 1, 9, 0)], headers ), RowItemModel( [-14, -333, -33333, -6, datetime(2000, 2, 9, 0)], headers ), RowItemModel( [-15, -333, -33333, -2, datetime(2000, 2,11, 0)], headers ), # Will set clinical_item_link inheritances to this item to only record certain associations RowItemModel( [-16, -333, -33333, -11, datetime(2000, 2,11, 0)], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel) headers = ["clinical_item_id", "linked_item_id"] dataModels = \ [ # Don't have direct, but instead demonstrate inherited relationship from 6 to 2 will still be recognized RowItemModel( [-6, -4], headers ), RowItemModel( [-4, -2], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_link", dataModel) # Temp filename for data buffer self.bufferFilename = "updateBufferTemp.txt" self.analyzer = AssociationAnalysis()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self); self.manager = SimManager(); # Instance to test on from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader; ClinicalItemDataLoader.build_clinical_item_psql_schemata(); self.manager.buildCPOESimSchema(); self.testPatientId = None; self.purgeTestRecords(); log.info("Populate the database with test data") self.clinicalItemCategoryIdStrList = list(); headers = ["clinical_item_category_id","source_table"]; dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel ); self.clinicalItemCategoryIdStrList.append( str(dataItemId) ); headers = ["clinical_item_id","clinical_item_category_id","name","analysis_status"]; dataModels = \ [ RowItemModel( [-1, -1, "CBC",1], headers ), RowItemModel( [-2, -1, "BMP",1], headers ), RowItemModel( [-3, -1, "Hepatic Panel",1], headers ), RowItemModel( [-4, -1, "Cardiac Enzymes",1], headers ), RowItemModel( [-5, -2, "CXR",1], headers ), RowItemModel( [-6, -2, "RUQ Ultrasound",1], headers ), RowItemModel( [-7, -2, "CT Abdomen/Pelvis",1], headers ), RowItemModel( [-8, -2, "CT PE Thorax",1], headers ), RowItemModel( [-9, -3, "Acetaminophen",1], headers ), RowItemModel( [-10, -3, "Carvedilol",1], headers ), RowItemModel( [-11, -3, "Enoxaparin",1], headers ), RowItemModel( [-12, -3, "Warfarin",1], headers ), RowItemModel( [-13, -3, "Ceftriaxone",1], headers ), RowItemModel( [-14, -4, "Foley Catheter",1], headers ), RowItemModel( [-15, -4, "Vital Signs",1], headers ), RowItemModel( [-16, -4, "Fall Precautions",1], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel ); dataTextStr = \ """sim_user_id;name -1;Test User """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_user", delim=";"); dataTextStr = \ """sim_patient_id;age_years;gender;name -1;60;Female;Test Female Patient -2;55;Male;Test Male Patient """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_patient", delim=";"); dataTextStr = \ """sim_result_id;name;description;group_string;priority -10;Temp;Temperature (F);Flowsheet>Vitals;10 -20;Pulse;Pulse / Heart Rate (HR);Flowsheet>Vitals;20 -30;SBP;Blood Pressure, Systolic (SBP);Flowsheet>Vitals;30 -40;DBP;Blood Pressure, Diastolic (DBP);Flowsheet>Vitals;40 -50;Resp;Respirations (RR);Flowsheet>Vitals;50 -60;FiO2;Fraction Inspired Oxygen;Flowsheet>Vitals;60 -70;Urine;Urine Output (UOP);Flowsheet>Vitals;70 -11000;WBC;WBC;LAB BLOOD ORDERABLES>Hematology>Automated Blood Count;11000 -11010;HGB;HEMOGLOBIN;LAB BLOOD ORDERABLES>Hematology>Automated Blood Count;11010 -11020;HCT;HEMATOCRIT;LAB BLOOD ORDERABLES>Hematology>Automated Blood Count;11020 -11030;PLT;PLATELET COUNT;LAB BLOOD ORDERABLES>Hematology>Automated Blood Count;11030 -13010;NA;SODIUM, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13010 -13020;K;POTASSIUM, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13020 -13030;CL;CHLORIDE, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13030 -13040;CO2;CO2, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13040 -13050;BUN;UREA NITROGEN,SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13050 -13060;CR;CREATININE, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13060 -13070;GLU;GLUCOSE, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13070 -13090;CA;CALCIUM, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13090 -13110;MG;MAGNESIUM, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13110 -13120;PHOS;PHOSPHORUS, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13120 -13210;TBIL;TOTAL BILIRUBIN;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13210 -13220;DBIL;CONJUGATED BILI;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13220 -13230;IBIL;UNCONJUGATED BILIRUBIN;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13230 -13240;AST;AST (SGOT), SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13240 -13250;ALT;ALT (SGPT), SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13250 -13260;ALKP;ALK P'TASE, TOTAL, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13260 -13270;ALB;ALBUMIN, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13270 -13280;TP;PROTEIN, TOTAL, SER/PLAS;LAB BLOOD ORDERABLES>Chemistry>General Chemistry;13280 """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_result", delim=";"); # Map orders to expected results. # Simplify expect vital signs to result in 5 minutes. Basic chemistry labs in 10 minutes, CBC in 15 minutes dataTextStr = \ """sim_order_result_map_id;clinical_item_id;sim_result_id;turnaround_time -1;-15;-10;300 -2;-15;-20;300 -3;-15;-30;300 -4;-15;-40;300 -5;-15;-50;300 -6;-1;-11000;900 -7;-1;-11010;900 -8;-1;-11020;900 -9;-1;-11030;900 -10;-2;-13010;600 -11;-2;-13020;600 -12;-2;-13030;600 -13;-2;-13040;600 -14;-2;-13050;600 -15;-2;-13060;600 -16;-2;-13070;600 -17;-2;-13090;600 -18;-3;-13210;600 -19;-3;-13240;600 -20;-3;-13250;600 -21;-3;-13260;600 -22;-3;-13270;600 -23;-3;-13280;600 """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_order_result_map", delim=";"); dataTextStr = \ """sim_state_id;name;description 0;Test 0; Test State 0 -1;Test 1;Test State 1 -2;Test 2;Test State 2 -3;Test 3;Test State 3 -4;Test 4;Test State 4 """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_state", delim=";"); dataTextStr = \ """sim_state_transition_id;pre_state_id;post_state_id;clinical_item_id;time_trigger;description -1;-1;-2;None;9000;Passive time from 1 to 2 -2;-2;-3;-11;None;Transition 2 to 3 if order for 11 (Enoxaparin) -3;-2;-3;-12;None;Transition 2 to 3 if order for 12 (Warfarin) (don't need both anti-coagulants. One adequate to trigger transition) -4;-2;-4;-13;None;Transition 2 to 4 if order for 13 (Ceftriaxone) -5;-3;-1;-10;9000;Transition 3 back to 1 if order for 10 (Carvedilol) OR 9000 seconds pass """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_state_transition", delim=";"); dataTextStr = \ """sim_patient_state_id;sim_patient_id;sim_state_id;relative_time_start;relative_time_end -1;-1;-1;-7200;0 -3;-1;-1;0;1800 -2;-1;-2;1800;None """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_patient_state", delim=";"); # Order Vital Signs at time 0, then basic labs (CBC, BMP, LFTs) at 10 minutes (600 seconds) dataTextStr = \ """sim_patient_order_id;sim_user_id;sim_patient_id;sim_state_id;clinical_item_id;relative_time_start;relative_time_end -1;-1;-1;-1;-15;0;None -2;-1;-1;-1;-1;600;None -3;-1;-1;-1;-2;600;None -4;-1;-1;-1;-3;600;None -5;-1;-1;-2;-15;1800;None -6;-1;-1;-2;-1;1800;None -7;-1;-1;-2;-2;1800;None """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_patient_order", delim=";"); dataTextStr = \ """sim_state_result_id;sim_result_id;sim_state_id;num_value;num_value_noise;text_value;result_flag -1;-10;0;98.7;0.2;; -2;-20;0;75;3;; -3;-30;0;130;4;; -4;-40;0;85;2;; -5;-50;0;12;1;; -6;-60;0;0.21;0;; -7;-70;0;500;100;; -8;-11000;0;7;1;; -9;-11010;0;13;0.5;; -10;-11020;0;40;1;; -11;-11030;0;300;25;; -12;-13010;0;140;4;; -13;-13020;0;4.5;0.4;; -14;-13030;0;95;3;; -15;-13040;0;24;1;; -16;-13050;0;12;3;; -17;-13060;0;0.7;0.2;; -18;-13070;0;140;12;; -19;-13090;0;9;0.4;; -20;-13110;0;2;0.3;; -21;-13120;0;3;0.5;; -22;-13210;0;0.2;0.1;; -23;-13240;0;29;5;; -24;-13250;0;20;4;; -25;-13260;0;85;8;; -26;-13270;0;4;0.4;; -27;-13280;0;6;0.5;; -28;-10;-1;101.4;0.4;Fever;H -29;-20;-1;115;4;Tachycardia;H -30;-30;-1;92;5;Hypotension;L -31;-40;-1;55;3;Hypotension;L -32;-70;-1;50;10;Low UOP;L -33;-11000;-1;12;1;Leukocytosis;H -34;-13060;-1;2.4;0.3;AKI;H -35;-20;-2;105;4;Tachycardia;H -36;-11000;-2;10;1;; -37;-13060;-2;1.9;0.3;AKI;H -38;-13070;-2;250;13;;H """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_state_result", delim=";"); dataTextStr = \ """sim_note_id;sim_state_id;relative_state_time;content -1;-1;7200;Initial Note -2;-2;0;Later Note """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "sim_note", delim=";");
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() #self.purgeTestRecords(); headers = [ "clinical_item_category_id", "default_recommend", "source_table" ] dataModels = \ [ RowItemModel( [-1, 1, "Labs"], headers ), RowItemModel( [-2, 1, "Imaging"], headers ), RowItemModel( [-3, 1, "Meds"], headers ), RowItemModel( [-4, 1, "Nursing"], headers ), RowItemModel( [-5, 1, "Problems"], headers ), RowItemModel( [-6, 1, "Lab Results"], headers ), RowItemModel( [-7, 0, "No Rec Category"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) headers = [ "clinical_item_id", "clinical_item_category_id", "patient_count", "name", "analysis_status" ] dataModels = \ [ RowItemModel( [-1, -1, 100, "CBC",1], headers ), RowItemModel( [-2, -1, 200, "BMP",0], headers ), # Clear analysis status, so this will be ignored unless changed RowItemModel( [-3, -1, 300, "Hepatic Panel",1], headers ), RowItemModel( [-4, -1, 400, "Cardiac Enzymes",1], headers ), RowItemModel( [-5, -2, 500, "CXR",1], headers ), RowItemModel( [-6, -2, 600, "RUQ Ultrasound",1], headers ), RowItemModel( [-7, -2, 700, "CT Abdomen/Pelvis",1], headers ), RowItemModel( [-8, -2, 800, "CT PE Thorax",1], headers ), RowItemModel( [-9, -3, 900, "Acetaminophen",1], headers ), RowItemModel( [-10, -3, 1000, "Carvedilol",1], headers ), RowItemModel( [-11, -3, 100, "Enoxaparin",1], headers ), RowItemModel( [-12, -3, 200, "Warfarin",1], headers ), RowItemModel( [-13, -3, 300, "Ceftriaxone",1], headers ), RowItemModel( [-14, -4, 400, "Foley Catheter",1], headers ), RowItemModel( [-15, -4, 500, "Strict I&O",1], headers ), RowItemModel( [-16, -4, 600, "Fall Precautions",1], headers ), RowItemModel( [-77, -7, 700, "No Rec Item",1], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) dataTextStr = \ """patient_item_id;patient_id;clinical_item_id;item_date -1;-123;-6;3/11/2012 10:57 -2;-123;-7;3/11/2012 10:57 -3;-123;-1;4/11/2012 10:57 -4;-123;-2;4/11/2012 10:57 -5;-123;-3;4/11/2012 10:57 -6;-123;-4;4/11/2012 10:57 -8;-123;-8;4/11/2012 10:57 -9;-123;-9;4/11/2012 10:57 -10;-123;-10;4/11/2012 0:00 -11;-123;-11;4/11/2012 10:57 -12;-123;-12;4/11/2012 10:57 -13;-123;-13;4/11/2012 10:57 -14;-123;-12;4/12/2012 3:57 -15;-123;-14;4/12/2012 3:57 -16;-123;-15;4/12/2012 3:57 -17;-123;-16;4/12/2012 3:57 -18;-123;-13;5/12/2012 8:57 -19;-123;-5;5/12/2012 8:57 -21;-456;-4;12/24/2013 6:50 -22;-456;-4;12/24/2013 7:50 -24;-456;-77;12/24/2013 8:50 -25;-456;-10;12/24/2013 0:00 -26;-456;-12;12/24/2013 6:50 -27;-456;-12;12/24/2013 6:55 -28;-456;-12;12/24/2013 6:59 -29;-456;-12;12/24/2013 18:50 -30;-456;-12;12/24/2013 19:50 -31;-456;-14;12/24/2013 18:50 -32;-456;-8;12/24/2013 18:50 -33;-456;-8;12/24/2013 20:50 -34;-456;-8;12/24/2013 18:30 -35;-789;-1;8/19/2011 11:12 -36;-789;-3;8/19/2011 11:12 -37;-789;-3;8/19/2011 0:12 -38;-789;-3;8/19/2011 0:52 -39;-789;-5;8/19/2011 11:12 -40;-789;-9;8/19/2011 11:12 -41;-789;-9;8/19/2011 0:12 -42;-789;-9;8/19/2011 13:12 -43;-789;-10;8/19/2011 0:00 -44;-789;-11;8/19/2011 11:12 -45;-789;-13;8/19/2011 19:12 -46;-789;-15;8/19/2011 19:12 -47;-789;-15;8/19/2011 19:14 -48;-789;-15;8/19/2011 19:22 -49;-789;-15;8/19/2011 19:32 -50;-789;-15;8/19/2011 19:42 -1001;-321;-6;3/11/2012 10:57 -1002;-321;-7;3/11/2012 10:57 -1010;-321;-10;4/11/2012 0:00 -1003;-321;-1;4/11/2012 10:57 -1004;-321;-2;4/11/2012 10:57 -1005;-321;-3;4/11/2012 10:57 -1006;-321;-4;4/11/2012 10:57 -1008;-321;-8;4/11/2012 10:57 -1009;-321;-9;4/11/2012 10:57 -1011;-321;-11;4/11/2012 10:57 -1012;-321;-12;4/11/2012 10:57 -1013;-321;-13;4/11/2012 10:57 -1014;-321;-12;4/12/2012 3:57 -1015;-321;-14;4/12/2012 3:57 -1016;-321;-15;4/12/2012 3:57 -1017;-321;-16;4/12/2012 3:57 -1018;-321;-13;4/12/2012 8:57 -1019;-321;-5;4/12/2012 8:57 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "patient_item", delim=";") dataTextStr = \ """item_collection_id;external_id;name;section;subgroup -1;-1;Test Order Set - 1;Meds;TreatmentMeds -2;-1;Test Order Set - 1;Meds;SymptomsMeds -3;-1;Test Order Set - 1;Labs;GeneralLabs -4;-2;Test Order Set - 2;Labs;GeneralLabs -5;-2;Test Order Set - 2;Imaging;Xrays -6;-2;Test Order Set - 2;Imaging;AdvancedImaging -7;-3;Test Order Set - 3;Imaging;GeneralImaging -8;-3;Test Order Set - 3;Nursing;GeneralNursing -9;-4;Test Order Set - 4;Ad-hoc Orders;Ad-hoc Orders """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "item_collection", delim=";") dataTextStr = \ """item_collection_item_id;item_collection_id;clinical_item_id;collection_type_id -1;-1;-12;4 -2;-1;-13;4 -3;-2;-11;4 -4;-2;-10;4 -5;-3;-1;4 -6;-3;-2;4 -7;-4;-2;4 -8;-4;-3;4 -9;-5;-5;4 -10;-6;-6;4 -11;-6;-7;4 -12;-6;-8;4 -74;-6;-4;4 -77;-6;-77;4 -13;-7;-5;4 -14;-7;-6;4 -15;-8;-14;4 -16;-8;-15;4 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "item_collection_item", delim=";") dataTextStr = \ """patient_item_collection_link_id;patient_item_id;item_collection_item_id -1;-3;-5 -2;-4;-6 -3;-15;-15 -4;-32;-12 -1001;-1003;-5 -1002;-1004;-6 -1003;-1015;-15 -1004;-1019;-9 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "patient_item_collection_link", delim=";") # Sample Prepared Validation File self.validationFileStr = \ """patient_id\tqueryItemCountByIdJSON\tverifyItemCountByIdJSON\tbaseItemId\tbaseItemDate\tqueryStartTime\tqueryEndTime\tverifyEndTime\toutcome.7 -123\t{"-1": 1, "-2": 1, "-3": 1, "-4": 1, "-8": 1, "-9": 1, "-10": 1, "-11": 1, "-12": 1, "-13": 1}\t{"-12": 1, "-14": 1, "-15": 1, "-16": 1}\t10\t2012-04-11 00:00:00\t2012-04-11 10:57:00\t2012-04-11 14:57:00\t2012-04-12 10:57:00\t0 -456\t{"-4": 2, "-77": 1, "-10": 1, "-12": 3}\t{"-12": 2, "-14": 1, "-8": 3}\t10\t2013-12-24 00:00:00\t2013-12-24 06:50:00\t2013-12-24 10:50:00\t2013-12-25 06:50:00\t1 -789\t{"-1": 1, "-3": 3, "-5": 1, "-9": 3, "-10": 1, "-11": 1}\t{"-13": 1, "-15": 5}\t10\t2011-08-19 00:00:00\t2011-08-19 11:12:00\t2011-08-19 15:12:00\t2011-08-20 11:12:00\t0 -321\t{"-1": 1, "-2": 1, "-3": 1, "-4": 1, "-8": 1, "-9": 1, "-10": 1, "-11": 1, "-12": 1, "-13": 1}\t{"-12": 1, "-14": 1, "-15": 1, "-16": 1}\t10\t2012-04-11 00:00:00\t2012-04-11 10:57:00\t2012-04-11 14:57:00\t2012-04-12 10:57:00\t0 """ # Another Sample Prepared Validation File, with key Order Set triggers self.orderSetValidationFileStr = \ """patient_id\tqueryItemCountByIdJSON\tverifyItemCountByIdJSON\tbaseItemId\tbaseItemDate\tqueryStartTime\tqueryEndTime\tverifyEndTime\toutcome.7\torder_set_id -123\t{"-10": 1}\t{"-1": 1, "-2": 1, "-3": 1, "-4": 1, "-8": 1, "-9": 1, "-11": 1, "-12": 1, "-13": 1}\t10\t2012-04-11 00:00:00\t2012-04-11 10:57:00\t2012-04-11 10:57:00\t2012-04-11 11:57:00\t0\t-1 -456\t{"-10": 1, "-4": 2, "-77": 1, "-12": 4, "-14": 1, "-8": 1}\t{"-12": 1, "-8": 2}\t10\t2013-12-24 00:00:00\t2013-12-24 06:50:00\t2013-12-24 18:50:00\t2013-12-24 19:50:00\t1\t-2 -789\t{"-1": 1, "-3": 3, "-5": 1, "-9": 3, "-10": 1, "-11": 1}\t{"-13": 1, "-15": 5}\t10\t2011-08-19 00:00:00\t2011-08-19 11:12:00\t2011-08-19 15:12:00\t2011-08-20 11:12:00\t0\t-4 -321\t{"-10": 1}\t{"-1": 1, "-2": 1, "-3": 1, "-4": 1, "-8": 1, "-9": 1, "-11": 1, "-12": 1, "-13": 1}\t10\t2012-04-11 00:00:00\t2012-04-11 10:57:00\t2012-04-11 10:57:00\t2012-04-11 11:57:00\t0\t-1 -321\t{"-10": 1, "-1": 1, "-2": 1, "-3": 1, "-4": 1, "-8": 1, "-9": 1, "-11": 1, "-12": 1, "-13": 1}\t{"-12": 1,"-14": 1, "-15": 1, "-16": 1}\t10\t2012-04-11 00:00:00\t2012-04-11 10:57:00\t2012-04-12 3:57:00\t2012-04-12 4:57:00\t0\t-3 """ self.analyzer = OrderSetUsageAnalysis()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata() headers = [ "stride_preadmit_med_id", "pat_anon_id", "contact_date", "medication_id", "description", "thera_class", "pharm_class", "pharm_subclass" ] dataModels = \ [ # Deliberately design dates in far future to facilitate isolated testing RowItemModel([-100, -1000, datetime(2113, 7, 6), -5680, "NORVASC 5 MG PO TABS", "CARDIAC DRUGS", "CALCIUM CHANNEL BLOCKING AGENTS", "Calcium Channel Blockers - Dihydropyridines"], headers ), RowItemModel([-110, -2000, datetime(2110, 3, 8), -6540, "PRILOSEC 20 MG PO CPDR", "GASTROINTESTINAL", "PROTON-PUMP INHIBITORS", "Gastric Acid Secretion Reducing Agents - Proton Pump Inhibitors (PPIs)"], headers ), RowItemModel([-120, -2000, datetime(2110, 3, 8), -8113, "TRIAMCINOLONE 0.1% CREAM", "SKIN PREPS", "TOPICAL ANTI-INFLAMMATORY STEROIDAL", "Dermatological - Glucocorticoid"], headers ), # Multiple or no mappings RowItemModel([-130, -3000, datetime(2109, 9,20),-126745, "NORETHINDRN ESTRADIOL", "CONTRACEPTIVES", "CONTRACEPTIVES,ORAL", "Contraceptive Oral - Monophasic"], headers ), RowItemModel([-140, -4000, datetime(2110, 5, 4), -28384, "HYDROCODONE-ACETAMINOPHEN 10-325 MG PO TABS", "ANALGESICS", "ANALGESICS, NARCOTICS", "Analgesic Narcotic Hydrocodone Combinations"], headers ), # Excessively complex mapping RowItemModel([-150, -5000, datetime(2108, 8, 6), -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", "BIOLOGICALS", "GRAM POSITIVE COCCI VACCINES", "Vaccine Bacterial - Gram Positive Cocci"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_preadmit_med", dataModel, retrieveCol="pat_anon_id") # Mapping table to simplify dose headers = ["medication_id", "name", "rxcui", "active_ingredient"] dataModels = \ [ # Mappings to active ingredients RowItemModel( [ -5680, "NORVASC 5 MG PO TABS", -17767, "Amlodipine"], headers ), RowItemModel( [ -6540, "PRILOSEC 20 MG PO CPDR", -7646, "Omeprazole"], headers ), RowItemModel( [ -8113, "TRIAMCINOLONE ACETONIDE 0.1 % TP CREA", -10759, "Triamcinolone"], headers ), # If multiple active ingredients in a combo, unravel to active components RowItemModel( [ -28384, "HYDROCODONE-ACETAMINOPHEN 10-325 MG PO TABS", -161, "Acetaminophen"], headers ), RowItemModel( [ -28384, "HYDROCODONE-ACETAMINOPHEN 10-325 MG PO TABS", -5489, "Hydrocodone"], headers ), # No mapping entries for Norethindrone+Estradiol # Excessive mappings for pneumovax RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854930, "pneumococcal capsular polysaccharide type 1 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854932, "pneumococcal capsular polysaccharide type 10A vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854934, "pneumococcal capsular polysaccharide type 11A vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854936, "pneumococcal capsular polysaccharide type 12F vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854938, "pneumococcal capsular polysaccharide type 14 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854940, "pneumococcal capsular polysaccharide type 15B vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854942, "pneumococcal capsular polysaccharide type 17F vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854944, "pneumococcal capsular polysaccharide type 18C vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854946, "pneumococcal capsular polysaccharide type 19A vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854948, "pneumococcal capsular polysaccharide type 19F vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854950, "pneumococcal capsular polysaccharide type 2 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854952, "pneumococcal capsular polysaccharide type 20 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854954, "pneumococcal capsular polysaccharide type 22F vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854956, "pneumococcal capsular polysaccharide type 23F vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854958, "pneumococcal capsular polysaccharide type 3 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854960, "pneumococcal capsular polysaccharide type 33F vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854962, "pneumococcal capsular polysaccharide type 4 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854964, "pneumococcal capsular polysaccharide type 5 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854966, "pneumococcal capsular polysaccharide type 6B vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854968, "pneumococcal capsular polysaccharide type 7F vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854970, "pneumococcal capsular polysaccharide type 8 vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854972, "pneumococcal capsular polysaccharide type 9N vaccine"], headers ), RowItemModel( [ -95140, "PNEUMOCOCCAL 23-VALPS VACCINE 25 MCG/0.5 ML INJ INJ", -854974, "pneumococcal capsular polysaccharide type 9V vaccine"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_mapped_meds", dataModel, retrieveCol="rxcui") self.converter = STRIDEPreAdmitMedConversion()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self); log.info("Populate the database with test data") StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata(); self.orderMedIdStrList = list(); headers = ["order_med_id", "pat_id", "pat_enc_csn_id", "ordering_date", "medication_id", "description","freq_name","med_route","number_of_doses"]; dataModels = \ [ # Deliberately design dates in far future to facilitate isolated testing RowItemModel( [ -418063010, "3032765", 111, datetime(2111,12,12, 8,56), 9000000, "ZZZ IMS TEMPLATE","DAILY","PO", None], headers ), RowItemModel( [ -418436155, "1607844", 222, datetime(2111,12,20, 0,40), -1080, "BISACODYL 10 MG PR SUPP","DAILY PRN","PR", None], headers ), RowItemModel( [ -418436145, "1607844", 222, datetime(2111,12,22, 0,40), -1080, "BISACODYL 10 MG PR SUPP","DAILY","PR", None], headers ), RowItemModel( [ -421032269, "2968778", 333, datetime(2112, 2, 8,11,17), -96559, "PIPERACILLIN-TAZOBACTAM-DEXTRS 3.375 GRAM/50 ML IV PGBK","EVERY 6 HOURS","IV", None], headers ), RowItemModel( [ -418011851, "-2429057", 444, datetime(2111,12,10,19, 9), -10011, "FAMOTIDINE 20 MG PO TABS","2 TIMES DAILY","PO", None], headers ), RowItemModel( [ -418013851, "-2429057", 444, datetime(2111,12,10,19,10), -10012, "FAMOTIDINE 40 MG PO TABS","2 TIMES DAILY","PO", None], headers ), RowItemModel( [ -418062652, "3036488", 555, datetime(2111,12,12, 8,30), -5007, "METOPROLOL TARTRATE 5 MG/5 ML IV SOLN 20 mg injection","ONCE","IV", 1], headers ), RowItemModel( [ -418062352, "3016488", 666, datetime(2111,12,13, 8,30), -5007, "METOPROLOL TARTRATE 5 MG/5 ML IV SOLN","ONCE","IV", 1], headers ), RowItemModel( [ -414321352, "3036588", 777, datetime(2111,12,14, 8,30), -5007, "ZZZ IMS TEMPLATE","ONCE","IV", 1], headers ), # Simple mixture in unimportant base RowItemModel( [ -395900000, "1234567", 888, datetime(2111, 1, 2, 3, 0), -520102, "CEFEPIME 2 GM IVPB","ONCE","IV", 1], headers ), RowItemModel( [ -395800000, "1234567", 888, datetime(2111, 1,10, 3, 0), -520102, "CEFEPIME 2 GM IVPB","q8h","IV", 6], headers ), # Fixed number of doses RowItemModel( [ -395700000, "1234567", 888, datetime(2111, 3,10, 3, 0), -520102, "CEFEPIME 2 GM IVPB","q8h","IV", None], headers ), # No dose limit specified # Complex mixtures RowItemModel( [ -392000000, "1234567", 888, datetime(2111, 4, 1, 3, 0), -530000, "IVF Mix","ONCE","IV", 1], headers ), RowItemModel( [ -391000000, "1234567", 888, datetime(2111, 4, 2, 3, 0), -540000, "Mini TPN","ONCE","IV", 1], headers ), RowItemModel( [ -390000000, "1234567", 888, datetime(2111, 5, 2, 3, 0), -550000, "TPN Adult","Continuous","IV", None], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_order_med", dataModel, retrieveCol="order_med_id" ); self.orderMedIdStrList.append( str(dataItemId) ); # Child table for more detailed mixtures headers = ["order_med_id", "line", "medication_id", "medication_name","ingredient_type_c","ingredient_type"]; dataModels = \ [ # Just a dose combination RowItemModel( [ -418063010, 1, -6494, "PREDNISONE 10 MG PO TABS", 3, "Medications",], headers ), RowItemModel( [ -418063010, 2, -6498, "PREDNISONE 50 MG PO TABS", 3, "Medications",], headers ), # Simple mixture with a base fluid of negligible significance RowItemModel( [ -395900000, 1, -87114, "CEFEPIME 2 GRAM IV SOLR", 3, "Medications",], headers ), RowItemModel( [ -395900000, 2, -2364, "DEXTROSE 5 % IN WATER (D5W) IV SOLP", 1, "Base",], headers ), RowItemModel( [ -395800000, 1, -87114, "CEFEPIME 2 GRAM IV SOLR", 3, "Medications",], headers ), RowItemModel( [ -395800000, 2, -2364, "DEXTROSE 5 % IN WATER (D5W) IV SOLP", 1, "Base",], headers ), RowItemModel( [ -395700000, 1, -87114, "CEFEPIME 2 GRAM IV SOLR", 3, "Medications",], headers ), RowItemModel( [ -395700000, 2, -2364, "DEXTROSE 5 % IN WATER (D5W) IV SOLP", 1, "Base",], headers ), # IVF Mix RowItemModel( [ -392000000, 2, -2367, "DEXTROSE 70 % IN WATER (D70W) IV SOLP", 1, "Base",], headers ), RowItemModel( [ -392000000, 3, -7322, "SODIUM CHLORIDE 4 MEQ/ML IV SOLP", 2, "Additives",], headers ), RowItemModel( [ -392000000, 5, -116034, "POTASSIUM CHLORIDE 2 MEQ/ML IV SOLP", 2, "Additives",], headers ), # Mini mixture, expands RowItemModel( [ -391000000, 1, -203799, "PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP", 1, "Base",], headers ), RowItemModel( [ -391000000, 2, -2367, "DEXTROSE 70 % IN WATER (D70W) IV SOLP", 1, "Base",], headers ), RowItemModel( [ -391000000, 3, -7322, "SODIUM CHLORIDE 4 MEQ/ML IV SOLP", 2, "Additives",], headers ), RowItemModel( [ -391000000, 4, -7351, "SODIUM PHOSPHATE 3 MMOL/ML IV SOLN", 2, "Additives",], headers ), # Complex mixture RowItemModel( [ -390000000, 1, -203799, "PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP", 1, "Base",], headers ), RowItemModel( [ -390000000, 2, -2367, "DEXTROSE 70 % IN WATER (D70W) IV SOLP", 1, "Base",], headers ), RowItemModel( [ -390000000, 3, -7322, "SODIUM CHLORIDE 4 MEQ/ML IV SOLP", 2, "Additives",], headers ), RowItemModel( [ -390000000, 4, -7351, "SODIUM PHOSPHATE 3 MMOL/ML IV SOLN", 2, "Additives",], headers ), RowItemModel( [ -390000000, 5, -116034, "POTASSIUM CHLORIDE 2 MEQ/ML IV SOLP", 2, "Additives",], headers ), RowItemModel( [ -390000000, 6, -1312, "CALCIUM GLUCONATE 100 MG/ML (10%) IV SOLN", 2, "Additives",], headers ), RowItemModel( [ -390000000, 7, -4720, "MAGNESIUM SULFATE 4 MEQ/ML (50 %) INJ SOLN", 2, "Additives",], headers ), RowItemModel( [ -390000000, 8, -8047, "TRACE ELEM ZN-CUPRIC CL-MN-CR 0.8-0.2-0.16 MG IV SOLN", 2, "Additives",], headers ), RowItemModel( [ -390000000, 9, -124215, "MVI, ADULT NO.1 WITH VIT K 3,300 UNIT- 150 MCG/10 ML IV SOLN", 2, "Additives",], headers ), RowItemModel( [ -390000000, 10,-540571, "INSULIN REG HUMAN 100 UNITS/ML INJ", 2, "Additives",], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_order_medmixinfo", dataModel, retrieveCol="order_med_id" ); # Mapping table to simplify dose headers = ["medication_id", "name", "rxcui", "active_ingredient"]; dataModels = \ [ # If multiple active ingredients in a combo, unravel to active components RowItemModel( [ -96559, "PIPERACILLIN-TAZOBACTAM-DEXTRS 3.375 GRAM/50 ML IV PGBK", -1001, "Piperacillin"], headers ), RowItemModel( [ -96559, "PIPERACILLIN-TAZOBACTAM-DEXTRS 3.375 GRAM/50 ML IV PGBK", -1002, "Tazobactam"], headers ), # Multiple names / dosage totals for the same medication, use this mapping to narrow to a common ingredient RowItemModel( [ -10011, "FAMOTIDINE 20 MG PO TABS", -2001, "Famotidine"], headers ), RowItemModel( [ -10012, "FAMOTIDINE 40 MG PO TABS", -2001, "Famotidine"], headers ), RowItemModel( [ -1080, "BISACODYL 10 MG PR SUPP", -3001, "Bisacodyl"], headers ), RowItemModel( [ -6494, "PREDNISONE 10 MG PO TABS", -4001, "prednisone"], headers ), RowItemModel( [ -6498, "PREDNISONE 50 MG PO TABS", -4001, "prednisone"], headers ), # Simple mixture RowItemModel( [ -87114, "CEFEPIME 2 GRAM IV SOLR", -20481, "cefepime"], headers ), RowItemModel( [ -2364, "DEXTROSE 5% IN WATER (D5W) IV SOLP", -4850, "Glucose"], headers ), # Additional medication level mapping should probably ignored if have mixture components RowItemModel( [ -520102, "CEFEPIME 2 GM IVPB", -20481, "cefepime"], headers ), # Complex ingredients RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -10898, 'Tryptophan',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -11115, 'Valine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -4919, 'Glycine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -5340, 'Histidine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -6033, 'Isoleucine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -6308, 'Leucine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -6536, 'Lysine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -6837, 'Methionine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -8156, 'Phenylalanine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -8737, 'Proline',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -9671, 'Serine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -10524, 'Threonine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -10962, 'Tyrosine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -426, 'Alanine',], headers ), RowItemModel( [ -203799, 'PARENTERAL AMINO ACID 10% NO.6 10 % IV SOLP', -1091, 'Arginine',], headers ), RowItemModel( [ -2367, 'DEXTROSE 70% IN WATER (D70W) IV SOLP', -4850, 'Glucose',], headers ), RowItemModel( [ -7322, 'SODIUM CHLORIDE 4 MEQ/ML IV SOLP', -9863, 'Sodium Chloride',], headers ), RowItemModel( [ -7351, 'SODIUM PHOSPHATE 3 MILLIMOLE/ML IV SOLN', -235496, 'Sodium Phosphate, Monobasic',], headers ), RowItemModel( [ -7351, 'SODIUM PHOSPHATE 3 MILLIMOLE/ML IV SOLN', -236719, 'Sodium Phosphate, Dibasic',], headers ), RowItemModel( [ -116034, 'POTASSIUM CHLORIDE 2 MEQ/ML IV SOLP', -8591, 'Potassium Chloride',], headers ), RowItemModel( [ -1312, 'CALCIUM GLUCONATE 100 MG/ML (10%) IV SOLN', -1908, 'Calcium Gluconate',], headers ), RowItemModel( [ -4720, 'MAGNESIUM SULFATE 50 % (4 MEQ/ML) INJ SOLN', -6585, 'Magnesium Sulfate',], headers ), RowItemModel( [ -8047, 'TRACE ELEM ZN-CUPRIC CL-MN-CR 0.8-0.2-0.16 MG IV SOLN', -39937, 'zinc chloride',], headers ), RowItemModel( [ -8047, 'TRACE ELEM ZN-CUPRIC CL-MN-CR 0.8-0.2-0.16 MG IV SOLN', -21032, 'chromous chloride',], headers ), RowItemModel( [ -8047, 'TRACE ELEM ZN-CUPRIC CL-MN-CR 0.8-0.2-0.16 MG IV SOLN', -21579, 'Copper Sulfate',], headers ), RowItemModel( [ -8047, 'TRACE ELEM ZN-CUPRIC CL-MN-CR 0.8-0.2-0.16 MG IV SOLN', -29261, 'manganese chloride',], headers ), RowItemModel( [ -124215, 'MVI, ADULT NO.1 WITH VIT K 1-5-10-200 MG-MCG-MG-MG IV SOLN', -8308, 'Vitamin K 1',], headers ), RowItemModel( [ -124215, 'MVI, ADULT NO.1 WITH VIT K 1-5-10-200 MG-MCG-MG-MG IV SOLN', -89905, 'Multivitamin preparation',], headers ), RowItemModel( [ -540571, 'INSULIN REG HUMAN 100 UNITS/ML INJ', -253182, 'Regular Insulin, Human',], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_mapped_meds", dataModel, retrieveCol="rxcui" ); # Certain items drawn from order sets headers = ["order_med_id", "protocol_id","protocol_name","section_name","smart_group"]; dataModels = \ [ RowItemModel( [ -418436145, -111, "General Admit", "Medications", "Stool Softeners",], headers ), RowItemModel( [ -421032269, -111, "General Admit", "Medications", "Antibiotics",], headers ), RowItemModel( [ -391000000, -222, "Nutrition", "Infusions", "TPN",], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("stride_orderset_order_med", dataModel, retrieveCol="order_med_id" ); self.converter = STRIDEOrderMedConversion(); # Instance to test on
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self); log.info("Populate the database with test data") from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader; ClinicalItemDataLoader.build_clinical_item_psql_schemata(); self.clinicalItemCategoryIdStrList = list(); headers = ["clinical_item_category_id","source_table"]; dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel ); self.clinicalItemCategoryIdStrList.append( str(dataItemId) ); headers = ["clinical_item_id","clinical_item_category_id","name","analysis_status"]; dataModels = \ [ RowItemModel( [-1, -1, "CBC",1], headers ), RowItemModel( [-2, -1, "BMP",0], headers ), # Clear analysis status, so this will be ignored unless changed RowItemModel( [-3, -1, "Hepatic Panel",1], headers ), RowItemModel( [-4, -1, "Cardiac Enzymes",1], headers ), RowItemModel( [-5, -2, "CXR",1], headers ), RowItemModel( [-6, -2, "RUQ Ultrasound",1], headers ), RowItemModel( [-7, -2, "CT Abdomen/Pelvis",1], headers ), RowItemModel( [-8, -2, "CT PE Thorax",1], headers ), RowItemModel( [-9, -3, "Acetaminophen",1], headers ), RowItemModel( [-10, -3, "Carvedilol",1], headers ), RowItemModel( [-11, -3, "Enoxaparin",1], headers ), RowItemModel( [-12, -3, "Warfarin",1], headers ), RowItemModel( [-13, -3, "Ceftriaxone",1], headers ), RowItemModel( [-14, -4, "Admit",1], headers ), # Look for sequences of these RowItemModel( [-15, -4, "Discharge",1], headers ), RowItemModel( [-16, -4, "Readmit",1], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel ); headers = ["patient_item_id","encounter_id","patient_id","clinical_item_id","item_date"]; dataModels = \ [ RowItemModel( [-2, -111, -11111, -10, datetime(2000, 1, 1, 0)], headers ), RowItemModel( [-3, -111, -11111, -8, datetime(2000, 1, 1, 2)], headers ), RowItemModel( [-1, -111, -11111, -14, datetime(2000, 1, 1,10)], headers ), # Admit RowItemModel( [-4, -111, -11111, -10, datetime(2000, 1, 2, 0)], headers ), RowItemModel( [-5, -111, -11111, -12, datetime(2000, 2, 1, 0)], headers ), RowItemModel( [-6, -111, -11111, -15, datetime(2000, 2, 2, 0)], headers ), # Discharge RowItemModel( [-10, -111, -11111, -11, datetime(2000, 2, 2, 0)], headers ), RowItemModel( [-13, -111, -11111, -10, datetime(2000, 2, 2,10)], headers ), RowItemModel( [-7, -112, -11111, -9, datetime(2000, 3, 1, 0)], headers ), RowItemModel( [-8, -112, -11111, -14, datetime(2000, 3, 1, 1)], headers ), # Admit RowItemModel( [-9, -112, -11111, -8, datetime(2000, 3, 1, 1)], headers ), RowItemModel( [-11, -112, -11111, -15, datetime(2000, 3, 2, 0)], headers ), # Discharge RowItemModel( [-12, -112, -11111, -7, datetime(2000, 3, 2, 0)], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel ); self.analyzer = TripleAssociationAnalysis(); # Instance to test on
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() #self.purgeTestRecords(); self.clinicalItemCategoryIdStrList = list() headers = [ "clinical_item_category_id", "default_recommend", "source_table" ] dataModels = \ [ RowItemModel( [-1, 1, "Labs"], headers ), RowItemModel( [-2, 1, "Imaging"], headers ), RowItemModel( [-3, 1, "Meds"], headers ), RowItemModel( [-4, 1, "Nursing"], headers ), RowItemModel( [-5, 0, "Problems"], headers ), RowItemModel( [-6, 1, "Lab Results"], headers ), RowItemModel( [-7, 1, "Admit Dx"], headers ), RowItemModel( [-8, 0, "Demographics"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) self.clinicalItemCategoryIdStrList.append(str(dataItemId)) headers = [ "clinical_item_id", "clinical_item_category_id", "analysis_status", "default_recommend", "name" ] dataModels = \ [ RowItemModel( [-1, -1, 1, 1, "CBC"], headers ), RowItemModel( [-2, -1, 1, 1, "BMP"], headers ), RowItemModel( [-3, -1, 1, 1, "Hepatic Panel"], headers ), RowItemModel( [-4, -1, 1, 1, "Cardiac Enzymes"], headers ), RowItemModel( [-5, -2, 1, 1, "CXR"], headers ), RowItemModel( [-6, -2, 1, 1, "RUQ Ultrasound"], headers ), RowItemModel( [-7, -2, 1, 1, "CT Abdomen/Pelvis"], headers ), RowItemModel( [-8, -2, 1, 1, "CT PE Thorax"], headers ), RowItemModel( [-9, -3, 1, 1, "Acetaminophen"], headers ), RowItemModel( [-10, -3, 1, 1, "Carvedilol"], headers ), RowItemModel( [-11, -3, 1, 1, "Enoxaparin"], headers ), RowItemModel( [-12, -3, 1, 1, "Warfarin"], headers ), RowItemModel( [-13, -3, 1, 0, "Ceftriaxone"], headers ), RowItemModel( [-14, -4, 1, 1, "Foley Catheter"], headers ), RowItemModel( [-15, -4, 1, 1, "Strict I&O"], headers ), RowItemModel( [-16, -4, 1, 1, "Fall Precautions"], headers ), RowItemModel( [-22, -5, 1, 1, "Diagnosis 2"], headers ), RowItemModel( [-23, -5, 1, 1, "Diagnosis 3"], headers ), RowItemModel( [-24, -5, 1, 1, "Diagnosis 4"], headers ), RowItemModel( [-21, -7, 0, 1, "Diagnosis 1 (Admit)"], headers ), RowItemModel( [-25, -7, 1, 1, "Diagnosis 2 (Admit)"], headers ), RowItemModel( [-30, -6, 1, 1, "Troponin (High)"], headers ), RowItemModel( [-31, -6, 1, 1, "BNP (High)"], headers ), RowItemModel( [-32, -6, 1, 1, "Creatinine (High)"], headers ), RowItemModel( [-33, -6, 1, 1, "ESR (High)"], headers ), # Default exclude from recommendations RowItemModel( [-41, -8, 1, 1, "Male"], headers ), RowItemModel( [-42, -8, 1, 1, "Female"], headers ), RowItemModel( [-43, -8, 1, 1, "Birth"], headers ), RowItemModel( [-44, -8, 1, 1, "Birth1980s"], headers ), RowItemModel( [-45, -8, 1, 1, "Birth1970s"], headers ), RowItemModel( [-46, -8, 1, 1, "RaceWhite"], headers ), RowItemModel( [-47, -8, 1, 1, "RaceBlack"], headers ), RowItemModel( [-49, -8, 1, 1, "Death"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) headers = [ "patient_item_id", "patient_id", "clinical_item_id", "item_date", "analyze_date" ] dataModels = \ [ RowItemModel( [-101,-11111, -43, datetime(1972, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-102,-11111, -45, datetime(1972, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-103,-11111, -41, datetime(1972, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-104,-11111, -46, datetime(1972, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-52, -11111, -23, datetime(1999, 9, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-51, -11111, -21, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-1, -11111, -4, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-2, -11111, -10, datetime(2000, 1, 1, 1), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-3, -11111, -8, datetime(2000, 1, 1, 2), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-4, -11111, -4, datetime(2000, 1, 1, 3), datetime(2010, 1, 1, 0)], headers ), # Repeat item RowItemModel( [-60, -11111, -32, datetime(2000, 1, 1, 4), datetime(2010, 1, 1, 0)], headers ), # Within query time RowItemModel( [-61, -11111, -30, datetime(2000, 1, 4, 0), datetime(2010, 1, 1, 0)], headers ), # Within 1 week RowItemModel( [-63, -11111, -13, datetime(2000, 1, 4, 5), datetime(2010, 1, 1, 0)], headers ), # Exclude item RowItemModel( [-64, -11111, -24, datetime(2000, 1, 4,10), datetime(2010, 1, 1, 0)], headers ), # Exclude category RowItemModel( [-62, -11111, -31, datetime(2000, 1,10, 0), datetime(2010, 1, 1, 0)], headers ), # Beyond 1 week RowItemModel( [-71, -11111, -8, datetime(2000, 1, 4, 1), datetime(2010, 1, 1, 0)], headers ), # Repeat query item within 1 week verify period, don't use as a verify item RowItemModel( [-201, -11111,-49, datetime(2009, 1, 1, 1), datetime(2010, 1, 1, 0)], headers ), # Death date in far future RowItemModel( [-5, -11111, -12, datetime(2000, 2, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-121,-22222, -43, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-122,-22222, -44, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-123,-22222, -42, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-124,-22222, -47, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-10, -22222, -7, datetime(2000, 1, 5, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-12, -22222, -6, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-13, -22222, -11, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-131,-33333, -43, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-132,-33333, -44, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-133,-33333, -42, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-134,-33333, -46, datetime(1983, 5, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-14, -33333, -6, datetime(2000, 2, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-15, -33333, -2, datetime(2000, 2,11, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-141,-44444, -43, datetime(1975, 3, 3, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-142,-44444, -45, datetime(1975, 3, 3, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-143,-44444, -42, datetime(1975, 3, 3, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-144,-44444, -46, datetime(1975, 3, 3, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-20, -44444, -21, datetime(2000, 1, 5, 0), datetime(2010, 1, 1, 0)], headers ), # Admit diagnosis RowItemModel( [-22, -44444, -6, datetime(2000, 1, 5, 0), datetime(2010, 1, 1, 0)], headers ), # Items recorded with date level precision, not time RowItemModel( [-23, -44444, -12, datetime(2000, 1, 5, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-24, -44444, -11, datetime(2000, 1, 6, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-25, -44444, -8, datetime(2000, 1, 6, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-204,-44444,-49, datetime(2000, 2, 1, 1), datetime(2010, 1, 1, 0)], headers ), # Death date within 1 month # Order Set Usage example RowItemModel( [-5002,-55555, -3, datetime(2000,10, 1, 0, 0), datetime(2010, 1, 1, 0)], headers ), # Very old item, not relevant to current query RowItemModel( [-5040,-55555, -25, datetime(2000,10,10, 0, 0), datetime(2010, 1, 1, 0)], headers ), # Admit diagnosis (coded at date level precision before time-level order data) RowItemModel( [-5005,-55555, -2, datetime(2000,10,10,10, 0), datetime(2010, 1, 1, 0)], headers ), # Non-order set item before RowItemModel( [-5010,-55555, -1, datetime(2000,10,10,10, 5), datetime(2010, 1, 1, 0)], headers ), # Order Set 1 RowItemModel( [-5020,-55555, -9, datetime(2000,10,10,10, 5), datetime(2010, 1, 1, 0)], headers ), # Order Set 1 RowItemModel( [-5030,-55555, -5, datetime(2000,10,10,10,10), datetime(2010, 1, 1, 0)], headers ), # Ad-hoc within 1 hour RowItemModel( [-5050,-55555, -8, datetime(2000,10,10,10,30), datetime(2010, 1, 1, 0)], headers ), # Order Set 2 RowItemModel( [-5060,-55555, -11, datetime(2000,10,10,10,30), datetime(2010, 1, 1, 0)], headers ), # Order Set 2 RowItemModel( [-5070,-55555, -12, datetime(2000,10,10,10,30), datetime(2010, 1, 1, 0)], headers ), # Ad-hoc Within 1 hour RowItemModel( [-5080,-55555, -10, datetime(2000,10,10,20, 0), datetime(2010, 1, 1, 0)], headers ), # Ad-hoc 10 hours later RowItemModel( [-5090,-55555, -1, datetime(2000,10,10,20, 0), datetime(2010, 1, 1, 0)], headers ), # Order Set 1 again (ignore repeats) RowItemModel( [-5100,-55555, -2, datetime(2000,10,10,20, 0), datetime(2010, 1, 1, 0)], headers ), # Order Set 1 again RowItemModel( [-5110,-55555, -3, datetime(2000,10,10,20, 0), datetime(2010, 1, 1, 0)], headers ), # Ad-hoc 10 hours later ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel) dataTextStr = \ """item_collection_id;external_id;name;section;subgroup -1;-1;Test Order Set - 1;Meds;TreatmentMeds -2;-1;Test Order Set - 1;Meds;SymptomsMeds -3;-1;Test Order Set - 1;Labs;GeneralLabs -4;-2;Test Order Set - 2;Labs;GeneralLabs -5;-2;Test Order Set - 2;Imaging;Xrays -6;-2;Test Order Set - 2;Imaging;AdvancedImaging -7;-3;Test Order Set - 3;Imaging;GeneralImaging -8;-3;Test Order Set - 3;Nursing;GeneralNursing """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "item_collection", delim=";") dataTextStr = \ """item_collection_item_id;item_collection_id;clinical_item_id;collection_type_id -1;-1;-11;4 -2;-1;-12;4 -3;-1;-13;4 -4;-2;-9;4 -5;-2;-10;4 -6;-3;-1;4 -7;-3;-2;4 -8;-3;-3;4 -100;-3;-4;4 -9;-4;-1;4 -10;-4;-2;4 -11;-4;-3;4 -101;-4;-11;4 -12;-5;-5;4 -74;-6;-6;4 -77;-6;-7;4 -13;-6;-8;4 -14;-7;-5;4 -15;-7;-6;4 -16;-7;-7;4 -17;-7;-8;4 -18;-8;-14;4 -19;-8;-15;4 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "item_collection_item", delim=";") dataTextStr = \ """patient_item_collection_link_id;patient_item_id;item_collection_item_id -1;-5010;-6 -2;-5020;-4 -3;-5050;-13 -4;-5060;-101 -5;-5090;-6 -6;-5100;-7 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(dataTextStr), "patient_item_collection_link", delim=";") # Instance to test on self.analyzer = PreparePatientItems()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) self.manager = SimManager() # Instance to test on from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.manager.buildCPOESimSchema() log.info("Populate the database with test data") # Basically import a bunch of rigged CSV or TSV files that have realistic simulating case and grading data # Get that data into the test database clinical_item_category_str = \ """clinical_item_category_id;source_table 1;source_table """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_category_str), "clinical_item_category", delim=";") clinical_item_str = \ """clinical_item_id;clinical_item_category_id;name 1;1;Clinical item 1 2;1;Clinical item 2 3;1;Clinical item 3 4;1;Clinical item 4 5;1;Clinical item 5 6;1;Clinical item 6 7;1;Clinical item 7 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_str), "clinical_item", delim=";") clinical_item_str = \ """sim_user_id;name 0;Default user 1;Jonathan Chen 2;User 2 3;User 3 4;User 4 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_str), "sim_user", delim=";") sim_patient_str = \ """sim_patient_id;name;age_years;gender 1;Patient One;40;Male 2;Patient Two;50;Female 3;Patient Three;60;Male 4;Patient Four;70;Female 5;Patient Five;80;Male 6;Patient Six;90;Female 7;Patient Seven;100;Male """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_patient_str), "sim_patient", delim=";") sim_state_str = \ """sim_state_id;name 1;Sim state 1 2;Sim state 2 3;Sim state 3 4;Sim state 4 5;Sim state 5 6;Sim state 6 7;Sim state 7 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_state_str), "sim_state", delim=";") sim_patient_order_str = \ """sim_patient_order_id;sim_user_id;sim_patient_id;clinical_item_id;relative_time_start;sim_state_id 1;0;1;1;1;1 2;1;1;2;2;2 3;1;1;3;3;3 4;1;1;4;4;4 5;1;1;5;5;5 6;1;1;6;6;6 7;1;1;7;7;7 8;2;2;1;1;1 9;3;2;2;2;1 10;3;2;3;3;2 11;2;3;1;1;1 12;3;3;2;2;2 13;3;3;3;3;3 14;1;4;1;1;2 15;1;4;2;2;3 16;2;5;1;1;3 17;2;5;2;2;4 18;3;6;4;1;1 19;3;6;4;2;2 20;3;6;4;3;3 21;4;7;5;1;1 22;4;7;5;2;2 23;4;7;5;3;3 24;4;7;5;4;4 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_patient_order_str), "sim_patient_order", delim=";") sim_grading_key_str = \ """sim_grader_id;sim_state_id;clinical_item_id;score;group_name Jonathan Chen;1;1;1;g1 Jonathan Chen;2;2;1;g2 Jonathan Chen;3;3;1;g3 Jonathan Chen;4;4;1; Jonathan Chen;5;5;1;g5 Jonathan Chen;6;6;1; Jonathan Chen;7;7;1;g7 Jonathan Chen;3;1;1;g8 Jonathan Chen;4;2;1;g8 Jonathan Chen;1;4;-1000; Jonathan Chen;2;4;10; Jonathan Chen;3;4;2000; Jonathan Chen;1;5;-1000;g9 Jonathan Chen;2;5;-1; Jonathan Chen;3;5;0;g10 Jonathan Chen;3;5;-500; """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_grading_key_str), "sim_grading_key", delim=";")
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() log.info("Populate the database with test data") self.clinicalItemCategoryIdStrList = list() headers = ["clinical_item_category_id", "source_table"] dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) self.clinicalItemCategoryIdStrList.append(str(dataItemId)) headers = [ "clinical_item_id", "clinical_item_category_id", "name", "analysis_status" ] dataModels = \ [ RowItemModel( [-1, -1, "CBC",1], headers ), RowItemModel( [-2, -1, "BMP",0], headers ), # Clear analysis status, so this will be ignored unless changed RowItemModel( [-3, -1, "Hepatic Panel",1], headers ), RowItemModel( [-4, -1, "Cardiac Enzymes",1], headers ), RowItemModel( [-5, -2, "CXR",1], headers ), RowItemModel( [-6, -2, "RUQ Ultrasound",1], headers ), RowItemModel( [-7, -2, "CT Abdomen/Pelvis",1], headers ), RowItemModel( [-8, -2, "CT PE Thorax",1], headers ), RowItemModel( [-9, -3, "Acetaminophen",1], headers ), RowItemModel( [-10, -3, "Carvedilol",1], headers ), RowItemModel( [-11, -3, "Enoxaparin",1], headers ), RowItemModel( [-12, -3, "Warfarin",1], headers ), RowItemModel( [-13, -3, "Ceftriaxone",1], headers ), RowItemModel( [-14, -4, "Foley Catheter",1], headers ), RowItemModel( [-15, -4, "Strict I&O",1], headers ), RowItemModel( [-16, -4, "Fall Precautions",1], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) self.clinicalItemQuery = \ """ select clinical_item_id, name, analysis_status, default_recommend from clinical_item where clinical_item_id < 0 order by clinical_item_id desc """ headers = [ "patient_item_id", "patient_id", "clinical_item_id", "item_date", "analyze_date" ] dataModels = \ [ RowItemModel( [-1, -11111, -4, datetime(2000, 1, 1, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-2, -11111, -10, datetime(2000, 1, 1, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-3, -11111, -8, datetime(2000, 1, 1, 2), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-4, -11111, -10, datetime(2000, 1, 2, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-5, -11111, -12, datetime(2000, 2, 1, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-10, -22222, -7, datetime(2000, 1, 5, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-12, -22222, -6, datetime(2000, 1, 9, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-13, -22222, -11, datetime(2000, 1, 9, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-14, -33333, -6, datetime(2000, 2, 9, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-15, -33333, -2, datetime(2000, 2,11, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-16, -33333, -11, datetime(2000, 2,11, 0), datetime(2100, 1, 1, 0)], headers ), RowItemModel( [-17, -33333, -11, datetime(2001, 1, 1, 0), datetime(2100, 1, 1, 0)], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel) self.patientItemQuery = \ """ select patient_item_id, patient_id, clinical_item_id, item_date, analyze_date from patient_item where clinical_item_id < 0 order by patient_id desc, item_date, patient_item_id desc """ headers = [ "clinical_item_id","subsequent_item_id",\ "count_0","count_3600","count_86400","count_604800","count_any", "time_diff_sum","time_diff_sum_squares", "patient_count_0","patient_count_3600","patient_count_86400","patient_count_604800","patient_count_any", "patient_time_diff_sum","patient_time_diff_sum_squares", "patient_count_0","encounter_count_0", ] dataModels = \ [ RowItemModel( [-11,-11, 3, 3, 3, 3, 4, 999.0, 9999.0, 2, 2, 2, 2, 2, 999.0, 9999.0, 2,2], headers ), RowItemModel( [-11, -7, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, 0, 0, 0, 0.0, 0.0, 0,0], headers ), RowItemModel( [-11, -6, 1, 1, 1, 1, 1, 0.0, 0.0, 1, 1, 1, 1, 1, 0.0, 0.0, 1,1], headers ), RowItemModel( [-11, -2, 1, 1, 1, 1, 1, 0.0, 0.0, 1, 1, 1, 1, 1, 0.0, 0.0, 1,1], headers ), RowItemModel( [ -7,-11, 0, 0, 0, 1, 1, 345600.0, 119439360000.0, 0, 0, 0, 1, 1, 345600.0, 119439360000.0, 0,0], headers ), RowItemModel( [ -7, -7, 1, 1, 1, 1, 1, 0.0, 0.0, 1, 1, 1, 1, 1, 0.0, 0.0, 1,1], headers ), RowItemModel( [ -7, -6, 0, 0, 0, 1, 1, 345600.0, 119439360000.0, 0, 0, 0, 1, 1, 345600.0, 119439360000.0, 0,0], headers ), RowItemModel( [ -6,-11, 1, 1, 1, 2, 2, 172800.0, 29859840000.0, 1, 1, 1, 2, 2, 172800.0, 29859840000.0, 1,1], headers ), RowItemModel( [ -6, -7, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, 0, 0, 0, 0.0, 0.0, 0,0], headers ), RowItemModel( [ -6, -6, 2, 2, 2, 2, 2, 0.0, 0.0, 2, 2, 2, 2, 2, 0.0, 0.0, 2,2], headers ), RowItemModel( [ -6, -2, 0, 0, 0, 1, 1, 172800.0, 29859840000.0, 0, 0, 0, 1, 1, 172800.0, 29859840000.0, 0,0], headers ), RowItemModel( [ -2,-11, 1, 1, 1, 1, 1, 0.0, 0.0, 1, 1, 1, 1, 1, 0.0, 0.0, 1,1], headers ), RowItemModel( [ -2, -7, 1, 1, 1, 1, 1, 0.0, 0.0, 1, 1, 1, 1, 1, 0.0, 0.0, 1,1], headers ), RowItemModel( [ -2, -6, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, 0, 0, 0, 0.0, 0.0, 0,0], headers ), RowItemModel( [ -2, -2, 1, 1, 1, 1, 1, 0.0, 0.0, 1, 1, 1, 1, 1, 0.0, 0.0, 1,1], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_association", dataModel) self.clinicalItemAssociationQuery = \ """ select clinical_item_id, subsequent_item_id, count_0,count_3600,count_86400,count_604800,count_any, time_diff_sum,time_diff_sum_squares, patient_count_0,patient_count_3600,patient_count_86400,patient_count_604800,patient_count_any, patient_time_diff_sum, patient_time_diff_sum_squares from clinical_item_association where clinical_item_id < 0 order by clinical_item_id, subsequent_item_id """ self.analyzer = DataManager() # Instance to test on self.analyzer.maxClinicalItemId = 0
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.clinicalItemCategoryIdStrList = list() headers = ["clinical_item_category_id", "source_table"] dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) self.clinicalItemCategoryIdStrList.append(str(dataItemId)) headers = [ "clinical_item_id", "clinical_item_category_id", "name", "analysis_status" ] dataModels = \ [ RowItemModel( [1, -1, "CBC",1], headers ), RowItemModel( [2, -1, "BMP",0], headers ), # Clear analysis status, so this will be ignored unless changed RowItemModel( [3, -1, "Hepatic Panel",1], headers ), RowItemModel( [4, -1, "Cardiac Enzymes",1], headers ), RowItemModel( [5, -2, "CXR",1], headers ), RowItemModel( [6, -2, "RUQ Ultrasound",1], headers ), RowItemModel( [7, -2, "CT Abdomen/Pelvis",1], headers ), RowItemModel( [8, -2, "CT PE Thorax",1], headers ), RowItemModel( [9, -3, "Acetaminophen",1], headers ), RowItemModel( [10, -3, "Carvedilol",1], headers ), RowItemModel( [11, -3, "Enoxaparin",1], headers ), RowItemModel( [12, -3, "Warfarin",1], headers ), RowItemModel( [13, -3, "Ceftriaxone",1], headers ), RowItemModel( [14, -4, "Foley Catheter",1], headers ), RowItemModel( [15, -4, "Strict I&O",1], headers ), RowItemModel( [16, -4, "Fall Precautions",1], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) # Input file contents in Bag-of-Words formats # Specifically avoid the use of items 6 or 7 in the training data self.inputBOWFileStr = \ """[[1,1],[2,2],[3,1],[4,4],[5,10],[8,5]] [[3,4],[4,4],[9,3],[10,2],[12,6],[13,3],[15,5],[16,8]] [[1,1],[2,2],[3,1],[4,4],[5,10],[8,5],[9,1],[10,2],[11,1],[12,4],[13,10],[14,1],[15,3],[16,5]] [[1,4],[2,9],[9,1],[10,2],[11,7],[12,4],[13,2],[16,6]] [[4,3],[5,31],[8,5],[12,6],[13,8],[16,5]] """ self.instance = TopicModel()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() log.info("Populate the database with test data") self.clinicalItemCategoryIdStrList = list() headers = ["clinical_item_category_id", "source_table"] dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) self.clinicalItemCategoryIdStrList.append(str(dataItemId)) headers = ["clinical_item_id", "clinical_item_category_id", "name"] dataModels = \ [ RowItemModel( [-1, -1, "CBC"], headers ), RowItemModel( [-2, -1, "BMP"], headers ), RowItemModel( [-3, -1, "Hepatic Panel"], headers ), RowItemModel( [-4, -1, "Cardiac Enzymes"], headers ), RowItemModel( [-5, -2, "CXR"], headers ), RowItemModel( [-6, -2, "RUQ Ultrasound"], headers ), RowItemModel( [-7, -2, "CT Abdomen/Pelvis"], headers ), RowItemModel( [-8, -2, "CT PE Thorax"], headers ), RowItemModel( [-9, -3, "Acetaminophen"], headers ), RowItemModel( [-10, -3, "Carvedilol"], headers ), RowItemModel( [-11, -3, "Enoxaparin"], headers ), RowItemModel( [-12, -3, "Warfarin"], headers ), RowItemModel( [-13, -3, "Ceftriaxone"], headers ), RowItemModel( [-14, -4, "Foley Catheter"], headers ), RowItemModel( [-15, -4, "Strict I&O"], headers ), RowItemModel( [-16, -4, "Fall Precautions"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) headers = [ "patient_item_id", "patient_id", "clinical_item_id", "item_date", "analyze_date" ] dataModels = \ [ RowItemModel( [-1, -11111, -4, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-2, -11111, -10, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-3, -11111, -8, datetime(2000, 1, 1, 2), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-4, -11111, -10, datetime(2000, 1, 2, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-5, -11111, -12, datetime(2000, 2, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-10, -22222, -7, datetime(2000, 1, 5, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-12, -22222, -6, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-13, -22222, -11, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-14, -33333, -6, datetime(2000, 2, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-15, -33333, -2, datetime(2000, 2,11, 0), datetime(2010, 1, 1, 0)], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel) headers = \ [ "clinical_item_id","subsequent_item_id", "patient_count_0","patient_count_3600","patient_count_86400","patient_count_604800","patient_count_any", "time_diff_sum", "time_diff_sum_squares", ] dataModels = \ [ RowItemModel( [ -1, -1, 30, 30, 30, 30, 30, 0.0, 0.0], headers ), RowItemModel( [ -2, -2, 30, 30, 30, 30, 30, 0.0, 0.0], headers ), RowItemModel( [ -3, -3, 95, 95, 97, 97, 97, 0.0, 0.0], headers ), RowItemModel( [ -4, -4, 40, 40, 40, 40, 40, 0.0, 0.0], headers ), RowItemModel( [ -5, -5, 40, 40, 50, 50, 50, 0.0, 0.0], headers ), RowItemModel( [ -6, -6, 70, 70, 70, 70, 70, 0.0, 0.0], headers ), RowItemModel( [ -2, -3, 0, 0, 0, 0, 0, 0.0, 0.0], headers ), # Zero count associations, probably shouldn't even be here. If so, ignore them anyway RowItemModel( [ -2, -4, 0, 2, 3, 3, 3, 200.0, 50000.0], headers ), RowItemModel( [ -2, -6, 2, 2, 5, 5, 5, 300.0, 11990.0], headers ), RowItemModel( [ -3, -1, 20, 23, 23, 23, 23, 400.0, 344990.0], headers ), RowItemModel( [ -4, -5, 3, 3, 13, 43, 43, 340.0, 343110.0], headers ), RowItemModel( [ -4, -6, 23, 33, 33, 33, 63, 420.0, 245220.0], headers ), RowItemModel( [ -4, -7, 23, 33, 33, 33, 63, 40.0, 5420.0], headers ), RowItemModel( [ -5, -4, 0, 0, 20, 20, 20, 540.0, 54250.0], headers ), RowItemModel( [ -6, -2, 7, 7, 7, 7, 7, 1.0, 1.0], headers ), RowItemModel( [ -6, -4, 20, 20, 20, 20, 20, 1.0, 1.0], headers ), ] for dataModel in dataModels: # Add non patient_count variations (Adding 5 to values that are >5 and not for the zero time interval) for header in headers: if header.startswith("patient_count_"): timeStr = header[len("patient_count_"):] dataModel["count_%s" % timeStr] = dataModel[header] # Copy over value if timeStr != "0" and dataModel[header] > 5: dataModel["count_%s" % timeStr] += 5 (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_association", dataModel) # Indicate that cache data needs to be updated self.dataManager = DataManager() self.dataManager.clearCacheData("analyzedPatientCount") self.dataManager.clearCacheData("clinicalItemCountsUpdated") self.recommender = ItemAssociationRecommender()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) self.usage_reporter = SimManager() from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.usage_reporter.buildCPOESimSchema() log.info("Populate the database with test data") # Basically import a bunch of rigged CSV or TSV files that have realistic simulating case and grading data # Get that data into the test database clinical_item_category_str = \ """clinical_item_category_id;source_table 1;source_table """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_category_str), "clinical_item_category", delim=";") clinical_item_str = \ """clinical_item_id;clinical_item_category_id;name 1;1;Clinical item 1 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_str), "clinical_item", delim=";") clinical_item_str = \ """sim_user_id;name 1;Jonathan Chen """ # Parse into DB insertion object DBUtil.insertFile(StringIO(clinical_item_str), "sim_user", delim=";") sim_patient_str = \ """sim_patient_id;name;age_years;gender 1;Patient One;40;Male """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_patient_str), "sim_patient", delim=";") sim_state_str = \ """sim_state_id;name 1;Sim state 1 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_state_str), "sim_state", delim=";") sim_patient_order_str = \ """sim_patient_order_id;sim_user_id;sim_patient_id;clinical_item_id;relative_time_start;sim_state_id 1;1;1;1;1;1 """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_patient_order_str), "sim_patient_order", delim=";") sim_grading_key_str = \ """sim_grader_id;sim_state_id;clinical_item_id;score;group_name;sim_case_name Jonathan Chen;1;1;1;g1;case_name Andre Kumar;1;1;2;g1;case_name """ # Parse into DB insertion object DBUtil.insertFile(StringIO(sim_grading_key_str), "sim_grading_key", delim=";") # Prepare survey file self.survey_csv = tempfile.NamedTemporaryFile(mode='w+', delete=False) self.survey_csv.write("Physician User Name,resident" + os.linesep + "Jonathan Chen,1") self.survey_csv.flush()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self); log.info("Populate the database with test data") from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader; ClinicalItemDataLoader.build_clinical_item_psql_schemata(); self.clinicalItemCategoryIdStrList = list(); headers = ["clinical_item_category_id","default_recommend","source_table"]; dataModels = \ [ RowItemModel( [-1, 1, "Labs"], headers ), RowItemModel( [-2, 1, "Imaging"], headers ), RowItemModel( [-3, 1, "Meds"], headers ), RowItemModel( [-4, 0, "Nursing"], headers ), # Disable default recommend to allow for checks RowItemModel( [-5, 0, "Problems"], headers ), RowItemModel( [-6, 1, "Lab Results"], headers ), RowItemModel( [-7, 1, "Admit Dx"], headers ), RowItemModel( [-8, 0, "Demographics"], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel ); self.clinicalItemCategoryIdStrList.append( str(dataItemId) ); headers = ["clinical_item_id","clinical_item_category_id","default_recommend","item_count","name"]; dataModels = \ [ RowItemModel( [-1, -1, 1, 30, "CBC"], headers ), RowItemModel( [-2, -1, 1, 30, "BMP"], headers ), RowItemModel( [-3, -1, 1, 95, "Hepatic Panel"], headers ), RowItemModel( [-4, -1, 1, 40, "Cardiac Enzymes"], headers ), RowItemModel( [-5, -2, 1, 40, "CXR"], headers ), RowItemModel( [-6, -2, 1, 70, "RUQ Ultrasound"], headers ), RowItemModel( [-7, -2, 1, 70, "CT Abdomen/Pelvis"], headers ), RowItemModel( [-8, -2, 1, 35, "CT PE Thorax"], headers ), RowItemModel( [-9, -3, 1, 0, "Acetaminophen"], headers ), RowItemModel( [-10, -3, 1, 45, "Carvedilol"], headers ), RowItemModel( [-11, -3, 1, 50, "Enoxaparin"], headers ), RowItemModel( [-12, -3, 1, 75, "Warfarin"], headers ), RowItemModel( [-13, -3, 0, 0, "Ceftriaxone"], headers ), # Disable default recommend to allow for checks RowItemModel( [-14, -4, 1, 0, "Foley Catheter"], headers ), RowItemModel( [-15, -4, 1, 0, "Strict I&O"], headers ), RowItemModel( [-16, -4, 1, 0, "Fall Precautions"], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel ); headers = ["patient_item_id","patient_id","clinical_item_id","item_date","analyze_date"]; dataModels = \ [ RowItemModel( [-1, -11111, -4, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-2, -11111, -10, datetime(2000, 1, 1, 1), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-3, -11111, -8, datetime(2000, 1, 1, 2), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-5, -11111, -12, datetime(2000, 2, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-6, -11111, -6, datetime(2000, 2, 1, 1), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-10, -22222, -7, datetime(2000, 1, 5, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-12, -22222, -6, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-13, -22222, -11, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-14, -33333, -6, datetime(2000, 2, 9, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-15, -33333, -2, datetime(2000, 2,11, 0), datetime(2010, 1, 1, 0)], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel ); headers = \ [ "clinical_item_id","subsequent_item_id", "count_0","count_3600","count_86400","count_604800","count_any", "time_diff_sum", "time_diff_sum_squares", ]; dataModels = \ [ RowItemModel( [ -1, -1, 30, 30, 30, 30, 30, 0.0, 0.0], headers ), RowItemModel( [ -2, -2, 30, 30, 30, 30, 30, 0.0, 0.0], headers ), RowItemModel( [ -3, -3, 95, 95, 97, 97, 97, 0.0, 0.0], headers ), RowItemModel( [ -4, -4, 40, 40, 40, 40, 40, 0.0, 0.0], headers ), RowItemModel( [ -5, -5, 40, 40, 50, 50, 50, 0.0, 0.0], headers ), RowItemModel( [ -6, -6, 70, 70, 70, 70, 70, 0.0, 0.0], headers ), RowItemModel( [ -7, -7, 70, 70, 70, 70, 70, 0.0, 0.0], headers ), RowItemModel( [ -8, -8, 35, 35, 35, 50, 80, 0.0, 0.0], headers ), RowItemModel( [-10,-10, 45, 45, 55, 60, 90, 0.0, 0.0], headers ), RowItemModel( [-11,-11, 50, 50, 50, 80, 90, 0.0, 0.0], headers ), RowItemModel( [-12,-12, 75, 75, 75, 80, 90, 0.0, 0.0], headers ), RowItemModel( [ -2, -4, 0, 2, 3, 3, 3, 200.0, 50000.0], headers ), RowItemModel( [ -2, -6, 2, 2, 5, 5, 5, 300.0, 11990.0], headers ), RowItemModel( [ -3, -1, 20, 23, 23, 23, 23, 400.0, 344990.0], headers ), RowItemModel( [ -4, -5, 3, 3, 13, 43, 43, 340.0, 343110.0], headers ), RowItemModel( [ -4, -6, 23, 33, 33, 33, 63, 420.0, 245220.0], headers ), RowItemModel( [ -4, -7, 27, 33, 33, 33, 63, 40.0, 5420.0], headers ), RowItemModel( [ -4,-10, 25, 35, 40, 45, 63, 47.0, 5420.0], headers ), RowItemModel( [ -5, -4, 0, 0, 20, 20, 20, 540.0, 54250.0], headers ), RowItemModel( [ -8,-12, 15,15, 15, 15, 15, 25.0, 520.0], headers ), RowItemModel( [ -10,-11, 12,12, 16, 16, 20, 20.0, 220.0], headers ), RowItemModel( [ -10,-12, 10,10, 10, 10, 10, 20.0, 120.0], headers ), ]; for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_association", dataModel ); dataTextStr = \ """item_collection_id;external_id;name;section;subgroup -1;-1;Test Order Set - 1;Meds;TreatmentMeds -2;-1;Test Order Set - 1;Meds;SymptomsMeds -3;-1;Test Order Set - 1;Labs;GeneralLabs -4;-2;Test Order Set - 2;Labs;GeneralLabs -5;-2;Test Order Set - 2;Imaging;Xrays -6;-2;Test Order Set - 2;Imaging;AdvancedImaging -7;-3;Test Order Set - 3;Imaging;GeneralImaging -8;-3;Test Order Set - 3;Nursing;GeneralNursing -9;-3;Test Order Set - 3;Meds;RandomMeds """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "item_collection", delim=";"); dataTextStr = \ """item_collection_item_id;item_collection_id;clinical_item_id;collection_type_id -1;-1;-11;4 -2;-1;-12;4 -3;-1;-13;4 -4;-2;-9;4 -5;-2;-10;4 -6;-3;-1;4 -7;-3;-2;4 -8;-3;-3;4 -100;-3;-4;4 -9;-4;-1;4 -10;-4;-2;4 -11;-4;-3;4 -101;-4;-11;4 -12;-5;-5;4 -74;-6;-6;4 -77;-6;-7;4 -13;-6;-8;4 -14;-7;-5;4 -15;-7;-6;4 -16;-7;-7;4 -17;-7;-8;4 -18;-8;-14;4 -19;-8;-15;4 -20;-9;-11;4 -21;-9;-12;4 -22;-9;-13;4 """ # Parse into DB insertion object DBUtil.insertFile( StringIO(dataTextStr), "item_collection_item", delim=";"); # Instance to test on self.analyzer = RecommendationClassificationAnalysis(); self.preparer = PreparePatientItems();
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") StrideLoader.build_stride_psql_schemata() ClinicalItemDataLoader.build_clinical_item_psql_schemata() dataTextStr = """order_proc_id\tpat_id\tpat_enc_csn_id\torder_type\tproc_id\tproc_code\tdescription -30560253\t-7803\t-1772\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -31300455\t-2168\t-261\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -29501223\t-9860\t-1772\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -31823670\t-2130\t-3897\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -31237072\t-124\t-8391\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -29966444\t-5690\t-1150\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -33197720\t-9926\t-4898\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -36668349\t-9815\t-3658\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -33280031\t-3858\t-6463\tLab\t471521\tLABACETA\tACETAMINOPHEN, SERUM -38543619\t-6562\t-4489\tLab\t898794\tLABCSMP\tCANCER SOMATIC MUTATION PANEL -35954787\t-7074\t-6965\tLab\t898794\tLABCSMP\tCANCER SOMATIC MUTATION PANEL -22793877\t-3261\t-4837\tLab\t471944\tLABCBCD\tCBC WITH DIFF -40604146\t-7480\t-8730\tLab\t896082\t10355R\tHLA - MONITORING BY IGG -33765278\t-4255\t-622\tLab\t896082\t10355R\tHLA - MONITORING BY IGG -39004110\t-5750\t-4953\tLab\t472748\tLABYLEPTN\tLEPTIN -22910018\t-1862\t-621\tLab\t472785\tLABMGN\tMAGNESIUM, SERUM/PLASMA -22840955\t-9532\t-639\tLab\t472837\tLABTNI\tTROPONIN I -21479311\t-9844\t-5135\tLab\t473684\tLABMETB\tMETABOLIC PANEL, BASIC -19231504\t-1518\t-3744\tLab\t473684\tLABMETB\tMETABOLIC PANEL, BASIC -19007449\t-9542\t-4105\tLab\t473684\tLABMETB\tMETABOLIC PANEL, BASIC -1748206\t-1099\t-9890\tLab\t473766\tLABY25VD\tVITAMIN D, 25-HYDROXY -2794591\t-4038\t-6687\tLab\t473766\tLABY25VD\tVITAMIN D, 25-HYDROXY -3580354\t-2795\t-752\tLab\t473766\tLABY25VD\tVITAMIN D, 25-HYDROXY -3347071\t-6139\t-7104\tLab\t473766\tLABY25VD\tVITAMIN D, 25-HYDROXY -4464954\t-4591\t-1383\tLab\t473766\tLABY25VD\tVITAMIN D, 25-HYDROXY -3393444\t-5157\t-5537\tLab\t473766\tLABY25VD\tVITAMIN D, 25-HYDROXY -2658433\t-6894\t-211\tLab\t473766\tLABY25VD\tVITAMIN D, 25-HYDROXY """ DBUtil.insertFile(StringIO(dataTextStr), "stride_order_proc", delim="\t") # Deliberately design dates in far future to facilitate isolated testing dataTextStr = \ """order_proc_id\tline\tresult_time\tcommon_name\tbase_name\tord_num_value\tresult_flag\tresult_in_range_yn -4464954\t2\t5/28/2113 23:28\t25-HYDROXY D3\t25OHD3\t55\tNone\tNone -3580354\t2\t12/17/2113 0:40\t25-HYDROXY D3\t25OHD3\t49\tNone\tNone -3393444\t2\t10/9/2113 5:03\t25-HYDROXY D3\t25OHD3\t65\tNone\tNone -3347071\t2\t9/8/2113 22:10\t25-HYDROXY D3\t25OHD3\t2\tNone\tNone -2794591\t2\t3/19/2113 19:26\t25-HYDROXY D3\t25OHD3\t70\tNone\tNone -2658433\t2\t7/5/2111 0:28\t25-HYDROXY D3\t25OHD3\t45\tNone\tNone -1748206\t2\t7/3/2111 14:21\t25-HYDROXY D3\t25OHD3\t50\tNone\tNone -36668349\t1\t10/30/2111 7:23\tACETAMINOPHEN(ACETA)\tACETA\t7.7\tNone\tNone -33280031\t1\t11/29/2111 7:41\tACETAMINOPHEN(ACETA)\tACETA\t9999999\tNone\tNone -33197720\t1\t11/29/2111 15:22\tACETAMINOPHEN(ACETA)\tACETA\tNone\tNone\tNone -31823670\t1\t11/29/2111 14:08\tACETAMINOPHEN(ACETA)\tACETA\t5.4\tNone\tNone -31300455\t1\t11/29/2111 18:58\tACETAMINOPHEN(ACETA)\tACETA\t270.7\tNone\tNone -31237072\t1\t11/29/2111 5:45\tACETAMINOPHEN(ACETA)\tACETA\t50.6\tNone\tNone -30560253\t1\t11/29/2111 16:13\tACETAMINOPHEN(ACETA)\tACETA\t2.6\tNone\tNone -29966444\t1\t11/29/2111 2:27\tACETAMINOPHEN(ACETA)\tACETA\t4.2\tNone\tNone -29501223\t1\t11/29/2111 0:15\tACETAMINOPHEN(ACETA)\tACETA\t5.1\tNone\tNone -22793877\t4\t11/29/2111 14:36\tHEMATOCRIT(HCT)\tHCT\t19.7\tLow Panic\tNone -22793877\t3\t11/30/2111 7:36\tHEMOGLOBIN(HGB)\tHGB\t7\tLow Panic\tNone -40604146\t15\t12/13/2111 18:12\tINTERPRETATION/ COMMENTS CLASS II 9374R\t9374R\tNone\tNone\tNone -33765278\t10\t9/22/2112 20:26\tINTERPRETATION/ COMMENTS CLASS II 9374R\t9374R\t9999999\tNone\tNone -39004110\t1\t8/26/2112 15:07\tLEPTIN\tYLEPT1\t20\tNone\tNone -22910018\t1\t11/13/2112 8:18\tMAGNESIUM, SER/PLAS(MGN)\tMG\t2.1\tNone\tY -22793877\t6\t10/17/2112 1:09\tMCH(MCH)\tMCH\t31.7\tNone\tY -22793877\t7\t12/13/2112 2:54\tMCHC(MCHC)\tMCHC\t35.4\tNone\tY -22793877\t5\t11/11/2112 2:54\tMCV(MCV)\tMCV\t89.7\tNone\tY -22793877\t9\t1/30/2113 13:28\tPLATELET COUNT(PLT)\tPLT\t11\tLow\tNone -22793877\t2\t7/11/2113 23:24\tRBC(RBC)\tRBC\t2.2\tLow\tNone -22793877\t8\t1/27/2113 14:44\tRDW(RDW)\tRDW\t33.3\tHigh\tNone -21479311\t1\t8/31/2109 15:42\tSODIUM, SER/PLAS\tNA\t142\tNone\tNone -19231504\t1\t8/20/2109 12:22\tSODIUM, SER/PLAS\tNA\t134\tLow\tNone -19007449\t1\t9/13/2109 11:55\tSODIUM, SER/PLAS\tNA\t157\tHigh\tNone -38543619\t15\t10/23/2109 14:30\tTP53(GTP53)\tGTP53\t9999999\tNone\tNone -35954787\t15\t8/19/2109 16:39\tTP53(GTP53)\tGTP53\t9999999\tNone\tNone -22793877\t1\t9/25/2109 16:10\tWBC(WBC)\tWBC\t0.2\tLow Panic\tNone """ DBUtil.insertFile(StringIO(dataTextStr), "stride_order_results", delim="\t", dateColFormats={"result_time": None}) self.converter = STRIDEOrderResultsConversion()
def setUp(self): """Prepare state for test cases""" DBTestCase.setUp(self) log.info("Populate the database with test data") from stride.clinical_item.ClinicalItemDataLoader import ClinicalItemDataLoader ClinicalItemDataLoader.build_clinical_item_psql_schemata() self.clinicalItemCategoryIdStrList = list() headers = ["clinical_item_category_id", "source_table"] dataModels = \ [ RowItemModel( [-1, "Labs"], headers ), RowItemModel( [-2, "Imaging"], headers ), RowItemModel( [-3, "Meds"], headers ), RowItemModel( [-4, "Nursing"], headers ), RowItemModel( [-5, "Problems"], headers ), RowItemModel( [-6, "Lab Results"], headers ), RowItemModel( [-7, "Admit Dx"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_category", dataModel) self.clinicalItemCategoryIdStrList.append(str(dataItemId)) headers = [ "clinical_item_id", "clinical_item_category_id", "analysis_status", "name" ] dataModels = \ [ RowItemModel( [-1, -1, 1, "CBC"], headers ), RowItemModel( [-2, -1, 1, "BMP"], headers ), RowItemModel( [-3, -1, 1, "Hepatic Panel"], headers ), RowItemModel( [-4, -1, 1, "Cardiac Enzymes"], headers ), RowItemModel( [-5, -2, 1, "CXR"], headers ), RowItemModel( [-6, -2, 1, "RUQ Ultrasound"], headers ), RowItemModel( [-7, -2, 1, "CT Abdomen/Pelvis"], headers ), RowItemModel( [-8, -2, 1, "CT PE Thorax"], headers ), RowItemModel( [-9, -3, 1, "Acetaminophen"], headers ), RowItemModel( [-10, -3, 1, "Carvedilol"], headers ), RowItemModel( [-11, -3, 1, "Enoxaparin"], headers ), RowItemModel( [-12, -3, 1, "Warfarin"], headers ), RowItemModel( [-13, -3, 1, "Ceftriaxone"], headers ), RowItemModel( [-14, -4, 1, "Admit"], headers ), RowItemModel( [-15, -4, 1, "Discharge"], headers ), RowItemModel( [-16, -4, 1, "Readmit"], headers ), RowItemModel( [-22, -5, 1, "Diagnosis 2"], headers ), RowItemModel( [-23, -5, 1, "Diagnosis 3"], headers ), RowItemModel( [-24, -5, 1, "Diagnosis 4"], headers ), RowItemModel( [-30, -6, 1, "Troponin (High)"], headers ), RowItemModel( [-31, -6, 1, "BNP (High)"], headers ), RowItemModel( [-32, -6, 1, "Creatinine (High)"], headers ), RowItemModel( [-33, -6, 1, "ESR (High)"], headers ), RowItemModel( [-21, -7, 0, "Diagnosis 1"], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item", dataModel) headers = [ "patient_item_id", "patient_id", "clinical_item_id", "item_date", "analyze_date" ] dataModels = \ [ RowItemModel( [-52, -11111, -23, datetime(1999, 9, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-51, -11111, -21, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-1, -11111, -4, datetime(2000, 1, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-2, -11111, -10, datetime(2000, 1, 1, 1), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-3, -11111, -8, datetime(2000, 1, 1, 2), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-5, -11111, -12, datetime(2000, 2, 1, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-60, -11111, -32, datetime(2000, 1, 1, 4), datetime(2010, 1, 1, 0)], headers ), # Within query time RowItemModel( [-61, -11111, -30, datetime(2000, 1, 4, 0), datetime(2010, 1, 1, 0)], headers ), # Within 1 week RowItemModel( [-62, -11111, -31, datetime(2000, 1,10, 0), datetime(2010, 1, 1, 0)], headers ), # Past 1 week RowItemModel( [-55, -22222, -21, datetime(2000, 1, 8, 0), datetime(2010, 1, 1, 0)], headers ), # Admit Dx RowItemModel( [-12, -22222, -6, datetime(2000, 1, 8, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-13, -22222, -14, datetime(2000, 1, 8, 1), datetime(2010, 1, 1, 0)], headers ), # Admit RowItemModel( [-14, -22222, -7, datetime(2000, 1, 8, 2), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-15, -22222, -8, datetime(2000, 1, 8, 3), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-16, -22222, -15, datetime(2000, 1, 9, 0), datetime(2010, 1, 1, 0)], headers ), # Discharge RowItemModel( [-56, -22222, -21, datetime(2000, 1,13, 0), datetime(2010, 1, 1, 0)], headers ), # Admit Dx RowItemModel( [-17, -22222, -9, datetime(2000, 1,13, 0), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-19, -22222, -14, datetime(2000, 1,13, 1), datetime(2010, 1, 1, 0)], headers ), # Admit (Readmit) RowItemModel( [-20, -22222, -10, datetime(2000, 1,13, 2), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-21, -22222, -11, datetime(2000, 1,13, 3), datetime(2010, 1, 1, 0)], headers ), RowItemModel( [-22, -22222, -15, datetime(2000, 1,18, 0), datetime(2010, 1, 1, 0)], headers ), # Discharge ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("patient_item", dataModel) headers = \ [ "clinical_item_id","subsequent_item_id", "count_0","count_3600","count_86400","count_604800","count_any", "time_diff_sum", "time_diff_sum_squares", ] dataModels = \ [ RowItemModel( [ -1, -1, 30, 30, 30, 30, 30, 0.0, 0.0], headers ), RowItemModel( [ -2, -2, 30, 30, 30, 30, 30, 0.0, 0.0], headers ), RowItemModel( [ -3, -3, 95, 95, 97, 97, 97, 0.0, 0.0], headers ), RowItemModel( [ -4, -4, 40, 40, 40, 40, 40, 0.0, 0.0], headers ), RowItemModel( [ -5, -5, 40, 40, 50, 50, 50, 0.0, 0.0], headers ), RowItemModel( [ -6, -6, 70, 70, 70, 70, 70, 0.0, 0.0], headers ), RowItemModel( [ -7, -7, 70, 70, 70, 70, 70, 0.0, 0.0], headers ), RowItemModel( [ -8, -8, 35, 35, 35, 50, 80, 0.0, 0.0], headers ), RowItemModel( [-10,-10, 45, 45, 55, 60, 90, 0.0, 0.0], headers ), RowItemModel( [-12,-12, 75, 75, 75, 80, 90, 0.0, 0.0], headers ), RowItemModel( [-14,-14, 100, 100, 100, 100, 100, 0.0, 0.0], headers ), RowItemModel( [-15,-15, 100, 100, 100, 100, 100, 0.0, 0.0], headers ), RowItemModel( [-16,-16, 30, 30, 30, 30, 30, 0.0, 0.0], headers ), RowItemModel( [-30,-30, 3, 3, 3, 3, 3, 0.0, 0.0], headers ), RowItemModel( [-31,-31, 4, 4, 4, 4, 4, 0.0, 0.0], headers ), RowItemModel( [-32,-32, 4, 4, 4, 4, 4, 0.0, 0.0], headers ), RowItemModel( [-33,-33, 5, 5, 5, 5, 5, 0.0, 0.0], headers ), RowItemModel( [ -2, -4, 0, 2, 3, 3, 3, 200.0, 50000.0], headers ), RowItemModel( [ -2, -6, 2, 2, 5, 5, 5, 300.0, 11990.0], headers ), RowItemModel( [ -3, -1, 20, 23, 23, 23, 23, 400.0, 344990.0], headers ), RowItemModel( [ -4, -5, 3, 3, 13, 43, 43, 340.0, 343110.0], headers ), RowItemModel( [ -4, -6, 23, 33, 33, 33, 63, 420.0, 245220.0], headers ), RowItemModel( [ -4, -7, 27, 33, 33, 33, 63, 40.0, 5420.0], headers ), RowItemModel( [ -4,-10, 25, 35, 40, 45, 63, 47.0, 5420.0], headers ), RowItemModel( [ -5, -4, 0, 0, 20, 20, 20, 540.0, 54250.0], headers ), RowItemModel( [ -6,-16, 10, 10, 10, 10, 10, 0.0, 0.0], headers ), RowItemModel( [ -8,-16, 5, 5, 5, 5, 5, 0.0, 0.0], headers ), RowItemModel( [-10,-16, 8, 8, 8, 8, 8, 0.0, 0.0], headers ), RowItemModel( [-10,-30, 10, 10, 10, 10, 10, 0.0, 0.0], headers ), RowItemModel( [-10,-31, 10, 10, 10, 10, 10, 0.0, 0.0], headers ), RowItemModel( [-12,-30, 20, 20, 20, 20, 20, 0.0, 0.0], headers ), RowItemModel( [-12,-31, 20, 20, 20, 20, 20, 0.0, 0.0], headers ), RowItemModel( [-10,-32, 10, 10, 10, 10, 10, 0.0, 0.0], headers ), RowItemModel( [-10,-33, 10, 10, 10, 10, 10, 0.0, 0.0], headers ), ] for dataModel in dataModels: (dataItemId, isNew) = DBUtil.findOrInsertItem("clinical_item_association", dataModel) # Indicate that cache data needs to be updated self.dataManager = DataManager() self.dataManager.clearCacheData("analyzedPatientCount") self.dataManager.clearCacheData("clinicalItemCountsUpdated") # Instance to test on self.analyzer = OutcomePredictionAnalysis() self.preparer = PreparePatientItems()