| Home | Trees | Indices | Help |
|
|---|
|
|
1 """GNUmed measurement widgets.
2 """
3 #================================================================
4 __version__ = "$Revision: 1.17 $"
5 __author__ = "Sebastian Hilbert <Sebastian.Hilbert@gmx.net>"
6 __license__ = "GPL"
7
8
9 import sys, logging, datetime as pyDT, decimal, StringIO
10 from lxml import etree
11
12 import wx #, wx.grid
13
14
15 if __name__ == '__main__':
16 sys.path.insert(0, '../../')
17
18 from Gnumed.business import gmPerson, gmDevices, gmDocuments, gmPersonSearch
19 from Gnumed.pycommon import gmDispatcher, gmMatchProvider
20 from Gnumed.wxpython import gmRegetMixin, gmGuiHelpers, gmPatSearchWidgets
21 from Gnumed.wxGladeWidgets import wxgCardiacDevicePluginPnl
22
23 _log = logging.getLogger('gm.ui')
24 _log.info(__version__)
25 #================================================================
26 -class cCardiacDevicePluginPnl(wxgCardiacDevicePluginPnl.wxgCardiacDevicePluginPnl, gmRegetMixin.cRegetOnPaintMixin):
27 """Panel holding a number of widgets to manage implanted cardiac devices. Used as notebook page."""
29 wxgCardiacDevicePluginPnl.wxgCardiacDevicePluginPnl.__init__(self, *args, **kwargs)
30 gmRegetMixin.cRegetOnPaintMixin.__init__(self)
31
32 # check if report types exist in db, if not create them
33 self.__checkup_doc_type = u'cardiac device checkup report'
34 dtype = gmDocuments.create_document_type(self.__checkup_doc_type)
35 # cannot reuse self.__checkup_doc_type here or else it wouldn't get translated
36 dtype.set_translation(_('cardiac device checkup report'))
37
38 self.__init_ui()
39 self.__register_interests()
40 #--------------------------------------------------------
41 # event handling
42 #--------------------------------------------------------
44 gmDispatcher.connect(signal = u'pre_patient_selection', receiver = self._on_pre_patient_selection)
45 gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._schedule_data_reget)
46 #--------------------------------------------------------
49 #--------------------------------------------------------
53 #--------------------------------------------------------
57 #--------------------------------------------------------
58 #def _on_select_button_pressed(self, evt):
59 # if self._RBTN_my_unsigned.GetValue() is True:
60 # self.data_grid.select_cells(unsigned_only = True, accountables_only = True, keep_preselections = False)
61 # elif self._RBTN_all_unsigned.GetValue() is True:
62 # self.data_grid.select_cells(unsigned_only = True, accountables_only = False, keep_preselections = False)
63 #--------------------------------------------------------
64 #def __on_sign_current_selection(self, evt):
65 # self.data_grid.sign_current_selection()
66 #--------------------------------------------------------
67 #def __on_delete_current_selection(self, evt):
68 # self.data_grid.delete_current_selection()
69 #--------------------------------------------------------
70 # internal API
71 #--------------------------------------------------------
74 #self.__action_button_popup = wx.Menu(title = _('Act on selected results'))
75
76 #menu_id = wx.NewId()
77 #self.__action_button_popup.AppendItem(wx.MenuItem(self.__action_button_popup, menu_id, _('Review and &sign')))
78 #wx.EVT_MENU(self.__action_button_popup, menu_id, self.__on_sign_current_selection)
79
80 #menu_id = wx.NewId()
81 #self.__action_button_popup.AppendItem(wx.MenuItem(self.__action_button_popup, menu_id, _('Export to &file')))
82 ##wx.EVT_MENU(self.__action_button_popup, menu_id, self.data_grid.current_selection_to_file)
83 #self.__action_button_popup.Enable(id = menu_id, enable = False)
84
85 #menu_id = wx.NewId()
86 #self.__action_button_popup.AppendItem(wx.MenuItem(self.__action_button_popup, menu_id, _('Export to &clipboard')))
87 ##wx.EVT_MENU(self.__action_button_popup, menu_id, self.data_grid.current_selection_to_clipboard)
88 #self.__action_button_popup.Enable(id = menu_id, enable = False)
89
90 #menu_id = wx.NewId()
91 #self.__action_button_popup.AppendItem(wx.MenuItem(self.__action_button_popup, menu_id, _('&Delete')))
92 #wx.EVT_MENU(self.__action_button_popup, menu_id, self.__on_delete_current_selection)
93 #--------------------------------------------------------
94 # reget mixin API
95 #--------------------------------------------------------
97
98 pat = gmPerson.gmCurrentPatient()
99 if not pat.connected:
100 return True
101
102 # get documents of type self.__checkup_doc_type
103 pat = gmPerson.gmCurrentPatient()
104 doc_folder = pat.get_document_folder()
105 checkups = doc_folder.get_documents(doc_type = self.__checkup_doc_type)
106 _log.info(checkups)
107
108 text = _('There are no device checkup reports in the database.')
109 if len(checkups) != 0:
110 # since get_documents() is sorted I simply get the first one as the most recent one
111 # for now assume that the xml file provide the cardiac device context.
112 # that pretty much means logical connection of leads and generator is provided in the xml
113 xml_fname = checkups[-1].parts[0].export_to_file()
114 tree = etree.parse(xml_fname)
115 DevicesDisplayed = gmDevices.device_status_as_text(tree)
116 text = u''.join(DevicesDisplayed)
117
118 self._TCTRL_current_status.SetValue(text)
119
120 return True
121 #================================================================
122 # main
123 #----------------------------------------------------------------
124 if __name__ == '__main__':
125
126 from Gnumed.pycommon import gmLog2, gmDateTime, gmI18N
127
128 gmI18N.activate_locale()
129 gmI18N.install_domain()
130 gmDateTime.init()
131
132 #------------------------------------------------------------
134 pat = gmPersonSearch.ask_for_patient()
135 app = wx.PyWidgetTester(size = (500, 300))
136 lab_grid = cMeasurementsGrid(parent = app.frame, id = -1)
137 lab_grid.patient = pat
138 app.frame.Show()
139 app.MainLoop()
140 #------------------------------------------------------------
142 pat = gmPersonSearch.ask_for_patient()
143 gmPatSearchWidgets.set_active_patient(patient=pat)
144 app = wx.PyWidgetTester(size = (500, 300))
145 ea = cMeasurementEditAreaPnl(parent = app.frame, id = -1)
146 app.frame.Show()
147 app.MainLoop()
148 #------------------------------------------------------------
149 if (len(sys.argv) > 1) and (sys.argv[1] == 'test'):
150 #test_grid()
151 test_test_ea_pnl()
152
153 #================================================================
154 # $Log: gmDeviceWidgets.py,v $
155 # Revision 1.17 2009-07-18 19:26:35 shilbert
156 # - now actually returns the most recent interrogation
157 #
158 # Revision 1.16 2009/07/18 17:48:24 shilbert
159 # - debugging repopulate_ui()
160 #
161 # Revision 1.15 2009/07/18 14:33:02 ncq
162 # - some more cleanup
163 #
164 # Revision 1.14 2009/07/17 22:18:45 ncq
165 # - a *bit* of cleanup ;-)
166 #
167 # Revision 1.13 2009/07/17 21:08:07 shilbert
168 # - cleanup
169 #
170 # Revision 1.12 2009/07/17 19:57:06 shilbert
171 # - now gets xml data from database
172 #
173 # Revision 1.11 2009/07/16 20:25:08 shilbert
174 # - fixed typos and syntax errors
175 #
176 # Revision 1.10 2009/07/16 19:59:06 shilbert
177 # - xml should now be gotten from database
178 #
179 # Revision 1.9 2009/07/15 20:13:37 shilbert
180 # - first step to getting xml from database
181 #
182 # Revision 1.8 2009/06/04 16:30:30 ncq
183 # - use set active patient from pat search widgets
184 #
185 # Revision 1.7 2009/04/16 12:47:28 ncq
186 # - some cleanup
187 #
188 # Revision 1.6 2009/04/14 18:35:52 shilbert
189 # - cleanup
190 #
191 # Revision 1.5 2009/04/13 19:10:06 shilbert
192 # -
193 #
194 # Revision 1.4 2009/04/13 19:06:25 ncq
195 # - add missing )
196 #
197 # Revision 1.3 2009/04/13 18:37:14 shilbert
198 # - updated class/filename
199 #
200 # Revision 1.2 2009/04/13 18:22:08 ncq
201 # - a tiny bit of cleanup
202 #
203 #
204
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Nov 29 04:04:51 2010 | http://epydoc.sourceforge.net |