Skip to main content

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

Project description

pypi actions codecov downloads

edc-visit-tracking

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):
        pass

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):
        pass

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

PreviousVisitModelMixin

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

VisitTrackingModelFormMixin

see DEFAULT_REPORT_DATETIME_ALLOWANCE

Missed Visit Report

A detail report should be submitted for scheduled visits that are missed. By selecting the reason missed visit on SubjectVisit, only the missed visit CRF will be required for the timepoint. All other CRFs and requisitions will be excluded.

Unscheduled visits cannot be missed.

The model mixin SubjectVisitMissedModelMixin provides the basic features of a SubjectVisitMissed model.

In your subject app declare:

from django.db.models import PROTECT
from edc_crf.model_mixins import CrfWithActionModelMixin
from edc_model import models as edc_models
from edc_visit_tracking.model_mixins import SubjectVisitMissedModelMixin

class SubjectVisitMissed(SubjectVisitMissedModelMixin, edc_models.BaseUuidModel):

    missed_reasons = models.ManyToManyField(
        SubjectVisitMissedReasons, blank=True, related_name="+"
    )

    class Meta(CrfWithActionModelMixin.Meta, edc_models.BaseUuidModel.Meta):
        verbose_name = "Missed Visit Report"
        verbose_name_plural = "Missed Visit Report"

In your list model app, e.g. meta_lists, declare the list model:

class SubjectVisitMissedReasons(ListModelMixin):
    class Meta(ListModelMixin.Meta):
        verbose_name = "Subject Missed Visit Reasons"
        verbose_name_plural = "Subject Missed Visit Reasons"

… and update the list_data dictionary, for example:

list_data = {
...
"meta_lists.subjectvisitmissedreasons": [
    ("forgot", "Forgot / Can’t remember being told about appointment"),
    ("family_emergency", "Family emergency (e.g. funeral) and was away"),
    ("travelling", "Away travelling/visiting"),
    ("working_schooling", "Away working/schooling"),
    ("too_sick", "Too sick or weak to come to the centre"),
    ("lack_of_transport", "Transportation difficulty"),
    (OTHER, "Other reason (specify below)",),
],
...
}

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

edc-visit-tracking-0.3.21.tar.gz (37.6 kB view details)

Uploaded Source

Built Distribution

edc_visit_tracking-0.3.21-py3-none-any.whl (53.1 kB view details)

Uploaded Python 3

File details

Details for the file edc-visit-tracking-0.3.21.tar.gz.

File metadata

  • Download URL: edc-visit-tracking-0.3.21.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.9

File hashes

Hashes for edc-visit-tracking-0.3.21.tar.gz
Algorithm Hash digest
SHA256 3125c308fabd0c20a4fb9f30945d73ddfcaf74534e49a954e4eecdff48e80936
MD5 e4bcd651cb81484bcd5f23315787e1f3
BLAKE2b-256 dd759f484eb34d7935be4460727d032a4ade263031040ee2c5c15326d38b2536

See more details on using hashes here.

File details

Details for the file edc_visit_tracking-0.3.21-py3-none-any.whl.

File metadata

File hashes

Hashes for edc_visit_tracking-0.3.21-py3-none-any.whl
Algorithm Hash digest
SHA256 56e6276700ee2417efb82734bc266a79d5f1f408c4e5dac5b5cbbba5e7c7e2bc
MD5 a749cc5a87c5f43ffbf1c27507e5d6c2
BLAKE2b-256 8ae0af441793d9acc101a5b127b79993702ec2a3c7a7609ac2843044b639d97b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page