Skip to content
Snippets Groups Projects
Commit a6b08f28 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

hardcoded SUBJECT_TYPE_CHOICES consts removed

parent e6465a12
No related branches found
No related tags found
1 merge request!305Resolve "Allow for adding modifying types of subjects"
Pipeline #38318 failed
...@@ -10,10 +10,11 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "smash.settings") ...@@ -10,10 +10,11 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "smash.settings")
django.setup() django.setup()
from django.contrib.auth.models import User from django.contrib.auth.models import User
# models (please add in both lines) # models (please add in both lines)
from web.models import StudySubject, Availability, Visit, Appointment, AppointmentType, AppointmentTypeLink, Study, Subject, Worker, Location, Language, Country, WorkerStudyRole, Item, FlyingTeam, Room, MailTemplate from web.models import StudySubject, Availability, Visit, Appointment, AppointmentType, AppointmentTypeLink, Study, \
Subject, Worker, Location, Language, Country, WorkerStudyRole, Item, FlyingTeam, Room, MailTemplate, SubjectType
from smash.local_settings import MEDIA_ROOT from smash.local_settings import MEDIA_ROOT
from web.models.constants import SEX_CHOICES_MALE, SEX_CHOICES_FEMALE, SUBJECT_TYPE_CHOICES_CONTROL, SUBJECT_TYPE_CHOICES_PATIENT, \ from web.models.constants import SEX_CHOICES_MALE, SEX_CHOICES_FEMALE, COUNTRY_AFGHANISTAN_ID, GLOBAL_STUDY_ID, \
COUNTRY_AFGHANISTAN_ID, GLOBAL_STUDY_ID, DEFAULT_LOCALE_NAME DEFAULT_LOCALE_NAME
from web.models.constants import MAIL_TEMPLATE_CONTEXT_APPOINTMENT, MAIL_TEMPLATE_CONTEXT_VISIT, \ from web.models.constants import MAIL_TEMPLATE_CONTEXT_APPOINTMENT, MAIL_TEMPLATE_CONTEXT_VISIT, \
MAIL_TEMPLATE_CONTEXT_SUBJECT, MAIL_TEMPLATE_CONTEXT_VOUCHER MAIL_TEMPLATE_CONTEXT_SUBJECT, MAIL_TEMPLATE_CONTEXT_VOUCHER
from web.models.worker_study_role import ROLE_CHOICES_PROJECT_MANAGER, ROLE_CHOICES_SECRETARY, ROLE_CHOICES_DOCTOR, \ from web.models.worker_study_role import ROLE_CHOICES_PROJECT_MANAGER, ROLE_CHOICES_SECRETARY, ROLE_CHOICES_DOCTOR, \
...@@ -416,8 +417,8 @@ class smashProvider(BaseProvider): ...@@ -416,8 +417,8 @@ class smashProvider(BaseProvider):
study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0] study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0]
if type is None: if type is None:
type = choice([SUBJECT_TYPE_CHOICES_CONTROL, type = choice([SubjectType.objects.all().first(),
SUBJECT_TYPE_CHOICES_PATIENT], 1, p=[0.2, 0.8]) SubjectType.objects.all().last()], 1, p=[0.2, 0.8])
type = type[0] type = type[0]
if default_location is None: if default_location is None:
......
...@@ -18,7 +18,7 @@ import re ...@@ -18,7 +18,7 @@ import re
from operator import itemgetter from operator import itemgetter
from collections import OrderedDict from collections import OrderedDict
from django.contrib.auth.models import User from django.contrib.auth.models import User
from web.models.constants import VOUCHER_STATUS_IN_USE, SUBJECT_TYPE_CHOICES_PATIENT, GLOBAL_STUDY_ID, SEX_CHOICES_MALE, SEX_CHOICES_FEMALE from web.models.constants import VOUCHER_STATUS_IN_USE, GLOBAL_STUDY_ID, SEX_CHOICES_MALE, SEX_CHOICES_FEMALE
from web.algorithm import VerhoeffAlgorithm, LuhnAlgorithm from web.algorithm import VerhoeffAlgorithm, LuhnAlgorithm
from web.utils import is_valid_social_security_number from web.utils import is_valid_social_security_number
...@@ -501,7 +501,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types, lcsb_w ...@@ -501,7 +501,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types, lcsb_w
'nd_number': nd_number, 'nd_number': nd_number,
'resigned': row['RESIGNED'], 'resigned': row['RESIGNED'],
'resign_reason': row['REASON'], 'resign_reason': row['REASON'],
'type': SUBJECT_TYPE_CHOICES_PATIENT, 'type': StudySubject.objects.all().first(),
'excluded': row['EXCLUDED'], 'excluded': row['EXCLUDED'],
'exclude_reason': row['REASON.1'], 'exclude_reason': row['REASON.1'],
'comments': row['COMMENT'], 'comments': row['COMMENT'],
......
...@@ -24,10 +24,6 @@ VALUE_TYPE_CHOICES = ( ...@@ -24,10 +24,6 @@ VALUE_TYPE_CHOICES = (
(VALUE_TYPE_TEXT, 'Text'), (VALUE_TYPE_TEXT, 'Text'),
) )
SUBJECT_TYPE_CHOICES_CONTROL = 'C'
SUBJECT_TYPE_CHOICES_PATIENT = 'P'
APPOINTMENT_TYPE_DEFAULT_COLOR = '#cfc600' APPOINTMENT_TYPE_DEFAULT_COLOR = '#cfc600'
APPOINTMENT_TYPE_DEFAULT_FONT_COLOR = '#00000' APPOINTMENT_TYPE_DEFAULT_FONT_COLOR = '#00000'
......
...@@ -7,7 +7,7 @@ from django.db import transaction ...@@ -7,7 +7,7 @@ from django.db import transaction
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver from django.dispatch import receiver
from web.models.constants import BOOL_CHOICES, SUBJECT_TYPE_CHOICES_CONTROL from web.models.constants import BOOL_CHOICES
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -84,11 +84,8 @@ class Visit(models.Model): ...@@ -84,11 +84,8 @@ class Visit(models.Model):
study = self.subject.study study = self.subject.study
if self.subject.type == SUBJECT_TYPE_CHOICES_CONTROL: args = {self.subject.type.follow_up_delta_units: self.subject.type.follow_up_delta_time}
args = {study.default_delta_time_for_follow_up_units: study.default_delta_time_for_control_follow_up}
else:
args = {study.default_delta_time_for_follow_up_units: study.default_delta_time_for_patient_follow_up}
time_to_next_visit = relativedelta(**args) * (follow_up_number - 1) #calculated from first visit time_to_next_visit = relativedelta(**args) * (follow_up_number - 1) #calculated from first visit
logger.warning('new visit: {} {} {}'.format(args, relativedelta(**args), time_to_next_visit)) logger.warning('new visit: {} {} {}'.format(args, relativedelta(**args), time_to_next_visit))
......
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