Exemplo n.º 1
0
def newStaff(request):
	context = get_context(request)
	office_staff = request.session['MHL_Users']['OfficeStaff']
	current_practice = office_staff.current_practice
	request.session['SELECTED_ORG_ID'] = current_practice.id
	showDialog = 0
	username = ""
	if request.method == 'POST':
		staff_form = CreateOfficeStaffForm(request.POST, \
				current_practice=current_practice, include_manager=False)
		mhluser_form = CreateMHLUserForm(request.POST, request.FILES)

		if staff_form.is_valid() and mhluser_form.is_valid():
			# todo, using function createNewOfficeStaff in /mdcom/MHLogin/MHLUsers/utils_users.py
			# createNewOfficeStaff(mhluser_form, staff_form, office_staff)
			username = mhluser_form.cleaned_data['username']
			mhluser = mhluser_form.save(commit=False)
			mhluser.is_active = 0
			mhluser.address1 = current_practice.practice_address1
			mhluser.address2 = current_practice.practice_address2
			mhluser.city = current_practice.practice_city
			mhluser.state = current_practice.practice_state
			mhluser.zip = current_practice.practice_zip
			mhluser.lat = current_practice.practice_lat
			mhluser.longit = current_practice.practice_longit
			mhluser.save()

			staff = staff_form.save(commit=False)
			staff.user = mhluser
			staff.current_practice = current_practice
			staff.save()

			staff.practices.add(current_practice)
			staff.save()

			staff_type = staff_form.cleaned_data['staff_type']

			if '3' == staff_type:
				nurse = Nurse(user=staff)
				nurse.save()
			elif '4' == staff_type:
				dietician = Dietician(user=staff)
				dietician.save()

			sendAccountActiveCode(request, 101)

			showDialog = 1
			#return HttpResponseRedirect(reverse('MHLogin.MHLPractices.views.staffHome'))
		else:
			context['showDialog'] = showDialog
			context['user_form'] = mhluser_form
			context['staff_form'] = staff_form
			return render_to_response('Staff/newStaff.html', context)
	context['username'] = username
	context['showDialog'] = showDialog
	context['user_form'] = CreateMHLUserForm()
	context['staff_form'] = CreateOfficeStaffForm(current_practice=current_practice,
					include_manager=False)

	return render_to_response('Staff/newStaff.html', context)
Exemplo n.º 2
0
def newStaff(request):
    context = get_context(request)
    office_staff = request.session['MHL_Users']['OfficeStaff']
    current_practice = office_staff.current_practice
    request.session['SELECTED_ORG_ID'] = current_practice.id
    showDialog = 0
    username = ""
    if request.method == 'POST':
        staff_form = CreateOfficeStaffForm(request.POST, \
          current_practice=current_practice, include_manager=False)
        mhluser_form = CreateMHLUserForm(request.POST, request.FILES)

        if staff_form.is_valid() and mhluser_form.is_valid():
            # todo, using function createNewOfficeStaff in /mdcom/MHLogin/MHLUsers/utils_users.py
            # createNewOfficeStaff(mhluser_form, staff_form, office_staff)
            username = mhluser_form.cleaned_data['username']
            mhluser = mhluser_form.save(commit=False)
            mhluser.is_active = 0
            mhluser.address1 = current_practice.practice_address1
            mhluser.address2 = current_practice.practice_address2
            mhluser.city = current_practice.practice_city
            mhluser.state = current_practice.practice_state
            mhluser.zip = current_practice.practice_zip
            mhluser.lat = current_practice.practice_lat
            mhluser.longit = current_practice.practice_longit
            mhluser.save()

            staff = staff_form.save(commit=False)
            staff.user = mhluser
            staff.current_practice = current_practice
            staff.save()

            staff.practices.add(current_practice)
            staff.save()

            staff_type = staff_form.cleaned_data['staff_type']

            if '3' == staff_type:
                nurse = Nurse(user=staff)
                nurse.save()
            elif '4' == staff_type:
                dietician = Dietician(user=staff)
                dietician.save()

            sendAccountActiveCode(request, 101)

            showDialog = 1
            #return HttpResponseRedirect(reverse('MHLogin.MHLPractices.views.staffHome'))
        else:
            context['showDialog'] = showDialog
            context['user_form'] = mhluser_form
            context['staff_form'] = staff_form
            return render_to_response('Staff/newStaff.html', context)
    context['username'] = username
    context['showDialog'] = showDialog
    context['user_form'] = CreateMHLUserForm()
    context['staff_form'] = CreateOfficeStaffForm(
        current_practice=current_practice, include_manager=False)

    return render_to_response('Staff/newStaff.html', context)
Exemplo n.º 3
0
def member_staff_create(request):
	context = get_context_for_organization(request)
	current_practice = request.org
	if request.method == 'POST':
		staff_form = CreateOfficeStaffForm(request.POST, current_practice=current_practice)
		mhluser_form = CreateMHLUserForm(request.POST, request.FILES)

		if staff_form.is_valid() and mhluser_form.is_valid():
			mhluser = mhluser_form.save(commit=False)
			mhluser.is_active = 0
			mhluser.address1 = current_practice.practice_address1
			mhluser.address2 = current_practice.practice_address2
			mhluser.city = current_practice.practice_city
			mhluser.state = current_practice.practice_state
			mhluser.zip = current_practice.practice_zip
			mhluser.lat = current_practice.practice_lat
			mhluser.longit = current_practice.practice_longit
			mhluser.save()

			staff = staff_form.save(commit=False)
			staff.user = mhluser
			staff.current_practice = current_practice
			staff.save()

			staff.practices.add(current_practice)
			staff.save()

			staff_type = int(staff_form.cleaned_data['staff_type'])

			if USER_TYPE_OFFICE_MANAGER == staff_type:
				manager = Office_Manager(user=staff, practice=current_practice)
				manager.save()
			if USER_TYPE_NURSE == staff_type:
				nurse = Nurse(user=staff)
				nurse.save()
			elif USER_TYPE_DIETICIAN == staff_type:
				dietician = Dietician(user=staff)
				dietician.save()

			# TESTING_KMS_INTEGRATION
			create_default_keys(mhluser)

			sendAccountActiveCode(request, USER_TYPE_OFFICE_STAFF, 
				current_practice, request.session["MHL_Users"]["MHLUser"])
		else:
			context['user_form'] = mhluser_form
			context['staff_form'] = staff_form
			return render_to_response('MHLOrganization/Member/member_staff_create.html', context)
	context['user_form'] = CreateMHLUserForm()

	staff_form = CreateOfficeStaffForm(current_practice=current_practice)
	context['staff_form'] = staff_form

	return render_to_response('MHLOrganization/Member/member_staff_create.html', context)
Exemplo n.º 4
0
    def test_user_update_photo(self):
        request = generateHttpRequest()

        #get method
        request.method = 'GET'
        result = user_update_photo(request)
        self.assertEqual(result.status_code, 400)
        msg = json.loads(result.content)
        self.assertEqual(msg['errno'], 'GE002')

        #post method
        request.method = 'POST'

        #provider login and has no photo
        result = user_update_photo(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(
            msg['photo'],
            ''.join([settings.MEDIA_URL, 'images/photos/avatar2.png']))

        #staff login and has no photo
        staff = OfficeStaff(user=request.user)
        staff.save()
        assn = SmartPhoneAssn.all_objects.get(
            device_id=request.REQUEST['DCOM_DEVICE_ID'])
        assn.user_type = 101
        assn.save(request)
        result = user_update_photo(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(
            msg['photo'],
            ''.join([settings.MEDIA_URL, 'images/photos/staff_icon.jpg']))

        #nurse login and has no photo
        nurse = Nurse(user=staff)
        nurse.save()
        result = user_update_photo(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(
            msg['photo'],
            ''.join([settings.MEDIA_URL, 'images/photos/nurse.jpg']))

        #user has photo, and new photo == old photo
        mhluser = MHLUser.objects.get(id=request.user.id)
        mhluser.photo = 'a.png'
        mhluser.save()
        result = user_update_photo(request)
        self.assertEqual(result.status_code, 200)
Exemplo n.º 5
0
 def testOfficeStaffProfileView(self):
     user = create_user('practicemgr1', 'lin', 'xing', 'demo')
     staff = OfficeStaff()
     staff.user = user
     staff.office_lat = 0.0
     staff.office_longit = 0.0
     staff.save()
     self.assertEqual(
         officeStaffProfileView(staff)['photo'],
         '/media/images/photos/staff_icon.jpg')
     nurse = Nurse(user=staff)
     nurse.save()
     self.assertEqual(
         officeStaffProfileView(nurse.user)['photo'],
         '/media/images/photos/nurse.jpg')
Exemplo n.º 6
0
    def done(self, request, form_list):
        inviteform = form_list[0]
        userform = form_list[1]
        user = userform.save(commit=False)
        user.set_password(userform.cleaned_data['password1'])
        user.tos_accepted = True

        invite = Invitation.objects.get(code=inviteform.cleaned_data['code'],
                                        userType=101)
        if invite.recipient == request.POST['email']:
            user.email_confirmed = True
        user.email = request.POST['email']

        assignPractice = invite.assignPractice
        if assignPractice:
            # use mhluser's address1, address2, city, state, zip to store "address" information,
            user.address1 = assignPractice.practice_address1
            user.address2 = assignPractice.practice_address2
            user.city = assignPractice.practice_city
            user.state = assignPractice.practice_state
            user.zip = assignPractice.practice_zip
            user.lat = assignPractice.practice_lat
            user.longit = assignPractice.practice_longit

        user.save()

        staff = OfficeStaff(user=user, current_practice=assignPractice)
        staff.save()
        staff.practices.add(assignPractice)

        userType = request.POST['userType']
        if userType == '3':
            nurse = Nurse(user=staff)
            nurse.save()
        if userType == '4':
            dietician = Dietician(user=staff)
            dietician.save()

        # TESTING_KMS_INTEGRATION
        create_default_keys(user, userform.cleaned_data['password1'])

        # Remove the invitation.
        invite = Invitation.objects.get(code=inviteform.cleaned_data['code'],
                                        userType=101)
        invite.delete(createdUser=user, send_notice=False)
        return HttpResponseRedirect(self.redirect_url)
Exemplo n.º 7
0
	def test_user_update_photo(self):
		request = generateHttpRequest()

		#get method
		request.method = 'GET'
		result = user_update_photo(request)
		self.assertEqual(result.status_code, 400)
		msg = json.loads(result.content)
		self.assertEqual(msg['errno'], 'GE002')

		#post method
		request.method = 'POST'

		#provider login and has no photo
		result = user_update_photo(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(msg['photo'], ''.join([settings.MEDIA_URL, 'images/photos/avatar2.png']))

		#staff login and has no photo
		staff = OfficeStaff(user=request.user)
		staff.save()
		assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
		assn.user_type = 101
		assn.save(request)
		result = user_update_photo(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(msg['photo'], ''.join([settings.MEDIA_URL, 'images/photos/staff_icon.jpg']))

		#nurse login and has no photo
		nurse = Nurse(user=staff)
		nurse.save()
		result = user_update_photo(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(msg['photo'], ''.join([settings.MEDIA_URL, 'images/photos/nurse.jpg']))

		#user has photo, and new photo == old photo
		mhluser = MHLUser.objects.get(id=request.user.id)
		mhluser.photo = 'a.png'
		mhluser.save()
		result = user_update_photo(request)
		self.assertEqual(result.status_code, 200)
Exemplo n.º 8
0
	def done(self, request, form_list):
		inviteform = form_list[0]
		userform = form_list[1]
		user = userform.save(commit=False)
		user.set_password(userform.cleaned_data['password1'])
		user.tos_accepted = True

		invite = Invitation.objects.get(code=inviteform.cleaned_data['code'], userType=101)
		if invite.recipient == request.POST['email']:
			user.email_confirmed = True
		user.email = request.POST['email']

		assignPractice = invite.assignPractice
		if assignPractice:
			# use mhluser's address1, address2, city, state, zip to store "address" information,
			user.address1 = assignPractice.practice_address1
			user.address2 = assignPractice.practice_address2
			user.city = assignPractice.practice_city
			user.state = assignPractice.practice_state
			user.zip = assignPractice.practice_zip
			user.lat = assignPractice.practice_lat
			user.longit = assignPractice.practice_longit

		user.save()

		staff = OfficeStaff(user=user, current_practice=assignPractice)
		staff.save()
		staff.practices.add(assignPractice)

		userType = request.POST['userType']
		if userType == '3':
			nurse = Nurse(user=staff)
			nurse.save()
		if userType == '4':
			dietician = Dietician(user=staff)
			dietician.save()

		# TESTING_KMS_INTEGRATION
		create_default_keys(user, userform.cleaned_data['password1'])

		# Remove the invitation.
		invite = Invitation.objects.get(code=inviteform.cleaned_data['code'], userType=101)
		invite.delete(createdUser=user, send_notice=False)
		return HttpResponseRedirect(self.redirect_url)
Exemplo n.º 9
0
def createNewOfficeStaff(mhluser_form, staff_form, current_user):
	if isinstance(mhluser_form, CreateMHLUserForm) and \
			isinstance(staff_form, CreateOfficeStaffForm):
		current_practice = current_user.current_practice
		mhluser = mhluser_form.save(commit=False)
		mhluser.is_active = 0
		if current_practice:
			mhluser.address1 = current_practice.practice_address1
			mhluser.address2 = current_practice.practice_address2
			mhluser.city = current_practice.practice_city
			mhluser.state = current_practice.practice_state
			mhluser.zip = current_practice.practice_zip
			mhluser.lat = current_practice.practice_lat
			mhluser.longit = current_practice.practice_longit
		else:
			mhluser.lat = 0.0
			mhluser.longit = 0.0
		mhluser.save()

		staff = staff_form.save(commit=False)
		staff.user = mhluser
		staff.current_practice = current_practice
		staff.save()

		if current_practice:
			staff.practices.add(current_practice)
		staff.save()

		staff_type = int(staff_form.cleaned_data['staff_type'])

		if USER_TYPE_NURSE == staff_type:
			nurse = Nurse(user=staff)
			nurse.save()
		elif USER_TYPE_DIETICIAN == staff_type:
			dietician = Dietician(user=staff)
			dietician.save()

		# TESTING_KMS_INTEGRATION
		create_default_keys(mhluser)

		sendAccountActiveCode(mhluser_form, 101, current_user)

	else:
		raise TypeError
Exemplo n.º 10
0
	def testSetOfficeStaffResultList(self):
# 		create office staff
		staff = create_office_staff(get_random_username(), "staff", "thj", "demo",
						"555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff)
		staff2 = create_office_staff(get_random_username(), "nurse", "thj", "demo",
						"555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff)
		nurse = Nurse(user=staff2)
		nurse.save()
		staff3 = create_office_staff(get_random_username(), "maneger", "thj", "demo",
						"555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff)
		mgr = Office_Manager(user=staff3)
		practice = PracticeLocation(
			practice_address1='555 Pleasant Pioneer Grove',
			practice_address2='Trailer Q615',
			practice_city='Mountain View',
			practice_state='CA',
			practice_zip='94040-4104',
			practice_lat=37.36876,
			practice_longit=-122.081864)
		practice.save()
		mgr.manager_role = 1
		mgr.practice = practice
		mgr.save()

		mhlu = create_user(get_random_username(), "mhluser", "thj", "demo", 
						"555 Bryant St.", "Palo Alto", "CA", "")
		mhlu.mdcom_phone = '9002000001'
		mhlu.save()

		self.assertEqual(0, len(setOfficeStaffResultList([])), 
						'test failed for setOfficeStaffResultList null')
		self.assertEqual(1, len(setOfficeStaffResultList([staff])), 
						'test failed for setOfficeStaffResultList staff')
# 		self.assertEqual(1, len(setOfficeStaffResultList([nurse])), 
						#'test failed for setOfficeStaffResultList nurse')
		self.assertEqual(1, len(setOfficeStaffResultList([mgr])), 
						'test failed for setOfficeStaffResultList mgr')
		self.assertEqual(3, len(setOfficeStaffResultList([staff, nurse.user, mgr])), 
						'test failed for setOfficeStaffResultList')
		self.assertEqual(3, len(setOfficeStaffResultList([staff, nurse.user, mgr], staff)), 
						'test failed for setOfficeStaffResultList')
Exemplo n.º 11
0
def generate_users(request):
	if (not settings.DEBUG):
		return HttpResponseRedirect(reverse('MHLogin.Administration.views.home'))
	context = get_context(request)
	if (request.method == 'GET'):
		context["form"] = GenerateUsersForm()
		return render_to_response('qa_tools/genereate_users.html', context)
	else:
		form = GenerateUsersForm(request.POST)
		if form.is_valid():
			current_practice = form.cleaned_data["practices"]
			user_type = int(form.cleaned_data["user_types"])
			number = int(form.cleaned_data["number"])
			user_name_start = form.cleaned_data["user_name_start"]
			generate_user = None
			for i in range(number):
				username = "******" % (user_name_start, i)
				first_name = "%s_f_%d" % (user_name_start, i)
				last_name = "%s_f_%d" % (user_name_start, i)
				email = "*****@*****.**" % (username)
				password = "******"
				if USER_TYPE_DOCTOR == user_type \
					or USER_TYPE_NPPA == user_type \
					or USER_TYPE_MEDICAL_STUDENT == user_type:
					provider = Provider(
						username=username,
						first_name=first_name,
						last_name=last_name,
						email=email,
						email_confirmed=True,
						lat=current_practice.practice_lat,
						longit=current_practice.practice_longit,

						address1=current_practice.practice_address1,
						address2=current_practice.practice_address2,
						city=current_practice.practice_city,
						state=current_practice.practice_state,
						zip=current_practice.practice_zip,

						current_practice=current_practice,
						is_active=1,
						office_lat=current_practice.practice_lat,
						office_longit=current_practice.practice_longit,

						mdcom_phone="8004664411"
					)
					provider.save()
					provider.set_password(password)

					provider.practices.add(current_practice)
					provider.user_id = provider.pk
					provider.save()

					if USER_TYPE_DOCTOR == user_type:
						#Physician
						ph = Physician(user=provider)
						ph.save()
					elif USER_TYPE_NPPA == user_type:
						#NP/PA/Midwife
						np = NP_PA(user=provider)
						np.save()
					elif USER_TYPE_MEDICAL_STUDENT == user_type:
						ph = Physician(user=provider)
						ph.save()

					create_default_keys(provider.user, password)
					# Generating the user's voicemail box configuration
					config = VMBox_Config(pin='')
					config.owner = provider
					config.save()
					generate_user = provider
				elif USER_TYPE_OFFICE_MANAGER == user_type \
					or USER_TYPE_NURSE == user_type \
					or USER_TYPE_DIETICIAN == user_type:
					mhluser = MHLUser(
						username = username,
						first_name = first_name,
						last_name = last_name,
						email = email,
						email_confirmed = True,

						is_active = 1,
						address1 = current_practice.practice_address1,
						address2 = current_practice.practice_address2,
						city = current_practice.practice_city,
						state = current_practice.practice_state,
						zip = current_practice.practice_zip,
						lat = current_practice.practice_lat,
						longit = current_practice.practice_longit
					)
					mhluser.save()
					mhluser.set_password(password)

					staff = OfficeStaff(
								user=mhluser,
								current_practice=current_practice
							)
					staff.user = mhluser
					staff.current_practice = current_practice
					staff.save()

					staff.practices.add(current_practice)
					staff.save()

					if USER_TYPE_OFFICE_MANAGER == user_type:
						manager = Office_Manager(user=staff, practice=current_practice)
						manager.save()
					if USER_TYPE_NURSE == user_type:
						nurse = Nurse(user=staff)
						nurse.save()
					elif USER_TYPE_DIETICIAN == user_type:
						dietician = Dietician(user=staff)
						dietician.save()
					generate_user = mhluser
				log_str = 'Generate user %d: for %s' % (i, str(generate_user))
				logger.debug(log_str)
				print log_str

			return render_to_response('qa_tools/genereate_users_success.html', context)
		else:
			context["form"] = form
			return render_to_response('qa_tools/genereate_users.html', context)
Exemplo n.º 12
0
def generate_users(request):
    if (not settings.DEBUG):
        return HttpResponseRedirect(
            reverse('MHLogin.Administration.views.home'))
    context = get_context(request)
    if (request.method == 'GET'):
        context["form"] = GenerateUsersForm()
        return render_to_response('qa_tools/genereate_users.html', context)
    else:
        form = GenerateUsersForm(request.POST)
        if form.is_valid():
            current_practice = form.cleaned_data["practices"]
            user_type = int(form.cleaned_data["user_types"])
            number = int(form.cleaned_data["number"])
            user_name_start = form.cleaned_data["user_name_start"]
            generate_user = None
            for i in range(number):
                username = "******" % (user_name_start, i)
                first_name = "%s_f_%d" % (user_name_start, i)
                last_name = "%s_f_%d" % (user_name_start, i)
                email = "*****@*****.**" % (username)
                password = "******"
                if USER_TYPE_DOCTOR == user_type \
                 or USER_TYPE_NPPA == user_type \
                 or USER_TYPE_MEDICAL_STUDENT == user_type:
                    provider = Provider(
                        username=username,
                        first_name=first_name,
                        last_name=last_name,
                        email=email,
                        email_confirmed=True,
                        lat=current_practice.practice_lat,
                        longit=current_practice.practice_longit,
                        address1=current_practice.practice_address1,
                        address2=current_practice.practice_address2,
                        city=current_practice.practice_city,
                        state=current_practice.practice_state,
                        zip=current_practice.practice_zip,
                        current_practice=current_practice,
                        is_active=1,
                        office_lat=current_practice.practice_lat,
                        office_longit=current_practice.practice_longit,
                        mdcom_phone="8004664411")
                    provider.save()
                    provider.set_password(password)

                    provider.practices.add(current_practice)
                    provider.user_id = provider.pk
                    provider.save()

                    if USER_TYPE_DOCTOR == user_type:
                        #Physician
                        ph = Physician(user=provider)
                        ph.save()
                    elif USER_TYPE_NPPA == user_type:
                        #NP/PA/Midwife
                        np = NP_PA(user=provider)
                        np.save()
                    elif USER_TYPE_MEDICAL_STUDENT == user_type:
                        ph = Physician(user=provider)
                        ph.save()

                    create_default_keys(provider.user, password)
                    # Generating the user's voicemail box configuration
                    config = VMBox_Config(pin='')
                    config.owner = provider
                    config.save()
                    generate_user = provider
                elif USER_TYPE_OFFICE_MANAGER == user_type \
                 or USER_TYPE_NURSE == user_type \
                 or USER_TYPE_DIETICIAN == user_type:
                    mhluser = MHLUser(
                        username=username,
                        first_name=first_name,
                        last_name=last_name,
                        email=email,
                        email_confirmed=True,
                        is_active=1,
                        address1=current_practice.practice_address1,
                        address2=current_practice.practice_address2,
                        city=current_practice.practice_city,
                        state=current_practice.practice_state,
                        zip=current_practice.practice_zip,
                        lat=current_practice.practice_lat,
                        longit=current_practice.practice_longit)
                    mhluser.save()
                    mhluser.set_password(password)

                    staff = OfficeStaff(user=mhluser,
                                        current_practice=current_practice)
                    staff.user = mhluser
                    staff.current_practice = current_practice
                    staff.save()

                    staff.practices.add(current_practice)
                    staff.save()

                    if USER_TYPE_OFFICE_MANAGER == user_type:
                        manager = Office_Manager(user=staff,
                                                 practice=current_practice)
                        manager.save()
                    if USER_TYPE_NURSE == user_type:
                        nurse = Nurse(user=staff)
                        nurse.save()
                    elif USER_TYPE_DIETICIAN == user_type:
                        dietician = Dietician(user=staff)
                        dietician.save()
                    generate_user = mhluser
                log_str = 'Generate user %d: for %s' % (i, str(generate_user))
                logger.debug(log_str)
                print log_str

            return render_to_response('qa_tools/genereate_users_success.html',
                                      context)
        else:
            context["form"] = form
            return render_to_response('qa_tools/genereate_users.html', context)
Exemplo n.º 13
0
	def testGetUserInfo(self):
		mhlu = create_user(get_random_username(), "mhluser", "thj", "demo", "555 Bryant St.", 
						"Palo Alto", "CA", "")
		mhlu.mdcom_phone = '9002000001'
		mhlu.save()
		mhlu_id = mhlu.id

		return_data1 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.',
					'office_address2': u'', 'photo': '/media/images/photos/generic_128.png',
					'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto',
					'accepting_patients': False, 'id': mhlu_id, 'custom_logos': get_custom_logos(mhlu_id),
					'first_name': u'mhluser', 'office_state': u'CA', 'office_zip': u'', 'staff_type': ''}
		self.assertEqual(Http404, getUserInfo(mhlu_id + 1, None), 'test failed for getUserInfo')
		self.assertEqual(return_data1, getUserInfo(mhlu_id), 'test failed for getUserInfo mhluser')

		# create provider for test
		provider = create_user(get_random_username(), "provider", "thj", "demo",
							"555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider)
		provider.mdcom_phone = '9002000002'
		provider.save()

		return_data2 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.',
					'office_address2': u'', 'photo': '/media/images/photos/avatar2.png',
					'specialty': 'NP/PA/Midwife', 'mdcom_phone': u'9002000002', 'office_city': u'Palo Alto',
					'accepting_patients': False, 'id': provider.user.id,
					'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'provider',
					'office_state': u'CA', 'office_zip': u'', 'staff_type': ''}
		self.assertEqual(return_data2, getUserInfo(provider.user.id), 'test failed for getUserInfo provider')

		# create physician
		provider1 = create_user(get_random_username(), "physician", "thj", "demo", "555 Bryant St.",
							"Palo Alto", "CA", "", uklass=Provider)
		provider1.mdcom_phone = '9002000002'
		provider1.save()
		phy = Physician(user=provider1)
		phy.specialty = 'AC'
		phy.save()
		return_data3 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.',
					'office_address2': u'', 'photo': '/media/images/photos/avatar2.png',
					'specialty': u'Acupuncture', 'mdcom_phone': u'9002000002',
					'office_city': u'Palo Alto', 'accepting_patients': True,
					'id': phy.user.user.id, 'custom_logos': get_custom_logos(mhlu_id),
					'first_name': u'physician', 'office_state': u'CA', 'office_zip': u'',
					'staff_type': ''}
		self.assertEqual(return_data3, getUserInfo(phy.user.user.id), 'test failed for getUserInfo physician')

# 		create office staff
		staff = create_office_staff(get_random_username(), "staff", "thj", "demo", "555 Bryant St.",
					"Palo Alto", "CA", "", uklass=OfficeStaff)
		return_data4 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.',
					'office_address2': u'', 'photo': '/media/images/photos/staff_icon.jpg',
					'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto',
					'accepting_patients': False, 'id': staff.user.id,
					'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'staff',
					'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Staff'}
		self.assertEqual(return_data4, getUserInfo(staff.user.id), 'test failed for getUserInfo staff')

# 		create nurse
		staff2 = create_office_staff(get_random_username(), "nurse", "thj", "demo",
					"555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff)
		nurse = Nurse(user=staff2)
		nurse.save()
		return_data5 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.',
				'office_address2': u'', 'photo': '/media/images/photos/nurse.jpg',
				'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto',
				'accepting_patients': False, 'id': nurse.user.user.id,
				'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'nurse',
				'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Staff'}
		self.assertEqual(return_data5, getUserInfo(nurse.user.user.id), 'test failed for getUserInfo nurse')

# 		create office staff
		staff3 = create_office_staff(get_random_username(), "maneger", "thj", "demo",
				"555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff)
		mgr = Office_Manager(user=staff3)

		practice = PracticeLocation(
			practice_address1='555 Pleasant Pioneer Grove',
			practice_address2='Trailer Q615',
			practice_city='Mountain View',
			practice_state='CA',
			practice_zip='94040-4104',
			practice_lat=37.36876,
			practice_longit=-122.081864)
		practice.save()
		mgr.manager_role = 1
		mgr.practice = practice
		mgr.save()
		return_data5 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.',
				'office_address2': u'', 'photo': '/media/images/photos/staff_icon.jpg',
				'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto',
				'accepting_patients': False, 'id': mgr.user.user.id,
				'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'maneger',
				'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Manager'}
		self.assertEqual(return_data5, getUserInfo(mgr.user.user.id), 'test failed for getUserInfo maneger')
Exemplo n.º 14
0
    def testGetUserInfo(self):
        mhlu = create_user(get_random_username(), "mhluser", "thj", "demo",
                           "555 Bryant St.", "Palo Alto", "CA", "")
        mhlu.mdcom_phone = '9002000001'
        mhlu.save()
        mhlu_id = mhlu.id

        return_data1 = {
            'last_name': u'thj',
            'office_address1': u'555 Bryant St.',
            'office_address2': u'',
            'photo': '/media/images/photos/generic_128.png',
            'specialty': '',
            'mdcom_phone': '',
            'office_city': u'Palo Alto',
            'accepting_patients': False,
            'id': mhlu_id,
            'custom_logos': get_custom_logos(mhlu_id),
            'first_name': u'mhluser',
            'office_state': u'CA',
            'office_zip': u'',
            'staff_type': ''
        }
        self.assertEqual(Http404, getUserInfo(mhlu_id + 1, None),
                         'test failed for getUserInfo')
        self.assertEqual(return_data1, getUserInfo(mhlu_id),
                         'test failed for getUserInfo mhluser')

        # create provider for test
        provider = create_user(get_random_username(),
                               "provider",
                               "thj",
                               "demo",
                               "555 Bryant St.",
                               "Palo Alto",
                               "CA",
                               "",
                               uklass=Provider)
        provider.mdcom_phone = '9002000002'
        provider.save()

        return_data2 = {
            'last_name': u'thj',
            'office_address1': u'555 Bryant St.',
            'office_address2': u'',
            'photo': '/media/images/photos/avatar2.png',
            'specialty': 'NP/PA/Midwife',
            'mdcom_phone': u'9002000002',
            'office_city': u'Palo Alto',
            'accepting_patients': False,
            'id': provider.user.id,
            'custom_logos': get_custom_logos(mhlu_id),
            'first_name': u'provider',
            'office_state': u'CA',
            'office_zip': u'',
            'staff_type': ''
        }
        self.assertEqual(return_data2, getUserInfo(provider.user.id),
                         'test failed for getUserInfo provider')

        # create physician
        provider1 = create_user(get_random_username(),
                                "physician",
                                "thj",
                                "demo",
                                "555 Bryant St.",
                                "Palo Alto",
                                "CA",
                                "",
                                uklass=Provider)
        provider1.mdcom_phone = '9002000002'
        provider1.save()
        phy = Physician(user=provider1)
        phy.specialty = 'AC'
        phy.save()
        return_data3 = {
            'last_name': u'thj',
            'office_address1': u'555 Bryant St.',
            'office_address2': u'',
            'photo': '/media/images/photos/avatar2.png',
            'specialty': u'Acupuncture',
            'mdcom_phone': u'9002000002',
            'office_city': u'Palo Alto',
            'accepting_patients': True,
            'id': phy.user.user.id,
            'custom_logos': get_custom_logos(mhlu_id),
            'first_name': u'physician',
            'office_state': u'CA',
            'office_zip': u'',
            'staff_type': ''
        }
        self.assertEqual(return_data3, getUserInfo(phy.user.user.id),
                         'test failed for getUserInfo physician')

        # 		create office staff
        staff = create_office_staff(get_random_username(),
                                    "staff",
                                    "thj",
                                    "demo",
                                    "555 Bryant St.",
                                    "Palo Alto",
                                    "CA",
                                    "",
                                    uklass=OfficeStaff)
        return_data4 = {
            'last_name': u'thj',
            'office_address1': u'555 Bryant St.',
            'office_address2': u'',
            'photo': '/media/images/photos/staff_icon.jpg',
            'specialty': '',
            'mdcom_phone': '',
            'office_city': u'Palo Alto',
            'accepting_patients': False,
            'id': staff.user.id,
            'custom_logos': get_custom_logos(mhlu_id),
            'first_name': u'staff',
            'office_state': u'CA',
            'office_zip': u'',
            'staff_type': 'Office Staff'
        }
        self.assertEqual(return_data4, getUserInfo(staff.user.id),
                         'test failed for getUserInfo staff')

        # 		create nurse
        staff2 = create_office_staff(get_random_username(),
                                     "nurse",
                                     "thj",
                                     "demo",
                                     "555 Bryant St.",
                                     "Palo Alto",
                                     "CA",
                                     "",
                                     uklass=OfficeStaff)
        nurse = Nurse(user=staff2)
        nurse.save()
        return_data5 = {
            'last_name': u'thj',
            'office_address1': u'555 Bryant St.',
            'office_address2': u'',
            'photo': '/media/images/photos/nurse.jpg',
            'specialty': '',
            'mdcom_phone': '',
            'office_city': u'Palo Alto',
            'accepting_patients': False,
            'id': nurse.user.user.id,
            'custom_logos': get_custom_logos(mhlu_id),
            'first_name': u'nurse',
            'office_state': u'CA',
            'office_zip': u'',
            'staff_type': 'Office Staff'
        }
        self.assertEqual(return_data5, getUserInfo(nurse.user.user.id),
                         'test failed for getUserInfo nurse')

        # 		create office staff
        staff3 = create_office_staff(get_random_username(),
                                     "maneger",
                                     "thj",
                                     "demo",
                                     "555 Bryant St.",
                                     "Palo Alto",
                                     "CA",
                                     "",
                                     uklass=OfficeStaff)
        mgr = Office_Manager(user=staff3)

        practice = PracticeLocation(
            practice_address1='555 Pleasant Pioneer Grove',
            practice_address2='Trailer Q615',
            practice_city='Mountain View',
            practice_state='CA',
            practice_zip='94040-4104',
            practice_lat=37.36876,
            practice_longit=-122.081864)
        practice.save()
        mgr.manager_role = 1
        mgr.practice = practice
        mgr.save()
        return_data5 = {
            'last_name': u'thj',
            'office_address1': u'555 Bryant St.',
            'office_address2': u'',
            'photo': '/media/images/photos/staff_icon.jpg',
            'specialty': '',
            'mdcom_phone': '',
            'office_city': u'Palo Alto',
            'accepting_patients': False,
            'id': mgr.user.user.id,
            'custom_logos': get_custom_logos(mhlu_id),
            'first_name': u'maneger',
            'office_state': u'CA',
            'office_zip': u'',
            'staff_type': 'Office Manager'
        }
        self.assertEqual(return_data5, getUserInfo(mgr.user.user.id),
                         'test failed for getUserInfo maneger')
Exemplo n.º 15
0
    def testSetOfficeStaffResultList(self):
        # 		create office staff
        staff = create_office_staff(get_random_username(),
                                    "staff",
                                    "thj",
                                    "demo",
                                    "555 Bryant St.",
                                    "Palo Alto",
                                    "CA",
                                    "",
                                    uklass=OfficeStaff)
        staff2 = create_office_staff(get_random_username(),
                                     "nurse",
                                     "thj",
                                     "demo",
                                     "555 Bryant St.",
                                     "Palo Alto",
                                     "CA",
                                     "",
                                     uklass=OfficeStaff)
        nurse = Nurse(user=staff2)
        nurse.save()
        staff3 = create_office_staff(get_random_username(),
                                     "maneger",
                                     "thj",
                                     "demo",
                                     "555 Bryant St.",
                                     "Palo Alto",
                                     "CA",
                                     "",
                                     uklass=OfficeStaff)
        mgr = Office_Manager(user=staff3)
        practice = PracticeLocation(
            practice_address1='555 Pleasant Pioneer Grove',
            practice_address2='Trailer Q615',
            practice_city='Mountain View',
            practice_state='CA',
            practice_zip='94040-4104',
            practice_lat=37.36876,
            practice_longit=-122.081864)
        practice.save()
        mgr.manager_role = 1
        mgr.practice = practice
        mgr.save()

        mhlu = create_user(get_random_username(), "mhluser", "thj", "demo",
                           "555 Bryant St.", "Palo Alto", "CA", "")
        mhlu.mdcom_phone = '9002000001'
        mhlu.save()

        self.assertEqual(0, len(setOfficeStaffResultList([])),
                         'test failed for setOfficeStaffResultList null')
        self.assertEqual(1, len(setOfficeStaffResultList([staff])),
                         'test failed for setOfficeStaffResultList staff')
        # 		self.assertEqual(1, len(setOfficeStaffResultList([nurse])),
        #'test failed for setOfficeStaffResultList nurse')
        self.assertEqual(1, len(setOfficeStaffResultList([mgr])),
                         'test failed for setOfficeStaffResultList mgr')
        self.assertEqual(
            3, len(setOfficeStaffResultList([staff, nurse.user, mgr])),
            'test failed for setOfficeStaffResultList')
        self.assertEqual(
            3, len(setOfficeStaffResultList([staff, nurse.user, mgr], staff)),
            'test failed for setOfficeStaffResultList')