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