class SubjectVisit(VisitModelMixin, ReferenceModelMixin, CreatesMetadataModelMixin, SiteModelMixin, RequiresConsentFieldsModelMixin, BaseUuidModel): """A model completed by the user that captures the covering information for the data collected for this timepoint/appointment, e.g.report_datetime. """ appointment = models.OneToOneField(Appointment, on_delete=models.PROTECT) reason = models.CharField( verbose_name='What is the reason for this visit report?', max_length=25, choices=VISIT_REASON) reason_unscheduled = models.CharField( verbose_name=( 'If \'Unscheduled\' above, provide reason for ' 'the unscheduled visit'), max_length=25, choices=VISIT_UNSCHEDULED_REASON, default=NOT_APPLICABLE) info_source = models.CharField( verbose_name='What is the main source of this information?', max_length=25, choices=INFO_SOURCE) on_site = CurrentSiteManager() objects = VisitModelManager() history = HistoricalRecords() class Meta(VisitModelMixin.Meta): pass
class SubjectVisit( VisitModelMixin, ReferenceModelMixin, CreatesMetadataModelMixin, SiteModelMixin, RequiresConsentFieldsModelMixin, edc_models.BaseUuidModel, ): """A model completed by the user that captures the covering information for the data collected for this timepoint/appointment, e.g.report_datetime. """ reason = models.CharField( verbose_name="What is the reason for this visit report?", max_length=25, choices=VISIT_REASON, help_text=( "Only baseline (0m), 6m and 12m are considered " "`scheduled` visits as per the MOCCA protocol." f"If `missed' complete CRF {SubjectVisitMissed._meta.verbose_name}." ), ) reason_unscheduled = models.CharField( verbose_name="If 'unscheduled', provide reason for the unscheduled visit", max_length=25, choices=VISIT_UNSCHEDULED_REASON, default=NOT_APPLICABLE, ) clinic_services = models.ManyToManyField( ClinicServices, verbose_name="Why is the patient at the clinic today?", related_name="visit_clinic_services", ) clinic_services_other = edc_models.OtherCharField() info_source = models.CharField( verbose_name="What is the main source of this information?", max_length=25, choices=INFO_SOURCE, ) on_site = CurrentSiteManager() objects = VisitModelManager() history = edc_models.HistoricalRecords() class Meta(VisitModelMixin.Meta, edc_models.BaseUuidModel.Meta): pass
class SubjectVisit( VisitModelMixin, ReferenceModelMixin, CreatesMetadataModelMixin, SiteModelMixin, RequiresConsentFieldsModelMixin, BaseUuidModel, ): """A model completed by the user that captures the covering information for the data collected for this timepoint/appointment, e.g.report_datetime. """ reason = models.CharField( verbose_name="What is the reason for this visit report?", max_length=25, choices=VISIT_REASON, ) reason_unscheduled = models.CharField( verbose_name= "If 'unscheduled', provide reason for the unscheduled visit", max_length=25, choices=VISIT_UNSCHEDULED_REASON, default=NOT_APPLICABLE, ) info_source = models.CharField( verbose_name="What is the main source of this information?", max_length=25, choices=INFO_SOURCE, default=HOSPITAL_NOTES, ) on_site = CurrentSiteManager() objects = VisitModelManager() history = HistoricalRecords() def __str__(self): return ( f"{self.subject_identifier} {self.visit_code}.{self.visit_code_sequence} " f"(HMS_ID:{self.hospital_identifier})") @property def hospital_identifier(self): return SubjectScreening.objects.get( subject_identifier=self.subject_identifier).hospital_identifier class Meta(BaseUuidModel.Meta, VisitModelMixin.Meta): pass
class SubjectVisit(VisitModelMixin, CreatesMetadataModelMixin, RequiresConsentMixin, SurveyModelMixin, ReferenceModelMixin, StatusHelperModelMixin, BaseUuidModel): """A model completed by the user that captures the covering information for the data collected for this timepoint/appointment, e.g.report_datetime. """ appointment = models.OneToOneField(Appointment, on_delete=models.PROTECT) household_member = models.ForeignKey( HouseholdMember, on_delete=models.PROTECT) reason_unscheduled = models.CharField( verbose_name=( 'If \'Unscheduled\' above, provide reason for ' 'the unscheduled visit'), max_length=25, blank=True, null=True, choices=VISIT_UNSCHEDULED_REASON, ) objects = VisitModelManager() history = HistoricalRecords() def save(self, *args, **kwargs): self.survey = self.appointment.survey_object.field_value self.survey_schedule = ( self.appointment.survey_object.survey_schedule.field_value) self.info_source = 'subject' self.reason = SCHEDULED super().save(*args, **kwargs) class Meta(VisitModelMixin.Meta, RequiresConsentMixin.Meta): app_label = "bcpp_subject" consent_model = 'bcpp_subject.subjectconsent' anonymous_consent_model = 'bcpp_subject.anonymousconsent'
class MaternalVisit(VisitModelMixin, CreatesMetadataModelMixin, ReferenceModelMixin, RequiresConsentFieldsModelMixin, CaretakerFieldsMixin, SiteModelMixin, BaseUuidModel): """ Maternal visit form that links all antenatal/ postnatal follow-up forms """ appointment = models.OneToOneField(Appointment, on_delete=models.PROTECT) reason = models.CharField(verbose_name='Reason for visit', max_length=25, choices=VISIT_REASON) reason_missed = models.CharField( verbose_name='If \'missed\' above, reason scheduled visit was missed', blank=True, null=True, max_length=250) reason_unscheduled = models.CharField( verbose_name= 'If \'Unscheduled\' above, provide reason for the unscheduled visit', blank=True, null=True, max_length=25, ) study_status = models.CharField( verbose_name='What is the participant\'s current study status', max_length=50, choices=MATERNAL_VISIT_STUDY_STATUS) survival_status = models.CharField( max_length=10, verbose_name='Participant\'s survival status', choices=ALIVE_DEAD_UNKNOWN, null=True, default=ALIVE) info_source = models.CharField(verbose_name='Source of information?', default=PARTICIPANT, max_length=25, choices=VISIT_INFO_SOURCE) last_alive_date = models.DateField( verbose_name='Date participant last known alive', blank=True, null=True, validators=[date_not_before_study_start, date_not_future]) tb_participation = models.CharField( verbose_name= 'Participant willing to do an Informed consent for the Tb Study', choices=YES_NO, max_length=10, default='') on_site = CurrentSiteManager() objects = VisitModelManager() history = HistoricalRecords() @property def action_item_reason(self): return self.study_status def run_metadata_rules(self, visit=None): """Runs all the rule groups. Initially called by post_save signal. Also called by post_save signal after metadata is updated. """ visit = visit or self if visit.reason != MISSED_VISIT: metadata_rule_evaluator = self.metadata_rule_evaluator_cls( visit=visit) metadata_rule_evaluator.evaluate_rules() class Meta(VisitModelMixin.Meta): app_label = 'flourish_caregiver' verbose_name = 'Maternal Visit'