The lino_welfare.modlib.pcsw plugin

This page describes the lino_welfare.modlib.pcsw plugin.

A tested document

This is a tested document. The following instructions are used for initialization:

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

Client events

>>> show_choicelist(pcsw.ClientEvents)
=========== =========== ===================== ========================= ========================
 value       name        de                    fr                        en
----------- ----------- --------------------- ------------------------- ------------------------
 created     created     Erstellt              Créé                      Created
 modified    modified    Bearbeitet            Modifié                   Modified
 note        note        Notiz                 Notiz                     Note
 dispense    dispense    Dispenz               Dispenz                   Dispense
 penalty     penalty     AG-Sperre             AG-Sperre                 Penalty
 active      active      Begleitung            Intervention              Coaching
 isip        isip        VSE                   PIIS                      ISIP
 jobs        jobs        Art.60§7-Konvention   Mise à l'emploi art60§7   Art60§7 job supplyment
 available   available   Verfügbar             Disponible                Available
 art61       art61       Art.61-Konvention     Mise à l'emploi art.61    Art61 job supplyment
=========== =========== ===================== ========================= ========================

Refusal reasons

>>> show_choicelist(pcsw.RefusalReasons)
======= ====== ============================================= ============================================ ==========================================
 value   name   de                                            fr                                           en
------- ------ --------------------------------------------- -------------------------------------------- ------------------------------------------
 10      None   Information (keine Begleitung erforderlich)   Demande d'information (pas d'intervention)   Information request (No coaching needed)
 20      None   ÖSHZ ist nicht zuständig                      CPAS n'est pas compétent                     PCSW is not competent
 30      None   Antragsteller ist nicht zurück gekommen       Client n'est plus revenu                     Client did not return
======= ====== ============================================= ============================================ ==========================================

eID card summary

Here a test case (fixed 2013-08-27) to test the new eid_info field:

>>> soup = get_json_soup('rolf', 'pcsw/Clients/116', 'overview')
>>> print(soup.get_text("\n"))
Ansicht als Partner , Person , Klient
Alfons Ausdemwald
Am Bahndamm
4700 Eupen
Adressen verwalten
Karte Nr. 123456789012 (C (Personalausweis für Ausländer)), ausgestellt durch Eupen
, gültig von 19.08.12 bis 18.08.13
Muss eID-Karte einlesen!
Keinen Kaffee anbieten
>>> soup = get_json_soup('rolf', 'pcsw/Clients/118', 'overview')
>>> print(soup.get_text("\n"))
Ansicht als Partner , Person ,  Klient
Charlotte Collard
Auf dem Spitzberg
4700 Eupen
Adressen verwalten
Karte Nr. 591413288107 (Belgischer Staatsbürger), ausgestellt durch Eupen, gültig von 19.08.11 bis 19.08.16

Coaching types

>>> ses = rt.login('rolf')
=================== ====== ====== =====================
 Bezeichnung         DSBE   ASD    Role in evaluations
------------------- ------ ------ ---------------------
 ASD                 Nein   Ja     Kollege
 DSBE                Ja     Nein   Kollege
 Schuldnerberatung   Nein   Nein
=================== ====== ====== =====================

Creating a new client

>>> url = '/api/pcsw/CoachedClients/-99999?an=insert&fmt=json'
>>> res = test_client.get(url, REMOTE_USER='rolf')
>>> res.status_code
>>> d = AttrDict(json.loads(res.content))
>>> keys = list(d.keys())
>>> keys.sort()
>>> rmu(keys)
['data', 'phantom', 'title']
>>> d.phantom
>>> print(d.title)
Klient erstellen

There are a lot of data fields:

>>> len(
>>> print(' '.join(sorted(
disabled_fields first_name gender genderHidden language languageHidden last_name national_id

The detail action

The following would have detected a bug which caused the MTI navigator to not work (bug has been fixed 2015-02-27) :

>>> from etgen.html import E
>>> p = contacts.Person.objects.get(pk=178)
>>> cli = pcsw.Client.objects.get(pk=178)
>>> ses = rt.login('robin')
>>> ar = contacts.Partners.request_from(ses)
>>> print(cli.get_detail_action(ses))
<BoundAction(pcsw.Clients, <lino.core.actions.ShowDetail detail ('Detail')>)>
>>> print(cli.get_detail_action(ar))
<BoundAction(pcsw.Clients, <lino.core.actions.ShowDetail detail ('Detail')>)>

And this tests a potential source of problems in E.tostring which I removed at the same time:

>>> ses = rt.login('robin', renderer=settings.SITE.kernel.default_renderer)
>>> ar = contacts.Partners.request_from(ses)
>>> ar.renderer = settings.SITE.kernel.extjs_renderer
>>> print(tostring(ar.obj2html(p)))
<a href=",{ &quot;record_id&quot;: 178 })">Herr Karl KELLER</a>
>>> print(tostring(ar.obj2html(cli)))
<a href=",{ &quot;record_id&quot;: 178 })">KELLER Karl (178)</a>
>>> print(settings.SITE.kernel.extjs_renderer.instance_handler(ar, cli, None)),{ "record_id": 178 })
>>> print(tostring(p.get_mti_buttons(ar)))
<a href=",{ &quot;record_id&quot;: 178 })">Partner</a>,
<b>Person</b>, <a
href=",{ &quot;record_id&quot;: 178 })">Klient</a> [<a
...javascript:Lino.contacts.Partners.del_client(null,true,178,{ })...">❌</a>]

Virtual fields on client

The following snippet just tests some virtual fields on Client for runtime errors.

>>> vfields = ('primary_coach', 'coaches', 'active_contract', 'contract_company',
...     'find_appointment', 'cbss_relations', 'applies_from', 'applies_until')
>>> counters = { k: set() for k in vfields }
>>> for cli in pcsw.Client.objects.all():
...     for k in vfields:
...         counters[k].add(getattr(cli, k))
>>> [len(counters[k]) for k in vfields]
[1, 20, 21, 4, 1, 1, 21, 21]
class lino_welfare.modlib.pcsw.Client

Inherits from lino_welfare.modlib.contacts.Person and lino_xl.lib.beid.BeIdCardHolder.

A Client is a polymorphic specialization of Person.


Whether Lino should make ESF summaries for this client.

This field exists only if lino_welfasre.modlib.esf is installed.


A panel with general information about this client.


A virtual field displaying a group of shortcut links for managing CVs (Curriculum Vitaes).

This field is an excerpts shortcut (lino_xl.lib.excerpts.models.Shortcuts) and works only if the database has an ExcerptType whose shortcut points to it.


A virtual field displaying a group of buttons for managing the “identifying document”, i.e. an uploaded document which has been used as alternative to the eID card.


Pointer to PersonGroup. The intergration phase of this client.

The UsersWithClients table groups clients using this field.


The civil state of this client. Allowed choices are defined in CivilState.


Pointer to ClientStates.


The date when this client got unemployed and stopped to have a regular work.


The date when this client registered as unemployed and started to look for a new job.

get_first_meeting(self, today=None)

Return the last note of type “First meeting” for this client. Usage example see Debts mediation and Notes.

class lino_welfare.modlib.pcsw.Clients

The list that opens by Contacts ‣ Clients.


If not empty, show only Clients whose client_state equals the specified value.