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
3503a0aa
Commit
3503a0aa
authored
4 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
show inconclusive results in the study subject form
parent
3ea0403f
No related branches found
No related tags found
1 merge request
!250
Virus visit column changes
Pipeline
#25896
passed
4 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/forms/study_subject_forms.py
+36
-32
36 additions, 32 deletions
smash/web/forms/study_subject_forms.py
with
36 additions
and
32 deletions
smash/web/forms/study_subject_forms.py
+
36
−
32
View file @
3503a0aa
import
logging
import
re
from
distutils.util
import
strtobool
from
django
import
forms
from
django.forms
import
ModelForm
from
web.models
import
ConfigurationItem
from
distutils.util
import
strtobool
from
web.forms.forms
import
DATETIMEPICKER_DATE_ATTRS
,
get_worker_from_args
from
web.models
import
ConfigurationItem
from
web.models
import
StudySubject
,
Study
,
StudyColumns
,
VoucherType
,
Worker
from
web.models.constants
import
SCREENING_NUMBER_PREFIXES_FOR_TYPE
,
VISIT_SHOW_VISIT_NUMBER_FROM_ZERO
from
web.models.worker_study_role
import
WORKER_HEALTH_PARTNER
...
...
@@ -16,17 +15,20 @@ logger = logging.getLogger(__name__)
class
StudySubjectForm
(
ModelForm
):
datetime_contact_reminder
=
forms
.
DateTimeField
(
label
=
"
Contact on
"
,
widget
=
forms
.
DateTimeInput
(
DATETIMEPICKER_DATE_ATTRS
),
required
=
False
)
datetime_contact_reminder
=
forms
.
DateTimeField
(
label
=
"
Contact on
"
,
widget
=
forms
.
DateTimeInput
(
DATETIMEPICKER_DATE_ATTRS
),
required
=
False
)
referral_letter
=
forms
.
FileField
(
label
=
'
Referral letter
'
,
widget
=
SecuredFileWidget
(),
required
=
False
)
voucher_types
=
forms
.
ModelMultipleChoiceField
(
required
=
False
,
widget
=
forms
.
CheckboxSelectMultiple
,
queryset
=
VoucherType
.
objects
.
all
())
voucher_types
=
forms
.
ModelMultipleChoiceField
(
required
=
False
,
widget
=
forms
.
CheckboxSelectMultiple
,
queryset
=
VoucherType
.
objects
.
all
())
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
StudySubjectForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'
health_partner
'
].
queryset
=
Worker
.
get_workers_by_worker_type
(
WORKER_HEALTH_PARTNER
)
visit_from_zero
=
ConfigurationItem
.
objects
.
get
(
type
=
VISIT_SHOW_VISIT_NUMBER_FROM_ZERO
).
value
#True values are y, yes, t, true, on and 1; false values are n, no, f, false, off and 0.
#
True values are y, yes, t, true, on and 1; false values are n, no, f, false, off and 0.
if
strtobool
(
visit_from_zero
):
virus_visit_numbers
=
range
(
0
,
5
)
for
one_based_idx
,
virus_visit_number
in
enumerate
(
virus_visit_numbers
,
1
):
...
...
@@ -36,9 +38,7 @@ class StudySubjectForm(ModelForm):
self
.
fields
[
date_field
].
label
=
'
Visit {} RT-PCR date
'
.
format
(
virus_visit_number
)
class
StudySubjectAddForm
(
StudySubjectForm
):
class
Meta
:
model
=
StudySubject
fields
=
'
__all__
'
...
...
@@ -49,16 +49,8 @@ class StudySubjectAddForm(StudySubjectForm):
self
.
study
=
get_study_from_args
(
kwargs
)
super
(
StudySubjectAddForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'
virus_test_1
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_2
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_3
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_4
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_5
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_1_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_2_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_3_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_4_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_5_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
for
visit_number
in
range
(
1
,
6
):
disable_virus_test_field
(
self
,
visit_number
)
prepare_study_subject_fields
(
fields
=
self
.
fields
,
study
=
self
.
study
)
...
...
@@ -117,7 +109,6 @@ def get_new_screening_number(screening_number_prefix):
class
StudySubjectDetailForm
(
StudySubjectForm
):
class
Meta
:
model
=
StudySubject
fields
=
'
__all__
'
...
...
@@ -152,17 +143,9 @@ class StudySubjectEditForm(StudySubjectForm):
self
.
fields
[
'
resigned
'
].
disabled
=
was_resigned
self
.
fields
[
'
endpoint_reached
'
].
disabled
=
endpoint_was_reached
self
.
fields
[
'
virus_test_1
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_2
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_3
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_4
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_5
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_1_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_2_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_3_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_4_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
'
virus_test_5_updated
'
].
widget
.
attrs
[
'
readonly
'
]
=
True
for
visit_number
in
range
(
1
,
6
):
disable_virus_test_field
(
self
,
visit_number
)
self
.
update_virus_inconclusive_data
(
visit_number
)
prepare_study_subject_fields
(
fields
=
self
.
fields
,
study
=
self
.
study
)
...
...
@@ -171,11 +154,31 @@ class StudySubjectEditForm(StudySubjectForm):
validate_subject_mpower_number
(
self
,
self
.
cleaned_data
)
validate_subject_resign_reason
(
self
,
self
.
cleaned_data
)
def
update_virus_inconclusive_data
(
self
,
visit_number
):
test_result_column_name
=
'
virus_test_{}
'
.
format
(
visit_number
)
test_date_column_name
=
'
virus_test_{}_updated
'
.
format
(
visit_number
)
self
.
fields
[
test_result_column_name
].
widget
.
choices
.
append
((
"
Inc
"
,
'
Inconclusive
'
))
instance
=
getattr
(
self
,
'
instance
'
,
None
)
if
instance
and
instance
.
id
:
test_result
=
getattr
(
instance
,
test_result_column_name
)
test_date
=
getattr
(
instance
,
test_date_column_name
)
if
test_result
is
None
and
test_date
is
not
None
:
self
.
initial
[
test_result_column_name
]
=
"
Inc
"
class
Meta
:
model
=
StudySubject
fields
=
'
__all__
'
def
disable_virus_test_field
(
self
,
visit_number
):
test_result_column_name
=
'
virus_test_{}
'
.
format
(
visit_number
)
test_date_column_name
=
'
virus_test_{}_updated
'
.
format
(
visit_number
)
self
.
fields
[
test_result_column_name
].
widget
.
attrs
[
'
readonly
'
]
=
True
self
.
fields
[
test_result_column_name
].
widget
.
attrs
[
'
disabled
'
]
=
True
self
.
fields
[
test_date_column_name
].
widget
.
attrs
[
'
readonly
'
]
=
True
def
get_study_from_args
(
kwargs
):
study
=
kwargs
.
pop
(
'
study
'
,
None
)
if
study
is
None
:
...
...
@@ -251,7 +254,8 @@ def validate_subject_nd_number(self, cleaned_data):
if
subjects_from_db
:
if
subjects_from_db
[
0
].
screening_number
!=
cleaned_data
.
get
(
'
screening_number
'
,
''
):
self
.
add_error
(
'
nd_number
'
,
"
ND number already in use
"
)
#else: #empty nd_number is valid
# else: #empty nd_number is valid
def
validate_subject_resign_reason
(
self
,
cleaned_data
):
if
self
.
study
.
columns
.
resigned
and
self
.
study
.
columns
.
resign_reason
:
...
...
This diff is collapsed.
Click to expand it.
Piotr Gawron
@piotr.gawron
mentioned in issue
#331 (closed)
·
4 years ago
mentioned in issue
#331 (closed)
mentioned in issue #331
Toggle commit list
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