def home():
	doctors = Doctor.query.all()[:200]
	form = DoctorForm(request.form)
	if request.method == 'POST':
		if form.validate():
			#flash ('Form Validated')
			if form.id.data == '':
				doc = Doctor(name = form.name.data, email = form.email.data, phoneNumber = form.phoneNumber.data, description = form.description.data, education = form.education.data, experience = form.experience.data, speciality = form.speciality.data)
				db_session.add(doc)
				db_session.commit()
				doctors = Doctor.query.all()
		else:
			flash ('Form Validation unsuccessful. Please enter valid data')
			return render_template("addDoctor.html",form = form)
	return render_template("home.html", doctors = doctors, form = form)
def editDoctor(doctor_id):
	try:
		doc = Doctor.query.get(int(doctor_id))
		form = DoctorForm(request.form)
		#return render_template("editDoctor.html",form=form,doctor=doc)
	except AttributeError:
		return render_template("home.html", errMsg = "No Such Doctor")
	if request.method == 'POST':
		if form.validate():
			doc.name = form.name.data
			doc.email = form.email.data
			doc.phoneNumber = form.phoneNumber.data
			doc.description = form.description.data
			doc.education = form.education.data
			doc.experience = form.experience.data
			db_session.commit()
			doctors = Doctor.query.all()
			return render_template("home.html", doctors = doctors)
		else:
			flash("Invalid data entered!!")
			doctors = Doctor.query.all()
			return render_template('editDoctor.html', doctor = doc, form = form)
	else:
		return render_template("editDoctor.html", doctor = doc, form = form)