def rejectAssociation(request): practice = request.org if (request.method == 'POST'): form = AssociationAssocIdForm(request.POST) else: form = AssociationAssocIdForm(request.GET) if (not form.is_valid()): return HttpResponse(json.dumps({'err': _('The data is error. Please refresh ' 'the page again.')}), mimetype='application/json') assoc_id = form.cleaned_data['assoc_id'] association = Pending_Association.objects.get(pk=assoc_id) provider = Provider.objects.get(user=association.from_user) Log_Association().save_from_association(association, request.user.id, 'REJ') association.delete() mail_add_association(request, _('DoctorCom: Request To Join Practice Rejected'), """Dear {{provider_name}}, We're sorry, but your DoctorCom Invitation to join {{practice_name}} practice has been rejected. Best, DoctorCom Staff""", provider.user.email, practice_name=practice.practice_name, provider_name=provider.user) return HttpResponse(json.dumps('OK'), mimetype='application/json')
def removeAssociation(request): #send email and update resent date user = request.user practice = request.org if (request.method == 'POST'): form = AssociationAssocIdForm(request.POST) else: form = AssociationAssocIdForm(request.GET) if (not form.is_valid()): return HttpResponse(json.dumps({'err': _('The data is error. ' 'Please refresh the page again.')}), mimetype='application/json') assoc_id = form.cleaned_data['assoc_id'] association = Pending_Association.objects.get(pk=assoc_id) provider = Provider.objects.get(user=association.to_user) Log_Association().save_from_association(association, user.id, 'CAN') association.delete() mail_add_association(request, _('DoctorCom: Invitation To Join Practice Withdrawn'), """Dear {{provider_name}}, We're sorry, but your DoctorCom Invitation to join {{practice_name}} has been withdrawn. Best, DoctorCom Staff""", provider.user.email, practice_name=practice.practice_name, provider_name=provider.user, server_address=settings.SERVER_ADDRESS ) return HttpResponse(json.dumps('OK'), mimetype='application/json')
def resendAssociation(request): #send email and update resent date user = request.user office_staff = request.session['MHL_Users']['OfficeStaff'] practice = office_staff.current_practice if (request.method == 'POST'): form = AssociationAssocIdForm(request.POST) else: form = AssociationAssocIdForm(request.GET) if (not form.is_valid()): return HttpResponse(json.dumps({'err': _('The data is error. ' 'Please refresh the page again.')}), mimetype='application/json') assoc_id = form.cleaned_data['assoc_id'] association = Pending_Association.objects.get(pk=assoc_id) created_time = datetime.datetime.now() association.resent_time = created_time association.save() #lets log our action log_association = Log_Association() log_association.association_id = association.id log_association.from_user_id = association.from_user_id log_association.to_user_id = association.to_user_id log_association.practice_location_id = association.practice_location.id log_association.action_user_id = user.id log_association.action = 'RES' log_association.created_time = created_time log_association.save() provider = Provider.objects.get(user=association.to_user) mail_add_association(request, _('DoctorCom: Invitation To Join Practice'), # subject, """Dear {{provider_name}}, {{manager_name}} {{manager_name_last}} has sent you an invitation to join {{practice_name}}. Please login to DoctorCom to view and accept the pending invitaion. You can also accept the invitation by clicking https://{{server_address}}/Profile/Practices/ Best, DoctorCom Staff""", provider.user.email, practice_name=practice.practice_name, manager_name=request.user.first_name, manager_name_last=request.user.last_name, provider_name=provider.user, server_address=settings.SERVER_ADDRESS ) return HttpResponse(json.dumps('OK'), mimetype='application/json')
def removeAssociation(request): #send email and update resent date user = request.user office_staff = request.session['MHL_Users']['OfficeStaff'] practice = office_staff.current_practice if (request.method == 'POST'): form = AssociationAssocIdForm(request.POST) else: form = AssociationAssocIdForm(request.GET) if (not form.is_valid()): return HttpResponse(json.dumps({'err': _('The data is error. ' 'Please refresh the page again.')}), mimetype='application/json') assoc_id = form.cleaned_data['assoc_id'] association = Pending_Association.objects.get(pk=assoc_id) provider = Provider.objects.get(user=association.to_user) log_association = Log_Association() log_association.association_id = association.id log_association.from_user_id = association.from_user_id log_association.to_user_id = association.to_user_id log_association.practice_location_id = association.practice_location.id log_association.action_user_id = user.id log_association.action = 'CAN' log_association.created_time = datetime.datetime.now() log_association.save() association.delete() mail_add_association(request, _('DoctorCom: Invitation To Join Practice Withdrawn'), """Dear {{provider_name}}, We're sorry, but your DoctorCom Invitation to join {{practice_name}} has been withdrawn. Best, DoctorCom Staff""", provider.user.email, practice_name=practice.practice_name, provider_name=provider.user, server_address=settings.SERVER_ADDRESS ) return HttpResponse(json.dumps('OK'), mimetype='application/json')
def rejectAssociation(request): office_staff = request.session['MHL_Users']['OfficeStaff'] practice = office_staff.current_practice if (request.method == 'POST'): form = AssociationAssocIdForm(request.POST) else: form = AssociationAssocIdForm(request.GET) if (not form.is_valid()): return HttpResponse(json.dumps({'err': _('The data is error. Please refresh ' 'the page again.')}), mimetype='application/json') assoc_id = form.cleaned_data['assoc_id'] association = Pending_Association.objects.get(pk=assoc_id) provider = Provider.objects.get(user=association.from_user) log_association = Log_Association() log_association.association_id = association.id log_association.from_user_id = association.from_user_id log_association.to_user_id = association.to_user_id log_association.practice_location_id = association.practice_location.id log_association.action_user_id = request.user.id log_association.action = 'REJ' log_association.created_time = datetime.datetime.now() log_association.save() association.delete() mail_add_association(request, _('DoctorCom: Request To Join Practice Rejected'), """Dear {{provider_name}}, We're sorry, but your DoctorCom Invitation to join {{practice_name}} practice has been rejected. Best, DoctorCom Staff""", provider.user.email, practice_name=practice.practice_name, provider_name=provider.user) return HttpResponse(json.dumps('OK'), mimetype='application/json')
def addAssociation(request): user = request.user office_staff = request.session['MHL_Users']['OfficeStaff'] practice = office_staff.current_practice if (request.method == 'POST'): form = AssociationProviderIdForm(request.POST) else: form = AssociationProviderIdForm(request.GET) if (not form.is_valid()): return HttpResponse(json.dumps({'err': _('The data is wrong. Please ' 'refresh the page again.')}), mimetype='application/json') prov_id = form.cleaned_data['prov_id'] #check if invitation from provider Exists ret_set = Pending_Association.objects.filter(from_user=prov_id, practice_location=practice.id) if (ret_set.count() > 0): return HttpResponse(json.dumps(['duplicate'])) # , mimetype='application/json') association = Pending_Association() created_time = datetime.datetime.now() resend_time = created_time association.from_user_id = user.id association.to_user_id = prov_id association.practice_location_id = practice.id association.created_time = created_time association.resent_time = resend_time association.save() #lets log our action log_association = Log_Association() log_association.association_id = association.id log_association.from_user_id = user.id log_association.to_user_id = prov_id log_association.practice_location_id = practice.id log_association.action_user_id = user.id log_association.action = 'CRE' log_association.created_time = created_time association.resent_time = resend_time log_association.save() #now let's mail provider invitaion request if request.POST['userType'] == '1': #provider = Provider.objects.get(user=prov_id) provider = Provider.objects.get(user__id=prov_id) else: #provider = OfficeStaff.objects.get(user=prov_id) provider = OfficeStaff.objects.get(user__id=prov_id) mail_add_association(request, _('DoctorCom: Invitation To Join Practice'), # subject, """Dear {{provider_name}}, {{manager_name}} {{manager_name_last}} has sent you an invitation to join {{practice_name}}. Please login to DoctorCom to view and accept the pending invitaion. You can also accept the invitation by clicking https://{{server_address}}/Profile/Practices/ Best, DoctorCom Staff""", provider.user.email, practice_name=practice.practice_name, manager_name=request.user.first_name, manager_name_last=request.user.last_name, provider_name=provider.user, server_address=settings.SERVER_ADDRESS ) return HttpResponse(json.dumps(['ok'])) # , mimetype='application/json')