diff --git a/classification/models/classification.py b/classification/models/classification.py index 85d37cdda..84ab5bc46 100644 --- a/classification/models/classification.py +++ b/classification/models/classification.py @@ -689,9 +689,15 @@ def _evidence(self): def id_str(self): return str(self.id) + @property + def cr_lab_id(self): + if settings.VARIANT_CLASSIFICATION_ID_OVERRIDE_PREFIX: + return f"CR_{self.id}" + return self.lab_record_id + @property def friendly_label(self): - return self.lab.name + ' / ' + self.lab_record_id + return self.lab.name + ' / ' + self.cr_lab_id @staticmethod def to_date(date_str: str) -> Optional[datetime]: @@ -1816,6 +1822,7 @@ def as_json(self, params: ClassificationJsonParams) -> dict: 'lab_record_id': self.lab_record_id, 'institution_name': self.lab.organization.name, 'lab_id': self.lab.group_name, + 'cr_lab_id': self.cr_lab_id, 'org_name': self.lab.organization.shortest_name, 'lab_name': self.lab.name, 'title': title, @@ -2276,6 +2283,12 @@ def _evidence(self): def id_str(self) -> str: return self.classification.id_str + '.' + str(self.created.timestamp()) + @property + def cr_lab_id(self) -> str: + if settings.VARIANT_CLASSIFICATION_ID_OVERRIDE_PREFIX: + return f"CR_{self.classification.id_str}" + return self.classification.lab_record_id + @property def curated_date(self) -> datetime: return CuratedDate(self).date diff --git a/classification/signals/classification_search.py b/classification/signals/classification_search.py index 469694b02..6139e89be 100644 --- a/classification/signals/classification_search.py +++ b/classification/signals/classification_search.py @@ -2,6 +2,7 @@ from functools import reduce from typing import Optional, List +from django.conf import settings from django.contrib.auth.models import User from django.db.models import Q from django.dispatch import receiver @@ -18,16 +19,19 @@ search_type=Classification, example=SearchExample( note="The lab record ID", - examples=["vc1545"] + examples=["CR_1545" if settings.VARIANT_CLASSIFICATION_ID_OVERRIDE_PREFIX else "vc1545"] ) ) def classification_search(search_input: SearchInputInstance): search_string = search_input.search_string """ Search for LabId which can be either: - "vc1080" or "Molecular Genetics, Frome Road / vc1080" (as it appears in classification) """ - - filters = [Q(classification__lab_record_id__iexact=search_string)] # exact match + "vc1080" or "Molecular Genetics/ Frome Road / vc1080" (as it appears in classification) or CR_1080 or Molecular Genetics/ Frome Road / CR_1080 """ + if search_string.startswith("CR_"): + search_string = search_string[3:] + filters = [Q(classification__id=search_string)] + else: + filters = [Q(classification__lab_record_id__iexact=search_string)] # exact match slash_index = search_string.find("/") if slash_index > 0: parts = [p.strip() for p in search_string.split("/")] @@ -50,7 +54,11 @@ def classification_search(search_input: SearchInputInstance): lab_qs = lab_qs.filter(organization=org) if lab_qs: - filters.append(Q(classification__lab_record_id=lab_record_id) & Q(classification__lab__in=lab_qs)) + if lab_record_id.startswith("CR_"): + lab_record_id = lab_record_id[3:] + filters.append(Q(classification__id=lab_record_id) & Q(classification__lab__in=lab_qs)) + else: + filters.append(Q(classification__lab_record_id=lab_record_id) & Q(classification__lab__in=lab_qs)) q_cm = reduce(operator.or_, filters) cm_qs = ClassificationModification.filter_for_user(search_input.user).filter(is_last_published=True) diff --git a/classification/templates/classification/classification.html b/classification/templates/classification/classification.html index f94d911ed..367e1d030 100644 --- a/classification/templates/classification/classification.html +++ b/classification/templates/classification/classification.html @@ -22,6 +22,7 @@ vcform.init( { userAdmin: {{ user.is_superuser | jsonify }}, + lab_record_id: "{{ record.lab_record_id }}", genomeBuild: "{{ genome_build.pk }}", // citations: new Citations($('#citations')), citations: $('#citations'), @@ -124,7 +125,7 @@
Literature Citations
-
{{ record.org_name }} / {{ record.lab_name }} / {{ record.lab_record_id }}
+
{{ record.org_name }} / {{ record.lab_name }} / {{ record.cr_lab_id }}
diff --git a/classification/templates/classification/tags/classification_group_row.html b/classification/templates/classification/tags/classification_group_row.html index 65488fb84..a23a438dc 100644 --- a/classification/templates/classification/tags/classification_group_row.html +++ b/classification/templates/classification/tags/classification_group_row.html @@ -112,7 +112,7 @@
{% for record in group.modifications %}
- {{ record.classification.lab_record_id }} + {{ record.classification.cr_lab_id}} {{ record.classification.allele_info.issue_icon|default_if_none:'' }}
...
diff --git a/classification/templates/classification/tags/classification_quick.html b/classification/templates/classification/tags/classification_quick.html index 82ccfe451..c3d9ee05d 100644 --- a/classification/templates/classification/tags/classification_quick.html +++ b/classification/templates/classification/tags/classification_quick.html @@ -2,7 +2,7 @@ {% load static %} {% if vcm and vcm.classification.id %} {% if mode == "compact" %} - {{ vcm.classification.lab }} / {{ vcm.classification.lab_record_id }} + {{ vcm.classification.lab }} / {{ vcm.cr_lab_id }} {% else %}