示例#1
0
    def test_form_other_volunteer_options(self):
        """WorkupForm offers only non-attendings for 'other volunteers'"""

        form = WorkupForm()
        user_pks = [u.pk for u in self.users]
        other_vol_options = [c[0] for c in form['other_volunteer'].field.choices]

        # check that any user can be the other volunteer
        assert set(user_pks) == set(other_vol_options)
        assert len(user_pks) == len(other_vol_options)

        # check that error is thrown if one of the other volunteers
        # is the attending
        attending = build_user([user_factories.AttendingGroupFactory])
        non_attending = build_user()

        form_data = wu_dict()
        form_data['attending'] = attending
        form_data['other_volunteer'] = [non_attending, attending]
        form = WorkupForm(data=form_data)
        assert form['other_volunteer'].errors

        # and that no error is thrown if they are different
        form_data['other_volunteer'] = [non_attending]
        form = WorkupForm(data=form_data)
        assert not form['other_volunteer'].errors
示例#2
0
    def test_pending_note_submit(self):

        # pull standard workup data, but delete required field
        wu_data = wu_dict(units=True, dx_category=True)
        wu_data['pending'] = ''
        del wu_data['chief_complaint']
        for field in ['encounter', 'author', 'author_type']:
            thing = wu_data[field]
            wu_data[field] = thing.id

        pt = wu_data['patient']
        wu_data['patient'] = pt.id

        prev_count = pt.workup_set.count()
        prev_completed_count = pt.completed_workup_set().count()
        prev_pending_count = pt.pending_workup_set().count()

        response = self.client.post(reverse('new-workup', args=(pt.id, )),
                                    data=wu_data)

        self.assertRedirects(response,
                             reverse('core:patient-detail', args=(pt.id, )))

        # new pending workup should be created which is not included
        # in set of completed workups
        assert pt.workup_set.count() == prev_count + 1
        assert pt.completed_workup_set().count() == prev_completed_count
        assert pt.pending_workup_set().count() == prev_pending_count + 1
示例#3
0
    def test_workup_submit(self):
        """verify we can submit a valid workup as a signer and nonsigner"""

        for role in user_factories.all_roles:
            user = build_user([role])
            log_in_user(self.client, user)

            wu_count = models.Workup.objects.all().count()
            wu_data = wu_dict(units=True, dx_category=True)
            pt = wu_data['patient']
            wu_data['patient'] = pt.id
            wu_data['author'] = user.id
            wu_data['author_type'] = user.groups.first().id
            e = wu_data['encounter']
            wu_data['encounter'] = e.id

            response = self.client.post(reverse('new-workup', args=(pt.id, )),
                                        data=wu_data)
            self.assertRedirects(
                response, reverse("core:patient-detail", args=(pt.id, )))

            can_attest = role in user_factories.attesting_roles
            assert models.Workup.objects.all().count() == wu_count + 1
            new = models.Workup.objects.get(patient=pt)
            assert new.signed() == can_attest
示例#4
0
    def setUp(self):

        models.ClinicDate.objects.create(
            clinic_type=models.ClinicType.objects.first(),
            clinic_date=now().date())

        self.wu = models.Workup.objects.create(**wu_dict())
        self.note = models.AttestableBasicNote.objects.create(**note_dict())
示例#5
0
    def setUp(self):

        self.user = build_user()
        log_in_user(self.client, self.user)

        self.note_data = note_dict(user=self.user)

        self.wu = models.Workup.objects.create(**wu_dict(user=self.user))
        self.form_data = note_dict(user=self.user, encounter_pk=False)
示例#6
0
    def setUp(self):

        models.ClinicDate.objects.create(
            clinic_type=models.ClinicType.objects.first(),
            clinic_date=now().date())

        self.user = build_user()
        log_in_user(self.client, self.user)

        self.wu = models.Workup.objects.create(**wu_dict(user=self.user))
示例#7
0
    def setUp(self):
        DiagnosisType.objects.create(name='Cardiovascular')

        wu_data = wu_dict()
        wu_data['diagnosis_categories'] = [DiagnosisType.objects.first().pk]
        wu_data['got_imaging_voucher'] = False
        wu_data['got_voucher'] = False

        del wu_data['t']

        # this wu_data object should have specified _none_ of the fields
        # for unit-aware vital signs
        self.wu_data = wu_data
        self.pt = wu_data['patient']
示例#8
0
    def test_workup_urls(self):
        """Test creation of many workups."""

        wu_urls = ['workup', 'workup-update']

        for i in range(5):
            models.Workup.objects.bulk_create(
                [models.Workup(**wu_dict()) for i in range(5)])
            wu = models.Workup.objects.last()

            wu.diagnosis_categories.add(models.DiagnosisType.objects.first())

            for wu_url in wu_urls:
                response = self.client.get(reverse(wu_url, args=(wu.id, )))
                assert response.status_code == 200
示例#9
0
    def setUp(self):
        DiagnosisType.objects.create(name='Cardiovascular')
        ClinicType.objects.create(name='Main Clinic')
        ClinicDate.objects.create(
            clinic_date='2018-08-26', clinic_type=ClinicType.objects.first())

        wu_data = wu_dict()
        wu_data['diagnosis_categories'] = [DiagnosisType.objects.first().pk]
        wu_data['clinic_day'] = wu_data['clinic_day'].pk
        wu_data['got_imaging_voucher'] = False
        wu_data['got_voucher'] = False

        del wu_data['t']

        # this wu_data object should have specified _none_ of the fields
        # for unit-aware vital signs
        self.wu_data = wu_data
示例#10
0
    def test_workup_submit(self):
        """verify we can submit a valid workup as a signer and nonsigner"""

        for role in user_factories.all_roles:
            user = build_user([role])
            log_in_user(self.client, user)
            pt_id = Patient.objects.first().pk

            wu_count = models.Workup.objects.all().count()
            wu_data = wu_dict(units=True, clinic_day_pk=True, dx_category=True)

            response = self.client.post(reverse('new-workup', args=(pt_id, )),
                                        data=wu_data)
            self.assertRedirects(
                response, reverse("core:patient-detail", args=(pt_id, )))

            can_attest = role in user_factories.attesting_roles
            assert models.Workup.objects.all().count() == wu_count + 1
            assert models.Workup.objects.last().signed() == can_attest
示例#11
0
    def test_invalid_workup_submit_preserves_units(self):

        # first, craft a workup that has units, but fail to set the
        # diagnosis categories, so that it will fail to be accepted.
        wu_data = wu_dict(units=True)
        del wu_data['chief_complaint']
        pt_id = Patient.objects.first().pk

        response = self.client.post(reverse('new-workup', args=(pt_id, )),
                                    data=wu_data)

        # verify we're bounced back to workup_create
        assert response.status_code == 200
        self.assertTemplateUsed(response, 'workup/workup_create.html')
        self.assertFormError(response, 'form', 'chief_complaint',
                             'This field is required.')

        for unit in ['height_units', 'weight_units', 'temperature_units']:
            self.assertContains(response, '<input name="%s"' % (unit))

            assert response.context['form'][unit].value() == wu_data[unit]
示例#12
0
 def setUp(self):
     self.valid_wu_dict = wu_dict()
示例#13
0
    def setUp(self):

        self.wu = models.Workup.objects.create(**wu_dict())
        self.note = models.AttestableBasicNote.objects.create(**note_dict())
示例#14
0
    def setUp(self):
        # build a user and log in
        self.password = factory.Faker("password").generate()
        attending = build_user(
            password=self.password,
            group_factories=[user_factories.AttendingGroupFactory])
        coordinator = build_user(
            password=self.password,
            group_factories=[user_factories.CaseManagerGroupFactory])
        volunteer = build_user(
            password=self.password,
            group_factories=[user_factories.VolunteerGroupFactory])
        self.users = {
            'attending': attending,
            'coordinator': coordinator,
            'volunteer': volunteer,
        }

        workup_models.ClinicType.objects.create(name="Basic Care Clinic")

        # various time references used in object creation
        tomorrow = now().date() + datetime.timedelta(days=1)
        yesterday = now().date() - datetime.timedelta(days=1)
        earlier_this_week = now().date() - datetime.timedelta(days=5)
        last_week = now().date() - datetime.timedelta(days=15)

        tomorrow_clindate = workup_models.ClinicDate.objects.create(
            clinic_type=workup_models.ClinicType.objects.first(),
            clinic_date=tomorrow)
        yesterday_clindate = workup_models.ClinicDate.objects.create(
            clinic_type=workup_models.ClinicType.objects.first(),
            clinic_date=yesterday)
        last_week_clindate = workup_models.ClinicDate.objects.create(
            clinic_type=workup_models.ClinicType.objects.first(),
            clinic_date=earlier_this_week)
        # log_in_provider(self.client, build_user(["Attending"]))

        pt1 = models.Patient.objects.get(pk=1)
        pt1.toggle_active_status(coordinator, coordinator.groups.first())
        pt1.save()
        self.pt1 = pt1

        pt_prototype = {
            'phone': '+49 178 236 5288',
            'gender': models.Gender.objects.all()[1],
            'address': 'Schulstrasse 9',
            'city': 'Munich',
            'state': 'BA',
            'zip_code': '63108',
            'pcp_preferred_zip': '63018',
            'date_of_birth': datetime.date(1990, 1, 1),
            'patient_comfortable_with_english': False,
            'preferred_contact_method': models.ContactMethod.objects.first(),
        }

        self.pt2 = models.Patient.objects.create(
            first_name="Juggie",
            last_name="Brodeltein",
            middle_name="Bayer",
            **pt_prototype
        )

        self.pt3 = models.Patient.objects.create(
            first_name="Asdf",
            last_name="Lkjh",
            middle_name="Bayer",
            **pt_prototype
        )

        self.pt4 = models.Patient.objects.create(
            first_name="No",
            last_name="Action",
            middle_name="Item",
            **pt_prototype
        )

        self.pt5 = models.Patient.objects.create(
            first_name="No",
            last_name="Workup",
            middle_name="Patient",
            **pt_prototype
        )
        self.pt5.case_managers.add(coordinator)

        # use default values
        wu_prototype = wu_dict()

        # Give self.pt2 a workup one day later.
        wu_prototype['clinic_day'] = tomorrow_clindate
        wu_prototype['patient'] = self.pt2
        workup_models.Workup.objects.create(**wu_prototype)

        # Give pt3 a workup one day ago.
        wu_prototype['clinic_day'] = yesterday_clindate
        wu_prototype['patient'] = self.pt3
        workup_models.Workup.objects.create(**wu_prototype)

        # Give pt1 a signed workup five days ago.
        wu_prototype['clinic_day'] = yesterday_clindate
        wu_prototype['patient'] = self.pt1
        wu_prototype['signer'] = self.users['attending']
        workup_models.Workup.objects.create(**wu_prototype)

        ai_prototype = {
            'author': self.users['coordinator'],
            'author_type': self.users['coordinator'].groups.first(),
            'instruction': models.ActionInstruction.objects.first(),
            'comments': ""
        }

        # make pt1 have and AI due tomorrow
        models.ActionItem.objects.create(
            due_date=tomorrow,
            patient=pt1,
            **ai_prototype)

        # make self.pt2 have an AI due yesterday
        models.ActionItem.objects.create(
            due_date=yesterday,
            patient=self.pt2,
            **ai_prototype)

        # make pt3 have an AI that during the test will be marked done
        models.ActionItem.objects.create(
            due_date=last_week,
            patient=self.pt3,
            **ai_prototype)
示例#15
0
 def setUp(self):
     self.valid_wu_dict = wu_dict()
     self.pt = self.valid_wu_dict['patient']
示例#16
0
    def setUp(self):

        self.user = build_user()
        log_in_user(self.client, self.user)

        self.wu = models.Workup.objects.create(**wu_dict(user=self.user))