Module: Inferno::DSL::InputOutputHandling

Defined in:
lib/inferno/dsl/input_output_handling.rb

Instance Method Summary collapse

Instance Method Details

#input(identifier, *other_identifiers, **input_params) ⇒ void

This method returns an undefined value.

Define inputs

Examples:

input :patient_id, title: 'Patient ID', description: 'The ID of the patient being searched for',
                  default: 'default_patient_id'
input :textarea, title: 'Textarea Input Example', type: 'textarea', optional: true

Parameters:

  • identifier (Symbol)

    identifier for the input

  • other_identifiers (Symbol)

    array of symbols if specifying multiple inputs

  • input_params (Hash)

    options for input such as type, description, or title

  • options (Hash)

    a customizable set of options

Options Hash (**input_params):

  • :title (String)

    Human readable title for input

  • :description (String)

    Description for the input

  • :type (String)

    text | textarea | radio

  • :default (String)

    The default value for the input

  • :optional (Boolean)

    Set to true to not require input for test execution

  • :options (Hash)

    Possible input option formats based on input type



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/inferno/dsl/input_output_handling.rb', line 22

def input(identifier, *other_identifiers, **input_params)
  if other_identifiers.present?
    [identifier, *other_identifiers].compact.each do |input_identifier|
      inputs << input_identifier
      config.add_input(input_identifier)
      children
        .reject { |child| child.inputs.include? input_identifier }
        .each do |child|
          child.input(input_identifier)
        end
    end
  else
    inputs << identifier
    config.add_input(identifier, input_params)
    children
      .reject { |child| child.inputs.include? identifier }
      .each do |child|
        child.input(identifier, **input_params)
      end
  end
end

#input_order(*new_input_order) ⇒ Array<String, Symbol>

Define a particular order for inputs to be presented in the API/UI

Examples:

group do
  input :input1, :input2, :input3
  input_order :input3, :input2, :input1
end

Parameters:

  • new_input_order (Array<String,Symbol>)

Returns:

  • (Array<String, Symbol>)


114
115
116
117
118
# File 'lib/inferno/dsl/input_output_handling.rb', line 114

def input_order(*new_input_order)
  return @input_order = new_input_order if new_input_order.present?

  @input_order ||= []
end

#output(identifier, *other_identifiers, **output_definition) ⇒ void

This method returns an undefined value.

Define outputs

Examples:

output :patient_id, :condition_id, :observation_id
output :oauth_credentials, type: 'oauth_credentials'

Parameters:

  • identifier (Symbol)

    identifier for the output

  • other_identifiers (Symbol)

    array of symbols if specifying multiple outputs

  • output_definition (Hash)

    options for output

Options Hash (**output_definition):

  • :type (String)

    text | textarea | oauth_credentials



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/inferno/dsl/input_output_handling.rb', line 55

def output(identifier, *other_identifiers, **output_definition)
  if other_identifiers.present?
    [identifier, *other_identifiers].compact.each do |output_identifier|
      outputs << output_identifier
      config.add_output(output_identifier)
      children
        .reject { |child| child.outputs.include? output_identifier }
        .each do |child|
          child.output(output_identifier)
        end
    end
  else
    outputs << identifier
    config.add_output(identifier, output_definition)
    children
      .reject { |child| child.outputs.include? identifier }
      .each do |child|
        child.output(identifier, **output_definition)
      end
  end
end