def format(self): txt = u'%s [#%s]\n' % ( gmTools.bool2subst(self._payload[self._idx['is_active']], _('Active clinical hint'), _('Inactive clinical hint')), self._payload[self._idx['pk_auto_hint']] ) txt += u'\n' txt += self._payload[self._idx['title']] txt += u'\n' txt += u'\n' txt += _('Source: %s\n') % self._payload[self._idx['source']] txt += _('Language: %s\n') % self._payload[self._idx['lang']] txt += u'\n' txt += gmTools.wrap(self._payload[self._idx['hint']], width = 50, initial_indent = u' ', subsequent_indent = u' ') txt += u'\n' txt += u'\n' if self._payload[self._idx['recommendation']] is not None: txt += gmTools.wrap(self._payload[self._idx['recommendation']], width = 50, initial_indent = u' ', subsequent_indent = u' ') txt += u'\n' txt += u'\n' txt += gmTools.wrap ( gmTools.coalesce(self._payload[self._idx['url']], u''), width = 50, initial_indent = u' ', subsequent_indent = u' ' ) txt += u'\n' txt += u'\n' txt += gmTools.wrap(self._payload[self._idx['query']], width = 50, initial_indent = u' ', subsequent_indent = u' ') txt += u'\n' if self._payload[self._idx['recommendation_query']] is not None: txt += u'\n' txt += gmTools.wrap(self._payload[self._idx['recommendation_query']], width = 50, initial_indent = u' ', subsequent_indent = u' ') txt += u'\n' return txt
def tooltip(item): return ( '%s %s (#%s) %s\n' '\n' ' %s @ %s\n' '\n' ' %s: %s\n' '%s' ) % ( gmTools.u_box_horiz_single * 3, item['option'], item['pk_cfg_item'], gmTools.u_box_horiz_single * 3, item['owner'], item['workplace'], item['type'], gmTools.wrap( text = item['value'], width = 40, subsequent_indent = ' ' * 8 ), gmTools.wrap ( text = gmTools.coalesce(item['description'], '', '\n%s'), width = 40, initial_indent = ' ', subsequent_indent = ' ' ) )
def delete(translation=None): msg = _( 'Are you sure you want to delete the translation of:\n' '\n' '%s\n' '\n' 'into [%s] as:\n' '\n' '%s\n' '\n' '? (Note that you must know the database administrator password !)\n' ) % (gmTools.wrap(text=translation['orig'], width=60, initial_indent=' ', subsequent_indent=' '), translation['lang'], gmTools.wrap(text=translation['trans'], width=60, initial_indent=' ', subsequent_indent=' ')) delete_it = gmGuiHelpers.gm_show_question( aTitle=_('Deleting translation from database'), aMessage=msg) if not delete_it: return False conn = gmAuthWidgets.get_dbowner_connection( procedure=_('deleting a translation')) if conn is None: return False return gmPG2.delete_translation_from_database( link_obj=conn, language=translation['lang'], original=translation['orig'])
def format(self): txt = '%s [#%s]\n' % ( gmTools.bool2subst(self._payload[self._idx['is_active']], _('Suppressed active dynamic hint'), _('Suppressed inactive dynamic hint')), self._payload[self._idx['pk_suppressed_hint']] ) txt += '\n' txt += '%s\n\n' % self._payload[self._idx['title']] txt += _('Suppressed by: %s\n') % self._payload[self._idx['suppressed_by']] txt += _('Suppressed at: %s\n') % gmDateTime.pydt_strftime(self._payload[self._idx['suppressed_when']], '%Y %b %d') txt += _('Hint #: %s\n') % self._payload[self._idx['pk_hint']] txt += _('Patient #: %s\n') % self._payload[self._idx['pk_identity']] txt += _('MD5 (currently): %s\n') % self._payload[self._idx['md5_hint']] txt += _('MD5 (at suppression): %s\n') % self._payload[self._idx['md5_suppressed']] txt += _('Source: %s\n') % self._payload[self._idx['source']] txt += _('Language: %s\n') % self._payload[self._idx['lang']] txt += '\n' txt += '%s\n' % gmTools.wrap(self._payload[self._idx['hint']], width = 50, initial_indent = ' ', subsequent_indent = ' ') txt += '\n' if self._payload[self._idx['recommendation']] is not None: txt += '\n' txt += '%s\n' % gmTools.wrap(self._payload[self._idx['recommendation']], width = 50, initial_indent = ' ', subsequent_indent = ' ') txt += '\n' txt += '%s\n' % gmTools.wrap ( gmTools.coalesce(self._payload[self._idx['url']], ''), width = 50, initial_indent = ' ', subsequent_indent = ' ' ) txt += '\n' txt += '%s\n' % gmTools.wrap(self._payload[self._idx['query']], width = 50, initial_indent = ' ', subsequent_indent = ' ') return txt
def format(self): txt = u'%s [#%s]\n' % ( gmTools.bool2subst(self._payload[self._idx['is_active']], _('Suppressed active dynamic hint'), _('Suppressed inactive dynamic hint')), self._payload[self._idx['pk_suppressed_hint']] ) txt += u'\n' txt += u'%s\n\n' % self._payload[self._idx['title']] txt += _('Suppressed by: %s\n') % self._payload[self._idx['suppressed_by']] txt += _('Suppressed at: %s\n') % gmDateTime.pydt_strftime(self._payload[self._idx['suppressed_when']], '%Y %b %d') txt += _('Hint #: %s\n') % self._payload[self._idx['pk_hint']] txt += _('Patient #: %s\n') % self._payload[self._idx['pk_identity']] txt += _('MD5 (currently): %s\n') % self._payload[self._idx['md5_hint']] txt += _('MD5 (at suppression): %s\n') % self._payload[self._idx['md5_suppressed']] txt += _('Source: %s\n') % self._payload[self._idx['source']] txt += _('Language: %s\n') % self._payload[self._idx['lang']] txt += u'\n' txt += u'%s\n' % gmTools.wrap(self._payload[self._idx['hint']], width = 50, initial_indent = u' ', subsequent_indent = u' ') txt += u'\n' if self._payload[self._idx['recommendation']] is not None: txt += u'\n' txt += u'%s\n' % gmTools.wrap(self._payload[self._idx['recommendation']], width = 50, initial_indent = u' ', subsequent_indent = u' ') txt += u'\n' txt += u'%s\n' % gmTools.wrap ( gmTools.coalesce(self._payload[self._idx['url']], u''), width = 50, initial_indent = u' ', subsequent_indent = u' ' ) txt += u'\n' txt += u'%s\n' % gmTools.wrap(self._payload[self._idx['query']], width = 50, initial_indent = u' ', subsequent_indent = u' ') return txt
def format(self, left_margin='', fancy=False, width=75): if fancy: txt = gmTools.wrap ( text = _('%s: %s by %.8s (v%s)\n%s') % ( self._payload[self._idx['date']].strftime('%x %H:%M'), gmSoapDefs.soap_cat2l10n_str[self._payload[self._idx['soap_cat']]], self._payload[self._idx['modified_by']], self._payload[self._idx['row_version']], self._payload[self._idx['narrative']] ), width = width, initial_indent = '', subsequent_indent = left_margin + ' ' ) else: txt = '%s [%s]: %s (%.8s)' % ( self._payload[self._idx['date']].strftime('%x %H:%M'), gmSoapDefs.soap_cat2l10n[self._payload[self._idx['soap_cat']]], self._payload[self._idx['narrative']], self._payload[self._idx['modified_by']] ) if len(txt) > width: txt = txt[:width] + gmTools.u_ellipsis return txt
def _calc_inbox_item_tooltip(self, data): if isinstance(data, gmProviderInbox.cInboxMessage): return data.format() if isinstance(data, gmAutoHints.cDynamicHint): return '%s\n\n%s%s\n\n%s %s' % ( data['title'], gmTools.wrap(data['hint'], width = 50), gmTools.wrap(gmTools.coalesce(data['recommendation'], '', '\n\n%s'), width = 50), gmTools.wrap(gmTools.coalesce(data['url'], '', '%s\n\n'), width = 50), data['source'] ) if isinstance(data, type('')): return data return None
def delete(translation=None): msg = _( 'Are you sure you want to delete the translation of:\n' '\n' '%s\n' '\n' 'into [%s] as:\n' '\n' '%s\n' '\n' '? (Note that you must know the database administrator password !)\n' ) % ( gmTools.wrap ( text = translation['orig'], width = 60, initial_indent = ' ', subsequent_indent = ' ' ), translation['lang'], gmTools.wrap ( text = translation['trans'], width = 60, initial_indent = ' ', subsequent_indent = ' ' ) ) delete_it = gmGuiHelpers.gm_show_question ( aTitle = _('Deleting translation from database'), aMessage = msg ) if not delete_it: return False conn = gmAuthWidgets.get_dbowner_connection(procedure = _('deleting a translation')) if conn is None: return False return gmPG2.delete_translation_from_database(link_obj = conn, language = translation['lang'], original = translation['orig'])
def format(self, include_sql=False): txt = '%s [#%s]\n' % (gmTools.bool2subst( self._payload[self._idx['is_active']], _('Active clinical hint'), _('Inactive clinical hint')), self._payload[ self._idx['pk_auto_hint']]) txt += '\n' txt += self._payload[self._idx['title']] txt += '\n' txt += '\n' txt += _('Source: %s\n') % self._payload[self._idx['source']] txt += _('Language: %s\n') % self._payload[self._idx['lang']] txt += '\n' txt += gmTools.wrap(self._payload[self._idx['hint']], width=50, initial_indent=' ', subsequent_indent=' ') txt += '\n' txt += '\n' if self._payload[self._idx['recommendation']] is not None: txt += gmTools.wrap(self._payload[self._idx['recommendation']], width=50, initial_indent=' ', subsequent_indent=' ') txt += '\n' txt += '\n' txt += gmTools.wrap(gmTools.coalesce(self._payload[self._idx['url']], ''), width=50, initial_indent=' ', subsequent_indent=' ') txt += '\n' if include_sql: txt += '\n' txt += gmTools.wrap(self._payload[self._idx['query']], width=50, initial_indent=' ', subsequent_indent=' ') txt += '\n' if self._payload[self._idx['recommendation_query']] is not None: txt += '\n' txt += gmTools.wrap( self._payload[self._idx['recommendation_query']], width=50, initial_indent=' ', subsequent_indent=' ') txt += '\n' if self._payload[self._idx['rationale4suppression']] is not None: txt += '\n' txt += _('Rationale for suppression:') txt += '\n' txt += gmTools.wrap( self._payload[self._idx['rationale4suppression']], width=50, initial_indent=' ', subsequent_indent=' ') txt += '\n' return txt
def __get_info_for_episode_problem(self, problem=None, fancy=False): soap = '' emr = self.__pat.emr prev_enc = emr.get_last_but_one_encounter(episode_id = problem['pk_episode']) if prev_enc is not None: soap += prev_enc.format ( episodes = [ problem['pk_episode'] ], with_soap = True, with_docs = fancy, with_tests = fancy, patient = self.__pat, fancy_header = False, with_rfe_aoe = True ) else: if problem['pk_health_issue'] is not None: prev_enc = emr.get_last_but_one_encounter(episode_id = problem['pk_health_issue']) if prev_enc is not None: soap += prev_enc.format ( with_soap = True, with_docs = fancy, with_tests = fancy, patient = self.__pat, issues = [ problem['pk_health_issue'] ], fancy_header = False, with_rfe_aoe = True ) if problem['pk_health_issue'] is None: tmp = emr.active_encounter.format_soap(soap_cats = 'soapu', emr = emr) else: tmp = emr.active_encounter.format_soap(soap_cats = 'soapu', emr = emr, issues = [problem['pk_health_issue']]) if len(tmp) > 0: soap += _('Current encounter:') + '\n' soap += '\n'.join(tmp) + '\n' if problem['summary'] is not None: soap += '\n-- %s ----------\n%s' % ( _('Cumulative summary'), gmTools.wrap ( text = problem['summary'], width = 45, initial_indent = ' ', subsequent_indent = ' ' ).strip('\n') ) return soap
def format(self, left_margin=0, eol=u'\n', width=None, with_formula=False, with_warnings=True, with_variables=False, with_sub_results=False, with_hints=True, return_list=False): lines = [] lines.append(self.message) if with_formula: txt = gmTools.wrap(text=u'%s %s' % (_('Algorithm:'), self.formula_name), width=width, initial_indent=u' ', subsequent_indent=u' ' * 2, eol=eol) lines.append(txt) txt = gmTools.wrap(text=u'%s %s' % (_('Source:'), self.formula_source), width=width, initial_indent=u' ', subsequent_indent=u' ' * 2, eol=eol) lines.append(txt) if with_warnings: if len(self.warnings) > 0: lines.append(u' Caveat:') for w in self.warnings: txt = gmTools.wrap(text=w, width=width, initial_indent=u' %s ' % gmTools.u_arrow2right, subsequent_indent=u' ', eol=eol) lines.append(txt) if with_hints: if len(self.hints) > 0: lines.append(u' Hints:') for h in self.hints: txt = gmTools.wrap(text=h, width=width, initial_indent=u' %s ' % gmTools.u_arrow2right, subsequent_indent=u' ', eol=eol) lines.append(txt) if with_variables: if len(self.variables) > 0: lines.append(u' %s' % _('Variables:')) for key in self.variables.keys(): txt = u' %s %s: %s' % (gmTools.u_arrow2right, key, self.variables[key]) lines.append(txt) if with_sub_results: if len(self.sub_results) > 0: lines.append(u' %s' % _('Intermediate results:')) for r in self.sub_results: lines.extend( r.format( left_margin=left_margin + 1, width=width, eol=eol, with_formula=with_formula, with_warnings=with_warnings, with_variables=with_variables, with_sub_results=False, # break cycles return_list=True)) lines = gmTools.strip_trailing_empty_lines(lines=lines, eol=eol) if return_list: return lines left_margin = u' ' * left_margin return left_margin + (eol + left_margin).join(lines) + eol
def format(self, left_margin=0, eol='\n', width=None, with_formula=False, with_warnings=True, with_variables=False, with_sub_results=False, with_hints=True, return_list=False): lines = [] lines.append(self.message) if with_formula: txt = gmTools.wrap ( text = '%s %s' % ( _('Algorithm:'), self.formula_name ), width = width, initial_indent = ' ', subsequent_indent = ' ' * 2, eol = eol ) lines.append(txt) txt = gmTools.wrap ( text = '%s %s' % ( _('Source:'), self.formula_source ), width = width, initial_indent = ' ', subsequent_indent = ' ' * 2, eol = eol ) lines.append(txt) if with_warnings: if len(self.warnings) > 0: lines.append(' Caveat:') for w in self.warnings: txt = gmTools.wrap(text = w, width = width, initial_indent = ' %s ' % gmTools.u_arrow2right, subsequent_indent = ' ', eol = eol) lines.append(txt) if with_hints: if len(self.hints) > 0: lines.append(' Hints:') for h in self.hints: txt = gmTools.wrap(text = h, width = width, initial_indent = ' %s ' % gmTools.u_arrow2right, subsequent_indent = ' ', eol = eol) lines.append(txt) if with_variables: if len(self.variables) > 0: lines.append(' %s' % _('Variables:')) for key in self.variables.keys(): txt = ' %s %s: %s' % ( gmTools.u_arrow2right, key, self.variables[key] ) lines.append(txt) if with_sub_results: if len(self.sub_results) > 0: lines.append(' %s' % _('Intermediate results:')) for r in self.sub_results: lines.extend(r.format ( left_margin = left_margin + 1, width = width, eol = eol, with_formula = with_formula, with_warnings = with_warnings, with_variables = with_variables, with_sub_results = False, # break cycles return_list = True )) lines = gmTools.strip_trailing_empty_lines(lines = lines, eol = eol) if return_list: return lines left_margin = ' ' * left_margin return left_margin + (eol + left_margin).join(lines) + eol