Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
77b5c140
Commit
77b5c140
authored
4 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
serology tests can be exported to mail template
parent
d3f85fa4
No related branches found
No related tags found
1 merge request
!253
Resolve "import of serology data"
Pipeline
#27199
passed
4 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/models/mail_template.py
+85
-7
85 additions, 7 deletions
smash/web/models/mail_template.py
with
85 additions
and
7 deletions
smash/web/models/mail_template.py
+
85
−
7
View file @
77b5c140
...
...
@@ -39,6 +39,13 @@ def get_formatted_time(time_format):
return
now
.
strftime
(
time_format
).
decode
(
date_format_encoding
())
def
date_to_str
(
date
,
format
):
if
date
is
not
None
:
return
date
.
strftime
(
format
).
decode
(
date_format_encoding
())
else
:
return
""
class
MailTemplate
(
models
.
Model
):
MAILS_TEMPLATE_GENERIC_TAGS
=
[
(
"
##DATE_FULL##
"
,
"
Current date when the mail will be generated (long format)
"
,
...
...
@@ -74,6 +81,36 @@ class MailTemplate(models.Model):
(
"
##S_MPOWER_ID##
"
,
"
Subject
'
s mPower identifier
"
,
""
),
(
"
##S_ND_NUMBER##
"
,
"
Subject
'
s ND number
"
,
""
),
(
"
##S_DATE_ADDED##
"
,
"
Subject
'
s date of creation
"
,
get_formatted_time
(
DATE_FORMAT_SHORT
)),
(
"
##VIRUS_1_SAMPLE_COLLECTION_DATE##
"
,
"
Virus test collection date in visit 1
"
,
get_formatted_time
(
DATE_FORMAT_SHORT
)),
(
"
##VIRUS_2_SAMPLE_COLLECTION_DATE##
"
,
"
Virus test collection date in visit 2
"
,
get_formatted_time
(
DATE_FORMAT_SHORT
)),
(
"
##VIRUS_3_SAMPLE_COLLECTION_DATE##
"
,
"
Virus test collection date in visit 3
"
,
get_formatted_time
(
DATE_FORMAT_SHORT
)),
(
"
##VIRUS_4_SAMPLE_COLLECTION_DATE##
"
,
"
Virus test collection date in visit 4
"
,
get_formatted_time
(
DATE_FORMAT_SHORT
)),
(
"
##VIRUS_5_SAMPLE_COLLECTION_DATE##
"
,
"
Virus test collection date in visit 5
"
,
get_formatted_time
(
DATE_FORMAT_SHORT
)),
(
"
##VIRUS_1_RESULT##
"
,
"
Virus test results in visit 1
"
,
"
Positive
"
),
(
"
##VIRUS_2_RESULT##
"
,
"
Virus test results in visit 2
"
,
"
Negative
"
),
(
"
##VIRUS_3_RESULT##
"
,
"
Virus test results in visit 3
"
,
"
Inconclusive
"
),
(
"
##VIRUS_4_RESULT##
"
,
"
Virus test results in visit 4
"
,
""
),
(
"
##VIRUS_5_RESULT##
"
,
"
Virus test results in visit 5
"
,
""
),
(
"
##VIRUS_1_IGA_STATUS##
"
,
"
IgA Status in visit 1
"
,
"
Positive
"
),
(
"
##VIRUS_2_IGA_STATUS##
"
,
"
IgA Status in visit 2
"
,
"
Negative
"
),
(
"
##VIRUS_3_IGA_STATUS##
"
,
"
IgA Status in visit 3
"
,
"
Borderline
"
),
(
"
##VIRUS_4_IGA_STATUS##
"
,
"
IgA Status in visit 4
"
,
""
),
(
"
##VIRUS_5_IGA_STATUS##
"
,
"
IgA Status in visit 5
"
,
""
),
(
"
##VIRUS_1_IGG_STATUS##
"
,
"
IgG Status in visit 1
"
,
"
Positive
"
),
(
"
##VIRUS_2_IGG_STATUS##
"
,
"
IgG Status in visit 2
"
,
"
Negative
"
),
(
"
##VIRUS_3_IGG_STATUS##
"
,
"
IgG Status in visit 3
"
,
"
Borderline
"
),
(
"
##VIRUS_4_IGG_STATUS##
"
,
"
IgG Status in visit 4
"
,
""
),
(
"
##VIRUS_5_IGG_STATUS##
"
,
"
IgG Status in visit 5
"
,
""
),
]
MAILS_TEMPLATE_VISIT_TAGS
=
[
...
...
@@ -257,12 +294,10 @@ class MailTemplate(models.Model):
@staticmethod
def
get_subject_replacements
(
study_subject
):
result
=
{}
if
study_subject
is
not
None
:
if
study_subject
.
subject
.
date_born
is
not
None
:
date_born
=
study_subject
.
subject
.
date_born
.
strftime
(
DATE_FORMAT_SHORT
).
decode
(
date_format_encoding
())
else
:
date_born
=
""
return
{
date_born
=
date_to_str
(
study_subject
.
subject
.
date_born
,
DATE_FORMAT_SHORT
)
result
=
{
"
##S_FULL_NAME##
"
:
unicode
(
study_subject
),
"
##S_FIRST_NAME##
"
:
study_subject
.
subject
.
first_name
,
"
##S_LAST_NAME##
"
:
study_subject
.
subject
.
last_name
,
...
...
@@ -270,7 +305,7 @@ class MailTemplate(models.Model):
"
##S_CITY##
"
:
study_subject
.
subject
.
city
,
"
##S_COUNTRY##
"
:
unicode
(
study_subject
.
subject
.
country
),
"
##S_DIAGNOSIS_YEAR##
"
:
str
(
study_subject
.
year_of_diagnosis
),
"
##S_DATE_ADDED##
"
:
study_subject
.
date_added
.
strftime
(
DATE_FORMAT_SHORT
)
.
decode
(
date_format_encoding
())
,
"
##S_DATE_ADDED##
"
:
date_to_str
(
study_subject
.
date_added
,
DATE_FORMAT_SHORT
),
"
##S_DATE_BORN##
"
:
date_born
,
"
##S_DIAGNOSIS##
"
:
unicode
(
study_subject
.
diagnosis
),
"
##S_EMAIL##
"
:
unicode
(
study_subject
.
subject
.
email
),
...
...
@@ -286,7 +321,39 @@ class MailTemplate(models.Model):
'
##S_MAIL_LANGUAGE##
'
:
str
(
study_subject
.
subject
.
default_written_communication_language
),
'
##S_KNOWN_LANGUAGES##
'
:
"
,
"
.
join
([
l
.
name
for
l
in
study_subject
.
subject
.
languages
.
all
()])
}
return
{}
for
i
in
range
(
1
,
6
):
virus_test_field
=
"
##VIRUS_{}_RESULT##
"
.
format
(
i
)
virus_test_value
=
virus_test_to_str
(
getattr
(
study_subject
,
"
virus_test_{}
"
.
format
(
i
)),
getattr
(
study_subject
,
"
virus_test_{}_updated
"
.
format
(
i
)))
virus_test_date_field
=
"
##VIRUS_{}_SAMPLE_COLLECTION_DATE##
"
.
format
(
i
)
virus_test_date_value
=
date_to_str
(
getattr
(
study_subject
,
"
virus_test_{}_collection_date
"
.
format
(
i
)),
DATE_FORMAT_SHORT
)
virus_iga_status_field
=
"
##VIRUS_{}_IGA_STATUS##
"
.
format
(
i
)
virus_iga_status_value
=
getattr
(
study_subject
,
"
virus_test_{}_iga_status
"
.
format
(
i
))
if
virus_iga_status_value
is
None
:
virus_iga_status_value
=
""
virus_igg_status_field
=
"
##VIRUS_{}_IGG_STATUS##
"
.
format
(
i
)
virus_igg_status_value
=
getattr
(
study_subject
,
"
virus_test_{}_igg_status
"
.
format
(
i
))
if
virus_igg_status_value
is
None
:
virus_igg_status_value
=
""
if
virus_test_date_value
!=
""
:
if
virus_test_value
==
""
:
virus_test_value
=
"
N/A
"
if
virus_iga_status_value
==
""
:
virus_iga_status_value
=
"
N/A
"
if
virus_igg_status_value
==
""
:
virus_igg_status_value
=
"
N/A
"
result
[
virus_test_field
]
=
virus_test_value
result
[
virus_test_date_field
]
=
virus_test_date_value
result
[
virus_iga_status_field
]
=
virus_iga_status_value
result
[
virus_igg_status_field
]
=
virus_igg_status_value
return
result
@staticmethod
def
get_voucher_replacements
(
voucher
):
...
...
@@ -310,3 +377,14 @@ class MailTemplate(models.Model):
"
##C_HOURS##
"
:
str
(
voucher
.
hours
),
}
return
{}
def
virus_test_to_str
(
test
,
date
):
if
test
is
None
and
date
is
not
None
:
return
"
Inconclusive
"
if
test
is
None
:
return
""
if
test
:
return
"
Positive
"
else
:
return
"
Negative
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment