|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# |
|
3
|
|
|
# This file is part of SENAITE.CORE |
|
4
|
|
|
# |
|
5
|
|
|
# Copyright 2018 by it's authors. |
|
6
|
|
|
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst. |
|
7
|
|
|
|
|
8
|
|
|
""" Beckman Coulter Access 2 |
|
9
|
|
|
""" |
|
10
|
|
|
from bika.lims import bikaMessageFactory as _ |
|
11
|
|
|
from bika.lims.utils import t |
|
12
|
|
|
from . import FacsCaliburParser, FacsCaliburImporter |
|
13
|
|
|
import json |
|
14
|
|
|
import traceback |
|
15
|
|
|
|
|
16
|
|
|
title = "TaqMan96 DNA212BS" |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
def Import(context, request): |
|
20
|
|
|
""" TaqMan96 DNA212BS analysis results |
|
21
|
|
|
""" |
|
22
|
|
|
infile = request.form['taqman96_dna212bs_file'] |
|
23
|
|
|
fileformat = request.form['taqman96_dna212bs_format'] |
|
24
|
|
|
artoapply = request.form['taqman96_dna212bs_artoapply'] |
|
25
|
|
|
override = request.form['taqman96_dna212bs_override'] |
|
26
|
|
|
sample = request.form.get('taqman96_dna212bs_sample', |
|
27
|
|
|
'requestid') |
|
28
|
|
|
instrument = request.form.get('instrument', None) |
|
29
|
|
|
errors = [] |
|
30
|
|
|
logs = [] |
|
31
|
|
|
warns = [] |
|
32
|
|
|
|
|
33
|
|
|
# Load the most suitable parser according to file extension/options/etc... |
|
34
|
|
|
parser = None |
|
35
|
|
|
if not hasattr(infile, 'filename'): |
|
36
|
|
|
errors.append(_("No file selected")) |
|
37
|
|
|
if fileformat == 'csv': |
|
38
|
|
|
parser = FacsCalibur2Parser(infile) |
|
39
|
|
|
else: |
|
40
|
|
|
errors.append(t(_("Unrecognized file format ${fileformat}", |
|
41
|
|
|
mapping={"fileformat": fileformat}))) |
|
42
|
|
|
|
|
43
|
|
|
if parser: |
|
44
|
|
|
# Load the importer |
|
45
|
|
|
status = ['sample_received', 'attachment_due', 'to_be_verified'] |
|
46
|
|
|
if artoapply == 'received': |
|
47
|
|
|
status = ['sample_received'] |
|
48
|
|
|
elif artoapply == 'received_tobeverified': |
|
49
|
|
|
status = ['sample_received', 'attachment_due', 'to_be_verified'] |
|
50
|
|
|
|
|
51
|
|
|
over = [False, False] |
|
52
|
|
|
if override == 'nooverride': |
|
53
|
|
|
over = [False, False] |
|
54
|
|
|
elif override == 'override': |
|
55
|
|
|
over = [True, False] |
|
56
|
|
|
elif override == 'overrideempty': |
|
57
|
|
|
over = [True, True] |
|
58
|
|
|
|
|
59
|
|
|
sam = ['getId', 'getSampleID', 'getClientSampleID'] |
|
60
|
|
|
if sample == 'requestid': |
|
61
|
|
|
sam = ['getId'] |
|
62
|
|
|
if sample == 'sampleid': |
|
63
|
|
|
sam = ['getSampleID'] |
|
64
|
|
|
elif sample == 'clientsid': |
|
65
|
|
|
sam = ['getClientSampleID'] |
|
66
|
|
|
elif sample == 'sample_clientsid': |
|
67
|
|
|
sam = ['getSampleID', 'getClientSampleID'] |
|
68
|
|
|
|
|
69
|
|
|
importer = FacsCalibur2Importer(parser=parser, |
|
70
|
|
|
context=context, |
|
71
|
|
|
idsearchcriteria=sam, |
|
72
|
|
|
allowed_ar_states=status, |
|
73
|
|
|
allowed_analysis_states=None, |
|
74
|
|
|
override=over, |
|
75
|
|
|
instrument_uid=instrument) |
|
76
|
|
|
tbex = '' |
|
77
|
|
|
try: |
|
78
|
|
|
importer.process() |
|
79
|
|
|
except: |
|
80
|
|
|
tbex = traceback.format_exc() |
|
81
|
|
|
errors = importer.errors |
|
82
|
|
|
logs = importer.logs |
|
83
|
|
|
warns = importer.warns |
|
84
|
|
|
if tbex: |
|
85
|
|
|
errors.append(tbex) |
|
86
|
|
|
|
|
87
|
|
|
results = {'errors': errors, 'log': logs, 'warns': warns} |
|
88
|
|
|
|
|
89
|
|
|
return json.dumps(results) |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
class FacsCalibur2Parser(FacsCaliburCSVParser): |
|
|
|
|
|
|
93
|
|
|
def getAttachmentFileType(self): |
|
94
|
|
|
return "TaqMan96 DNA212BS " |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
class FacsCalibur2Importer(FacsCaliburImporter): |
|
98
|
|
|
def getKeywordsToBeExcluded(self): |
|
99
|
|
|
return [] |
|
100
|
|
|
|