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
54353f21
Commit
54353f21
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
consider excluded in the mark_as_finished method
parent
94a1130b
No related branches found
No related tags found
1 merge request
!178
Feature/import data pdp
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/models/visit.py
+15
-6
15 additions, 6 deletions
smash/web/models/visit.py
with
15 additions
and
6 deletions
smash/web/models/visit.py
+
15
−
6
View file @
54353f21
...
@@ -9,6 +9,7 @@ from web.models.constants import BOOL_CHOICES, SUBJECT_TYPE_CHOICES_CONTROL
...
@@ -9,6 +9,7 @@ from web.models.constants import BOOL_CHOICES, SUBJECT_TYPE_CHOICES_CONTROL
class
Visit
(
models
.
Model
):
class
Visit
(
models
.
Model
):
class
Meta
:
class
Meta
:
app_label
=
'
web
'
app_label
=
'
web
'
...
@@ -35,7 +36,8 @@ class Visit(models.Model):
...
@@ -35,7 +36,8 @@ class Visit(models.Model):
blank
=
True
,
blank
=
True
,
)
)
# this value is automatically computed by signal handled by update_visit_number method
# this value is automatically computed by signal handled by
# update_visit_number method
visit_number
=
models
.
IntegerField
(
visit_number
=
models
.
IntegerField
(
verbose_name
=
'
Visit number
'
,
verbose_name
=
'
Visit number
'
,
default
=
1
default
=
1
...
@@ -56,23 +58,29 @@ class Visit(models.Model):
...
@@ -56,23 +58,29 @@ class Visit(models.Model):
create_follow_up
=
False
create_follow_up
=
False
elif
self
.
subject
.
resigned
:
elif
self
.
subject
.
resigned
:
create_follow_up
=
False
create_follow_up
=
False
elif
self
.
subject
.
excluded
:
create_follow_up
=
False
elif
not
self
.
subject
.
study
.
auto_create_follow_up
:
elif
not
self
.
subject
.
study
.
auto_create_follow_up
:
create_follow_up
=
False
create_follow_up
=
False
if
create_follow_up
:
if
create_follow_up
:
visit_started
=
Visit
.
objects
.
filter
(
subject
=
self
.
subject
).
filter
(
visit_number
=
1
)[
0
].
datetime_begin
visit_started
=
Visit
.
objects
.
filter
(
follow_up_number
=
Visit
.
objects
.
filter
(
subject
=
self
.
subject
).
count
()
+
1
subject
=
self
.
subject
).
filter
(
visit_number
=
1
)[
0
].
datetime_begin
follow_up_number
=
Visit
.
objects
.
filter
(
subject
=
self
.
subject
).
count
()
+
1
delta_days
=
365
delta_days
=
365
if
self
.
subject
.
type
==
SUBJECT_TYPE_CHOICES_CONTROL
:
if
self
.
subject
.
type
==
SUBJECT_TYPE_CHOICES_CONTROL
:
delta_days
=
365
*
3
+
366
delta_days
=
365
*
3
+
366
time_to_next_visit
=
datetime
.
timedelta
(
days
=
delta_days
*
(
follow_up_number
-
1
))
time_to_next_visit
=
datetime
.
timedelta
(
days
=
delta_days
*
(
follow_up_number
-
1
))
Visit
.
objects
.
create
(
Visit
.
objects
.
create
(
subject
=
self
.
subject
,
subject
=
self
.
subject
,
datetime_begin
=
visit_started
+
time_to_next_visit
,
datetime_begin
=
visit_started
+
time_to_next_visit
,
datetime_end
=
visit_started
+
time_to_next_visit
+
datetime
.
timedelta
(
days
=
93
)
datetime_end
=
visit_started
+
time_to_next_visit
+
datetime
.
timedelta
(
days
=
93
)
)
)
...
@@ -80,7 +88,8 @@ class Visit(models.Model):
...
@@ -80,7 +88,8 @@ class Visit(models.Model):
def
update_visit_number
(
sender
,
instance
,
**
kwargs
):
def
update_visit_number
(
sender
,
instance
,
**
kwargs
):
visit
=
instance
visit
=
instance
if
visit
.
subject
is
not
None
:
if
visit
.
subject
is
not
None
:
count
=
Visit
.
objects
.
filter
(
subject
=
visit
.
subject
).
filter
(
datetime_begin__lte
=
visit
.
datetime_begin
).
count
()
count
=
Visit
.
objects
.
filter
(
subject
=
visit
.
subject
).
filter
(
datetime_begin__lte
=
visit
.
datetime_begin
).
count
()
if
count
!=
visit
.
visit_number
:
if
count
!=
visit
.
visit_number
:
visit
.
visit_number
=
count
visit
.
visit_number
=
count
visit
.
save
()
visit
.
save
()
...
...
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