def create_test_request(data): patient = DAO.get_patient(data.get('patient')) laboratory = DAO.get_laboratory(data.get('laboratory')) lab_time_slot = laboratory.get_time_slot(data.get('time_slot'), ) test_ids = data.get('tests') cost = 0 for test_id in test_ids: cost += Insurance.get_price(laboratory.get_test(id=test_id), patient) test_request = TestRequest() test_request.save(time_slot=lab_time_slot, cost=cost, address=data.get('address'), test_ids=test_ids) payment_url = test_request.get_payment_url() return { 'payment_url': payment_url, 'cost': cost, }
def get_list_of_addresses(patient_id): patient = DAO.get_patient(patient_id) address_list = patient.get_list_of_addresses() result = [] for address in address_list: result.append({'address': address.address, 'id': address.id}) return result
def get_labs_and_prices(test_ids, patient_id): patient = DAO.get_patient(patient_id) proper_labs = [ lab for lab in DAO.get_list_of_labs() if lab.has_every_test(test_ids) ] print(proper_labs) data = list() for lab in proper_labs: data_instance = dict() data_instance['id'] = lab.id data_instance['name'] = lab.name lab_total_cost = 0 for test_id in test_ids: lab_total_cost += Insurance.get_price(lab.get_test(test_id), patient) data_instance['price'] = lab_total_cost data.append(data_instance) return data
def create_new_address(data): patient = DAO.get_patient(data.get('patient_id')) address_id = patient.create_address(data.get('address')) return address_id