def setUp(self):
        year = get_utcnow().year
        add_or_update_django_sites(apps=django_apps,
                                   sites=ambition_sites,
                                   fqdn=fqdn,
                                   verbose=False)
        self.user = User.objects.create(username="******",
                                        is_staff=True,
                                        is_active=True)
        for permission in Permission.objects.filter(
                content_type__app_label="ambition_subject",
                content_type__model="followup"):
            self.user.user_permissions.add(permission)

        subject_screening = mommy.make_recipe(
            "ambition_screening.subjectscreening")
        consent = mommy.make_recipe(
            "ambition_subject.subjectconsent",
            screening_identifier=subject_screening.screening_identifier,
            consent_datetime=datetime(year, 12, 1, 0, 0, 0, 0, pytz.utc),
            user_created="erikvw",
        )
        self.subject_identifier = consent.subject_identifier

        for appointment in Appointment.objects.filter(
                subject_identifier=self.subject_identifier).order_by(
                    "timepoint"):
            SubjectVisit.objects.create(
                appointment=appointment,
                subject_identifier=self.subject_identifier,
                reason=SCHEDULED,
            )

        self.registered_subject = RegisteredSubject.objects.get(
            subject_identifier=consent.subject_identifier)
예제 #2
0
    def setUp(self):
        add_or_update_django_sites(sites=self.default_sites)

        self.facility = Facility(name="clinic",
                                 days=[MO, TU, WE, TH, FR],
                                 slots=[100, 100, 100, 100, 100])
        import_holidays()
예제 #3
0
 def setUpClass(cls):
     super().setUpClass()
     import_holidays(test=True)
     add_or_update_django_sites(sites=get_sites_by_country("tanzania"))
     site_list_data.autodiscover()
     GroupPermissionsUpdater(codenames_by_group=get_codenames_by_group(),
                             verbose=True)
     if cls.import_randomization_list:
         RandomizationListImporter(verbose=False, name="default")
예제 #4
0
 def setUpClass(cls):
     add_or_update_django_sites(sites=[
         SingleSite(
             settings.SITE_ID,
             "test_site",
             country_code="ug",
             country="uganda",
             domain="bugamba.ug.clinicedc.org",
         )
     ])
     return super().setUpClass()
    def setUpClass(cls):
        super().setUpClass()

        site_randomizers._registry = {}
        site_randomizers.register(Randomizer)
        add_or_update_django_sites(
            apps=django_apps, sites=ambition_sites, fqdn=fqdn, verbose=False
        )
        if cls.import_randomization_list:
            RandomizationListImporter(name="ambition", verbose=False)
        import_holidays(test=True)
예제 #6
0
    def test_to_subject_dashboard(self):
        add_or_update_django_sites(apps=django_apps,
                                   sites=ambition_sites,
                                   fqdn=fqdn)
        RandomizationListImporter()
        GroupPermissionsUpdater()
        import_holidays()
        site_list_data.autodiscover()
        self.login(superuser=False, groups=[EVERYONE, CLINIC, PII])

        subject_screening = baker.make_recipe(
            "ambition_screening.subjectscreening")

        home_page = self.app.get(reverse("home_url"),
                                 user=self.user,
                                 status=200)
        screening_listboard_page = home_page.click(description="Screening",
                                                   index=1)

        add_subjectconsent_page = screening_listboard_page.click(
            description="Consent", index=1)
        # submit blank form
        response = add_subjectconsent_page.form.submit()
        self.assertIn("Please correct the errors below", response)

        subject_consent = baker.make_recipe(
            "ambition_subject.subjectconsent",
            screening_identifier=subject_screening.screening_identifier,
            dob=(get_utcnow() -
                 relativedelta(years=subject_screening.age_in_years)).date(),
            first_name="Melissa",
            last_name="Rodriguez",
            initials="MR",
            consent_datetime=get_utcnow(),
        )

        home_page = self.app.get(reverse("home_url"),
                                 user=self.user,
                                 status=200)
        screening_listboard_page = home_page.click(description="Screening",
                                                   index=1)

        self.assertIn("Dashboard", screening_listboard_page)
        self.assertIn(
            f"subjectscreening_change_{subject_screening.screening_identifier}",
            screening_listboard_page,
        )

        home_page = self.app.get(reverse("home_url"),
                                 user=self.user,
                                 status=200)
        subject_listboard_page = home_page.click(description="Subjects",
                                                 index=1)

        self.assertIn(subject_consent.subject_identifier,
                      subject_listboard_page)

        href = reverse(
            "ambition_dashboard:subject_dashboard_url",
            kwargs={"subject_identifier": subject_consent.subject_identifier},
        )
        subject_dashboard_page = subject_listboard_page.click(href=href)

        self.assertEqual(subject_dashboard_page.status_code, 200)

        # on subject_dashboard
        # assert all appointment are showing
        subject_identifier = subject_consent.subject_identifier
        appointments = Appointment.objects.filter(
            subject_identifier=subject_identifier).order_by("appt_datetime")
        for appointment in appointments:
            self.assertIn(appointment.visit_code, subject_dashboard_page)

        # start appointment 1000
        page = subject_dashboard_page.click(linkid="start_btn_1000")
        page.form["appt_status"] = IN_PROGRESS_APPT
        page.form["appt_reason"] = SCHEDULED_APPT
        subject_dashboard_page = page.form.submit()
        self.assertEqual(subject_dashboard_page.status_code, 302)
        self.assertEqual(
            subject_dashboard_page.url,
            f"/subject/subject_dashboard/{subject_identifier}/",
        )

        subject_dashboard_page = self.app.get(subject_dashboard_page.url,
                                              user=self.user,
                                              status=200)

        # start visit 1000
        self.assertIn(" Start ", subject_dashboard_page)
        subject_visit_page = subject_dashboard_page.click(
            linkid=(f"start_btn_{appointments[0].visit_code}_"
                    f"{appointments[0].visit_code_sequence}"))
        subject_visit_page.form["info_source"] = "patient"
        subject_dashboard_page = subject_visit_page.form.submit()

        url = (f"/subject/subject_dashboard/{subject_identifier}/"
               f"{str(appointments[0].pk)}/")
        self.assertEqual(subject_dashboard_page.status_code, 302)
        self.assertEqual(subject_dashboard_page.url, url)

        subject_dashboard_page = self.app.get(
            reverse(
                "ambition_dashboard:subject_dashboard_url",
                kwargs=dict(
                    subject_identifier=subject_identifier,
                    appointment=str(appointments[0].id),
                ),
            ),
            user=self.user,
            status=200,
        )

        self.assertIn("CRFs", subject_dashboard_page)
        self.assertIn("Requisitions", subject_dashboard_page)
 def setUpClass(cls):
     add_or_update_django_sites(apps=django_apps,
                                sites=ambition_sites,
                                fqdn=fqdn,
                                verbose=True)
     return super().setUpClass()
예제 #8
0
 def setUp(self):
     add_or_update_django_sites(sites=self.default_sites)
 def test_site2(self):
     add_or_update_django_sites(sites=self.default_sites, verbose=False)
     obj = SubjectModelOne.objects.create(screening_identifier="12345")
     rs = RegisteredSubject.objects.get(
         registration_identifier=obj.to_string(obj.registration_identifier))
     self.assertEqual(rs.site.pk, 20)
예제 #10
0
 def setUp(self):
     add_or_update_django_sites(sites=self.default_sites)
     self.user = User.objects.create(username="******")
     import_holidays()
예제 #11
0
 def setUp(self):
     add_or_update_django_sites(sites=self.default_sites, verbose=False)
     self.user = User.objects.create(first_name="Noam", last_name="Chomsky")
     consignee = Consignee.objects.create(name="consignee")
     shipper = Shipper.objects.create(name="shipper")
     self.manifest = Manifest.objects.create(consignee=consignee, shipper=shipper)
예제 #12
0
 def setUp(self):
     super().setUp()
     add_or_update_django_sites(sites=all_sites)
     site_randomizers._registry = {}
     site_randomizers.register(Randomizer)