From c5abe3aaf5520edd68939c9add93989d3651112a Mon Sep 17 00:00:00 2001 From: Pau Soliva Date: Wed, 22 Mar 2017 17:20:41 +0100 Subject: [PATCH 1/4] patient column sorts reviewed --- bika/health/browser/patients/folder_view.py | 53 ++++++++++++--------- bika/health/catalog.py | 2 +- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/bika/health/browser/patients/folder_view.py b/bika/health/browser/patients/folder_view.py index 3c61991e..094dfa75 100644 --- a/bika/health/browser/patients/folder_view.py +++ b/bika/health/browser/patients/folder_view.py @@ -47,29 +47,36 @@ def __init__(self, context, request): self.columns = { - 'Title': {'title': _('Patient'), - 'index': 'sortable_title'}, - - 'getPatientID': {'title': _('Patient ID'), }, - - 'getClientPatientID': {'title': _('Client PID'), - 'sortable': False}, - - 'getGender': {'title': _('Gender'), - 'toggle': True, - 'sortable': False}, - - 'getAgeSplittedStr': {'title': _('Age'), - 'toggle': True, - 'sortable': False}, - - 'getBirthDate': {'title': _('BirthDate'), - 'toggle': True, - 'sortable': False}, - - 'getPrimaryReferrer': {'title': _('Primary Referrer'), - 'toggle': True, - 'sortable': False}, + 'Title': { + 'title': _('Patient'), + 'index': 'Title'}, + + 'getPatientID': { + 'title': _('Patient ID'), }, + + 'getClientPatientID': { + 'title': _('Client PID'), + 'sortable': False}, + + 'getGender': { + 'title': _('Gender'), + 'toggle': True, + 'sortable': False}, + + 'getAgeSplittedStr': { + 'title': _('Age'), + 'toggle': True, + 'sortable': False}, + + 'getBirthDate': { + 'title': _('BirthDate'), + 'toggle': True, + 'sortable': False}, + + 'getPrimaryReferrer': { + 'title': _('Primary Referrer'), + 'toggle': True, + 'sortable': False}, } diff --git a/bika/health/catalog.py b/bika/health/catalog.py index 6f27b9e0..721a3306 100644 --- a/bika/health/catalog.py +++ b/bika/health/catalog.py @@ -25,7 +25,7 @@ # Necessary to avoid reindexing whole catalog when we need to # reindex only one object. ExtendedPathIndex also could be used. 'path': 'PathIndex', - 'sortable_title': 'FieldIndex', + 'Title': 'FieldIndex', 'review_state': 'FieldIndex', 'inactive_state': 'FieldIndex', 'portal_type': 'FieldIndex', From 902f68fd74834a11632c8ea3438a694ae89ef9bc Mon Sep 17 00:00:00 2001 From: Pau Soliva Date: Wed, 22 Mar 2017 17:53:36 +0100 Subject: [PATCH 2/4] cleaning samples columns --- bika/health/browser/samples/folder_view.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bika/health/browser/samples/folder_view.py b/bika/health/browser/samples/folder_view.py index 5a2395dd..66a2546a 100644 --- a/bika/health/browser/samples/folder_view.py +++ b/bika/health/browser/samples/folder_view.py @@ -12,10 +12,22 @@ def __init__(self, context, request): super(SamplesView, self).__init__(context, request) # Add Patient fields - self.columns['getPatientID'] = {'title': _('Patient ID'), 'toggle': True} - self.columns['getClientPatientID'] = {'title': _("Client PID"), 'toggle': True} - self.columns['getPatient'] = {'title': _('Patient'), 'toggle': True} - self.columns['getDoctor'] = {'title': _('Doctor'), 'toggle': True} + self.columns['getPatientID'] = { + 'title': _('Patient ID'), + 'sortable': False, + 'toggle': True} + self.columns['getClientPatientID'] = { + 'title': _("Client PID"), + 'sortable': False, + 'toggle': True} + self.columns['getPatient'] = { + 'title': _('Patient'), + 'sortable': False, + 'toggle': True} + self.columns['getDoctor'] = { + 'title': _('Doctor'), + 'sortable': False, + 'toggle': True} for rs in self.review_states: i = rs['columns'].index('getSampleID') + 1 rs['columns'].insert(i, 'getClientPatientID') From cc26f0fb6f88130b34533af54e632286e2b0ffd4 Mon Sep 17 00:00:00 2001 From: Pau Soliva Date: Wed, 22 Mar 2017 18:42:25 +0100 Subject: [PATCH 3/4] patient column sorting in analysis request lists --- bika/health/browser/analysisrequests/view.py | 1 + .../health/catalog/analysisrequest_catalog.py | 2 ++ bika/health/content/analysisrequest.py | 24 ++++++++++++++++--- bika/health/content/configure.zcml | 2 ++ bika/health/upgrade/to320.py | 12 ++++++---- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/bika/health/browser/analysisrequests/view.py b/bika/health/browser/analysisrequests/view.py index 5faced62..16a01f7f 100644 --- a/bika/health/browser/analysisrequests/view.py +++ b/bika/health/browser/analysisrequests/view.py @@ -24,6 +24,7 @@ def folderitems(self, full_objects=False): 'toggle': True} self.columns['getClientPatientID'] = { 'title': _("Client PID"), + 'sortable': False, 'toggle': True} self.columns['getPatient'] = { 'title': _('Patient'), diff --git a/bika/health/catalog/analysisrequest_catalog.py b/bika/health/catalog/analysisrequest_catalog.py index 8f98be18..617ca94b 100644 --- a/bika/health/catalog/analysisrequest_catalog.py +++ b/bika/health/catalog/analysisrequest_catalog.py @@ -12,6 +12,8 @@ 'indexes': { 'getDoctorUID': 'FieldIndex', 'getPatientUID': 'FieldIndex', + # To sort columns + 'getPatient': 'FieldIndex', }, 'columns': [ 'getDoctorUID', diff --git a/bika/health/content/analysisrequest.py b/bika/health/content/analysisrequest.py index 4a0a1730..835d83b3 100644 --- a/bika/health/content/analysisrequest.py +++ b/bika/health/content/analysisrequest.py @@ -26,7 +26,7 @@ # TODO-catalog: delete this index @indexer(IAnalysisRequest, IBikaCatalog) def getPatientUID(instance): - field = instance.Schema().get('Patient', '') + field = instance.getField('Patient', '') item = field.get(instance) if field else None value = item and item.UID() or '' return value @@ -34,7 +34,7 @@ def getPatientUID(instance): @indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing) def getPatientUID(instance): - field = instance.Schema().get('Patient', '') + field = instance.getField('Patient', '') item = field.get(instance) if field else None value = item and item.UID() or '' return value @@ -42,12 +42,30 @@ def getPatientUID(instance): @indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing) def getDoctorUID(instance): - field = instance.Schema().get('Doctor', '') + field = instance.getField('Doctor', '') item = field.get(instance) if field else None value = item and item.UID() or '' return value +# We use this index to sort columns and filter lists +@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing) +def getPatient(instance): + field = instance.getField('Patient', '') + item = field.get(instance) if field else None + value = item and item.Title() or '' + return value + + +# We use this index to sort columns and filter lists +@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing) +def getPatientID(instance): + field = instance.getField('Patient', '') + item = field.get(instance) if field else None + value = item and item.getId() or '' + return value + + class AnalysisRequestSchemaExtender(object): adapts(IAnalysisRequest) implements(IOrderableSchemaExtender) diff --git a/bika/health/content/configure.zcml b/bika/health/content/configure.zcml index 6e326769..f8a447db 100644 --- a/bika/health/content/configure.zcml +++ b/bika/health/content/configure.zcml @@ -12,6 +12,8 @@ + + diff --git a/bika/health/upgrade/to320.py b/bika/health/upgrade/to320.py index db88b14d..ee1a8ea8 100644 --- a/bika/health/upgrade/to320.py +++ b/bika/health/upgrade/to320.py @@ -9,7 +9,10 @@ from bika.health import logger from Products.CMFCore import permissions from bika.lims.catalog import setup_catalogs -from bika.health.catalog import getCatalogDefinitions +from bika.lims.catalog\ + import getCatalogDefinitions as getCatalogDefinitionsLIMS +from bika.health.catalog\ + import getCatalogDefinitions as getCatalogDefinitionsHealth from bika.health.catalog import getCatalogExtensions @@ -43,11 +46,12 @@ def upgrade(tool): """ # wf = getToolByName(portal, 'portal_workflow') # wf.updateRoleMappings() - + catalog_definitions_lims_health = getCatalogDefinitionsLIMS() + catalog_definitions_lims_health.update(getCatalogDefinitionsHealth()) # Updating health catalogs if there is any change in them setup_catalogs( - portal, getCatalogDefinitions(), - catalog_extensions=getCatalogExtensions()) + portal, catalog_definitions_lims_health, + catalogs_extension=getCatalogExtensions()) # TODO: Deleting bika_patient_catalog # if 'bika_patient_catalog' in portal.keys(): # logger.info('Deletting catalog bika_patient_catalog...') From 1964038865f793e416d0e3b90a556c546acfac66 Mon Sep 17 00:00:00 2001 From: Pau Soliva Date: Thu, 23 Mar 2017 16:24:57 +0100 Subject: [PATCH 4/4] patient and patient id shown in lists --- bika/health/browser/analysisrequests/view.py | 31 ++++++++++--------- .../health/catalog/analysisrequest_catalog.py | 1 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bika/health/browser/analysisrequests/view.py b/bika/health/browser/analysisrequests/view.py index 16a01f7f..c6241583 100644 --- a/bika/health/browser/analysisrequests/view.py +++ b/bika/health/browser/analysisrequests/view.py @@ -9,26 +9,29 @@ def __init__(self, context, request): super(AnalysisRequestsView, self).__init__(context, request) self.patient_catalog = None self.columns['BatchID']['title'] = _('Case ID') + # Add Client Patient fields + self.columns['getPatientID'] = { + 'title': _('Patient ID'), } + self.columns['getClientPatientID'] = { + 'title': _("Client PID"), + 'sortable': False, } + self.columns['getPatient'] = { + 'title': _('Patient'), } def folderitems(self, full_objects=False): pm = getToolByName(self.context, "portal_membership") member = pm.getAuthenticatedMember() # We will use this list for each element roles = member.getRoles() - if 'Manager' in roles \ - or 'LabManager' in roles \ - or 'LabClerk' in roles: - # Add Client Patient fields - self.columns['getPatientID'] = { - 'title': _('Patient ID'), - 'toggle': True} - self.columns['getClientPatientID'] = { - 'title': _("Client PID"), - 'sortable': False, - 'toggle': True} - self.columns['getPatient'] = { - 'title': _('Patient'), - 'toggle': True} + # delete roles user doesn't have permissions + if 'Manager' not in roles \ + and 'LabManager' not in roles \ + and 'LabClerk' not in roles: + del self.columns['getPatientID'] + del self.columns['getClientPatientID'] + del self.columns['getPatient'] + # Otherwise show the columns in the list + else: for rs in self.review_states: i = rs['columns'].index('BatchID') + 1 rs['columns'].insert(i, 'getClientPatientID') diff --git a/bika/health/catalog/analysisrequest_catalog.py b/bika/health/catalog/analysisrequest_catalog.py index 617ca94b..bd6e6691 100644 --- a/bika/health/catalog/analysisrequest_catalog.py +++ b/bika/health/catalog/analysisrequest_catalog.py @@ -14,6 +14,7 @@ 'getPatientUID': 'FieldIndex', # To sort columns 'getPatient': 'FieldIndex', + 'getPatientID': 'FieldIndex', }, 'columns': [ 'getDoctorUID',