Ejemplo n.º 1
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,))
Ejemplo n.º 2
0
 def setUp(self):
     self.client_1, self.client_2 = ClientFactory.create_batch(2)
     manufacturer = ManufacturerFactory(image=ImageField(
         filename='biotronik.jpg'))
     product = ProductFactory(manufacturer=manufacturer)
     self.item_1 = ItemFactory(cost=randint(110, 150),
                               cost_type=UNIT_COST,
                               device=DeviceFactory(client=self.client_1,
                                                    product=product))
     self.item_2 = ItemFactory(cost=randint(210, 290),
                               cost_type=UNIT_COST,
                               device=DeviceFactory(client=self.client_1))
     self.item_3 = ItemFactory(cost=randint(400, 500),
                               device=DeviceFactory(client=self.client_2))
     self.item_4 = ItemFactory(cost=1000,
                               cost_type=UNIT_COST,
                               device=DeviceFactory(
                                   client=self.client_1,
                                   product=ProductFactory(
                                       manufacturer=manufacturer,
                                       category=product.category)))
     physician_role = RoleFactory(priority=RolePriority.PHYSICIAN.value)
     self.physician_1 = AccountFactory(client=self.client_1,
                                       role=physician_role)
     self.physician_2 = AccountFactory(client=self.client_2,
                                       role=physician_role,
                                       user=self.physician_1.user)
     self.physician_3 = AccountFactory(client=self.client_1,
                                       role=physician_role)
Ejemplo n.º 3
0
 def setUp(self):
     super().setUp()
     self.path = reverse('api:hospital:clients')
     self.client_1, self.client_2 = ClientFactory.create_batch(2)
     AccountFactory(user=self.user, client=self.client_1)
     AccountFactory(user=self.user, client=self.client_2)
     AccountFactory(client=self.client_2)
     AccountFactory.create_batch(2)
Ejemplo n.º 4
0
 def setUp(self):
     super().setUp()
     self.client = ClientFactory(name='Central Dental Hospital')
     self.physician = AccountFactory(
         user=UserFactory(email='*****@*****.**'),
         client=self.client).user
     self.admin = AccountFactory(
         user=UserFactory(email='*****@*****.**'),
         client=self.client,
         role=RoleFactory(priority=RolePriority.ADMIN.value)).user
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def test_form_invalid(self):
        client = ClientFactory()
        account = AccountFactory()
        form = RepCaseForm(data={'client': client.id, 'owners': [account.id]})
        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['__all__'],
                         [f'Invalid {account.role.name} {account.user.email} for {client.name}'])

        account_1, account_2, account_3 = AccountFactory.create_batch(3, client=client)
        form = RepCaseForm(data={'client': client.id,
                                 'owners': [account_1.id, account_3.id],
                                 'physician': account_2.id,
                                 'procedure_date': '2000-11-22',
                                 'status': NEW_CASE})
        self.assertTrue(form.is_valid())
    def setUp(self):
        doctor = RoleFactory(name='Physician', priority=1)
        hospital_admin = RoleFactory(name='Hospital Administrator',
                                     priority=10)
        self.client_1, self.client_2 = ClientFactory.create_batch(2)
        self.account_1 = AccountFactory(client=self.client_1, role=doctor)
        self.account_2 = AccountFactory(client=self.client_1,
                                        role=hospital_admin)
        self.account_3, self.account_4 = AccountFactory.create_batch(
            2, client=self.client_2, role=doctor)

        super(ClientAccountsListingAdminTestCase, self).setUp()
        self.log_in_master_admin()
        self.visit_reverse('admin:hospital_account_changelist')
        self.wait_for_element_contains_text('#content h1',
                                            'Select user account to change')
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    def setUp(self):
        super().setUp()
        self.client_1 = ClientFactory()
        self.today = datetime.utcnow().date()
        self.path = reverse('api:hospital:tracker:saving_by_date',
                            args=(self.client_1.id, '2017-08'))
        physician = AccountFactory(
            user=self.user,
            client=self.client_1,
            role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
        device_1 = DeviceFactory(client=self.client_1)
        self.item_1, self.item_2 = ItemFactory.create_batch(2,
                                                            device=device_1,
                                                            saving=200,
                                                            cost=1000)
        RepCaseFactory(client=self.client_1,
                       physician=physician,
                       items=[self.item_1, self.item_2],
                       procedure_date=date(2017, 8, 1))
        device_2 = DeviceFactory(client=self.client_1)
        self.item_3 = ItemFactory(device=device_2, saving=150, cost=1000)
        RepCaseFactory(client=self.client_1,
                       physician=physician,
                       items=[self.item_3],
                       procedure_date=date(2017, 7, 5))

        self.item_4 = ItemFactory(device=device_2, saving=200, cost=900)
        RepCaseFactory(client=self.client_1,
                       items=[self.item_4],
                       procedure_date=date(2015, 1, 1))
Ejemplo n.º 10
0
    def test_put_method_authenticated_user_valid_params(self):
        account1, account2 = AccountFactory.create_batch(2, user=self.user)
        client1 = account1.client
        client2 = account2.client

        response = self.authorized_client.put(
            self.path, {'default_client_id': client1.id})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertDictEqual(
            response.data, {
                'email': self.user.email,
                'name': self.user.name,
                'default_client': {
                    'id': client1.id,
                    'name': client1.name,
                    'image': None
                },
                'admin_client': None,
            })

        response = self.authorized_client.put(
            self.path, {'default_client_id': client2.id})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertDictEqual(
            response.data, {
                'email': self.user.email,
                'name': self.user.name,
                'default_client': {
                    'id': client2.id,
                    'name': client2.name,
                    'image': None
                },
                'admin_client': None,
            })
Ejemplo n.º 11
0
    def test_used_by_physician_queryset(self):
        physician_3 = AccountFactory(client=self.client_2,
                                     role=self.physician_2.role)
        self.assertEqual(
            Item.objects.used_by_physician(self.physician_1).count(), 0)
        self.assertEqual(
            Item.objects.used_by_physician(self.physician_2).count(), 0)
        self.assertEqual(
            Item.objects.used_by_physician(physician_3).count(), 0)

        RepCaseFactory(items=[self.item_1],
                       physician=self.physician_1,
                       client=self.client_1)
        RepCaseFactory(items=[self.item_2],
                       physician=self.physician_1,
                       client=self.client_1)
        RepCaseFactory(items=[self.item_3, self.item_4],
                       physician=self.physician_2,
                       client=self.client_2)
        RepCaseFactory(items=ItemFactory.create_batch(2),
                       physician=physician_3,
                       client=self.client_2)
        self.assertCountEqual(Item.objects.used_by_physician(self.physician_1),
                              [self.item_1, self.item_2])
        self.assertCountEqual(Item.objects.used_by_physician(self.physician_2),
                              [self.item_3, self.item_4])
Ejemplo n.º 12
0
 def setUp(self):
     super().setUp()
     self.client_1 = ClientFactory()
     self.today = datetime.utcnow().date()
     self.manufacturer_1, self.manufacturer_2 = ManufacturerFactory.create_batch(2)
     self.physician = AccountFactory(client=self.client_1, role=RoleFactory(priority=RolePriority.PHYSICIAN.value),
                                     user=self.user)
     self.path = reverse('api:hospital:device:marketshare', args=(self.client_1.id,))
Ejemplo n.º 13
0
    def test_post_method_with_valid_data(self):
        self.assertEqual(AuthToken.objects.count(), 0)

        admin_client = AccountFactory(
            user=self.user,
            role=RoleFactory(priority=RolePriority.ADMIN.value)).client
        response = self.client.post(self.path, {
            'email': '*****@*****.**',
            'password': '******'
        })
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
        self.assertEqual(response.data,
                         {'detail': 'Unauthorized physician access'})

        AccountFactory(user=self.user,
                       role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
        for token_count in range(1, 3):
            response = self.client.post(self.path, {
                'email': '*****@*****.**',
                'password': '******'
            })
            response_data = response.data

            self.assertEqual(response.status_code, status.HTTP_200_OK)
            token = response_data.pop('token')
            self.assertDictEqual(
                response_data, {
                    'user': {
                        'email': '*****@*****.**',
                        'name': 'Dr. Admin',
                        'default_client': None,
                        'admin_client': {
                            'id': admin_client.id,
                            'name': admin_client.name,
                            'image': None
                        }
                    }
                })
            self.assertIsNotNone(token)
            self.assertEqual(AuthToken.objects.count(), token_count)

            user, auth_token = TokenAuthentication().authenticate_credentials(
                token.encode())
            self.assertEqual(user, self.user)

        self.assertEqual(AuthToken.objects.filter(user=self.user).count(), 2)
Ejemplo n.º 14
0
    def test_physician_post_request_valid_data(self):
        account = AccountFactory(
            user=self.user,
            client=self.hospital,
            role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
        product = ProductFactory()
        questions = PreferenceFactory(
            questions=QuestionFactory.create_batch(3)).questions.all()
        data = {
            'product':
            product.id,
            'procedure_datetime':
            '2020-12-21 10:15:20',
            'cost_type':
            2,
            'discounts': [
                {
                    'name': 'CCO',
                    'value': 10,
                    'order': 1
                },
                {
                    'name': 'Repless',
                    'value': 20,
                    'order': 2
                },
            ],
            'preference_questions': [questions[1].id, questions[0].id]
        }
        self.assertEqual(Order.objects.count(), 0)

        response = self.authorized_client.post(self.path, data)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(Order.objects.count(), 1)
        self.assertCountEqual(response.data.pop('preference_questions'),
                              [questions[0].id, questions[1].id])
        self.assertDictEqual(
            response.data, {
                'product':
                product.id,
                'procedure_datetime':
                '2020-12-21T10:15:20Z',
                'cost_type':
                2,
                'discounts': [{
                    'name': 'CCO',
                    'value': 10,
                    'order': 1
                }, {
                    'name': 'Repless',
                    'value': 20,
                    'order': 2
                }],
                'physician':
                account.id,
                'status':
                'New'
            })
Ejemplo n.º 15
0
    def test_non_physician_post_request(self):
        response = self.authorized_client.post(self.path)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
        self.assertEqual(response.data, {'detail': 'Not found.'})

        AccountFactory(user=self.user,
                       client=self.hospital,
                       role=RoleFactory(priority=RolePriority.ADMIN.value))
        response = self.authorized_client.post(self.path)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
        self.assertEqual(response.data, {'detail': 'Not found.'})
Ejemplo n.º 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'))
Ejemplo n.º 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, [])
Ejemplo n.º 18
0
    def test_physician_without_any_order(self):
        client = AccountFactory(
            role=RoleFactory(priority=RolePriority.PHYSICIAN.value),
            user=self.user).client
        path = reverse('api:hospital:order:ordersummary', args=(client.id, ))

        response = self.authorized_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertDictEqual(response.data['physician'], {
            'id': self.user.id,
            'count': 0,
            'name': self.user.name
        })
Ejemplo n.º 19
0
 def setUp(self):
     super().setUp()
     self.client_1 = ClientFactory()
     self.product = ProductFactory()
     self.path = reverse('api:hospital:device:items', args=(self.client_1.id, self.product.id))
     AccountFactory(client=self.client_1, user=self.user)
     ItemFactory.create_batch(2, device=DeviceFactory(product=self.product))
     ItemFactory(device=DeviceFactory(client=self.client_1))
     device = DeviceFactory(client=self.client_1, product=self.product)
     self.item_1, self.item_2 = ItemFactory.create_batch(2, device=device, is_used=False,
                                                         purchase_type=BULK_PURCHASE)
     ItemFactory(device=device, purchase_type=CONSIGNMENT_PURCHASE, is_used=False)
     ItemFactory(device=device, purchase_type=BULK_PURCHASE, is_used=True)
    def setUp(self):
        super().setUp()
        self.log_in_master_admin()
        self.visit_reverse('admin:tracker_repcase_add')
        self.wait_for_element_contains_text('#content h1', 'Add rep case')
        physician = RoleFactory(name='Physician',
                                priority=RolePriority.PHYSICIAN.value)
        admin = RoleFactory(name='Admin', priority=RolePriority.ADMIN.value)
        client = ClientFactory(name='NSINC')
        AccountFactory(user=UserFactory(email='*****@*****.**'),
                       role=physician,
                       client=client)
        AccountFactory(user=UserFactory(email='*****@*****.**'),
                       role=admin,
                       client=client)

        client = ClientFactory(name='EA')
        AccountFactory(user=UserFactory(email='*****@*****.**'),
                       role=admin,
                       client=client)

        ClientFactory(name='UVMC')
Ejemplo n.º 21
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))
Ejemplo n.º 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.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, ))
Ejemplo n.º 23
0
    def test_view_order_of_other_client(self):
        client = ClientFactory()
        path = reverse('api:hospital:order:ordersummary_by_category',
                       args=(client.id, self.category_1.id))

        response = self.authorized_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
        self.assertDictEqual(response.data,
                             {'detail': 'Unauthorized physician access'})

        AccountFactory(client=client,
                       user=self.user,
                       role=RoleFactory(priority=RolePriority.ADMIN.value))
        response = self.authorized_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
        self.assertDictEqual(response.data,
                             {'detail': 'Unauthorized physician access'})
Ejemplo n.º 24
0
 def test_physician_post_request_invalid_data(self):
     AccountFactory(user=self.user,
                    client=self.hospital,
                    role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
     response = self.authorized_client.post(self.path)
     self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
     self.assertDictEqual(
         response.data, {
             'product': ['This field is required.'],
             'procedure_datetime': ['This field is required.'],
             'preference_questions': ['This field is required.']
         })
     data = {
         'product':
         1,
         'procedure_datetime':
         '10:20:30 21-12-2020',
         'cost_type':
         3,
         'discounts': [
             {
                 'name': 'CCO',
                 'value': 10,
                 'order': 1
             },
             {
                 'name': 'Repless',
                 'value': 20,
                 'order': 2
             },
         ],
         'preference_questions': [10]
     }
     response = self.authorized_client.post(self.path, data)
     self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
     self.assertDictEqual(
         response.data, {
             'product': ['Invalid pk "1" - object does not exist.'],
             'procedure_datetime': [
                 'Datetime has wrong format. Use one of these formats instead: '
                 'YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].'
             ],
             'cost_type': ['"3" is not a valid choice.'],
             'preference_questions':
             ['Invalid pk "10" - object does not exist.']
         })
Ejemplo n.º 25
0
 def setUp(self):
     super().setUp()
     self.account = AccountFactory(
         user=self.user,
         role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
     self.product = ProductFactory()
     preference = PreferenceFactory(
         client=self.account.client,
         questions=QuestionFactory.create_batch(3))
     self.question_1, self.question_2, self.question_3 = preference.questions.all(
     )
     OrderFactory.create_batch(2,
                               physician=self.account,
                               product=self.product,
                               preference_questions=(self.question_1,
                                                     self.question_2))
     OrderFactory.create_batch(3,
                               physician=self.account,
                               product=self.product,
                               preference_questions=(self.question_2,
                                                     self.question_3))
     self.path = reverse('api:hospital:order:order_preferences',
                         args=(self.account.client.id, self.product.id))
Ejemplo n.º 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, ))
Ejemplo n.º 27
0
 def test_account_to_string(self):
     account = AccountFactory(user=UserFactory(email='*****@*****.**'), role=RoleFactory(name='admin'))
     self.assertEqual(str(account), 'admin [email protected]')
    def setUp(self):
        super().setUp()
        self.log_in_master_admin()

        self.client = ClientFactory(name='NSINC')
        self.product_1 = ProductFactory(
            name='Accolade VR',
            manufacturer=ManufacturerFactory(short_name='MDT'))
        self.product_2 = ProductFactory(
            name='Evera MRI XT',
            manufacturer=ManufacturerFactory(short_name='BIO'))
        ClientPriceFactory(client=self.client,
                           product=self.product_1,
                           system_cost=100,
                           discounts=[
                               DiscountFactory(name='CCO',
                                               cost_type=SYSTEM_COST,
                                               discount_type=PERCENT_DISCOUNT,
                                               percent=20,
                                               order=2,
                                               apply_type=ON_DOCTOR_ORDER),
                               DiscountFactory(name='Repless',
                                               cost_type=SYSTEM_COST,
                                               discount_type=VALUE_DISCOUNT,
                                               value=20,
                                               order=1,
                                               apply_type=ON_DOCTOR_ORDER),
                           ])

        bulk_discount = DiscountFactory(name='Bulk',
                                        cost_type=UNIT_COST,
                                        discount_type=VALUE_DISCOUNT,
                                        value=50,
                                        order=1,
                                        apply_type=PRE_DOCTOR_ORDER)
        ClientPriceFactory(client=self.client,
                           product=self.product_2,
                           unit_cost=200,
                           discounts=[
                               DiscountFactory(name='Repless',
                                               cost_type=UNIT_COST,
                                               percent=10,
                                               order=1,
                                               apply_type=ON_DOCTOR_ORDER),
                               bulk_discount
                           ])
        device = Device.objects.get(client=self.client, product=self.product_2)
        item = ItemFactory(device=device,
                           is_used=False,
                           serial_number='SER1234',
                           discounts=[bulk_discount],
                           cost_type=UNIT_COST,
                           purchased_date=date(2018, 1, 1))
        self.assertEqual(item.cost, 150)

        physician = AccountFactory(
            role=RoleFactory(priority=RolePriority.PHYSICIAN.value),
            client=self.client)
        self.rep_case = RepCaseFactory(client=self.client,
                                       owners=[physician],
                                       physician=physician,
                                       procedure_date=date(2018, 9, 10))
        self.visit_reverse('admin:tracker_repcase_change', self.rep_case.id)
        self.wait_for_element_contains_text('#content h1', 'Change rep case')
Ejemplo n.º 29
0
 def setUp(self):
     super().setUp()
     self.hospital = ClientFactory()
     self.account_1, self.account_2 = AccountFactory.create_batch(2, client=self.hospital)
     AccountFactory()
     self.path = reverse('api:staff:accounts', args=(self.hospital.id,))