bika.health.catalog.indexers.analysisrequest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 34
dl 0
loc 75
rs 10
c 0
b 0
f 0

8 Functions

Rating   Name   Duplication   Size   Complexity  
A getClientPatientID() 0 3 1
A getPatientID() 0 3 1
A getDoctorTitle() 0 3 1
A getPatientTitle() 0 3 1
A getDoctorURL() 0 4 1
A getDoctorUID() 0 3 1
A getPatientURL() 0 4 1
A getPatientUID() 0 3 1
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 plone.indexer import indexer
22
23
from bika.health.utils import get_obj_from_field, get_attr_from_field
24
from bika.lims import api
25
from bika.lims import logger
26
from bika.lims.catalog import CATALOG_ANALYSIS_REQUEST_LISTING
27
from bika.lims.interfaces import IAnalysisRequest
28
from bika.lims.interfaces import IBikaCatalogAnalysisRequestListing
29
30
31
# Defining the indexes for this extension. Since this is an extension, no
32
# getter is created so we need to create indexes in that way.
33
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
34
def getPatientUID(instance):
35
    return get_attr_from_field(instance, 'Patient', 'UID', '')
36
37
38
# We use this index to sort columns and filter lists
39
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
40
def getPatientTitle(instance):
41
    return get_attr_from_field(instance, 'Patient', 'Title', '')
42
43
44
45
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
46
def getPatientID(instance):
47
    return get_attr_from_field(instance, 'Patient', 'getId', '')
48
49
50
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
51
def getPatientURL(instance):
52
    item = get_obj_from_field(instance, 'Patient', None)
53
    return item and item.absolute_url_path() or ''
54
55
56
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
57
def getClientPatientID(instance):
58
    return get_attr_from_field(instance, 'Patient', 'ClientPatientID', '')
59
60
61
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
62
def getDoctorUID(instance):
63
    return get_attr_from_field(instance, 'Doctor', 'UID', '')
64
65
66
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
67
def getDoctorTitle(instance):
68
    return get_attr_from_field(instance, 'Doctor', 'Title', '')
69
70
71
@indexer(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
72
def getDoctorURL(instance):
73
    item = get_obj_from_field(instance, 'Doctor', None)
74
    return item and item.absolute_url_path() or ''
75
76