def post_experience(): data = request.get_json() # need to look up plan and company plan = database.plan_by_company_name(g.db, data['company'], data['plan'], data['state']) if plan is None: plan = database.create_plan(g.db, data['company'], data['plan'], data['state']) def make_experience(service_data): return database.Experience(date=datetime.datetime.strptime( service_data['date'], '%Y-%m-%d'), plan=plan, documented_gender='U', service=service_data['name'], success=service_data['success'], age=service_data['age']) # there may be multiple services in one request experiences = [ make_experience(service_data) for service_data in data['services'] ] g.db.add_all(experiences) g.db.commit() return build_response()
def post_coverage(): data = request.get_json() # look up by plan and company plan = database.plan_by_company_name(g.db, data['company'], data['plan'], data['state']) if plan is None: plan = database.create_plan(g.db, data['company'], data['plan'], data['state']) def make_coverage (service_type_data): return database.CoverageStatement( date=datetime.datetime.strptime(data['date'], '%Y-%m-%d'), plan=plan, service_type=service_type_data['name'], covered=service_type_data['covered']) # there may be multiple service_types in one request coverage_reports = [make_coverage(service_type_data) for service_type_data in data['service_types']] g.db.add_all(coverage_reports) g.db.commit() return build_response()
def post_coverage(): data = request.get_json() # look up by plan and company plan = database.plan_by_company_name(g.db, data['company'], data['plan'], data['state']) if plan is None: plan = database.create_plan(g.db, data['company'], data['plan'], data['state']) def make_coverage(service_type_data): return database.CoverageStatement( date=datetime.datetime.strptime(data['date'], '%Y-%m-%d'), plan=plan, service_type=service_type_data['name'], covered=service_type_data['covered']) # there may be multiple service_types in one request coverage_reports = [ make_coverage(service_type_data) for service_type_data in data['service_types'] ] g.db.add_all(coverage_reports) g.db.commit() return build_response()
def post_experience(): data = request.get_json() # need to look up plan and company plan = database.plan_by_company_name(g.db, data['company'], data['plan'], data['state']) if plan is None: plan = database.create_plan(g.db, data['company'], data['plan'], data['state']) def make_experience (service_data): return database.Experience( date=datetime.datetime.strptime(service_data['date'], '%Y-%m-%d'), plan=plan, documented_gender='U', service=service_data['name'], success=service_data['success'], age=service_data['age']) # there may be multiple services in one request experiences = [make_experience(service_data) for service_data in data['services']] g.db.add_all(experiences) g.db.commit() return build_response()