def randomization_rows(last_int: int, rows_to_add: int):
    rows = []
    for country, sites in all_sites.items():
        for site in sites:
            arm = "intervention" if is_intervention_site(site) else "control"
            n = int(f"{site.site_id}{last_int}")
            for i in range(1, rows_to_add + 1):
                n += 1
                rows.append([n, arm, site.name, country])
    return rows
Esempio n. 2
0
def raise_if_intervention_site_without_icc_registration():
    if is_intervention_site():
        try:
            IntegratedCareClinicRegistration.objects.get(
                site_id=Site.objects.get_current())
        except ObjectDoesNotExist:
            raise forms.ValidationError(
                "This is an intervention site. Complete the "
                f"`{IntegratedCareClinicRegistration._meta.verbose_name}` form first."
            )
Esempio n. 3
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     icc_registration_outstanding = False
     if is_intervention_site():
         try:
             IntegratedCareClinicRegistration.objects.get(
                 site__id=settings.SITE_ID)
         except ObjectDoesNotExist:
             icc_registration_outstanding = True
     context.update(
         icc_registration_outstanding=icc_registration_outstanding,
         daily_closing_log_url=self.get_daily_closing_log_url(),
     )
     return context
Esempio n. 4
0
 def clean(self):
     cleaned_data = super().clean()
     if not is_intervention_site():
         raise forms.ValidationError(
             "Wait! This site is NOT an intervention site. Check randomization."
         )
     if not self.instance.id:
         try:
             IntegratedCareClinicRegistration.objects.get(
                 site=Site.objects.get_current())
         except ObjectDoesNotExist:
             pass
         else:
             raise forms.ValidationError(
                 "This form may only be completed once per facilty / site. "
                 "Try `editing` the existing entry.")
     return cleaned_data
 def save(self, *args, **kwargs):
     if not is_intervention_site():
         raise Hba1cRegistrationManagerError(
             "Registration failed. This site is not included in this substudy. "
             "Perhaps catch this in the form validation.")
     super().save(*args, **kwargs)
Esempio n. 6
0
 def save(self, *args, **kwargs):
     if not is_intervention_site():
         raise IntegratedCareClinicRegistrationError(
             "Registration failed. This is not an intervention site. "
             "Perhaps catch this in the form validation.")
     super().save(*args, **kwargs)
Esempio n. 7
0
 def test_is_not_intervention(self):
     self.assertFalse(is_intervention_site())
Esempio n. 8
0
 def test_is_intervention(self):
     self.assertTrue(is_intervention_site())