Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from naralabs/bug/NMRL-182-sort-on-not-working
Browse files Browse the repository at this point in the history
NMRL-182 sort on not working
  • Loading branch information
xispa authored Mar 24, 2017
2 parents 310fcaa + 1964038 commit f1d2175
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 48 deletions.
30 changes: 17 additions & 13 deletions bika/health/browser/analysisrequests/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
53 changes: 30 additions & 23 deletions bika/health/browser/patients/folder_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},

}

Expand Down
20 changes: 16 additions & 4 deletions bika/health/browser/samples/folder_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 3 additions & 0 deletions bika/health/catalog/analysisrequest_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
'indexes': {
'getDoctorUID': 'FieldIndex',
'getPatientUID': 'FieldIndex',
# To sort columns
'getPatient': 'FieldIndex',
'getPatientID': 'FieldIndex',
},
'columns': [
'getDoctorUID',
Expand Down
2 changes: 1 addition & 1 deletion bika/health/catalog/patient_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
24 changes: 21 additions & 3 deletions bika/health/content/analysisrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,46 @@
# 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


@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


@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)
Expand Down
2 changes: 2 additions & 0 deletions bika/health/content/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<adapter factory=".analysisrequest.AnalysisRequestSchemaExtender" />
<adapter factory=".analysisrequest.AnalysisRequestSchemaModifier" />
<adapter factory=".analysisrequest.getPatientUID" name="getPatientUID" />
<adapter factory=".analysisrequest.getPatient" name="getPatient" />
<adapter factory=".analysisrequest.getPatientID" name="getPatientID" />

<adapter factory=".batch.BatchSchemaExtender" />
<adapter factory=".batch.BatchSchemaModifier" />
Expand Down
12 changes: 8 additions & 4 deletions bika/health/upgrade/to320.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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...')
Expand Down

0 comments on commit f1d2175

Please sign in to comment.