The tests were expecting _include parameters to be formatted as _include=searchParam. Instead, they should be formatted as _include=SourceType:searchParam(:targetType).
The packaged Implementation Guide (package.tgz) was incorrect, which led to the generated tests being incorrect.
The fix
Patch the Implementation Guide
The Capability Statement required updates to include the correct _include syntax.
I wanted to ensure it was clear that we were doing a patch to the implementation guide and why we were doing the patch, so I did not change the Implementation Guide directly. Instead, I put the updated Capability Statement in a folder called "package_supersede". Any files in this folder will supersede files in the Implementation Guide (package.tgz).
There was a similar existing patch for r4_search-parameters. I moved this file into "package_supplement", because we do not want this file to supersede existing files, we just want it to add in missing information.
The load order determines what files "supersede" and what files "supplement".
IGResources accesses resources by grabbing the first matching resource it finds for a request. Files that are loaded first take precedence.
So the load order is:
package_supersede
package
package_supplement
Accessing search definitions for the _include parameters
For both test generation and in the tests themselves, the code needs to access search definitions for the _include parameters:
search_param_paths(include_param).each do |include_ref_path|
However, the dictionaries that use include_param as a key are generated from the searchParams in the Capability Statement, which do not include the sourceType. For example, in the Capability Statement, if the searchInclude is Basic:subject, the searchParam is just subject.
So we need to strip off the sourceType from include_param in order to access the search definitions.
There are multiple ways to do this, which include:
strip the sourceType from the include_param inline where necessary
create a helper function and call that where necessary
create a new generated variable to store the stripped parameter
I chose 3.
For 1, I wanted more error handling than inline code provided, and felt it was done enough times it deserved to be broken out.
For 2, the scopes of use are different: one is in the generator, and one is in the search itself. So figuring out where to place the helper function in a way that was logical for both scopes was challenging.
I don't love 3, but it allows the stripping to only occur in the generator, and treats this step as native / necessary rather than as a workaround.
For the reviewer
Please come up with a better name than include_param_search_param.
Testing Guidance
Delete the generated folder.
Call rake usdf:generate
Confirm there are no differences in the generated files (git diff)
Confirm that the testing metadata.yml files match the generated metadata.yml files:
Summary
The issue
The tests were expecting
_include
parameters to be formatted as_include=searchParam
. Instead, they should be formatted as_include=SourceType:searchParam(:targetType)
.The packaged Implementation Guide (package.tgz) was incorrect, which led to the generated tests being incorrect.
The fix
Patch the Implementation Guide
The Capability Statement required updates to include the correct
_include
syntax.I wanted to ensure it was clear that we were doing a patch to the implementation guide and why we were doing the patch, so I did not change the Implementation Guide directly. Instead, I put the updated Capability Statement in a folder called "package_supersede". Any files in this folder will supersede files in the Implementation Guide (package.tgz).
There was a similar existing patch for
r4_search-parameters
. I moved this file into "package_supplement", because we do not want this file to supersede existing files, we just want it to add in missing information.The load order determines what files "supersede" and what files "supplement".
IGResources
accesses resources by grabbing the first matching resource it finds for a request. Files that are loaded first take precedence.So the load order is:
Accessing search definitions for the
_include
parametersFor both test generation and in the tests themselves, the code needs to access search definitions for the
_include
parameters:lib/davinci_us_drug_formulary_test_kit/generator/include_search_test_generator.rb:
lib/davinci_us_drug_formulary_test_kit/search_test.rb
However, the dictionaries that use
include_param
as a key are generated from thesearchParams
in the Capability Statement, which do not include thesourceType
. For example, in the Capability Statement, if thesearchInclude
isBasic:subject
, thesearchParam
is justsubject
.So we need to strip off the
sourceType
frominclude_param
in order to access the search definitions.There are multiple ways to do this, which include:
sourceType
from theinclude_param
inline where necessaryI chose 3.
For 1, I wanted more error handling than inline code provided, and felt it was done enough times it deserved to be broken out.
For 2, the scopes of use are different: one is in the generator, and one is in the search itself. So figuring out where to place the helper function in a way that was logical for both scopes was challenging.
I don't love 3, but it allows the stripping to only occur in the generator, and treats this step as native / necessary rather than as a workaround.
For the reviewer
Please come up with a better name than
include_param_search_param
.Testing Guidance
Delete the
generated
folder. Callrake usdf:generate
Confirm there are no differences in the generated files (git diff
)Confirm that the testing metadata.yml files match the generated metadata.yml files:
Run
rake
to run the tests.