lims: repetitions: consider method when controlling repetitions

This commit is contained in:
Adrián Bernardi 2021-07-22 10:26:22 -03:00
parent c9291dc4ad
commit 8257c908e3
3 changed files with 41 additions and 51 deletions

View File

@ -430,8 +430,8 @@ class Notebook(ModelSQL, ModelView):
notebooks_ids = '\', \''.join(str(n) for n in notebooks_ids + [0])
cursor.execute('SELECT nl.notebook, nl.analysis, nl.accepted, '
'd.report_grouper '
cursor.execute('SELECT nl.notebook, nl.analysis, nl.method, '
'd.report_grouper, nl.accepted '
'FROM "' + NotebookLine._table + '" nl '
'INNER JOIN "' + EntryDetailAnalysis._table + '" d '
'ON d.id = nl.analysis_detail '
@ -453,13 +453,12 @@ class Notebook(ModelSQL, ModelView):
(laboratory_id,))
notebook_lines = cursor.fetchall()
# Check accepted repetitions
to_check = []
oks = []
# Check repetitions
oks, to_check = [], []
accepted_notebooks = []
for line in notebook_lines:
key = (line[0], line[1], line[3])
if not line[2]:
key = (line[0], line[1], line[2], line[3])
if not line[4]:
to_check.append(key)
else:
oks.append(key)
@ -469,7 +468,7 @@ class Notebook(ModelSQL, ModelView):
accepted_notebooks = list(set(accepted_notebooks))
excluded_notebooks = set()
for n_id, a_id, grouper in to_check:
for n_id, a_id, m_id, grouper in to_check:
if n_id not in accepted_notebooks:
continue
key = (n_id, grouper)
@ -6039,7 +6038,8 @@ class AnalysisPendingInform(Report):
if party:
party_clause = 'AND e.party = ' + str(party)
cursor.execute('SELECT nl.notebook, nl.analysis, nl.accepted '
cursor.execute('SELECT nl.notebook, nl.analysis, nl.method, '
'nl.accepted '
'FROM "' + NotebookLine._table + '" nl '
'INNER JOIN "' + Notebook._table + '" n '
'ON n.id = nl.notebook '
@ -6061,12 +6061,11 @@ class AnalysisPendingInform(Report):
(date_from, date_to, laboratory,))
notebook_lines = cursor.fetchall()
# Check accepted repetitions
to_check = []
oks = []
# Check repetitions
oks, to_check = [], []
for line in notebook_lines:
key = (line[0], line[1])
if not line[2]:
key = (line[0], line[1], line[2])
if not line[3]:
to_check.append(key)
else:
oks.append(key)
@ -6074,7 +6073,7 @@ class AnalysisPendingInform(Report):
to_check = list(set(to_check) - set(oks))
excluded_notebooks = {}
for n_id, a_id in to_check:
for n_id, a_id, m_id in to_check:
if n_id not in excluded_notebooks:
excluded_notebooks[n_id] = []
excluded_notebooks[n_id].append(a_id)

View File

@ -2079,8 +2079,8 @@ class GenerateResultsReport(Wizard):
if self.start.party:
party_clause = 'AND e.party = ' + str(self.start.party.id)
cursor.execute('SELECT nl.notebook, nl.analysis, nl.accepted, '
'd.report_grouper '
cursor.execute('SELECT nl.notebook, nl.analysis, nl.method, '
'd.report_grouper, nl.accepted '
'FROM "' + NotebookLine._table + '" nl '
'INNER JOIN "' + EntryDetailAnalysis._table + '" d '
'ON d.id = nl.analysis_detail '
@ -2105,13 +2105,12 @@ class GenerateResultsReport(Wizard):
self.start.laboratory.id,))
notebook_lines = cursor.fetchall()
# Check accepted repetitions
to_check = []
oks = []
# Check repetitions
oks, to_check = [], []
accepted_notebooks = []
for line in notebook_lines:
key = (line[0], line[1], line[3])
if not line[2]:
key = (line[0], line[1], line[2], line[3])
if not line[4]:
to_check.append(key)
else:
oks.append(key)
@ -2121,7 +2120,7 @@ class GenerateResultsReport(Wizard):
accepted_notebooks = list(set(accepted_notebooks))
excluded_notebooks = {}
for n_id, a_id, grouper in to_check:
for n_id, a_id, m_id, grouper in to_check:
if n_id not in accepted_notebooks:
continue
key = (n_id, grouper)

View File

@ -3045,8 +3045,9 @@ class Sample(ModelSQL, ModelView):
samples_in_progress = Config(1).samples_in_progress
digits = Sample.completion_percentage.digits[1]
cursor.execute('SELECT nl.notebook, nl.analysis, nl.accepted, '
'nl.result, nl.literal_result, nl.result_modifier '
cursor.execute('SELECT nl.notebook, nl.analysis, nl.method, '
'nl.accepted, nl.result, nl.literal_result, '
'nl.result_modifier '
'FROM "' + NotebookLine._table + '" nl '
'INNER JOIN "' + EntryDetailAnalysis._table + '" d '
'ON d.id = nl.analysis_detail '
@ -3066,22 +3067,23 @@ class Sample(ModelSQL, ModelView):
if not total:
return _ZERO
# Check repetitions
oks, to_check = [], []
if samples_in_progress == 'accepted':
for line in notebook_lines:
key = (line[0], line[1])
if line[2]:
key = (line[0], line[1], line[2])
if line[3]:
oks.append(key)
else:
to_check.append(key)
elif samples_in_progress == 'result':
for line in notebook_lines:
key = (line[0], line[1])
if (line[3] not in [None, ''] or
line[4] not in [None, ''] or
line[5] in ['d', 'nd', 'pos',
key = (line[0], line[1], line[2])
if (line[4] not in [None, ''] or
line[5] not in [None, ''] or
line[6] in ['d', 'nd', 'pos',
'neg', 'ni', 'abs', 'pre', 'na']):
oks.append(key)
else:
@ -4460,21 +4462,16 @@ class CountersampleStorage(Wizard):
if not notebook_lines:
continue
# Check not accepted (with repetitions)
to_check = []
oks = []
# Check repetitions
oks, to_check = [], []
for line in notebook_lines:
key = line.analysis.id
key = (line.analysis.id, line.method.id)
if not line.accepted:
to_check.append(key)
else:
oks.append(key)
to_check = list(set(to_check))
oks = list(set(oks))
if to_check:
for key in oks:
if key in to_check:
to_check.remove(key)
to_check = list(set(to_check) - set(oks))
if len(to_check) > 0:
continue
@ -6099,21 +6096,16 @@ class CountersampleStorageReport(Report):
if not notebook_lines:
continue
# Check not accepted (with repetitions)
to_check = []
oks = []
# Check repetitions
oks, to_check = [], []
for line in notebook_lines:
key = line.analysis.id
key = (line.analysis.id, line.method.id)
if not line.accepted:
to_check.append(key)
else:
oks.append(key)
to_check = list(set(to_check))
oks = list(set(oks))
if to_check:
for key in oks:
if key in to_check:
to_check.remove(key)
to_check = list(set(to_check) - set(oks))
if len(to_check) > 0:
continue