Пример #1
0
    def testSiteManage(self):
        site = Site(name='mysite',
                    address1='555 Pleasant Pioneer Grove',
                    address2='Trailer Q615',
                    city='Mountain View',
                    state='CA',
                    zip='94040-4104',
                    lat=37.36876,
                    longit=-122.081864,
                    short_name='MSite')
        site.save()
        self.user.current_site = site
        self.user.sites.add(site)
        self.user.save()
        response = self.client.get(reverse\
          ('MHLogin.api.v1.views_account.siteManage'), **self.extra)
        self.assertEqual(response.status_code, 200, response.status_code)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 2)

        response = self.client.post(reverse\
          ('MHLogin.api.v1.views_account.siteManage'), **self.extra)
        self.assertEqual(response.status_code, 200, response.status_code)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 2)

        response = self.client.post(reverse\
          ('MHLogin.api.v1.views_account.siteManage'), data={'current_site':site.id}, **self.extra)
        self.assertEqual(response.status_code, 200, response.status_code)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 2)
Пример #2
0
	def testSiteManage(self):
		site = Site(
				name='mysite',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
		site.save()
		self.user.current_site = site
		self.user.sites.add(site)
		self.user.save()
		response = self.client.get(reverse\
				('MHLogin.api.v1.views_account.siteManage'), **self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 2)
		
		response = self.client.post(reverse\
				('MHLogin.api.v1.views_account.siteManage'), **self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 2)

		response = self.client.post(reverse\
				('MHLogin.api.v1.views_account.siteManage'), data={'current_site':site.id}, **self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 2)
Пример #3
0
	def test_site_staff(self):
		request = generateHttpRequest()
		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)

		#staff has not current site
		result = site_staff(request)
		self.assertEqual(result.status_code, 200)

		current_site = Site(name='test site', address1='test address', lat=0.0, longit=0.1)
		current_site.save()

		staff.current_site = current_site
		staff.save()

		#staff has current site
		result = site_staff(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(len(msg['data']['users']), 0)

		#return_python == true
		result = site_staff(request, True)
		msg = result['data']['users']
		self.assertEqual(len(msg), 0)
Пример #4
0
    def test_site_providers(self):
        request = generateHttpRequest()

        #provider has not current site
        result = site_providers(request)
        self.assertEqual(result.status_code, 200)

        current_site = Site(name='test site',
                            address1='test address',
                            lat=0.0,
                            longit=0.1)
        current_site.save()

        request.provider.current_site = current_site
        request.provider.save()

        #provider has current site
        result = site_providers(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['users']), 0)

        #return_python == true
        result = site_providers(request, True)
        msg = result['data']['users']
        self.assertEqual(len(msg), 0)
Пример #5
0
    def test_site_staff(self):
        request = generateHttpRequest()
        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)

        #staff has not current site
        result = site_staff(request)
        self.assertEqual(result.status_code, 200)

        current_site = Site(name='test site',
                            address1='test address',
                            lat=0.0,
                            longit=0.1)
        current_site.save()

        staff.current_site = current_site
        staff.save()

        #staff has current site
        result = site_staff(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['users']), 0)

        #return_python == true
        result = site_staff(request, True)
        msg = result['data']['users']
        self.assertEqual(len(msg), 0)
Пример #6
0
	def testSiteStaff(self):
		site = Site(name="pyang", address1="Palo Alto",lat="0.0",longit="0.0")
		site.save()
		
		response = self.client.post(reverse\
				('MHLogin.api.v1.views_sites.siteStaff', \
				args=(site.id,)), **self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
Пример #7
0
	def testMySiteMedStudents(self):
		site = Site(name="pyang", address1="Palo Alto",lat="0.0",longit="0.0")
		site.save()
		data = {
			'id': site.id
		}
		response = self.client.post(reverse\
				('MHLogin.api.v1.views_sites.mySiteMedStudents'), data, **self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
Пример #8
0
 def testMySiteStaff(self):
     site = Site(name="pyang",
                 address1="Palo Alto",
                 lat="0.0",
                 longit="0.0")
     site.save()
     data = {'id': site.id}
     response = self.client.post(reverse\
       ('MHLogin.api.v1.views_sites.mySiteStaff'), data, **self.extra)
     self.assertEqual(response.status_code, 200, response.status_code)
Пример #9
0
	def testProfile(self):
		phys = Physician(user = self.user)
		phys.save()
		data = {
			'username':get_random_username(),
			'first_name':'c',
			'last_name':'tian',
			'mobile_phone':9001111111,
			'gender':'M',
			'old_email':'*****@*****.**',
			'email':'*****@*****.**',
			'lat':0.0, 
			'longit':0.0, 
			'address1':'address1', 
			'address2':'address2', 
			'city':'Chicago', 
			'state':'IL', 
			'zip':60601,
			'user_type':1,
			'office_lat':41.885805,
			'office_longit':-87.6229106,
		}

		response = self.client.post(reverse\
				('MHLogin.api.v1.views_account.profile'), data,**self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 2)
		
		site = Site(
				name='mysite',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
		site.save()
		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice.save()
		self.user.current_site = site
		self.user.current_practice = practice
		self.user.save()
		response = self.client.get(reverse\
				('MHLogin.api.v1.views_account.profile'), data,**self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 2)
		
Пример #10
0
    def testSiteStaff(self):
        site = Site(name="pyang",
                    address1="Palo Alto",
                    lat="0.0",
                    longit="0.0")
        site.save()

        response = self.client.post(reverse\
          ('MHLogin.api.v1.views_sites.siteStaff', \
          args=(site.id,)), **self.extra)
        self.assertEqual(response.status_code, 200, response.status_code)
Пример #11
0
    def testProfile(self):
        phys = Physician(user=self.user)
        phys.save()
        data = {
            'username': get_random_username(),
            'first_name': 'c',
            'last_name': 'tian',
            'mobile_phone': 9001111111,
            'gender': 'M',
            'old_email': '*****@*****.**',
            'email': '*****@*****.**',
            'lat': 0.0,
            'longit': 0.0,
            'address1': 'address1',
            'address2': 'address2',
            'city': 'Chicago',
            'state': 'IL',
            'zip': 60601,
            'user_type': 1,
            'office_lat': 41.885805,
            'office_longit': -87.6229106,
        }

        response = self.client.post(reverse\
          ('MHLogin.api.v1.views_account.profile'), data,**self.extra)
        self.assertEqual(response.status_code, 200, response.status_code)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 2)

        site = Site(name='mysite',
                    address1='555 Pleasant Pioneer Grove',
                    address2='Trailer Q615',
                    city='Mountain View',
                    state='CA',
                    zip='94040-4104',
                    lat=37.36876,
                    longit=-122.081864,
                    short_name='MSite')
        site.save()
        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        self.user.current_site = site
        self.user.current_practice = practice
        self.user.save()
        response = self.client.get(reverse\
          ('MHLogin.api.v1.views_account.profile'), data,**self.extra)
        self.assertEqual(response.status_code, 200, response.status_code)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 2)
Пример #12
0
def create_site():
    site = Site(name='mysite',
                address1='555 Pleasant Pioneer Grove',
                address2='Trailer Q615',
                city='Mountain View',
                state='CA',
                zip='94040-4104',
                lat=37.36876,
                longit=-122.081864,
                short_name='MSite')
    site.save()
    return site
Пример #13
0
	def testGetSiteList(self):

		site1 = Site(
				name = 'mysite site',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name = 'MSite'
			)
		site1.save()
		
		site2 = Site(
				name = 'doctorcom site',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615 Bryant',
				city='Mountain View Palo',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name = 'MSite'
			)
		site2.save()
#	
		condition_dicts = [
					{'name':u'site','result':2,'result_failed':'name failed'},
					{'name':u'mysite','result':1,'result_failed':'name failed'},
					{'name':u'abc','result':0,'result_failed':'name failed'},
					{'address':u'Bryant','result':1,'result_failed':'address failed'},
					{'address':u'555 Pleasant Pioneer Grove','result':2,'result_failed':'address failed'},
					{'address':u'abc','result':0,'result_failed':'address failed'},
					{'city':u'Palo','result':1,'result_failed':'city failed'},
					{'city':u'Mountain View','result':2,'result_failed':'city failed'},
					{'city':u'abc','result':0,'result_failed':'city failed'},
					{'state':u'CA','result':2,'result_failed':'state failed1'},
					{'state':u'abc','result':0,'result_failed':'state failed3'},
					{'zip':'94040-4104','result':2,'result_failed':'zip failed1'},
					{'zip':u'22222','result':0,'result_failed':'zip failed2'},
					{'limit':0,'result':2, 'result_total':2, 'result_failed':'limit failed1'},
					{'limit':1,'result':1, 'result_total':2, 'result_failed':'limit failed2'},
					{'limit':2,'result':2, 'result_total':2, 'result_failed':'limit failed3'},
			]
		for dict in condition_dicts:
			result = getSiteList(dict)
			if 'result_total' not in dict:
				dict['result_total'] = dict['result']
			self.assertEqual(dict['result_total'], result['total_count'], dict['result_failed'])
Пример #14
0
def create_site():
	site = Site(
				name='mysite',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
	site.save()
	return site
Пример #15
0
    def test_site_students(self):
        request = generateHttpRequest()
        staff = OfficeStaff(user=request.user)
        staff.save()

        #provider not staff
        assn = SmartPhoneAssn.all_objects.get(
            device_id=request.REQUEST['DCOM_DEVICE_ID'])
        assn.user_type = 101
        assn.save(request)
        result = site_students(request)
        self.assertEqual(result.status_code, 400)
        msg = json.loads(result.content)
        self.assertEqual(msg['errno'], 'DM020')

        #get back provider and has no current site
        assn = SmartPhoneAssn.all_objects.get(
            device_id=request.REQUEST['DCOM_DEVICE_ID'])
        assn.user_type = 1
        assn.save(request)
        result = site_students(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['users']), 0)

        #provider has current site
        site = Site(name='test site',
                    address1='test address',
                    lat=0.0,
                    longit=0.1)
        site.save()
        request.provider.current_site = site
        request.provider.save()
        result = site_students(request)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(len(msg['data']['users']), 0)

        #Physician has current site
        request.provider.sites.add(site)
        request.provider.clinical_clerk = True
        request.provider.save()
        phy = Physician(user=request.provider)
        phy.save()
        result = site_students(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['users']), 1)
Пример #16
0
	def test_site_mgmt(self):
		request = generateHttpRequest()
		#get method and provider
		request.method = 'GET'
		result = site_mgmt(request)
		self.assertEqual(result.status_code, 200)

		#post method and site is none
		request.method = 'POST'
		result = site_mgmt(request)
		self.assertEqual(result.status_code, 200)

		#post method and new site is user site
		site = Site(name='test site', address1='test address', lat=0.0, longit=0.1)
		site.save()
		request.POST['current_site'] = site.id
		request.provider.sites.add(site)
		result = site_mgmt(request)
		self.assertEqual(result.status_code, 200)
Пример #17
0
	def test_site_students(self):
		request = generateHttpRequest()
		staff = OfficeStaff(user=request.user)
		staff.save()

		#provider not staff
		assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
		assn.user_type = 101
		assn.save(request)
		result = site_students(request)
		self.assertEqual(result.status_code, 400)
		msg = json.loads(result.content)
		self.assertEqual(msg['errno'], 'DM020')

		#get back provider and has no current site
		assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
		assn.user_type = 1
		assn.save(request)
		result = site_students(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(len(msg['data']['users']), 0)

		#provider has current site
		site = Site(name='test site', address1='test address', lat=0.0, longit=0.1)
		site.save()
		request.provider.current_site = site
		request.provider.save()
		result = site_students(request)
		self.assertEqual(result.status_code, 200)
		self.assertEqual(len(msg['data']['users']), 0)

		#Physician has current site
		request.provider.sites.add(site)
		request.provider.clinical_clerk = True
		request.provider.save()
		phy = Physician(user=request.provider)
		phy.save()
		result = site_students(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(len(msg['data']['users']), 1)
Пример #18
0
	def test_site_providers(self):
		request = generateHttpRequest()

		#provider has not current site
		result = site_providers(request)
		self.assertEqual(result.status_code, 200)

		current_site = Site(name='test site', address1='test address', lat=0.0, longit=0.1)
		current_site.save()

		request.provider.current_site = current_site
		request.provider.save()

		#provider has current site
		result = site_providers(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(len(msg['data']['users']), 0)

		#return_python == true
		result = site_providers(request, True)
		msg = result['data']['users']
		self.assertEqual(len(msg), 0)
Пример #19
0
    def testGetStaffList(self, mockgeo):
        practice1 = PracticeLocation(
            practice_name='USA practice',
            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)
        practice1.save()

        practice2 = PracticeLocation(practice_name='China practice',
                                     practice_address1='jiangsu',
                                     practice_address2='beijing',
                                     practice_city='suzhou',
                                     practice_state='JS',
                                     practice_zip='94040-4104',
                                     practice_lat=37.36876,
                                     practice_longit=-122.081864)
        practice2.save()

        site1 = Site(name='mysite',
                     address1='555 Pleasant Pioneer Grove',
                     address2='Trailer Q615',
                     city='Mountain View',
                     state='CA',
                     zip='94040-4104',
                     lat=37.36876,
                     longit=-122.081864,
                     short_name='MSite')
        site1.save()

        site2 = Site(name='doctorcom',
                     address1='555 Pleasant Pioneer Grove',
                     address2='Trailer Q615',
                     city='Mountain View',
                     state='CA',
                     zip='94040-4104',
                     lat=37.36876,
                     longit=-122.081864,
                     short_name='MSite')
        site2.save()

        staff1 = create_office_staff(get_random_username(),
                                     "staff_first",
                                     "staff_last",
                                     "demo",
                                     "555 Bryant St.",
                                     "Palo Alto",
                                     "CA",
                                     "25010",
                                     uklass=OfficeStaff)
        staff1.user.address2 = 'suzhou china'
        staff1.user.save()
        staff1.sites.add(site1)
        staff1.sites.add(site2)
        staff1.current_site = site1
        staff1.practices.add(practice1)
        staff1.practices.add(practice2)
        staff1.current_practice = practice1
        staff1.save()
        staff2 = create_office_staff(get_random_username(),
                                     "staff_first1",
                                     "staff_last1",
                                     "demo",
                                     "suzhou china",
                                     "suzhou",
                                     "AB",
                                     "25011",
                                     uklass=OfficeStaff)
        staff2.sites.add(site2)
        staff2.current_site = site2
        staff2.practices.add(practice2)
        staff2.current_practice = practice2
        staff2.save()

        condition_dicts = [
            {
                'name': u'staff',
                'result': 2,
                'result_failed': 'name failed'
            },
            {
                'name': u'last1 first1',
                'result': 1,
                'result_failed': 'name failed'
            },
            {
                'name': u'abc',
                'result': 0,
                'result_failed': 'name failed'
            },
            {
                'address': u'Bryant',
                'result': 1,
                'result_failed': 'address failed'
            },
            {
                'address': u'suzhou china',
                'result': 2,
                'result_failed': 'address failed'
            },
            {
                'address': u'abc',
                'result': 0,
                'result_failed': 'address failed'
            },
            {
                'city': u'Palo',
                'result': 1,
                'result_failed': 'city failed'
            },
            {
                'city': u'suzhou',
                'result': 1,
                'result_failed': 'city failed'
            },
            {
                'city': u'abc',
                'result': 0,
                'result_failed': 'city failed'
            },
            {
                'state': u'CA',
                'result': 1,
                'result_failed': 'state failed'
            },
            {
                'state': u'AB',
                'result': 1,
                'result_failed': 'state failed'
            },
            {
                'state': u'abc',
                'result': 0,
                'result_failed': 'state failed'
            },
            {
                'zip': staff1.user.zip,
                'result': 1,
                'result_failed': 'zip failed'
            },
            {
                'zip': staff2.user.zip,
                'result': 1,
                'result_failed': 'zip failed'
            },
            {
                'zip': u'22222',
                'result': 0,
                'result_failed': 'zip failed'
            },
            {
                'current_hospital': u'doctorcom',
                'result': 1,
                'result_failed': 'current_hospital failed'
            },
            {
                'current_hospital': u'mysite',
                'result': 1,
                'result_failed': 'current_hospital failed'
            },
            {
                'current_hospital': u'22222',
                'result': 0,
                'result_failed': 'current_hospital failed'
            },
            {
                'hospital': u'mysite',
                'result': 1,
                'result_failed': 'hospital failed'
            },
            {
                'hospital': u'doctorcom',
                'result': 2,
                'result_failed': 'hospital failed'
            },
            {
                'hospital': u'abc',
                'result': 0,
                'result_failed': 'hospital failed'
            },
            {
                'current_practice': u'USA practice',
                'result': 1,
                'result_failed': 'current_practice failed'
            },
            {
                'current_practice': u'China practice',
                'result': 1,
                'result_failed': 'current_practice failed'
            },
            {
                'current_practice': u'abc',
                'result': 0,
                'result_failed': 'current_practice failed'
            },
            {
                'practice': u'USA practice',
                'result': 1,
                'result_failed': 'practice failed'
            },
            {
                'practice': u'China practice',
                'result': 2,
                'result_failed': 'practice failed'
            },
            {
                'practice': u'abc',
                'result': 0,
                'result_failed': 'practice failed'
            },
            {
                'limit': 0,
                'result': 2,
                'result_total': 2,
                'result_failed': 'limit failed'
            },
            {
                'limit': 1,
                'result': 1,
                'result_total': 2,
                'result_failed': 'limit failed'
            },
            {
                'limit': 2,
                'result': 2,
                'result_total': 2,
                'result_failed': 'limit failed'
            },
            {
                'name': u'staff',
                'address': u'suzhou china',
                'city': u'suzhou',
                'state': u'AB',
                'zip': staff2.user.zip,
                'current_hospital': u'doctorcom',
                'hospital': u'doctorcom',
                'current_practice': u'China practice',
                'limit': 1,
                'result': 1,
                'result_total': 1,
                'result_failed': 'all failed'
            },
            {
                'name': u'abc',
                'address': u'suzhou china',
                'city': u'suzhou',
                'state': u'AB',
                'zip': staff2.user.zip,
                'current_hospital': u'doctorcom',
                'hospital': u'doctorcom',
                'current_practice': u'China practice',
                'limit': 1,
                'result': 0,
                'result_total': 0,
                'result_failed': 'all failed'
            },
        ]

        for d in condition_dicts:
            result = getStaffList(d)
            if 'result_total' not in d:
                d['result_total'] = d['result']
            self.assertEqual(d['result_total'], result['total_count'],
                             d['result_failed'])
            self.assertEqual(d['result'], len(result['results']),
                             d['result_failed'])
Пример #20
0
    def testGetProviderList(self, mockgeo):
        practice1 = PracticeLocation(
            practice_name='USA practice',
            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)
        practice1.save()

        practice2 = PracticeLocation(practice_name='China practice',
                                     practice_address1='jiangsu',
                                     practice_address2='beijing',
                                     practice_city='suzhou',
                                     practice_state='JS',
                                     practice_zip='94040-4104',
                                     practice_lat=37.36876,
                                     practice_longit=-122.081864)
        practice2.save()

        site1 = Site(name='mysite',
                     address1='555 Pleasant Pioneer Grove',
                     address2='Trailer Q615',
                     city='Mountain View',
                     state='CA',
                     zip='94040-4104',
                     lat=37.36876,
                     longit=-122.081864,
                     short_name='MSite')
        site1.save()

        site2 = Site(name='doctorcom',
                     address1='555 Pleasant Pioneer Grove',
                     address2='Trailer Q615',
                     city='Mountain View',
                     state='CA',
                     zip='94040-4104',
                     lat=37.36876,
                     longit=-122.081864,
                     short_name='MSite')
        site2.save()

        provider1 = create_user("prov1",
                                "provider_first",
                                "provider_last",
                                "demo",
                                "555 Bryant St.",
                                "Palo Alto",
                                "CA",
                                "94306",
                                uklass=Provider)
        provider1.address2 = 'suzhou china'
        provider1.user.save()
        provider1.sites.add(site1)
        provider1.sites.add(site2)
        provider1.current_site = site1
        provider1.practices.add(practice1)
        provider1.practices.add(practice2)
        provider1.current_practice = practice1
        provider1.save()
        provider2 = create_user("prov2",
                                "provider_first1",
                                "provider_last1",
                                "demo",
                                "suzhou china",
                                "suzhou",
                                "AB",
                                "94307",
                                uklass=Provider)
        provider2.sites.add(site2)
        provider2.current_site = site2
        provider2.practices.add(practice2)
        provider2.current_practice = practice2
        provider2.save()

        condition_dicts = [
            {
                'name': u'provider',
                'result': 2,
                'result_failed': 'name failed'
            },
            {
                'name': u'last1 first1',
                'result': 1,
                'result_failed': 'name failed'
            },
            {
                'name': u'abc',
                'result': 0,
                'result_failed': 'name failed'
            },
            {
                'address': u'Bryant',
                'result': 1,
                'result_failed': 'address failed'
            },
            {
                'address': u'suzhou china',
                'result': 2,
                'result_failed': 'address failed'
            },
            {
                'address': u'abc',
                'result': 0,
                'result_failed': 'address failed'
            },
            {
                'city': u'Palo',
                'result': 1,
                'result_failed': 'city failed'
            },
            {
                'city': u'suzhou',
                'result': 1,
                'result_failed': 'city failed'
            },
            {
                'city': u'abc',
                'result': 0,
                'result_failed': 'city failed'
            },
            {
                'state': u'CA',
                'result': 1,
                'result_failed': 'state failed'
            },
            {
                'state': u'AB',
                'result': 1,
                'result_failed': 'state failed'
            },
            {
                'state': u'abc',
                'result': 0,
                'result_failed': 'state failed'
            },
            {
                'zip': provider1.zip,
                'result': 1,
                'result_failed': 'zip failed1'
            },
            {
                'zip': provider2.zip,
                'result': 1,
                'result_failed': 'zip failed2'
            },
            {
                'zip': provider2.zip,
                'distance': 5000,
                'result': 1,
                'result_failed': 'zip failed3'
            },
            {
                'zip': u'43523',
                'result': 0,
                'result_failed': 'zip failed'
            },
            {
                'current_hospital': u'doctorcom',
                'result': 1,
                'result_failed': 'current_hospital failed'
            },
            {
                'current_hospital': u'mysite',
                'result': 1,
                'result_failed': 'current_hospital failed'
            },
            {
                'current_hospital': u'22222',
                'result': 0,
                'result_failed': 'current_hospital failed'
            },
            {
                'hospital': u'mysite',
                'result': 1,
                'result_failed': 'hospital failed'
            },
            {
                'hospital': u'doctorcom',
                'result': 2,
                'result_failed': 'hospital failed'
            },
            {
                'hospital': u'abc',
                'result': 0,
                'result_failed': 'hospital failed'
            },
            {
                'current_practice': u'USA practice',
                'result': 1,
                'result_failed': 'current_practice failed'
            },
            {
                'current_practice': u'China practice',
                'result': 1,
                'result_failed': 'current_practice failed'
            },
            {
                'current_practice': u'abc',
                'result': 0,
                'result_failed': 'current_practice failed'
            },
            {
                'practice': u'USA practice',
                'result': 1,
                'result_failed': 'practice failed'
            },
            {
                'practice': u'China practice',
                'result': 2,
                'result_failed': 'practice failed'
            },
            {
                'practice': u'abc',
                'result': 0,
                'result_failed': 'practice failed'
            },
            {
                'limit': 0,
                'result': 2,
                'result_total': 2,
                'result_failed': 'limit failed'
            },
            {
                'limit': 1,
                'result': 1,
                'result_total': 2,
                'result_failed': 'limit failed'
            },
            {
                'limit': 2,
                'result': 2,
                'result_total': 2,
                'result_failed': 'limit failed'
            },
            {
                'name': u'provider',
                'address': u'suzhou china',
                'city': u'suzhou',
                'state': u'AB',
                'current_hospital': u'doctorcom',
                'hospital': u'doctorcom',
                'current_practice': u'China practice',
                'limit': 1,
                'result': 1,
                'result_total': 1,
                'result_failed': 'all failed'
            },
            {
                'name': u'abc',
                'address': u'suzhou china',
                'city': u'suzhou',
                'state': u'AB',
                'zip': provider2.zip,
                'current_hospital': u'doctorcom',
                'hospital': u'doctorcom',
                'current_practice': u'China practice',
                'limit': 1,
                'result': 0,
                'result_total': 0,
                'result_failed': 'all failed'
            },
        ]

        with mock.patch('MHLogin.api.v1.utils_users.geocode2',
                        new_callable=lambda: UtilsUsersTest.mock_geocode):
            for d in condition_dicts:
                result = getProviderList(d)
                if 'result_total' not in d:
                    d['result_total'] = d['result']
                self.assertEqual(d['result_total'], result['total_count'],
                                 d['result_failed'])
                self.assertEqual(d['result'], len(result['results']),
                                 d['result_failed'])

        phy2 = Physician(user=provider1)
        phy2.specialty = 'AC'
        phy2.save()

        nppa = NP_PA(user=provider2)
        nppa.save()

        condition_dicts = [
            {
                'specialty': u'AC',
                'result': 1,
                'result_failed': 'specialty failed'
            },
            {
                'specialty': u'NP/PA/Midwife',
                'result': 1,
                'result_failed': 'specialty failed'
            },
            {
                'specialty': u'abc',
                'result': 2,
                'result_failed': 'specialty failed'
            },
        ]
        for d in condition_dicts:
            result = getProviderList(d)
            if 'result_total' not in d:
                d['result_total'] = d['result']
            self.assertEqual(d['result_total'], result['total_count'],
                             d['result_failed'])
            self.assertEqual(d['result'], len(result['results']),
                             d['result_failed'])
Пример #21
0
    def testSetProviderResultList(self):
        provider = create_user(get_random_username(),
                               "nppa",
                               "thj",
                               "demo",
                               "555 Bryant St.",
                               "Palo Alto",
                               "CA",
                               "",
                               uklass=Provider)
        provider.save()
        nppa = NP_PA(user=provider)
        nppa.save()

        provider1 = create_user(get_random_username(),
                                "physician",
                                "thj",
                                "demo",
                                "555 Bryant St.",
                                "Palo Alto",
                                "CA",
                                "",
                                uklass=Provider)
        provider1.save()
        phy = Physician(user=provider1)
        phy.specialty = 'AC'
        phy.save()

        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()

        provider2 = create_user(get_random_username(),
                                "nppa",
                                "thj",
                                "demo",
                                "555 Bryant St.",
                                "Palo Alto",
                                "CA",
                                "",
                                uklass=Provider)
        provider2.practices.add(practice)
        provider2.current_practice = practice
        provider2.save()
        nppa2 = NP_PA(user=provider2)
        nppa2.save()

        provider3 = create_user(get_random_username(),
                                "physician",
                                "thj",
                                "demo",
                                "555 Bryant St.",
                                "Palo Alto",
                                "CA",
                                "",
                                uklass=Provider)
        provider3.practices.add(practice)
        provider3.current_practice = practice
        provider3.save()
        phy2 = Physician(user=provider3)
        phy2.specialty = 'AC'
        phy2.save()

        site = Site(name='mysite',
                    address1='555 Pleasant Pioneer Grove',
                    address2='Trailer Q615',
                    city='Mountain View',
                    state='CA',
                    zip='94040-4104',
                    lat=37.36876,
                    longit=-122.081864,
                    short_name='MSite')
        site.save()

        provider4 = create_user(get_random_username(),
                                "nppa",
                                "thj",
                                "demo",
                                "555 Bryant St.",
                                "Palo Alto",
                                "CA",
                                "",
                                uklass=Provider)
        provider4.sites.add(site)
        provider4.current_site = site
        provider4.save()
        nppa3 = NP_PA(user=provider4)
        nppa3.save()

        provider5 = create_user(get_random_username(),
                                "physician",
                                "thj",
                                "demo",
                                "555 Bryant St.",
                                "Palo Alto",
                                "CA",
                                "",
                                uklass=Provider)
        provider5.sites.add(site)
        provider5.current_site = site
        provider5.save()
        phy3 = Physician(user=provider5)
        phy3.specialty = 'AC'
        phy3.save()

        self.assertEqual(0, len(setProviderResultList([])),
                         'test failed for setProviderResultList')
        self.assertEqual(1, len(setProviderResultList([nppa.user], phy.user)),
                         'test failed for setProviderResultList')
        self.assertEqual(1, len(setProviderResultList([phy.user])),
                         'test failed for setProviderResultList')
        self.assertEqual(1, len(setProviderResultList([nppa2.user])),
                         'test failed for setProviderResultList')
        self.assertEqual(1, len(setProviderResultList([phy2.user])),
                         'test failed for setProviderResultList')
        self.assertEqual(1, len(setProviderResultList([nppa3.user])),
                         'test failed for setProviderResultList')
        self.assertEqual(1, len(setProviderResultList([phy3.user])),
                         'test failed for setProviderResultList')
        self.assertEqual(
            6,
            len(
                setProviderResultList([
                    nppa.user, phy.user, nppa2.user, phy2.user, nppa3.user,
                    phy3.user
                ])), 'test failed for setProviderResultList')
Пример #22
0
	def testGetProviderList(self, mockgeo):
		practice1 = PracticeLocation(
			practice_name='USA practice',
			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)
		practice1.save()

		practice2 = PracticeLocation(
			practice_name='China practice',
			practice_address1='jiangsu',
			practice_address2='beijing',
			practice_city='suzhou',
			practice_state='JS',
			practice_zip='94040-4104',
			practice_lat=37.36876,
			practice_longit=-122.081864)
		practice2.save()

		site1 = Site(
				name='mysite',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
		site1.save()

		site2 = Site(
				name='doctorcom',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
		site2.save()

		provider1 = create_user("prov1", "provider_first", 
			"provider_last", "demo", "555 Bryant St.", "Palo Alto", "CA", 
			"94306", uklass=Provider)
		provider1.address2 = 'suzhou china'
		provider1.user.save()
		provider1.sites.add(site1)
		provider1.sites.add(site2)
		provider1.current_site = site1
		provider1.practices.add(practice1)
		provider1.practices.add(practice2)
		provider1.current_practice = practice1
		provider1.save()
		provider2 = create_user("prov2", "provider_first1", "provider_last1", 
				"demo", "suzhou china", "suzhou", "AB", "94307", uklass=Provider)
		provider2.sites.add(site2)
		provider2.current_site = site2
		provider2.practices.add(practice2)
		provider2.current_practice = practice2
		provider2.save()

		condition_dicts = [
					{'name':u'provider', 'result':2, 'result_failed':'name failed'},
					{'name':u'last1 first1', 'result':1, 'result_failed':'name failed'},
					{'name':u'abc', 'result':0, 'result_failed':'name failed'},
					{'address':u'Bryant', 'result':1, 'result_failed':'address failed'},
					{'address':u'suzhou china', 'result':2, 'result_failed':'address failed'},
					{'address':u'abc', 'result':0, 'result_failed':'address failed'},
					{'city':u'Palo', 'result':1, 'result_failed':'city failed'},
					{'city':u'suzhou', 'result':1, 'result_failed':'city failed'},
					{'city':u'abc', 'result':0, 'result_failed':'city failed'},
					{'state':u'CA', 'result':1, 'result_failed':'state failed'},
					{'state':u'AB', 'result':1, 'result_failed':'state failed'},
					{'state':u'abc', 'result':0, 'result_failed':'state failed'},
  					{'zip':provider1.zip, 'result':1, 'result_failed':'zip failed1'},
  					{'zip':provider2.zip, 'result':1, 'result_failed':'zip failed2'},
  					{'zip':provider2.zip, 'distance':5000, 'result':1, 'result_failed':'zip failed3'},
  					{'zip':u'43523', 'result':0, 'result_failed':'zip failed'},
					{'current_hospital':u'doctorcom', 'result':1, 'result_failed':'current_hospital failed'},
					{'current_hospital':u'mysite', 'result':1, 'result_failed':'current_hospital failed'},
					{'current_hospital':u'22222', 'result':0, 'result_failed':'current_hospital failed'},
					{'hospital':u'mysite', 'result':1, 'result_failed':'hospital failed'},
					{'hospital':u'doctorcom', 'result':2, 'result_failed':'hospital failed'},
					{'hospital':u'abc', 'result':0, 'result_failed':'hospital failed'},
					{'current_practice':u'USA practice', 'result':1, 'result_failed':'current_practice failed'},
					{'current_practice':u'China practice', 'result':1, 'result_failed':'current_practice failed'},
					{'current_practice':u'abc', 'result':0, 'result_failed':'current_practice failed'},
					{'practice':u'USA practice', 'result':1, 'result_failed':'practice failed'},
					{'practice':u'China practice', 'result':2, 'result_failed':'practice failed'},
					{'practice':u'abc', 'result':0, 'result_failed':'practice failed'},
					{'limit':0, 'result':2, 'result_total':2, 'result_failed':'limit failed'},
					{'limit':1, 'result':1, 'result_total':2, 'result_failed':'limit failed'},
					{'limit':2, 'result':2, 'result_total':2, 'result_failed':'limit failed'},
					{
						'name':u'provider', 'address':u'suzhou china', 'city':u'suzhou', 'state':u'AB',
						'current_hospital':u'doctorcom',
						'hospital':u'doctorcom', 'current_practice':u'China practice',
						'limit':1, 'result':1, 'result_total':1, 'result_failed':'all failed'
					},
					{
						'name':u'abc', 'address':u'suzhou china', 'city':u'suzhou', 'state':u'AB',
						'zip':provider2.zip, 'current_hospital':u'doctorcom',
						'hospital':u'doctorcom', 'current_practice':u'China practice',
						'limit':1, 'result':0, 'result_total':0, 'result_failed':'all failed'
					},
			]

		with mock.patch('MHLogin.api.v1.utils_users.geocode2', 
						new_callable=lambda: UtilsUsersTest.mock_geocode):
			for d in condition_dicts:
				result = getProviderList(d)
				if 'result_total' not in d:
					d['result_total'] = d['result']
				self.assertEqual(d['result_total'], result['total_count'], d['result_failed'])
				self.assertEqual(d['result'], len(result['results']), d['result_failed'])

		phy2 = Physician(user=provider1)
		phy2.specialty = 'AC'
		phy2.save()

		nppa = NP_PA(user=provider2)
		nppa.save()

		condition_dicts = [
					{'specialty':u'AC', 'result':1, 'result_failed':'specialty failed'},
					{'specialty':u'NP/PA/Midwife', 'result':1, 'result_failed':'specialty failed'},
					{'specialty':u'abc', 'result':2, 'result_failed':'specialty failed'},
		]
		for d in condition_dicts:
			result = getProviderList(d)
			if 'result_total' not in d:
				d['result_total'] = d['result']
			self.assertEqual(d['result_total'], result['total_count'], d['result_failed'])
			self.assertEqual(d['result'], len(result['results']), d['result_failed'])
Пример #23
0
	def testSetProviderResultList(self):
		provider = create_user(get_random_username(), "nppa", "thj", "demo", 
							"555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider)
		provider.save()
		nppa = NP_PA(user=provider)
		nppa.save()

		provider1 = create_user(get_random_username(), "physician", "thj", "demo", 
							"555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider)
		provider1.save()
		phy = Physician(user=provider1)
		phy.specialty = 'AC'
		phy.save()

		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()

		provider2 = create_user(get_random_username(), "nppa", "thj", "demo", 
							"555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider)
		provider2.practices.add(practice)
		provider2.current_practice = practice
		provider2.save()
		nppa2 = NP_PA(user=provider2)
		nppa2.save()

		provider3 = create_user(get_random_username(), "physician", "thj", "demo", 
							"555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider)
		provider3.practices.add(practice)
		provider3.current_practice = practice
		provider3.save()
		phy2 = Physician(user=provider3)
		phy2.specialty = 'AC'
		phy2.save()

		site = Site(
				name='mysite',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
		site.save()

		provider4 = create_user(get_random_username(), "nppa", "thj", "demo", 
							"555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider)
		provider4.sites.add(site)
		provider4.current_site = site
		provider4.save()
		nppa3 = NP_PA(user=provider4)
		nppa3.save()

		provider5 = create_user(get_random_username(), "physician", "thj", "demo", 
							"555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider)
		provider5.sites.add(site)
		provider5.current_site = site
		provider5.save()
		phy3 = Physician(user=provider5)
		phy3.specialty = 'AC'
		phy3.save()

		self.assertEqual(0, len(setProviderResultList([])), 'test failed for setProviderResultList')
		self.assertEqual(1, len(setProviderResultList([nppa.user], phy.user)), 
						'test failed for setProviderResultList')
		self.assertEqual(1, len(setProviderResultList([phy.user])), 'test failed for setProviderResultList')
		self.assertEqual(1, len(setProviderResultList([nppa2.user])), 'test failed for setProviderResultList')
		self.assertEqual(1, len(setProviderResultList([phy2.user])), 'test failed for setProviderResultList')
		self.assertEqual(1, len(setProviderResultList([nppa3.user])), 'test failed for setProviderResultList')
		self.assertEqual(1, len(setProviderResultList([phy3.user])), 'test failed for setProviderResultList')
		self.assertEqual(6, len(setProviderResultList([nppa.user, phy.user, nppa2.user, phy2.user,
				nppa3.user, phy3.user])), 'test failed for setProviderResultList')
Пример #24
0
	def testGetStaffList(self, mockgeo):
		practice1 = PracticeLocation(
			practice_name='USA practice',
			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)
		practice1.save()

		practice2 = PracticeLocation(
			practice_name='China practice',
			practice_address1='jiangsu',
			practice_address2='beijing',
			practice_city='suzhou',
			practice_state='JS',
			practice_zip='94040-4104',
			practice_lat=37.36876,
			practice_longit=-122.081864)
		practice2.save()

		site1 = Site(
				name='mysite',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
		site1.save()

		site2 = Site(
				name='doctorcom',
				address1='555 Pleasant Pioneer Grove',
				address2='Trailer Q615',
				city='Mountain View',
				state='CA',
				zip='94040-4104',
				lat=37.36876,
				longit=-122.081864,
				short_name='MSite'
			)
		site2.save()

		staff1 = create_office_staff(get_random_username(), "staff_first", "staff_last", 
				"demo", "555 Bryant St.", "Palo Alto", "CA", "25010", uklass=OfficeStaff)
		staff1.user.address2 = 'suzhou china'
		staff1.user.save()
		staff1.sites.add(site1)
		staff1.sites.add(site2)
		staff1.current_site = site1
		staff1.practices.add(practice1)
		staff1.practices.add(practice2)
		staff1.current_practice = practice1
		staff1.save()
		staff2 = create_office_staff(get_random_username(), "staff_first1", "staff_last1", 
				"demo", "suzhou china", "suzhou", "AB", "25011", uklass=OfficeStaff)
		staff2.sites.add(site2)
		staff2.current_site = site2
		staff2.practices.add(practice2)
		staff2.current_practice = practice2
		staff2.save()

		condition_dicts = [
				{'name':u'staff', 'result':2, 'result_failed':'name failed'},
				{'name':u'last1 first1', 'result':1, 'result_failed':'name failed'},
				{'name':u'abc', 'result':0, 'result_failed':'name failed'},
				{'address':u'Bryant', 'result':1, 'result_failed':'address failed'},
				{'address':u'suzhou china', 'result':2, 'result_failed':'address failed'},
				{'address':u'abc', 'result':0, 'result_failed':'address failed'},
				{'city':u'Palo', 'result':1, 'result_failed':'city failed'},
				{'city':u'suzhou', 'result':1, 'result_failed':'city failed'},
				{'city':u'abc', 'result':0, 'result_failed':'city failed'},
				{'state':u'CA', 'result':1, 'result_failed':'state failed'},
				{'state':u'AB', 'result':1, 'result_failed':'state failed'},
				{'state':u'abc', 'result':0, 'result_failed':'state failed'},
				{'zip':staff1.user.zip, 'result':1, 'result_failed':'zip failed'},
				{'zip':staff2.user.zip, 'result':1, 'result_failed':'zip failed'},
				{'zip':u'22222', 'result':0, 'result_failed':'zip failed'},
				{'current_hospital':u'doctorcom', 'result':1, 'result_failed':'current_hospital failed'},
				{'current_hospital':u'mysite', 'result':1, 'result_failed':'current_hospital failed'},
				{'current_hospital':u'22222', 'result':0, 'result_failed':'current_hospital failed'},
				{'hospital':u'mysite', 'result':1, 'result_failed':'hospital failed'},
				{'hospital':u'doctorcom', 'result':2, 'result_failed':'hospital failed'},
				{'hospital':u'abc', 'result':0, 'result_failed':'hospital failed'},
				{'current_practice':u'USA practice', 'result':1, 'result_failed':'current_practice failed'},
				{'current_practice':u'China practice', 'result':1, 'result_failed':'current_practice failed'},
				{'current_practice':u'abc', 'result':0, 'result_failed':'current_practice failed'},
				{'practice':u'USA practice', 'result':1, 'result_failed':'practice failed'},
				{'practice':u'China practice', 'result':2, 'result_failed':'practice failed'},
				{'practice':u'abc', 'result':0, 'result_failed':'practice failed'},
				{'limit':0, 'result':2, 'result_total':2, 'result_failed':'limit failed'},
				{'limit':1, 'result':1, 'result_total':2, 'result_failed':'limit failed'},
				{'limit':2, 'result':2, 'result_total':2, 'result_failed':'limit failed'},
				{
					'name':u'staff', 'address':u'suzhou china', 'city':u'suzhou', 'state':u'AB',
					'zip':staff2.user.zip, 'current_hospital':u'doctorcom',
					'hospital':u'doctorcom', 'current_practice':u'China practice',
					'limit':1, 'result':1, 'result_total':1, 'result_failed':'all failed'
				},
				{
					'name':u'abc', 'address':u'suzhou china', 'city':u'suzhou', 'state':u'AB',
					'zip':staff2.user.zip, 'current_hospital':u'doctorcom',
					'hospital':u'doctorcom', 'current_practice':u'China practice',
					'limit':1, 'result':0, 'result_total':0, 'result_failed':'all failed'
				},
			]

		for d in condition_dicts:
			result = getStaffList(d)
			if 'result_total' not in d:
				d['result_total'] = d['result']
			self.assertEqual(d['result_total'], result['total_count'], d['result_failed'])
			self.assertEqual(d['result'], len(result['results']), d['result_failed'])