def search_plan_add_filter_dental(constrains, detail_constrains): """ Add a filter for medical plan for dental plan :param constrains: current constains on <plans> table :param detail_constrains: detail constrains on <dental_plans> table """ filters = list() filters.append((1, "State")) filters.append((2, "Plan Type")) filters.append((3, "QHP Type")) filters.append((4, "Child Option")) filters.append((5, "Metal level")) filters.append((6, "Quit")) utils.print_data_frame(filters, ["Index", "Filter"]) instruction = "\nPlease select an filter:" values = list(str(i) for i in range(1, 1 + len(filters))) index = wait_input(instruction, values) if index == -1: return if index.strip() == "1": # Decide constrains for state state_list = Query.get_plan_state() utils.print_data_frame(state_list, ["State"]) instruction = "\nPlease select a state: " values = list(value[0] for value in state_list) state = wait_input(instruction, values) if state == -1: return constrains[const.PLAN_STATE] = (const.EQUAL, state) elif index.strip() == "2": # Decide constrains for plan type keys = list(Enum.plan_type.keys()) utils.print_series(keys, "Plan Type", showindex=True) instruction = "\nWhich type of plan do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return constrains[const.PLAN_TYPE] = (const.EQUAL, Enum.plan_type[keys[int(index)]]) elif index.strip() == "3": # Decide constrains for QHP type keys = list(Enum.qhp_type.keys()) utils.print_series(keys, "QHP Type", showindex=True) instruction = "\nWhich QHP type do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return constrains[const.QHP_TYPE] = (const.EQUAL, Enum.qhp_type[keys[int(index)]]) elif index.strip() == "4": # Decide constrains for child option keys = list(Enum.child_only_type.keys()) utils.print_series(keys, "Child Option", showindex=True) instruction = "\nWhich child option do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return constrains[const.CHILD_ONLY] = (const.EQUAL, Enum.child_only_type[keys[int(index)]]) elif index.strip() == "5": # Decide constrains for metal level keys = list(Enum.d_metal_type.keys()) utils.print_series(keys, "Metal Level", showindex=True) instruction = "\nWhich metal level do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return detail_constrains[const.M_METAL_LEVEL] = ( const.EQUAL, Enum.d_metal_type[keys[int(index)]]) elif index.strip() == "6": print("Quit.") return else: print("Invalid Index.")
def search_plan_add_filter_medical(constrains, detail_constrains): """ Add a filter for medical plan :param constrains: current constains on <plans> table :param detail_constrains: detail constrains on <medical_plans> table """ filters = list() filters.append((1, "State")) filters.append((2, "Plan Type")) filters.append((3, "QHP Type")) filters.append((4, "Child Option")) filters.append((5, "Metal level")) filters.append((6, "Notice for pregnancy Required")) filters.append((7, "Wellness Program Offered")) filters.append((8, "Quit")) utils.print_data_frame(filters, ["Index", "Filter"]) instruction = "\nPlease select an filter:" values = list(str(i) for i in range(1, 1 + len(filters))) index = wait_input(instruction, values) if index == -1: return if index.strip() == "1": # Decide constrains for state state_list = Query.get_plan_state() utils.print_data_frame(state_list, ["State"]) instruction = "\nPlease select a state: " values = list(value[0] for value in state_list) state = wait_input(instruction, values) if state == -1: return constrains[const.PLAN_STATE] = (const.EQUAL, state) elif index.strip() == "2": # Decide constrains for plan type keys = list(Enum.plan_type.keys()) utils.print_series(keys, "Plan Type", showindex=True) instruction = "\nWhich type of plan do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return constrains[const.PLAN_TYPE] = (const.EQUAL, Enum.plan_type[keys[int(index)]]) elif index.strip() == "3": # Decide constrains for QHP type keys = list(Enum.qhp_type.keys()) utils.print_series(keys, "QHP Type", showindex=True) instruction = "\nWhich QHP type do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return constrains[const.QHP_TYPE] = (const.EQUAL, Enum.qhp_type[keys[int(index)]]) elif index.strip() == "4": # Decide constrains for child option keys = list(Enum.child_only_type.keys()) utils.print_series(keys, "Child Option", showindex=True) instruction = "\nWhich child option do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return constrains[const.CHILD_ONLY] = (const.EQUAL, Enum.child_only_type[keys[int(index)]]) elif index.strip() == "5": # Decide constrains for metal level keys = list(Enum.m_metal_type.keys()) utils.print_series(keys, "Metal Level", showindex=True) instruction = "\nWhich metal level do you want?: " values = list(str(i) for i in range(len(keys))) index = wait_input(instruction, values) if index == -1: return detail_constrains[const.M_METAL_LEVEL] = ( const.EQUAL, Enum.m_metal_type[keys[int(index)]]) elif index.strip() == "6": # Decide constrains for pregnancy notice instruction = "\nWhether notice required for pregnancy?(yes/no): " values = ["yes", "no"] value = wait_input(instruction, values) if value == -1: return detail_constrains[const.PREG_NOTICE] = ( const.EQUAL, True) if value == "yes" else (const.EQUAL, False) elif index.strip() == "7": # Decide constrains for wellness program of plan instruction = "\nDo you want wellness program included?(yes/no): " values = ["yes", "no"] value = wait_input(instruction, values) if value == -1: return detail_constrains[const.WELLNESS_OFFER] = ( const.EQUAL, True) if value == "yes" else (const.EQUAL, False) elif index.strip() == "8": print("Quit.") return else: print("Invalid Index.")