Skip to main content

Base classes for visit reports/tracking in clinicedc/edc.

Project description

pypi travis codecov downloads


Track study participant visit reports.

Declaring a visit model

A visit_model is declared using the model mixin VisitModelMixin. Normally, a visit_model will be declared with additional model mixins, but VisitModelMixin must be there.

class SubjectVisit(VisitModelMixin, BaseUuidModel):

Also, ensure the Meta class attributes of VisitModelMixin are inherited. These include required constraints and ordering.

class SubjectVisit(VisitModelMixin, BaseUuidModel):


    class Meta(VisitModelMixin.Meta):

Among other features, VisitModelMixin adds a OneToOneField foreign key to the visit_model that points to edc_appointment.Appointment.

Important: A visit model is a special model in the EDC. A model declared with the model mixin, VisitModelMixin, is the definition of a visit model. CRFs and Requisitions have a foreign key pointing to a visit model. A number of methods on CRFs and Requisitions detect their visit model foreign key name, model class and value by looking for the FK declared with VisitModelMixin.

For a subject that requires ICF the visit model would look like this:

class SubjectVisit(VisitModelMixin, OffstudyMixin, CreatesMetadataModelMixin,
                   RequiresConsentModelMixin, BaseUuidModel):

    class Meta(VisitModelMixin.Meta):
        consent_model = 'myapp.subjectconsent'  # for RequiresConsentModelMixin

If the subject does not require ICF, such as an infant, don’t include the RequiresConsentModelMixin:

class InfantVisit(VisitModelMixin, OffstudyMixin,
                  CreatesMetadataModelMixin, BaseUuidModel):

    class Meta(VisitModelMixin.Meta):

Declaring a CRF

The CrfModelMixin is required for all CRF models. CRF models have a OneToOneField key to a visit model.

class CrfOne(CrfModelMixin, OffstudyCrfModelMixin, RequiresConsentModelMixin,
             UpdatesCrfMetadataModelMixin, BaseUuidModel):

    subject_visit = models.OneToOneField(SubjectVisit)

    f1 = models.CharField(max_length=10, default='erik')

    vl = models.CharField(max_length=10, default=NO)

    rdb = models.CharField(max_length=10, default=NO)

    class Meta:
        consent_model = 'myapp.subjectconsent'  # for RequiresConsentModelMixin

Declaring forms:

The VisitFormMixin includes a number of common validations in the clean method:

class SubjectVisitForm(VisitFormMixin, forms.ModelForm):

    class Meta:
        model = SubjectVisit


The PreviousVisitModelMixin ensures that visits are entered in sequence. It is included with the VisitModelMixin.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
edc_visit_tracking-0.2.36-py3-none-any.whl (41.4 kB) Copy SHA256 hash SHA256 Wheel py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page