| Home | Trees | Indices | Help |
|
|---|
|
|
1 """GNUmed staff management widgets."""
2 #=========================================================================
3 __author__ = "K. Hilbert <Karsten.Hilbert@gmx.net>"
4 __license__ = "GPL v2 or later (details at http://www.gnu.org)"
5
6 import logging
7
8
9 import wx
10
11
12 from Gnumed.pycommon import gmTools
13 from Gnumed.pycommon import gmI18N
14 from Gnumed.pycommon import gmMatchProvider
15
16 from Gnumed.business import gmPerson
17 from Gnumed.business import gmStaff
18
19 from Gnumed.wxpython import gmGuiHelpers
20 from Gnumed.wxpython import gmAuthWidgets
21 from Gnumed.wxpython import gmPhraseWheel
22
23
24 _log = logging.getLogger('gm.ui')
25
26 #==========================================================================
28
30
31 gmPhraseWheel.cPhraseWheel.__init__ (
32 self,
33 *args,
34 **kwargs
35 )
36 self.matcher = gmPerson.cMatchProvider_Provider()
37 self.SetToolTip(_('Select a healthcare provider.'))
38 self.selection_only = True
39
40 #==========================================================================
42
44
45 gmPhraseWheel.cPhraseWheel.__init__(self, *args, **kwargs)
46
47 items = [
48 {'list_label': _('Public (no clinical or demographic access)'), 'field_label': _('public'), 'data': 'public access', 'weight': 1},
49 {'list_label': _('Staff (demographic access only)'), 'field_label': _('staff (clerical)'), 'data': 'non-clinical access', 'weight': 1},
50 {'list_label': _('full clinical access'), 'field_label': _('full clinical access'), 'data': 'full clinical access', 'weight': 1}
51 ]
52 mp = gmMatchProvider.cMatchProvider_FixedList(items)
53 mp.setThresholds(1, 2, 3)
54 mp.word_separators = None
55 #mp.ignored_chars = r"[.'\\(){}\[\]<>~#*$%^_=&@\t0123456789]+" + r'"'
56 #self.SetToolTip(_('The preparation (form) of the substance or drug.'))
57 self.matcher = mp
58 self.selection_only = True
59
60 #==========================================================================
61 from Gnumed.wxGladeWidgets import wxgEditStaffListDlg
62
64
66 wxgEditStaffListDlg.wxgEditStaffListDlg.__init__(self, *args, **kwds)
67
68 self._LCTRL_staff.InsertColumn(0, _('Alias'))
69 self._LCTRL_staff.InsertColumn(1, _('DB account'))
70 self._LCTRL_staff.InsertColumn(2, _('Role'))
71 self._LCTRL_staff.InsertColumn(3, _('Name'))
72 self._LCTRL_staff.InsertColumn(4, _('Comment'))
73 self._LCTRL_staff.InsertColumn(5, _('Status'))
74
75 self.__init_ui_data()
76 #--------------------------------------------------------
77 # internal API
78 #--------------------------------------------------------
80 lbl_active = {True: _('active'), False: _('inactive')}
81 lbl_login = {True: _('can login'), False: _('can not login')}
82
83 self._LCTRL_staff.DeleteAllItems()
84 staff_list = gmStaff.get_staff_list()
85 pos = len(staff_list) + 1
86 for staff in staff_list:
87 row_num = self._LCTRL_staff.InsertItem(pos, label=staff['short_alias'])
88 self._LCTRL_staff.SetItem(index = row_num, column = 1, label = staff['db_user'])
89 self._LCTRL_staff.SetItem(index = row_num, column = 2, label = staff['l10n_role'])
90 title = gmTools.coalesce(staff['title'], '')
91 self._LCTRL_staff.SetItem(index = row_num, column = 3, label = '%s %s, %s' % (title, staff['lastnames'], staff['firstnames']))
92 self._LCTRL_staff.SetItem(index = row_num, column = 4, label = gmTools.coalesce(staff['comment'], ''))
93 self._LCTRL_staff.SetItem(index = row_num, column = 5, label = '%s / %s' % (lbl_active[bool(staff['is_active'])], lbl_login[bool(staff['can_login'])]))
94 # color
95 if staff['is_active'] and staff['can_login']:
96 #self._LCTRL_staff.SetItemTextColour(row_num, col=wx.Colour('BLUE'))
97 pass
98 elif not staff['is_active'] and not staff['can_login']:
99 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.LIGHT_GREY)
100 else:
101 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.Colour('RED'))
102 # data
103 self._LCTRL_staff.SetItemData(item = row_num, data = staff['pk_staff'])
104
105 if len(staff_list) > 0:
106 self._LCTRL_staff.SetColumnWidth(0, wx.LIST_AUTOSIZE)
107 self._LCTRL_staff.SetColumnWidth(1, wx.LIST_AUTOSIZE_USEHEADER)
108 self._LCTRL_staff.SetColumnWidth(2, wx.LIST_AUTOSIZE)
109 self._LCTRL_staff.SetColumnWidth(3, wx.LIST_AUTOSIZE)
110 self._LCTRL_staff.SetColumnWidth(4, wx.LIST_AUTOSIZE)
111 self._LCTRL_staff.SetColumnWidth(5, wx.LIST_AUTOSIZE)
112
113 # disable buttons
114 self._btn_save.Enable(False)
115 self._btn_delete.Enable(False)
116 self._btn_deactivate.Enable(False)
117 self._btn_activate.Enable(False)
118 # clear editor
119 self._TCTRL_name.SetValue('')
120 self._TCTRL_alias.SetValue('')
121 self._TCTRL_account.SetValue('')
122 self._PRW_user_role.SetText(value = '', data = None)
123 self._TCTRL_comment.SetValue('')
124 #--------------------------------------------------------
125 # event handlers
126 #--------------------------------------------------------
128 self._btn_save.Enable(True)
129 self._btn_delete.Enable(True)
130 self._btn_deactivate.Enable(True)
131 self._btn_activate.Enable(True)
132 # fill editor
133 pk_staff = self._LCTRL_staff.GetItemData(self._LCTRL_staff.GetFirstSelected())
134 staff = gmStaff.cStaff(aPK_obj=pk_staff)
135 self._TCTRL_name.SetValue('%s.%s %s' % (staff['title'], staff['firstnames'], staff['lastnames']))
136 self._TCTRL_alias.SetValue(staff['short_alias'])
137 self._TCTRL_account.SetValue(staff['db_user'])
138 self._PRW_user_role.SetText(value = staff['l10n_role'], data = staff['role'], suppress_smarts = True)
139 self._TCTRL_comment.SetValue(gmTools.coalesce(staff['comment'], ''))
140 #--------------------------------------------------------
142 self._btn_save.Enable(False)
143 self._btn_delete.Enable(False)
144 self._btn_deactivate.Enable(False)
145 self._btn_activate.Enable(False)
146 # clear editor
147 self._TCTRL_name.SetValue('')
148 self._TCTRL_alias.SetValue('')
149 self._TCTRL_account.SetValue('')
150 self._PRW_user_role.SetText(value = '', data = None)
151 self._TCTRL_comment.SetValue('')
152 #--------------------------------------------------------
162 #--------------------------------------------------------
172 #--------------------------------------------------------
185 #--------------------------------------------------------
217 #==========================================================================
218 from Gnumed.wxGladeWidgets import wxgAddPatientAsStaffDlg
219
221
223 wxgAddPatientAsStaffDlg.wxgAddPatientAsStaffDlg.__init__(self, *args, **kwds)
224 self.__init_ui_data()
225 #--------------------------------------------------------
226 # internal API
227 #--------------------------------------------------------
229 pat = gmPerson.gmCurrentPatient()
230 name = pat.get_active_name()
231 txt = _("""
232 %s "%s" %s
233 born: %s""") % (
234 name['firstnames'],
235 name['preferred'],
236 name['lastnames'],
237 pat.get_formatted_dob(format = '%Y %b %d')
238 )
239 self._TXT_person.SetValue(txt)
240 txt = name['firstnames'][:2] + name['lastnames'][:2]
241 self._TXT_short_alias.SetValue(txt)
242 self._TXT_account.SetValue(txt.lower())
243 #--------------------------------------------------------
244 # event handlers
245 #--------------------------------------------------------
248 #--------------------------------------------------------
298
299 #==========================================================================
300
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Fri Jan 25 02:55:27 2019 | http://epydoc.sourceforge.net |