Automatic calendar events

For every contract, Lino Welfare automatically generates a series of calendar events for evaluation meetings.

Side note: Code snippets (lines starting with >>>) in this document get tested as part of our development workflow. The following initialization snippet tells you which demo project is being used in this document.

>>> from lino import startup
>>> startup('lino_welfare.projects.gerd.settings.doctests')
>>> from lino.api.doctest import *
>>> translation.activate("en")

Plugin configuration

Some local settings which influence automatic generation of calendar events:

>>> print(dd.plugins.cal.ignore_dates_before)
None
>>> print(str(dd.plugins.cal.ignore_dates_after))
2019-05-22

Evaluation events

The EntriesByController table shows the evaluation events which have been generated.

>>> settings.SITE.site_config.update(hide_events_before=None)

For example let’s look at ISIP contract #26 of the demo database.

>>> obj = isip.Contract.objects.get(pk=26)
>>> obj.exam_policy
ExamPolicy #1 ('Every month')
>>> rt.show(cal.EntriesByController, obj)
... 
================================ =================== ================= ===== =================
 When                             Short description   Managed by        No.   Workflow
-------------------------------- ------------------- ----------------- ----- -----------------
 `Mon 15/06/2015 (09:00) <…>`__   Évaluation 10       Alicia Allmanns   10    **? Suggested**
 `Wed 13/05/2015 (09:00) <…>`__   Évaluation 9        Alicia Allmanns   9     **? Suggested**
 `Mon 13/04/2015 (09:00) <…>`__   Évaluation 8        Alicia Allmanns   8     **? Suggested**
 `Thu 12/03/2015 (09:00) <…>`__   Évaluation 7        Alicia Allmanns   7     **? Suggested**
 `Thu 12/02/2015 (09:00) <…>`__   Évaluation 6        Alicia Allmanns   6     **? Suggested**
 `Mon 12/01/2015 (09:00) <…>`__   Évaluation 5        Alicia Allmanns   5     **? Suggested**
 `Wed 10/12/2014 (09:00) <…>`__   Évaluation 4        Alicia Allmanns   4     **? Suggested**
 `Mon 10/11/2014 (09:00) <…>`__   Évaluation 3        Alicia Allmanns   3     **? Suggested**
 `Fri 10/10/2014 (09:00) <…>`__   Évaluation 2        Alicia Allmanns   2     **? Suggested**
 `Wed 10/09/2014 (09:00) <…>`__   Évaluation 1        Alicia Allmanns   1     **? Suggested**
================================ =================== ================= ===== =================

Note how Lino avoids Sundays and Saturdays by moving to the following Monday.

Configuration

The frequence of the evaluation meetings depends on the evaluation policy exam_policy used for this contract.

You can configure the list of allowed examination policies via the Configure ‣ Integration ‣ Examination policies command.

>>> ses = rt.login('robin')
>>> translation.activate('en')
>>> ses.get_user().user_type.hidden_languages = None
>>> ses.show(isip.ExamPolicies)
... 
====================== ========================= ====================
 Designation            Designation (fr)          Designation (en)
---------------------- ------------------------- --------------------
 Monatlich              Chaque mois               Every month
 Alle 2 Monate          Tous les 2 mois           Every 2 months
 Alle 3 Monate          Tous les 3 mois           Every 3 months
 Alle 2 Wochen          Toutes les 2 semaines     Every 2 weeks
 Einmal nach 10 Tagen   Une fois après 10 jours   Once after 10 days
 Sonstige               Autre                     Other
====================== ========================= ====================

Coach changes while contract active

A special condition –which in reality arises quite often– is that the coach changes while the contract is still active. This is why Lino must attribute every automatic evaluation event to the currently responsible coach at the event’s date.

For example, let’s pick up ISIP contract #1.

>>> obj = isip.Contract.objects.get(pk=1)
>>> rt.show(cal.EntriesByController, obj)
================================ =================== ================= ===== =================
 When                             Short description   Managed by        No.   Workflow
-------------------------------- ------------------- ----------------- ----- -----------------
 `Thu 01/08/2013 (09:00) <…>`__   Auswertung 10       Mélanie Mélard    10    **? Suggested**
 `Mon 01/07/2013 (09:00) <…>`__   Auswertung 9        Mélanie Mélard    9     **? Suggested**
 `Wed 29/05/2013 (09:00) <…>`__   Auswertung 8        Mélanie Mélard    8     **? Suggested**
 `Mon 29/04/2013 (09:00) <…>`__   Auswertung 7        Mélanie Mélard    7     **? Suggested**
 `Thu 28/03/2013 (09:00) <…>`__   Auswertung 6        Mélanie Mélard    6     **? Suggested**
 `Thu 28/02/2013 (09:00) <…>`__   Auswertung 5        Hubert Huppertz   5     **? Suggested**
 `Thu 31/01/2013 (09:00) <…>`__   Auswertung 4        Hubert Huppertz   4     **? Suggested**
 `Mon 31/12/2012 (09:00) <…>`__   Auswertung 3        Hubert Huppertz   3     **? Suggested**
 `Thu 29/11/2012 (09:00) <…>`__   Auswertung 2        Hubert Huppertz   2     **? Suggested**
 `Mon 29/10/2012 (09:00) <…>`__   Auswertung 1        Hubert Huppertz   1     **? Suggested**
================================ =================== ================= ===== =================

The above shows that appointments before 2013-03-08 are with Hubert, while later appointments are with Caroline. How did Lino know which coach to assign? To find an answer, we must look at the coachings of this client:

>>> rt.show('coachings.CoachingsByClient', obj.client)
============== ============ ================= ========= =============== ============================
 Coached from   until        Coach             Primary   Coaching type   Reason of termination
-------------- ------------ ----------------- --------- --------------- ----------------------------
 03/03/2012                  Alicia Allmanns   No        General
 13/03/2012     08/03/2013   Hubert Huppertz   No        Integ           Transfer to colleague
 08/03/2013     24/10/2013   Mélanie Mélard    No        Integ           End of right on social aid
 24/10/2013                  Caroline Carnol   Yes       Integ
============== ============ ================= ========= =============== ============================

ISIP contract #21 was signed by Hubert for a period from 2013-02-16 until 2014-06-11.

>>> print(obj.user.username)
hubert
>>> print(obj.applies_from)
2012-09-29
>>> print(obj.applies_until)
2013-08-07

So there was no coaching at all defined for this client when the contract started. This is theoretically not possible, but Lino does not prevent us from creating such a contract.

This is why Hubert got responsible for the first evaluation meetings. On 2013-11-10 Caroline started to coach this client, but this didn’t change the responsible user since this coaching was for the General social service which is not considered integration work.

The currently responsible coach is the user for which there is an active integration coaching. An integration coaching is a coaching whose type has its does_integ field set to True. You can configure this via Configure ‣ PCSW ‣ Coaching types. The default configuration is as follows:

>>> ses.show('coachings.CoachingTypes')
=================== ===================== ================== ============= ===== =====================
 Designation         Designation (fr)      Designation (en)   Integration   GSS   Role in evaluations
------------------- --------------------- ------------------ ------------- ----- ---------------------
 ASD                 SSG                   General            No            Yes   Colleague
 DSBE                SI                    Integ              Yes           No    Colleague
 Schuldnerberatung   Médiation de dettes   Debts mediation    No            No
=================== ===================== ================== ============= ===== =====================

The above is coded in lino_welfare.modlib.isip.ContractBase.setup_auto_event().