Skip to content

Commit 2739081

Browse files
[ENH] in the review interface, it is possible to toggle, if only conflicting entries are shown
1 parent 33466fc commit 2739081

File tree

7 files changed

+156
-5
lines changed

7 files changed

+156
-5
lines changed

svip-o-vue/src/components/widgets/review/VariantDisease.vue

+55-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
<template>
22
<div :key="renderKey">
3+
<div v-if="review_cycle > 1">
4+
<br />
5+
<b-form-checkbox
6+
id="checkbox-1"
7+
v-model="only_conflicting"
8+
name="checkbox-1"
9+
value="yes"
10+
unchecked-value="no">
11+
Show only conflicting entries
12+
</b-form-checkbox>
13+
14+
<br />
15+
16+
</div>
17+
318
<div v-for="(submissionEntry, idx) in submissionEntries" :key="submissionEntry[0] + idx">
419
<b-card class="shadow-sm mb-3" align="left" no-body>
520
<h6 class="bg-primary text-light unwrappable-header p-2 m-0">
@@ -11,14 +26,25 @@
1126
<b-card-body class="p-0">
1227
<transition name="slide-fade">
1328
<div v-if="expander_array[idx].disease">
14-
<b-card-text class="p-2 m-0">
29+
<b-card-text
30+
class="p-2 m-0"
31+
:class="
32+
only_conflicting === 'yes' && !type.if_conflicting_reviews
33+
? 'hidden'
34+
: ''
35+
">
1536
<b-row align-v="center">
1637
<b-col align="left" cols="2">
1738
<div class="ml-1">
1839
<expander
1940
v-model="expander_array[idx].curation_entries[index]" />
2041
{{ type.type_of_evidence }}
2142
{{ type.drug && ` - ${type.drug}` }}
43+
<br />
44+
45+
<p style="color: red" v-if="type.if_conflicting_reviews">
46+
Conflicting entry!
47+
</p>
2248
</div>
2349
</b-col>
2450
<b-col cols="2">
@@ -324,6 +350,7 @@ export default {
324350
props: ['variant_id', 'gene_id'],
325351
data() {
326352
return {
353+
only_conflicting: 'no',
327354
renderKey: 0,
328355
submissionEntries: [],
329356
selfReviewedEvidences: {},
@@ -343,22 +370,29 @@ export default {
343370
},
344371
draft: false,
345372
showOnlyOwnReviewStatus: true,
373+
review_cycle: 0,
346374
};
347375
},
348376
created() {
349377
// Watch if user is going to leave the page
350378
window.addEventListener('beforeunload', this.beforeWindowUnload);
351379
380+
if (this.variant.submission_entries.length > 0) {
381+
this.review_cycle = this.variant.submission_entries[0].review_cycle;
382+
}
383+
352384
this.submissionEntries = Object.entries(
353385
groupBy(
354-
this.variant.submission_entries.filter(i =>
355-
['Prognostic', 'Diagnostic', 'Predictive / Therapeutic'].includes(i.type_of_evidence)
356-
),
386+
this.variant.submission_entries //
387+
.filter(i =>
388+
['Prognostic', 'Diagnostic', 'Predictive / Therapeutic'].includes(i.type_of_evidence)
389+
),
357390
item => {
358391
return item.disease && item.disease.name ? item.disease.name : 'Unspecified';
359392
}
360393
)
361394
);
395+
362396
this.getExpanderArray();
363397
364398
// Check that this page is appropriate regarding current review stage of variant
@@ -390,6 +424,19 @@ export default {
390424
},
391425
392426
methods: {
427+
// groupSubmissionsEntries(submissionEntriesUngrouped) {
428+
// return Object.entries(
429+
// groupBy(
430+
// submissionEntriesUngrouped.filter(i =>
431+
// ['Prognostic', 'Diagnostic', 'Predictive / Therapeutic'].includes(i.type_of_evidence)
432+
// ),
433+
// item => {
434+
// return item.disease && item.disease.name ? item.disease.name : 'Unspecified';
435+
// }
436+
// )
437+
// );
438+
// },
439+
393440
numberOfEmptySquares(length) {
394441
switch (length) {
395442
case 0:
@@ -644,4 +691,8 @@ export default {
644691
.alert-border {
645692
border-color: red;
646693
}
694+
695+
.hidden {
696+
visibility: hidden;
697+
}
647698
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.28 on 2022-12-12 17:25
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0167_submissionentry_review_cycle'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='submissionentry',
15+
name='if_conflicting_reviews',
16+
field=models.BooleanField(default=False),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 2.2.28 on 2022-12-12 17:29
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0168_submissionentry_if_conflicting_reviews'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='submissionentry',
15+
name='if_conflicting_reviews',
16+
),
17+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.28 on 2022-12-12 17:33
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0169_remove_submissionentry_if_conflicting_reviews'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='submissionentry',
15+
name='if_conflicting_reviews',
16+
field=models.BooleanField(default=False),
17+
),
18+
]

svip_api/api/models/svip.py

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ class SubmissionEntry(models.Model):
248248
effect = models.TextField(default="Not yet annotated")
249249
tier = models.TextField(default="Not yet annotated")
250250
review_cycle = models.IntegerField(default=1)
251+
if_conflicting_reviews = models.BooleanField(default=False)
251252

252253

253254
class CURATION_STATUS(ModelChoice):

svip_api/api/serializers/svip.py

+4
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ class Meta:
552552

553553

554554
class SubmissionEntrySerializer(serializers.ModelSerializer):
555+
556+
555557
variant = SimpleVariantSerializer()
556558
curation_entries = CurationEntrySerializer(
557559
many=True, required=False, source='curationentry_set')
@@ -567,6 +569,8 @@ class Meta:
567569
read_only_fields = ['id']
568570

569571

572+
573+
570574
# ================================================================================================================
571575
# === SVIP Variant Submission
572576
# ================================================================================================================

svip_api/api/views/svip.py

+43-1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,30 @@ def perform_create(self, serializer):
316316
"""Create a new recipe."""
317317
serializer.save(user=self.request.user)
318318

319+
@action(detail=False, methods=['POST'])
320+
def bulk_submit_test(self, request):
321+
if isinstance(request.data, dict) and request.data['update']:
322+
for entry in request.data['data']:
323+
submission_entry = SubmissionEntry.objects.filter(pk=entry['id'])
324+
for id in entry['curation_reviews']:
325+
curation_review = CurationReview.objects.get(pk=id)
326+
print(entry['effect'], curation_review.annotated_effect, entry['tier'], curation_review.annotated_tier)
327+
print(entry['effect'] == curation_review.annotated_effect and entry['tier'] == curation_review.annotated_tier)
328+
print('\n' * 5)
329+
submission_entry = submission_entry[0]
330+
print([review.acceptance for review in submission_entry.curation_reviews.all()])
331+
print(all(review.acceptance for review in submission_entry.curation_reviews.all()))
332+
return JsonResponse({
333+
"message": "pi pa po",
334+
})
335+
336+
return JsonResponse({
337+
"message": "pi pa po",
338+
})
339+
340+
341+
342+
319343
@action(detail=False, methods=['POST'])
320344
def bulk_submit(self, request):
321345

@@ -326,8 +350,25 @@ def bulk_submit(self, request):
326350
review_cycle=submission_entry[0].review_cycle + 1)
327351
for id in entry['curation_entries']:
328352
CurationEntry.objects.filter(pk=id).update(status='resubmitted')
353+
354+
for id in entry['curation_reviews']:
355+
curation_review = CurationReview.objects.get(pk=id)
356+
if entry['effect'] == curation_review.annotated_effect and entry['tier'] == curation_review.annotated_tier:
357+
curation_review.acceptance = True
358+
else:
359+
curation_review.acceptance = False
360+
curation_review.save()
361+
362+
submission_entry = submission_entry[0]
363+
if not all(review.acceptance for review in submission_entry.curation_reviews.all()):
364+
submission_entry.if_conflicting_reviews = True
365+
else:
366+
submission_entry.if_conflicting_reviews = False
367+
submission_entry.save()
368+
329369
for id in entry['curation_reviews']:
330370
CurationReview.objects.get(pk=id).delete()
371+
331372
return JsonResponse({
332373
"message": "Your annotation was successfully saved!",
333374

@@ -367,7 +408,8 @@ def __save_review_obj(self, obj):
367408
review = CurationReview.objects.get(id=obj['id'])
368409
else:
369410
review = CurationReview()
370-
review.submission_entry = SubmissionEntry.objects.get(id=obj['submission_entry'])
411+
submission_entry = SubmissionEntry.objects.get(id=obj['submission_entry'])
412+
review.submission_entry = submission_entry
371413
review.annotated_effect = obj['effect']
372414
review.annotated_tier = obj['tier']
373415
review.comment = obj['comment']

0 commit comments

Comments
 (0)