def format(self): txt = u'%s #%s\n' % ( gmTools.bool2subst ( self._payload[self._idx['is_textual']], _('Textual keyword expansion'), _('Binary keyword expansion') ), self._payload[self._idx['pk_expansion']] ) txt += u' %s%s\n' % ( gmTools.bool2subst ( self._payload[self._idx['private_expansion']], _('private'), _('public') ), gmTools.bool2subst ( self._payload[self._idx['is_encrypted']], u', %s' % _('encrypted'), u'' ) ) txt += _(' Keyword: %s\n') % self._payload[self._idx['keyword']] txt += _(' Owner: %s\n') % self._payload[self._idx['owner']] if self._payload[self._idx['is_textual']]: txt += u'\n%s' % self._payload[self._idx['expansion']] else: txt += u' Data: %s (%s Bytes)' % (gmTools.size2str(self._payload[self._idx['data_size']]), self._payload[self._idx['data_size']]) return txt
def format(self, with_address=False, with_org=True, with_comms=False): lines = [] lines.append(_('Unit%s: %s%s') % ( gmTools.bool2subst ( self._payload[self._idx['is_praxis_branch']], _(' (of your praxis)'), '' ), self._payload[self._idx['unit']], gmTools.coalesce(self._payload[self._idx['l10n_unit_category']], '', ' (%s)') )) if with_org: lines.append(_('Organization: %s (%s)') % ( self._payload[self._idx['organization']], self._payload[self._idx['l10n_organization_category']] )) if with_address: adr = self.address if adr is not None: lines.extend(adr.format()) if with_comms: for comm in self.comm_channels: lines.append('%s: %s%s' % ( comm['l10n_comm_type'], comm['url'], gmTools.bool2subst(comm['is_confidential'], _(' (confidential)'), '', '') )) return lines
def __format_episode_as_timeline_xml(episode, patient): data = { 'category': _('Episodes'), 'start': format_pydt(episode.best_guess_clinical_start_date), 'container_id': gmTools.coalesce(episode['pk_health_issue'], '', '(%s)'), 'label': gmTools.xml_escape_string ( gmTools.shorten_words_in_line(text = episode['description'], max_length = 20, min_word_length = 5) ), 'ends2day': gmTools.bool2subst(episode['episode_open'], 'True', 'False'), 'progress': gmTools.bool2subst(episode['episode_open'], '0', '100'), 'desc': gmTools.xml_escape_string(episode.format ( patient = patient, with_summary = True, with_codes = True, with_encounters = True, with_documents = False, with_hospital_stays = False, with_procedures = False, with_family_history = False, with_tests = False, with_vaccinations = False, with_health_issue = True ).strip().strip('\n').strip()) } end = episode.best_guess_clinical_end_date if end is None: data['end'] = format_pydt(now) else: data['end'] = format_pydt(end) return __xml_episode_template % data
def format_maximum_information(self, patient=None): lines = [] lines.append('%s%s: %s [#%s]' % ( self._payload[self._idx['l10n_type']], gmTools.bool2subst ( self._payload[self._idx['definite']], ' (%s)' % _('definite'), ' (%s)' % _('indefinite'), '' ), self._payload[self._idx['descriptor']], self._payload[self._idx['pk_allergy']] )) if self._payload[self._idx['reaction']] is not None: lines.append(' ' + _('Reaction:') + ' ' + self._payload[self._idx['reaction']]) if self._payload[self._idx['date']] is not None: lines.append(' ' + _('Noted:') + ' ' + gmDateTime.pydt_strftime(self._payload[self._idx['date']], '%Y %b %d')) if self._payload[self._idx['allergene']] is not None: lines.append(' ' + _('Allergene:') + ' ' + self._payload[self._idx['allergene']]) if self._payload[self._idx['substance']] is not None: lines.append(' ' + _('Substance:') + ' ' + self._payload[self._idx['substance']]) if self._payload[self._idx['substance_code']] is not None: lines.append(' ' + _('Code:') + ' ' + self._payload[self._idx['substance_code']]) if self._payload[self._idx['atc_code']] is not None: lines.append(' ' + _('ATC:') + ' ' + self._payload[self._idx['atc_code']]) lines.append(' ' + _('Specific to:') + ' ' + gmTools.bool2subst ( self._payload[self._idx['generic_specific']], _('this substance only'), _('drug class'), _('unknown') )) if self._payload[self._idx['generics']] is not None: lines.append(' ' + _('Generics:') + ' ' + self._payload[self._idx['generics']]) return lines
def __format_episode_as_timeline_xml(episode, patient): end = gmTools.bool2subst( episode['episode_open'], format_pydt(now), format_pydt(episode.latest_access_date), ) return __xml_episode_template % ( format_pydt(episode.best_guess_start_date), # start end, # end gmTools.xml_escape_string(episode['description']), # text gmTools.bool2subst(episode['episode_open'], u'True', u'False'), # ends_today _('Episodes'), # category gmTools.xml_escape_string( episode.format( # description patient=patient, with_summary=True, with_codes=True, with_encounters=True, with_documents=False, with_hospital_stays=False, with_procedures=False, with_family_history=False, with_tests=False, with_vaccinations=False, with_health_issue=True)))
def format(self, *args, **kwargs): lines = [] lines.append(_('%s with %s %s #%s') % ( gmTools.bool2subst(self._payload[self._idx['is_live']], _('Live vaccine'), _('Inactive vaccine'), '<liveness error in DB>'), len(self._payload[self._idx['indications']]), gmTools.bool2subst(len(self._payload[self._idx['indications']]) == 1, _('indication'), _('indications'), _('indication(s)')), self._payload[self._idx['pk_vaccine']] )) lines.append(_(' Product: "%s" #%s') % ( self._payload[self._idx['vaccine']], self._payload[self._idx['pk_drug_product']] )) lines.append(_(' %s%s%s%s') % ( self._payload[self._idx['l10n_preparation']], gmTools.coalesce(gmTools.bool2subst(self._payload[self._idx['is_fake_vaccine']], _('fake product'), None, None), '', ', %s'), gmTools.coalesce(self._payload[self._idx['atc_code']], '', ' [ATC:%s]'), gmTools.coalesce(self._payload[self._idx['external_code']], '', ' [%s:%%s]' % self._payload[self._idx['external_code_type']]) )) #lines.append(_(u' %sage %s - %s') % ( # gmTools.coalesce(self._payload[self._idx['route_description']], u'', u'%s, '), #route_abbreviation lines.append(_(' Age %s - %s') % ( gmTools.coalesce(self._payload[self._idx['min_age']], '?'), gmTools.coalesce(self._payload[self._idx['max_age']], '?') )) if self._payload[self._idx['comment']] is not None: lines.extend([ ' %s' % l for l in self._payload[self._idx['comment']].split('\n')] ) lines.append(_(' Indications')) lines.extend( [ ' %s [ATC:%s]' % (i['l10n_indication'], i['atc_indication']) for i in self._payload[self._idx['indications']] ]) return lines
def format_maximum_information(self, patient=None): lines = [] lines.append(u'%s%s: %s [#%s]' % ( self._payload[self._idx['l10n_type']], gmTools.bool2subst ( self._payload[self._idx['definite']], u' (%s)' % _('definite'), u' (%s)' % _('indefinite'), u'' ), self._payload[self._idx['descriptor']], self._payload[self._idx['pk_allergy']] )) if self._payload[self._idx['reaction']] is not None: lines.append(u' ' + _('Reaction:') + u' ' + self._payload[self._idx['reaction']]) if self._payload[self._idx['date']] is not None: lines.append(u' ' + _('Noted:') + u' ' + gmDateTime.pydt_strftime(self._payload[self._idx['date']], '%Y %b %d')) if self._payload[self._idx['allergene']] is not None: lines.append(u' ' + _('Allergene:') + u' ' + self._payload[self._idx['allergene']]) if self._payload[self._idx['substance']] is not None: lines.append(u' ' + _('Substance:') + u' ' + self._payload[self._idx['substance']]) if self._payload[self._idx['substance_code']] is not None: lines.append(u' ' + _('Code:') + u' ' + self._payload[self._idx['substance_code']]) if self._payload[self._idx['atc_code']] is not None: lines.append(u' ' + _('ATC:') + u' ' + self._payload[self._idx['atc_code']]) lines.append(u' ' + _('Specific to:') + u' ' + gmTools.bool2subst ( self._payload[self._idx['generic_specific']], _('this substance only'), _('drug class'), _('unknown') )) if self._payload[self._idx['generics']] is not None: lines.append(u' ' + _('Generics:') + u' ' + self._payload[self._idx['generics']]) return lines
def __format_episode_as_timeline_xml(episode, patient): data = { 'category': _('Episodes'), 'start': format_pydt(episode.best_guess_clinical_start_date), 'container_id': gmTools.coalesce ( value2test = episode['pk_health_issue'], return_instead = '', template4value = '(%s)' ), 'label': gmTools.xml_escape_string ( gmTools.shorten_words_in_line(text = episode['description'], max_length = 20, min_word_length = 5) ), 'ends2day': gmTools.bool2subst(episode['episode_open'], 'True', 'False'), 'progress': gmTools.bool2subst(episode['episode_open'], '0', '100'), 'desc': gmTools.xml_escape_string(episode.format ( patient = patient, with_summary = True, with_codes = True, with_encounters = True, with_documents = False, with_hospital_stays = False, with_procedures = False, with_family_history = False, with_tests = False, with_vaccinations = False, with_health_issue = True ).strip().strip('\n').strip()) } end = episode.best_guess_clinical_end_date if end is None: data['end'] = format_pydt(now) else: data['end'] = format_pydt(end) return __xml_episode_template % data
def __format_episode_as_timeline_xml(episode, patient): end = gmTools.bool2subst ( episode['episode_open'], format_pydt(now), format_pydt(episode.latest_access_date), ) return __xml_episode_template % ( format_pydt(episode.best_guess_start_date), # start end, # end gmTools.xml_escape_string(episode['description']), # text gmTools.bool2subst(episode['episode_open'], u'True', u'False'), # ends_today _('Episodes'), # category gmTools.xml_escape_string(episode.format ( # description patient = patient, with_summary = True, with_codes = True, with_encounters = True, with_documents = False, with_hospital_stays = False, with_procedures = False, with_family_history = False, with_tests = False, with_vaccinations = False, with_health_issue = True )) )
def refresh_issues(lctrl): #issues = [ i for i in emr.health_issues ] issues = emr.health_issues lctrl.set_string_items([[ gmTools.bool2subst(i['is_confidential'], _('!! CONFIDENTIAL !!'), ''), i['description'], gmTools.bool2subst(i['is_active'], _('active'), _('inactive')) ] for i in issues]) lctrl.set_data(issues)
def format(self, include_receiver=True, include_doc=True): txt = '%s [#%s]\n' % (gmTools.bool2subst( (self._payload[self._idx['close_date']] is None), _('Open bill'), _('Closed bill')), self._payload[self._idx['pk_bill']]) txt += _(' Invoice ID: %s\n') % self._payload[self._idx['invoice_id']] if self._payload[self._idx['close_date']] is not None: txt += _(' Closed: %s\n') % gmDateTime.pydt_strftime( self._payload[self._idx['close_date']], '%Y %b %d', accuracy=gmDateTime.acc_days) if self._payload[self._idx['comment']] is not None: txt += _(' Comment: %s\n') % self._payload[self._idx['comment']] txt += _(' Bill value: %(curr)s%(val)s\n') % { 'curr': self._payload[self._idx['currency']], 'val': self._payload[self._idx['total_amount']] } if self._payload[self._idx['apply_vat']] is None: txt += _(' VAT: undecided\n') elif self._payload[self._idx['apply_vat']] is True: txt += _(' VAT: %(perc_vat)s%% %(equals)s %(curr)s%(vat)s\n') % { 'perc_vat': self._payload[self._idx['percent_vat']], 'equals': gmTools.u_corresponds_to, 'curr': self._payload[self._idx['currency']], 'vat': self._payload[self._idx['total_vat']] } txt += _(' Value + VAT: %(curr)s%(val)s\n') % { 'curr': self._payload[self._idx['currency']], 'val': self._payload[self._idx['total_amount_with_vat']] } else: txt += _(' VAT: does not apply\n') if self._payload[self._idx['pk_bill_items']] is None: txt += _(' Items billed: 0\n') else: txt += _(' Items billed: %s\n') % len( self._payload[self._idx['pk_bill_items']]) if include_doc: txt += _(' Invoice: %s\n') % (gmTools.bool2subst( self._payload[self._idx['pk_doc']] is None, _('not available'), '#%s' % self._payload[self._idx['pk_doc']])) txt += _(' Patient: #%s\n') % self._payload[self._idx['pk_patient']] if include_receiver: txt += gmTools.coalesce( self._payload[self._idx['pk_receiver_identity']], '', _(' Receiver: #%s\n')) if self._payload[self._idx['pk_receiver_address']] is not None: txt += '\n '.join( gmDemographicRecord.get_patient_address( pk_patient_address=self._payload[ self._idx['pk_receiver_address']]).format()) return txt
def _calc_contacts_list_item_tooltip(self, data): if isinstance(data, gmEMRStructItems.cHospitalStay): return data.format() if isinstance(data, gmExternalCare.cExternalCareItem): return '\n'.join(data.format ( with_health_issue = True, with_address = True, with_comms = True )) if isinstance(data, gmDemographicRecord.cPatientAddress): return '\n'.join(data.format()) if isinstance(data, gmDemographicRecord.cCommChannel): parts = [] if data['is_confidential']: parts.append(_('*** CONFIDENTIAL ***')) if data['comment'] is not None: parts.append(data['comment']) return '\n'.join(parts) if isinstance(data, gmPerson.cPerson): return '%s\n\n%s' % ( data['description_gender'], '\n'.join([ '%s: %s%s' % ( c['l10n_comm_type'], c['url'], gmTools.bool2subst(c['is_confidential'], _(' (confidential !)'), '', '') ) for c in data.get_comm_channels() ]) ) if isinstance(data, str): return data if isinstance(data, gmStaff.cStaff): ident = data.identity return '%s: %s\n\n%s%s' % ( data['short_alias'], ident['description_gender'], '\n'.join([ '%s: %s%s' % ( c['l10n_comm_type'], c['url'], gmTools.bool2subst(c['is_confidential'], _(' (confidential !)'), '', '') ) for c in ident.get_comm_channels() ]), gmTools.coalesce(data['comment'], '', '\n\n%s') ) return None
def _calc_contacts_list_item_tooltip(self, data): if isinstance(data, gmEMRStructItems.cHospitalStay): return data.format() if isinstance(data, gmExternalCare.cExternalCareItem): return '\n'.join(data.format ( with_health_issue = True, with_address = True, with_comms = True )) if isinstance(data, gmDemographicRecord.cPatientAddress): return '\n'.join(data.format()) if isinstance(data, gmDemographicRecord.cCommChannel): parts = [] if data['is_confidential']: parts.append(_('*** CONFIDENTIAL ***')) if data['comment'] is not None: parts.append(data['comment']) return '\n'.join(parts) if isinstance(data, gmPerson.cPerson): return '%s\n\n%s' % ( data.description_gender, '\n'.join([ '%s: %s%s' % ( c['l10n_comm_type'], c['url'], gmTools.bool2subst(c['is_confidential'], _(' (confidential !)'), '', '') ) for c in data.get_comm_channels() ]) ) if isinstance(data, str): return data if isinstance(data, gmStaff.cStaff): ident = data.identity return '%s: %s\n\n%s%s' % ( data['short_alias'], ident.description_gender, '\n'.join([ '%s: %s%s' % ( c['l10n_comm_type'], c['url'], gmTools.bool2subst(c['is_confidential'], _(' (confidential !)'), '', '') ) for c in ident.get_comm_channels() ]), gmTools.coalesce(data['comment'], '', '\n\n%s') ) return None
def refresh(lctrl=None): expansions = gmKeywordExpansion.get_keyword_expansions(order_by = 'is_textual DESC, keyword, public_expansion', force_reload = True) items = [[ e['keyword'], gmTools.bool2subst(e['is_textual'], _('text'), _('data')), gmTools.bool2subst(e['public_expansion'], _('public'), _('private')) ] for e in expansions ] lctrl.set_string_items(items) lctrl.set_data(expansions)
def refresh_issues(lctrl): #issues = [ i for i in emr.health_issues ] issues = emr.health_issues lctrl.set_string_items ([ [ gmTools.bool2subst(i['is_confidential'], _('!! CONFIDENTIAL !!'), ''), i['description'], gmTools.bool2subst(i['is_active'], _('active'), _('inactive')) ] for i in issues ]) lctrl.set_data(issues)
def refresh(lctrl): issues = emr.get_health_issues() items = [ [ gmTools.bool2subst(i['is_confidential'], _('CONFIDENTIAL'), '', ''), i['description'], gmTools.bool2subst(i['clinically_relevant'], _('relevant'), '', ''), gmTools.bool2subst(i['is_active'], _('active'), '', ''), gmTools.bool2subst(i['is_cause_of_death'], _('fatal'), '', '') ] for i in issues ] lctrl.set_string_items(items = items) lctrl.set_data(data = issues)
def _on_delete_focussed_msg(self, evt): if self.__focussed_msg['is_virtual']: gmDispatcher.send(signal = 'statustext', msg = _('You must deal with the reason for this message to remove it from your inbox.'), beep = True) return False # if not "to" current provider, then don't delete if self.__focussed_msg['pk_staff'] != gmStaff.gmCurrentProvider()['pk_staff']: gmDispatcher.send(signal = 'statustext', msg = _('This message can only be deleted by [%s].') % self.__focussed_msg['provider'], beep = True) return False pk_patient = self.__focussed_msg['pk_patient'] if pk_patient is not None: emr = gmClinicalRecord.cClinicalRecord(aPKey = pk_patient) epi = emr.add_episode(episode_name = 'administrative', is_open = False) soap_cat = gmTools.bool2subst ( (self.__focussed_msg['category'] == 'clinical'), 'u', None ) narr = _('Deleted inbox message:\n%s') % self.__focussed_msg.format(with_patient = False) emr.add_clin_narrative(note = narr, soap_cat = soap_cat, episode = epi) gmDispatcher.send(signal = 'statustext', msg = _('Recorded deletion of inbox message in EMR.'), beep = False) if not self.provider.inbox.delete_message(self.__focussed_msg['pk_inbox_message']): gmDispatcher.send(signal='statustext', msg=_('Problem removing message from Inbox.')) return False return True
def format(self): txt = '%s [#%s]\n\n' % ( gmTools.bool2subst ( self._payload[self._idx['active']], _('Active billable item'), _('Inactive billable item') ), self._payload[self._idx['pk_billable']] ) txt += ' %s: %s\n' % ( self._payload[self._idx['billable_code']], self._payload[self._idx['billable_description']] ) txt += _(' %(curr)s%(raw_val)s + %(perc_vat)s%% VAT = %(curr)s%(val_w_vat)s\n') % { 'curr': self._payload[self._idx['currency']], 'raw_val': self._payload[self._idx['raw_amount']], 'perc_vat': self._payload[self._idx['vat_multiplier']] * 100, 'val_w_vat': self._payload[self._idx['amount_with_vat']] } txt += ' %s %s%s (%s)' % ( self._payload[self._idx['catalog_short']], self._payload[self._idx['catalog_version']], gmTools.coalesce(self._payload[self._idx['catalog_language']], '', ' - %s'), self._payload[self._idx['catalog_long']] ) txt += gmTools.coalesce(self._payload[self._idx['comment']], '', '\n %s') return txt
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 GetLoginInfo(self): """convenience function for compatibility with gmLoginInfo.LoginInfo""" if self.cancelled: return None # FIXME: do not assume conf file is latin1 ! # profile = self.__backend_profiles[self._CBOX_profile.GetValue().encode('latin1').strip()] profile = self.__backend_profiles[self._CBOX_profile.GetValue().encode("utf8").strip()] _log.info(u'backend profile "%s" selected', profile.name) _log.info( u" details: <%s> on %s@%s:%s (%s, %s)", self._CBOX_user.GetValue(), profile.database, profile.host, profile.port, profile.encoding, gmTools.bool2subst(profile.public_db, u"public", u"private"), ) _log.info(u' helpdesk: "%s"', profile.helpdesk) login = gmLoginInfo.LoginInfo( user=self._CBOX_user.GetValue(), password=self.pwdentry.GetValue(), host=profile.host, database=profile.database, port=profile.port, ) login.public_db = profile.public_db login.helpdesk = profile.helpdesk login.backend_profile = profile.name return login
def format(self, with_health_issue=True, with_address=False, with_comms=False): lines = [] lines.append(_(u'External care #%s') % self._payload[self._idx['pk_external_care']]) if with_health_issue: if self._payload[self._idx['pk_health_issue']] is None: lines.append(u' ' + _(u'Issue: %s') % self._payload[self._idx['issue']]) else: lines.append(u' ' + _(u'Health issue: %s') % self._payload[self._idx['issue']]) lines.append(u' (' + _(u'also treated here') + u')') if self._payload[self._idx['provider']] is not None: lines.append(u' ' + _(u'Provider: %s') % self._payload[self._idx['provider']]) lines.append(u' ' + _(u'Location: %s@%s') % (self._payload[self._idx['unit']], self._payload[self._idx['organization']])) unit = self.org_unit if with_address: adr = unit.address if adr is not None: lines.extend(adr.format()) if with_comms: for comm in unit.comm_channels: lines.append(u' %s: %s%s' % ( comm['l10n_comm_type'], comm['url'], gmTools.bool2subst(comm['is_confidential'], _(' (confidential)'), u'', u'') )) if self._payload[self._idx['comment']] is not None: lines.append(u'') lines.append(u' ' + self._payload[self._idx['comment']]) return lines
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 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 refresh(lctrl): vaccines = gmVaccination.get_vaccines(order_by = 'vaccine') items = [ [ u'%s' % v['pk_brand'], u'%s%s' % ( v['vaccine'], gmTools.bool2subst ( v['is_fake_vaccine'], u' (%s)' % _('fake'), u'' ) ), v['preparation'], #u'%s (%s)' % (v['route_abbreviation'], v['route_description']), #gmTools.bool2subst(v['is_live'], gmTools.u_checkmark_thin, u'', u'?'), gmTools.coalesce(v['atc_code'], u''), u'%s%s' % ( gmTools.coalesce(v['min_age'], u'?'), gmTools.coalesce(v['max_age'], u'?', u' - %s'), ), gmTools.coalesce(v['comment'], u'') ] for v in vaccines ] lctrl.set_string_items(items) lctrl.set_data(vaccines)
def _on_delete_focussed_msg(self, evt): if self.__focussed_msg['is_virtual']: gmDispatcher.send(signal = 'statustext', msg = _('You must deal with the reason for this message to remove it from your inbox.'), beep = True) return False # if not "to" current provider, then don't delete if self.__focussed_msg['pk_staff'] != gmStaff.gmCurrentProvider()['pk_staff']: gmDispatcher.send(signal = 'statustext', msg = _('This message can only be deleted by [%s].') % self.__focussed_msg['provider'], beep = True) return False pk_patient = self.__focussed_msg['pk_patient'] if pk_patient is not None: #emr = gmClinicalRecord.cClinicalRecord(aPKey = pk_patient, allow_user_interaction = False) from Gnumed.wxpython import gmChartPullingWidgets emr = gmChartPullingWidgets.pull_chart(gmPerson.cPerson(pk_patient)) if emr is None: return False epi = emr.add_episode(episode_name = 'administrative', is_open = False) soap_cat = gmTools.bool2subst ( (self.__focussed_msg['category'] == u'clinical'), u'U', None ) narr = _('Deleted inbox message:\n%s') % self.__focussed_msg.format(with_patient = False) emr.add_clin_narrative(note = narr, soap_cat = soap_cat, episode = epi) gmDispatcher.send(signal = 'statustext', msg = _('Recorded deletion of inbox message in EMR.'), beep = False) if not self.provider.inbox.delete_message(self.__focussed_msg['pk_inbox_message']): gmDispatcher.send(signal='statustext', msg=_('Problem removing message from Inbox.')) return False return True
def GetLoginInfo(username=None, password=None, backend=None ): # username is provided through the web interface # password is provided # we need the profile """convenience function for compatibility with gmLoginInfo.LoginInfo""" from Gnumed.pycommon import gmLoginInfo #if not self.cancelled: # FIXME: do not assume conf file is latin1 ! #profile = self.__backend_profiles[self._CBOX_profile.GetValue().encode('latin1').strip()] #self.__backend_profiles = self.__get_backend_profiles() __backend_profiles = __get_backend_profiles() profile = __backend_profiles[backend.encode('utf8').strip()] _log.debug(u'backend profile "%s" selected', profile.name) _log.debug(u' details: <%s> on %s@%s:%s (%s, %s)', username, profile.database, profile.host, profile.port, profile.encoding, gmTools.bool2subst(profile.public_db, u'public', u'private') ) #_log.debug(u' helpdesk: "%s"', profile.helpdesk) login = gmLoginInfo.LoginInfo ( user = username, password = password, host = profile.host, database = profile.database, port = profile.port ) #login.public_db = profile.public_db #login.helpdesk = profile.helpdesk return login
def _on_delete_focussed_msg(self, evt): if self.__focussed_msg['is_virtual']: gmDispatcher.send(signal = 'statustext', msg = _('You must deal with the reason for this message to remove it from your inbox.'), beep = True) return False # message to a certain provider ? if self.__focussed_msg['pk_staff'] is not None: # do not delete messages to *other* providers if self.__focussed_msg['pk_staff'] != gmStaff.gmCurrentProvider()['pk_staff']: gmDispatcher.send(signal = 'statustext', msg = _('This message can only be deleted by [%s].') % self.__focussed_msg['provider'], beep = True) return False pk_patient = self.__focussed_msg['pk_patient'] if pk_patient is not None: emr = gmClinicalRecord.cClinicalRecord(aPKey = pk_patient) epi = emr.add_episode(episode_name = 'administrative', is_open = False) soap_cat = gmTools.bool2subst ( (self.__focussed_msg['category'] == 'clinical'), 'u', None ) narr = _('Deleted inbox message:\n%s') % self.__focussed_msg.format(with_patient = False) emr.add_clin_narrative(note = narr, soap_cat = soap_cat, episode = epi) gmDispatcher.send(signal = 'statustext', msg = _('Recorded deletion of inbox message in EMR.'), beep = False) if not self.provider.inbox.delete_message(self.__focussed_msg['pk_inbox_message']): gmDispatcher.send(signal='statustext', msg=_('Problem removing message from Inbox.')) return False return True
def format(self): txt = '%s [#%s]\n\n' % ( gmTools.bool2subst(self._payload[self._idx['active']], _('Active billable item'), _('Inactive billable item')), self._payload[self._idx['pk_billable']]) txt += ' %s: %s\n' % (self._payload[self._idx['billable_code']], self._payload[self._idx['billable_description']]) txt += _( ' %(curr)s%(raw_val)s + %(perc_vat)s%% VAT = %(curr)s%(val_w_vat)s\n' ) % { 'curr': self._payload[self._idx['currency']], 'raw_val': self._payload[self._idx['raw_amount']], 'perc_vat': self._payload[self._idx['vat_multiplier']] * 100, 'val_w_vat': self._payload[self._idx['amount_with_vat']] } txt += ' %s %s%s (%s)' % ( self._payload[self._idx['catalog_short']], self._payload[self._idx['catalog_version']], gmTools.coalesce( self._payload[self._idx['catalog_language']], '', ' - %s'), self._payload[self._idx['catalog_long']]) txt += gmTools.coalesce(self._payload[self._idx['comment']], '', '\n %s') return txt
def _set_is_print_job(self, is_print_job): desig = gmTools.bool2subst(is_print_job, PRINT_JOB_DESIGNATION, None, None) if self._payload[self._idx['designation']] == desig: return self['designation'] = desig self.save()
def GetLoginInfo(username=None, password=None, backend=None): # username is provided through the web interface # password is provided # we need the profile """convenience function for compatibility with gmLoginInfo.LoginInfo""" #if not self.cancelled: # FIXME: do not assume conf file is latin1 ! #profile = self.__backend_profiles[self._CBOX_profile.GetValue().encode('latin1').strip()] #self.__backend_profiles = self.__get_backend_profiles() __backend_profiles = __get_backend_profiles() profile = __backend_profiles[backend.encode('utf8').strip()] _log.debug(u'backend profile "%s" selected', profile.name) _log.debug(u' details: <%s> on %s@%s:%s (%s, %s)', username, profile.database, profile.host, profile.port, profile.encoding, gmTools.bool2subst(profile.public_db, u'public', u'private')) #_log.debug(u' helpdesk: "%s"', profile.helpdesk) login = gmLoginInfo.LoginInfo(user=username, password=password, host=profile.host, database=profile.database, port=profile.port) #login.public_db = profile.public_db #login.helpdesk = profile.helpdesk return login
def run(self, patient=None, debug=False): self.pdf_result = None cfg_file = self.__write_config_file(patient=patient) # FIXME: add user-configured path if not self.__detect_binary(): return False args = (self.path_to_binary, '--file=%s' % cfg_file, '--show-cli-pane=%s' % gmTools.bool2subst(debug, 'true', 'false')) try: subprocess.check_call(args=args, close_fds=True) except (OSError, ValueError, subprocess.CalledProcessError): _log.exception('there was a problem executing [%s]', self.path_to_binary) gmDispatcher.send(signal='statustext', msg=_('Cannot run [arriba] !'), beep=True) return False try: open(self.pdf_result).close() except Exception: _log.exception('error accessing [%s]', self.pdf_result) gmDispatcher.send(signal='statustext', msg=_('No [arriba] result found in [%s].') % self.pdf_result, beep=False) return False return True
def format(self, with_patient=True): tt = '%s: %s%s\n' % ( gmDateTime.pydt_strftime ( self._payload[self._idx['received_when']], format = '%A, %Y %b %d, %H:%M', accuracy = gmDateTime.acc_minutes ), gmTools.bool2subst(self._payload[self._idx['is_virtual']], _('virtual message'), _('message')), gmTools.coalesce(self._payload[self._idx['pk_inbox_message']], '', ' #%s ') ) tt += '%s: %s\n' % ( self._payload[self._idx['l10n_category']], self._payload[self._idx['l10n_type']] ) tt += '%s %s %s\n' % ( self._payload[self._idx['modified_by']], gmTools.u_arrow2right, gmTools.coalesce(self._payload[self._idx['provider']], _('everyone')) ) tt += '\n%s%s%s\n\n' % ( gmTools.u_left_double_angle_quote, self._payload[self._idx['comment']], gmTools.u_right_double_angle_quote ) if with_patient and (self._payload[self._idx['pk_patient']] is not None): tt += _('Patient: %s, %s%s %s #%s\n' % ( self._payload[self._idx['lastnames']], self._payload[self._idx['firstnames']], gmTools.coalesce(self._payload[self._idx['l10n_gender']], '', ' (%s)'), gmDateTime.pydt_strftime(self._payload[self._idx['dob']], '%Y %b %d', none_str = ''), self._payload[self._idx['pk_patient']] )) if self._payload[self._idx['due_date']] is not None: if self._payload[self._idx['is_overdue']]: template = _('Due: %s (%s ago)\n') else: template = _('Due: %s (in %s)\n') tt += template % ( gmDateTime.pydt_strftime(self._payload[self._idx['due_date']], '%Y %b %d'), gmDateTime.format_interval_medically(self._payload[self._idx['interval_due']]) ) if self._payload[self._idx['expiry_date']] is not None: if self._payload[self._idx['is_expired']]: template = _('Expired: %s\n') else: template = _('Expires: %s\n') tt += template % gmDateTime.pydt_strftime(self._payload[self._idx['expiry_date']], '%Y %b %d') if self._payload[self._idx['data']] is not None: tt += self._payload[self._idx['data']][:150] if len(self._payload[self._idx['data']]) > 150: tt += gmTools.u_ellipsis return tt
def run(self, patient=None, debug=False): self.pdf_result = None cfg_file = self.__write_config_file(patient = patient) # FIXME: add user-configured path if not self.__detect_binary(): return False args = ( self.path_to_binary, '--file=%s' % cfg_file, '--show-cli-pane=%s' % gmTools.bool2subst(debug, 'true', 'false') ) try: subprocess.check_call(args = args, close_fds = True) except (OSError, ValueError, subprocess.CalledProcessError): _log.exception('there was a problem executing [%s]', self.path_to_binary) gmDispatcher.send(signal = u'statustext', msg = _('Cannot run [arriba] !'), beep = True) return False try: open(self.pdf_result).close() except: _log.exception('error accessing [%s]', self.pdf_result) gmDispatcher.send(signal = u'statustext', msg = _('No [arriba] result found in [%s].') % self.pdf_result, beep = False) return False return True
def format_header(self, eol=None): lines = [] lines.append( _('Chart entry (%s): %s [#%s in %s]') % (self.i18n_soap_cat, self.item_type_str, self._payload[self._idx['src_pk']], self._payload[self._idx['src_table']])) lines.append( _(' Modified: %s by %s (%s rev %s)') % (self._payload[self._idx['date_modified']], self._payload[self._idx['modified_by']], gmTools.u_arrow2right, self._payload[self._idx['row_version']])) lines.append('') if self._payload[self._idx['health_issue']] is None: issue_info = gmTools.u_diameter else: issue_info = '%s%s' % ( self._payload[self._idx['health_issue']], gmTools.bool2subst(self._payload[self._idx['issue_active']], ' (' + _('active') + ')', ' (' + _('inactive') + ')', '')) lines.append(_('Health issue: %s') % issue_info) if self._payload[self._idx['episode']] is None: episode_info = gmTools.u_diameter else: episode_info = '%s%s' % ( self._payload[self._idx['episode']], gmTools.bool2subst(self._payload[self._idx['episode_open']], ' (' + _('open') + ')', ' (' + _('closed') + ')', '')) lines.append(_('Episode: %s') % episode_info) if self._payload[self._idx['encounter_started']] is None: enc_info = gmTools.u_diameter else: enc_info = '%s - %s (%s)' % (gmDateTime.pydt_strftime( self._payload[self._idx['encounter_started']], '%Y %b %d %H:%M' ), self._payload[self._idx['encounter_last_affirmed']].strftime( '%H:%M'), self._payload[self._idx['encounter_l10n_type']]) lines.append(_('Encounter: %s') % enc_info) lines.append( _('Event: %s') % self._payload[self._idx['clin_when']].strftime('%Y %b %d %H:%M')) if eol is None: return lines return eol.join(lines)
def refresh_episodes(lctrl): all_epis = [ epi for epi in emr.get_episodes(order_by = 'description') if epi.has_narrative ] lctrl.set_string_items ([ [ '%s%s' % (e['description'], gmTools.coalesce(e['health_issue'], '', ' (%s)')), gmTools.bool2subst(e['episode_open'], _('open'), _('closed')) ] for e in all_epis ]) lctrl.set_data(all_epis)
def format(self, with_patient=True): tt = '%s: %s%s\n' % ( gmDateTime.pydt_strftime(self._payload[self._idx['received_when']], format='%A, %Y %b %d, %H:%M', accuracy=gmDateTime.acc_minutes), gmTools.bool2subst(self._payload[self._idx['is_virtual']], _('virtual message'), _('message')), gmTools.coalesce(self._payload[self._idx['pk_inbox_message']], '', ' #%s ')) tt += '%s: %s\n' % (self._payload[self._idx['l10n_category']], self._payload[self._idx['l10n_type']]) tt += '%s %s %s\n' % ( self._payload[self._idx['modified_by']], gmTools.u_arrow2right, gmTools.coalesce(self._payload[self._idx['provider']], _('everyone'))) tt += '\n%s%s%s\n\n' % (gmTools.u_left_double_angle_quote, self._payload[self._idx['comment']], gmTools.u_right_double_angle_quote) if with_patient and (self._payload[self._idx['pk_patient']] is not None): tt += _( 'Patient: %s, %s%s %s #%s\n' % (self._payload[self._idx['lastnames']], self._payload[self._idx['firstnames']], gmTools.coalesce(self._payload[self._idx['l10n_gender']], '', ' (%s)'), gmDateTime.pydt_strftime( self._payload[self._idx['dob']], '%Y %b %d', none_str=''), self._payload[self._idx['pk_patient']])) if self._payload[self._idx['due_date']] is not None: if self._payload[self._idx['is_overdue']]: template = _('Due: %s (%s ago)\n') else: template = _('Due: %s (in %s)\n') tt += template % (gmDateTime.pydt_strftime( self._payload[self._idx['due_date']], '%Y %b %d'), gmDateTime.format_interval_medically( self._payload[self._idx['interval_due']])) if self._payload[self._idx['expiry_date']] is not None: if self._payload[self._idx['is_expired']]: template = _('Expired: %s\n') else: template = _('Expires: %s\n') tt += template % gmDateTime.pydt_strftime( self._payload[self._idx['expiry_date']], '%Y %b %d') if self._payload[self._idx['data']] is not None: tt += self._payload[self._idx['data']][:150] if len(self._payload[self._idx['data']]) > 150: tt += gmTools.u_ellipsis return tt
def format(self): txt = '%s (%s %s%s) [#%s]\n' % ( gmTools.bool2subst( self._payload[self._idx['pk_bill']] is None, _('Open item'), _('Billed item'), ), self._payload[self._idx['catalog_short']], self._payload[self._idx['catalog_version']], gmTools.coalesce(self._payload[self._idx['catalog_language']], '', ' - %s'), self._payload[self._idx['pk_bill_item']] ) txt += ' %s: %s\n' % ( self._payload[self._idx['billable_code']], self._payload[self._idx['billable_description']] ) txt += gmTools.coalesce ( self._payload[self._idx['billable_comment']], '', ' (%s)\n', ) txt += gmTools.coalesce ( self._payload[self._idx['item_detail']], '', _(' Details: %s\n'), ) txt += '\n' txt += _(' %s of units: %s\n') % ( gmTools.u_numero, self._payload[self._idx['unit_count']] ) txt += _(' Amount per unit: %(curr)s%(val_p_unit)s (%(cat_curr)s%(cat_val)s per catalog)\n') % { 'curr': self._payload[self._idx['currency']], 'val_p_unit': self._payload[self._idx['net_amount_per_unit']], 'cat_curr': self._payload[self._idx['billable_currency']], 'cat_val': self._payload[self._idx['billable_amount']] } txt += _(' Amount multiplier: %s\n') % self._payload[self._idx['amount_multiplier']] txt += _(' VAT would be: %(perc_vat)s%% %(equals)s %(curr)s%(vat)s\n') % { 'perc_vat': self._payload[self._idx['vat_multiplier']] * 100, 'equals': gmTools.u_corresponds_to, 'curr': self._payload[self._idx['currency']], 'vat': self._payload[self._idx['vat']] } txt += '\n' txt += _(' Charge date: %s') % gmDateTime.pydt_strftime ( self._payload[self._idx['date_to_bill']], '%Y %b %d', accuracy = gmDateTime.acc_days ) bill = self.bill if bill is not None: txt += _('\n On bill: %s') % bill['invoice_id'] return txt
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 refresh(lctrl): hints = gmAutoHints.get_dynamic_hints( order_by='is_active DESC, source, hint') items = [[ gmTools.bool2subst(h['is_active'], gmTools.u_checkmark_thin, ''), h['title'], h['source'][:30], h['hint'][:60], gmTools.coalesce(h['url'], '')[:60], h['lang'], h['pk_auto_hint'] ] for h in hints] lctrl.set_string_items(items) lctrl.set_data(hints)
def refresh(lctrl): reminders = gmProviderInbox.get_reminders(pk_patient=patient) items = [[ gmTools.bool2subst(r['is_overdue'], _('overdue for %s'), _('due in %s')) % gmDateTime.format_interval_medically(r['interval_due']), r['comment'], r['pk_inbox_message'] ] for r in reminders] lctrl.set_string_items(items) lctrl.set_data(reminders)
def format(self, with_health_issue=True, with_address=False, with_comms=False): lines = [] lines.append( _('External care%s #%s') % (gmTools.bool2subst(self._payload[self._idx['inactive']], ' (%s)' % _('inactive'), '', ' [ERROR: .inactive is NULL]'), self._payload[self._idx['pk_external_care']])) if with_health_issue: if self._payload[self._idx['pk_health_issue']] is None: lines.append(' ' + _('Issue: %s') % self._payload[self._idx['issue']]) else: lines.append(' ' + _('Health issue: %s') % self._payload[self._idx['issue']]) lines.append(' (' + _('also treated here') + ')') if self._payload[self._idx['provider']] is not None: lines.append(' ' + _('Provider: %s') % self._payload[self._idx['provider']]) lines.append(' ' + _('Location: %s@%s') % (self._payload[self._idx['unit']], self._payload[self._idx['organization']])) unit = self.org_unit if with_address: adr = unit.address if adr is not None: lines.extend(adr.format()) if with_comms: for comm in unit.comm_channels: lines.append( ' %s: %s%s' % (comm['l10n_comm_type'], comm['url'], gmTools.bool2subst(comm['is_confidential'], _(' (confidential)'), '', ''))) if self._payload[self._idx['comment']] is not None: lines.append('') lines.append(' ' + self._payload[self._idx['comment']]) return lines
def refresh(lctrl): epis = emr.get_episodes(order_by = 'description') items = [ [ e['description'], gmTools.bool2subst(e['episode_open'], _('ongoing'), _('closed'), '<unknown>'), gmDateTime.pydt_strftime(e.best_guess_clinical_start_date, '%Y %b %d'), gmTools.coalesce(e['health_issue'], '') ] for e in epis ] lctrl.set_string_items(items = items) lctrl.set_data(data = epis)
def refresh(lctrl): care = emr.get_external_care_items( order_by='inactive, issue, provider, unit, organization') items = [[ '%s @ %s' % (c['unit'], c['organization']), gmTools.coalesce(c['provider'], ''), c['issue'], gmTools.bool2subst(c['inactive'], _('inactive'), '', '<ERROR: .inactive IS NULL>'), gmTools.coalesce(c['comment'], '') ] for c in care] lctrl.set_string_items(items) lctrl.set_data(care)
def __refresh_results(self, patient=None): list_items = [] list_data = [] emr = patient.emr most_recent = emr.get_most_recent_results(no_of_results = 1) if most_recent is None: self._LCTRL_results.set_string_items(items = []) self._LCTRL_results.set_data(data = []) return now = gmDateTime.pydt_now_here() list_items.append(_('Latest: %s ago (%s %s%s%s%s)') % ( gmDateTime.format_interval_medically(now - most_recent['clin_when']), most_recent['unified_abbrev'], most_recent['unified_val'], gmTools.coalesce(most_recent['val_unit'], '', ' %s'), gmTools.coalesce(most_recent['abnormality_indicator'], '', ' %s'), gmTools.bool2subst(most_recent['reviewed'], '', (' %s' % gmTools.u_writing_hand)) )) list_data.append(most_recent) most_recent_needs_red = False if most_recent.is_considered_abnormal is True: if most_recent['is_clinically_relevant']: most_recent_needs_red = True unsigned = emr.get_unsigned_results(order_by = "(trim(coalesce(abnormality_indicator), '') <> '') DESC NULLS LAST, unified_abbrev") no_of_reds = 0 for result in unsigned: if result['pk_test_result'] == most_recent['pk_test_result']: continue if result['abnormality_indicator'] is not None: if result['abnormality_indicator'].strip() != '': no_of_reds += 1 list_items.append(_('%s %s%s%s (%s ago, %s)') % ( result['unified_abbrev'], result['unified_val'], gmTools.coalesce(result['val_unit'], '', ' %s'), gmTools.coalesce(result['abnormality_indicator'], '', ' %s'), gmDateTime.format_interval_medically(gmDateTime.pydt_now_here() - result['clin_when']), gmTools.u_writing_hand )) list_data.append(result) self._LCTRL_results.set_string_items(items = list_items) self._LCTRL_results.set_data(data = list_data) if most_recent_needs_red: self._LCTRL_results.SetItemTextColour(0, wx.Colour('RED')) if no_of_reds > 0: for idx in range(1, no_of_reds + 1): self._LCTRL_results.SetItemTextColour(idx, wx.Colour('RED'))
def __refresh_results(self, patient=None): list_items = [] list_data = [] emr = patient.get_emr() most_recent = emr.get_most_recent_results(no_of_results = 1) if most_recent is None: self._LCTRL_results.set_string_items(items = []) self._LCTRL_results.set_data(data = []) return now = gmDateTime.pydt_now_here() list_items.append(_('Latest: %s ago (%s %s%s%s%s)') % ( gmDateTime.format_interval_medically(now - most_recent['clin_when']), most_recent['unified_abbrev'], most_recent['unified_val'], gmTools.coalesce(most_recent['val_unit'], u'', u' %s'), gmTools.coalesce(most_recent['abnormality_indicator'], u'', u' %s'), gmTools.bool2subst(most_recent['reviewed'], u'', (u' %s' % gmTools.u_writing_hand)) )) list_data.append(most_recent) most_recent_needs_red = False if most_recent.is_considered_abnormal is True: if most_recent['is_clinically_relevant']: most_recent_needs_red = True unsigned = emr.get_unsigned_results(order_by = u"(trim(coalesce(abnormality_indicator), '') <> '') DESC NULLS LAST, unified_abbrev") no_of_reds = 0 for result in unsigned: if result['pk_test_result'] == most_recent['pk_test_result']: continue if result['abnormality_indicator'] is not None: if result['abnormality_indicator'].strip() != u'': no_of_reds += 1 list_items.append(_('%s %s%s%s (%s ago, %s)') % ( result['unified_abbrev'], result['unified_val'], gmTools.coalesce(result['val_unit'], u'', u' %s'), gmTools.coalesce(result['abnormality_indicator'], u'', u' %s'), gmDateTime.format_interval_medically(gmDateTime.pydt_now_here() - result['clin_when']), gmTools.u_writing_hand )) list_data.append(result) self._LCTRL_results.set_string_items(items = list_items) self._LCTRL_results.set_data(data = list_data) if most_recent_needs_red: self._LCTRL_results.SetItemTextColour(0, wx.NamedColour('RED')) if no_of_reds > 0: for idx in range(1, no_of_reds + 1): self._LCTRL_results.SetItemTextColour(idx, wx.NamedColour('RED'))
def refresh(lctrl): hints = gmAutoHints.get_dynamic_hints(order_by = 'is_active DESC, source, hint') items = [ [ gmTools.bool2subst(h['is_active'], gmTools.u_checkmark_thin, ''), h['title'], h['source'][:30], h['hint'][:60], gmTools.coalesce(h['url'], '')[:60], h['lang'], h['pk_auto_hint'] ] for h in hints ] lctrl.set_string_items(items) lctrl.set_data(hints)
def edit_waiting_list_entry(parent=None, entry=None, patient=None): if parent is None: parent = wx.GetApp().GetTopWindow() ea = cWaitingListEntryEditAreaPnl(parent, -1, patient = gmTools.bool2subst((entry is None), patient, None)) ea.data = entry ea.mode = gmTools.coalesce(entry, 'new', 'edit') dlg = gmEditArea.cGenericEditAreaDlg2(parent, -1, edit_area = ea, single_entry = True) dlg.SetTitle(gmTools.coalesce(entry, _('Adding new waiting list entry'), _('Editing waiting list entry'))) if dlg.ShowModal() == wx.ID_OK: dlg.DestroyLater() return True dlg.DestroyLater() return False
def refresh(lctrl): reminders = gmProviderInbox.get_reminders(pk_patient = patient) items = [ [ gmTools.bool2subst ( r['is_overdue'], _('overdue for %s'), _('due in %s') ) % gmDateTime.format_interval_medically(r['interval_due']), r['comment'], r['pk_inbox_message'] ] for r in reminders ] lctrl.set_string_items(items) lctrl.set_data(reminders)
def edit_waiting_list_entry(parent=None, entry=None, patient=None): if parent is None: parent = wx.GetApp().GetTopWindow() ea = cWaitingListEntryEditAreaPnl(parent, -1, patient = gmTools.bool2subst((entry is None), patient, None)) ea.data = entry ea.mode = gmTools.coalesce(entry, 'new', 'edit') dlg = gmEditArea.cGenericEditAreaDlg2(parent, -1, edit_area = ea, single_entry = True) dlg.SetTitle(gmTools.coalesce(entry, _('Adding new waiting list entry'), _('Editing waiting list entry'))) if dlg.ShowModal() == wx.ID_OK: dlg.Destroy() return True dlg.Destroy() return False
def refresh(lctrl): hints = gmAutoHints.get_suppressed_hints(pk_identity=pk_identity, order_by='title') items = [[ h['title'], gmDateTime.pydt_strftime(h['suppressed_when'], '%Y %b %d'), h['suppressed_by'], h['rationale'], gmTools.bool2subst(h['is_active'], gmTools.u_checkmark_thin, ''), h['source'][:30], gmTools.coalesce(h['url'], '')[:60], h['pk_hint'] ] for h in hints] lctrl.set_string_items(items) lctrl.set_data(hints)
def refresh(lctrl): hints = gmAutoHints.get_suppressed_hints(pk_identity = pk_identity, order_by = 'title') items = [ [ h['title'], gmDateTime.pydt_strftime(h['suppressed_when'], '%Y %b %d'), h['suppressed_by'], h['rationale'], gmTools.bool2subst(h['is_active'], gmTools.u_checkmark_thin, ''), h['source'][:30], gmTools.coalesce(h['url'], '')[:60], h['pk_hint'] ] for h in hints ] lctrl.set_string_items(items) lctrl.set_data(hints)
def refresh(lctrl): hints = gmAutoHints.get_dynamic_hints(order_by=u"is_active DESC, source, hint") items = [ [ gmTools.bool2subst(h["is_active"], gmTools.u_checkmark_thin, u""), h["title"], h["source"][:30], h["hint"][:60], gmTools.coalesce(h["url"], u"")[:60], h["lang"], h["pk_auto_hint"], ] for h in hints ] lctrl.set_string_items(items) lctrl.set_data(hints)