-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from NHS-NGS/development
Development
- Loading branch information
Showing
20 changed files
with
482 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,5 +284,6 @@ class Meta: | |
'recruiting_disease', | ||
'sex', | ||
'nhs_num', | ||
'disease_subtype' | ||
'disease_subtype', | ||
'case_code' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,46 @@ def update_for_t3(report_id): | |
pullt3=True, | ||
sample=report.ir_family.participant_family.proband.gel_id) | ||
|
||
@task | ||
def case_alert_email(): | ||
''' | ||
Utility function designed to be run with celery. Emails GELTeam nightly about CaseAlert cases | ||
:param report_id: GEL InterpretationReport ID | ||
:return: Nothing | ||
''' | ||
sample_types = {'raredisease': False, 'cancer': False} | ||
matching_cases = {} | ||
for s_type in sample_types: | ||
case_alerts = CaseAlert.objects.filter(sample_type=s_type) | ||
gel_reports = GELInterpretationReport.objects.latest_cases_by_sample_type( | ||
sample_type=s_type).prefetch_related('ir_family__participant_family__proband') | ||
matching_cases[s_type] = {} | ||
for case in case_alerts: | ||
matching_cases[s_type][case.id] = [] | ||
for report in gel_reports: | ||
try: | ||
if report.ir_family.participant_family.proband.gel_id == str(case.gel_id): | ||
matching_cases[s_type][case.id].append((report.id, | ||
report.ir_family.ir_family_id)) | ||
sample_types[s_type] = True | ||
except Proband.DoesNotExist: | ||
pass | ||
|
||
text_content = '' | ||
if sample_types['cancer'] or sample_types['raredisease']: | ||
for s_type in sample_types: | ||
if matching_cases[s_type]: | ||
text_content += f'{s_type} Case Alert:\n' | ||
for case in matching_cases[s_type]: | ||
case_alert = CaseAlert.objects.get(id=case) | ||
text_content += f'Case {case_alert.gel_id} with CIP-ID of {matching_cases[s_type][case][0][1]} ' \ | ||
f'has been added to the database. CaseAlert comment: {case_alert.comment}\n' | ||
subject, from_email, to = f'GeL2MDT CaseAlert', '[email protected]', '[email protected]' | ||
msg = EmailMessage(subject, text_content, from_email, [to]) | ||
try: | ||
msg.send() | ||
except Exception as e: | ||
pass | ||
|
||
@task | ||
def listupdate_email(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.