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

Do not allow to "submit" AST analyses with no result saved #25

Merged
merged 3 commits into from
Jun 21, 2023
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 docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.1.0 (unreleased)
------------------

- #25 Do not allow to "submit" AST analyses with no result save
- #23 Fix AST calculation does not work when extrapolated antibiotics
- #22 Hide Unit and display Submitter before Captured in AST entry
- #21 Fix AST entry is empty when analyses categorization for sample is checked
Expand Down
20 changes: 13 additions & 7 deletions src/senaite/ast/adapters/guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,26 @@ def guard_submit(self):
# Not an AST analysis
return True

# Check that all interim fields have non-empty values
keyword = self.context.getKeyword()
for interim in self.context.getInterimFields():
# Get the antibiotics (as interim fields)
antibiotics = self.context.getInterimFields()
if not antibiotics:
return False

if utils.is_extrapolated_interim(interim):
# Skip extrapolated interims
keyword = self.context.getKeyword()
for antibiotic in antibiotics:
if utils.is_extrapolated_interim(antibiotic):
# Skip extrapolated antibiotics
continue

if utils.is_interim_empty(antibiotic):
# Cannot submit if no result
return False

if keyword in [ZONE_SIZE_KEY, DISK_CONTENT_KEY]:
# Negative values are not permitted
value = interim.get("value")
value = antibiotic.get("value")
value = api.to_float(value, default=-1)
if value < 0:
return False

# No empties
return True