Class: StudyEngine::BeginAssessmentForm

Inherits:
Form
  • Object
show all
Defined in:
app/models/study_engine/begin_assessment_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Form

attributes, #attributes, #initialize, lookup_ancestors, model_name, new_from_model, #save, wrapped_class, wraps

Constructor Details

This class inherits a constructor from StudyEngine::Form

Instance Attribute Details

#restartObject

Returns the value of attribute restart.



11
12
13
# File 'app/models/study_engine/begin_assessment_form.rb', line 11

def restart
  @restart
end

Instance Method Details

#existing_assessmentObject



41
42
43
44
45
# File 'app/models/study_engine/begin_assessment_form.rb', line 41

def existing_assessment
  if study_id and new_record?
    @existing_assessment ||= Assessment.by_study_id(study_id).where(event: event).last
  end
end

#id_optionsObject



59
60
61
# File 'app/models/study_engine/begin_assessment_form.rb', line 59

def id_options
  ids_grouped_by_study_and_site[study_id_study.to_s + study_id_site.to_s]
end

#ids_grouped_by_study_and_siteObject



63
64
65
# File 'app/models/study_engine/begin_assessment_form.rb', line 63

def ids_grouped_by_study_and_site
  StudyID::Bank.ids_grouped_by_study_and_site
end

#method_appliedObject



37
38
39
# File 'app/models/study_engine/begin_assessment_form.rb', line 37

def method_applied
  @method_applied || "In-person"
end

#restartable?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/study_engine/begin_assessment_form.rb', line 47

def restartable?
  existing_assessment.try(:incomplete?)
end

#site_optionsObject



55
56
57
# File 'app/models/study_engine/begin_assessment_form.rb', line 55

def site_options
  coordinator.try(:site_id).present? ? [coordinator.site_id] : StudyID::Bank.sites
end

#study_idObject



33
34
35
# File 'app/models/study_engine/begin_assessment_form.rb', line 33

def study_id
  @study_id ||= StudyID.new
end

#study_id_idObject



29
30
31
# File 'app/models/study_engine/begin_assessment_form.rb', line 29

def study_id_id
  id_options.one? ? id_options.first : study_id.id
end

#study_id_siteObject



25
26
27
# File 'app/models/study_engine/begin_assessment_form.rb', line 25

def study_id_site
  site_options.one? ? site_options.first : study_id.site
end

#study_id_studyObject



21
22
23
# File 'app/models/study_engine/begin_assessment_form.rb', line 21

def study_id_study
  study_options.one? ? study_options.first : study_id.study
end

#study_optionsObject



51
52
53
# File 'app/models/study_engine/begin_assessment_form.rb', line 51

def study_options
  StudyID::Bank.studies_grouped_by_site.fetch(coordinator.try(:site_id)) { StudyID::Bank.studies }
end