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_time_slots(lab_id): lab = DAO.get_laboratory(lab_id) time_slots_list = lab.get_list_of_available_time_slots() result = [] print(time_slots_list) for time_slot in time_slots_list: result.append({ 'id': time_slot.id, 'date': (str(time_slot.start_date.date()) + ' ' + time_slot.start_date.strftime('%H:%M') + '-' + time_slot.end_date.strftime('%H:%M')) }) return result