-
Notifications
You must be signed in to change notification settings - Fork 35
Fi 900 - generic ui fields - proof of concept #470
Conversation
I think adding the labels and descriptions in the module.yml is a good way to start, but I'm worried about having to manage and update the prerequisites in multiple places. Right now we have a situation where they need to be edited in the ERBs, model and test code and its a bear to deal with. I'm not sure if its the best way to do it, but it might be nice to be able to add the label and description when defining the prerequisite so that it all happens in the same place. Otherwise I could see the prerequisites getting out of sync where maybe we forget to add a label in the config or have a label in the config, but never use it. I don't want perfect to get in the way of good, but I think longer term we might want to be able to centralize the management of prereqs. |
Could take care of this using ruby. By default have these just be defined completely in the sequences. And if you use in multiple sequences place in a common ruby file / module and include the common file. And/or you could have it be smart enough that only 1 sequence has to include the label/description portions, and in the other just require the parameter name it is good enough. But from a workflow perspective, maybe it does make sense to have a module file on the top where you define what global variables there are and what gets 'exported'? |
lib/app/sequence_base.rb
Outdated
|
||
instance_class.define_method requirement_setter_name do | ||
requirement_found = sequence_requirements.find { |requirement| requirement.name == requirement_name.to_s } | ||
return unless requirement_found.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this create the requirement if it isn't found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this so the rake tests pass, but it also works so if you don't have the requirement in the module file, you can still use the requirement. It just won't have a nice label or description.
55403e1
to
2265480
Compare
c25214d
to
a41b870
Compare
lib/app/models/testing_instance.rb
Outdated
# Get the conditions that determine whether the record already exists | ||
conditions = attributes.select { |key, _value| condition_attributes.include?(key) } | ||
|
||
SequenceRequirement.first_or_create(conditions, attributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think lines 287-290 are overcomplicating things.
SequenceRequirement.first_or_create(conditions, attributes) | |
SequenceRequirement.first_or_create({ name: requirement[:name], testing_instance: self }, attributes) |
lib/app/models/testing_instance.rb
Outdated
def get_sequence_requirement(requirement) | ||
return unless requirement&.dig(:name) | ||
|
||
attributes = { name: requirement[:name], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to set name: requirement[:name]
if we're then merging in requirement
.
@@ -37,6 +38,13 @@ def initialize(params) | |||
test_sets[test_set_key] = TestSet.new(test_set_key, test_set) | |||
end | |||
end | |||
if params[:sequence_requirements].present? | |||
@sequence_requirements = {}.tap do |requirements| | |||
params[:sequence_requirements].each do |requirement_key, texts| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this value called texts
? The same thing is done in TestingInstance
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed name to req_description
.
lib/app/models/testing_instance.rb
Outdated
|
||
def set_requirement_value(requirement_name, value) | ||
get_sequence_requirement(name: requirement_name.to_s, testing_instance: self).update(value: value) | ||
self.patient_id = value if requirement_name == 'patient_id' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope we're not keeping this in the final version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took this out. Forgot we have the setters now so I'm back to using that in the test_set_endpoint
Not a blocking issue, but I was very specific about how we ordered the fields that come up in the form. At least now, the order is not quite right -- though that may be because this is a mix of the old and new methods... perhaps if we went to all the new method they will show up in the interface in the order that they are put in the module file? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an improvement for sure. We've got a ways to go, but this moves it in the right direction and any issues I have with it can be addressed later.
This is adds a way for sequences to specify their own prerequisites without changing the the view erb files or changing the testinginstance data model. They would just "require" whatever prerequisites they need and the UI and database entry for it would be made by Inferno. I have it working with US Core tests. The patient id's field and device codes field are not in the default.erb file, but you can see them in the UI when running the tests. I also tested with my generated ukcore code, and confirmed it was working for the new fields there as well.
To require a new field, you'll first need to add it in the module yaml file. In the uscore_v3.1.0_module.yml file, you can see the sequence_requirements section. To add a new requirement, just add one with a label. Then in a sequence file, add that requirement.
Submitter:
Reviewer 1:
Name:
where appropriate, and accomplishes the task's purpose
Reviewer 2:
Name:
where appropriate, and accomplishes the task's purpose