예제 #1
0
    def setUp(self):
        clean_db_datas()

        OrganizationType.objects.all().delete()
        org_setting = OrganizationSetting()
        org_setting.save()
        self.org_type = OrganizationType(name="Test Org Type1",
                                         organization_setting=org_setting,
                                         is_public=True)
        self.org_type.save()

        self.organization = create_organization()

        self.admin = create_user('admin',
                                 'Morris',
                                 'Kelly',
                                 'demo',
                                 uklass=Administrator)
        staff = create_user('practicemgr1',
                            'Practice',
                            'Mgr',
                            'demo',
                            uklass=OfficeStaff)
        staff.practices.add(self.organization)
        staff.save()

        self.manager = Office_Manager(user=staff,
                                      practice=self.organization,
                                      manager_role=1)
        self.manager.save()
예제 #2
0
class GetOrgSubUserTypesTest(TestCase):
	organization = None
	org_setting = None
	org_type = None
	org_type_setting = None

	def setUp(self):
		clean_db_datas()

		self.org_setting = OrganizationSetting(
				can_have_physician = True,
				can_have_nppa = True,
				can_have_medical_student = True,
				can_have_staff = True,
				can_have_manager = True,
				can_have_nurse = True,
				can_have_tech_admin = True,
			)
		self.org_setting.save()

		self.organization = create_organization()
		self.organization.organization_setting = self.org_setting

	def test_get_org_sub_user_types(self):
		self.assertListEqual([1,2,10,100,101,3,-1], self.organization.get_org_sub_user_types())

	def tearDown(self):
		clean_db_datas()
예제 #3
0
파일: utils.py 프로젝트: cnzhuran/mdcom
def create_organization(auto_type=True, org_type=None, org_type_id=None, org_name="Test Org"):
	if not org_type:
		if auto_type:
			org_setting = OrganizationSetting(can_have_luxury_logo=True,
											display_in_contact_list_tab=True)
			org_setting.save()
			type_name = "Test Org Type1"
			if org_type_id:
				org_type = OrganizationType(id=org_type_id, 
					name=type_name, organization_setting=org_setting)
				org_type.save()
			else:
				org_type = OrganizationType(name=type_name, organization_setting=org_setting)
				# force id for test - MySQL UT's don't re-use ids after cleanup 
				org_type.id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
				# TODO: issue 2030, reserved id's is a hazardous approach, the UT's 
				# were working with SQLlite but not with MySQL, DB engines recycle
				# id's differently and we should not rely on reserved id fields.  This 
				# should be addressed in a separate Redmine as model changes may occur.
				org_type.save()

	_organization = PracticeLocation(
		practice_name="Test Org",
		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,
		organization_type=org_type)
	_organization.save()
	return _organization
예제 #4
0
	def setUp(self):
		clean_db_datas()

		OrganizationType.objects.all().delete()
		org_setting = OrganizationSetting()
		org_setting.save()
		self.org_type = OrganizationType(name="Test Org Type1", 
			organization_setting=org_setting, is_public=True)
		# TODO: issue 2030, reserved id's is a hazardous approach, the UT's 
		# were working with SQLlite but not with MySQL, DB engines recycle
		# id's differently and we should not rely on reserved id fields.  This 
		# should be addressed in a separate Redmine as model changes may occur.
		self.org_type.id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
		self.org_type.save()

		self.organization = create_organization()
		self.organization = PracticeLocation(
			practice_name=get_random_username(),
			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)
		self.organization.save()

		self.admin = create_user('admin', 'Morris', 'Kelly', 'demo', uklass=Administrator)
		staff = create_user('practicemgr1', 'Practice', 'Mgr', 'demo', uklass=OfficeStaff)
		staff.practices.add(self.organization)
		staff.save()

		self.manager = Office_Manager(user=staff, practice=self.organization, manager_role=1)
		self.manager.save()
예제 #5
0
	def setUp(self):
		clean_db_datas()
		org_setting = OrganizationSetting()
		org_setting.save()
		self.org_type = OrganizationType(name="Test Org Type1", 
			organization_setting=org_setting, is_public=True)
		self.org_type.save()
예제 #6
0
class GetOrgSubUserTypesTest(TestCase):
    organization = None
    org_setting = None
    org_type = None
    org_type_setting = None

    def setUp(self):
        clean_db_datas()

        self.org_setting = OrganizationSetting(
            can_have_physician=True,
            can_have_nppa=True,
            can_have_medical_student=True,
            can_have_staff=True,
            can_have_manager=True,
            can_have_nurse=True,
            can_have_tech_admin=True,
        )
        self.org_setting.save()

        self.organization = create_organization()
        self.organization.organization_setting = self.org_setting

    def test_get_org_sub_user_types(self):
        self.assertListEqual([1, 2, 10, 100, 101, 3, -1],
                             self.organization.get_org_sub_user_types())

    def tearDown(self):
        clean_db_datas()
예제 #7
0
	def setUp(self):
		clean_db_datas()

		org_setting = OrganizationSetting()
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", organization_setting=org_setting, is_public=True)
		org_type.save()
		self.org = PracticeLocation(
			practice_name="Test1",
			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)
		self.org.organization_type = org_type
		self.org.save()

		for i in range(10):
			user_name = "".join(["Staff1_", str(i)])
			first_name = "".join(["Test1_", str(i)])
			user = create_user(user_name, first_name, 'S', 'demo', uklass=OfficeStaff)
			self.org_staff.append(user)

			# IntegrityError: column username is not unique
#			provider_name = "".join(["Pravider1_", str(i)])
#			pro = create_user(provider_name, 'Provider', 'P', 'demo', uklass=Provider)
#			self.org_providers.append(pro)

		self.staff = create_user("Staff2", 'Test2', 'S', 'demo', uklass=OfficeStaff)
		self.staff.save()
		self.provider = create_user("Pravider2", 'Provider', 'P', 'demo', uklass=Provider)
		self.provider.save()
예제 #8
0
 def setUpClass(cls):
     cls.provider1 = Provider.objects.create(username='******',
                                             first_name='heal',
                                             last_name='meister',
                                             address1="555 Bryant St.",
                                             city="Palo Alto",
                                             state="CA",
                                             lat=0.0,
                                             longit=0.0,
                                             office_lat=0.0,
                                             office_longit=0.0,
                                             is_active=True,
                                             tos_accepted=True,
                                             mobile_confirmed=True,
                                             mdcom_phone='777',
                                             mobile_phone='666')
     cls.provider1.set_password('demo')
     cls.provider1.user = cls.provider1  # for our unique prov-user reln
     cls.provider1.save()
     cls.provider2 = Provider.objects.create(username='******',
                                             first_name='doc',
                                             last_name='holiday',
                                             address1="123 Main St.",
                                             city="Tombstone",
                                             state="AZ",
                                             lat=0.0,
                                             longit=0.0,
                                             office_lat=0.0,
                                             office_longit=0.0,
                                             is_active=True,
                                             tos_accepted=True,
                                             mobile_confirmed=True,
                                             mdcom_phone='999',
                                             mobile_phone='888')
     cls.provider2.set_password('demo')
     cls.provider2.user = cls.provider2  # for our unique prov-user reln
     cls.provider2.save()
     cls.call_group = CallGroup.objects.create(description='test',
                                               team='team')
     org_setting = OrganizationSetting(can_have_answering_service=True)
     org_setting.save()
     cls.practice = PracticeLocation.objects.create(
         practice_name='The MRC Gang',
         practice_phone='765',
         mdcom_phone='909',
         pin='1234',
         name_greeting='hello',
         greeting_closed='we are closed',
         greeting_lunch='its lunch time',
         config_complete=False,
         practice_lat=0.0,
         practice_longit=0.0,
         time_zone='UTC',
         call_group=cls.call_group,
         organization_setting=org_setting)
     # TESTING_KMS_INTEGRATION create keys
     generate_keys_for_users(output=devnull)
     # setup to get us going
     cls.setup_IVR_for_providers()
     cls.setup_IVR_for_practice()
예제 #9
0
	def setUp(self):
		clean_db_datas()

		org_setting = OrganizationSetting()
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", organization_setting=org_setting, is_public=True)
		org_type.save()
		self.org = create_organization()

		for i in range(10):
			user_name = "".join(["Staff1_", str(i)])
			first_name = "".join(["Test1_", str(i)])
			user = create_user(user_name, first_name, 'S', 'demo')
			self.staff = OfficeStaff()
			self.staff.user = user
			self.staff.office_lat = 0.0
			self.staff.office_longit = 0.0
			self.staff.save()
			self.org_staff.append(self.staff)

			# IntegrityError: column username is not unique
#			provider_name = "".join(["Pravider1_", str(i)])
#			pro = create_user(provider_name, 'Provider', 'P', 'demo', uklass=Provider)
#			self.org_providers.append(pro)
		self.user = create_user(get_random_username(), 'staff', 'S', 'demo')
		staff = OfficeStaff()
		staff.user = self.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.save()
		self.staff = staff
		self.provider = create_user("Pravider2", 'Provider', 'P', 'demo', uklass=Provider)
		self.provider.save()
예제 #10
0
	def setUp(self):
		clean_db_datas()

		org_setting = OrganizationSetting()
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", organization_setting=org_setting, is_public=True)
		org_type.save()
		self.org = create_organization()

		user1 = create_user(get_random_username(), 'Test1', 'S', 'demo')
		staff1 = OfficeStaff()
		staff1.user = user1
		staff1.office_lat = 0.0
		staff1.office_longit = 0.0
		staff1.current_practice = self.org
		staff1.save()
		staff1.practices.add(self.org)
		self.manager = Office_Manager(user=staff1, practice=self.org, manager_role=1)

		user = create_user(get_random_username(), 'Test1', 'S', 'demo')
		staff = OfficeStaff()
		staff.user = user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.save()
		self.staff = staff
		
		self.provider = create_user("Pravider2", 'Provider', 'P', 'demo', uklass=Provider)
		self.provider.save()
예제 #11
0
	def setUpClass(cls):
		cls.provider1 = Provider.objects.create(username='******', first_name='heal',
			last_name='meister', address1="555 Bryant St.", city="Palo Alto", state="CA", 
			lat=0.0, longit=0.0, office_lat=0.0, office_longit=0.0, is_active=True, 
			tos_accepted=True, mobile_confirmed=True, mdcom_phone='777', mobile_phone='666')
		cls.provider1.set_password('demo')
		cls.provider1.user = cls.provider1  # for our unique prov-user reln
		cls.provider1.save()
		cls.provider2 = Provider.objects.create(username='******', first_name='doc',
			last_name='holiday', address1="123 Main St.", city="Tombstone", state="AZ", 
			lat=0.0, longit=0.0, office_lat=0.0, office_longit=0.0, is_active=True, 
			tos_accepted=True, mobile_confirmed=True, mdcom_phone='999', mobile_phone='888')
		cls.provider2.set_password('demo')
		cls.provider2.user = cls.provider2  # for our unique prov-user reln
		cls.provider2.save()
		cls.call_group = CallGroup.objects.create(description='test', team='team')
		org_setting = OrganizationSetting(can_have_answering_service=True)
		org_setting.save()
		cls.practice = PracticeLocation.objects.create(practice_name='The MRC Gang',
			practice_phone='765', mdcom_phone='909', pin='1234', name_greeting='hello',
			greeting_closed='we are closed', greeting_lunch='its lunch time', 
			config_complete=False, practice_lat=0.0, practice_longit=0.0, 
			time_zone='UTC', call_group=cls.call_group, organization_setting=org_setting)
		# TESTING_KMS_INTEGRATION create keys
		generate_keys_for_users(output=devnull)
		# setup to get us going
		cls.setup_IVR_for_providers()
		cls.setup_IVR_for_practice()
예제 #12
0
class OrganizationSettingTest(TestCase):
    organization = None
    org_setting = None
    org_type = None
    org_type_setting = None

    def setUp(self):
        clean_db_datas()
        self.organization = create_organization(auto_type=False)

        self.org_setting = OrganizationSetting()
        self.org_setting.save()

        self.org_type_setting = OrganizationSetting()
        self.org_type_setting.save()
        self.org_type = OrganizationType(
            name="Test Org Type", organization_setting=self.org_type_setting)
        self.org_type.save()

    def testOrganizationSetting_None(self):
        self.assertIsNone(self.organization.get_setting())

        self.organization.organization_setting = self.org_setting
        self.organization.save()
        self.org_setting.delete_flag = True
        self.org_setting.save()
        self.assertIsNone(self.organization.get_setting())

    def testOrganizationSetting_FromOrganization(self):
        self.organization.organization_setting = self.org_setting
        self.organization.save()
        self.org_setting.delete_flag = False
        self.org_setting.save()
        self.assertEqual(self.org_setting, self.organization.get_setting())

        self.organization.organization_type = self.org_type
        self.organization.save()
        setting = self.organization.get_setting()
        self.assertEqual(self.org_setting, setting)
        self.assertNotEqual(self.org_type_setting, setting)

    def testOrganizationSetting_FromOrganizationType(self):
        self.organization.organization_type = self.org_type
        self.organization.organization_setting = None
        self.organization.save()
        self.assertEqual(self.org_type_setting,
                         self.organization.get_setting())

        self.org_setting.delete_flag = True
        self.org_setting.save()
        self.organization.organization_type = self.org_type
        self.organization.organization_setting = self.org_setting
        self.organization.save()
        setting = self.organization.get_setting()
        self.assertEqual(self.org_type_setting, setting)
        self.assertNotEqual(self.org_setting, setting)

    def tearDown(self):
        clean_db_datas()
예제 #13
0
 def setUp(self):
     clean_db_datas()
     org_setting = OrganizationSetting()
     org_setting.save()
     self.org_type = OrganizationType(name="Test Org Type1",
                                      organization_setting=org_setting,
                                      is_public=True)
     self.org_type.save()
예제 #14
0
파일: base.py 프로젝트: cnzhuran/mdcom
 def _add_practices(self):
     org_setting = OrganizationSetting(can_have_answering_service=True)
     org_setting.save()
     for pract in self.practice_data:
         practice = PracticeLocation.objects.create(
             practice_name=pract["practice_name"],
             practice_address1=pract["practice_address1"],
             practice_address2=pract["practice_address2"],
             practice_city=pract["practice_city"],
             practice_state=pract["practice_state"],
             practice_zip=pract["practice_zip"],
             mdcom_phone=pract["mdcom_phone"],
             practice_phone=pract["practice_phone"],
             time_zone=pract["time_zone"],
             practice_lat=pract["practice_lat"],
             practice_longit=pract["practice_longit"],
             organization_setting=org_setting)
         practice.save()
         self.practices.append(practice)
     self.callgroup1 = CallGroup(description="Team A",
                                 team="Team A",
                                 number_selection=2)
     self.callgroup1.save()
     self.callgroup2 = CallGroup(description="Team B",
                                 team="Team B",
                                 number_selection=3)
     self.callgroup2.save()
     self.callgroup3 = CallGroup(description="Team C",
                                 team="Team C",
                                 number_selection=4)
     self.callgroup3.save()
     self.callgroup4 = CallGroup(description="Team D",
                                 team="Team D",
                                 number_selection=5)
     self.callgroup4.save()
     p1 = self.practices[0]
     p1.call_group = self.callgroup1
     p1.save()
     p2 = self.practices[1]
     p2.call_groups.add(self.callgroup2)
     p2.save()
     p3 = self.practices[2]
     p3.call_groups.add(self.callgroup3)
     p3.call_groups.add(self.callgroup4)
     p3.save()
     self.specialty1 = Specialty()
     self.specialty1.name = 'Cardiology'
     self.specialty1.practice_location = self.practices[2]
     self.specialty1.number_selection = 3
     self.specialty1.save()
     self.specialty1.call_groups.add(self.callgroup3)
     self.specialty2 = Specialty()
     self.specialty2.name = 'ENT'
     self.specialty2.practice_location = self.practices[2]
     self.specialty2.number_selection = 4
     self.specialty2.save()
     self.specialty2.call_groups.add(self.callgroup4)
예제 #15
0
class OrganizationSettingTest(TestCase):
	organization = None
	org_setting = None
	org_type = None
	org_type_setting = None

	def setUp(self):
		clean_db_datas()
		self.organization = create_organization(auto_type=False)

		self.org_setting = OrganizationSetting()
		self.org_setting.save()

		self.org_type_setting = OrganizationSetting()
		self.org_type_setting.save()
		self.org_type = OrganizationType(name="Test Org Type", organization_setting=self.org_type_setting)
		self.org_type.save()

	def testOrganizationSetting_None(self):
		self.assertIsNone(self.organization.get_setting())

		self.organization.organization_setting = self.org_setting
		self.organization.save()
		self.org_setting.delete_flag = True
		self.org_setting.save()
		self.assertIsNone(self.organization.get_setting())

	def testOrganizationSetting_FromOrganization(self):
		self.organization.organization_setting = self.org_setting
		self.organization.save()
		self.org_setting.delete_flag = False
		self.org_setting.save()
		self.assertEqual(self.org_setting, self.organization.get_setting())

		self.organization.organization_type = self.org_type
		self.organization.save()
		setting = self.organization.get_setting()
		self.assertEqual(self.org_setting, setting)
		self.assertNotEqual(self.org_type_setting, setting)

	def testOrganizationSetting_FromOrganizationType(self):
		self.organization.organization_type = self.org_type
		self.organization.organization_setting = None
		self.organization.save()
		self.assertEqual(self.org_type_setting, self.organization.get_setting())

		self.org_setting.delete_flag = True
		self.org_setting.save()
		self.organization.organization_type = self.org_type
		self.organization.organization_setting = self.org_setting
		self.organization.save()
		setting = self.organization.get_setting()
		self.assertEqual(self.org_type_setting, setting)
		self.assertNotEqual(self.org_setting, setting)

	def tearDown(self):
		clean_db_datas()
예제 #16
0
파일: utils.py 프로젝트: DongHuaLu/mdcom
def create_org_type(org_setting=None):
	if not org_setting:
		org_setting = OrganizationSetting() 
		org_setting.save()
	type_name = "Test Org Type"
	organization_type = OrganizationType(name=type_name, organization_setting=org_setting)
	# force id for test - MySQL UT's don't re-use ids after cleanup 
	organization_type.id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
	# TODO: issue 2030, reserved id's is a hazardous approach, the UT's 
	# were working with SQLlite but not with MySQL, DB engines recycle
	# id's differently and we should not rely on reserved id fields.  This 
	# should be addressed in a separate Redmine as model changes may occur.
	organization_type.save()
	return organization_type
예제 #17
0
파일: base.py 프로젝트: DongHuaLu/mdcom
	def _add_practices(self):
		org_setting = OrganizationSetting(can_have_answering_service=True)
		org_setting.save()
		for pract in self.practice_data:
			practice = PracticeLocation.objects.create(
				practice_name=pract["practice_name"],
				practice_address1=pract["practice_address1"],
				practice_address2=pract["practice_address2"],
				practice_city=pract["practice_city"],
				practice_state=pract["practice_state"],
				practice_zip=pract["practice_zip"],
				mdcom_phone=pract["mdcom_phone"],
				practice_phone=pract["practice_phone"],
				time_zone=pract["time_zone"],
				practice_lat=pract["practice_lat"],
				practice_longit=pract["practice_longit"],
				organization_setting=org_setting)
			practice.save()
			self.practices.append(practice)
		self.callgroup1 = CallGroup(description="Team A", team="Team A", number_selection=2)
		self.callgroup1.save()
		self.callgroup2 = CallGroup(description="Team B", team="Team B", number_selection=3)
		self.callgroup2.save()
		self.callgroup3 = CallGroup(description="Team C", team="Team C", number_selection=4)
		self.callgroup3.save()
		self.callgroup4 = CallGroup(description="Team D", team="Team D", number_selection=5)
		self.callgroup4.save()
		p1 = self.practices[0]
		p1.call_group = self.callgroup1
		p1.save()
		p2 = self.practices[1]
		p2.call_groups.add(self.callgroup2)
		p2.save()
		p3 = self.practices[2]
		p3.call_groups.add(self.callgroup3)
		p3.call_groups.add(self.callgroup4)
		p3.save()
		self.specialty1 = Specialty()
		self.specialty1.name = 'Cardiology'
		self.specialty1.practice_location = self.practices[2]
		self.specialty1.number_selection = 3
		self.specialty1.save()
		self.specialty1.call_groups.add(self.callgroup3)
		self.specialty2 = Specialty()
		self.specialty2.name = 'ENT'
		self.specialty2.practice_location = self.practices[2]
		self.specialty2.number_selection = 4
		self.specialty2.save()
		self.specialty2.call_groups.add(self.callgroup4)
예제 #18
0
파일: utils.py 프로젝트: cnzhuran/mdcom
def create_org_type(org_setting=None):
    if not org_setting:
        org_setting = OrganizationSetting()
        org_setting.save()
    type_name = "Test Org Type"
    organization_type = OrganizationType(name=type_name,
                                         organization_setting=org_setting)
    # force id for test - MySQL UT's don't re-use ids after cleanup
    organization_type.id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
    # TODO: issue 2030, reserved id's is a hazardous approach, the UT's
    # were working with SQLlite but not with MySQL, DB engines recycle
    # id's differently and we should not rely on reserved id fields.  This
    # should be addressed in a separate Redmine as model changes may occur.
    organization_type.save()
    return organization_type
예제 #19
0
    def setUp(self):
        clean_db_datas()

        org_setting = OrganizationSetting()
        org_setting.save()
        org_type = OrganizationType(name="Test Org Type",
                                    organization_setting=org_setting,
                                    is_public=True)
        org_type.save()
        self.org = PracticeLocation(
            practice_name="Test1",
            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)
        self.org.organization_type = org_type
        self.org.save()

        for i in range(10):
            user_name = "".join(["Staff1_", str(i)])
            first_name = "".join(["Test1_", str(i)])
            user = create_user(user_name,
                               first_name,
                               'S',
                               'demo',
                               uklass=OfficeStaff)
            self.org_staff.append(user)

            # IntegrityError: column username is not unique
#			provider_name = "".join(["Pravider1_", str(i)])
#			pro = create_user(provider_name, 'Provider', 'P', 'demo', uklass=Provider)
#			self.org_providers.append(pro)

        self.staff = create_user("Staff2",
                                 'Test2',
                                 'S',
                                 'demo',
                                 uklass=OfficeStaff)
        self.staff.save()
        self.provider = create_user("Pravider2",
                                    'Provider',
                                    'P',
                                    'demo',
                                    uklass=Provider)
        self.provider.save()
예제 #20
0
	def test_which_orgs_contain_this_user_in_tab(self):
		org_ids = []
		for p in self.orgs:
			org_setting = OrganizationSetting(display_in_contact_list_tab=True)
			org_setting.save()
			p.organization_setting = org_setting
			p.save()
			self.staff.practices.add(p)
			org_ids.append(p.id)
		self.staff.save()

		orgs_contain = which_orgs_contain_this_user(self.staff.user.id, in_tab=True)
		orgs_contain_ids = [p.id for p in orgs_contain]
		self.assertEqual(len(org_ids), len(orgs_contain_ids))
		self.assertListEqual(org_ids, orgs_contain_ids)
		self.assertNotIn(self.org.id, orgs_contain_ids)
예제 #21
0
    def test_which_orgs_contain_this_user_in_tab(self):
        org_ids = []
        for p in self.orgs:
            org_setting = OrganizationSetting(display_in_contact_list_tab=True)
            org_setting.save()
            p.organization_setting = org_setting
            p.save()
            self.staff.practices.add(p)
            org_ids.append(p.id)
        self.staff.save()

        orgs_contain = which_orgs_contain_this_user(self.staff.user.id,
                                                    in_tab=True)
        orgs_contain_ids = [p.id for p in orgs_contain]
        self.assertEqual(len(org_ids), len(orgs_contain_ids))
        self.assertListEqual(org_ids, orgs_contain_ids)
        self.assertNotIn(self.org.id, orgs_contain_ids)
예제 #22
0
	def setUp(self):
		clean_db_datas()
		self.user = create_user(get_random_username(),'yang','peng','demo')
		org_setting = OrganizationSetting(display_in_contact_list_tab=True)
		org_setting.save()
		self.org_type = OrganizationType(name="Test Org Type", organization_setting=org_setting, is_public=True)
		self.org_type.save()
		self.org = create_organization()
		staff = OfficeStaff()
		staff.user = self.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.save()
		self.staff = staff

		self.org_members = []
		self.org_members = create_multiple_organizations(10)
예제 #23
0
    def setUp(self):
        clean_db_datas()

        OrganizationType.objects.all().delete()
        org_setting = OrganizationSetting()
        org_setting.save()
        self.org_type = OrganizationType(name="Test Org Type1",
                                         organization_setting=org_setting,
                                         is_public=True)
        # TODO: issue 2030, reserved id's is a hazardous approach, the UT's
        # were working with SQLlite but not with MySQL, DB engines recycle
        # id's differently and we should not rely on reserved id fields.  This
        # should be addressed in a separate Redmine as model changes may occur.
        self.org_type.id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
        self.org_type.save()

        self.organization = create_organization()
        self.organization = PracticeLocation(
            practice_name=get_random_username(),
            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)
        self.organization.save()

        self.admin = create_user('admin',
                                 'Morris',
                                 'Kelly',
                                 'demo',
                                 uklass=Administrator)
        staff = create_user('practicemgr1',
                            'Practice',
                            'Mgr',
                            'demo',
                            uklass=OfficeStaff)
        staff.practices.add(self.organization)
        staff.save()

        self.manager = Office_Manager(user=staff,
                                      practice=self.organization,
                                      manager_role=1)
        self.manager.save()
예제 #24
0
	def test_get_orgs_I_can_manage_user(self):
		user = create_user('yangpeng','yang','peng','demo')
		org_setting = OrganizationSetting()
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", \
				organization_setting=org_setting, is_public=True)
		org_type.save()
		staff = OfficeStaff()
		staff.user = user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = self.organization
		staff.save()
		staff.practices.add(self.organization)
		mgr = Office_Manager(user=staff, practice=self.organization, manager_role=2)
		mgr.save()
		get_orgs_I_can_manage(mgr.id,parent_id=self.parent_organization.id,\
				org_type_id=org_type.id,clear_no_type_org=True)
예제 #25
0
	def setUp(self):
		clean_db_datas()

		OrganizationType.objects.all().delete()
		org_setting = OrganizationSetting()
		org_setting.save()
		self.org_type = OrganizationType(name="Test Org Type1", organization_setting=org_setting, is_public=True)
		self.org_type.save()

		self.organization = create_organization()

		self.admin = create_user('admin', 'Morris', 'Kelly', 'demo', uklass=Administrator)
		staff = create_user('practicemgr1', 'Practice', 'Mgr', 'demo', uklass=OfficeStaff)
		staff.practices.add(self.organization)
		staff.save()

		self.manager = Office_Manager(user=staff, practice=self.organization, manager_role=1)
		self.manager.save()
예제 #26
0
파일: utils.py 프로젝트: cnzhuran/mdcom
def create_organization_not_member(org_type=None):
	org_setting = OrganizationSetting()
	org_setting.save()
	org_type = OrganizationType(name="Test Org Type", 
		organization_setting=org_setting, is_public=True)
	organization_not_member = PracticeLocation(
		practice_name="Test2",
		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)
	if org_type:
			organization_not_member.organization_type = org_type
	organization_not_member.save()
	return organization_not_member
예제 #27
0
    def setUpClass(cls):
        clean_db_datas()
        cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
        org_setting = OrganizationSetting()
        org_setting.save()
        org_type = OrganizationType(name="Test Org Type",
                                    organization_setting=org_setting,
                                    is_public=True)
        org_type.save()
        cls.org_type = org_type
        sub_types = create_multiple_organization_types(org_type)
        cls.sub_types = sub_types

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
            organization_type=org_type,
        )
        practice.save()
        practice1 = PracticeLocation(
            practice_name='test1',
            practice_longit='0.1',
            practice_lat='0.0',
            organization_type=org_type,
        )
        practice1.save()
        OrganizationRelationship.objects.create(organization=practice,
                                                parent=practice1,
                                                create_time=int(time.time()),
                                                billing_flag=True)
        cls.practice = practice
        cls.practice1 = practice1

        staff = OfficeStaff()
        staff.user = cls.user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.current_practice = practice
        staff.save()
        staff.practices.add(practice)

        mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
        mgr.save()
예제 #28
0
파일: utils.py 프로젝트: cnzhuran/mdcom
def create_multiple_organization_types(parent_type, num=10, is_public=True):
	sub_types = []
	OrganizationType.objects.all().delete()
	org_setting = OrganizationSetting()
	org_setting.save()
	for i in xrange(num):
		type_name = "".join(["Test Org Type2_", str(i)])
		_org_type = OrganizationType(name=type_name, 
			organization_setting=org_setting, is_public=is_public)
		_org_type.id = i + 1
		# TODO: issue 2030, reserved id's is a hazardous approach, the UT's 
		# were working with SQLlite but not with MySQL, DB engines recycle
		# id's differently and we should not rely on reserved id fields.  This 
		# should be addressed in a separate Redmine as model changes may occur.
		_org_type.save()
		sub_types.append(_org_type)
		OrganizationTypeSubs.objects.create(from_organizationtype=parent_type, 
			to_organizationtype=_org_type)
	return sub_types
예제 #29
0
    def setUp(self):
        clean_db_datas()
        self.user = create_user(get_random_username(), 'yang', 'peng', 'demo')
        org_setting = OrganizationSetting(display_in_contact_list_tab=True)
        org_setting.save()
        self.org_type = OrganizationType(name="Test Org Type",
                                         organization_setting=org_setting,
                                         is_public=True)
        self.org_type.save()
        self.org = create_organization()
        staff = OfficeStaff()
        staff.user = self.user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.save()
        self.staff = staff

        self.org_members = []
        self.org_members = create_multiple_organizations(10)
예제 #30
0
 def test_get_orgs_I_can_manage_user(self):
     user = create_user('yangpeng', 'yang', 'peng', 'demo')
     org_setting = OrganizationSetting()
     org_setting.save()
     org_type = OrganizationType(name="Test Org Type", \
       organization_setting=org_setting, is_public=True)
     org_type.save()
     staff = OfficeStaff()
     staff.user = user
     staff.office_lat = 0.0
     staff.office_longit = 0.0
     staff.current_practice = self.organization
     staff.save()
     staff.practices.add(self.organization)
     mgr = Office_Manager(user=staff,
                          practice=self.organization,
                          manager_role=2)
     mgr.save()
     get_orgs_I_can_manage(mgr.id,parent_id=self.parent_organization.id,\
       org_type_id=org_type.id,clear_no_type_org=True)
예제 #31
0
	def setUpClass(cls):
		clean_db_datas()
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
		cls.admin = create_user("sduper", "super", "duper", "demo", 
							"Ocean Avenue", "Carmel", "CA", "93921", uklass=Administrator)
		cls.admin.save()
		org_setting = OrganizationSetting(can_have_manager=True,\
						can_have_nurse=True,can_have_dietician=True)
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", \
						organization_setting=org_setting, is_public=True)
		org_type.save()
		cls.org_type = org_type
		cls.org_setting = org_setting
		
		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_setting =org_setting,
								organization_type = org_type)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_setting =org_setting,
								organization_type = org_type)
		practice1.save()
		cls.practice = practice
		cls.practice1 = practice1
		
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)
		cls.staff = staff
		
		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
예제 #32
0
    def setUp(self):
        clean_db_datas()

        org_setting = OrganizationSetting()
        org_setting.save()
        org_type = OrganizationType(name="Test Org Type",
                                    organization_setting=org_setting,
                                    is_public=True)
        org_type.save()
        self.org = create_organization()

        for i in range(10):
            user_name = "".join(["Staff1_", str(i)])
            first_name = "".join(["Test1_", str(i)])
            user = create_user(user_name, first_name, 'S', 'demo')
            self.staff = OfficeStaff()
            self.staff.user = user
            self.staff.office_lat = 0.0
            self.staff.office_longit = 0.0
            self.staff.save()
            self.org_staff.append(self.staff)

            # IntegrityError: column username is not unique


#			provider_name = "".join(["Pravider1_", str(i)])
#			pro = create_user(provider_name, 'Provider', 'P', 'demo', uklass=Provider)
#			self.org_providers.append(pro)
        self.user = create_user(get_random_username(), 'staff', 'S', 'demo')
        staff = OfficeStaff()
        staff.user = self.user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.save()
        self.staff = staff
        self.provider = create_user("Pravider2",
                                    'Provider',
                                    'P',
                                    'demo',
                                    uklass=Provider)
        self.provider.save()
예제 #33
0
	def setUp(self):
		clean_db_datas()
		org_setting = OrganizationSetting(can_have_physician=True)
		org_setting.save()
		self.org_setting = org_setting
		org_type = OrganizationType(name="Test Org Type", 
			organization_setting=org_setting, is_public=True)
		org_type.save()
		self.org_type = org_type

		practice = PracticeLocation(practice_name='test',
						practice_longit='0.1',
						practice_lat='0.0',
						organization_type=org_type,
						organization_setting=org_setting,)
		practice.save()
		self.practice = practice

		user = create_user('admin', 'Morris', 'Kelly', 'demo', uklass=Administrator)
		user.save()
		self.client.post('/login/', {'username': user.user.username, 'password': '******'})
예제 #34
0
    def test_get_practices_by_position(self):
        lat = 0.0
        longit = 0.0
        distance = None
        result = get_practices_by_position(lat, longit, distance)
        self.assertEqual(len(result), 0)

        lat = 12.1
        longit = 12.0
        distance = 2
        result = get_practices_by_position(lat, longit, distance)
        self.assertEqual(len(result), 0)

        try:
            org_type = OrganizationType.objects.get(
                pk=RESERVED_ORGANIZATION_TYPE_ID_PRACTICE)
        except OrganizationType.DoesNotExist:
            setting = OrganizationSetting()
            setting.save()
            org_type = OrganizationType(
                pk=RESERVED_ORGANIZATION_TYPE_ID_PRACTICE,
                organization_setting=setting)
            org_type.save()

        location = 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,
            organization_type=org_type)
        location.save()

        lat = 37
        longit = -122.0
        distance = None
        result = get_practices_by_position(lat, longit, distance)
        self.assertEqual(len(result), 1)
예제 #35
0
    def setUp(self):
        clean_db_datas()

        org_setting = OrganizationSetting()
        org_setting.save()
        org_type = OrganizationType(name="Test Org Type",
                                    organization_setting=org_setting,
                                    is_public=True)
        org_type.save()
        self.org = create_organization()

        user1 = create_user(get_random_username(), 'Test1', 'S', 'demo')
        staff1 = OfficeStaff()
        staff1.user = user1
        staff1.office_lat = 0.0
        staff1.office_longit = 0.0
        staff1.current_practice = self.org
        staff1.save()
        staff1.practices.add(self.org)
        self.manager = Office_Manager(user=staff1,
                                      practice=self.org,
                                      manager_role=1)

        user = create_user(get_random_username(), 'Test1', 'S', 'demo')
        staff = OfficeStaff()
        staff.user = user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.save()
        self.staff = staff

        self.provider = create_user("Pravider2",
                                    'Provider',
                                    'P',
                                    'demo',
                                    uklass=Provider)
        self.provider.save()
예제 #36
0
	def test_get_practices_by_position(self):
		lat = 0.0
		longit = 0.0
		distance = None
		result = get_practices_by_position(lat, longit, distance)
		self.assertEqual(len(result), 0)
		
		lat = 12.1
		longit = 12.0
		distance = 2
		result = get_practices_by_position(lat, longit, distance)
		self.assertEqual(len(result), 0)

		try:
			org_type = OrganizationType.objects.get(pk=RESERVED_ORGANIZATION_TYPE_ID_PRACTICE)
		except OrganizationType.DoesNotExist:
			setting= OrganizationSetting()
			setting.save()
			org_type = OrganizationType(pk=RESERVED_ORGANIZATION_TYPE_ID_PRACTICE, organization_setting=setting)
			org_type.save()

		location = 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,
			organization_type=org_type)
		location.save()
		
		lat = 37
		longit = -122.0
		distance = None
		result = get_practices_by_position(lat, longit, distance)
		self.assertEqual(len(result), 1)
예제 #37
0
	def setUpClass(cls):
		clean_db_datas()
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')

		org_setting = OrganizationSetting()
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", 
			organization_setting=org_setting, is_public=True)
		org_type.save()
		cls.org_type = org_type
		sub_types = create_multiple_organization_types(org_type)
		cls.sub_types = sub_types

		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_type = org_type)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_type = org_type)
		practice1.save()

		OrganizationRelationship.objects.create(organization=practice,\
				parent=practice1,create_time=int(time.time()),billing_flag=True)
		cls.practice = practice
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)

		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
예제 #38
0
파일: utils.py 프로젝트: cnzhuran/mdcom
def create_multiple_organizations(num=10, org_type=None):
	orgs = []
	if not org_type:
		org_setting = OrganizationSetting()
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type2", 
			organization_setting=org_setting, is_public=True)
		org_type.save()

	for i in xrange(num):
		practice_name = "".join(["Test1_", str(i)])
		_organization = PracticeLocation(
			practice_name=practice_name,
			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,
			organization_type=org_type)
		_organization.save()
		orgs.append(_organization)
	return orgs
예제 #39
0
    def setUpClass(cls):
        clean_db_datas()
        cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
        cls.provider = create_user("dholiday",
                                   "doc",
                                   "holiday",
                                   "demo",
                                   uklass=Provider)

        org_setting = OrganizationSetting(can_have_physician=True,
                                          can_have_nppa=True,
                                          can_have_medical_student=True)
        org_setting.save()
        cls.org_setting = org_setting
        org_type = OrganizationType(name="Test Org Type",
                                    organization_setting=org_setting,
                                    is_public=True)
        org_type.save()
        cls.org_type = org_type

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
            organization_type=org_type,
            organization_setting=org_setting,
        )
        practice.save()
        practice1 = PracticeLocation(
            practice_name='test1',
            practice_longit='0.1',
            practice_lat='0.0',
            organization_type=org_type,
            organization_setting=org_setting,
        )
        practice1.save()

        OrganizationRelationship.objects.create(organization=practice,
                                                parent=practice1,
                                                create_time=int(time.time()),
                                                billing_flag=True)

        cls.practice = practice
        staff = OfficeStaff()
        staff.user = cls.user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.current_practice = practice
        staff.save()
        staff.practices.add(practice)

        mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
        mgr.save()
        datadict = {
            'user_type': 1,
            'org_id': cls.practice.id,
            'username': get_random_username(),
            'first_name': 'yang',
            'last_name': 'peng',
            'mobile_phone': 9001111111,
            'gender': 'M',
            '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,
        }
        cls.datadict = datadict
예제 #40
0
파일: test_org.py 프로젝트: cnzhuran/mdcom
	def setUpClass(cls):
		from MHLogin.MHLOrganization.tests.utils import create_multiple_organization_types
		clean_db_datas()
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
		org_setting = OrganizationSetting(can_have_staff=True, 
			can_have_nurse=True, can_have_dietician=True)
		org_setting.save()

		org_type = OrganizationType(name="Test Org Type - old type", 
				organization_setting=org_setting, is_public=True)
		org_type.save()
		cls.org_type = org_type

		parent_org_type = OrganizationType(name="Test Org Type - parent type", organization_setting=org_setting, is_public=True)
		parent_org_type.save()
		cls.parent_org_type = parent_org_type

		sub_types = create_multiple_organization_types(parent_org_type)
		cls.sub_types = sub_types

		old_parent_practice = PracticeLocation(practice_name='old org parent',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_setting=org_setting,
								organization_type=parent_org_type,)
		old_parent_practice.save()
		OrganizationRelationship.objects.create(organization=old_parent_practice,
			parent=None, create_time=int(time.time()), billing_flag=True)
		cls.old_parent_practice = old_parent_practice

		practice = PracticeLocation(practice_name='test org',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_setting=org_setting,
								organization_type=org_type,)
		practice.save()

		OrganizationRelationship.objects.create(organization=practice,\
			parent=old_parent_practice, create_time=int(time.time()), billing_flag=True)

		new_parent_practice = PracticeLocation(practice_name='new org parent',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_setting=org_setting,
								organization_type=parent_org_type,)
		new_parent_practice.save()
		OrganizationRelationship.objects.create(organization=new_parent_practice,
			parent=None, create_time=int(time.time()), billing_flag=True)

		cls.new_parent_practice = new_parent_practice
		cls.practice = practice

		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)
		staff.practices.add(old_parent_practice)
		staff.practices.add(new_parent_practice)
		cls.staff = staff
		Office_Manager.objects.create(user=staff, practice=practice, manager_role=2)

		datadict = {
			'user_type':1,
			'org_id': practice.id,
			'username':get_random_username(),
			'first_name':'yang',
			'last_name':'peng',
			'mobile_phone':9001111111,
			'gender':'M',
			'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,
		}
		cls.datadict = datadict
예제 #41
0
	def setUpClass(cls):
		clean_db_datas()
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
		cls.provider = create_user("dholiday", "doc", "holiday", "demo", uklass=Provider)

		org_setting = OrganizationSetting(can_have_physician=True, can_have_nppa=True,
				can_have_medical_student=True)
		org_setting.save()
		cls.org_setting = org_setting
		org_type = OrganizationType(name="Test Org Type", 
				organization_setting=org_setting, is_public=True)
		org_type.save()
		cls.org_type = org_type

		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_type=org_type,
								organization_setting=org_setting,)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_type=org_type,
								organization_setting=org_setting,)
		practice1.save()

		OrganizationRelationship.objects.create(organization=practice,
			parent=practice1, create_time=int(time.time()), billing_flag=True)

		cls.practice = practice
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)

		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
		datadict = {
			'user_type':1,
			'org_id': cls.practice.id,
			'username':get_random_username(),
			'first_name':'yang',
			'last_name':'peng',
			'mobile_phone':9001111111,
			'gender':'M',
			'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,
		}
		cls.datadict = datadict