from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random #from otree_tools.models import fields as tool_models import itertools import json import intervention.bcra class Constants(BaseConstants): name_in_url = 'Questionnaire' players_per_group = None surveys = ['1', '2', '3'] num_rounds = 1 StandardChoices=[ [1, 'Disagree strongly'], [2, 'Disagree moderately'], [3, 'Disagree a little'], [4, 'Neither agree nor disagree'], [5, 'Agree a little'], [6, 'Agree moderately'], [7, 'Agree strongly'], ] class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): round_numbers = list(range(1, Constants.num_rounds + 1)) random.shuffle(round_numbers) p.participant.vars['surveys_rounds'] = dict(zip(Constants.surveys, round_numbers)) p.participant.vars['num_rounds'] = Constants.num_rounds class Group(BaseGroup): pass class Player(BasePlayer): signature = models.StringField(blank=True, initial=None) risk_calc_q1 = models.IntegerField( label="Do you have a medical history of any breast cancer or of ductal carcinoma in situ (DCIS) or lobular " "carcinoma in situ (LCIS) or have you received previous radiation therapy to the chest for treatment of " "Hodgkin lymphoma?", choices=[ [1, 'Yes'], [2, 'No or Unknown'] ] ) risk_calc_q2 = models.IntegerField( label="Do you have a mutation in either the BRCA1 or BRCA2 gene, or a diagnosis of a genetic syndrome that " "may be associated with elevated risk of breast cancer?", choices=[ [1, 'Yes'], [2, 'No'], [3, 'Unknown'] ] ) risk_calc_q3 = models.FloatField( label="What is your age?", min=35, max=100, blank=True, initial=None ) risk_calc_q4 = models.IntegerField( label="Which race do you most identify with?", choices=[ [1, 'White or Caucasian'], [2, 'Black or African American'], [3, 'Hispanic or Latino and born in the United States'], [4, 'American Indian or Alaska Native'], [5, 'Hispanic or Latino and born outside the United States'], [6, 'Chinese'], [7, 'Japanese'], [8, 'Filipino'], [9, 'Hawaiian'], [10, 'Other Pacific Islander'], [11, 'Other Asian'] ] ) risk_calc_q5 = models.IntegerField( label="Have you ever had a breast biopsy with a benign/harmless (not cancer) diagnosis?", choices=[ [1, 'Yes'], [2, 'No or Unknown'] ] ) risk_calc_q6 = models.IntegerField( label="How many breast biopsies with a benign diagnosis have you had?", choices=[ [1, '1'], [2, '2 or more'], [0, 'Unknown'] ], initial=0 ) risk_calc_q7 = models.IntegerField( label="Have you ever had a breast biopsy with atypical hyperplasia?", choices=[ [1, 'Yes'], [2, 'No '], [0, 'Unknown'] ], initial=0 ) risk_calc_q8 = models.IntegerField( label="To the best of your memory, what was your age at the time of your first menstrual period?", choices=[ [2, '7 to 11 (including 11)'], [1, '11 to 14 (excluding 11 and including 14)'], [0, '14 or older (excluding 14)'] ], initial = 2 ) risk_calc_q9 = models.IntegerField( label="Have you given birth to any child?", choices=[ [1, 'Yes'], [2, 'No'] ] ) risk_calc_q10 = models.IntegerField( label="What was your age when you gave birth to your first child?", choices=[ [0, '19 or younger'], [1, '20-24'], [2, '25-29'], [3, '30 or older'] ], initial=2 ) risk_calc_q11 = models.IntegerField( label="How many of your first-degree relatives (mother, sisters, daughters) have had breast cancer?", choices=[ [0, 'None or Unknown'], [1, 'One'], [2, 'More than one'], ], initial=0 ) confirmation_q1 = models.IntegerField( label="What is approximately the 5 year relative survival rate of stage 0 and stage 1 breast cancer?" " (in percents)", min=0, max=100, blank=True, initial=None ) confirmation_q2 = models.IntegerField( label="What is approximately the 5 year relative survival rate of stage 4 breast cancer? (in percents)", min=0, max=100, blank=True, initial=None ) confirmation_q3 = models.IntegerField( label="How long does a mammogram typically take? (in minutes)", min=0, max=500, blank=True, initial=None ) confirmation_q5 = models.IntegerField( label="On average, one out of how many women in the US will develop breast cancer in their life times?", choices=[2, 4, 6, 8, 10] ) confirmation_q4 = models.IntegerField( label="Is annual mammogram usually covered by health insurance?", choices=[ [0, 'No'], [1, 'Yes'] ] ) brisk_five = models.FloatField() brisk_life = models.FloatField() page_pass_time = models.FloatField() prolific_id = models.StringField(default=str(" "))