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
File details
Details for the file edc-facility-0.1.7.macosx-10.13-x86_64.tar.gz
.
File metadata
- Download URL: edc-facility-0.1.7.macosx-10.13-x86_64.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 079d6a9822c760699cde5b1f112f89d978687b4ea89fc0e3a6a6d8e096d80814 |
|
MD5 | 2762bcfeb6f59ecb683375d3ef3166d3 |
|
BLAKE2b-256 | 6e88485d1c80bbc092d8f9fb66770785569e579cad0a8b62cbdeba65dc206620 |
File details
Details for the file edc_facility-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: edc_facility-0.1.7-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 832c23696449cd6b336d2f29f9044207734ffbc086dc1d56dd5ad63ec4b33906 |
|
MD5 | 95143803648777c5b4331169891f4606 |
|
BLAKE2b-256 | 523e9badee53019342cb8b250ea47959b01fa3c98878f0bc7f3ad4d8ff6e65aa |