def add_new_appointment(data): appointment = models.Appointment(doctor_id=data.get('doctor_id'), member_id=data.get('member_id'), start=int(data.get('start'))) session.add(appointment) session.commit() return appointment
def add_new_plan(data): plan = models.Plan(name=data.get('name')) session.add(plan) session.commit() return plan
def add_new_speciality(data): speciality = models.Speciality(name=data.get('name'), description=data.get('description')) session.add(speciality) session.commit() return speciality
def add_new_news(data): news = models.News(title=data.get('title'), image=data.get('image'), content=data.get('content'), author_id=data.get('author_id')) session.add(news) session.commit() return news
def update_doctor(doctor, data): doctor.update(data) if doctor.user: doctor.user.update(data) else: user = User( username=data.get('username'), password=data.get('password'), doctor_id=doctor.id ) session.add(user) session.commit()
def add_new_health_center(data): health_center = models.HealthCenter(name=data.get('name'), address=data.get('address'), telephone=data.get('telephone'), location=data.get('location'), extradata=data.get('extradata'), plan_ids=data.get('plan_ids')) session.add(health_center) session.commit() return health_center
def add_new_member(data): member = models.Member( name=data.get('name'), address=data.get('address'), telephone=data.get('telephone'), plan_id=data.get('plan_id'), member_number=data.get('member_number') ) session.add(member) session.commit() return member
def upload(): json_data = request.json print("/upload", json_data, "\n") mesurement = Measurements( s_time=datetime.datetime.fromtimestamp(json_data['s_time'] / 1e3), e_time=datetime.datetime.fromtimestamp(json_data['e_time'] / 1e3), data=json_data['data']) # Constructs a new mesurement object try: db_session.add( mesurement) # adds new mesurement object to the database db_session.commit() status = 'success' except Exception as e: print("Error occured trying to upload data:", e) status = 'failure' finally: db_session.close() return jsonify({'result': status})
def add_new_doctor(data): doctor = models.Doctor( name=data.get('name'), address=data.get('address'), telephone=data.get('telephone'), location=data.get('location'), plan_ids=data.get('plan_ids'), speciality_ids=data.get('speciality_ids'), ) session.add(doctor) session.commit() user = User( username=data.get('username'), password=data.get('password'), doctor_id=doctor.id ) session.add(user) session.commit() return doctor