1 """GNUmed scrolled window text dump of EMR content.
2 """
3
4 __version__ = "$Revision: 1.22 $"
5 __author__ = "K.Hilbert <Karsten.Hilbert@gmx.net>"
6
7 import sys, string
8
9
10 import wx
11
12
13 from Gnumed.pycommon import gmDispatcher, gmExceptions
14 from Gnumed.business import gmPerson
15
16
17 _log = gmLog.gmDefLog
18
26
28 self.txt = wx.TextCtrl(
29 self,
30 -1,
31 _('No EMR data loaded.'),
32 style = wx.TE_MULTILINE | wx.TE_READONLY
33 )
34
35 szr_outer = wx.StaticBoxSizer(wx.StaticBox(self, -1, _("EMR text dump")), wx.VERTICAL)
36 szr_outer.Add(self.txt, 1, wx.EXPAND, 0)
37
38 self.SetAutoLayout(1)
39 self.SetSizer(szr_outer)
40 szr_outer.Fit(self)
41 szr_outer.SetSizeHints(self)
42 self.Layout()
43
45
46 gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._on_post_patient_selection)
47 return 1
48
51
52
54 pat = gmPerson.gmCurrentPatient()
55
56 if not pat.connected:
57 _log.Log(gmLog.lErr, 'no active patient, cannot get EMR text dump')
58 self.txt.SetValue(_('Currently there is no active patient. Cannot retrieve EMR text.'))
59 return None
60 emr = pat.get_emr()
61 if emr is None:
62 _log.Log(gmLog.lErr, 'cannot get EMR text dump')
63 self.txt.SetValue(_(
64 'An error occurred while retrieving a text\n'
65 'dump of the EMR for the active patient.\n\n'
66 'Please check the log file for details.'
67 ))
68 return None
69 dump = emr.get_text_dump()
70 if dump is None:
71 _log.Log(gmLog.lErr, 'cannot get EMR text dump')
72 self.txt.SetValue(_(
73 'An error occurred while retrieving a text\n'
74 'dump of the EMR for the active patient.\n\n'
75 'Please check the log file for details.'
76 ))
77 return None
78 keys = dump.keys()
79 keys.sort()
80 txt = ''
81 for age in keys:
82 for line in dump[age]:
83 txt = txt + "%s\n" % line
84 self.txt.SetValue(txt)
85 return True
86
89 wx.ScrolledWindow.__init__(
90 self,
91 parent,
92 -1
93 )
94 self.txt = wx.TextCtrl(
95 self,
96 -1,
97 _('No EMR data loaded.'),
98 style = wx.TE_MULTILINE | wx.TE_READONLY
99 )
100 szr_vbox_main = wx.BoxSizer(wx.VERTICAL)
101 szr_vbox_main.Add(self.txt, 0, wxEXPAND | wx.CENTER | wx.ALL, 5)
102
103 self.SetAutoLayout(1)
104 self.SetSizer(szr_vbox_main)
105 szr_vbox_main.Fit(self)
106 szr_vbox_main.SetSizeHints(self)
107 szr_vbox_main.SetVirtualSizeHints(self)
108 self.Layout()
109
110
111 self.EnableScrolling(0, 1)
112 self.SetScrollRate(0, 20)
113 wx.CallAfter(self.Scroll, 0, 0)
114
115
116
117