def get_home(request): template_name = "home.html" if (secretkeys.ACCESS_TOKEN == None): secretkeys.oauth_code = request.GET.get('code') response = requests.post('https://drchrono.com/o/token/', data={ 'code': secretkeys.oauth_code, 'grant_type': 'authorization_code', 'redirect_uri': secretkeys.redirect_uri, 'client_id': secretkeys.client_id, 'client_secret': secretkeys.client_secret, }) data = response.json() secretkeys.ACCESS_TOKEN = data['access_token'] secretkeys.REFRESH_TOKEN = data['refresh_token'] secretkeys.ACCESS_TOKEN_EXPIRES_IN = data['expires_in'] refreshtoken.countdown_refresh_accesstoken( secretkeys.ACCESS_TOKEN_EXPIRES_IN) data = getcurrentuserinfo() username = data['username'] patients = getpatients() template = get_template(template_name) context = { 'currentuser': username, "patients_data": patients } html = template.render(Context(context)) return HttpResponse(html)
def getuser_token(request): template_name = "checkin.html" print "hello!" if (settings.ACCESS_TOKEN == None): settings.oauth_code = request.GET.get('code') response = requests.post('https://drchrono.com/o/token/', data={ 'code': settings.oauth_code, 'grant_type': 'authorization_code', 'redirect_uri': settings.LOGIN_REDIRECT_URL2, 'client_id': settings.SOCIAL_AUTH_DRCHRONO_KEY, 'client_secret': settings.SOCIAL_AUTH_DRCHRONO_SECRET, }) data = response.json() settings.ACCESS_TOKEN = data['access_token'] settings.REFRESH_TOKEN = data['refresh_token'] settings.EXPIRES_IN = data['expires_in'] refreshtoken.countdown_refresh_accesstoken(settings.EXPIRES_IN) data = getcurrentuserinfo() username = data['username'] doc_id = data['doctor'] template = get_template(template_name) context = {'currentuser': username} html = template.render(Context(context)) return HttpResponse(html)
def get_context_data(self, **kwargs): context = super(GetHome, self).get_context_data(**kwargs) if (secretkeys.ACCESS_TOKEN == None): secretkeys.oauth_code = self.request.GET.get('code') response = requests.post('https://drchrono.com/o/token/', data={ 'code': secretkeys.oauth_code, 'grant_type': 'authorization_code', 'redirect_uri': secretkeys.redirect_uri, 'client_id': secretkeys.client_id, 'client_secret': secretkeys.client_secret, }) data = response.json() secretkeys.ACCESS_TOKEN = data['access_token'] secretkeys.REFRESH_TOKEN = data['refresh_token'] secretkeys.ACCESS_TOKEN_EXPIRES_IN = data['expires_in'] refreshtoken.countdown_refresh_accesstoken( secretkeys.ACCESS_TOKEN_EXPIRES_IN) data = getcurrentuserinfo() username = data['username'] patients = getpatients() template = get_template(GetHome.template_name) context = { 'currentuser': username, "patients_data": patients } return context
def wishpatient(request,id): if (settings.ACCESS_TOKEN == None ): settings.oauth_code = request.GET.get('code'); response = requests.post('https://drchrono.com/o/token/', data={ 'code': settings.oauth_code, 'grant_type': 'authorization_code', 'redirect_uri': settings.redirect_uri, 'client_id': settings.client_id, 'client_secret': settings.client_secret, }) data = response.json() settings.ACCESS_TOKEN = data['access_token'] settings.REFRESH_TOKEN = data['refresh_token'] settings.ACCESS_TOKEN_EXPIRES_IN = data['expires_in'] refreshtoken.countdown_refresh_accesstoken(settings.ACCESS_TOKEN_EXPIRES_IN) data = getcurrentuserinfo() username = data['username'] patient_data = patientsrecords[str(id)] context = {'currentuser': username,'patient':patient_data} template_name = "patientdetails.html" template = get_template(template_name) html = template.render(Context(context)) return HttpResponse(html)