Skip to content

Commit

Permalink
[ENH] in the review interface, it is possible to toggle, if only conf…
Browse files Browse the repository at this point in the history
…licting entries are shown
  • Loading branch information
anastasia-escher committed Dec 13, 2022
1 parent 33466fc commit 2739081
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 5 deletions.
59 changes: 55 additions & 4 deletions svip-o-vue/src/components/widgets/review/VariantDisease.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<template>
<div :key="renderKey">
<div v-if="review_cycle > 1">
<br />
<b-form-checkbox
id="checkbox-1"
v-model="only_conflicting"
name="checkbox-1"
value="yes"
unchecked-value="no">
Show only conflicting entries
</b-form-checkbox>

<br />

</div>

<div v-for="(submissionEntry, idx) in submissionEntries" :key="submissionEntry[0] + idx">
<b-card class="shadow-sm mb-3" align="left" no-body>
<h6 class="bg-primary text-light unwrappable-header p-2 m-0">
Expand All @@ -11,14 +26,25 @@
<b-card-body class="p-0">
<transition name="slide-fade">
<div v-if="expander_array[idx].disease">
<b-card-text class="p-2 m-0">
<b-card-text
class="p-2 m-0"
:class="
only_conflicting === 'yes' && !type.if_conflicting_reviews
? 'hidden'
: ''
">
<b-row align-v="center">
<b-col align="left" cols="2">
<div class="ml-1">
<expander
v-model="expander_array[idx].curation_entries[index]" />
{{ type.type_of_evidence }}
{{ type.drug && ` - ${type.drug}` }}
<br />

<p style="color: red" v-if="type.if_conflicting_reviews">
Conflicting entry!
</p>
</div>
</b-col>
<b-col cols="2">
Expand Down Expand Up @@ -324,6 +350,7 @@ export default {
props: ['variant_id', 'gene_id'],
data() {
return {
only_conflicting: 'no',
renderKey: 0,
submissionEntries: [],
selfReviewedEvidences: {},
Expand All @@ -343,22 +370,29 @@ export default {
},
draft: false,
showOnlyOwnReviewStatus: true,
review_cycle: 0,
};
},
created() {
// Watch if user is going to leave the page
window.addEventListener('beforeunload', this.beforeWindowUnload);
if (this.variant.submission_entries.length > 0) {
this.review_cycle = this.variant.submission_entries[0].review_cycle;
}
this.submissionEntries = Object.entries(
groupBy(
this.variant.submission_entries.filter(i =>
['Prognostic', 'Diagnostic', 'Predictive / Therapeutic'].includes(i.type_of_evidence)
),
this.variant.submission_entries //
.filter(i =>
['Prognostic', 'Diagnostic', 'Predictive / Therapeutic'].includes(i.type_of_evidence)
),
item => {
return item.disease && item.disease.name ? item.disease.name : 'Unspecified';
}
)
);
this.getExpanderArray();
// Check that this page is appropriate regarding current review stage of variant
Expand Down Expand Up @@ -390,6 +424,19 @@ export default {
},
methods: {
// groupSubmissionsEntries(submissionEntriesUngrouped) {
// return Object.entries(
// groupBy(
// submissionEntriesUngrouped.filter(i =>
// ['Prognostic', 'Diagnostic', 'Predictive / Therapeutic'].includes(i.type_of_evidence)
// ),
// item => {
// return item.disease && item.disease.name ? item.disease.name : 'Unspecified';
// }
// )
// );
// },
numberOfEmptySquares(length) {
switch (length) {
case 0:
Expand Down Expand Up @@ -644,4 +691,8 @@ export default {
.alert-border {
border-color: red;
}
.hidden {
visibility: hidden;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2022-12-12 17:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0167_submissionentry_review_cycle'),
]

operations = [
migrations.AddField(
model_name='submissionentry',
name='if_conflicting_reviews',
field=models.BooleanField(default=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.2.28 on 2022-12-12 17:29

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0168_submissionentry_if_conflicting_reviews'),
]

operations = [
migrations.RemoveField(
model_name='submissionentry',
name='if_conflicting_reviews',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2022-12-12 17:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0169_remove_submissionentry_if_conflicting_reviews'),
]

operations = [
migrations.AddField(
model_name='submissionentry',
name='if_conflicting_reviews',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions svip_api/api/models/svip.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class SubmissionEntry(models.Model):
effect = models.TextField(default="Not yet annotated")
tier = models.TextField(default="Not yet annotated")
review_cycle = models.IntegerField(default=1)
if_conflicting_reviews = models.BooleanField(default=False)


class CURATION_STATUS(ModelChoice):
Expand Down
4 changes: 4 additions & 0 deletions svip_api/api/serializers/svip.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ class Meta:


class SubmissionEntrySerializer(serializers.ModelSerializer):


variant = SimpleVariantSerializer()
curation_entries = CurationEntrySerializer(
many=True, required=False, source='curationentry_set')
Expand All @@ -567,6 +569,8 @@ class Meta:
read_only_fields = ['id']




# ================================================================================================================
# === SVIP Variant Submission
# ================================================================================================================
Expand Down
44 changes: 43 additions & 1 deletion svip_api/api/views/svip.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ def perform_create(self, serializer):
"""Create a new recipe."""
serializer.save(user=self.request.user)

@action(detail=False, methods=['POST'])
def bulk_submit_test(self, request):
if isinstance(request.data, dict) and request.data['update']:
for entry in request.data['data']:
submission_entry = SubmissionEntry.objects.filter(pk=entry['id'])
for id in entry['curation_reviews']:
curation_review = CurationReview.objects.get(pk=id)
print(entry['effect'], curation_review.annotated_effect, entry['tier'], curation_review.annotated_tier)
print(entry['effect'] == curation_review.annotated_effect and entry['tier'] == curation_review.annotated_tier)
print('\n' * 5)
submission_entry = submission_entry[0]
print([review.acceptance for review in submission_entry.curation_reviews.all()])
print(all(review.acceptance for review in submission_entry.curation_reviews.all()))
return JsonResponse({
"message": "pi pa po",
})

return JsonResponse({
"message": "pi pa po",
})




@action(detail=False, methods=['POST'])
def bulk_submit(self, request):

Expand All @@ -326,8 +350,25 @@ def bulk_submit(self, request):
review_cycle=submission_entry[0].review_cycle + 1)
for id in entry['curation_entries']:
CurationEntry.objects.filter(pk=id).update(status='resubmitted')

for id in entry['curation_reviews']:
curation_review = CurationReview.objects.get(pk=id)
if entry['effect'] == curation_review.annotated_effect and entry['tier'] == curation_review.annotated_tier:
curation_review.acceptance = True
else:
curation_review.acceptance = False
curation_review.save()

submission_entry = submission_entry[0]
if not all(review.acceptance for review in submission_entry.curation_reviews.all()):
submission_entry.if_conflicting_reviews = True
else:
submission_entry.if_conflicting_reviews = False
submission_entry.save()

for id in entry['curation_reviews']:
CurationReview.objects.get(pk=id).delete()

return JsonResponse({
"message": "Your annotation was successfully saved!",

Expand Down Expand Up @@ -367,7 +408,8 @@ def __save_review_obj(self, obj):
review = CurationReview.objects.get(id=obj['id'])
else:
review = CurationReview()
review.submission_entry = SubmissionEntry.objects.get(id=obj['submission_entry'])
submission_entry = SubmissionEntry.objects.get(id=obj['submission_entry'])
review.submission_entry = submission_entry
review.annotated_effect = obj['effect']
review.annotated_tier = obj['tier']
review.comment = obj['comment']
Expand Down

0 comments on commit 2739081

Please sign in to comment.