-
-
Save marten/9e659cd7629cd2e5d93e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
class Epd::FillOutSessionsController < EpdAreaController | |
def new | |
interaction = interactor :select_measurement, measurement_id: params[:measurement_id], | |
last_used_measurement_id: session[:last_used_measurement_id], | |
respondent_type: params[:respondent_type], | |
current_patient: @patient | |
@protocols = interaction.protocols | |
@measurement = interaction.measurement | |
@questionnaires = interaction.questionnaires | |
@respondent_type = interaction.respondent_type | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Interactors | |
class SelectMeasurement < Interactor | |
attribute :current_patient, Patient | |
attribute :measurement_id, Integer, default: nil | |
attribute :last_used_measurement_id, Integer, default: nil | |
attribute :respondent_type, String, default: nil | |
attr_reader :protocols | |
attr_reader :measurement | |
attr_reader :questionnaires | |
attr_reader :respondent_type | |
private | |
def authorized? | |
true | |
end | |
def execute | |
@protocols = query(:available_protocols_with_measurements) | |
@measurement = Measurement.find_by_id(measurement_id || last_used_measurement_id) | |
@measurement ||= @protocols.values.flatten.first if @protocols.values.flatten.count == 1 | |
if @measurement | |
@questionnaires = query :available_questionnaires, measurement: @measurement, | |
current_patient: current_patient, | |
respondent_type: respondent_type | |
@respondent_type = @questionnaires.current_respondent_type | |
end | |
self | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment