edc-facility


Nameedc-facility JSON
Version 0.3.38 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-facility
SummaryDefine clinic facilities for clinicedc/edc projects
upload_time2024-11-20 22:50:13
maintainerNone
docs_urlNone
authorErik van Widenfelt
requires_python>=3.12
licenseGPL license, see LICENSE
keywords django edc clinic facility clinicedc clinical trials
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            |pypi| |actions| |codecov| |downloads|


edc-facility
------------

Loading holidays
++++++++++++++++

To load the list of holidays into the system:

.. code-block:: python

    python manage.py import_holidays


Customizing appointment scheduling by ``Facility``
++++++++++++++++++++++++++++++++++++++++++++++++++

Appointment scheduling can be customized per ``facility`` or clinic:

Add each facility to ``app_config.facilities`` specifying the facility ``name``, ``days`` open and the maximum number of ``slots`` available per day:

.. code-block:: python

    from edc_facility.apps import AppConfig as EdcAppointmentAppConfig

    class AppConfig(EdcAppointmentAppConfig):

        facilities = {
            'clinic1': Facility(name='clinic', days=[MO, TU, WE, TH, FR], slots=[100, 100, 100, 100, 100])}
            'clinic2': Facility(name='clinic', days=[MO, WE, FR], slots=[30, 30, 30])}

To schedule an appointment that falls on a day that the clinic is open, isn't a holiday and isn't already over-booked:

.. code-block:: python

    from edc_utils import get_utcnow
    from .facility import Facility

    suggested_datetime = get_utcnow()
    available_datetime = facility.available_datetime(suggested_datetime)


If holidays are entered (in model ``Holiday``) and the appointment lands on a holiday, the appointment date is incremented forward to an allowed weekday. Assuming ``facility`` is configured in ``app_config`` to only schedule appointments on [TU, TH]:

.. code-block:: python

    from datetime import datetime
    from dateutil.relativedelta import TU, TH
    from django.conf import settings
    from django.utils import timezone
    from zoneifo import ZoneInfo

    from .facility import Facility
    from .models import Holiday

    Holiday.objects.create(
        name='Id-ul-Adha (Feast of the Sacrifice)',
        date=date(2015, 9, 24)
    )
    suggested_datetime = datetime(2015, 9, 24, tzinfo=ZoneInfo("UTC"))  # TH
    available_datetime = facility.available_datetime(suggested_datetime)
    print(available_datetime)  # 2015-09-29 00:00:00, TU

The maximum number of possible scheduling slots per day is configured in ``app_config``. As with the holiday example above, the appointment date will be incremented forward to a day with an available slot.


System checks
+++++++++++++
* ``edc_facility.001`` Holiday file not set! settings.HOLIDAY_FILE not defined.
* ``edc_facility.002`` Holiday file not found.
* ``edc_facility.003`` Holiday table is empty. Run management command 'import_holidays'.
* ``edc_facility.004`` No Holidays have been defined for this country.


HealthFacility model
++++++++++++++++++++

The ``HealthFacility`` model is used by ``edc-next-appointment`` when reporting the next routine
appointment for a participant. This is important for trials that collect data at routine clinic appointments
not set by the research staff or defined by the protocol.

See also ``edc-next-appointment``.

If you need to customize the model, declare the concrete model locally in your app. You can use the mixins to build
your own classes.

You'll also need to update ``settings`` to tell ``edc_facility`` where the custom model is::

    EDC_FACILITY_HEALTH_FACILITY_MODEL = "myapp.healthfacility"


For example:

.. code-block:: python

    # models.py
    class HealthFacility(SiteModelMixin, HealthFacilityModelMixin, BaseUuidModel):

        objects = Manager()
        on_site = CurrentSiteManager()
        history = HistoricalRecords()

        class Meta(SiteModelMixin.Meta, BaseUuidModel.Meta):
            verbose_name = "Health Facility"
            verbose_name_plural = "Health Facilities"

.. code-block:: python

    # forms.py
    class HealthFacilityForm(FormValidatorMixin, forms.ModelForm):
        form_validator_cls = HealthFacilityFormValidator

        class Meta:
            model = HealthFacility
            fields = "__all__"

.. code-block:: python

    # admin.py
    @admin.register(HealthFacility, site=intecomm_facility_admin)
    class HealthFacilityAdmin(
        HealthFacilityModelAdminMixin,
        SiteModelAdminMixin,
        BaseModelAdminMixin,
    ):
        form = HealthFacilityForm

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

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

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

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clinicedc/edc-facility",
    "name": "edc-facility",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "django Edc clinic facility clinicedc, clinical trials",
    "author": "Erik van Widenfelt",
    "author_email": "ew2789@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/68/28/58781f4a43259c3e3703ce92666ff66d09b77e5b09a8ab2462d910347fb9/edc_facility-0.3.38.tar.gz",
    "platform": null,
    "description": "|pypi| |actions| |codecov| |downloads|\n\n\nedc-facility\n------------\n\nLoading holidays\n++++++++++++++++\n\nTo load the list of holidays into the system:\n\n.. code-block:: python\n\n    python manage.py import_holidays\n\n\nCustomizing appointment scheduling by ``Facility``\n++++++++++++++++++++++++++++++++++++++++++++++++++\n\nAppointment scheduling can be customized per ``facility`` or clinic:\n\nAdd each facility to ``app_config.facilities`` specifying the facility ``name``, ``days`` open and the maximum number of ``slots`` available per day:\n\n.. code-block:: python\n\n    from edc_facility.apps import AppConfig as EdcAppointmentAppConfig\n\n    class AppConfig(EdcAppointmentAppConfig):\n\n        facilities = {\n            'clinic1': Facility(name='clinic', days=[MO, TU, WE, TH, FR], slots=[100, 100, 100, 100, 100])}\n            'clinic2': Facility(name='clinic', days=[MO, WE, FR], slots=[30, 30, 30])}\n\nTo schedule an appointment that falls on a day that the clinic is open, isn't a holiday and isn't already over-booked:\n\n.. code-block:: python\n\n    from edc_utils import get_utcnow\n    from .facility import Facility\n\n    suggested_datetime = get_utcnow()\n    available_datetime = facility.available_datetime(suggested_datetime)\n\n\nIf holidays are entered (in model ``Holiday``) and the appointment lands on a holiday, the appointment date is incremented forward to an allowed weekday. Assuming ``facility`` is configured in ``app_config`` to only schedule appointments on [TU, TH]:\n\n.. code-block:: python\n\n    from datetime import datetime\n    from dateutil.relativedelta import TU, TH\n    from django.conf import settings\n    from django.utils import timezone\n    from zoneifo import ZoneInfo\n\n    from .facility import Facility\n    from .models import Holiday\n\n    Holiday.objects.create(\n        name='Id-ul-Adha (Feast of the Sacrifice)',\n        date=date(2015, 9, 24)\n    )\n    suggested_datetime = datetime(2015, 9, 24, tzinfo=ZoneInfo(\"UTC\"))  # TH\n    available_datetime = facility.available_datetime(suggested_datetime)\n    print(available_datetime)  # 2015-09-29 00:00:00, TU\n\nThe maximum number of possible scheduling slots per day is configured in ``app_config``. As with the holiday example above, the appointment date will be incremented forward to a day with an available slot.\n\n\nSystem checks\n+++++++++++++\n* ``edc_facility.001`` Holiday file not set! settings.HOLIDAY_FILE not defined.\n* ``edc_facility.002`` Holiday file not found.\n* ``edc_facility.003`` Holiday table is empty. Run management command 'import_holidays'.\n* ``edc_facility.004`` No Holidays have been defined for this country.\n\n\nHealthFacility model\n++++++++++++++++++++\n\nThe ``HealthFacility`` model is used by ``edc-next-appointment`` when reporting the next routine\nappointment for a participant. This is important for trials that collect data at routine clinic appointments\nnot set by the research staff or defined by the protocol.\n\nSee also ``edc-next-appointment``.\n\nIf you need to customize the model, declare the concrete model locally in your app. You can use the mixins to build\nyour own classes.\n\nYou'll also need to update ``settings`` to tell ``edc_facility`` where the custom model is::\n\n    EDC_FACILITY_HEALTH_FACILITY_MODEL = \"myapp.healthfacility\"\n\n\nFor example:\n\n.. code-block:: python\n\n    # models.py\n    class HealthFacility(SiteModelMixin, HealthFacilityModelMixin, BaseUuidModel):\n\n        objects = Manager()\n        on_site = CurrentSiteManager()\n        history = HistoricalRecords()\n\n        class Meta(SiteModelMixin.Meta, BaseUuidModel.Meta):\n            verbose_name = \"Health Facility\"\n            verbose_name_plural = \"Health Facilities\"\n\n.. code-block:: python\n\n    # forms.py\n    class HealthFacilityForm(FormValidatorMixin, forms.ModelForm):\n        form_validator_cls = HealthFacilityFormValidator\n\n        class Meta:\n            model = HealthFacility\n            fields = \"__all__\"\n\n.. code-block:: python\n\n    # admin.py\n    @admin.register(HealthFacility, site=intecomm_facility_admin)\n    class HealthFacilityAdmin(\n        HealthFacilityModelAdminMixin,\n        SiteModelAdminMixin,\n        BaseModelAdminMixin,\n    ):\n        form = HealthFacilityForm\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-facility.svg\n    :target: https://pypi.python.org/pypi/edc-facility\n\n.. |actions| image:: https://github.com/clinicedc/edc-facility/actions/workflows/build.yml/badge.svg\n  :target: https://github.com/clinicedc/edc-facility/actions/workflows/build.yml\n\n.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-facility/branch/develop/graph/badge.svg\n  :target: https://codecov.io/gh/clinicedc/edc-facility\n\n.. |downloads| image:: https://pepy.tech/badge/edc-facility\n   :target: https://pepy.tech/project/edc-facility\n",
    "bugtrack_url": null,
    "license": "GPL license, see LICENSE",
    "summary": "Define clinic facilities for clinicedc/edc projects",
    "version": "0.3.38",
    "project_urls": {
        "Homepage": "https://github.com/clinicedc/edc-facility"
    },
    "split_keywords": [
        "django edc clinic facility clinicedc",
        " clinical trials"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "418c6af6aa4a78976ebcb0d43c156dcb26d325c771cc5c7b9664e06b7dc14952",
                "md5": "42b6b4bfb2e7eaf0da34ef7c9b7b5f52",
                "sha256": "0586bb1ad5181d418d505272135d955c419e5ff2c751cd3816c164ef2194378c"
            },
            "downloads": -1,
            "filename": "edc_facility-0.3.38-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "42b6b4bfb2e7eaf0da34ef7c9b7b5f52",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 55859,
            "upload_time": "2024-11-20T22:50:12",
            "upload_time_iso_8601": "2024-11-20T22:50:12.123477Z",
            "url": "https://files.pythonhosted.org/packages/41/8c/6af6aa4a78976ebcb0d43c156dcb26d325c771cc5c7b9664e06b7dc14952/edc_facility-0.3.38-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "682858781f4a43259c3e3703ce92666ff66d09b77e5b09a8ab2462d910347fb9",
                "md5": "aa95f8ae09641ee292bf66f6297a8b19",
                "sha256": "1a1a0dcf69a5d79ecd017af8a3d252eeafd9770850281e8cb835c98fa508f43f"
            },
            "downloads": -1,
            "filename": "edc_facility-0.3.38.tar.gz",
            "has_sig": false,
            "md5_digest": "aa95f8ae09641ee292bf66f6297a8b19",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 45937,
            "upload_time": "2024-11-20T22:50:13",
            "upload_time_iso_8601": "2024-11-20T22:50:13.289633Z",
            "url": "https://files.pythonhosted.org/packages/68/28/58781f4a43259c3e3703ce92666ff66d09b77e5b09a8ab2462d910347fb9/edc_facility-0.3.38.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-20 22:50:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clinicedc",
    "github_project": "edc-facility",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "edc-facility"
}
        
Elapsed time: 0.57462s