예제 #1
0
class CrfModelMixin(CrfNoManagerModelMixin):

    on_site = CurrentSiteManager()
    objects = CrfModelManager()
    history = HistoricalRecords(inherit=True)

    class Meta(CrfNoManagerModelMixin.Meta):
        abstract = True
예제 #2
0
class CrfWithActionModelMixin(
        CrfNoManagerModelMixin,
        ActionNoManagersModelMixin,
        TrackingModelMixin,
):

    action_name = None
    tracking_identifier_prefix = ""

    on_site = CurrentSiteManager()
    objects = CrfModelManager()
    history = HistoricalRecords(inherit=True)

    class Meta(CrfNoManagerModelMixin.Meta):
        abstract = True
예제 #3
0
class SubjectRefusal(
    NonUniqueSubjectIdentifierModelMixin, SiteModelMixin, BaseUuidModel
):
    subject_screening = models.ForeignKey(SubjectScreening, on_delete=models.PROTECT)

    subject_identifier = models.CharField(max_length=50, editable=False)

    screening_identifier = models.CharField(max_length=50, editable=False)

    report_datetime = models.DateTimeField(
        verbose_name="Report Date and Time", default=get_utcnow
    )

    reason = models.CharField(
        verbose_name="Reason for refusal to join",
        max_length=25,
        choices=REFUSAL_REASONS,
    )

    other_reason = OtherCharField()

    on_site = CurrentSiteManager()

    objects = SubjectRefusalManager()

    history = HistoricalRecords()

    def save(self, *args, **kwargs):
        self.screening_identifier = self.subject_screening.screening_identifier
        self.subject_identifier = self.subject_screening.subject_identifier
        self.subject_identifier_as_pk = self.subject_screening.subject_identifier_as_pk
        super().save(*args, **kwargs)

    def __str__(self):
        return (
            f"{self.screening_identifier} {self.subject_screening.gender} "
            f"{self.subject_screening.age_in_years}"
        )

    def natural_key(self):
        return (self.subject_identifier,)

    def get_search_slug_fields(self):
        return ["screening_identifier", "subject_identifier"]

    class Meta:
        verbose_name = "Subject Refusal"
        verbose_name_plural = "Subject Refusals"
예제 #4
0
class SubjectReconsent(
        ConsentModelMixin,
        PersonalFieldsMixin,
        IdentityFieldsMixin,
        UniqueSubjectIdentifierFieldMixin,
        UpdatesOrCreatesRegistrationModelMixin,
        SiteModelMixin,
        BaseUuidModel,
):

    objects = SubjectIdentifierManager()

    history = HistoricalRecords()

    def natural_key(self):
        return (self.subject_identifier, )
예제 #5
0
class SubjectRefusalScreening(SiteModelMixin, BaseUuidModel):
    mocca_register = models.OneToOneField(
        "mocca_screening.moccaregister",
        on_delete=models.PROTECT,
        null=True,
        verbose_name="MOCCA (original) register details",
    )

    report_datetime = models.DateTimeField(verbose_name="Report Date and Time",
                                           default=get_utcnow)

    reason = models.CharField(
        verbose_name="Reason for refusal to screen",
        max_length=25,
        choices=REFUSAL_REASONS_SCREENING,
    )

    other_reason = OtherCharField()

    comment = models.TextField(
        verbose_name="Additional Comments",
        null=True,
        blank=True,
    )

    on_site = CurrentSiteManager()

    objects = Manager()

    history = HistoricalRecords()

    def __str__(self):
        return self.mocca_register.mocca_study_identifier

    def natural_key(self):
        return tuple(self.mocca_register)

    @staticmethod
    def get_search_slug_fields():
        return ["screening_identifier"]

    class Meta(BaseUuidModel.Meta):
        verbose_name = "Refusal to Screen"
        verbose_name_plural = "Refusal to Screen"
예제 #6
0
class SubjectRefusal(SiteModelMixin, BaseUuidModel):
    screening_identifier = models.CharField(max_length=50, unique=True)

    report_datetime = models.DateTimeField(verbose_name="Report Date and Time",
                                           default=get_utcnow)

    reason = models.CharField(
        verbose_name="Reason for refusal to join",
        max_length=25,
        choices=REFUSAL_REASONS,
    )

    other_reason = OtherCharField()

    comment = models.TextField(
        verbose_name="Additional Comments",
        null=True,
        blank=True,
    )

    on_site = CurrentSiteManager()

    objects = SubjectRefusalManager()

    history = HistoricalRecords()

    def __str__(self):
        return self.screening_identifier

    def natural_key(self):
        return (self.screening_identifier, )

    @staticmethod
    def get_search_slug_fields():
        return ["screening_identifier"]

    class Meta(BaseUuidModel.Meta):
        verbose_name = "Refusal to Consent"
        verbose_name_plural = "Refusal to Consent"
예제 #7
0
class DailyClosingLog(SiteModelMixin, BaseUuidModel):

    site = models.ForeignKey(
        Site,
        on_delete=models.PROTECT,
        null=True,
        related_name="+",
        blank=False,
    )

    log_date = models.DateField(verbose_name="Clinic date", default=get_utcnow)

    clinic_services = models.CharField(
        verbose_name="Which services are being offered at the clinic today?",
        max_length=25,
        choices=CLINIC_DAYS,
    )

    attended = models.IntegerField(
        verbose_name="Total number of patients who attended the clinic today",
        validators=[MinValueValidator(0)],
    )

    selection_method = models.CharField(
        verbose_name="How were patients selected to be approached?",
        max_length=25,
        choices=SELECTION_METHOD,
    )

    approached = models.IntegerField(
        verbose_name=
        "Of those who attended, how many were approached by the study team",
        validators=[MinValueValidator(0)],
    )

    agreed_to_screen = models.IntegerField(
        verbose_name="Of those approached, how many agreed to be screened",
        validators=[MinValueValidator(0)],
    )

    comment = models.TextField(
        verbose_name="Additional Comments",
        null=True,
        blank=True,
    )

    on_site = CurrentSiteManager()

    objects = DailyClosingLogManager()

    history = HistoricalRecords()

    def __str__(self):
        return self.log_date.strftime(
            convert_php_dateformat(settings.DATE_FORMAT))

    def natural_key(self):
        return (self.log_date, self.site)

    class Meta:
        verbose_name = "Daily Closing Log"
        verbose_name_plural = "Daily Closing Logs"
        constraints = [
            models.UniqueConstraint(fields=["log_date", "site"],
                                    name="unique_date_for_site"),
        ]
예제 #8
0
class ScreeningFieldsModeMixin(SiteModelMixin, models.Model):
    reference = models.UUIDField(verbose_name="Reference",
                                 unique=True,
                                 default=uuid4,
                                 editable=False)

    screening_identifier = models.CharField(
        verbose_name="Screening ID",
        max_length=50,
        blank=True,
        unique=True,
        editable=False,
    )

    report_datetime = models.DateTimeField(
        verbose_name="Report Date and Time",
        default=get_utcnow,
        help_text="Date and time of report.",
    )

    gender = models.CharField(choices=GENDER, max_length=10)

    age_in_years = models.IntegerField(
        validators=[MinValueValidator(0),
                    MaxValueValidator(110)])

    consent_ability = models.CharField(
        verbose_name="Participant or legal guardian/representative able and "
        "willing to give informed consent.",
        max_length=25,
        choices=YES_NO,
    )

    unsuitable_for_study = models.CharField(
        verbose_name=("Is there any other reason the patient is "
                      "deemed to not be suitable for the study?"),
        max_length=5,
        choices=YES_NO,
        default=NO,
        help_text="If YES, patient NOT eligible, please give reason below.",
    )

    reasons_unsuitable = models.TextField(
        verbose_name="Reason not suitable for the study",
        max_length=150,
        null=True,
        blank=True,
    )

    unsuitable_agreed = models.CharField(
        verbose_name=("Does the study coordinator agree that the patient "
                      "is not suitable for the study?"),
        max_length=5,
        choices=YES_NO_NA,
        default=NOT_APPLICABLE,
    )

    eligible = models.BooleanField(default=False, editable=False)

    reasons_ineligible = models.TextField(verbose_name="Reason not eligible",
                                          max_length=150,
                                          null=True,
                                          editable=False)

    eligibility_datetime = models.DateTimeField(
        null=True,
        editable=False,
        help_text="Date and time eligibility was determined")

    consented = models.BooleanField(default=False, editable=False)

    refused = models.BooleanField(default=False, editable=False)

    on_site = CurrentSiteManager()

    objects = ScreeningManager()

    history = HistoricalRecords(inherit=True)

    class Meta:
        abstract = True