Class: StudyType

Inherits:
ApplicationRecord show all
Extended by:
Attributable::Association::Target
Defined in:
app/models/study_type.rb

Overview

Note:

Study::Metadata#study_type_valid? has hard-coded validation to prevent the ‘Not specified’ study type from being used. This should probably be updated to use the #valid_for_creation flag. I’m also not sure of having ‘Not specified’ be a specific database entry, although it has been assigned to several historic studies so does at least allow a not_nil constraint.

On Study creation the user selects a StudyType from a drop down list of pre-registered study types.

This information is exposed:

  • In the warehouses, where it may be used by customers, NPG, or bioinformaticians

  • Via the V1 API. (Not aware of any uses here, but there may be)

  • As <STUDY_TYPE existing_study_type=“…” /> during study accessioning with the EBI

Defined Under Namespace

Modules: Associations

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Attributable::Association::Target

default, extended, for_select_association

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Attribute Details

#vaild_typeBoolean

Returns Indicates the study type is recognised by the EBI. If false the accessioned study will contain <STUDY_TYPE existing_study_type=“Other” new_study_type=“<study_type.name>”/> instead of <STUDY_TYPE existing_study_type=“<study_type.name>”/>.

Returns:

  • (Boolean)

    Indicates the study type is recognised by the EBI. If false the accessioned study will contain <STUDY_TYPE existing_study_type=“Other” new_study_type=“<study_type.name>”/> instead of <STUDY_TYPE existing_study_type=“<study_type.name>”/>



28
# File 'app/models/study_type.rb', line 28

has_many :study

#valid_for_creationBoolean

Returns Indicates a study can be created with this option (determines if it appears in the dropdown).

Returns:

  • (Boolean)

    Indicates a study can be created with this option (determines if it appears in the dropdown)



28
# File 'app/models/study_type.rb', line 28

has_many :study

Class Method Details

.include?(studytype_name) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
# File 'app/models/study_type.rb', line 39

def self.include?(studytype_name)
  study_type = StudyType.find_by(name: studytype_name)
  return study_type.valid_type unless study_type.nil?

  false
end