Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Fix PCRReplicate Batch control validation to properly check nucleic a…
Browse files Browse the repository at this point in the history
…cid type from requested Target rather than a related RT
  • Loading branch information
aaronstephenson committed Jun 11, 2019
1 parent 4a04284 commit 5c3769e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion code.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "lide",
"organization": "U.S. Geological Survey",
"description": "Web services for LILI (LIDE (Laboratory for Infectious Disease and the Environment) Information Management System)",
"version": "v0.101.0",
"version": "v0.102.0",
"status": "Release Candidate",

"permissions": {
Expand Down
22 changes: 14 additions & 8 deletions lideservices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,9 +1117,15 @@ def validate(self, request):
message += " and extraction number of " + str(request.data['extraction_number'])
return Response({"extraction_batch": message})

target = Target.objects.filter(id=request.data['target']).first()

if not target:
message = "No target was found with ID of " + str(request.data['target'])
return Response({"target": message})

pcrreplicate_batch = PCRReplicateBatch.objects.filter(
extraction_batch=extraction_batch.id,
target=request.data['target'],
target=target.id,
replicate_number=request.data['replicate_number']
).first()

Expand All @@ -1129,7 +1135,7 @@ def validate(self, request):
message += " and replicate number of " + str(request.data['replicate_number'])
return Response({"pcrreplicate_batch": message}, status=400)

rt = ReverseTranscription.objects.filter(extraction_batch=extraction_batch.id, re_rt=None).first()
rna = True if target.nucleic_acid_type.name == 'RNA' else False

# start building up the response object
field_validations = {"id": pcrreplicate_batch.id}
Expand All @@ -1139,12 +1145,12 @@ def validate(self, request):
'pcr_neg_cq_value', 'pcr_neg_gc_reaction', 'pcr_pos_cq_value', 'pcr_pos_gc_reaction']
control_validations = []
for field in control_fields:
field_validations[field] = request.data[field] if field in request.data else None
# exclude RT fields if there are no RTs related to this extraction batch
if 'rt' not in field or rt:
validation_error = self.validate_controls(field)
if validation_error:
control_validations.append(validation_error)
field_validations[field] = request.data[field] if field in request.data else None
# exclude RT fields if this is a DNA target
if 'rt' not in field or rna:
validation_error = self.validate_controls(field)
if validation_error:
control_validations.append(validation_error)
field_validations["validation_errors"] = control_validations

# check that pcrreplicates have been submitted
Expand Down

0 comments on commit 5c3769e

Please sign in to comment.