Skip to main content

Pivoted reference model for clinicedc/edc modules

Project description

|pypi| |travis| |coverage|


Pivoted reference table for EDC modules

``edc_reference`` creates a pivoted table of CRF and Requisition records with a small subset of values that can be efficiently referenced. The module is used by ``edc_metadata_rules`` to quickly determine if a CRF or Requisition model instance exists avoiding the need to query each individual model class.

See also ``edc_metadata_rules``

Usage and Configuration

Declare a model with the ``ReferenceModelMixin``.

.. code-block:: python

from edc_reference.model_mixins import ReferenceModelMixin

class CrfOne(ReferenceModelMixin, BaseUuidModel):

subject_visit = models.ForeignKey(SubjectVisit, on_delete=PROTECT)

report_datetime = models.DateTimeField(default=get_utcnow)

f1 = models.CharField(max_length=50)

f2 = models.CharField(max_length=50)

f3 = models.CharField(max_length=50)

f4 = models.DatetimeField(null=True)

Register the model and the relevant fields with the site global, ``site_reference_configs``:

.. code-block:: python

from import ReferenceModelConfig

reference = ReferenceModelConfig(
fields=['f1', 'f4'])

Create a model instance:

.. code-block:: python

crf_one = CrfOne.objects.create(

The ``Reference`` model will be updated:

.. code-block:: python

from edc_reference.models import Reference

reference = Reference.objects.get(

>>> reference.__dict__
{ ...
'datatype': 'CharField',
'field_name': 'f1',
'identifier': '1',
'model': 'edc_reference.crfone',
'report_datetime': datetime.datetime(2017, 7, 7, 13, 30, 6, 545140, tzinfo=<UTC>),
'timepoint': 'code',
'value_date': None,
'value_datetime': None,
'value_int': None,
'value_str': 'happiness',

Get the ``value`` from the reference instance:

.. code-block:: python

>>> reference.value

Model managers methods are also available, for example:

.. code-block:: python

reference = Reference.objects.crf_get_for_visit(

>>> reference.value

Accessing pivoted data with ``LongitudinalRefset``


.. |pypi| image::

.. |travis| image::

.. |coverage| image::

Project details

Download files

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

Files for edc-reference, version 0.1.16
Filename, size File type Python version Upload date Hashes
Filename, size edc-reference-0.1.16.macosx-10.13-x86_64.tar.gz (60.2 kB) File type Source Python version None Upload date Hashes View
Filename, size edc_reference-0.1.16-py3-none-any.whl (37.8 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page