def check_use_cache(file_types, cache_timestamp): """ Check if cache at HUB server is still usable. @param file_types: the file types,it is supposed to be a str array, each item in the array should be a non-None/empty str. Required. @param cache_timestamp: the cache timestamp, it is supposed to be None or a non-None datetime. Optional, default to None. """ if cache_timestamp is None: return False if config.dbconfig["type"]=='redis': claimPersistence = RedisClaimPersistence() elif config.dbconfig["type"] == "mysql": claimPersistence = MySQLClaimPersistence() else: raise ValueError("Invalid db type: " + config.dbconfig["type"]) claimPersistence.connectionConfig = config.dbconfig claimFile = CSVClaimFile() processor = ClaimFileProcessor() processor.claimPersistence = claimPersistence processor.claimFile = claimFile for one_type in file_types: if processor.queryDataSize(one_type, "LAST_MODIFY > " + cache_timestamp.strftime('%Y%m%d%H%M%S') + "") > 0: return False return True
def check_use_cache(file_types, cache_timestamp): """ Check if cache at HUB server is still usable. @param file_types: the file types,it is supposed to be a str array, each item in the array should be a non-None/empty str. Required. @param cache_timestamp: the cache timestamp, it is supposed to be None or a non-None datetime. Optional, default to None. """ if cache_timestamp is None: return False if config.dbconfig["type"] == 'redis': claimPersistence = RedisClaimPersistence() elif config.dbconfig["type"] == "mysql": claimPersistence = MySQLClaimPersistence() else: raise ValueError("Invalid db type: " + config.dbconfig["type"]) claimPersistence.connectionConfig = config.dbconfig claimFile = CSVClaimFile() processor = ClaimFileProcessor() processor.claimPersistence = claimPersistence processor.claimFile = claimFile for one_type in file_types: if processor.queryDataSize( one_type, "LAST_MODIFY > " + cache_timestamp.strftime('%Y%m%d%H%M%S') + "") > 0: return False return True
def main(): """ The main execution section that will accept user parameters and either query for data and put it into a file, or query for data row count, or write a file into the DB. The writing can accept a directory instead, but all files must be of the same claim type. """ # Obtain parameters import argparse parser = argparse.ArgumentParser(description='Healthcare Fraud Prevention') parser.add_argument("-o", dest="operation", help="operation type") parser.add_argument("-t", dest="claimType", help="claim type") parser.add_argument("-f", dest="filename", help="file name") parser.add_argument("-q", dest="query", help="query string") parser.add_argument("-n", dest="pageNumber", help="page number") parser.add_argument("-s", dest="pageSize", help="page size") args = parser.parse_args() # Instantiate relevant classes if config.dbconfig["type"] == "redis": claimPersistence = RedisClaimPersistence() elif config.dbconfig["type"] == "mysql": claimPersistence = MySQLClaimPersistence() else: raise ValueError("Invalid db type: " + config.dbconfig["type"]) claimPersistence.connectionConfig = config.dbconfig claimFile = CSVClaimFile() processor = ClaimFileProcessor() processor.claimPersistence = claimPersistence processor.claimFile = claimFile if not args.operation: raise ValueError("Operation type is required") elif args.operation == "write": processor.writeFile(args.claimType, args.filename) elif args.operation == "query": processor.queryData(args.claimType, args.query, args.pageNumber, args.pageSize, args.filename) elif args.operation == "querySize": rowCount = processor.queryDataSize(args.claimType, args.query) print(rowCount) else: raise IllegalArgumentException("Unsupported operation %s" % args.operation)
def main(): """ The main execution section that will accept user parameters and either query for data and put it into a file, or query for data row count, or write a file into the DB. The writing can accept a directory instead, but all files must be of the same claim type. """ # Obtain parameters import argparse parser = argparse.ArgumentParser(description='Healthcare Fraud Prevention') parser.add_argument("-o", dest="operation", help="operation type") parser.add_argument("-t", dest="claimType", help="claim type") parser.add_argument("-f", dest="filename", help="file name") parser.add_argument("-q", dest="query", help="query string") parser.add_argument("-n", dest="pageNumber", help="page number") parser.add_argument("-s", dest="pageSize", help="page size") args = parser.parse_args() # Instantiate relevant classes if config.dbconfig["type"] == "redis": claimPersistence = RedisClaimPersistence() elif config.dbconfig["type"] == "mysql": claimPersistence = MySQLClaimPersistence() else: raise ValueError("Invalid db type: " + config.dbconfig["type"]) claimPersistence.connectionConfig = config.dbconfig claimFile = CSVClaimFile() processor = ClaimFileProcessor() processor.claimPersistence = claimPersistence processor.claimFile = claimFile if not args.operation: raise ValueError("Operation type is required") elif args.operation == "write": processor.writeFile(args.claimType, args.filename) elif args.operation == "query": processor.queryData(args.claimType, args.query, args.pageNumber, args.pageSize, args.filename) elif args.operation == "querySize": rowCount = processor.queryDataSize(args.claimType, args.query) print(rowCount) else: raise IllegalArgumentException("Unsupported operation %s" % args.operation)