|pypi| |actions| |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 zoneifo import ZoneInfo
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 = datetime(2015, 9, 24, tzinfo=ZoneInfo("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 set! 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.
HealthFacility model
++++++++++++++++++++
The ``HealthFacility`` model is used by ``edc-next-appointment`` when reporting the next routine
appointment for a participant. This is important for trials that collect data at routine clinic appointments
not set by the research staff or defined by the protocol.
See also ``edc-next-appointment``.
If you need to customize the model, declare the concrete model locally in your app. You can use the mixins to build
your own classes.
You'll also need to update ``settings`` to tell ``edc_facility`` where the custom model is::
EDC_FACILITY_HEALTH_FACILITY_MODEL = "myapp.healthfacility"
For example:
.. code-block:: python
# models.py
class HealthFacility(SiteModelMixin, HealthFacilityModelMixin, BaseUuidModel):
objects = Manager()
on_site = CurrentSiteManager()
history = HistoricalRecords()
class Meta(SiteModelMixin.Meta, BaseUuidModel.Meta):
verbose_name = "Health Facility"
verbose_name_plural = "Health Facilities"
.. code-block:: python
# forms.py
class HealthFacilityForm(FormValidatorMixin, forms.ModelForm):
form_validator_cls = HealthFacilityFormValidator
class Meta:
model = HealthFacility
fields = "__all__"
.. code-block:: python
# admin.py
@admin.register(HealthFacility, site=intecomm_facility_admin)
class HealthFacilityAdmin(
HealthFacilityModelAdminMixin,
SiteModelAdminMixin,
BaseModelAdminMixin,
):
form = HealthFacilityForm
.. |pypi| image:: https://img.shields.io/pypi/v/edc-facility.svg
:target: https://pypi.python.org/pypi/edc-facility
.. |actions| image:: https://github.com/clinicedc/edc-facility/actions/workflows/build.yml/badge.svg
:target: https://github.com/clinicedc/edc-facility/actions/workflows/build.yml
.. |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
Raw data
{
"_id": null,
"home_page": "https://github.com/clinicedc/edc-facility",
"name": "edc-facility",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "django Edc clinic facility clinicedc, clinical trials",
"author": "Erik van Widenfelt",
"author_email": "ew2789@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/53/b5/a442a3d6feaa49a4675839bf51bae50d98dd6d05ce86f2af9ddd7ef9f0ab/edc-facility-0.3.37.tar.gz",
"platform": null,
"description": "|pypi| |actions| |codecov| |downloads|\n\n\nedc-facility\n------------\n\nLoading holidays\n++++++++++++++++\n\nTo load the list of holidays into the system:\n\n.. code-block:: python\n\n python manage.py import_holidays\n\n\nCustomizing appointment scheduling by ``Facility``\n++++++++++++++++++++++++++++++++++++++++++++++++++\n\nAppointment scheduling can be customized per ``facility`` or clinic:\n\nAdd each facility to ``app_config.facilities`` specifying the facility ``name``, ``days`` open and the maximum number of ``slots`` available per day:\n\n.. code-block:: python\n\n from edc_facility.apps import AppConfig as EdcAppointmentAppConfig\n\n class AppConfig(EdcAppointmentAppConfig):\n\n facilities = {\n 'clinic1': Facility(name='clinic', days=[MO, TU, WE, TH, FR], slots=[100, 100, 100, 100, 100])}\n 'clinic2': Facility(name='clinic', days=[MO, WE, FR], slots=[30, 30, 30])}\n\nTo schedule an appointment that falls on a day that the clinic is open, isn't a holiday and isn't already over-booked:\n\n.. code-block:: python\n\n from edc_utils import get_utcnow\n from .facility import Facility\n\n suggested_datetime = get_utcnow()\n available_datetime = facility.available_datetime(suggested_datetime)\n\n\nIf 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]:\n\n.. code-block:: python\n\n from datetime import datetime\n from dateutil.relativedelta import TU, TH\n from django.conf import settings\n from django.utils import timezone\n from zoneifo import ZoneInfo\n\n from .facility import Facility\n from .models import Holiday\n\n Holiday.objects.create(\n name='Id-ul-Adha (Feast of the Sacrifice)',\n date=date(2015, 9, 24)\n )\n suggested_datetime = datetime(2015, 9, 24, tzinfo=ZoneInfo(\"UTC\")) # TH\n available_datetime = facility.available_datetime(suggested_datetime)\n print(available_datetime) # 2015-09-29 00:00:00, TU\n\nThe 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.\n\n\nSystem checks\n+++++++++++++\n* ``edc_facility.001`` Holiday file not set! settings.HOLIDAY_FILE not defined.\n* ``edc_facility.002`` Holiday file not found.\n* ``edc_facility.003`` Holiday table is empty. Run management command 'import_holidays'.\n* ``edc_facility.004`` No Holidays have been defined for this country.\n\n\nHealthFacility model\n++++++++++++++++++++\n\nThe ``HealthFacility`` model is used by ``edc-next-appointment`` when reporting the next routine\nappointment for a participant. This is important for trials that collect data at routine clinic appointments\nnot set by the research staff or defined by the protocol.\n\nSee also ``edc-next-appointment``.\n\nIf you need to customize the model, declare the concrete model locally in your app. You can use the mixins to build\nyour own classes.\n\nYou'll also need to update ``settings`` to tell ``edc_facility`` where the custom model is::\n\n EDC_FACILITY_HEALTH_FACILITY_MODEL = \"myapp.healthfacility\"\n\n\nFor example:\n\n.. code-block:: python\n\n # models.py\n class HealthFacility(SiteModelMixin, HealthFacilityModelMixin, BaseUuidModel):\n\n objects = Manager()\n on_site = CurrentSiteManager()\n history = HistoricalRecords()\n\n class Meta(SiteModelMixin.Meta, BaseUuidModel.Meta):\n verbose_name = \"Health Facility\"\n verbose_name_plural = \"Health Facilities\"\n\n.. code-block:: python\n\n # forms.py\n class HealthFacilityForm(FormValidatorMixin, forms.ModelForm):\n form_validator_cls = HealthFacilityFormValidator\n\n class Meta:\n model = HealthFacility\n fields = \"__all__\"\n\n.. code-block:: python\n\n # admin.py\n @admin.register(HealthFacility, site=intecomm_facility_admin)\n class HealthFacilityAdmin(\n HealthFacilityModelAdminMixin,\n SiteModelAdminMixin,\n BaseModelAdminMixin,\n ):\n form = HealthFacilityForm\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-facility.svg\n :target: https://pypi.python.org/pypi/edc-facility\n\n.. |actions| image:: https://github.com/clinicedc/edc-facility/actions/workflows/build.yml/badge.svg\n :target: https://github.com/clinicedc/edc-facility/actions/workflows/build.yml\n\n.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-facility/branch/develop/graph/badge.svg\n :target: https://codecov.io/gh/clinicedc/edc-facility\n\n.. |downloads| image:: https://pepy.tech/badge/edc-facility\n :target: https://pepy.tech/project/edc-facility\n",
"bugtrack_url": null,
"license": "GPL license, see LICENSE",
"summary": "Define clinic facilities for clinicedc/edc projects",
"version": "0.3.37",
"project_urls": {
"Homepage": "https://github.com/clinicedc/edc-facility"
},
"split_keywords": [
"django edc clinic facility clinicedc",
" clinical trials"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "331379611e59e150e1bc295ea31bd61ec0abf0c56c06c63d6726f7e0331827e4",
"md5": "6a5989ed305a870d5892264c97cfd6a1",
"sha256": "9f35de05b85c3ee44afcbed9a3025bd22edde55ea76b4822cd7e2e460e491619"
},
"downloads": -1,
"filename": "edc_facility-0.3.37-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6a5989ed305a870d5892264c97cfd6a1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 55861,
"upload_time": "2024-03-27T03:49:30",
"upload_time_iso_8601": "2024-03-27T03:49:30.946137Z",
"url": "https://files.pythonhosted.org/packages/33/13/79611e59e150e1bc295ea31bd61ec0abf0c56c06c63d6726f7e0331827e4/edc_facility-0.3.37-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "53b5a442a3d6feaa49a4675839bf51bae50d98dd6d05ce86f2af9ddd7ef9f0ab",
"md5": "7fb73df45b8b9b33b53ee69ea462fa80",
"sha256": "8c4413e942f1ae0ffc4e479938b771c16c7832536524fc93b5ee5cafdce30fd8"
},
"downloads": -1,
"filename": "edc-facility-0.3.37.tar.gz",
"has_sig": false,
"md5_digest": "7fb73df45b8b9b33b53ee69ea462fa80",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 45848,
"upload_time": "2024-03-27T03:49:33",
"upload_time_iso_8601": "2024-03-27T03:49:33.112996Z",
"url": "https://files.pythonhosted.org/packages/53/b5/a442a3d6feaa49a4675839bf51bae50d98dd6d05ce86f2af9ddd7ef9f0ab/edc-facility-0.3.37.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 03:49:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "clinicedc",
"github_project": "edc-facility",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "edc-facility"
}