Skip to main content

Patient registration module.

Project description

pypi travis coverage

edc-registration

The model RegisteredSubject is used by the Edc as the master subject registration table. Only one record may exist per individual. The table has space for PII so typically a RegisteredSubject instance is created or updated on completion of the informed consent. As always, PII in the Edc is encrypted at rest using django-crypto-field.

RegisteredSubjectModelMixin

Declare RegisteredSubject in your app using the RegisteredSubjectModelMixin, for example:

class RegisteredSubject(RegisteredSubjectModelMixin, BaseUuidModel):
    class Meta:
        app_label = 'my_app'

then in edc_registration AppConfig specify the app_label = 'my_app' so that other modules in the Edc can find the model class. (Note: The model_name is assumed to always be RegisteredSubject).

Other modules can find the model class by accessing the AppConfig:

>>> from django.apps import apps as django_apps
>>> RegisteredSubject = django_apps.get_app_config('edc_registration').model
>>> RegisteredSubject.objects.get(subject_identifier='12345678-9')
<RegisteredSubject: 12345678-9>

UpdatesOrCreatesRegistrationModelMixin

RegisteredSubject is never edited directly by the user. Instead some other model with the needed attributes is used as a proxy. To have a model perform the task of creating or updating RegisteredSubject, declare it with the UpdatesOrCreatesRegistrationModelMixin.

For example, a model, SubjectEligibility or a screening model creates or updates a RegisteredSubject without a subject identifier then a model such as the SubjectConsent in tests.models, also creates or updates a subject’s RegisteredSubject instance on save. For this to happen, both models are declared with the UpdatesOrCreatesRegistrationModelMixin:

    class SubjectEligibility(UniqueSubjectIdentifierModelMixin,
                         UpdatesOrCreatesRegistrationModelMixin, BaseUuidModel):

screening_identifier = models.CharField(
    max_length=36,
    null=True,
    unique=True)

    @property
def registration_unique_field(self):
    return 'screening_identifier'

def update_subject_identifier_on_save(self):
    """Overridden to not set the subject identifier on save.
    """
    if not self.subject_identifier:
        self.subject_identifier = self.subject_identifier_as_pk.hex
        self.subject_identifier_aka = self.subject_identifier_as_pk.hex
    return self.subject_identifier

class SubjectConsent(ConsentModelMixin, UpdatesOrCreatesRegistrationModelMixin,
                     CreateAppointmentsMixin, IdentityFieldsMixin, ReviewFieldsMixin,
                     PersonalFieldsMixin, CitizenFieldsMixin, VulnerabilityFieldsMixin,
                     BaseUuidModel):

            @property
        def registration_unique_field(self):
            return 'screening_identifier'

        class Meta:
            app_label = 'my_app'

The property registration_unique_field returns a model attribute that is used to set a registration identifier on RegisteredSubject.

A subject’s RegisteredSubject instance is created and updated in a post_save signal. As mentioned, it is never edited directly by the user.

For the signal to be registered you need to add the AppConfig to your INSTALLED_APPS:

INSTALLED_APPS = (
    ....
    'edc_registration.apps.AppConfig',
    ....
    )

However, since RegisteredSubject is not a model in edc_registration, you should subclass AppConfig instead, for example:

from django.apps import AppConfig as DjangoAppConfig
from edc_registration.apps import AppConfig as EdcRegistrationAppConfigParent

class AppConfig(DjangoAppConfig):
    name = 'my_app'

class EdcRegistrationAppConfig(EdcRegistrationAppConfigParent):
    app_label = 'my_app'

and update settings accordingly:

INSTALLED_APPS = (
    ....
    'my_app.apps.EdcRegistrationAppConfig',
    'my_app.apps.AppConfig',
    ....
    )

RegisteredSubjectMixin

Since the app_label of the model class RegisteredSubject is not known when the models classes are loaded, it is difficult to include the class as a foreign key. As a work around, use the RegisteredSubjectMixin. When this mixin is declared on your model, the subject_identifier field is added to the model and verified against RegisteredSubject on each save.

The subject_identifier field is added with editable=False. You must provide the correct subject identifier programmatically or the model will raise an RegisteredSubject.DoesNotExist exception on save.

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

Built Distribution

edc_registration-0.2.12-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file edc-registration-0.2.12.macosx-10.13-x86_64.tar.gz.

File metadata

File hashes

Hashes for edc-registration-0.2.12.macosx-10.13-x86_64.tar.gz
Algorithm Hash digest
SHA256 a6c58b715832f22e83803d5ebb990dc182ef602aa1a09a65bc3003d2f2111c63
MD5 c4dcc0d3ceefa584da4806089569d0d9
BLAKE2b-256 2f6b62464fc3638bd99ab8d570f4142d6ec80c202699f93e60a7e696f49f0145

See more details on using hashes here.

File details

Details for the file edc_registration-0.2.12-py3-none-any.whl.

File metadata

File hashes

Hashes for edc_registration-0.2.12-py3-none-any.whl
Algorithm Hash digest
SHA256 da25257897a6ba8df929efe0a5a2d3520cecf3c5cf6b278c684d7498b283a47e
MD5 789f9111dca23fb8eda426f6377ea06e
BLAKE2b-256 e8d27602efe465a844ce3b15b6978f939a43b58ec62a3d7d575768815157e397

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