示例#1
0
	def _on_show_forms_button_pressed(self, event):
		event.Skip()
		if self._LCTRL_forms.ItemCount == 0:
			return
		forms2show = self._LCTRL_forms.get_selected_item_data()
		if len(forms2show) == 0:
			data = self._LCTRL_forms.get_item_data(item_idx = 0)
			if data is None:
				return
			forms2show = [data]
		if len(forms2show) == 0:
			return
		for form in forms2show:
			for filename in form.final_output_filenames:
				gmMimeLib.call_viewer_on_file(filename, block = True)
示例#2
0
	def _on_show_forms_button_pressed(self, event):
		event.Skip()
		if self._LCTRL_forms.ItemCount == 0:
			return
		forms2show = self._LCTRL_forms.get_selected_item_data()
		if len(forms2show) == 0:
			data = self._LCTRL_forms.get_item_data(item_idx = 0)
			if data is None:
				return
			forms2show = [data]
		if len(forms2show) == 0:
			return
		for form in forms2show:
			for filename in form.final_output_filenames:
				gmMimeLib.call_viewer_on_file(filename, block = True)
示例#3
0
	def __browse_patient_data(self, base_dir):

		msg = _('Documents saved into:\n\n %s') % base_dir
		browse_index = gmGuiHelpers.gm_show_question (
			title = _('Browsing patient data excerpt'),
			question = msg + '\n\n' + _('Browse saved entries ?'),
			cancel_button = False
		)
		if not browse_index:
			return

		if os.path.isfile(os.path.join(base_dir, 'index.html')):
			gmNetworkTools.open_url_in_browser(url = 'file://%s' % os.path.join(base_dir, 'index.html'))
			return

		gmMimeLib.call_viewer_on_file(base_dir, block = False)
示例#4
0
    def display_via_mime(self, chunksize=0, block=None):

        fname = self.save_to_file(aChunkSize=chunksize)
        if fname is None:
            return False, ''

        success, msg = gmMimeLib.call_viewer_on_file(fname, block=block)
        if not success:
            return False, msg

        return True, ''
示例#5
0
	def display_via_mime(self, chunksize=0, block=None):

		fname = self.save_to_file(aChunkSize = chunksize)
		if fname is None:
			return False, ''

		success, msg = gmMimeLib.call_viewer_on_file(fname, block = block)
		if not success:
			return False, msg

		return True, ''
示例#6
0
文件: gmExportArea.py 项目: sk/gnumed
	def display_via_mime(self, chunksize=0, block=None):

		if self._payload[self._idx['pk_doc_obj']] is not None:
			return self.document_part.display_via_mime(chunksize = chunksize, block = block)

		fname = self.export_to_file(aChunkSize = chunksize)
		if fname is None:
			return False, ''

		success, msg = gmMimeLib.call_viewer_on_file(fname, block = block)
		if not success:
			return False, msg

		return True, ''
示例#7
0
    def display_via_mime(self, chunksize=0, block=None):

        if self._payload[self._idx['pk_doc_obj']] is not None:
            return self.document_part.display_via_mime(chunksize=chunksize,
                                                       block=block)

        fname = self.save_to_file(aChunkSize=chunksize)
        if fname is None:
            return False, ''

        success, msg = gmMimeLib.call_viewer_on_file(fname, block=block)
        if not success:
            return False, msg

        return True, ''
	def _on_view_log_button_pressed(self, evt):
		from Gnumed.pycommon import gmMimeLib
		gmLog2.flush()
		gmMimeLib.call_viewer_on_file(_logfile_name, block = False)
		evt.Skip()
示例#9
0
	def _on_open_directory_button_pressed(self, event):
		event.Skip()
		path = self.__calc_path()
		if not os.path.isdir(path):
			return
		gmMimeLib.call_viewer_on_file(path, block = False)
示例#10
0
	def _on_open_directory_button_pressed(self, event):
		event.Skip()
		path = self._LBL_directory.Label.strip().rstrip(os.sep).rstrip('/')
		if not os.path.isdir(path):
			return
		gmMimeLib.call_viewer_on_file(path, block = False)
示例#11
0
def edit_visual_progress_note(filename=None,
                              episode=None,
                              discard_unmodified=False,
                              doc_part=None,
                              health_issue=None):
    """This assumes <filename> contains an image which can be handled by the configured image editor."""

    if doc_part is not None:
        filename = doc_part.save_to_file()
        if filename is None:
            gmDispatcher.send(
                signal='statustext',
                msg=_('Cannot export visual progress note to file.'))
            return None

    editor = gmCfgDB.get4user(
        option='external.tools.visual_soap_editor_cmd',
        workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace)

    if editor is None:
        _log.error(
            'no editor for visual progress notes configured, trying mimetype editor'
        )
        gmDispatcher.send(
            signal='statustext',
            msg=_('Editor for visual progress note not configured.'),
            beep=False)
        mimetype = gmMimeLib.guess_mimetype(filename=filename)
        editor = gmMimeLib.get_editor_cmd(mimetype=mimetype, filename=filename)
        if editor is None:
            _log.error(
                'no editor for mimetype <%s> configured, trying mimetype viewer',
                mimetype)
            success, msg = gmMimeLib.call_viewer_on_file(aFile=filename,
                                                         block=True)
            if not success:
                _log.debug('problem running mimetype <%s> viewer', mimetype)
                gmGuiHelpers.gm_show_error(
                    _('There is no editor for visual progress notes defined.\n'
                      'Also, there is no editor command defined for the file type\n'
                      '\n'
                      ' [%s].\n'
                      '\n'
                      'Therefor GNUmed attempted to at least *show* this\n'
                      'visual progress note. That failed as well, however:\n'
                      '\n'
                      '%s') % (mimetype, msg),
                    _('Editing visual progress note'))
                editor = configure_visual_progress_note_editor()
                if editor is None:
                    gmDispatcher.send(
                        signal='statustext',
                        msg=_(
                            'Editor for visual progress note not configured.'),
                        beep=True)
                    return None

    if '%(img)s' in editor:
        editor = editor % {'img': filename}
    else:
        editor = '%s %s' % (editor, filename)

    if discard_unmodified:
        original_stat = os.stat(filename)
        original_md5 = gmTools.file2md5(filename)

    success = gmShellAPI.run_command_in_shell(editor, blocking=True)
    if not success:
        success, msg = gmMimeLib.call_viewer_on_file(aFile=filename,
                                                     block=True)
        if not success:
            _log.debug('problem running mimetype <%s> viewer', mimetype)
            gmGuiHelpers.gm_show_error(
                _('There was a problem running the editor\n'
                  '\n'
                  ' [%s] (%s)\n'
                  '\n'
                  'on the visual progress note.\n'
                  '\n'
                  'Therefor GNUmed attempted to at least *show* it.\n'
                  'That failed as well, however:\n'
                  '\n'
                  '%s') % (editor, mimetype, msg),
                _('Editing visual progress note'))
            editor = configure_visual_progress_note_editor()
            if editor is None:
                gmDispatcher.send(
                    signal='statustext',
                    msg=_('Editor for visual progress note not configured.'),
                    beep=True)
        return None

    try:
        open(filename, 'r').close()
    except Exception:
        _log.exception('problem accessing visual progress note file [%s]',
                       filename)
        gmGuiHelpers.gm_show_error(
            _('There was a problem reading the visual\n'
              'progress note from the file:\n'
              '\n'
              ' [%s]\n'
              '\n') % filename, _('Saving visual progress note'))
        return None

    if discard_unmodified:
        modified_stat = os.stat(filename)
        # same size ?
        if original_stat.st_size == modified_stat.st_size:
            modified_md5 = gmTools.file2md5(filename)
            # same hash ?
            if original_md5 == modified_md5:
                _log.debug('visual progress note (template) not modified')
                # ask user to decide
                msg = _(
                    'You either created a visual progress note from a template\n'
                    'in the database (rather than from a file on disk) or you\n'
                    'edited an existing visual progress note.\n'
                    '\n'
                    'The template/original was not modified at all, however.\n'
                    '\n'
                    'Do you still want to save the unmodified image as a\n'
                    'visual progress note into the EMR of the patient ?\n')
                save_unmodified = gmGuiHelpers.gm_show_question(
                    msg, _('Saving visual progress note'))
                if not save_unmodified:
                    _log.debug('user discarded unmodified note')
                    return

    if doc_part is not None:
        _log.debug('updating visual progress note')
        doc_part.update_data_from_file(fname=filename)
        doc_part.set_reviewed(technically_abnormal=False,
                              clinically_relevant=True)
        return None

    if not isinstance(episode, gmEMRStructItems.cEpisode):
        if episode is None:
            episode = _('visual progress notes')
        pat = gmPerson.gmCurrentPatient()
        emr = pat.emr
        episode = emr.add_episode(episode_name=episode.strip(),
                                  pk_health_issue=health_issue,
                                  is_open=False)

    doc = gmDocumentWidgets.save_file_as_new_document(
        filename=filename,
        document_type=gmDocuments.DOCUMENT_TYPE_VISUAL_PROGRESS_NOTE,
        episode=episode,
        unlock_patient=False,
        pk_org_unit=gmPraxis.gmCurrentPraxisBranch()['pk_org_unit'],
        date_generated=gmDateTime.pydt_now_here())
    doc.set_reviewed(technically_abnormal=False, clinically_relevant=True)

    return doc
示例#12
0
 def _on_view_log_button_pressed(self, evt):
     evt.Skip()
     from Gnumed.pycommon import gmMimeLib
     gmLog2.flush()
     gmMimeLib.call_viewer_on_file(_logfile_name, block=False)
示例#13
0
	def _on_print_button_pressed(self, event):
		if self.__tl_file is None:
			return
		tl_image_file = self._PNL_timeline.export_as_png()
		gmMimeLib.call_viewer_on_file(aFile = tl_image_file, block = None)
示例#14
0
    def _on_save_items_button_pressed(self, event):
        event.Skip()

        items = self._LCTRL_items.get_selected_item_data(only_one=False)
        if len(items) == 0:
            items = self._LCTRL_items.get_item_data()

        if len(items) == 0:
            return

        pat = gmPerson.gmCurrentPatient()
        dlg = cCreatePatientMediaDlg(self,
                                     -1,
                                     burn2cd=False,
                                     patient=pat,
                                     item_count=len(items))
        print("calling dlg.ShowModal()")
        choice = dlg.ShowModal()
        print("after returning from dlg.ShowModal()")
        if choice != wx.ID_SAVE:
            dlg.Destroy()
            return

        use_subdir = dlg._CHBOX_use_subdirectory.IsChecked()
        path = dlg._LBL_directory.Label.strip()
        remove_existing_data = dlg._RBTN_remove_data.Value is True
        generate_metadata = dlg._CHBOX_generate_metadata.IsChecked()
        dlg.Destroy()
        if use_subdir:
            path = gmTools.mk_sandbox_dir(prefix='%s-' % pat.subdir_name,
                                          base_dir=path)
        else:
            if remove_existing_data is True:
                if gmTools.rm_dir_content(path) is False:
                    gmGuiHelpers.gm_show_error(
                        title=_('Creating patient media'),
                        error=_('Cannot remove content from\n [%s]') % path)
                    return False

        exp_area = pat.export_area
        if generate_metadata:
            export_dir = exp_area.export(base_dir=path, items=items)
        else:
            export_dir = exp_area.dump_items_to_disk(base_dir=path,
                                                     items=items)

        self.save_soap_note(
            soap=_('Saved to [%s]:\n - %s') %
            (export_dir, '\n - '.join([i['description'] for i in items])))

        msg = _('Saved documents into directory:\n\n %s') % export_dir
        browse_index = gmGuiHelpers.gm_show_question(
            title=_('Creating patient media'),
            question=msg + '\n\n' + _('Browse patient data pack ?'),
            cancel_button=False)
        if browse_index:
            if generate_metadata:
                gmNetworkTools.open_url_in_browser(
                    url='file://%s' % os.path.join(export_dir, 'index.html'))
            else:
                gmMimeLib.call_viewer_on_file(export_dir, block=False)

        return True
示例#15
0
 def _on_browse_directory_button_pressed(self, event):
     event.Skip()
     path = self._LBL_directory.Label.strip()
     if path == '':
         return
     gmMimeLib.call_viewer_on_file(path, block=False)
示例#16
0
	def _on_print_button_pressed(self, event):
		if self.__tl_file is None:
			return
		tl_image_file = self._PNL_timeline.export_as_png()
		gmMimeLib.call_viewer_on_file(aFile = tl_image_file, block = None)