Define clinic facilities for clinicedc/edc projects
Project description
edc-facility
Loading holidays
To load the list of holidays into the system:
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:
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_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.
System checks
edc_facility.001 Holiday file not found! 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.
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 Distributions
Built Distribution
File details
Details for the file edc_facility-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: edc_facility-0.3.2-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdc4f926ccfe0654b1731307fd5c9f16c12c2ef8596bfbbf573b9d816edc17d4 |
|
MD5 | 0f52556be6511be08c208b21d594ba25 |
|
BLAKE2b-256 | e75cae1665555b8c6afd4115e8556c0e95d21990049508f272931b09adb437f5 |