Skip to main content

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:

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:

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:

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:

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.

Metadata

Release files for edc-timepoint 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for edc-timepoint 1.0.1
File Size Uploaded
edc_timepoint-1.0.1.tar.gz 34.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for edc-timepoint 1.0.1
File Interpreter ABI Platform
edc_timepoint-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 67.6 kB

Release files / edc_timepoint-1.0.1.tar.gz

Download URL edc_timepoint-1.0.1.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1e6999d0119ec3a6139b70a22abb1ee175b8b05d95f983bbdaab6c5acf4ca64a
BLAKE2b-256 checksum
How to use checksums
45dc6b5d59bae4f2a687d6cb937823630fbb09cfa304d800a9cdc2f385a0e17d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / edc_timepoint-1.0.1-py3-none-any.whl

Download URL edc_timepoint-1.0.1-py3-none-any.whl
Size 33.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d72766fb7431849b5f44ccc578d2da00eebf534b3d6fcbf5d116fedf009b719
BLAKE2b-256 checksum
How to use checksums
533ee6dc05043fe9e4b723cf34ef3d2489bafed85f805f1d6a01daa3264c9f23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.3.22

2 release files

0.3.21

2 release files

0.3.19

2 release files

0.3.18

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.11

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.1.17

1 release file

0.1.16

1 release file

0.1.15

1 release file

0.1.14

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page