diff --git a/bika/health/browser/analysisrequests/view.py b/bika/health/browser/analysisrequests/view.py
index 5faced62..c6241583 100644
--- a/bika/health/browser/analysisrequests/view.py
+++ b/bika/health/browser/analysisrequests/view.py
@@ -9,25 +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"),
- '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/browser/patients/folder_view.py b/bika/health/browser/patients/folder_view.py
index 775611f0..2e32a9bc 100644
--- a/bika/health/browser/patients/folder_view.py
+++ b/bika/health/browser/patients/folder_view.py
@@ -48,29 +48,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/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')
diff --git a/bika/health/catalog/analysisrequest_catalog.py b/bika/health/catalog/analysisrequest_catalog.py
index 8f98be18..bd6e6691 100644
--- a/bika/health/catalog/analysisrequest_catalog.py
+++ b/bika/health/catalog/analysisrequest_catalog.py
@@ -12,6 +12,9 @@
'indexes': {
'getDoctorUID': 'FieldIndex',
'getPatientUID': 'FieldIndex',
+ # To sort columns
+ 'getPatient': 'FieldIndex',
+ 'getPatientID': 'FieldIndex',
},
'columns': [
'getDoctorUID',
diff --git a/bika/health/catalog/patient_catalog.py b/bika/health/catalog/patient_catalog.py
index 87c986f5..ae6dd018 100644
--- a/bika/health/catalog/patient_catalog.py
+++ b/bika/health/catalog/patient_catalog.py
@@ -33,7 +33,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',
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...')