Esempio n. 1
0
	def _on_scan_items_button_pressed(self, event):
		event.Skip()
		scans = gmDocumentWidgets.acquire_images_from_capture_device(calling_window = self)
		if scans is None:
			return

		if not gmPerson.gmCurrentPatient().export_area.add_files(scans, _('scan')):
			gmGuiHelpers.gm_show_error (
				title = _('Scanning files into export area'),
				error = _('Cannot add (some of) the following scans to the export area:\n%s ') % '\n '.join(fnames)
			)
Esempio n. 2
0
def select_visual_progress_note_template(parent=None):

    if parent is None:
        parent = wx.GetApp().GetTopWindow()

    dlg = gmGuiHelpers.c3ButtonQuestionDlg(
        parent,
        -1,
        caption=_('Visual progress note source'),
        question=_(
            'From which source do you want to pick the image template ?'),
        button_defs=[{
            'label': _('Database'),
            'tooltip': _('List of templates in the database.'),
            'default': True
        }, {
            'label': _('File'),
            'tooltip': _('Files in the filesystem.'),
            'default': False
        }, {
            'label':
            _('Device'),
            'tooltip':
            _('Image capture devices (scanners, cameras, etc)'),
            'default':
            False
        }])
    result = dlg.ShowModal()
    dlg.Destroy()

    # 1) select from template
    if result == wx.ID_YES:
        _log.debug('visual progress note template from: database template')
        from Gnumed.wxpython import gmFormWidgets
        template = gmFormWidgets.manage_form_templates(
            parent=parent,
            template_types=[gmDocuments.DOCUMENT_TYPE_VISUAL_PROGRESS_NOTE],
            active_only=True)
        if template is None:
            return (None, None)
        filename = template.export_to_file()
        if filename is None:
            gmDispatcher.send(
                signal=u'statustext',
                msg=_('Cannot export visual progress note template for [%s].')
                % template['name_long'])
            return (None, None)
        return (filename, True)

    # 2) select from disk file
    if result == wx.ID_NO:
        _log.debug('visual progress note template from: disk file')
        fname = select_file_as_visual_progress_note_template(parent=parent)
        if fname is None:
            return (None, None)
        # create a copy of the picked file -- don't modify the original
        ext = os.path.splitext(fname)[1]
        tmp_name = gmTools.get_unique_filename(suffix=ext)
        _log.debug('visual progress note from file: [%s] -> [%s]', fname,
                   tmp_name)
        shutil.copy2(fname, tmp_name)
        return (tmp_name, False)

    # 3) acquire from capture device
    if result == wx.ID_CANCEL:
        _log.debug('visual progress note template from: image capture device')
        fnames = gmDocumentWidgets.acquire_images_from_capture_device(
            device=None, calling_window=parent)
        if fnames is None:
            return (None, None)
        if len(fnames) == 0:
            return (None, None)
        return (fnames[0], False)

    _log.debug('no visual progress note template source selected')
    return (None, None)