|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# |
|
3
|
|
|
# This file is part of SENAITE.HEALTH. |
|
4
|
|
|
# |
|
5
|
|
|
# SENAITE.HEALTH is free software: you can redistribute it and/or modify it |
|
6
|
|
|
# under the terms of the GNU General Public License as published by the Free |
|
7
|
|
|
# Software Foundation, version 2. |
|
8
|
|
|
# |
|
9
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT |
|
10
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
11
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
12
|
|
|
# details. |
|
13
|
|
|
# |
|
14
|
|
|
# You should have received a copy of the GNU General Public License along with |
|
15
|
|
|
# this program; if not, write to the Free Software Foundation, Inc., 51 |
|
16
|
|
|
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
17
|
|
|
# |
|
18
|
|
|
# Copyright 2018-2019 by it's authors. |
|
19
|
|
|
# Some rights reserved, see README and LICENSE. |
|
20
|
|
|
|
|
21
|
|
|
from AccessControl.SecurityInfo import ClassSecurityInfo |
|
22
|
|
|
from Products.ATContentTypes.content import schemata |
|
23
|
|
|
from Products.Archetypes import atapi |
|
24
|
|
|
from Products.Archetypes.ArchetypeTool import registerType |
|
25
|
|
|
from Products.CMFCore.utils import getToolByName |
|
26
|
|
|
from bika.lims.browser.bika_listing import BikaListingView |
|
27
|
|
|
from bika.health.config import PROJECTNAME, GENDERS_APPLY |
|
28
|
|
|
from bika.lims import bikaMessageFactory as _b |
|
29
|
|
|
from bika.health import bikaMessageFactory as _ |
|
30
|
|
|
from bika.lims.content.bikaschema import BikaFolderSchema |
|
31
|
|
|
from bika.health.interfaces import ISymptoms |
|
32
|
|
|
from plone.app.layout.globals.interfaces import IViewView |
|
33
|
|
|
from plone.app.content.browser.interfaces import IFolderContentsView |
|
34
|
|
|
from plone.app.folder.folder import ATFolder,ATFolderSchema |
|
35
|
|
|
from zope.interface.declarations import implements |
|
36
|
|
|
from operator import itemgetter |
|
37
|
|
|
|
|
38
|
|
|
class SymptomsView(BikaListingView): |
|
39
|
|
|
implements(IFolderContentsView,IViewView) |
|
40
|
|
|
|
|
41
|
|
|
def __init__(self,context,request): |
|
42
|
|
|
super(SymptomsView,self).__init__(context,request) |
|
43
|
|
|
self.catalog='bika_setup_catalog' |
|
44
|
|
|
self.contentFilter={'portal_type': 'Symptom', |
|
45
|
|
|
'sort_on': 'sortable_title'} |
|
46
|
|
|
self.context_actions={_('Add'): |
|
47
|
|
|
{'url': 'createObject?type_name=Symptom', |
|
48
|
|
|
'icon': '++resource++bika.lims.images/add.png'}} |
|
49
|
|
|
self.title=self.context.translate(_("Symptoms")) |
|
50
|
|
|
self.icon = self.portal_url + "/++resource++bika.health.images/symptom_big.png" |
|
51
|
|
|
self.description=_("Additional Symptoms not covered by ICD codes, can be entered here.") |
|
52
|
|
|
self.show_sort_column=False |
|
53
|
|
|
self.show_select_row=False |
|
54
|
|
|
self.show_select_column=True |
|
55
|
|
|
self.pagesize=25 |
|
56
|
|
|
|
|
57
|
|
|
self.columns={ |
|
58
|
|
|
'Title': {'title': _('Symptom'), |
|
59
|
|
|
'index':'sortable_title'}, |
|
60
|
|
|
'Description': {'title': _('Description'), |
|
61
|
|
|
'index': 'description', |
|
62
|
|
|
'toggle': True}, |
|
63
|
|
|
'Gender': {'title': _('Gender'), |
|
64
|
|
|
'index': 'getGender', |
|
65
|
|
|
'toggle': True}, |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
self.review_states=[ |
|
69
|
|
|
{'id':'default', |
|
70
|
|
|
'title': _('Active'), |
|
71
|
|
|
'contentFilter': {'is_active': True}, |
|
72
|
|
|
'transitions': [{'id':'deactivate'},], |
|
73
|
|
|
'columns': ['Title', |
|
74
|
|
|
'Description', |
|
75
|
|
|
'Gender']}, |
|
76
|
|
|
{'id':'inactive', |
|
77
|
|
|
'title': _('Dormant'), |
|
78
|
|
|
'contentFilter': {'is_active': False}, |
|
79
|
|
|
'transitions': [{'id':'activate'},], |
|
80
|
|
|
'columns': ['Title', |
|
81
|
|
|
'Description', |
|
82
|
|
|
'Gender']}, |
|
83
|
|
|
{'id':'all', |
|
84
|
|
|
'title': _('All'), |
|
85
|
|
|
'contentFilter':{}, |
|
86
|
|
|
'columns': ['Title', |
|
87
|
|
|
'Description', |
|
88
|
|
|
'Gender']}, |
|
89
|
|
|
] |
|
90
|
|
|
|
|
91
|
|
|
def before_render(self): |
|
92
|
|
|
"""Before template render hook |
|
93
|
|
|
""" |
|
94
|
|
|
super(SymptomsView, self).before_render() |
|
95
|
|
|
# Don't allow any context actions on Symptoms folder |
|
96
|
|
|
self.request.set("disable_border", 1) |
|
97
|
|
|
|
|
98
|
|
|
def folderitems(self): |
|
99
|
|
|
items=BikaListingView.folderitems(self) |
|
100
|
|
|
for x in range(len(items)): |
|
101
|
|
|
if not items[x].has_key('obj'): continue |
|
102
|
|
|
obj=items[x]['obj'] |
|
103
|
|
|
items[x]['Description']=obj.Description() |
|
104
|
|
|
items[x]['Gender']=GENDERS_APPLY.getValue(obj.getGender()) |
|
105
|
|
|
items[x]['replace']['Title']="<a href='%s'>%s</a>"%\ |
|
106
|
|
|
(items[x]['url'],items[x]['Title']) |
|
107
|
|
|
|
|
108
|
|
|
return items |
|
109
|
|
|
|
|
110
|
|
|
schema=ATFolderSchema.copy() |
|
111
|
|
|
class Symptoms(ATFolder): |
|
112
|
|
|
implements(ISymptoms) |
|
113
|
|
|
displayContentsTab=False |
|
114
|
|
|
schema=schema |
|
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
schemata.finalizeATCTSchema(schema,folderish=True,moveDiscussion=False) |
|
117
|
|
|
atapi.registerType(Symptoms,PROJECTNAME) |
|
118
|
|
|
|