| Home | Trees | Indices | Help |
|
|---|
|
|
1 """GNUmed patient export area widgets."""
2 #================================================================
3 __author__ = "Karsten.Hilbert@gmx.net"
4 __license__ = "GPL v2 or later"
5
6 # std lib
7 import sys
8 import logging
9 import os.path
10 import shutil
11
12
13 # 3rd party
14 import wx
15
16
17 # GNUmed libs
18 if __name__ == '__main__':
19 sys.path.insert(0, '../../')
20
21 from Gnumed.pycommon import gmDispatcher
22 from Gnumed.pycommon import gmTools
23 from Gnumed.pycommon import gmMimeLib
24 from Gnumed.pycommon import gmDateTime
25 from Gnumed.pycommon import gmPrinting
26 from Gnumed.pycommon import gmShellAPI
27 from Gnumed.pycommon import gmNetworkTools
28 from Gnumed.pycommon import gmCfg2
29 from Gnumed.pycommon import gmLog2
30
31 from Gnumed.business import gmPerson
32 from Gnumed.business import gmExportArea
33 from Gnumed.business import gmPraxis
34
35 from Gnumed.wxpython import gmRegetMixin
36 from Gnumed.wxpython import gmGuiHelpers
37 from Gnumed.wxpython import gmDocumentWidgets
38
39
40 _log = logging.getLogger('gm.ui')
41 _cfg = gmCfg2.gmCfgData()
42
43 #============================================================
44 from Gnumed.wxGladeWidgets import wxgExportAreaExportToMediaDlg
45
47
49 self.__patient = kwargs['patient']
50 del kwargs['patient']
51 self.__item_count = kwargs['item_count']
52 del kwargs['item_count']
53 super().__init__(*args, **kwargs)
54
55 self.__init_ui()
56
57 #--------------------------------------------------------
58 # event handling
59 #--------------------------------------------------------
67
68 #--------------------------------------------------------
71
72 #--------------------------------------------------------
75
76 #--------------------------------------------------------
80
81 #--------------------------------------------------------
88
89 #--------------------------------------------------------
111
112 #--------------------------------------------------------
126
127 #--------------------------------------------------------
128 # internal API
129 #--------------------------------------------------------
131 msg = _(
132 '\n'
133 'Number of entries to export: %s\n'
134 '\n'
135 'Patient: %s\n'
136 '\n'
137 'Select the media to export onto below.\n'
138 ) % (
139 self.__item_count,
140 self.__patient['description_gender']
141 )
142 self._LBL_header.Label = msg
143 self._LCTRL_removable_media.set_columns([_('Type'), _('Medium'), _('Details')])
144 self._LCTRL_removable_media.set_column_widths([wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE])
145 self._LCTRL_removable_media.set_resize_column()
146 self._LCTRL_removable_media.select_callback = self._on_media_selected
147 self._LCTRL_removable_media.deselect_callback = self._on_media_deselected
148
149 self.__update_media_list()
150 self.__update_ui_state()
151
152 #--------------------------------------------------------
154 media = self._LCTRL_removable_media.get_selected_item_data(only_one = True)
155 if media is None:
156 return None
157
158 if media['type'] == 'cd':
159 return -1
160
161 if media['is_mounted'] is False:
162 return -2
163
164 mnt_path = media['mountpoint']
165 if self._CHBOX_use_subdirectory.IsChecked():
166 return os.path.join(mnt_path, self.__patient.subdir_name)
167
168 return mnt_path
169
170 #--------------------------------------------------------
172
173 self._LCTRL_removable_media.remove_items_safely()
174 items = []
175 data = []
176
177 found, self.__burn_script = gmShellAPI.detect_external_binary('gm-burn_doc')
178
179 # USB / MMC drives
180 removable_partitions = gmTools.enumerate_removable_partitions()
181 for key in removable_partitions:
182 part = removable_partitions[key]
183 if part['is_mounted'] is False:
184 continue
185 items.append ([
186 part['bus'].upper(),
187 _('%s (%s %s) - %s free') % (
188 part['fs_label'],
189 part['vendor'],
190 part['model'],
191 gmTools.size2str(part['bytes_free'])
192 ),
193 _('%s (%s): %s in %s on %s') % (
194 part['mountpoint'],
195 gmTools.size2str(part['size_in_bytes']),
196 part['fs_type'],
197 part['partition'],
198 part['device']
199 )
200 ])
201 data.append(part)
202 for key in removable_partitions:
203 part = removable_partitions[key]
204 if part['is_mounted'] is True:
205 continue
206 items.append ([
207 part['bus'].upper(),
208 '%s (%s %s)' % (
209 part['fs_label'],
210 part['vendor'],
211 part['model']
212 ),
213 _('%s on %s, not mounted') % (
214 part['partition'],
215 part['device']
216 )
217 ])
218 data.append(part)
219
220 # optical drives: CD/DVD/BD
221 optical_writers = gmTools.enumerate_optical_writers()
222 for cdrw in optical_writers:
223 items.append ([
224 cdrw['type'].upper(),
225 cdrw['model'],
226 cdrw['device']
227 ])
228 data.append(cdrw)
229
230 self._LCTRL_removable_media.set_string_items(items)
231 self._LCTRL_removable_media.set_data(data)
232 self._LCTRL_removable_media.set_column_widths()
233
234 self._BTN_save2media.Disable()
235
236 #--------------------------------------------------------
238
239 media = self._LCTRL_removable_media.get_selected_item_data(only_one = True)
240 if media is None:
241 self._BTN_save2media.Disable()
242 self._BTN_open_directory.Disable()
243 self._BTN_clear_directory.Disable()
244 self._CHBOX_encrypt.Disable()
245 self._CHBOX_use_subdirectory.Disable()
246 self._LBL_directory.Label = ''
247 self._LBL_dir_is_empty.Label = ''
248 return
249
250 if media['type'] == 'cd':
251 self._BTN_open_directory.Disable()
252 self._BTN_clear_directory.Disable()
253 self._LBL_directory.Label = ''
254 if self.__burn_script is None:
255 self._BTN_save2media.Disable()
256 self._CHBOX_use_subdirectory.Disable()
257 self._CHBOX_encrypt.Disable()
258 self._LBL_dir_is_empty.Label = _('helper <gm-burn_doc(.bat)> not found')
259 else:
260 self._BTN_save2media.Enable()
261 self._CHBOX_use_subdirectory.Enable()
262 self._CHBOX_encrypt.Enable()
263 self._LBL_dir_is_empty.Label = ''
264 return
265
266 if media['is_mounted'] is False:
267 self._BTN_save2media.Disable()
268 self._BTN_open_directory.Disable()
269 self._BTN_clear_directory.Disable()
270 self._CHBOX_use_subdirectory.Disable()
271 self._CHBOX_encrypt.Disable()
272 self._LBL_directory.Label = ''
273 self._LBL_dir_is_empty.Label = _('media not mounted')
274 return
275
276 self._BTN_save2media.Enable()
277 self._CHBOX_use_subdirectory.Enable()
278 self._CHBOX_encrypt.Enable()
279
280 path = self.__calc_path()
281 self._LBL_directory.Label = path + os.sep
282 is_empty = gmTools.dir_is_empty(directory = path)
283 if is_empty is True:
284 self._LBL_dir_is_empty.Label = ''
285 self._BTN_open_directory.Enable()
286 self._BTN_clear_directory.Disable()
287 elif is_empty is False:
288 self._LBL_dir_is_empty.Label = _('directory contains data')
289 self._BTN_open_directory.Enable()
290 self._BTN_clear_directory.Enable()
291 else: # we don't know, say, use_subdir and subdir does not yet exist
292 self._LBL_dir_is_empty.Label = ''
293 self._BTN_open_directory.Disable()
294 self._BTN_clear_directory.Disable()
295
296 #============================================================
297 from Gnumed.wxGladeWidgets import wxgExportAreaSaveAsDlg
298
300
302 self.__patient = kwargs['patient']
303 del kwargs['patient']
304 self.__item_count = kwargs['item_count']
305 del kwargs['item_count']
306 super().__init__(*args, **kwargs)
307
308 self.__init_ui()
309
310 #--------------------------------------------------------
311 # event handlers
312 #--------------------------------------------------------
316
317 #--------------------------------------------------------
333
334 #--------------------------------------------------------
341
342 #--------------------------------------------------------
363
364 #--------------------------------------------------------
368
369 #--------------------------------------------------------
370 # internal API
371 #--------------------------------------------------------
373 msg = ('\n' + _('Number of entries to save: %s') + '\n\n' + _('Patient: %s') + '\n') % (
374 self.__item_count,
375 self.__patient['description_gender']
376 )
377 self._LBL_header.Label = msg
378 self._LBL_directory.Label = os.path.join(gmTools.gmPaths().home_dir, 'gnumed', self.__patient.subdir_name) + os.sep
379 self.__update_ui_state()
380
381 #--------------------------------------------------------
383 subdir_name = self.__patient.subdir_name
384 path = self._LBL_directory.Label.strip().rstrip(os.sep).rstrip('/')
385 if self._CHBOX_use_subdirectory.IsChecked():
386 # add subdir if needed
387 if not path.endswith(subdir_name):
388 path = os.path.join(path, subdir_name)
389 self._LBL_directory.Label = path + os.sep
390 else:
391 # remove subdir if there
392 if path.endswith(subdir_name):
393 path = path[:-len(subdir_name)].rstrip(os.sep).rstrip('/')
394 self._LBL_directory.Label = path + os.sep
395
396 is_empty = gmTools.dir_is_empty(directory = path)
397 if is_empty is True:
398 self._LBL_dir_is_empty.Label = ''
399 self._BTN_open_directory.Disable()
400 self._BTN_clear_directory.Disable()
401 self._BTN_save_files.Enable()
402 self._BTN_save_archive.Enable()
403 elif is_empty is False:
404 self._LBL_dir_is_empty.Label = _('directory contains data')
405 self._BTN_open_directory.Enable()
406 self._BTN_clear_directory.Enable()
407 self._BTN_save_files.Disable()
408 self._BTN_save_archive.Disable()
409 else: # we don't know, say, use_subdir and subdir does not yet exist
410 self._LBL_dir_is_empty.Label = ''
411 self._BTN_open_directory.Disable()
412 self._BTN_clear_directory.Disable()
413 self._BTN_save_files.Enable()
414 self._BTN_save_archive.Enable()
415
416 self.Layout()
417
418 #============================================================
419 from Gnumed.wxGladeWidgets import wxgExportAreaPluginPnl
420
421 -class cExportAreaPluginPnl(wxgExportAreaPluginPnl.wxgExportAreaPluginPnl, gmRegetMixin.cRegetOnPaintMixin):
422 """Panel holding a number of items for further processing.
423
424 Acts on the current patient.
425
426 Used as notebook page."""
428 wxgExportAreaPluginPnl.wxgExportAreaPluginPnl.__init__(self, *args, **kwargs)
429 gmRegetMixin.cRegetOnPaintMixin.__init__(self)
430 self.__init_ui()
431 self.__register_interests()
432
433 #--------------------------------------------------------
434 # event handling
435 #--------------------------------------------------------
437 gmDispatcher.connect(signal = 'pre_patient_unselection', receiver = self._on_pre_patient_unselection)
438 # gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._schedule_data_reget)
439 gmDispatcher.connect(signal = 'gm_table_mod', receiver = self._on_table_mod)
440
441 #--------------------------------------------------------
443 self._LCTRL_items.set_string_items([])
444
445 #--------------------------------------------------------
447 if kwargs['table'] != 'clin.export_item':
448 return
449 pat = gmPerson.gmCurrentPatient()
450 if not pat.connected:
451 return
452 if kwargs['pk_identity'] != pat.ID:
453 return
454 self._schedule_data_reget()
455
456 #--------------------------------------------------------
458 event.Skip()
459
460 #--------------------------------------------------------
467
468 #--------------------------------------------------------
487
488 #--------------------------------------------------------
507
508 #--------------------------------------------------------
519
520 #--------------------------------------------------------
533
534 #--------------------------------------------------------
546
547 #--------------------------------------------------------
561
562 #--------------------------------------------------------
587
588 #--------------------------------------------------------
597
598 #--------------------------------------------------------
661
662 # cleanup - ask !
663 # - files corresponding to DIR/DIR CONTENT entries
664 # - entries in export area
665 # remove_items = gmGuiHelpers.gm_show_question (
666 # title = _('Creating zip archive'),
667 # question = _(
668 # 'Zip archive created as:\n'
669 # '\n'
670 # ' [%s]\n'
671 # '\n'
672 # 'Remove archived entries from export area ?'
673 # ) % zip_file,
674 # cancel_button = False
675 # )
676 # if remove_items:
677 # exp_area.remove_items(items = items)
678 # return True
679
680 #--------------------------------------------------------
733
734 #--------------------------------------------------------
738
739 #--------------------------------------------------------
770
771 #--------------------------------------------------------
824
825 #--------------------------------------------------------
828
829 #--------------------------------------------------------
830 # internal API
831 #--------------------------------------------------------
833 self._LCTRL_items.set_columns([_('By'), _('When'), _('Description')])
834
835 self._BTN_archive_items.Disable()
836
837 # there's no GetToolTipText() in wx2.8
838 self.__mail_script_exists, path = gmShellAPI.detect_external_binary(binary = r'gm-mail_doc')
839 if not self.__mail_script_exists:
840 self._BTN_mail_items.Disable()
841 tt = self._BTN_mail_items.GetToolTipText() + '\n\n' + _('<gm-mail_doc(.bat) not found>')
842 self._BTN_mail_items.SetToolTip(tt)
843
844 self.__fax_script_exists, path = gmShellAPI.detect_external_binary(binary = r'gm-fax_doc')
845 if not self.__fax_script_exists:
846 self._BTN_fax_items.Disable()
847 tt = self._BTN_fax_items.GetToolTipText() + '\n\n' + _('<gm-fax_doc(.bat) not found>')
848 self._BTN_fax_items.SetToolTip(tt)
849
850 self.__burn_script_exists, path = gmShellAPI.detect_external_binary(binary = r'gm-burn_doc')
851 if not self.__burn_script_exists:
852 self._BTN_burn_items.Disable()
853 tt = self._BTN_burn_items.GetToolTipText() + '\n\n' + _('<gm-burn_doc(.bat) not found>')
854 self._BTN_burn_items.SetToolTip(tt)
855
856 # make me and listctrl file drop targets
857 dt = gmGuiHelpers.cFileDropTarget(target = self)
858 self.SetDropTarget(dt)
859 dt = gmGuiHelpers.cFileDropTarget(on_drop_callback = self._drop_target_consume_filenames)
860 self._LCTRL_items.SetDropTarget(dt)
861
862 #--------------------------------------------------------
864 if soap.strip() == '':
865 return
866 emr = gmPerson.gmCurrentPatient().emr
867 epi = emr.add_episode(episode_name = 'administrative', is_open = False)
868 emr.add_clin_narrative (
869 soap_cat = None,
870 note = soap,
871 episode = epi
872 )
873
874 #--------------------------------------------------------
875 - def __export_as_files(self, msg_title, base_dir=None, encrypt=False, with_metadata=False, items=None):
876 # get password
877 data_pwd = None
878 if encrypt:
879 data_pwd = self.__get_password(msg_title)
880 if data_pwd is None:
881 _log.debug('user aborted by not providing the same password twice')
882 gmDispatcher.send(signal = 'statustext', msg = _('Password not provided twice. Aborting.'))
883 return None
884 # save
885 wx.BeginBusyCursor()
886 try:
887 exp_area = gmPerson.gmCurrentPatient().export_area
888 if with_metadata:
889 export_dir = exp_area.export(base_dir = base_dir, items = items, passphrase = data_pwd)
890 else:
891 export_dir = exp_area.dump_items_to_disk(base_dir = base_dir, items = items, passphrase = data_pwd)
892 finally:
893 wx.EndBusyCursor()
894 if export_dir is None:
895 gmGuiHelpers.gm_show_error (
896 aMessage = _('Error exporting entries.'),
897 aTitle = msg_title
898 )
899 return None
900
901 return export_dir
902
903 #--------------------------------------------------------
905 # get password
906 zip_pwd = None
907 if encrypt:
908 zip_pwd = self.__get_password(msg_title)
909 if zip_pwd is None:
910 _log.debug('user aborted by not providing the same password twice')
911 gmDispatcher.send(signal = 'statustext', msg = _('Password not provided twice. Aborting.'))
912 return None
913 # create archive
914 wx.BeginBusyCursor()
915 zip_file = None
916 try:
917 exp_area = gmPerson.gmCurrentPatient().export_area
918 zip_file = exp_area.export_as_zip(passphrase = zip_pwd, items = items)
919 except Exception:
920 _log.exception('cannot create zip file')
921 wx.EndBusyCursor()
922 if zip_file is None:
923 gmGuiHelpers.gm_show_error (
924 aMessage = _('Error creating zip file.'),
925 aTitle = msg_title
926 )
927 return zip_file
928
929 #--------------------------------------------------------
931 while True:
932 data_pwd = wx.GetPasswordFromUser (
933 message = _(
934 'Enter passphrase to protect the data with.\n'
935 '\n'
936 '(minimum length: 5, trailing blanks will be stripped)'
937 ),
938 caption = msg_title
939 )
940 # minimal weakness check
941 data_pwd = data_pwd.rstrip()
942 if len(data_pwd) > 4:
943 break
944 retry = gmGuiHelpers.gm_show_question (
945 title = msg_title,
946 question = _(
947 'Insufficient passphrase.\n'
948 '\n'
949 '(minimum length: 5, trailing blanks will be stripped)\n'
950 '\n'
951 'Enter another passphrase ?'
952 )
953 )
954 if not retry:
955 # user changed her mind
956 return None
957 # confidentiality
958 gmLog2.add_word2hide(data_pwd)
959 # reget password
960 while True:
961 data_pwd4comparison = wx.GetPasswordFromUser (
962 message = _(
963 'Once more enter passphrase to protect the data with.\n'
964 '\n'
965 '(this will protect you from typos)\n'
966 '\n'
967 'Abort by leaving empty.'
968 ),
969 caption = msg_title
970 )
971 data_pwd4comparison = data_pwd4comparison.rstrip()
972 if data_pwd4comparison == '':
973 # user changed her mind ...
974 return None
975 if data_pwd == data_pwd4comparison:
976 break
977 gmGuiHelpers.gm_show_error (
978 error = _(
979 'Passphrases do not match.\n'
980 '\n'
981 'Retry, or abort with an empty passphrase.'
982 ),
983 title = msg_title
984 )
985 return data_pwd
986
987 #--------------------------------------------------------
989
990 items = self._LCTRL_items.get_selected_item_data(only_one = False)
991 if len(items) > 0:
992 return items
993
994 items = self._LCTRL_items.get_item_data()
995 if len(items) == 0:
996 gmDispatcher.send(signal = 'statustext', msg = _('Export area empty. Nothing to do.'))
997 return None
998
999 if len(items) == 1:
1000 return items
1001
1002 process_all = gmGuiHelpers.gm_show_question (
1003 title = msg_title,
1004 question = _('You have not selected any entries.\n\nReally use all %s entries ?') % len(items),
1005 cancel_button = False
1006 )
1007 if process_all:
1008 return items
1009
1010 return None
1011
1012 #--------------------------------------------------------
1014
1015 _log.debug('gm-burn_doc(.bat) API: "DIRECTORY-TO-BURN-FROM"')
1016
1017 found, burn_cmd = gmShellAPI.detect_external_binary('gm-burn_doc')
1018 if not found:
1019 gmDispatcher.send(signal = 'statustext', msg = _('Cannot burn to disk: Helper not found.')) # should not happen
1020 return False
1021
1022 args = [burn_cmd, base_dir]
1023 wx.BeginBusyCursor()
1024 try:
1025 success, ret_code, stdout = gmShellAPI.run_process(cmd_line = args, verbose = _cfg.get(option = 'debug'))
1026 finally:
1027 wx.EndBusyCursor()
1028 if success:
1029 return True
1030
1031 gmGuiHelpers.gm_show_error (
1032 aMessage = _('Error burning documents to CD/DVD.'),
1033 aTitle = _('Burning documents')
1034 )
1035 return False
1036
1037 #--------------------------------------------------------
1039
1040 msg = _('Documents saved into:\n\n %s') % base_dir
1041 browse_index = gmGuiHelpers.gm_show_question (
1042 title = _('Browsing patient data excerpt'),
1043 question = msg + '\n\n' + _('Browse saved entries ?'),
1044 cancel_button = False
1045 )
1046 if not browse_index:
1047 return
1048
1049 if os.path.isfile(os.path.join(base_dir, 'index.html')):
1050 gmNetworkTools.open_url_in_browser(url = 'file://%s' % os.path.join(base_dir, 'index.html'))
1051 return
1052
1053 gmMimeLib.call_viewer_on_file(base_dir, block = False)
1054
1055 #--------------------------------------------------------
1056 # file drop target API
1057 #--------------------------------------------------------
1059 pat = gmPerson.gmCurrentPatient()
1060 if not pat.connected:
1061 gmDispatcher.send(signal = 'statustext', msg = _('Cannot accept new documents. No active patient.'))
1062 return
1063
1064 # dive into folders dropped onto us and extract files (one level deep only)
1065 real_filenames = []
1066 for pathname in filenames:
1067 try:
1068 files = os.listdir(pathname)
1069 gmDispatcher.send(signal='statustext', msg=_('Extracting files from folder [%s] ...') % pathname)
1070 for file in files:
1071 fullname = os.path.join(pathname, file)
1072 if not os.path.isfile(fullname):
1073 continue
1074 real_filenames.append(fullname)
1075 except OSError:
1076 real_filenames.append(pathname)
1077
1078 if not pat.export_area.add_files(real_filenames, hint = _('Drag&Drop')):
1079 gmGuiHelpers.gm_show_error (
1080 title = _('Adding files to export area'),
1081 error = _('Cannot add (some of) the following files to the export area:\n%s ') % '\n '.join(real_filenames)
1082 )
1083 #--------------------------------------------------------
1084 # reget mixin API
1085 #
1086 # remember to call
1087 # self._schedule_data_reget()
1088 # whenever you learn of data changes from database
1089 # listener threads, dispatcher signals etc.
1090 #--------------------------------------------------------
1092 pat = gmPerson.gmCurrentPatient()
1093 if not pat.connected:
1094 return True
1095
1096 items = pat.export_area.items
1097 self._LCTRL_items.set_string_items ([
1098 [ i['created_by'],
1099 gmDateTime.pydt_strftime(i['created_when'], '%Y %b %d %H:%M'),
1100 i['description']
1101 ] for i in items
1102 ])
1103 self._LCTRL_items.set_column_widths([wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE])
1104 self._LCTRL_items.set_data(items)
1105
1106 self._LCTRL_items.SetFocus()
1107
1108 return True
1109
1110 #============================================================
1111 from Gnumed.wxGladeWidgets import wxgPrintMgrPluginPnl
1112
1113 -class cPrintMgrPluginPnl(wxgPrintMgrPluginPnl.wxgPrintMgrPluginPnl, gmRegetMixin.cRegetOnPaintMixin):
1114 """Panel holding print jobs.
1115
1116 Used as notebook page."""
1117
1119 wxgPrintMgrPluginPnl.wxgPrintMgrPluginPnl.__init__(self, *args, **kwargs)
1120 gmRegetMixin.cRegetOnPaintMixin.__init__(self)
1121 self.__init_ui()
1122 self.__register_interests()
1123 #--------------------------------------------------------
1124 # event handling
1125 #--------------------------------------------------------
1127 gmDispatcher.connect(signal = 'pre_patient_unselection', receiver = self._on_pre_patient_unselection)
1128 gmDispatcher.connect(signal = 'post_patient_selection', receiver = self._on_post_patient_selection)
1129 gmDispatcher.connect(signal = 'gm_table_mod', receiver = self._on_table_mod)
1130 #--------------------------------------------------------
1132 self._RBTN_active_patient_only.Enable(False)
1133 self._RBTN_all_patients.Value = True
1134 self._BTN_export_printouts.Enable(False)
1135 #--------------------------------------------------------
1139 #--------------------------------------------------------
1141 if kwargs['table'] != 'clin.export_item':
1142 return
1143 if self._RBTN_all_patients.Value is True:
1144 self._schedule_data_reget()
1145 return
1146 pat = gmPerson.gmCurrentPatient()
1147 if not pat.connected:
1148 return
1149 if kwargs['pk_identity'] != pat.ID:
1150 return
1151 self._schedule_data_reget()
1152 #--------------------------------------------------------
1156 #--------------------------------------------------------
1160 #--------------------------------------------------------
1167 #--------------------------------------------------------
1191 #--------------------------------------------------------
1200 #--------------------------------------------------------
1215
1216 #--------------------------------------------------------
1217 # internal API
1218 #--------------------------------------------------------
1220 self._BTN_export_printouts.Enable(False)
1221 #--------------------------------------------------------
1222 # reget mixin API
1223 #--------------------------------------------------------
1225 if self._RBTN_all_patients.Value is True:
1226 columns = [_('Patient'), _('Provider'), _('Description')]
1227 printouts = gmExportArea.get_print_jobs(order_by = 'pk_identity, description')
1228 items = [[
1229 '%s, %s (%s)' % (
1230 p['lastnames'],
1231 p['firstnames'],
1232 p['gender']
1233 ),
1234 p['created_by'],
1235 p['description']
1236 ] for p in printouts ]
1237 else:
1238 pat = gmPerson.gmCurrentPatient()
1239 if pat.connected:
1240 columns = [_('Provider'), _('Created'), _('Description')]
1241 printouts = pat.export_area.get_printouts(order_by = 'created_when, description')
1242 items = [[
1243 p['created_by'],
1244 gmDateTime.pydt_strftime(p['created_when'], '%Y %b %d %H:%M'),
1245 p['description']
1246 ] for p in printouts ]
1247 else:
1248 columns = [_('Patient'), _('Provider'), _('Description')]
1249 printouts = gmExportArea.get_print_jobs(order_by = 'pk_identity, description')
1250 items = [[
1251 '%s, %s (%s)' % (
1252 p['lastnames'],
1253 p['firstnames'],
1254 p['gender']
1255 ),
1256 p['created_by'],
1257 p['description']
1258 ] for p in printouts ]
1259 self._LCTRL_printouts.set_columns(columns)
1260 self._LCTRL_printouts.set_string_items(items)
1261 self._LCTRL_printouts.set_column_widths([wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE])
1262 self._LCTRL_printouts.set_data(printouts)
1263 self._LCTRL_printouts.SetFocus()
1264 return True
1265
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Jul 28 01:55:29 2019 | http://epydoc.sourceforge.net |