| 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
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 = '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 = 'pre_patient_unselection', receiver = self._on_pre_patient_unselection)
45 gmDispatcher.connect(signal = 'post_patient_selection', receiver = self._schedule_data_reget)
46 #--------------------------------------------------------
50 #--------------------------------------------------------
54 #--------------------------------------------------------
55 #def _on_select_button_pressed(self, evt):
56 # if self._RBTN_my_unsigned.GetValue() is True:
57 # self.data_grid.select_cells(unsigned_only = True, accountables_only = True, keep_preselections = False)
58 # elif self._RBTN_all_unsigned.GetValue() is True:
59 # self.data_grid.select_cells(unsigned_only = True, accountables_only = False, keep_preselections = False)
60 #--------------------------------------------------------
61 #def __on_sign_current_selection(self, evt):
62 # self.data_grid.sign_current_selection()
63 #--------------------------------------------------------
64 #def __on_delete_current_selection(self, evt):
65 # self.data_grid.delete_current_selection()
66 #--------------------------------------------------------
67 # internal API
68 #--------------------------------------------------------
71 #self.__action_button_popup = wx.Menu(title = _('Act on selected results'))
72
73 #menu_id = wx.NewId()
74 #self.__action_button_popup.AppendItem(wx.MenuItem(self.__action_button_popup, menu_id, _('Review and &sign')))
75 #wx.EVT_MENU(self.__action_button_popup, menu_id, self.__on_sign_current_selection)
76
77 #menu_id = wx.NewId()
78 #self.__action_button_popup.AppendItem(wx.MenuItem(self.__action_button_popup, menu_id, _('Export to &file')))
79 ##wx.EVT_MENU(self.__action_button_popup, menu_id, self.data_grid.current_selection_to_file)
80 #self.__action_button_popup.Enable(id = menu_id, enable = False)
81
82 #menu_id = wx.NewId()
83 #self.__action_button_popup.AppendItem(wx.MenuItem(self.__action_button_popup, menu_id, _('Export to &clipboard')))
84 ##wx.EVT_MENU(self.__action_button_popup, menu_id, self.data_grid.current_selection_to_clipboard)
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, _('&Delete')))
89 #wx.EVT_MENU(self.__action_button_popup, menu_id, self.__on_delete_current_selection)
90 #--------------------------------------------------------
91 # reget mixin API
92 #--------------------------------------------------------
94
95 pat = gmPerson.gmCurrentPatient()
96 if not pat.connected:
97 return True
98
99 # get documents of type self.__checkup_doc_type
100 pat = gmPerson.gmCurrentPatient()
101 doc_folder = pat.get_document_folder()
102 checkups = doc_folder.get_documents(doc_type = self.__checkup_doc_type)
103 _log.info(checkups)
104
105 text = _('There are no device checkup reports in the database.')
106 if len(checkups) != 0:
107 # since get_documents() is sorted I simply get the first one as the most recent one
108 # for now assume that the xml file provide the cardiac device context.
109 # that pretty much means logical connection of leads and generator is provided in the xml
110 xml_fname = checkups[-1].parts[0].save_to_file()
111 tree = etree.parse(xml_fname)
112 DevicesDisplayed = gmDevices.device_status_as_text(tree)
113 text = ''.join(DevicesDisplayed)
114
115 self._TCTRL_current_status.SetValue(text)
116
117 return True
118 #================================================================
119 # main
120 #----------------------------------------------------------------
121 if __name__ == '__main__':
122
123 from Gnumed.pycommon import gmLog2, gmDateTime, gmI18N
124
125 gmI18N.activate_locale()
126 gmI18N.install_domain()
127 gmDateTime.init()
128
129 #------------------------------------------------------------
131 pat = gmPersonSearch.ask_for_patient()
132 app = wx.PyWidgetTester(size = (500, 300))
133 lab_grid = cMeasurementsGrid(app.frame, -1)
134 lab_grid.patient = pat
135 app.frame.Show()
136 app.MainLoop()
137 #------------------------------------------------------------
139 pat = gmPersonSearch.ask_for_patient()
140 gmPatSearchWidgets.set_active_patient(patient=pat)
141 app = wx.PyWidgetTester(size = (500, 300))
142 ea = cMeasurementEditAreaPnl(app.frame, -1)
143 app.frame.Show()
144 app.MainLoop()
145 #------------------------------------------------------------
146 if (len(sys.argv) > 1) and (sys.argv[1] == 'test'):
147 #test_grid()
148 test_test_ea_pnl()
149
150 #================================================================
151 #
152
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Feb 29 02:55:27 2020 | http://epydoc.sourceforge.net |