|
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 Couter Access |
|
9
|
|
|
""" |
|
10
|
|
|
from datetime import datetime |
|
11
|
|
|
from bika.lims.exportimport.instruments.resultsimport import \ |
|
12
|
|
|
AnalysisResultsImporter, InstrumentCSVResultsFileParser |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
View Code Duplication |
class FacsCaliburParser(InstrumentCSVResultsFileParser): |
|
|
|
|
|
|
16
|
|
|
def __init__(self, csv): |
|
17
|
|
|
InstrumentCSVResultsFileParser.__init__(self, csv) |
|
18
|
|
|
self._columns = [] # The different columns names |
|
19
|
|
|
self._values = {} # The analysis services from the same resid |
|
20
|
|
|
self._resid = '' # A stored resid |
|
21
|
|
|
self._rownum = None |
|
22
|
|
|
self._end_header = False |
|
23
|
|
|
|
|
24
|
|
|
def _parseline(self, line): |
|
25
|
|
|
sline = line.split(',') |
|
26
|
|
|
if len(sline) > 0 and not self._end_header: |
|
27
|
|
|
self._columns = sline |
|
28
|
|
|
self._end_header = True |
|
29
|
|
|
return 0 |
|
30
|
|
|
elif sline > 0 and self._end_header: |
|
31
|
|
|
self.parse_data_line(sline) |
|
32
|
|
|
else: |
|
33
|
|
|
self.err("Unexpected data format", numline=self._numline) |
|
34
|
|
|
return -1 |
|
35
|
|
|
|
|
36
|
|
|
def parse_data_line(self, sline): |
|
37
|
|
|
""" |
|
38
|
|
|
Parses the data line and builds the dictionary. |
|
39
|
|
|
:param sline: a split data line to parse |
|
40
|
|
|
:returns: the number of rows to jump and parse the next data line or return the code error -1 |
|
41
|
|
|
""" |
|
42
|
|
|
# if there are less values founded than headers, it's an error |
|
43
|
|
|
if len(sline) != len(self._columns): |
|
44
|
|
|
self.err("One data line has the wrong number of items") |
|
45
|
|
|
return -1 |
|
46
|
|
|
#print self._columns |
|
47
|
|
|
rawdict = {} |
|
48
|
|
|
for idx, result in enumerate(sline): |
|
49
|
|
|
rawdict[self._columns[idx]] = result |
|
50
|
|
|
# Getting key values |
|
51
|
|
|
resid = rawdict['Sample ID'] |
|
52
|
|
|
del rawdict['Sample ID'] |
|
53
|
|
|
testname = rawdict['Test'] |
|
54
|
|
|
del rawdict['Test'] |
|
55
|
|
|
|
|
56
|
|
|
# Building the new dict |
|
57
|
|
|
rawdict['DefaultResult'] = 'Result' |
|
58
|
|
|
rawdict['Remarks'] = rawdict['Comment'] |
|
59
|
|
|
del rawdict['Comment'] |
|
60
|
|
|
print rawdict |
|
61
|
|
|
|
|
62
|
|
|
self._addRawResult(resid, {testname: rawdict}, False) |
|
63
|
|
|
return 0 |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
class FacsCaliburImporter(AnalysisResultsImporter): |
|
67
|
|
|
def __init__(self, parser, context, idsearchcriteria, override, |
|
68
|
|
|
allowed_ar_states=None, allowed_analysis_states=None, |
|
69
|
|
|
instrument_uid=None): |
|
70
|
|
|
AnalysisResultsImporter.__init__(self, parser, context, |
|
71
|
|
|
idsearchcriteria, override, |
|
72
|
|
|
allowed_ar_states, |
|
73
|
|
|
allowed_analysis_states, |
|
74
|
|
|
instrument_uid) |
|
75
|
|
|
|