Skip to content
Snippets Groups Projects
Commit 94a1130b authored by Carlos Vega's avatar Carlos Vega
Browse files

consider excluded

parent 39bbc90d
No related branches found
No related tags found
1 merge request!178Feature/import data pdp
......@@ -130,27 +130,35 @@ def get_notifications(the_user):
if worker is not None:
study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0]
if study.notification_parameters.exceeded_visits_visible:
notifications.append(get_exceeded_visit_notifications_count(worker))
notifications.append(
get_exceeded_visit_notifications_count(worker))
if study.notification_parameters.unfinished_visits_visible:
notifications.append(get_visits_without_appointments_count(worker))
if study.notification_parameters.approaching_visits_without_appointments_visible:
notifications.append(get_approaching_visits_without_appointments_count(worker))
notifications.append(
get_approaching_visits_without_appointments_count(worker))
if study.notification_parameters.unfinished_appointments_visible:
notifications.append(get_unfinished_appointments_count(worker))
if study.notification_parameters.visits_with_missing_appointments_visible:
notifications.append(get_visits_with_missing_appointments_count(worker))
notifications.append(
get_visits_with_missing_appointments_count(worker))
if study.notification_parameters.subject_no_visits_visible:
notifications.append(get_subject_with_no_visit_notifications_count(worker))
notifications.append(
get_subject_with_no_visit_notifications_count(worker))
if study.notification_parameters.subject_voucher_expiry_visible:
notifications.append(get_subject_voucher_expiry_notifications_count(worker))
notifications.append(
get_subject_voucher_expiry_notifications_count(worker))
if study.notification_parameters.approaching_visits_for_mail_contact_visible:
notifications.append(get_approaching_visits_for_mail_contact_count(worker))
notifications.append(
get_approaching_visits_for_mail_contact_count(worker))
if study.notification_parameters.subject_require_contact_visible:
notifications.append(get_subjects_with_reminder_count(worker))
if study.notification_parameters.missing_redcap_subject_visible:
notifications.append(get_missing_redcap_subject_notification_count(worker))
notifications.append(
get_missing_redcap_subject_notification_count(worker))
if study.notification_parameters.inconsistent_redcap_subject_visible:
notifications.append(get_inconsistent_redcap_subject_notification_count(worker))
notifications.append(
get_inconsistent_redcap_subject_notification_count(worker))
for notification in notifications:
count += notification.count
......@@ -164,7 +172,7 @@ def get_subjects_with_no_visit(user):
resigned=False,
unfinished_visit_count=0,
default_location__in=get_filter_locations(user),
postponed=False,
postponed=False, excluded=False,
datetime_contact_reminder__isnull=True,
).exclude(vouchers__status=VOUCHER_STATUS_NEW)
return result
......@@ -240,10 +248,12 @@ def get_approaching_visits_for_mail_contact(user):
def get_exceeded_visits(user):
return Visit.objects.filter(datetime_end__lt=get_today_midnight_date(),
is_finished=False,
subject__default_location__in=get_filter_locations(user)
subject__default_location__in=get_filter_locations(
user)
).filter(
# by default any visit where visit number is bigger than 1
# or in case of first visit - visits that had some successful appointment
# or in case of first visit - visits that had some successful
# appointment
Q(visit_number__gt=1) | Q(appointment__status=Appointment.APPOINTMENT_STATUS_FINISHED)).filter(
# visits that have scheduled appointments should be excluded
~Q(appointment__status=Appointment.APPOINTMENT_STATUS_SCHEDULED)).order_by(
......@@ -325,5 +335,3 @@ def get_filter_locations(user):
return Location.objects.all()
else:
return worker.locations.all()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment