Define clinic facilities for clinicedc/edc projects
Project description
|pypi| |travis| |coverage|
edc-facility
------------
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_base.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
.. |coverage| image:: https://coveralls.io/repos/github/clinicedc/edc-facility/badge.svg?branch=develop
:target: https://coveralls.io/github/clinicedc/edc-facility?branch=develop
edc-facility
------------
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_base.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
.. |coverage| image:: https://coveralls.io/repos/github/clinicedc/edc-facility/badge.svg?branch=develop
:target: https://coveralls.io/github/clinicedc/edc-facility?branch=develop
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for edc-facility-0.1.5.macosx-10.13-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | eda8c262f38e449b6fa541f4ab1fd2f6f16f07eb7f6558618377a7f271e1526d |
|
MD5 | ddcbf4cf1e93c0029fda5ee263d145c0 |
|
BLAKE2b-256 | 12d1d5cd592d1ec47d6c30f2a354ce4e28e9591fafad2a67022e987b2824585b |
Close
Hashes for edc_facility-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b1d12b33c7a5ccaaa1e5f97bf82b4d9e34f9bd9bc2530aa143d7117c0d30687 |
|
MD5 | 74ff4627a4bda8209f02ff7617677baf |
|
BLAKE2b-256 | 3b63051b1686cbd2c46d73a2fc2de74cf05aeca8e6ea52c5750813c073f51699 |