edc-reference


Nameedc-reference JSON
Version 0.3.28 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-reference
SummaryPivoted reference model for clinicedc/edc modules
upload_time2023-10-09 16:54:43
maintainer
docs_urlNone
authorErik van Widenfelt
requires_python>=3.11
licenseGPL license, see LICENSE
keywords django edc clinicedc clinical trials
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            |pypi| |actions| |coverage|


edc-reference
-------------

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 edc_reference.site_reference import ReferenceModelConfig

    reference = ReferenceModelConfig(
        model='edc_reference.crfone',
        fields=['f1', 'f4'])
    site_reference_configs.register(reference)

Create a model instance:

.. code-block:: python

    crf_one = CrfOne.objects.create(
        subject_visit=subject_visit,
        f1='happiness'
        f4=get_utcnow())

The ``Reference`` model will be updated:


.. code-block:: python

    from edc_reference.models import Reference

    reference = Reference.objects.get(
        identifier=self.subject_identifier,
        timepoint=self.subject_visit.visit_code,
        report_datetime=crf_one.report_datetime,
        field_name='f1')

    >>> 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
    'happiness'

Model managers methods are also available, for example:

.. code-block:: python

    reference = Reference.objects.crf_get_for_visit(
        model='edc_reference.crfone',
        visit=self.subject_visit,
        field_name='f1')

    >>> reference.value
    'happiness'


Accessing pivoted data with ``LongitudinalRefset``
==================================================

 TODO



.. |pypi| image:: https://img.shields.io/pypi/v/edc-reference.svg
    :target: https://pypi.python.org/pypi/edc-reference

.. |actions| image:: https://github.com/clinicedc/edc-reference/workflows/build/badge.svg?branch=develop
  :target: https://github.com/clinicedc/edc-reference/actions?query=workflow:build

.. |coverage| image:: https://coveralls.io/repos/github/clinicedc/edc-reference/badge.svg?branch=develop
    :target: https://coveralls.io/github/clinicedc/edc-reference?branch=develop

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clinicedc/edc-reference",
    "name": "edc-reference",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "django,edc,clinicedc,clinical trials",
    "author": "Erik van Widenfelt",
    "author_email": "ew2789@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/4d/54034f0e23dc5327b4aa3a639257ee8802a0c160e1092f6a7239092def4f/edc-reference-0.3.28.tar.gz",
    "platform": null,
    "description": "|pypi| |actions| |coverage|\n\n\nedc-reference\n-------------\n\nPivoted reference table for EDC modules\n\n``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.\n\nSee also ``edc_metadata_rules``\n\n\nUsage and Configuration\n=======================\n\nDeclare a model with the ``ReferenceModelMixin``.\n\n.. code-block:: python\n\n    from edc_reference.model_mixins import ReferenceModelMixin\n\n    class CrfOne(ReferenceModelMixin, BaseUuidModel):\n\n        subject_visit = models.ForeignKey(SubjectVisit, on_delete=PROTECT)\n\n        report_datetime = models.DateTimeField(default=get_utcnow)\n\n        f1 = models.CharField(max_length=50)\n\n        f2 = models.CharField(max_length=50)\n\n        f3 = models.CharField(max_length=50)\n\n        f4 = models.DatetimeField(null=True)\n\n\nRegister the model and the relevant fields with the site global, ``site_reference_configs``:\n\n.. code-block:: python\n\n    from edc_reference.site_reference import ReferenceModelConfig\n\n    reference = ReferenceModelConfig(\n        model='edc_reference.crfone',\n        fields=['f1', 'f4'])\n    site_reference_configs.register(reference)\n\nCreate a model instance:\n\n.. code-block:: python\n\n    crf_one = CrfOne.objects.create(\n        subject_visit=subject_visit,\n        f1='happiness'\n        f4=get_utcnow())\n\nThe ``Reference`` model will be updated:\n\n\n.. code-block:: python\n\n    from edc_reference.models import Reference\n\n    reference = Reference.objects.get(\n        identifier=self.subject_identifier,\n        timepoint=self.subject_visit.visit_code,\n        report_datetime=crf_one.report_datetime,\n        field_name='f1')\n\n    >>> reference.__dict__\n    { ...\n     'datatype': 'CharField',\n     'field_name': 'f1',\n     'identifier': '1',\n     'model': 'edc_reference.crfone',\n     'report_datetime': datetime.datetime(2017, 7, 7, 13, 30, 6, 545140, tzinfo=<UTC>),\n     'timepoint': 'code',\n     'value_date': None,\n     'value_datetime': None,\n     'value_int': None,\n     'value_str': 'happiness',\n     ...}\n\n\nGet the ``value`` from the reference instance:\n\n.. code-block:: python\n\n    >>> reference.value\n    'happiness'\n\nModel managers methods are also available, for example:\n\n.. code-block:: python\n\n    reference = Reference.objects.crf_get_for_visit(\n        model='edc_reference.crfone',\n        visit=self.subject_visit,\n        field_name='f1')\n\n    >>> reference.value\n    'happiness'\n\n\nAccessing pivoted data with ``LongitudinalRefset``\n==================================================\n\n TODO\n\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-reference.svg\n    :target: https://pypi.python.org/pypi/edc-reference\n\n.. |actions| image:: https://github.com/clinicedc/edc-reference/workflows/build/badge.svg?branch=develop\n  :target: https://github.com/clinicedc/edc-reference/actions?query=workflow:build\n\n.. |coverage| image:: https://coveralls.io/repos/github/clinicedc/edc-reference/badge.svg?branch=develop\n    :target: https://coveralls.io/github/clinicedc/edc-reference?branch=develop\n",
    "bugtrack_url": null,
    "license": "GPL license, see LICENSE",
    "summary": "Pivoted reference model for clinicedc/edc modules",
    "version": "0.3.28",
    "project_urls": {
        "Homepage": "https://github.com/clinicedc/edc-reference"
    },
    "split_keywords": [
        "django",
        "edc",
        "clinicedc",
        "clinical trials"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "254ede8cc9729fe571192a605821ec96117c61b3cc3f8569b06b07bc6cac2ac4",
                "md5": "a70857da33f7155ad121fedd0cd66d01",
                "sha256": "2a975d78385b7797add3f80b74d91cff37e9cbeada97bd5c741d56174e35a07e"
            },
            "downloads": -1,
            "filename": "edc_reference-0.3.28-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a70857da33f7155ad121fedd0cd66d01",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 70851,
            "upload_time": "2023-10-09T16:54:41",
            "upload_time_iso_8601": "2023-10-09T16:54:41.432500Z",
            "url": "https://files.pythonhosted.org/packages/25/4e/de8cc9729fe571192a605821ec96117c61b3cc3f8569b06b07bc6cac2ac4/edc_reference-0.3.28-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c4d54034f0e23dc5327b4aa3a639257ee8802a0c160e1092f6a7239092def4f",
                "md5": "5d1c04e45a7ecc6346d0db14394897cf",
                "sha256": "0b48fac939c523d06f2d67891cf1ddce22bc959f65b732c4690f76df0355246d"
            },
            "downloads": -1,
            "filename": "edc-reference-0.3.28.tar.gz",
            "has_sig": false,
            "md5_digest": "5d1c04e45a7ecc6346d0db14394897cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 54480,
            "upload_time": "2023-10-09T16:54:43",
            "upload_time_iso_8601": "2023-10-09T16:54:43.185199Z",
            "url": "https://files.pythonhosted.org/packages/6c/4d/54034f0e23dc5327b4aa3a639257ee8802a0c160e1092f6a7239092def4f/edc-reference-0.3.28.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-09 16:54:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clinicedc",
    "github_project": "edc-reference",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "edc-reference"
}
        
Elapsed time: 0.12140s