edc-timepoint


Nameedc-timepoint JSON
Version 0.3.22 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-timepoint
SummaryLock a timepoint from further editing once data is cleaned and reviewed in clinicedc/edc projects
upload_time2024-11-20 22:29:12
maintainerNone
docs_urlNone
authorErik van Widenfelt
requires_python>=3.12
licenseGPL license, see LICENSE
keywords django edc timepoint clinicedc clinical trials
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            |pypi| |actions| |codecov| |downloads|

edc-timepoint
-------------

Lock a "timepoint" from further editing once data is cleaned and reviewed.

With module ``edc_timepoint`` a data manager or supervisor is able to flag a model instance, that represents a timepoint, as closed to further edit. A good candidate for a "timepoint" model is one that is used to cover other data collection, such as an `edc_appointment.Appointment`. When the appointment status is set to something like 'complete' the timepoint status is set to ``closed`` and no further edits are allowed for data covered by that appointment.


Configuring the Timepoint Model
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Select a model that represent a timepoint. The model should at least have a `datetime` field and a `status` field. For example `Appointment`:


.. code-block:: python

    class Appointment(TimepointModelMixin, BaseUuidModel):

        appt_datetime = models.DateTimeField(
            verbose_name='Appointment date and time')

        appt_status = models.CharField(
            verbose_name='Status',
            choices=APPT_STATUS,
            max_length=25,
            default='NEW')

The ``TimepointModelMixin`` adds fields and methods prefixed as ``timepoint_<something>``. There is also a signal that is loaded in the ``AppConfig.ready`` that resets the timepoint attributes should ``Appointment.appt_status`` change from ``DONE``.

Only field ``timepoint_status`` is meant to be edited by the user. The other ``timepoint_<something>`` are managed automatically.

In your projects ``apps.py`` subclass ``edc_timepoint.apps.AppConfig`` and declare ``Appointment`` as a timepoint model by creating a ``Timepoint`` instance and appending it to ``AppConfig.timepoints``:

.. code-block:: python

    from django.apps import AppConfig as DjangoAppConfig

    from edc_timepoint.apps import AppConfig as EdcTimepointAppConfigParent
    from edc_timepoint.timepoint import Timepoint


    class AppConfig(DjangoAppConfig):
        name = 'example'

    class EdcTimepointAppConfig(EdcTimepointAppConfigParent):
        timepoints = TimepointCollection(
            timepoints=[Timepoint(
                model='example.appointment',
                datetime_field='appt_datetime',
                status_field='appt_status',
                closed_status='DONE')])

The user updates the ``Appointment`` normally closing it when the appointment is done. Then a data manager or supervisor can close the ``Appointment`` to further edit once the data has been reviewed.

To close the ``Appointment`` to further edit the code needs to call the ``timepoint_close_timepoint`` method:

.. code-block:: python

    appointment = Appointment.objects.create(**options)
    appointment.appt_status = 'DONE'
    appointment.timepoint_close_timepoint()

If the ``appointment.appt_status`` is not ``DONE`` when ``timepoint_close_timepoint`` is called, a ``TimepointError`` is raised.

If the appointment is successfully closed to further edit, any attempts to call ``appointment.save()`` will raise a ``TimepointError``.

The ``Appointment`` may be re-opened for edit by calling method ``timepoint_open_timepoint``.

Configuring others to use the Timepoint Model
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Continuing with the example above where ``Appointment`` is the timepoint model.

To prevent further edits to models related to ``Appointment``, configure the model with the ``TimepointLookupModelMixin`` and the ``TimepointLookup`` class. These models will refer to the timepoint model on ``save``.

For example:

.. code-block:: python

    class VisitTimepointLookup(TimepointLookup):
        timepoint_related_model_lookup = 'appointment'

    class VisitModel(TimepointLookupModelMixin, BaseUuidModel):

        timepoint_lookup_cls = VisitTimepointLookup

        appointment = models.ForeignKey(Appointment)

        report_datetime = models.DateTimeField(
            default=timezone.now)

If the timepoint model's ``timepoint_status`` is ``closed``, any attempt to create or modify ``VisitModel`` will raise a ``TimepointClosed`` exception.



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

.. |actions| image:: https://github.com/clinicedc/edc-timepoint/actions/workflows/build.yml/badge.svg
  :target: https://github.com/clinicedc/edc-timepoint/actions/workflows/build.yml

.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-timepoint/branch/develop/graph/badge.svg
  :target: https://codecov.io/gh/clinicedc/edc-timepoint

.. |downloads| image:: https://pepy.tech/badge/edc-timepoint
   :target: https://pepy.tech/project/edc-timepoint

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clinicedc/edc-timepoint",
    "name": "edc-timepoint",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "django Edc timepoint, clinicedc, clinical trials",
    "author": "Erik van Widenfelt",
    "author_email": "ew2789@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0b/82/ed8c473cc6ad4885376335261e544b6167aa1514be127815dba1f47017f1/edc_timepoint-0.3.22.tar.gz",
    "platform": null,
    "description": "|pypi| |actions| |codecov| |downloads|\n\nedc-timepoint\n-------------\n\nLock a \"timepoint\" from further editing once data is cleaned and reviewed.\n\nWith module ``edc_timepoint`` a data manager or supervisor is able to flag a model instance, that represents a timepoint, as closed to further edit. A good candidate for a \"timepoint\" model is one that is used to cover other data collection, such as an `edc_appointment.Appointment`. When the appointment status is set to something like 'complete' the timepoint status is set to ``closed`` and no further edits are allowed for data covered by that appointment.\n\n\nConfiguring the Timepoint Model\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSelect a model that represent a timepoint. The model should at least have a `datetime` field and a `status` field. For example `Appointment`:\n\n\n.. code-block:: python\n\n    class Appointment(TimepointModelMixin, BaseUuidModel):\n\n        appt_datetime = models.DateTimeField(\n            verbose_name='Appointment date and time')\n\n        appt_status = models.CharField(\n            verbose_name='Status',\n            choices=APPT_STATUS,\n            max_length=25,\n            default='NEW')\n\nThe ``TimepointModelMixin`` adds fields and methods prefixed as ``timepoint_<something>``. There is also a signal that is loaded in the ``AppConfig.ready`` that resets the timepoint attributes should ``Appointment.appt_status`` change from ``DONE``.\n\nOnly field ``timepoint_status`` is meant to be edited by the user. The other ``timepoint_<something>`` are managed automatically.\n\nIn your projects ``apps.py`` subclass ``edc_timepoint.apps.AppConfig`` and declare ``Appointment`` as a timepoint model by creating a ``Timepoint`` instance and appending it to ``AppConfig.timepoints``:\n\n.. code-block:: python\n\n    from django.apps import AppConfig as DjangoAppConfig\n\n    from edc_timepoint.apps import AppConfig as EdcTimepointAppConfigParent\n    from edc_timepoint.timepoint import Timepoint\n\n\n    class AppConfig(DjangoAppConfig):\n        name = 'example'\n\n    class EdcTimepointAppConfig(EdcTimepointAppConfigParent):\n        timepoints = TimepointCollection(\n            timepoints=[Timepoint(\n                model='example.appointment',\n                datetime_field='appt_datetime',\n                status_field='appt_status',\n                closed_status='DONE')])\n\nThe user updates the ``Appointment`` normally closing it when the appointment is done. Then a data manager or supervisor can close the ``Appointment`` to further edit once the data has been reviewed.\n\nTo close the ``Appointment`` to further edit the code needs to call the ``timepoint_close_timepoint`` method:\n\n.. code-block:: python\n\n    appointment = Appointment.objects.create(**options)\n    appointment.appt_status = 'DONE'\n    appointment.timepoint_close_timepoint()\n\nIf the ``appointment.appt_status`` is not ``DONE`` when ``timepoint_close_timepoint`` is called, a ``TimepointError`` is raised.\n\nIf the appointment is successfully closed to further edit, any attempts to call ``appointment.save()`` will raise a ``TimepointError``.\n\nThe ``Appointment`` may be re-opened for edit by calling method ``timepoint_open_timepoint``.\n\nConfiguring others to use the Timepoint Model\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nContinuing with the example above where ``Appointment`` is the timepoint model.\n\nTo prevent further edits to models related to ``Appointment``, configure the model with the ``TimepointLookupModelMixin`` and the ``TimepointLookup`` class. These models will refer to the timepoint model on ``save``.\n\nFor example:\n\n.. code-block:: python\n\n    class VisitTimepointLookup(TimepointLookup):\n        timepoint_related_model_lookup = 'appointment'\n\n    class VisitModel(TimepointLookupModelMixin, BaseUuidModel):\n\n        timepoint_lookup_cls = VisitTimepointLookup\n\n        appointment = models.ForeignKey(Appointment)\n\n        report_datetime = models.DateTimeField(\n            default=timezone.now)\n\nIf the timepoint model's ``timepoint_status`` is ``closed``, any attempt to create or modify ``VisitModel`` will raise a ``TimepointClosed`` exception.\n\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-timepoint.svg\n    :target: https://pypi.python.org/pypi/edc-timepoint\n\n.. |actions| image:: https://github.com/clinicedc/edc-timepoint/actions/workflows/build.yml/badge.svg\n  :target: https://github.com/clinicedc/edc-timepoint/actions/workflows/build.yml\n\n.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-timepoint/branch/develop/graph/badge.svg\n  :target: https://codecov.io/gh/clinicedc/edc-timepoint\n\n.. |downloads| image:: https://pepy.tech/badge/edc-timepoint\n   :target: https://pepy.tech/project/edc-timepoint\n",
    "bugtrack_url": null,
    "license": "GPL license, see LICENSE",
    "summary": "Lock a timepoint from further editing once data is cleaned and reviewed in clinicedc/edc projects",
    "version": "0.3.22",
    "project_urls": {
        "Homepage": "https://github.com/clinicedc/edc-timepoint"
    },
    "split_keywords": [
        "django edc timepoint",
        " clinicedc",
        " clinical trials"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "deebd84f2575e319b3258845109d2a27061df66343d770d0c300b5b29e199867",
                "md5": "2a6a54f5c67287ff9a09f1debaf3d314",
                "sha256": "07cb39409097d149bac4a3666796d8b35fcf01b15573b9ab73e82ba452c80050"
            },
            "downloads": -1,
            "filename": "edc_timepoint-0.3.22-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2a6a54f5c67287ff9a09f1debaf3d314",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 32652,
            "upload_time": "2024-11-20T22:29:10",
            "upload_time_iso_8601": "2024-11-20T22:29:10.199120Z",
            "url": "https://files.pythonhosted.org/packages/de/eb/d84f2575e319b3258845109d2a27061df66343d770d0c300b5b29e199867/edc_timepoint-0.3.22-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b82ed8c473cc6ad4885376335261e544b6167aa1514be127815dba1f47017f1",
                "md5": "423e85c8b471bd402f8c326815e4e822",
                "sha256": "580a488ab45ef14402b50833c11f797c03e5bfba2593826f3f6f30ce0b07c0ff"
            },
            "downloads": -1,
            "filename": "edc_timepoint-0.3.22.tar.gz",
            "has_sig": false,
            "md5_digest": "423e85c8b471bd402f8c326815e4e822",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 33740,
            "upload_time": "2024-11-20T22:29:12",
            "upload_time_iso_8601": "2024-11-20T22:29:12.028604Z",
            "url": "https://files.pythonhosted.org/packages/0b/82/ed8c473cc6ad4885376335261e544b6167aa1514be127815dba1f47017f1/edc_timepoint-0.3.22.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-20 22:29:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clinicedc",
    "github_project": "edc-timepoint",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "edc-timepoint"
}
        
Elapsed time: 0.33336s