def __populate_candidates_list(self): list_items = [[_('Patient'), self.__patient.description_gender.strip()]] list_data = [(self.__patient.description.strip(), self.__patient.get_addresses(), '', None)] candidate_type = _('Emergency contact') if self.__patient['emergency_contact'] is not None: name = self.__patient['emergency_contact'].strip() list_items.append([candidate_type, name]) list_data.append((name, [], '', None)) contact = self.__patient.emergency_contact_in_database if contact is not None: list_items.append([candidate_type, contact.description_gender]) list_data.append((contact.description.strip(), contact.get_addresses(), '', None)) candidate_type = _('Primary doctor') prov = self.__patient.primary_provider if prov is not None: ident = prov.identity list_items.append([candidate_type, '%s: %s' % (prov['short_alias'], ident.description_gender)]) list_data.append((ident.description.strip(), ident.get_addresses(), _('in-praxis primary provider'), None)) candidate_type = _('This praxis') branches = gmPraxis.get_praxis_branches(order_by = 'branch') for branch in branches: adr = branch.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (branch['branch'], branch['praxis'])]) list_data.append(('%s @ %s' % (branch['branch'], branch['praxis']), [adr], branch.format(), None)) del branches candidate_type = _('External care') cares = gmExternalCare.get_external_care_items(pk_identity = self.__patient.ID) for care in cares: details = '%s%s@%s (%s)' % ( gmTools.coalesce(care['provider'], '', '%s: '), care['unit'], care['organization'], care['issue'] ) name = ('%s%s' % ( gmTools.coalesce(care['provider'], '', '%s, '), '%s @ %s' % (care['unit'], care['organization']) )).strip() org_unit = care.org_unit adr = org_unit.address if adr is None: addresses = [] else: addresses = [adr] list_items.append([candidate_type, details]) tt = '\n'.join(care.format(with_health_issue = True, with_address = True, with_comms = True)) list_data.append((name, addresses, tt, org_unit)) del cares emr = self.__patient.emr candidate_type = _('Hospital stay') depts = emr.get_attended_hospitals_as_org_units() for dept in depts: adr = dept.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (dept['unit'], dept['organization'])]) list_data.append(('%s @ %s' % (dept['unit'], dept['organization']), [adr], '\n'.join(dept.format(with_comms = True)), dept)) del depts candidate_type = _('Procedure') proc_locs = emr.get_procedure_locations_as_org_units() for proc_loc in proc_locs: adr = proc_loc.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (proc_loc['unit'], proc_loc['organization'])]) list_data.append(('%s @ %s' % (proc_loc['unit'], proc_loc['organization']), [adr], '\n'.join(proc_loc.format(with_comms = True)), proc_loc)) del proc_locs candidate_type = _('Lab') labs = emr.get_labs_as_org_units() for lab in labs: adr = lab.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (lab['unit'], lab['organization'])]) list_data.append(('%s @ %s' % (lab['unit'], lab['organization']), [adr], '\n'.join(lab.format(with_comms = True)), lab)) del labs candidate_type = _('Bill receiver') bills = self.__patient.bills adrs_seen = [] for bill in bills: if bill['pk_receiver_address'] in adrs_seen: continue adr = bill.address if adr is None: continue adrs_seen.append(bill['pk_receiver_address']) details = '%s%s' % (bill['invoice_id'], gmDateTime.pydt_strftime(dt = bill['close_date'], format = ' (%Y %b %d)', none_str = '')) list_items.append([candidate_type, details]) list_data.append(('', [adr], '\n'.join(adr.format()), None)) candidate_type = _('Document') doc_folder = self.__patient.document_folder doc_units = doc_folder.all_document_org_units for doc_unit in doc_units: adr = doc_unit.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (doc_unit['unit'], doc_unit['organization'])]) list_data.append(('%s @ %s' % (doc_unit['unit'], doc_unit['organization']), [adr], '\n'.join(doc_unit.format(with_comms = True)), doc_unit)) del doc_units self._LCTRL_candidates.set_string_items(list_items) self._LCTRL_candidates.set_column_widths() self._LCTRL_candidates.set_data(list_data)
def __populate_candidates_list(self): list_items = [[_('Patient'), self.__patient['description_gender'].strip()]] list_data = [(self.__patient['description'].strip(), self.__patient.get_addresses(), '', None)] candidate_type = _('Emergency contact') if self.__patient['emergency_contact'] is not None: name = self.__patient['emergency_contact'].strip() list_items.append([candidate_type, name]) list_data.append((name, [], '', None)) contact = self.__patient.emergency_contact_in_database if contact is not None: list_items.append([candidate_type, contact['description_gender']]) list_data.append((contact['description'].strip(), contact.get_addresses(), '', None)) candidate_type = _('Primary doctor') prov = self.__patient.primary_provider if prov is not None: ident = prov.identity list_items.append([candidate_type, '%s: %s' % (prov['short_alias'], ident['description_gender'])]) list_data.append((ident['description'].strip(), ident.get_addresses(), _('in-praxis primary provider'), None)) candidate_type = _('This praxis') branches = gmPraxis.get_praxis_branches(order_by = 'branch') for branch in branches: adr = branch.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (branch['branch'], branch['praxis'])]) list_data.append(('%s @ %s' % (branch['branch'], branch['praxis']), [adr], branch.format(), None)) del branches candidate_type = _('External care') cares = gmExternalCare.get_external_care_items(pk_identity = self.__patient.ID) for care in cares: details = '%s%s@%s (%s)' % ( gmTools.coalesce(care['provider'], '', '%s: '), care['unit'], care['organization'], care['issue'] ) name = ('%s%s' % ( gmTools.coalesce(care['provider'], '', '%s, '), '%s @ %s' % (care['unit'], care['organization']) )).strip() org_unit = care.org_unit adr = org_unit.address if adr is None: addresses = [] else: addresses = [adr] list_items.append([candidate_type, details]) tt = '\n'.join(care.format(with_health_issue = True, with_address = True, with_comms = True)) list_data.append((name, addresses, tt, org_unit)) del cares emr = self.__patient.emr candidate_type = _('Hospital stay') depts = emr.get_attended_hospitals_as_org_units() for dept in depts: adr = dept.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (dept['unit'], dept['organization'])]) list_data.append(('%s @ %s' % (dept['unit'], dept['organization']), [adr], '\n'.join(dept.format(with_comms = True)), dept)) del depts candidate_type = _('Procedure') proc_locs = emr.get_procedure_locations_as_org_units() for proc_loc in proc_locs: adr = proc_loc.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (proc_loc['unit'], proc_loc['organization'])]) list_data.append(('%s @ %s' % (proc_loc['unit'], proc_loc['organization']), [adr], '\n'.join(proc_loc.format(with_comms = True)), proc_loc)) del proc_locs candidate_type = _('Lab') labs = emr.get_labs_as_org_units() for lab in labs: adr = lab.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (lab['unit'], lab['organization'])]) list_data.append(('%s @ %s' % (lab['unit'], lab['organization']), [adr], '\n'.join(lab.format(with_comms = True)), lab)) del labs candidate_type = _('Bill receiver') bills = self.__patient.bills adrs_seen = [] for bill in bills: if bill['pk_receiver_address'] in adrs_seen: continue adr = bill.address if adr is None: continue adrs_seen.append(bill['pk_receiver_address']) details = '%s%s' % (bill['invoice_id'], gmDateTime.pydt_strftime(dt = bill['close_date'], format = ' (%Y %b %d)', none_str = '')) list_items.append([candidate_type, details]) list_data.append(('', [adr], '\n'.join(adr.format()), None)) candidate_type = _('Document') doc_folder = self.__patient.document_folder doc_units = doc_folder.all_document_org_units for doc_unit in doc_units: adr = doc_unit.address if adr is None: continue list_items.append([candidate_type, '%s @ %s' % (doc_unit['unit'], doc_unit['organization'])]) list_data.append(('%s @ %s' % (doc_unit['unit'], doc_unit['organization']), [adr], '\n'.join(doc_unit.format(with_comms = True)), doc_unit)) del doc_units self._LCTRL_candidates.set_string_items(list_items) self._LCTRL_candidates.set_column_widths() self._LCTRL_candidates.set_data(list_data)