def api_login():
	if request.method == 'GET':
		_username = request.args.get("user")
		_pwd = request.args.get("pwd")
		_ud = UserDispatcher()
		return str(_ud.login(_username,_pwd))
	return _username
def doctor_patient(doctorId,patientId):
        u = UserDispatcher()
        _doctor = u.get(doctorId,False)
        _cpatient = u.get(patientId,False)
	_d = Data(patientId)
	_hm_hr,_hm_eda,_hm_temp  = _d.getHeatMapSessions(True)
	return render_template("doctor_patient.html",_hm_hr = _hm_hr,_hm_eda=_hm_eda,_hm_temp= _hm_temp, _patientID = patientId, _doctor = _doctor,_cpatient = _cpatient)
def doctor(doctorId):
	_userId = 1
        u = UserDispatcher()
        _doctor = u.get(doctorId,False)
	_d = Data(_userId)
	_hm_hr,_hm_eda,_hm_temp  = _d.getHeatMapSessions(True)
	return render_template("doctor.html",_hm_hr = _hm_hr,_hm_eda=_hm_eda,_hm_temp= _hm_temp, _patientID = _userId, _doctor = _doctor)
def userSession(_userId,_sessionId):
	u = UserDispatcher()
	_user = u.get(_userId,False)
	_d = Data(_userId)
	_sessionEDA = getData(_userId,_sessionId,"EDA",_json=False)
	try:
		_sessionHR = getData(_userId,_sessionId,"HR",_json=False)
		_sHR = _sessionHR["session"]["data"]["HR"]
	except:
		_sHR = []
	try:
		_sessionTEMP = getData(_userId,_sessionId,"TEMP",_json=False)
		_sTEMP =  _sessionTEMP["session"]["data"]["TEMP"]
	except:
		_sTEMP = []
	_sEDA =  _sessionEDA["session"]["data"]["EDA"]
	return render_template("sessionData.html",user = _user,_sessionHR = _sHR,_sessionEDA = _sEDA,_sessionTEMP = _sTEMP,_metadata = _sessionEDA["session"]["metadata"],_session = Session("data/"+_sessionId).getMetaDataOnly())
def userSessions(_userId):
	_d = Data(_userId)
	_sessions = _d.getSessions(False)
	u = UserDispatcher()
	_user = u.get(_userId,False)
	return render_template("userFeed.html",user = _user,sessions = _sessions)
def devices(_userId):
	u = UserDispatcher()
	return u.getDevices(_userId)
def god_users():
	u = UserDispatcher()
	print u.getAll(False)
	return render_template("god_users.html",_users= u.getAll(False))
def users(_userId):
	u = UserDispatcher()
	return u.get(_userId)