Example #1
0
    def test_rebatable_items(self):
        for model_name in ['product', 'category', 'specialty']:
            self.assertCountEqual(
                self.manufacturer.rebatable_items(model_name), [])

        specialty_1, specialty_2 = SpecialtyFactory.create_batch(2)
        category_1 = CategoryFactory(specialty=specialty_1)
        category_2, category_3 = CategoryFactory.create_batch(
            2, specialty=specialty_2)
        product_1 = ProductFactory(category=category_1,
                                   manufacturer=self.manufacturer)
        product_2 = ProductFactory(category=category_2,
                                   manufacturer=self.manufacturer)
        product_3 = ProductFactory(category=category_3,
                                   manufacturer=self.manufacturer)
        product_4 = ProductFactory(category=category_1,
                                   manufacturer=self.manufacturer)
        ProductFactory(category=category_3)

        self.assertCountEqual(self.manufacturer.rebatable_items('specialty'),
                              [specialty_1, specialty_2])
        self.assertCountEqual(self.manufacturer.rebatable_items('category'),
                              [category_1, category_2, category_3])
        self.assertCountEqual(self.manufacturer.rebatable_items('product'),
                              [product_1, product_2, product_3, product_4])
        self.assertCountEqual(
            self.manufacturer.rebatable_items('manufacturer'), [])
Example #2
0
    def setUp(self):
        super(ProductAdminTestCase, self).setUp()
        self.log_in_master_admin()
        self.specialty = SpecialtyFactory(name='Cardiac Rhythm Management')
        CategoryFactory.create_batch(2, specialty=self.specialty)

        self.product_1, self.product_2 = ProductFactory.create_batch(2, model_number='1456Q-86')
        ProductFactory.create_batch(3)
Example #3
0
    def test_get_all_parent_categories(self):
        category_1 = CategoryFactory()
        category_2 = CategoryFactory(parent=category_1)
        category_3 = CategoryFactory(parent=category_2)
        category_4 = CategoryFactory(parent=category_1)
        category_5 = CategoryFactory(parent=category_4)

        self.assertCountEqual(
            Category.get_all_parent_categories([category_3.id, category_5.id]),
            [category_1, category_2, category_4])
Example #4
0
 def setUp(self):
     super().setUp()
     self.log_in_master_admin()
     biotronic = ManufacturerFactory(name='Biotronic')
     medtronik = ManufacturerFactory(name='Medtronik')
     ClientFactory(name='Children Hospital')
     ClientFactory(name='Central hospital')
     category = CategoryFactory(name='Balloons', specialty=SpecialtyFactory(name='Accessories'))
     ProductFactory(name='Entrisa', manufacturer=medtronik,
                    category=CategoryFactory(name='DDD pacemaker', specialty=SpecialtyFactory(name='CRD')))
     ProductFactory(name='Apex', manufacturer=medtronik, category=category)
     ProductFactory(name='NC Quantum', manufacturer=biotronic, category=category)
Example #5
0
    def test_devices_by_specialties(self):
        specialty1, specialty2 = SpecialtyFactory.create_batch(2)
        category1 = CategoryFactory(specialty=specialty1)
        category2, category3 = CategoryFactory.create_batch(2, specialty=specialty2)
        product1 = DeviceFactory(client=self.client, product=ProductFactory(name='Device1', category=category1)).product
        product2 = DeviceFactory(client=self.client, product=ProductFactory(name='Device2', category=category2)).product
        product3 = DeviceFactory(client=self.client, product=ProductFactory(name='Device3', category=category3)).product

        self.assertDictEqual(self.client.devices_by_specialties(), {
            specialty1.id: {'name': specialty1.name, 'products': [(product1.id, product1.name)]},
            specialty2.id: {'name': specialty2.name, 'products': [(product2.id, product2.name),
                                                                  (product3.id, product3.name)]}
        })
Example #6
0
 def setUp(self):
     super().setUp()
     self.log_in_master_admin()
     self.client = ClientFactory(name='EA')
     specialty_1 = SpecialtyFactory(name='Structure Heart')
     specialty_2 = SpecialtyFactory(name='Orthopedic')
     CategoryFactory(name='DDD Pacemakers', specialty=specialty_1)
     CategoryFactory(name='VVI ICD', specialty=specialty_2)
     QuestionFactory(name='Longevity')
     QuestionFactory(name='Remote support')
     self.visit_reverse('admin:order_preference_add')
     self.wait_for_element_contains_text('.model-preference.change-form',
                                         'Add preference')
Example #7
0
    def test_get_method_authenticated_user_return_list_categories(self):
        response = self.authorized_client.get(self.path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, [])

        self.account_1.specialties.add(self.category_1.specialty)
        response = self.authorized_client.get(self.path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, [
            {'id': self.category_1.id, 'name': self.category_1.name, 'image': None, 'parent_id': None},
        ])

        self.account_1.specialties.add(self.category_2.specialty)
        response = self.authorized_client.get(self.path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertCountEqual(response.data, [
            {'id': self.category_1.id, 'name': self.category_1.name, 'image': None, 'parent_id': None},
            {'id': self.category_2.id, 'name': self.category_2.name, 'image': None, 'parent_id': None}
        ])

        path = reverse('api:hospital:device:categories', args=(self.client_2.id,))
        response = self.authorized_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, [])

        self.account_2.specialties.set([self.category_1.specialty, self.category_2.specialty])
        parent_category = CategoryFactory()
        self.category_1.parent = parent_category
        self.category_1.save()
        response = self.authorized_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertCountEqual(response.data, [
            {'id': self.category_1.id, 'name': self.category_1.name, 'image': None, 'parent_id': parent_category.id},
            {'id': parent_category.id, 'name': parent_category.name, 'image': None, 'parent_id': None},
        ])
Example #8
0
 def setUp(self):
     super().setUp()
     client = ClientFactory(name='UVMC')
     specialty = SpecialtyFactory(name='CDM')
     category = CategoryFactory(name='Pacemaker', specialty=specialty)
     PreferenceFactory(name='Default for all products',
                       client=None,
                       content_type=None,
                       object_id=None,
                       questions=[QuestionFactory(name='Longevity')])
     PreferenceFactory(name='Preferences for client',
                       client=client,
                       content_type=None,
                       object_id=None,
                       questions=[QuestionFactory(name='Size/shape')])
     PreferenceFactory(name='Preferences for client:specialty',
                       client=client,
                       object_id=specialty.id,
                       content_type=ContentType.objects.get(
                           app_label='device', model='specialty'),
                       questions=[QuestionFactory(name='Research')])
     PreferenceFactory(name='Preferences for client:category',
                       client=client,
                       object_id=category.id,
                       content_type=ContentType.objects.get(
                           app_label='device', model='category'),
                       questions=[QuestionFactory(name='cost')])
     self.log_in_master_admin()
     self.visit_reverse('admin:order_preference_changelist')
     self.wait_for_element_contains_text('.model-preference #content h1',
                                         'Select preference to change')
Example #9
0
 def _create_product_for_client(self, product, category, specialty, client):
     DeviceFactory(
         client=client,
         product=ProductFactory(
             name=product,
             category=CategoryFactory(name=category, specialty=specialty)
         ))
Example #10
0
    def test_session_authorized_admin_user(self):
        response = self.authorized_admin_client.get(self.path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, [])

        product_1, product_2 = ProductFactory.create_batch(2, manufacturer=self.manufacturer)
        product_3 = ProductFactory(category=product_1.category, manufacturer=self.manufacturer)
        ProductFactory(category=CategoryFactory(specialty=product_2.category.specialty))
        response = self.authorized_admin_client.get(self.path)
        self.assertCountEqual(response.data, [
            {'id': product_1.id, 'name': product_1.name},
            {'id': product_2.id, 'name': product_2.name},
            {'id': product_3.id, 'name': product_3.name},
        ])

        path = reverse('api:staff:rebatable_items', args=(self.manufacturer.id, 'category'))
        self.assertEqual(path, f'/api/staff/manufacturers/{self.manufacturer.id}/category')
        response = self.authorized_admin_client.get(path)
        self.assertCountEqual(response.data, [
            {'id': product_1.category.id, 'name': product_1.category.name},
            {'id': product_2.category.id, 'name': product_2.category.name},
        ])

        path = reverse('api:staff:rebatable_items', args=(self.manufacturer.id, 'specialty'))
        self.assertEqual(path, f'/api/staff/manufacturers/{self.manufacturer.id}/specialty')
        response = self.authorized_admin_client.get(path)
        self.assertCountEqual(response.data, [
            {'id': product_1.category.specialty.id, 'name': product_1.category.specialty.name},
            {'id': product_2.category.specialty.id, 'name': product_2.category.specialty.name},
        ])

        path = f'/api/staff/manufacturers/{self.manufacturer.id}/manufacturer'
        response = self.authorized_admin_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Example #11
0
 def setUp(self):
     super().setUp()
     self.specialty = SpecialtyFactory()
     self.category_1, self.category_2 = CategoryFactory.create_batch(2, specialty=self.specialty)
     self.log_in_master_admin()
     self.visit_reverse('admin:device_category_add')
     self.wait_for_element_contains_text('.model-category.change-form #content h1', 'Add category')
Example #12
0
    def setUp(self):
        super().setUp()
        self.category = CategoryFactory()
        self.client_1 = ClientFactory()
        AccountFactory.create(user=self.user, client=self.client_1)
        self.product_1, self.product_2 = ProductFactory.create_batch(2, category=self.category)
        self.feature_1 = FeatureFactory(name='Wireless', product=self.product_2,
                                        shared_image=SharedImageFactory(image=ImageField(filename='wireless.jpg')))
        self.feature_2, self.feature_3 = FeatureFactory.create_batch(2, product=self.product_2)
        price_1 = ClientPriceFactory(client=self.client_1, product=self.product_1, unit_cost=200, system_cost=300)
        price_2 = ClientPriceFactory(client=self.client_1, product=self.product_2, unit_cost=250, system_cost=300)
        ClientPriceFactory(client=self.client_1, unit_cost=250, system_cost=300,
                           product=ProductFactory(enabled=False),)
        self.discount_1 = DiscountFactory(
            client_price=price_1, discount_type=VALUE_DISCOUNT, value=50, name='CCO', order=1, percent=0,
            apply_type=ON_DOCTOR_ORDER, cost_type=UNIT_COST,
            shared_image=SharedImageFactory(image=ImageField(filename='CCO.png'))
        )
        self.discount_2 = DiscountFactory(
            client_price=price_2, discount_type=PERCENT_DISCOUNT, percent=10, cost_type=SYSTEM_COST, order=2,
            apply_type=ON_DOCTOR_ORDER, name='Repless',
            shared_image=SharedImageFactory(image=ImageField(filename='repless.png'))
        )
        self.discount_3 = DiscountFactory(
            client_price=price_1, discount_type=PERCENT_DISCOUNT, value=0, name='Bulk', order=2, percent=15,
            apply_type=PRE_DOCTOR_ORDER, cost_type=UNIT_COST, shared_image=None)
        device = self.client_1.device_set.get(product=self.product_1)
        ItemFactory(device=device, discounts=[self.discount_3], purchase_type=BULK_PURCHASE, is_used=False,
                    cost_type=UNIT_COST)

        self.path = reverse('api:hospital:device:products', args=(self.client_1.id, self.category.id,))
Example #13
0
 def setUp(self):
     super().setUp()
     self.client_1 = ClientFactory()
     AccountFactory(client=self.client_1,
                    user=self.user,
                    role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
     self.category = CategoryFactory()
     self.path = reverse('api:hospital:tracker:app:purchase_price',
                         args=(self.client_1.id, self.category.id, 'entry',
                               'unit_cost'))
     PurchasePriceFactory(category=self.category,
                          client=self.client_1,
                          cost_type=UNIT_COST,
                          level=ProductLevel.ENTRY.value,
                          year=datetime.utcnow().year,
                          min=1000,
                          max=1200,
                          avg=1100)
     PurchasePriceFactory(category=self.category,
                          client=self.client_1,
                          cost_type=SYSTEM_COST,
                          level=ProductLevel.ADVANCED.value,
                          year=datetime.utcnow().year,
                          min=1200,
                          max=1400,
                          avg=1300)
Example #14
0
 def setUp(self):
     super().setUp()
     self.log_in_master_admin()
     self.specialty = SpecialtyFactory(name='Cardiac Rhythm Management')
     self.client = ClientFactory()
     category = CategoryFactory(specialty=self.specialty)
     product = ProductFactory(category=category)
     DeviceFactory(client=self.client)
     ClientPriceFactory(client=self.client, product=product)
Example #15
0
    def test_show_list_of_categories(self):
        self.log_in_master_admin()
        self.specialty, specialty = SpecialtyFactory.create_batch(2)
        self.category = CategoryFactory(name='Total Knee System', specialty=self.specialty)
        CategoryFactory.create_batch(2, specialty=specialty)
        ProductFactory.create_batch(3, category=self.category)

        self.visit_reverse('admin:device_specialty_changelist')
        self.wait_for_element_contains_text('#content h1', 'Select specialty to change')
        self.assert_elements_count('#result_list tbody tr', count=2)

        self.find_link(self.specialty.name).click()
        self.wait_for_element_contains_text('#content h1', 'Select category to change')
        self.assert_elements_count('#result_list tbody tr', count=1)
        self.wait_for_element_contains_text('#result_list tbody tr', 'Total Knee System')

        self.find_link(self.category.name).click()
        self.wait_for_element_contains_text('#content h1', 'Select product to change')
        self.assert_elements_count('#result_list tbody tr', count=3)
Example #16
0
 def setUp(self):
     super().setUp()
     self.client_1 = ClientFactory()
     self.category = CategoryFactory()
     self.physician = AccountFactory(
         client=self.client_1,
         user=self.user,
         role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
     self.path = reverse('api:hospital:tracker:app:physician_app',
                         args=(self.client_1.id, self.category.id, 'entry',
                               'unit_cost'))
Example #17
0
    def test_physician_without_any_order(self):
        client = self.account.client
        category = CategoryFactory()
        OrderFactory(physician=AccountFactory(client=client),
                     product=ProductFactory(category=category))
        path = reverse('api:hospital:order:ordersummary_by_category',
                       args=(client.id, category.id))

        response = self.authorized_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, [])
Example #18
0
    def test_remove_invalid_category_features(self):
        category_features = CategoryFeatureFactory.create_batch(
            2, category=self.product.category)
        for category_feature in category_features:
            FeatureFactory(product=self.product, name=category_feature.name)
        FeatureFactory(product=self.product)
        self.assertEqual(Feature.objects.count(), 3)
        self.assertEqual(CategoryFeature.objects.count(), 3)

        self.product.category = CategoryFactory()
        self.product.remove_invalid_category_features()
        self.assertEqual(Feature.objects.count(), 0)
Example #19
0
 def test_get_all_parent_categories_with_circling_loop(self):
     category_1 = CategoryFactory()
     category_2 = CategoryFactory(parent=category_1)
     category_1.parent = category_2
     category_1.save()
     parent_categories = Category.get_all_parent_categories([category_2.id])
     self.assertCountEqual(parent_categories, [category_1, category_2])
Example #20
0
 def setUp(self):
     super().setUp()
     self.category_1, self.category_2 = CategoryFactory.create_batch(2)
     self.client_1, self.client_2 = ClientFactory.create_batch(2)
     self.user.default_client = self.client_1
     self.user.save()
     self.path = reverse('api:hospital:device:categories', args=(self.client_1.id,))
     self.account_1 = AccountFactory.create(user=self.user, client=self.client_1)
     self.account_2 = AccountFactory.create(user=self.user, client=self.client_2)
     ClientPriceFactory(client=self.client_1, product=ProductFactory(category=self.category_1))
     ClientPriceFactory(client=self.client_1, product=ProductFactory(category=self.category_2))
     ClientPriceFactory(client=self.client_2, product=ProductFactory(category=self.category_1))
     ClientPriceFactory.create_batch(3)
Example #21
0
 def test_to_string(self):
     self.assertEqual(
         str(
             RebatableItemFactory(content_object=ProductFactory(
                 name='Entrosa'))), 'product: Entrosa')
     self.assertEqual(
         str(
             RebatableItemFactory(content_object=CategoryFactory(
                 name='CRT-D'))), 'category: CRT-D')
     self.assertEqual(
         str(
             RebatableItemFactory(content_object=SpecialtyFactory(
                 name='IH'))), 'specialty: IH')
Example #22
0
    def setUp(self):
        super().setUp()
        specialty = SpecialtyFactory()
        self.account = AccountFactory.create(
            role=RoleFactory(priority=RolePriority.PHYSICIAN.value),
            user=self.user,
            specialties=(specialty, ))

        self.category_1 = CategoryFactory(specialty=specialty)
        self.category_2 = CategoryFactory(specialty=specialty)
        self.manufacturer_1 = ManufacturerFactory(image=ImageField(
            filename='Abbott.jpg'))
        self.manufacturer_2 = ManufacturerFactory(image=ImageField(
            filename='Simon.jpg'))
        self.product_1 = ProductFactory(category=self.category_1,
                                        manufacturer=self.manufacturer_1)
        self.product_2 = ProductFactory(category=self.category_2,
                                        manufacturer=self.manufacturer_2)
        self.product_3 = ProductFactory(category=self.category_1,
                                        manufacturer=self.manufacturer_2)

        faker = Faker()
        self.product_1_orders = faker.random_int(min=1, max=5)
        self.category_2_orders = faker.random_int(min=1, max=4)
        self.other_orders = faker.random_int(min=1, max=3)
        self.total_num_orders = self.product_1_orders + self.category_2_orders + self.other_orders
        OrderFactory.create_batch(self.product_1_orders,
                                  physician=self.account,
                                  product=self.product_1)
        OrderFactory.create_batch(self.category_2_orders,
                                  physician=self.account,
                                  product=self.product_2)
        OrderFactory.create_batch(
            self.other_orders,
            physician=AccountFactory(client=self.account.client),
            product=self.product_3)
        self.path = reverse('api:hospital:order:ordersummary_by_category',
                            args=(self.account.client.id, self.category_1.id))
Example #23
0
 def setUp(self):
     self.rebate = RebateFactory(name='Q3 bulk rebate',
                                 start_date=date(2018, 7, 1),
                                 end_date=date(2018, 9, 30))
     self.category = CategoryFactory()
     self.product_1, self.product_2 = ProductFactory.create_batch(
         2, category=self.category, manufacturer=self.rebate.manufacturer)
     self.rebate_item_1 = RebatableItemFactory(
         content_object=self.product_1,
         rebate=self.rebate,
         item_type=ELIGIBLE_ITEM)
     self.rebate_item_2 = RebatableItemFactory(content_object=self.category,
                                               rebate=self.rebate,
                                               item_type=REBATED_ITEM)
Example #24
0
    def setUp(self):
        super().setUp()
        specialty = SpecialtyFactory()
        self.account = AccountFactory.create(
            role=RoleFactory(priority=RolePriority.PHYSICIAN.value),
            user=self.user,
            specialties=(specialty, ))
        self.account_foo = AccountFactory.create(user=self.account.user,
                                                 specialties=(specialty, ))

        self.category_1 = CategoryFactory(specialty=specialty)
        self.category_2 = CategoryFactory(specialty=specialty)

        faker = Faker()
        self.category_1_orders = faker.random_int(min=1, max=20)
        self.category_2_orders = faker.random_int(min=1, max=20)
        self.other_orders = faker.random_int(min=1, max=20)
        self.total_num_orders = self.category_1_orders + self.category_2_orders + self.other_orders
        OrderFactory.create_batch(
            self.category_1_orders,
            physician=self.account,
            product=ProductFactory(category=self.category_1))
        OrderFactory.create_batch(
            self.category_2_orders,
            physician=self.account,
            product=ProductFactory(category=self.category_2))
        OrderFactory.create_batch(
            self.other_orders,
            physician=AccountFactory(client=self.account.client),
            product=ProductFactory(category=self.category_2))
        OrderFactory.create_batch(
            3,
            physician=self.account_foo,
            product=ProductFactory(category=self.category_1))

        self.path = reverse('api:hospital:order:ordersummary',
                            args=(self.account.client.id, ))
Example #25
0
    def test_product_ids(self):
        specialty = SpecialtyFactory()
        category_1, category_2 = CategoryFactory.create_batch(
            2, specialty=specialty)
        product_1, product_2 = ProductFactory.create_batch(2,
                                                           category=category_1)
        product_3, product_4 = ProductFactory.create_batch(2,
                                                           category=category_2)

        self.assertCountEqual(
            RebatableItemFactory(content_object=product_1).product_ids,
            [product_1.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=category_1).product_ids,
            [product_1.id, product_2.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=category_2).product_ids,
            [product_3.id, product_4.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=specialty).product_ids,
            [product_1.id, product_2.id, product_3.id, product_4.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=ClientFactory()).product_ids,
            [])
Example #26
0
 def setUp(self):
     super().setUp()
     self.client_1 = ClientFactory()
     physician = AccountFactory(
         client=self.client_1,
         user=self.user,
         role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
     self.category_1, self.category_2, self.category_3 = CategoryFactory.create_batch(
         3)
     device_1 = DeviceFactory(
         client=self.client_1,
         product=ProductFactory(category=self.category_1))
     device_2 = DeviceFactory(
         client=self.client_1,
         product=ProductFactory(category=self.category_2))
     device_3 = DeviceFactory(
         client=self.client_1,
         product=ProductFactory(category=self.category_3))
     rep_case = RepCaseFactory(client=self.client_1, physician=physician)
     ItemFactory(device=device_1, rep_case=rep_case, is_used=True)
     ItemFactory(device=device_2, rep_case=rep_case, is_used=True)
     ItemFactory(device=device_3, rep_case=RepCaseFactory(), is_used=True)
     self.path = reverse('api:hospital:tracker:app:categories',
                         args=(self.client_1.id, ))
Example #27
0
 def add_specialty_with_categories(self, name, categories):
     specialty = SpecialtyFactory(name=name)
     for category in categories:
         CategoryFactory(name=category, specialty=specialty)
Example #28
0
 def setUp(self):
     self.purchase_price = PurchasePriceFactory(category=CategoryFactory(name='TAVR'),
                                                client=ClientFactory(name='EA'),
                                                avg=Decimal(1000),
                                                level=ProductLevel.ENTRY.value,
                                                year=2018)
Example #29
0
 def setUp(self):
     self.client = ClientFactory(name='UVMCdemo')
     specialty = SpecialtyFactory(name='Cardiac Rhythm Management')
     self.category = CategoryFactory(name='DDD Pacemakers',
                                     specialty=specialty)
Example #30
0
 def setUp(self):
     self.specialty = SpecialtyFactory(name='Structural Heart')
     self.product = ProductFactory(category=CategoryFactory(
         specialty=self.specialty))