Define clinic facilities for clinicedc/edc projects
Project description
[![Build Status](https://travis-ci.org/clinicedc/edc-facility.svg?branch=develop)](https://travis-ci.org/clinicedc/edc-facility) [![Coverage Status](https://coveralls.io/repos/clinicedc/edc-facility/badge.svg?branch=develop&service=github)](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:
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:
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]:
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.
# 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:
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:
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]:
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.
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.3.macosx-10.13-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a12ed324e3f39fa6f341eb0a041bd348346f801d2b9968f7adbae3eb41788abe |
|
MD5 | 7d0c1e2abf9a0322a665d7f985d6dcb0 |
|
BLAKE2b-256 | ea982ef6ba46c90f70404f62c32d5cada266090d8db0d0c019bda232a43b3331 |
Close
Hashes for edc_facility-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ec888e4aa174c819b5e6bc0f59652ca24f9b7d3d97e5986e28b32f8b5ddf3b4 |
|
MD5 | 110202fa2ea6acb12e72a71a5c756d9b |
|
BLAKE2b-256 | 2cac4f931f7f133d1411c11e9668c318e82f9eaf94d6c81ad0524ea087c9587a |