This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
Fi 898 generic generator from capability statement #477
Merged
radamson
merged 26 commits into
development
from
fi-898-generic-generator-from-capability-statement
Aug 7, 2020
Merged
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
7e4c985
saving some progress
c751a7f
more progress
f1806c2
add interaction test
cfdf984
fix some interaction tests
plump-pinniped 4621846
some fixes
plump-pinniped 768698a
more fixes
plump-pinniped 66223a3
get correct type for parameters
plump-pinniped 87a3e75
add requirements to module file for generic ui
plump-pinniped 2b19c8e
nil safety for multiple_and_expecation and multiple_or_expectation
radamson d487170
break out search combos and add some nil safety
radamson 7a6efbb
move validation tests after read and search tests
radamson 636fc73
Update generator/generic/generic_generator.rb
radamson 467b335
rubocop and fix spacing
radamson e421cda
use capabilities attr_accessor instead of passing it around
radamson e045686
fix search combo change and change definitions module
plump-pinniped f8221c0
rename generic_utilities to sequence_utilities
radamson 755a88c
use map in basic_searches_from_capability_statement
radamson 31020e7
catch json parsing error
e9d87d4
update generator to test against correct profile
radamson 84fab52
save resources with profile reference
radamson 40c9969
us path when making sequence class name
plump-pinniped e946a81
rename ProfileDefinitions to include module path
radamson ff99f47
Definitions -> ProfileDefinitions to match what previously existed
radamson f3240fc
fix indentation
radamson 1c4f538
add logger line for json parsing error and fix profiledefinition modu…
467895f
fix rubocop spacing issue
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../test_metadata' | ||
|
||
module Inferno | ||
module Generator | ||
module InteractionTest | ||
def create_interaction_tests(metadata) | ||
metadata.interactions.each do |interaction| | ||
next if ['read', 'search-type'].include? interaction[:code] # already have tests for | ||
next if ['create', 'update', 'patch', 'delete', 'history-type'].include? interaction[:code] # not currently supported | ||
|
||
interaction[:code] = 'history' if interaction[:code] == 'history-instance' # how the history interaction is called already | ||
|
||
interaction_test = TestMetadata.new( | ||
title: "Server supports the #{metadata.resource_type} #{interaction[:code]} interaction", | ||
key: "resource_#{interaction[:code].gsub('-', '_').downcase}".to_sym, | ||
description: "This test will verify that #{metadata.resource_type} #{interaction[:code]} interactions are supported by the server.", | ||
optional: interaction[:expectation] != 'SHALL' | ||
) | ||
|
||
validate_reply_args = [ | ||
'@resource_found', | ||
"versioned_resource_class('#{metadata.resource_type}')" | ||
] | ||
validate_reply_args_string = validate_reply_args.join(', ') | ||
|
||
interaction_test.code = %( | ||
skip 'No resource found from Read test' unless @resource_found.present? | ||
validate_#{interaction[:code].gsub('-', '_')}_reply(#{validate_reply_args_string}) | ||
) | ||
metadata.add_test(interaction_test) | ||
end | ||
end | ||
end | ||
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../test_metadata' | ||
|
||
module Inferno | ||
module Generator | ||
module SearchTest | ||
def create_search_tests(metadata) | ||
metadata.searches.each do |search| | ||
search_test = TestMetadata.new( | ||
title: "Server returns expected results from #{metadata.resource_type} search by #{search[:parameters].join('+')}", | ||
key: :"search_by_#{search[:parameters].map(&:underscore).join('_')}", | ||
description: "This test will verify that #{metadata.resource_type} resources can be searched from the server.", | ||
optional: search[:expectation] != 'SHALL' | ||
) | ||
|
||
search_parameter_assignments = search[:parameters].map do |parameter| | ||
param_metadata = metadata.search_parameter_metadata.find { |parameter_metadata| parameter_metadata.code == parameter } | ||
path = param_metadata | ||
.expression | ||
.gsub(/(?<!\w)class(?!\w)/, 'local_class') | ||
.split('.') | ||
.drop(1) | ||
.join('.') | ||
|
||
# handle some fhir path stuff. Remove this once fhir path server is added | ||
path = path.gsub(/.where\((.*)/, '') | ||
as_type = path.scan(/.as\((.*?)\)/).flatten.first | ||
path = path.gsub(/.as\((.*?)\)/, capitalize_first_letter(as_type)) if as_type.present? | ||
|
||
"#{search_param_value_name(parameter)} = find_search_parameter_value_from_resource(@resource_found, '#{path}')" | ||
end | ||
search_test.code = %( | ||
skip 'No resource found from Read test' unless @resource_found.present? | ||
#{search_parameter_assignments.join("\n")} | ||
search_parameters = { | ||
#{search[:parameters].map { |parameter| "'#{parameter}': #{search_param_value_name(parameter)}" }.join(",\n")} | ||
} | ||
|
||
reply = get_resource_by_params(versioned_resource_class('#{metadata.resource_type}'), search_parameters) | ||
validate_search_reply(versioned_resource_class('#{metadata.resource_type}'), reply, search_parameters) | ||
) | ||
metadata.add_test(search_test) | ||
end | ||
end | ||
|
||
def search_param_value_name(parameter) | ||
parameter.gsub!(/^[\W_]+|[\W_]+$"/, '') # remove non-character elements from beginning and end of name | ||
"#{parameter.gsub('-', '_')}_val" | ||
end | ||
|
||
def capitalize_first_letter(str) | ||
str.slice(0).capitalize + str.slice(1..-1) | ||
end | ||
end | ||
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module Inferno | ||
module ProfileDefinitions | ||
class <%= class_name %> | ||
SEARCH_PARAMETERS = <%= search_parameters %>.freeze | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 probably log something here.
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.
👍