|
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
|
|
|
""" http://pypi.python.org/pypi/archetypes.schemaextender |
|
22
|
|
|
""" |
|
23
|
|
|
from Products.Archetypes.references import HoldingReference |
|
24
|
|
|
from Products.CMFCore import permissions |
|
25
|
|
|
from archetypes.schemaextender.interfaces import IOrderableSchemaExtender |
|
26
|
|
|
from archetypes.schemaextender.interfaces import ISchemaModifier |
|
27
|
|
|
from zope.component import adapts |
|
28
|
|
|
from zope.interface import implements |
|
29
|
|
|
|
|
30
|
|
|
from bika.health import bikaMessageFactory as _ |
|
31
|
|
|
from bika.health.permissions import ViewPatients |
|
32
|
|
|
from bika.lims.browser.widgets import ReferenceWidget |
|
33
|
|
|
from bika.lims.fields import ExtBooleanField |
|
34
|
|
|
from bika.lims.fields import BooleanWidget |
|
35
|
|
|
from bika.lims.fields import ExtReferenceField |
|
36
|
|
|
from bika.lims.fields import ExtStringField |
|
37
|
|
|
from bika.lims.interfaces import IAnalysisRequest |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
class AnalysisRequestSchemaExtender(object): |
|
41
|
|
|
adapts(IAnalysisRequest) |
|
42
|
|
|
implements(IOrderableSchemaExtender) |
|
43
|
|
|
|
|
44
|
|
|
def __init__(self, context): |
|
45
|
|
|
self.context = context |
|
46
|
|
|
|
|
47
|
|
|
fields = [ |
|
48
|
|
|
ExtReferenceField( |
|
49
|
|
|
'Doctor', |
|
50
|
|
|
allowed_types=('Doctor',), |
|
51
|
|
|
referenceClass = HoldingReference, |
|
52
|
|
|
relationship = 'AnalysisRequestDoctor', |
|
53
|
|
|
widget=ReferenceWidget( |
|
54
|
|
|
label=_('Doctor'), |
|
55
|
|
|
size=20, |
|
56
|
|
|
render_own_label=True, |
|
57
|
|
|
visible={'add': 'edit', |
|
58
|
|
|
'secondary': 'disabled'}, |
|
59
|
|
|
catalog_name='portal_catalog', |
|
60
|
|
|
base_query={'is_active': True,}, |
|
61
|
|
|
minLength=3, |
|
62
|
|
|
showOn=True, |
|
63
|
|
|
), |
|
64
|
|
|
), |
|
65
|
|
|
|
|
66
|
|
|
ExtReferenceField( |
|
67
|
|
|
'Patient', |
|
68
|
|
|
required=1, |
|
69
|
|
|
allowed_types = ('Patient',), |
|
70
|
|
|
referenceClass = HoldingReference, |
|
71
|
|
|
relationship = 'AnalysisRequestPatient', |
|
72
|
|
|
read_permission=ViewPatients, |
|
73
|
|
|
write_permission=permissions.ModifyPortalContent, |
|
74
|
|
|
widget=ReferenceWidget( |
|
75
|
|
|
label=_('Patient'), |
|
76
|
|
|
size=20, |
|
77
|
|
|
render_own_label=True, |
|
78
|
|
|
visible={'add': 'edit', |
|
79
|
|
|
'secondary': 'disabled'}, |
|
80
|
|
|
catalog_name='bikahealth_catalog_patient_listing', |
|
81
|
|
|
search_fields=('listing_searchable_text',), |
|
82
|
|
|
base_query={'is_active': True, |
|
83
|
|
|
'sort_limit': 50, |
|
84
|
|
|
'sort_on': 'getPatientID', |
|
85
|
|
|
'sort_order': 'ascending'}, |
|
86
|
|
|
colModel = [ |
|
87
|
|
|
{'columnName': "getPatientID", |
|
88
|
|
|
'width': '30', |
|
89
|
|
|
'label': _('PID'), |
|
90
|
|
|
'align': 'left'}, |
|
91
|
|
|
{'columnName': "getClientPatientID", |
|
92
|
|
|
'width': '30', |
|
93
|
|
|
'label': _('CPID'), |
|
94
|
|
|
'align': 'left'}, |
|
95
|
|
|
{'columnName': 'Title', |
|
96
|
|
|
'width': '30', |
|
97
|
|
|
'label': _('Fullname'), |
|
98
|
|
|
'align': 'left'}, |
|
99
|
|
|
], |
|
100
|
|
|
minLength=3, |
|
101
|
|
|
showOn=True, |
|
102
|
|
|
), |
|
103
|
|
|
), |
|
104
|
|
|
|
|
105
|
|
|
ExtStringField( |
|
106
|
|
|
'ClientPatientID', |
|
107
|
|
|
searchable=True, |
|
108
|
|
|
required=0, |
|
109
|
|
|
read_permission=ViewPatients, |
|
110
|
|
|
write_permission=permissions.ModifyPortalContent, |
|
111
|
|
|
widget=ReferenceWidget( |
|
112
|
|
|
label=_("Client Patient ID"), |
|
113
|
|
|
size=20, |
|
114
|
|
|
render_own_label=True, |
|
115
|
|
|
visible={'add': 'edit', |
|
116
|
|
|
'secondary': 'disabled'}, |
|
117
|
|
|
catalog_name='bikahealth_catalog_patient_listing', |
|
118
|
|
|
portal_types=('Patient',), |
|
119
|
|
|
search_fields=('getClientPatientID',), |
|
120
|
|
|
base_query={'is_active': True, |
|
121
|
|
|
'sort_limit': 50, |
|
122
|
|
|
'sort_on': 'getClientPatientID', |
|
123
|
|
|
'sort_order': 'ascending'}, |
|
124
|
|
|
colModel = [ |
|
125
|
|
|
{'columnName': "getPatientID", |
|
126
|
|
|
'width': '30', |
|
127
|
|
|
'label': _('PID'), |
|
128
|
|
|
'align': 'left'}, |
|
129
|
|
|
{'columnName': "getClientPatientID", |
|
130
|
|
|
'width': '30', |
|
131
|
|
|
'label': _('CPID'), |
|
132
|
|
|
'align': 'left'}, |
|
133
|
|
|
{'columnName': 'Title', |
|
134
|
|
|
'width': '30', |
|
135
|
|
|
'label': _('Fullname'), |
|
136
|
|
|
'align': 'left'}, |
|
137
|
|
|
], |
|
138
|
|
|
ui_item="getClientPatientID", |
|
139
|
|
|
minLength=3, |
|
140
|
|
|
showOn=True, |
|
141
|
|
|
), |
|
142
|
|
|
), |
|
143
|
|
|
] |
|
144
|
|
|
|
|
145
|
|
|
def getOrder(self, schematas): |
|
146
|
|
|
default = schematas['default'] |
|
147
|
|
|
default.remove('Patient') |
|
148
|
|
|
default.remove('Doctor') |
|
149
|
|
|
default.remove('ClientPatientID') |
|
150
|
|
|
default.insert(default.index('Template'), 'ClientPatientID') |
|
151
|
|
|
default.insert(default.index('Template'), 'Patient') |
|
152
|
|
|
default.insert(default.index('Template'), 'Doctor') |
|
153
|
|
|
schematas['default'] = default |
|
154
|
|
|
return schematas |
|
155
|
|
|
|
|
156
|
|
|
def getFields(self): |
|
157
|
|
|
return self.fields |
|
158
|
|
|
|
|
159
|
|
|
|
|
160
|
|
|
class AnalysisRequestSchemaModifier(object): |
|
161
|
|
|
adapts(IAnalysisRequest) |
|
162
|
|
|
implements(ISchemaModifier) |
|
163
|
|
|
|
|
164
|
|
|
def __init__(self, context): |
|
165
|
|
|
self.context = context |
|
166
|
|
|
|
|
167
|
|
|
def fiddle(self, schema): |
|
168
|
|
|
schema['Batch'].widget.label = _("Case") |
|
169
|
|
|
return schema |
|
170
|
|
|
|