Skip to content

Commit

Permalink
Merge discordance triage extended work
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMadBug committed Sep 13, 2023
1 parent 3c9bc36 commit 23a2470
Show file tree
Hide file tree
Showing 36 changed files with 797 additions and 309 deletions.
1 change: 0 additions & 1 deletion classification/admin/classification_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,6 @@ def ensure_bulk(self, request):
ensure_discordance_report_triages_bulk()



@admin.register(DiscordanceNotification)
class DiscordanceNotificationAdmin(ModelAdminBasics):
list_display = ("lab", "discordance_report", "notification_sent_date")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.2 on 2023-09-08 00:05

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('classification', '0108_discordancereporttriage'),
]

operations = [
migrations.AddField(
model_name='discordancereporttriage',
name='closed',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='discordancereporttriage',
name='triage_status',
field=models.TextField(choices=[('P', 'Pending Triage'), ('F', 'Will Amend'), ('D', 'For Joint Discussion'), ('R', 'Confident in Classification'), ('X', 'Low Penetrance/Risk Allele etc')], default='P', max_length=1),
),
]
14 changes: 14 additions & 0 deletions classification/migrations/0110_merge_20230912_1033.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.2.2 on 2023-09-12 01:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('classification', '0109_condition_matching_override_blank condition'),
('classification', '0109_discordancereporttriage_closed_and_more'),
]

operations = [
]
5 changes: 5 additions & 0 deletions classification/models/clinical_context_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,17 @@ class ClinicalContextRecalcTrigger(Enum):
DELAYED = "delayed"
OTHER = "other"
PENDING_CS_CHANGE = "pending_cs_change"
RE_OPEN = "reopen"


@dataclass(frozen=True)
class ClinicalContextChangeData:
cause_text: str
cause_code: ClinicalContextRecalcTrigger
notify_worthy: bool = True

def with_notify_worthy(self, notify: bool) -> 'ClinicalContextChangeData':
return ClinicalContextChangeData(cause_text=self.cause_text, cause_code=self.cause_code, notify_worthy=notify)


class ClinicalContext(FlagsMixin, TimeStampedModel):
Expand Down
17 changes: 16 additions & 1 deletion classification/models/discordance_lab_summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,19 @@ def for_discordance_report(discordance_report: DiscordanceReport, perspective: L
for triage in discordance_report.discordancereporttriage_set.select_related('lab').all():
triage_by_lab[triage.lab] = triage

return [dls._with_triage(triage_by_lab.pop(dls.lab, None)) for dls in dlses]
# apply triages to the first (non withdrawn row) for each lab
# in case a lab has both withdrawn and non-withdrawn records
with_triages = []
for dl in dlses:
if not dl.clinical_significance_to == 'withdrawn':
dl = dl._with_triage(triage_by_lab.pop(dl.lab, None))
with_triages.append(dl)

if triage_by_lab:
# there are some triages for purely withdrawn labs
for dl in with_triages:
if not dl.triage:
dl = dl._with_triage(triage_by_lab.pop(dl.lab, None))
with_triages.append(dl)

return with_triages
Loading

0 comments on commit 23a2470

Please sign in to comment.