Skip to main content

Define clinic facilities for clinicedc/edc projects

Project description

|pypi| |travis| |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 .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 = timezone.make_aware(datetime(2015, 9, 24), timezone=pytz.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.



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

.. |travis| image:: https://travis-ci.org/clinicedc/edc-facility.svg?branch=develop
:target: https://travis-ci.org/clinicedc/edc-facility

.. |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


Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

edc_facility-0.1.13-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file edc_facility-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: edc_facility-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for edc_facility-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 791ba77e799905ee7688283666c55217d1a4f73278be72373abf43e8de39af4c
MD5 8cd883d6091295e5b67427c28efbcc79
BLAKE2b-256 5454ea5786dbb0916e4fd70753b839371bbad7bdadc999635bdacf2496a1358e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page