Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing error percentage calculation for reference samples #1452

Merged
merged 2 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Changelog

**Fixed**

- #1452 Fix missing error percentage calculation for reference samples
- #1447 New Client contact has access to last client's Sample only
- #1446 Parameter `group` in `contact._addUserToGroup` was not considered
- #1444 Fixed Worksheet autofill of wide Iterims
Expand Down
1 change: 1 addition & 0 deletions bika/lims/browser/referencesample.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def folderitem(self, obj, item, index):
item["result"] = ref_result.get("result")
item["min"] = ref_result.get("min")
item["max"] = ref_result.get("max")
item["error"] = ref_result.get("error")

# Icons
after_icons = ""
Expand Down
13 changes: 10 additions & 3 deletions bika/lims/browser/widgets/referenceresultswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ def __init__(self, context, request, fieldvalue=[], allow_edit=True):
}
self.context_actions = {}


self.show_column_toggles = False
self.show_select_column = True
self.show_select_all_checkbox = True
self.pagesize = 999999
Expand Down Expand Up @@ -162,6 +160,7 @@ def folderitem(self, obj, item, index):
item["result"] = rr.get("result", "")
item["min"] = rr.get("min", "")
item["max"] = rr.get("max", "")
item["error"] = rr.get("error", "")

# Icons
after_icons = ""
Expand Down Expand Up @@ -224,16 +223,24 @@ def process_form(self, instance, field, form,

# If neither min nor max have been set, assume we only accept a
# discrete result (like if % of error was 0).
s_err = self._get_spec_value(form, uid, "error")
s_min = self._get_spec_value(form, uid, "min", result)
s_max = self._get_spec_value(form, uid, "max", result)

# If an error percentage was given, calculate the min/max from the
# error percentage
if s_err:
s_min = float(result) * (1 - float(s_err)/100)
s_max = float(result) * (1 + float(s_err)/100)

service = api.get_object_by_uid(uid)
values[uid] = {
"keyword": service.getKeyword(),
"uid": uid,
"result": result,
"min": s_min,
"max": s_max
"max": s_max,
"error": s_err
}

return values.values(), {}
Expand Down
5 changes: 5 additions & 0 deletions bika/lims/content/analysisspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def __init__(self, *arg, **kw):
super(ResultsRangeDict, self).__init__(*arg, **kw)
self["min"] = self.min
self["max"] = self.max
self["error"] = self.error
self["warn_min"] = self.warn_min
self["warn_max"] = self.warn_max
self["min_operator"] = self.min_operator
Expand All @@ -234,6 +235,10 @@ def min(self):
def max(self):
return self.get("max", '')

@property
def error(self):
return self.get("error", '')

@property
def warn_min(self):
return self.get("warn_min", self.min)
Expand Down