The lino_welfare.modlib.pcsw plugin

This page describes the lino_welfare.modlib.pcsw plugin.

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 *

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
Herr
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
Frau
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')
>>> ses.show('coachings.CoachingTypes')
... 
=================== ====== ====== =====================
 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
200
>>> d = AttrDict(json.loads(res.content))
>>> keys = list(d.keys())
>>> keys.sort()
>>> rmu(keys)
... 
['data', 'phantom', 'title']
>>> d.phantom
True
>>> print(d.title)
Klient erstellen

There are a lot of data fields:

>>> len(d.data.keys())
8
>>> print(' '.join(sorted(d.data.keys())))
... 
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(parent=ses)
>>> cli.get_detail_action(ses)
<BoundAction(pcsw.Clients, <lino.core.actions.ShowDetail detail ('Detail')>)>
>>> 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(parent=ses)
>>> ar.renderer = settings.SITE.kernel.extjs_renderer
>>> print(tostring(ar.obj2html(p)))
... 
<a href="javascript:Lino.contacts.Persons.detail.run(null,{
&quot;base_params&quot;: {  }, &quot;param_values&quot;: {
&quot;also_obsolete&quot;: false, &quot;end_date&quot;: null,
&quot;observed_event&quot;: null, &quot;observed_eventHidden&quot;: null,
&quot;start_date&quot;: null }, &quot;record_id&quot;: 178 })"
style="text-decoration:none">Herr Karl KELLER</a>
>>> print(tostring(ar.obj2html(cli)))
... 
<a href="javascript:Lino.pcsw.Clients.detail.run(null,{ &quot;base_params&quot;:
{  }, &quot;param_values&quot;: { &quot;also_obsolete&quot;: false,
&quot;end_date&quot;: null, &quot;observed_event&quot;: null,
&quot;observed_eventHidden&quot;: null, &quot;start_date&quot;: null },
&quot;record_id&quot;: 178 })" style="text-decoration:none">KELLER Karl
(178)</a>
>>> print(settings.SITE.kernel.extjs_renderer.instance_handler(ar, cli, None))
... 
Lino.pcsw.Clients.detail.run(null,{ "base_params": {  }, "param_values": {
"also_obsolete": false, "end_date": null, "observed_event": null,
"observed_eventHidden": null, "start_date": null }, "record_id": 178 })
>>> print(tostring(p.get_mti_buttons(ar)))
... 
<a href="javascript:Lino.contacts.Partners.detail.run(null,{
&quot;base_params&quot;: {  }, &quot;param_values&quot;: {
&quot;also_obsolete&quot;: false, &quot;end_date&quot;: null,
&quot;observed_event&quot;: null, &quot;observed_eventHidden&quot;: null,
&quot;start_date&quot;: null }, &quot;record_id&quot;: 178 })"
style="text-decoration:none">Partner</a>, <b>Person</b>, <a
href="javascript:Lino.pcsw.Clients.detail.run(null,{ &quot;base_params&quot;: {
}, &quot;param_values&quot;: { &quot;also_obsolete&quot;: false,
&quot;end_date&quot;: null, &quot;observed_event&quot;: null,
&quot;observed_eventHidden&quot;: null, &quot;start_date&quot;: null },
&quot;record_id&quot;: 178 })" style="text-decoration:none">Klient</a> [<a
href="javascript:Lino.contacts.Partners.del_client(null,true,178,{  })"
style="text-decoration:none">❌</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, 23, 4, 1, 1, 22, 22]
class lino_welfare.modlib.pcsw.Client

Django model used to represent a beneficiary.

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

A Client is a polymorphic specialization of Person.

has_esf

Whether Lino should make ESF summaries for this client.

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

overview

A panel with general information about this client.

cvs_emitted

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.

id_document

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.

group

Pointer to PersonGroup. The intergration phase of this client.

The UsersWithClients table groups clients using this field.

civil_state

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

client_state

Pointer to ClientStates.

needs_residence_permit
unemployed_since

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

seeking_since

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

work_permit_suspended_until
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.

client_state

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