def _on_encounter_start_lost_focus(self): start = self._PRW_encounter_start.GetData() if start is None: return start = start.get_pydt() end = self._PRW_encounter_end.GetData() if end is None: fts = gmDateTime.cFuzzyTimestamp(timestamp=start, accuracy=gmDateTime.acc_minutes) self._PRW_encounter_end.SetText(fts.format_accurately(), data=fts) return end = end.get_pydt() if start > end: end = end.replace(year=start.year, month=start.month, day=start.day) fts = gmDateTime.cFuzzyTimestamp(timestamp=end, accuracy=gmDateTime.acc_minutes) self._PRW_encounter_end.SetText(fts.format_accurately(), data=fts) return emr = self.__pat.emr if start != emr.active_encounter['started']: end = end.replace(year=start.year, month=start.month, day=start.day) fts = gmDateTime.cFuzzyTimestamp(timestamp=end, accuracy=gmDateTime.acc_minutes) self._PRW_encounter_end.SetText(fts.format_accurately(), data=fts) return return
def SetData(self, data=None): if data is None: gmPhraseWheel.cPhraseWheel.SetText(self, u'', None) else: if isinstance(data, pyDT.datetime): data = gmDateTime.cFuzzyTimestamp(timestamp=data) gmPhraseWheel.cPhraseWheel.SetText(self, value = data.format_accurately(accuracy = self.display_accuracy), data = data)
def SetData(self, data=None): if data is None: gmPhraseWheel.cPhraseWheel.SetText(self, '', None) else: if isinstance(data, pyDT.datetime): data = gmDateTime.cFuzzyTimestamp(timestamp=data) gmPhraseWheel.cPhraseWheel.SetText(self, value = data.format_accurately(accuracy = self.display_accuracy), data = data)
def SetText(self, value=u'', data=None, suppress_smarts=False): if data is not None: if isinstance(data, pyDT.datetime): data = gmDateTime.cFuzzyTimestamp(timestamp=data) if value.strip() == u'': value = data.format_accurately(accuracy = self.display_accuracy) gmPhraseWheel.cPhraseWheel.SetText(self, value = value, data = data, suppress_smarts = suppress_smarts)
def SetText(self, value='', data=None, suppress_smarts=False): if data is not None: if isinstance(data, pyDT.datetime): data = gmDateTime.cFuzzyTimestamp(timestamp = data) if value.strip() == '': value = data.format_accurately(accuracy = self.display_accuracy) super().SetText(value = value, data = data, suppress_smarts = suppress_smarts)
def refresh(self, allergy=None): if allergy is not None: self.__allergy = allergy if self.__allergy is None: ts = gmDateTime.cFuzzyTimestamp(timestamp=pyDT.datetime.now( tz=gmDateTime.gmCurrentLocalTimezone), accuracy=gmDateTime.acc_days) self._DPRW_date_noted.SetData(data=ts) self._PRW_trigger.SetText() self._TCTRL_product_name.SetValue('') self._TCTRL_generic.SetValue('') self._ChBOX_generic_specific.SetValue(0) self._TCTRL_atc_classes.SetValue('') self._PRW_reaction.SetText() self._RBTN_type_allergy.SetValue(1) self._RBTN_type_sensitivity.SetValue(0) self._ChBOX_definite.SetValue(1) return True if not isinstance(self.__allergy, gmAllergy.cAllergy): raise ValueError( '[%s].refresh(): expected gmAllergy.cAllergy instance, got [%s] instead' % (self.__class__.__name__, self.__allergy)) ts = gmDateTime.cFuzzyTimestamp(timestamp=self.__allergy['date'], accuracy=gmDateTime.acc_days) self._DPRW_date_noted.SetData(data=ts) self._PRW_trigger.SetText(value=self.__allergy['allergene']) self._TCTRL_product_name.SetValue(self.__allergy['substance']) self._TCTRL_generic.SetValue( gmTools.coalesce(self.__allergy['generics'], '')) self._ChBOX_generic_specific.SetValue( self.__allergy['generic_specific']) self._TCTRL_atc_classes.SetValue( gmTools.coalesce(self.__allergy['atc_code'], '')) self._PRW_reaction.SetText( value=gmTools.coalesce(self.__allergy['reaction'], '')) if self.__allergy['type'] == 'allergy': self._RBTN_type_allergy.SetValue(1) else: self._RBTN_type_sensitivity.SetValue(1) self._ChBOX_definite.SetValue(self.__allergy['definite'])
def _on_encounter_start_lost_focus(self): start = self._PRW_encounter_start.GetData() if start is None: return start = start.get_pydt() end = self._PRW_encounter_end.GetData() if end is None: fts = gmDateTime.cFuzzyTimestamp ( timestamp = start, accuracy = gmDateTime.acc_minutes ) self._PRW_encounter_end.SetText(fts.format_accurately(), data = fts) return end = end.get_pydt() if start > end: end = end.replace ( year = start.year, month = start.month, day = start.day ) fts = gmDateTime.cFuzzyTimestamp ( timestamp = end, accuracy = gmDateTime.acc_minutes ) self._PRW_encounter_end.SetText(fts.format_accurately(), data = fts) return emr = self.__pat.get_emr() if start != emr.active_encounter['started']: end = end.replace ( year = start.year, month = start.month, day = start.day ) fts = gmDateTime.cFuzzyTimestamp ( timestamp = end, accuracy = gmDateTime.acc_minutes ) self._PRW_encounter_end.SetText(fts.format_accurately(), data = fts) return return
def refresh(self, allergy=None): if allergy is not None: self.__allergy = allergy if self.__allergy is None: ts = gmDateTime.cFuzzyTimestamp ( timestamp = pyDT.datetime.now(tz=gmDateTime.gmCurrentLocalTimezone), accuracy = gmDateTime.acc_days ) self._DPRW_date_noted.SetData(data = ts) self._PRW_trigger.SetText() self._TCTRL_product_name.SetValue('') self._TCTRL_generic.SetValue('') self._ChBOX_generic_specific.SetValue(0) self._TCTRL_atc_classes.SetValue('') self._PRW_reaction.SetText() self._RBTN_type_allergy.SetValue(1) self._RBTN_type_sensitivity.SetValue(0) self._ChBOX_definite.SetValue(1) return True if not isinstance(self.__allergy, gmAllergy.cAllergy): raise ValueError('[%s].refresh(): expected gmAllergy.cAllergy instance, got [%s] instead' % (self.__class__.__name__, self.__allergy)) ts = gmDateTime.cFuzzyTimestamp ( timestamp = self.__allergy['date'], accuracy = gmDateTime.acc_days ) self._DPRW_date_noted.SetData(data=ts) self._PRW_trigger.SetText(value = self.__allergy['allergene']) self._TCTRL_product_name.SetValue(self.__allergy['substance']) self._TCTRL_generic.SetValue(gmTools.coalesce(self.__allergy['generics'], '')) self._ChBOX_generic_specific.SetValue(self.__allergy['generic_specific']) self._TCTRL_atc_classes.SetValue(gmTools.coalesce(self.__allergy['atc_code'], '')) self._PRW_reaction.SetText(value = gmTools.coalesce(self.__allergy['reaction'], '')) if self.__allergy['type'] == 'allergy': self._RBTN_type_allergy.SetValue(1) else: self._RBTN_type_sensitivity.SetValue(1) self._ChBOX_definite.SetValue(self.__allergy['definite'])
def _on_leave_age_noted(self, *args, **kwargs): if not self._PRW_age_noted.IsModified(): return True age_str = self._PRW_age_noted.GetValue().strip() if age_str == '': return True issue_age = gmDateTime.str2interval(str_interval = age_str) if issue_age is None: self.StatusText = _('Cannot parse [%s] into valid interval.') % age_str self._PRW_age_noted.display_as_valid(False) return True pat = gmPerson.gmCurrentPatient() if pat['dob'] is not None: max_issue_age = pydt.datetime.now(tz=pat['dob'].tzinfo) - pat['dob'] if issue_age >= max_issue_age: self.StatusText = _('Health issue cannot have been noted at age %s. Patient is only %s old.') % (issue_age, pat.get_medical_age()) self._PRW_age_noted.display_as_valid(False) return True self._PRW_age_noted.display_as_valid(True) self._PRW_age_noted.SetText(value = age_str, data = issue_age) if pat['dob'] is not None: fts = gmDateTime.cFuzzyTimestamp ( timestamp = pat['dob'] + issue_age, accuracy = gmDateTime.acc_months ) self._PRW_year_noted.SetText(value = str(fts), data = fts) return True
def _on_leave_age_noted(self, *args, **kwargs): if not self._PRW_age_noted.IsModified(): return True age_str = self._PRW_age_noted.GetValue().strip() if age_str == '': return True issue_age = gmDateTime.str2interval(str_interval = age_str) if issue_age is None: self.status_message = _('Cannot parse [%s] into valid interval.') % age_str self._PRW_age_noted.display_as_valid(False) return True pat = gmPerson.gmCurrentPatient() if pat['dob'] is not None: max_issue_age = pydt.datetime.now(tz=pat['dob'].tzinfo) - pat['dob'] if issue_age >= max_issue_age: self.status_message = _('Health issue cannot have been noted at age %s. Patient is only %s old.') % (issue_age, pat.get_medical_age()) self._PRW_age_noted.display_as_valid(False) return True self._PRW_age_noted.display_as_valid(True) self._PRW_age_noted.SetText(value = age_str, data = issue_age) if pat['dob'] is not None: fts = gmDateTime.cFuzzyTimestamp ( timestamp = pat['dob'] + issue_age, accuracy = gmDateTime.acc_months ) self._PRW_year_noted.SetText(value = str(fts), data = fts) return True
def refresh(self, encounter=None, msg=None): if msg is not None: self._LBL_instructions.SetLabel(msg) if encounter is not None: self.__encounter = encounter if self.__encounter is None: return True # getting the patient via the encounter allows us to act # on any encounter regardless of the currently active patient pat = gmPerson.cPatient(aPK_obj=self.__encounter['pk_patient']) self._LBL_patient.SetLabel(pat.get_description_gender().strip()) curr_pat = gmPerson.gmCurrentPatient() if curr_pat.connected: if curr_pat.ID == self.__encounter['pk_patient']: self._LBL_patient.SetForegroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)) else: self._LBL_patient.SetForegroundColour('red') self._PRW_encounter_type.SetText(self.__encounter['l10n_type'], data=self.__encounter['pk_type']) self._PRW_location.Enable(True) branch = self.__encounter.praxis_branch if branch is None: # None or old entry because praxis has been re-configured unit = self.__encounter.org_unit if unit is None: # None self._PRW_location.SetText('', data=None) else: # old entry self._PRW_location.Enable(False) self._PRW_location.SetText( _('old praxis branch: %s (%s)') % (unit['unit'], unit['organization']), data=None) else: self._PRW_location.SetText(self.__encounter['praxis_branch'], data=branch['pk_praxis_branch']) fts = gmDateTime.cFuzzyTimestamp(timestamp=self.__encounter['started'], accuracy=gmDateTime.acc_minutes) self._PRW_start.SetText(fts.format_accurately(), data=fts) fts = gmDateTime.cFuzzyTimestamp( timestamp=self.__encounter['last_affirmed'], accuracy=gmDateTime.acc_minutes) self._PRW_end.SetText(fts.format_accurately(), data=fts) # RFE self._TCTRL_rfe.SetValue( gmTools.coalesce(self.__encounter['reason_for_encounter'], '')) val, data = self._PRW_rfe_codes.generic_linked_codes2item_dict( self.__encounter.generic_codes_rfe) self._PRW_rfe_codes.SetText(val, data) # AOE self._TCTRL_aoe.SetValue( gmTools.coalesce(self.__encounter['assessment_of_encounter'], '')) val, data = self._PRW_aoe_codes.generic_linked_codes2item_dict( self.__encounter.generic_codes_aoe) self._PRW_aoe_codes.SetText(val, data) # last affirmed if self.__encounter['last_affirmed'] == self.__encounter['started']: self._PRW_end.SetFocus() else: self._TCTRL_aoe.SetFocus() return True
def refresh(self, encounter=None, msg=None): if msg is not None: self._LBL_instructions.SetLabel(msg) if encounter is not None: self.__encounter = encounter if self.__encounter is None: return True # getting the patient via the encounter allows us to act # on any encounter regardless of the currently active patient pat = gmPerson.cPatient(aPK_obj = self.__encounter['pk_patient']) self._LBL_patient.SetLabel(pat.get_description_gender().strip()) curr_pat = gmPerson.gmCurrentPatient() if curr_pat.connected: if curr_pat.ID == self.__encounter['pk_patient']: self._LBL_patient.SetForegroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)) else: self._LBL_patient.SetForegroundColour('red') self._PRW_encounter_type.SetText(self.__encounter['l10n_type'], data = self.__encounter['pk_type']) self._PRW_location.Enable(True) self._PRW_location.display_as_disabled(False) branch = self.__encounter.praxis_branch if branch is None: # None or old entry because praxis has been re-configured unit = self.__encounter.org_unit if unit is None: # None self._PRW_location.SetText(u'', data = None) else: # old entry self._PRW_location.Enable(False) self._PRW_location.display_as_disabled(True) self._PRW_location.SetText(_('old praxis branch: %s (%s)') % (unit['unit'], unit['organization']), data = None) else: self._PRW_location.SetText(self.__encounter['praxis_branch'], data = branch['pk_praxis_branch']) fts = gmDateTime.cFuzzyTimestamp ( timestamp = self.__encounter['started'], accuracy = gmDateTime.acc_minutes ) self._PRW_start.SetText(fts.format_accurately(), data=fts) fts = gmDateTime.cFuzzyTimestamp ( timestamp = self.__encounter['last_affirmed'], accuracy = gmDateTime.acc_minutes ) self._PRW_end.SetText(fts.format_accurately(), data=fts) # RFE self._TCTRL_rfe.SetValue(gmTools.coalesce(self.__encounter['reason_for_encounter'], '')) val, data = self._PRW_rfe_codes.generic_linked_codes2item_dict(self.__encounter.generic_codes_rfe) self._PRW_rfe_codes.SetText(val, data) # AOE self._TCTRL_aoe.SetValue(gmTools.coalesce(self.__encounter['assessment_of_encounter'], '')) val, data = self._PRW_aoe_codes.generic_linked_codes2item_dict(self.__encounter.generic_codes_aoe) self._PRW_aoe_codes.SetText(val, data) # last affirmed if self.__encounter['last_affirmed'] == self.__encounter['started']: self._PRW_end.SetFocus() else: self._TCTRL_aoe.SetFocus() return True