Module: DaVinciPlanNetTestKit::SearchTest

Extended by:
Forwardable
Includes:
DateSearchValidation, FHIRResourceNavigation
Included in:
DaVinciPlanNetV110::EndpointForwardChainOrganizationAddressSearchTest, DaVinciPlanNetV110::EndpointForwardChainOrganizationNameSearchTest, DaVinciPlanNetV110::EndpointForwardChainOrganizationPartofSearchTest, DaVinciPlanNetV110::EndpointForwardChainOrganizationTypeSearchTest, DaVinciPlanNetV110::EndpointIdSearchTest, DaVinciPlanNetV110::EndpointIncludeEndpointOrganizationSearchTest, DaVinciPlanNetV110::EndpointLastupdatedSearchTest, DaVinciPlanNetV110::EndpointNoParamsSearchTest, DaVinciPlanNetV110::EndpointOrganizationSearchTest, DaVinciPlanNetV110::HealthcareServiceCombinationListSpecialtyCoveredByNetworkSearchTest, DaVinciPlanNetV110::HealthcareServiceCoverageAreaSearchTest, DaVinciPlanNetV110::HealthcareServiceEndpointSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainEndpointOrganizationSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainLocationAddressCitySearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainLocationAddressPostalcodeSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainLocationAddressSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainLocationAddressStateSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainLocationOrganizationSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainLocationTypeSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainOrganizationAddressSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainOrganizationNameSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainOrganizationPartofSearchTest, DaVinciPlanNetV110::HealthcareServiceForwardChainOrganizationTypeSearchTest, DaVinciPlanNetV110::HealthcareServiceIdSearchTest, DaVinciPlanNetV110::HealthcareServiceIncludeHealthcareServiceCoverageAreaSearchTest, DaVinciPlanNetV110::HealthcareServiceIncludeHealthcareServiceEndpointSearchTest, DaVinciPlanNetV110::HealthcareServiceIncludeHealthcareServiceLocationSearchTest, DaVinciPlanNetV110::HealthcareServiceIncludeHealthcareServiceOrganizationSearchTest, DaVinciPlanNetV110::HealthcareServiceLastupdatedSearchTest, DaVinciPlanNetV110::HealthcareServiceLocationSearchTest, DaVinciPlanNetV110::HealthcareServiceNameSearchTest, DaVinciPlanNetV110::HealthcareServiceNoParamsSearchTest, DaVinciPlanNetV110::HealthcareServiceOrganizationSearchTest, DaVinciPlanNetV110::HealthcareServiceRevincludeOrganizationAffiliationServiceSearchTest, DaVinciPlanNetV110::HealthcareServiceRevincludePractitionerRoleServiceSearchTest, DaVinciPlanNetV110::HealthcareServiceServiceCategorySearchTest, DaVinciPlanNetV110::HealthcareServiceServiceTypeSearchTest, DaVinciPlanNetV110::HealthcareServiceSpecialtySearchTest, DaVinciPlanNetV110::InsurancePlanAdministeredBySearchTest, DaVinciPlanNetV110::InsurancePlanCoverageAreaSearchTest, DaVinciPlanNetV110::InsurancePlanForwardChainAdministeredByNameSearchTest, DaVinciPlanNetV110::InsurancePlanForwardChainAdministeredByPartofSearchTest, DaVinciPlanNetV110::InsurancePlanForwardChainOwnedByNameSearchTest, DaVinciPlanNetV110::InsurancePlanForwardChainOwnedByPartofSearchTest, DaVinciPlanNetV110::InsurancePlanIdSearchTest, DaVinciPlanNetV110::InsurancePlanIdentifierSearchTest, DaVinciPlanNetV110::InsurancePlanIncludeInsurancePlanAdministeredBySearchTest, DaVinciPlanNetV110::InsurancePlanIncludeInsurancePlanCoverageAreaSearchTest, DaVinciPlanNetV110::InsurancePlanIncludeInsurancePlanOwnedBySearchTest, DaVinciPlanNetV110::InsurancePlanLastupdatedSearchTest, DaVinciPlanNetV110::InsurancePlanNameSearchTest, DaVinciPlanNetV110::InsurancePlanNoParamsSearchTest, DaVinciPlanNetV110::InsurancePlanOwnedBySearchTest, DaVinciPlanNetV110::InsurancePlanPlanTypeSearchTest, DaVinciPlanNetV110::InsurancePlanTypeSearchTest, DaVinciPlanNetV110::LocationAddressCitySearchTest, DaVinciPlanNetV110::LocationAddressPostalcodeSearchTest, DaVinciPlanNetV110::LocationAddressSearchTest, DaVinciPlanNetV110::LocationAddressStateSearchTest, DaVinciPlanNetV110::LocationEndpointSearchTest, DaVinciPlanNetV110::LocationForwardChainEndpointOrganizationSearchTest, DaVinciPlanNetV110::LocationForwardChainOrganizationAddressSearchTest, DaVinciPlanNetV110::LocationForwardChainOrganizationNameSearchTest, DaVinciPlanNetV110::LocationForwardChainOrganizationPartofSearchTest, DaVinciPlanNetV110::LocationForwardChainOrganizationTypeSearchTest, DaVinciPlanNetV110::LocationForwardChainPartofAddressSearchTest, DaVinciPlanNetV110::LocationForwardChainPartofOrganizationSearchTest, DaVinciPlanNetV110::LocationForwardChainPartofTypeSearchTest, DaVinciPlanNetV110::LocationIdSearchTest, DaVinciPlanNetV110::LocationIncludeLocationEndpointSearchTest, DaVinciPlanNetV110::LocationIncludeLocationOrganizationSearchTest, DaVinciPlanNetV110::LocationIncludeLocationPartofSearchTest, DaVinciPlanNetV110::LocationLastupdatedSearchTest, DaVinciPlanNetV110::LocationNoParamsSearchTest, DaVinciPlanNetV110::LocationOrganizationSearchTest, DaVinciPlanNetV110::LocationPartofSearchTest, DaVinciPlanNetV110::LocationReverseChainInsurancePlanCoverageAreaOwnedBySearchTest, DaVinciPlanNetV110::LocationRevincludeHealthcareServiceLocationSearchTest, DaVinciPlanNetV110::LocationRevincludeInsurancePlanCoverageAreaSearchTest, DaVinciPlanNetV110::LocationRevincludeOrganizationAffiliationLocationSearchTest, DaVinciPlanNetV110::LocationRevincludePractitionerRoleLocationSearchTest, DaVinciPlanNetV110::LocationTypeSearchTest, DaVinciPlanNetV110::NetworkAddressSearchTest, DaVinciPlanNetV110::NetworkCoverageAreaSearchTest, DaVinciPlanNetV110::NetworkEndpointSearchTest, DaVinciPlanNetV110::NetworkForwardChainEndpointOrganizationSearchTest, DaVinciPlanNetV110::NetworkForwardChainPartofAddressSearchTest, DaVinciPlanNetV110::NetworkForwardChainPartofNameSearchTest, DaVinciPlanNetV110::NetworkForwardChainPartofTypeSearchTest, DaVinciPlanNetV110::NetworkIdSearchTest, DaVinciPlanNetV110::NetworkIncludeOrganizationCoverageAreaSearchTest, DaVinciPlanNetV110::NetworkIncludeOrganizationEndpointSearchTest, DaVinciPlanNetV110::NetworkIncludeOrganizationPartofSearchTest, DaVinciPlanNetV110::NetworkLastupdatedSearchTest, DaVinciPlanNetV110::NetworkNameSearchTest, DaVinciPlanNetV110::NetworkNoParamsSearchTest, DaVinciPlanNetV110::NetworkPartofSearchTest, DaVinciPlanNetV110::NetworkReverseChainPractitionerRoleNetworkLocationSearchTest, DaVinciPlanNetV110::NetworkRevincludePractitionerRoleNetworkSearchTest, DaVinciPlanNetV110::NetworkTypeSearchTest, DaVinciPlanNetV110::OrgAffilEndpointSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainEndpointOrganizationSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainLocationAddressCitySearchTest, DaVinciPlanNetV110::OrgAffilForwardChainLocationAddressPostalcodeSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainLocationAddressSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainLocationAddressStateSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainLocationOrganizationSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainLocationTypeSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainNetworkNameSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainNetworkPartofSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainParticipatingOrganizationAddressSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainParticipatingOrganizationNameSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainParticipatingOrganizationPartofSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainParticipatingOrganizationTypeSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainPrimaryOrganizationAddressSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainPrimaryOrganizationNameSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainPrimaryOrganizationPartofSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainPrimaryOrganizationTypeSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainServiceLocationSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainServiceOrganizationSearchTest, DaVinciPlanNetV110::OrgAffilForwardChainServiceServiceCategorySearchTest, DaVinciPlanNetV110::OrgAffilIdSearchTest, DaVinciPlanNetV110::OrgAffilIncludeOrganizationAffiliationEndpointSearchTest, DaVinciPlanNetV110::OrgAffilIncludeOrganizationAffiliationLocationSearchTest, DaVinciPlanNetV110::OrgAffilIncludeOrganizationAffiliationNetworkSearchTest, DaVinciPlanNetV110::OrgAffilIncludeOrganizationAffiliationParticipatingOrganizationSearchTest, DaVinciPlanNetV110::OrgAffilIncludeOrganizationAffiliationPrimaryOrganizationSearchTest, DaVinciPlanNetV110::OrgAffilIncludeOrganizationAffiliationServiceSearchTest, DaVinciPlanNetV110::OrgAffilLastupdatedSearchTest, DaVinciPlanNetV110::OrgAffilLocationSearchTest, DaVinciPlanNetV110::OrgAffilNetworkSearchTest, DaVinciPlanNetV110::OrgAffilNoParamsSearchTest, DaVinciPlanNetV110::OrgAffilParticipatingOrganizationSearchTest, DaVinciPlanNetV110::OrgAffilPrimaryOrganizationSearchTest, DaVinciPlanNetV110::OrgAffilRoleSearchTest, DaVinciPlanNetV110::OrgAffilServiceSearchTest, DaVinciPlanNetV110::OrgAffilSpecialtySearchTest, DaVinciPlanNetV110::OrganizationAddressSearchTest, DaVinciPlanNetV110::OrganizationCoverageAreaSearchTest, DaVinciPlanNetV110::OrganizationEndpointSearchTest, DaVinciPlanNetV110::OrganizationForwardChainEndpointOrganizationSearchTest, DaVinciPlanNetV110::OrganizationForwardChainPartofAddressSearchTest, DaVinciPlanNetV110::OrganizationForwardChainPartofNameSearchTest, DaVinciPlanNetV110::OrganizationForwardChainPartofTypeSearchTest, DaVinciPlanNetV110::OrganizationIdSearchTest, DaVinciPlanNetV110::OrganizationIncludeOrganizationCoverageAreaSearchTest, DaVinciPlanNetV110::OrganizationIncludeOrganizationEndpointSearchTest, DaVinciPlanNetV110::OrganizationIncludeOrganizationPartofSearchTest, DaVinciPlanNetV110::OrganizationLastupdatedSearchTest, DaVinciPlanNetV110::OrganizationNameSearchTest, DaVinciPlanNetV110::OrganizationNoParamsSearchTest, DaVinciPlanNetV110::OrganizationPartofSearchTest, DaVinciPlanNetV110::OrganizationReverseChainInsurancePlanOwnedByCoverageAreaSearchTest, DaVinciPlanNetV110::OrganizationReverseChainOrgAffilParticipatingOrganizationLocationSearchTest, DaVinciPlanNetV110::OrganizationReverseChainOrgAffilParticipatingOrganizationNetworkSearchTest, DaVinciPlanNetV110::OrganizationReverseChainOrgAffilParticipatingOrganizationSpecialtySearchTest, DaVinciPlanNetV110::OrganizationRevincludeEndpointOrganizationSearchTest, DaVinciPlanNetV110::OrganizationRevincludeHealthcareServiceOrganizationSearchTest, DaVinciPlanNetV110::OrganizationRevincludeInsurancePlanAdministeredBySearchTest, DaVinciPlanNetV110::OrganizationRevincludeInsurancePlanOwnedBySearchTest, DaVinciPlanNetV110::OrganizationRevincludeOrganizationAffiliationParticipatingOrganizationSearchTest, DaVinciPlanNetV110::OrganizationRevincludeOrganizationAffiliationPrimaryOrganizationSearchTest, DaVinciPlanNetV110::OrganizationRevincludePractitionerRoleOrganizationSearchTest, DaVinciPlanNetV110::OrganizationTypeSearchTest, DaVinciPlanNetV110::PractitionerFamilySearchTest, DaVinciPlanNetV110::PractitionerGivenSearchTest, DaVinciPlanNetV110::PractitionerIdSearchTest, DaVinciPlanNetV110::PractitionerLastupdatedSearchTest, DaVinciPlanNetV110::PractitionerNameSearchTest, DaVinciPlanNetV110::PractitionerNoParamsSearchTest, DaVinciPlanNetV110::PractitionerReverseChainPractitionerRolePractitionerLocationSearchTest, DaVinciPlanNetV110::PractitionerReverseChainPractitionerRolePractitionerNetworkSearchTest, DaVinciPlanNetV110::PractitionerReverseChainPractitionerRolePractitionerRoleSearchTest, DaVinciPlanNetV110::PractitionerReverseChainPractitionerRolePractitionerSpecialtySearchTest, DaVinciPlanNetV110::PractitionerRevincludePractitionerRolePractitionerSearchTest, DaVinciPlanNetV110::PractitionerRoleCombinationListPractitionersWithSpecialtyAndLocationSearchTest, DaVinciPlanNetV110::PractitionerRoleEndpointSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainEndpointOrganizationSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainLocationAddressCitySearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainLocationAddressPostalcodeSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainLocationAddressSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainLocationAddressStateSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainLocationOrganizationSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainLocationTypeSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainNetworkAddressSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainNetworkNameSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainNetworkPartofSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainNetworkTypeSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainOrganizationAddressSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainOrganizationNameSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainOrganizationPartofSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainOrganizationTypeSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainPractitionerNameSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainServiceLocationSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainServiceOrganizationSearchTest, DaVinciPlanNetV110::PractitionerRoleForwardChainServiceServiceCategorySearchTest, DaVinciPlanNetV110::PractitionerRoleIdSearchTest, DaVinciPlanNetV110::PractitionerRoleIncludePractitionerRoleEndpointSearchTest, DaVinciPlanNetV110::PractitionerRoleIncludePractitionerRoleLocationSearchTest, DaVinciPlanNetV110::PractitionerRoleIncludePractitionerRoleNetworkSearchTest, DaVinciPlanNetV110::PractitionerRoleIncludePractitionerRoleOrganizationSearchTest, DaVinciPlanNetV110::PractitionerRoleIncludePractitionerRolePractitionerSearchTest, DaVinciPlanNetV110::PractitionerRoleIncludePractitionerRoleServiceSearchTest, DaVinciPlanNetV110::PractitionerRoleLastupdatedSearchTest, DaVinciPlanNetV110::PractitionerRoleLocationSearchTest, DaVinciPlanNetV110::PractitionerRoleNetworkSearchTest, DaVinciPlanNetV110::PractitionerRoleNoParamsSearchTest, DaVinciPlanNetV110::PractitionerRoleOrganizationSearchTest, DaVinciPlanNetV110::PractitionerRolePractitionerSearchTest, DaVinciPlanNetV110::PractitionerRoleRoleSearchTest, DaVinciPlanNetV110::PractitionerRoleServiceSearchTest, DaVinciPlanNetV110::PractitionerRoleSpecialtySearchTest
Defined in:
lib/davinci_plan_net_test_kit/search_test.rb

Constant Summary

Constants included from FHIRResourceNavigation

FHIRResourceNavigation::DAR_EXTENSION_URL

Instance Method Summary collapse

Methods included from FHIRResourceNavigation

#find_a_value_at, #get_next_value, #resolve_path

Methods included from DateSearchValidation

#fhir_date_comparer, #get_fhir_datetime_range, #get_fhir_period_range, #is_date?, #validate_date_search, #validate_datetime_search, #validate_period_search

Instance Method Details

#additional_resource(field = nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 61

def additional_resource(field = nil)
  field = field&.to_sym if field.class != Symbol
  case field
  when nil
    scratch[:additional_resource_for_test][:resource]
  when :id
    scratch[:additional_resource_for_test][:id]
  when :"#{chain_param}"
    scratch[:additional_resource_for_test][:"#{chain_param}"]
  when :"#{inc_param_sp}"
    scratch[:additional_resource_for_test][:"#{inc_param_sp}"]
  when :"#{rev_param_sp}"
    scratch[:additional_resource_for_test][:"#{rev_param_sp}"]
  when :"#{reverse_chain_param}"
    given_input? ? self.send(:"#{input_name}") : scratch[:additional_resource_for_test][:"#{reverse_chain_param}"]
  end
end

#additional_scratch_resourcesObject



697
698
699
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 697

def additional_scratch_resources
  scratch_additional_resources[:all] ||= []
end

#all_combination_search_paramsObject



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 163

def all_combination_search_params
  @all_combination_search_params ||=
    #First get resource pool that can be used for populating base resources
    resource_pool = resources_with_all_search_params_with_values(search_param_names)
    #Then find a reference to one from this pool
    
    if inc_param_sp
      find_base_resource(resource_type, inc_param_sp, resource_pool)
      params_list = base_combination_search_params(additional_resource).dup
      params_list = include_param ? params_list.merge(_include: include_param) : params_list
    end
    # After all references have been confirmed, populate it with elements of the resource that meets all requirements
    # Revinclude
    # Forward Chain
    if reverse_chain_param
      params_list = base_combination_search_params(resource_pool.first).dup
      field_value = given_input? ? self.send(input_name) : find_reverse_chain_resource
      params_list.merge!("_has:#{additional_resource_type}:#{reverse_chain_target}:#{reverse_chain_param}": field_value)
    end
    #TODO: Fill with the rest of advanced searches once more combination tests are ready
    params_list
end

#all_comparator_searches_tested?Boolean

Returns:

  • (Boolean)


526
527
528
529
530
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 526

def all_comparator_searches_tested?
  return true if params_with_comparators.blank?

  Set.new(params_with_comparators) == search_variant_test_records[:comparator_searches]
end

#all_forward_chain_search_paramsObject



156
157
158
159
160
161
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 156

def all_forward_chain_search_params
  @all_forward_chain_search_params ||=
    all_search_params.transform_values! do |params_list|
      params_list.map { |params| {"#{chain_param_base}.#{chain_param}": find_forward_chain_value} }
    end
end

#all_include_search_paramsObject



139
140
141
142
143
144
145
146
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 139

def all_include_search_params
  @all_include_search_params ||=
    all_search_params.transform_values! do |params_list|
      # No input needed for includes so can just pass into the map
      find_base_resource(resource_type, inc_param_sp, all_scratch_resources)
      params_list.map { |params| {_id: additional_resource(:id)}.merge(_include: include_param) }
    end
end

#all_reverse_chain_search_paramsObject



148
149
150
151
152
153
154
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 148

def all_reverse_chain_search_params
  @all_revchain_search_params ||=
    all_search_params.transform_values! do |params_list|
      field_value = given_input? ? self.send(input_name) : find_reverse_chain_resource
      params_list.map { |params| {"_has:#{additional_resource_type}:#{reverse_chain_target}:#{reverse_chain_param}": field_value}}
    end
end

#all_revinclude_search_paramsObject



130
131
132
133
134
135
136
137
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 130

def all_revinclude_search_params
  @all_revinclude_search_params ||=
    all_search_params.transform_values! do |params_list|
      find_base_resource(additional_resource_type, rev_param_sp, additional_scratch_resources) if !given_input?
      base_id = given_input? ? self.send(input_name) : additional_resource(rev_param_sp)
      params_list.map { |params| {_id: base_id}.merge(_revinclude: revinclude_param) }
    end
end

#all_scratch_resourcesObject



693
694
695
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 693

def all_scratch_resources
  scratch_resources[:all] ||= []
end

#all_search_paramsObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 113

def all_search_params
  @all_search_params ||=
    resource_id_list.each_with_object({}) do |resource_id, params|
      params[resource_id] ||= []
      new_params =
        if fixed_value_search?
          fixed_value_search_param_values.map { |value| fixed_value_search_params(value, resource_id) }
        else
          [search_params_with_values(search_param_names, resource_id)]
        end
      new_params.reject! do |params|
        params.any? { |_key, value| value.blank? }
      end
      params[resource_id].concat(new_params)
    end
end

#all_search_params_present?(params) ⇒ Boolean

Returns:

  • (Boolean)


791
792
793
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 791

def all_search_params_present?(params)
  params.all? { |_name, value| value.present? }
end

#all_search_variants_tested?Boolean

Returns:

  • (Boolean)


521
522
523
524
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 521

def all_search_variants_tested?
  search_variant_test_records.all? { |_variant, tested| tested.present? } &&
    all_comparator_searches_tested?
end

#any_valid_search_params?(search_params) ⇒ Boolean

Returns:

  • (Boolean)


192
193
194
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 192

def any_valid_search_params?(search_params)
  search_params.any? { |_resource_id, params| params.present? }
end

#array_of_codes(array) ⇒ Object



795
796
797
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 795

def array_of_codes(array)
  array.map { |name| "`#{name}`" }.join(', ')
end

#base_combination_search_params(resource = nil) ⇒ Object



186
187
188
189
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 186

def base_combination_search_params(resource = nil)
  @base_combination_search_params ||=
    search_param_values_from_same_resource(search_param_names, resource)
end

#cant_resolve_next_bundle_message(link) ⇒ Object



949
950
951
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 949

def cant_resolve_next_bundle_message(link)
  "Could not resolve next bundle: #{link}"
end

#check_resource_against_params(resource, params) ⇒ Object



1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 1139

def check_resource_against_params(resource, params)
  params.each do |name, escaped_search_value|
    #unescape search value
    search_value = escaped_search_value&.gsub('\\,', ',')
    paths = search_param_paths(name, resource.resourceType)

    match_found = false
    values_found = []
     = resource.resourceType == resource_type ?  : 
    paths.each do |path|
      type = .search_definitions[name.to_sym][:type]
      values_found =
        resolve_path(resource, path)
          .flat_map do |value|
            case value
            when FHIR::Reference
              value.reference
            when FHIR::Extension
              value.valueReference.reference
            else
              value
            end
          end

      match_found =
        case type
        when 'Period', 'date', 'instant', 'dateTime'
          values_found.any? { |date| validate_date_search(search_value, date) }
        when 'HumanName'
          # When a string search parameter refers to the types HumanName and Address,
          # the search covers the elements of type string, and does not cover elements such as use and period
          # https://www.hl7.org/fhir/search.html#string
          search_value_downcase = search_value.downcase
          values_found.any? do |name|
            name&.text&.downcase&.start_with?(search_value_downcase) ||
              name&.family&.downcase&.start_with?(search_value_downcase) ||
              name&.given&.any? { |given| given.downcase.start_with?(search_value_downcase) } ||
              name&.prefix&.any? { |prefix| prefix.downcase.start_with?(search_value_downcase) } ||
              name&.suffix&.any? { |suffix| suffix.downcase.start_with?(search_value_downcase) }
          end
        when 'Address'
          search_value_downcase = search_value.downcase
          values_found.any? do |address|
            address&.text&.downcase&.start_with?(search_value_downcase) ||
            address&.city&.downcase&.start_with?(search_value_downcase) ||
            address&.state&.downcase&.start_with?(search_value_downcase) ||
            address&.postalCode&.downcase&.start_with?(search_value_downcase) ||
            address&.country&.downcase&.start_with?(search_value_downcase)
          end
        when 'CodeableConcept'
          # FHIR token search (https://www.hl7.org/fhir/search.html#token): "When in doubt, servers SHOULD
          # treat tokens in a case-insensitive manner, on the grounds that including undesired data has
          # less safety implications than excluding desired behavior".
          codings = values_found.flat_map(&:coding)
          if search_value.include? '|'
            system = search_value.split('|').first
            code = search_value.split('|').last
            codings&.any? { |coding| coding.system == system && coding.code&.casecmp?(code) }
          else
            codings&.any? { |coding| coding.code&.casecmp?(search_value) }
          end
        when 'Coding'
          if search_value.include? '|'
            system = search_value.split('|').first
            code = search_value.split('|').last
            values_found.any? { |coding| coding.system == system && coding.code&.casecmp?(code) }
          else
            values_found.any? { |coding| coding.code&.casecmp?(search_value) }
          end
        when 'Identifier'
          if search_value.include? '|'
            values_found.any? { |identifier| "#{identifier.system}|#{identifier.value}" == search_value }
          else
            values_found.any? { |identifier| identifier.value == search_value }
          end
        when 'string'
          searched_values = search_value.downcase.split(/(?<!\\\\),/).map{ |string| string.gsub('\\,', ',') }
          values_found.any? do |value_found|
            searched_values.any? { |searched_value| value_found.downcase.starts_with? searched_value || is_reference_match?(searched_value, value_found) }
          end
        else
          search_values = search_value.split(/(?<!\\\\),/).map { |string| string.gsub('\\,', ',') }
          values_found.any? do |value_found| 
            search_values.any? { |search_val| value_found == search_values || is_reference_match?(search_val, value_found) } 
          end

        end

      break if match_found
    end

    assert match_found,
           "#{resource_type}/#{resource.id} did not match the search parameters:\n" \
           "* Expected: #{search_value}\n" \
           "* Found: #{values_found.map(&:inspect).join(', ')}"
  end
end

#check_search_responseObject



502
503
504
505
506
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 502

def check_search_response
  assert_response_status(200)
  assert_resource_type(:bundle)
  # NOTE: how do we want to handle validating Bundles?
end

#date_comparator_value(comparator, date) ⇒ Object



532
533
534
535
536
537
538
539
540
541
542
543
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 532

def date_comparator_value(comparator, date)
  date = date.start || date.end if date.is_a? FHIR::Period
  case comparator
  when 'lt', 'le'
    comparator + (DateTime.xmlschema(date) + 1).xmlschema
  when 'gt', 'ge'
    comparator + (DateTime.xmlschema(date) - 1).xmlschema
  else
    # ''
    raise "Unsupported comparator '#{comparator}'"
  end
end

#default_search_values(param_name) ⇒ Object



643
644
645
646
647
648
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 643

def default_search_values(param_name)
  definition = .search_definitions[param_name]
  return [] if definition.blank?

  definition[:multiple_or] == 'SHALL' ? [definition[:values].join(',')] : Array.wrap(definition[:values])
end

#element_has_valid_value?(element, include_system) ⇒ Boolean

Returns:

  • (Boolean)


998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 998

def element_has_valid_value?(element, include_system)
  case element
  when FHIR::Reference
    element.reference.present?
  when FHIR::CodeableConcept
    if include_system
      coding =
        find_a_value_at(element, 'coding') { |coding| coding.code.present? && coding.system.present? }
      coding.present?
    else
      find_a_value_at(element, 'coding.code').present?
    end
  when FHIR::Identifier
    include_system ? element.value.present? && element.system.present? : element.value.present?
  when FHIR::Coding
    include_system ? element.code.present? && element.system.present? : element.code.present?
  when FHIR::HumanName
    (element.family || element.given&.first || element.text).present?
  when FHIR::Address
    (element.text || element.city || element.state || element.postalCode || element.country).present?
  else
    true
  end
end

#empty_search_params_message(empty_search_params) ⇒ Object



840
841
842
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 840

def empty_search_params_message(empty_search_params)
  "Could not find values for the search parameters #{array_of_codes(empty_search_params.keys)}"
end

#fetch_all_bundled_resources(reply_handler: nil, max_pages: 0, additional_resource_types: [], resource_type: self.resource_type) ⇒ Object



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 858

def fetch_all_bundled_resources(
      reply_handler: nil,
      max_pages: 0,
      additional_resource_types: [],
      resource_type: self.resource_type
    )
  page_count = 1
  resources = []
  bundle = resource
  resources += bundle&.entry&.map { |entry| entry&.resource }

  until bundle.nil? || (page_count == max_pages && max_pages != 0)
    
    next_bundle_link = bundle&.link&.find { |link| link.relation == 'next' }&.url
    reply_handler&.call(response)

    break if next_bundle_link.blank?

    reply = fhir_client.raw_read_url(next_bundle_link)

    store_request('outgoing') { reply }
    error_message = cant_resolve_next_bundle_message(next_bundle_link)

    assert_response_status(200)
    assert_valid_json(reply.body, error_message)

    bundle = fhir_client.parse_reply(FHIR::Bundle, fhir_client.default_format, reply)
    resources += bundle&.entry&.map { |entry| entry&.resource }

    page_count += 1
  end

  valid_resource_types = [resource_type, 'OperationOutcome'].concat(additional_resource_types)

  invalid_resource_types =
    resources.reject { |entry| valid_resource_types.include? entry.resourceType }
             .map(&:resourceType)
             .uniq

  if invalid_resource_types.any?
    info "Received resource type(s) #{invalid_resource_types.join(', ')} in search bundle, " \
         "but only expected resource types #{valid_resource_types.join(', ')}. " + \
         "This is unusual but allowed if the server believes additional resource types are relevant."
  end

  resources
end

#fetch_matching_bundled_resources(max_pages: 20, max_instances: 200, resource_type: self.resource_type) ⇒ Object



906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 906

def fetch_matching_bundled_resources(
      max_pages: 20,
      max_instances: 200,
      resource_type: self.resource_type
    )
  page_count = 0
  resources = []
  bundle = resource

  loop do
    bundle&.entry&.each do |a_entry|
      an_instance = a_entry.resource
      if ( an_instance && 
           an_instance.resourceType == resource_type && 
           # Plan Net Specific Special Case
           !DaVinciPlanNetTestKit::SpecialCases::filter_instance_for_parameterless_gathering?(.profile_url, an_instance)
      )
        resources << an_instance
        break if resources.size >= max_instances
      end
    end
    break if resources.size >= max_instances

    page_count += 1
    break if page_count >= max_pages

    next_bundle_link = bundle&.link&.find { |link| link.relation == 'next' }&.url
    break if next_bundle_link.blank?

    reply = fhir_client.raw_read_url(next_bundle_link)

    store_request('outgoing') { reply }
    error_message = cant_resolve_next_bundle_message(next_bundle_link)

    assert_response_status(200)
    assert_valid_json(reply.body, error_message)

    bundle = fhir_client.parse_reply(FHIR::Bundle, fhir_client.default_format, reply)
  end

  resources
end

#filter_conditions(resources) ⇒ Object



484
485
486
487
488
489
490
491
492
493
494
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 484

def filter_conditions(resources)
  # In order to distinguish which resources matches the current profile, Inferno has to manually filter
  # the result of first search.
  resources.select! do |resource|
    resource.category.any? do |category|
      category.coding.any? do |coding|
        .search_definitions[:category][:values].include? coding.code
      end
    end
  end
end

#filter_devices(resources) ⇒ Object



475
476
477
478
479
480
481
482
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 475

def filter_devices(resources)
  codes_to_include = implantable_device_codes&.split(',')&.map(&:strip)
  return resources if codes_to_include.blank?

  resources.select! do |resource|
    resource&.type&.coding&.any? { |coding| codes_to_include.include?(coding.code) }
  end
end

#find_base_resource(desired_resource, search_param, resources) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 79

def find_base_resource(desired_resource, search_param, resources)
  # Access correct scratch based on what base you are looking for
  is_include = desired_resource == resource_type
  skip_if resources.nil?, no_instance_gathering_message
  base_resource = resources
    .select { |resource| resource.resourceType == desired_resource }
    .reject { |resource| search_param_value(search_param, resource).nil? }
    .first
  skip_if base_resource.nil?, unable_to_find_base_message(desired_resource, search_param)
  set_additional_resource(base_resource)
  base_resource
end

#find_forward_chain_valueObject



92
93
94
95
96
97
98
99
100
101
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 92

def find_forward_chain_value
  # Look through return from relevant include test
  # If it is in additional_scratch_resources, it was put there from an _include/_revinclude test
  chain_candidate = additional_scratch_resources
    .find { |resource| !search_param_value(chain_param, resource).nil?}
  skip_if chain_candidate.nil?, no_forward_chain_resource_found_message
  chain_field_value = search_param_value(chain_param, chain_candidate)
  set_additional_resource(chain_candidate)
  chain_field_value
end

#find_reverse_chain_resourceObject



103
104
105
106
107
108
109
110
111
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 103

def find_reverse_chain_resource
  chain_candidate = additional_scratch_resources
    .reject { |resource| search_param_value(reverse_chain_target, resource).nil?}
    .find { |resource| !search_param_value(reverse_chain_param, resource).nil?}
  skip_if chain_candidate.nil?, no_reverse_chain_resource_found_message
  chain_field_value = search_param_value(reverse_chain_param, chain_candidate)
  set_additional_resource(chain_candidate)
  chain_field_value
end

#fixed_value_search_param_nameObject



712
713
714
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 712

def fixed_value_search_param_name
  (search_param_names - ['resource']).first
end

#fixed_value_search_param_valuesObject



716
717
718
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 716

def fixed_value_search_param_values
  .search_definitions[fixed_value_search_param_name.to_sym][:values]
end

#fixed_value_search_params(value, resource_id) ⇒ Object



720
721
722
723
724
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 720

def fixed_value_search_params(value, resource_id)
  search_param_names.each_with_object({}) do |name, params|
    resource_id_param?(name) ? params[name] = resource_id : params[name] = value
  end
end

#forward_chain_conformance_error_messageObject



824
825
826
827
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 824

def forward_chain_conformance_error_message
  "Unable to find any returned #{resource_type} instances that reference #{additional_resource_type} instances
  where the #{chain_param} field is populated with the value used in the request."
end

#forward_chaining_incorrect_reference_error_message(violating_resource) ⇒ Object



829
830
831
832
833
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 829

def forward_chaining_incorrect_reference_error_message(violating_resource)
  "#{resource_type} instance #{search_param_value("_id", violating_resource)} references 
  #{search_param_value(chain_param_base, violating_resource)} which does not have #{chain_param} value 
  #{additional_resource(chain_param)}"
end

#given_input?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 38

def given_input?
  !(self.send(input_name).nil? || self.send(input_name).empty?)
end

#initial_search_variant_test_recordsObject



512
513
514
515
516
517
518
519
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 512

def initial_search_variant_test_records
  {}.tap do |records|
    records[:post_variant] = false if test_post_search?
    records[:reference_variants] = false if test_reference_variants?
    records[:token_variants] = false if token_search_params.present?
    records[:comparator_searches] = Set.new if params_with_comparators.present?
  end
end

#input_based_skip_assert(resources, message) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 42

def input_based_skip_assert(resources, message)
  if given_input?
    skip_if resources.empty?, "#{message} Please try a different input"
  else
    assert !resources.empty?, message
  end
end

#is_reference_match?(reference, local_reference) ⇒ Boolean

Returns:

  • (Boolean)


1238
1239
1240
1241
1242
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 1238

def is_reference_match? (reference, local_reference)
  regex_pattern = /^(#{Regexp.escape(local_reference)}|\S+\/#{Regexp.escape(local_reference)}(?:[\/|]\S+)*)$/
  regex_pattern_local = /^(#{Regexp.escape(reference)}|\S+\/#{Regexp.escape(reference)}(?:[\/|]\S+)*)$/
  reference.match?(regex_pattern) || local_reference.match?(regex_pattern_local)
end

#no_forward_chain_resource_found_messageObject



813
814
815
816
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 813

def no_forward_chain_resource_found_message
  "Unable to find any previously returned #{additional_resource_type} instances with the 
  #{chain_param} field populated."
end

#no_instance_gathering_messageObject



808
809
810
811
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 808

def no_instance_gathering_message
  "Unable to find previously gathered instances of #{additional_resource_type}, please provide ids or
  \"Run All Tests\" from suite level"
end

#no_resources_skip_message(resource_type = self.resource_type) ⇒ Object



844
845
846
847
848
849
850
851
852
853
854
855
856
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 844

def no_resources_skip_message(resource_type = self.resource_type)
  msg = "No #{resource_type} resources appear to be available"

  if (!revinclude_param.nil? && include_param.nil?)
    msg.concat(" Please choose a base resource that is referenced by a #{additional_resource_type}")
  end

  if (revinclude_param.nil? && !include_param.nil?)
    msg.concat(" Please choose a base resource that is references a #{additional_resource_type}")
  end

  "#{msg}."
end

#no_reverse_chain_resource_found_messageObject



818
819
820
821
822
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 818

def no_reverse_chain_resource_found_message
  "Unable to find any previously returned #{additional_resource_type} instances with both
  #{reverse_chain_param} and #{reverse_chain_target} fields populated.  Please \"Run All Tests\"
  from suite level or provide specific field values."
end

#param_to_method(param) ⇒ Object

PARSING (Remove if methods exist elsewhere already)



1246
1247
1248
1249
1250
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 1246

def param_to_method(param)
  param = param.split('-').collect(&:capitalize).join
  param = "healthcareService" if param == "Service"
  param[0].downcase + param[1..]
end

#perform_comparator_searches(params, resource_id) ⇒ Object



554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 554

def perform_comparator_searches(params, resource_id)
  params_with_comparators.each do |name|
    next if search_variant_test_records[:comparator_searches].include? name

    required_comparators(name).each do |comparator|
      paths = search_param_paths(name).first
      date_element = find_a_value_at(scratch_resources_for_resource(resource_id), paths)
      params_with_comparator = params.merge(name => date_comparator_value(comparator, date_element))

      search_and_check_response(params_with_comparator)

      fetch_all_bundled_resources.each do |resource|
        check_resource_against_params(resource, params_with_comparator) if resource.resourceType == resource_type
      end
    end

    search_variant_test_records[:comparator_searches] << name
  end
end

#perform_multiple_or_search_testObject



651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 651

def perform_multiple_or_search_test
  resolved_one = false

  all_search_params.each do |resource_id, params_list|
    next unless params_list.present?

    search_params = params_list.first
    existing_values = {}
    missing_values = {}

    multiple_or_search_params.each do |param_name|
      search_value = default_search_values(param_name.to_sym)
      search_params = search_params.merge("#{param_name}" => search_value)
      existing_values[param_name.to_sym] = scratch_resources_for_resource(resource_id).map(&param_name.to_sym).compact.uniq
    end

    # skip resources without multiple-or values
    next if existing_values.values.any?(&:empty?)

    resolved_one = true

    search_and_check_response(search_params)

    resources_returned =
      fetch_all_bundled_resources
        .select { |resource| resource.resourceType == resource_type }

    multiple_or_search_params.each do |param_name|
      missing_values[param_name.to_sym] = existing_values[param_name.to_sym] - resources_returned.map(&param_name.to_sym)
    end

    missing_value_message = missing_values
      .reject { |_param_name, missing_value| missing_value.empty? }
      .map { |param_name, missing_value| "#{missing_value.join(',')} values from #{param_name}" }
      .join(' and ')

    assert missing_value_message.blank?, "Could not find #{missing_value_message} in any of the resources returned for #{resource_type}/#{resource_id}"

    break if resolved_one
  end
end

#perform_post_search(get_search_resources, params) ⇒ Object



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 454

def perform_post_search(get_search_resources, params)
  fhir_search resource_type, params: params, search_method: :post

  check_search_response

  post_search_resources = fetch_all_bundled_resources.select { |resource| resource.resourceType == resource_type }

  filter_conditions(post_search_resources) if resource_type == 'Condition' && .version == 'v5.0.1'
  filter_devices(post_search_resources) if resource_type == 'Device'

  get_resource_count = get_search_resources.length
  post_resource_count = post_search_resources.length

  search_variant_test_records[:post_variant] = true

  assert get_resource_count == post_resource_count,
         "Expected search by POST to return the same results as search by GET, " \
         "but GET search returned #{get_resource_count} resources, and POST search " \
         "returned #{post_resource_count} resources."
end

#perform_reference_with_type_search(params, resource_count) ⇒ Object



574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 574

def perform_reference_with_type_search(params, resource_count)
  return if resource_count == 0
  return if search_variant_test_records[:reference_variants]

  new_search_params = params.merge(resource_type.underscore => "#{resource_type}/#{params['resource']}")
  search_and_check_response(new_search_params)

  reference_with_type_resources = fetch_all_bundled_resources.select { |resource| resource.resourceType == resource_type }


  new_resource_count = reference_with_type_resources.count

  assert new_resource_count == resource_count,
         "Expected search by `#{params['resource']}` to to return the same results as searching " \
         "by `#{new_search_params['resource']}`, but found #{resource_count} resources with " \
         "`#{params['resource']}` and #{new_resource_count} with `#{new_search_params['resource']}`"

  search_variant_test_records[:reference_variants] = true
end

#perform_search(params, resource_id) ⇒ Object



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 419

def perform_search(params, resource_id)
  fhir_search resource_type, params: params

  perform_search_with_status(params, resource_id) if response[:status] == 400 && possible_status_search?

  check_search_response

  resources_returned =
    fetch_all_bundled_resources.select { |resource| resource.resourceType == resource_type }

  return [] if resources_returned.blank?

  perform_comparator_searches(params, resource_id) if params_with_comparators.present?

  if first_search?
    all_scratch_resources.concat(resources_returned).uniq!
    scratch_resources_for_resource(resource_id).concat(resources_returned).uniq!
  end

  resources_returned.each do |resource|
    check_resource_against_params(resource, params)
  end

  save_delayed_references(resources_returned) if saves_delayed_references?

  return resources_returned if all_search_variants_tested?

  perform_post_search(resources_returned, params) if test_post_search?

  perform_reference_with_type_search(params, resources_returned.count) if test_reference_variants?
  perform_search_with_system(params, resource_id) if token_search_params.present?

  resources_returned
end

#perform_search_with_status(original_params, resource_id, status_search_values: self.status_search_values, resource_type: self.resource_type) ⇒ Object



612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 612

def perform_search_with_status(
      original_params,
      resource_id,
      status_search_values: self.status_search_values,
      resource_type: self.resource_type
    )
  assert resource.is_a?(FHIR::OperationOutcome), "Server returned a status of 400 without an OperationOutcome"
  # TODO: warn about documenting status requirements
  status_search_values.flat_map do |status_value|
    search_params = original_params.merge("#{status_search_param_name}": status_value)

    search_and_check_response(search_params)

    entries = resource.entry.select { |entry| entry.resource.resourceType == resource_type }

    if entries.present?
      original_params.merge!("#{status_search_param_name}": status_value)
      break
    end
  end
end

#perform_search_with_system(params, resource_id) ⇒ Object



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 594

def perform_search_with_system(params, resource_id)
  return if search_variant_test_records[:token_variants]

  new_search_params = search_params_with_values(token_search_params, resource_id, include_system: true)
  return if new_search_params.any? { |_name, value| value.blank? }

  search_params = params.merge(new_search_params)
  search_and_check_response(search_params)

  resources_returned =
    fetch_all_bundled_resources
      .select { |resource| resource.resourceType == resource_type }

  assert resources_returned.present?, "No resources were returned when searching by `system|code`"

  search_variant_test_records[:token_variants] = true
end

#references_to_save(resource_type = nil) ⇒ Object



707
708
709
710
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 707

def references_to_save(resource_type = nil)
   = resource_type == 'Provenance' ?  : 
  .delayed_references
end

#required_comparators(name) ⇒ Object



545
546
547
548
549
550
551
552
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 545

def required_comparators(name)
  
    .search_definitions
    .dig(name.to_sym, :comparators)
    .select { |_comparator, expectation| expectation == 'SHALL' }
    .keys
    .map(&:to_s)
end

#resource_fields_conform_to_params?(resource, params) ⇒ Boolean

RESULT CHECKING ####

Returns:

  • (Boolean)


1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 1046

def resource_fields_conform_to_params?(resource, params)
  params.all? do |name, escaped_search_value|
    #unescape search value
    search_value = escaped_search_value&.gsub('\\,', ',')
    paths = search_param_paths(name, resource.resourceType)

    match_found = false
    values_found = []
     = resource.resourceType == resource_type ?  : 
    paths.each do |path|
      type = .search_definitions[name.to_sym][:type]
      values_found =
        resolve_path(resource, path)
          .flat_map do |value|
            case value
            when FHIR::Reference
              value.reference
            when FHIR::Extension
              value.valueReference.reference
            else
              value
            end
          end

      match_found =
        case type
        when 'Period', 'date', 'instant', 'dateTime'
          values_found.any? { |date| validate_date_search(search_value, date) }
        when 'HumanName'
          # When a string search parameter refers to the types HumanName and Address,
          # the search covers the elements of type string, and does not cover elements such as use and period
          # https://www.hl7.org/fhir/search.html#string
          search_value_downcase = search_value.downcase
          values_found.any? do |name|
            name&.text&.downcase&.start_with?(search_value_downcase) ||
              name&.family&.downcase&.start_with?(search_value_downcase) ||
              name&.given&.any? { |given| given.downcase.start_with?(search_value_downcase) } ||
              name&.prefix&.any? { |prefix| prefix.downcase.start_with?(search_value_downcase) } ||
              name&.suffix&.any? { |suffix| suffix.downcase.start_with?(search_value_downcase) }
          end
        when 'Address'
          search_value_downcase = search_value.downcase
          values_found.any? do |address|
            address&.text&.downcase&.start_with?(search_value_downcase) ||
            address&.city&.downcase&.start_with?(search_value_downcase) ||
            address&.state&.downcase&.start_with?(search_value_downcase) ||
            address&.postalCode&.downcase&.start_with?(search_value_downcase) ||
            address&.country&.downcase&.start_with?(search_value_downcase)
          end
        when 'CodeableConcept'
          # FHIR token search (https://www.hl7.org/fhir/search.html#token): "When in doubt, servers SHOULD
          # treat tokens in a case-insensitive manner, on the grounds that including undesired data has
          # less safety implications than excluding desired behavior".
          codings = values_found.flat_map(&:coding)
          if search_value.include? '|'
            system = search_value.split('|').first
            code = search_value.split('|').last
            codings&.any? { |coding| coding.system == system && coding.code&.casecmp?(code) }
          else
            codings&.any? { |coding| coding.code&.casecmp?(search_value) }
          end
        when 'Coding'
          if search_value.include? '|'
            system = search_value.split('|').first
            code = search_value.split('|').last
            values_found.any? { |coding| coding.system == system && coding.code&.casecmp?(code) }
          else
            values_found.any? { |coding| coding.code&.casecmp?(search_value) }
          end
        when 'Identifier'
          if search_value.include? '|'
            values_found.any? { |identifier| "#{identifier.system}|#{identifier.value}" == search_value }
          else
            values_found.any? { |identifier| identifier.value == search_value }
          end
        when 'string'
          searched_values = search_value.downcase.split(/(?<!\\\\),/).map{ |string| string.gsub('\\,', ',') }
          values_found.any? do |value_found|
            searched_values.any? { |searched_value| value_found.downcase.starts_with? searched_value || is_reference_match?(searched_value, value_found) }
          end
        else
          search_values = search_value.split(/(?<!\\\\),/).map { |string| string.gsub('\\,', ',') }
          values_found.any? do |value_found| 
            search_values.any? { |search_val| value_found == search_values || is_reference_match?(search_val, value_found) } 
          end
        end

      break if match_found
    end
    match_found
  end
end

#resource_id_listObject



768
769
770
771
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 768

def resource_id_list
  return [nil] unless respond_to? :resource_ids
  resource_ids.split(',').map(&:strip)
end

#resource_id_param?(name) ⇒ Boolean

Returns:

  • (Boolean)


777
778
779
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 777

def resource_id_param?(name)
  name == '_id'
end

#resource_search?Boolean

Returns:

  • (Boolean)


773
774
775
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 773

def resource_search?
  search_param_names.any? { |name| resource_id_param? name }
end

#resources_with_all_search_params_with_values(search_param_names) ⇒ Object



750
751
752
753
754
755
756
757
758
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 750

def resources_with_all_search_params_with_values(search_param_names)
  resources = all_scratch_resources

  candidate_resources = resources.select do |resource| 
    search_param_names.all? { |param| !search_param_value(param, resource).nil?}
  end
  skip_if candidate_resources.empty?, "No resources populate all base search parameters."
  candidate_resources
end

#reverse_chaining_incorrect_reference_error_message(violating_resource) ⇒ Object



835
836
837
838
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 835

def reverse_chaining_incorrect_reference_error_message(violating_resource)
  "Found #{resource_type} instance #{search_param_value("_id", violating_resource)} that is not referenced by any 
  #{additional_resource_type} that have a #{reverse_chain_param} value of #{additional_resource(reverse_chain_param)}"
end

#run_combination_search_testObject



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 377

def run_combination_search_test
  fhir_search resource_type, params: all_combination_search_params
  perform_search_with_status(all_combination_search_params, resource_id) if response[:status] == 400 && possible_status_search?

  check_search_response

  returned_resources = fetch_all_bundled_resources(additional_resource_types: [additional_resource_type])
  assert !returned_resources.empty?, "No #{resource_type} resources found"

  base_resources = returned_resources
      .select { |res| res.resourceType == resource_type }
  base_resources.each { |res| check_resource_against_params(res, base_combination_search_params)}

  if inc_param_sp
    matching_resources = returned_resources 
      .select { |res| res.resourceType == additional_resource_type }
    assert !matching_resources.empty?, "Server did not return any #{additional_resource_type} resources, but query was based on existing element"

    assert matching_resources.all? { |match_res| 
      base_resources.any? { |base_res|
        if search_param_value(inc_param_sp, base_res).nil?
          false
        else
          resource_fields_conform_to_params?(base_res, {"#{inc_param_sp}": search_param_value("_id", match_res)})
        end
      }
    }, "Server returned a #{additional_resource_type} resource that was not referenced by any matching #{resource_type} instances"
  end

  if reverse_chain_param
    input_based_skip_assert(returned_resources, "No resources found.")
    contextual_resources = run_search_on_additional_resource_type(reverse_chain_param)
    base_resources.each do |base_res| 
      assert (contextual_resources.any? do |res| 
        reference_value = search_param_value(reverse_chain_target, res)
        reference_value.nil? ? false : is_reference_match?(reference_value, search_param_value("_id", base_res))
      end), reverse_chaining_incorrect_reference_error_message(base_res)
    end  
  end
end

#run_forward_chain_search_testObject



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 322

def run_forward_chain_search_test
  resources =
    all_forward_chain_search_params.flat_map do |_resource_id, params_list|
      params_list.flat_map do |params|
        fhir_search resource_type, params: params
        perform_search_with_status(params, resource_id) if response[:status] == 400 && possible_status_search?

        check_search_response

        returned_resources = fetch_all_bundled_resources(additional_resource_types: [additional_resource_type])
        assert !returned_resources.empty?, "No #{resource_type} resources returned"
        base_resources = returned_resources
          .select { |res| res.resourceType == resource_type }
        
        contextual_resources = run_search_on_additional_resource_type(chain_param)
        # Check that all references within the Base point to one of the resources in scratch currently.
        base_resources.each do |base_res| 
          reference_value = search_param_value(chain_param_base, base_res)
          assert (contextual_resources.any? do |res| 
            is_reference_match?(reference_value, search_param_value("_id", res))
          end), forward_chaining_incorrect_reference_error_message(base_res)
        end  
        base_resources
      end
    end
    assert !resources.empty?, no_resources_skip_message
end

#run_include_search_testObject



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 196

def run_include_search_test
  skip_if !any_valid_search_params?(all_include_search_params), "Invalid Params"
  resources =
    all_include_search_params.flat_map do |_resource_id, params_list|
      params_list.flat_map do |params|
        fhir_search resource_type, params: params
        perform_search_with_status(params, resource_id) if response[:status] == 400 && possible_status_search?
    
        check_search_response

        returned_resources = fetch_all_bundled_resources(additional_resource_types: [additional_resource_type])
        
        base_resources = returned_resources
          .select { |res| res.resourceType == resource_type }

        matching_resources = returned_resources 
          .select { |res| res.resourceType == additional_resource_type }
          
        matching_resources.reject! { |res| res.id == params[:_id]} if additional_resource_type == resource_type

        expected_reference = additional_resource(inc_param_sp)
        matching_resources.each { |res| 
          check_resource_against_params(res, {_id: expected_reference})
        }
        matching_resources 
      end
    end

  save_delayed_references(resources, additional_resource_type)
  additional_scratch_resources.concat(resources).uniq!

  assert !resources.empty?, no_resources_skip_message(additional_resource_type)

end

#run_reverse_chain_search_testObject



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 350

def run_reverse_chain_search_test
  resources =
    all_reverse_chain_search_params.flat_map do |_resource_id, params_list|
      params_list.flat_map do |params|
        fhir_search resource_type, params: params
        perform_search_with_status(params, resource_id) if response[:status] == 400 && possible_status_search?

        check_search_response

        returned_resources = fetch_all_bundled_resources(additional_resource_types: [additional_resource_type])
        input_based_skip_assert(returned_resources, "No resources found.")
        base_resources = returned_resources
          .select { |res| res.resourceType == resource_type }

        contextual_resources = run_search_on_additional_resource_type(reverse_chain_param)
        base_resources.each do |base_res| 
          assert (contextual_resources.any? do |res| 
            reference_value = search_param_value(reverse_chain_target, res)
            reference_value.nil? ? false : is_reference_match?(reference_value, search_param_value("_id", base_res))
          end), reverse_chaining_incorrect_reference_error_message(base_res)
        end  
        base_resources
      end
    end
    input_based_skip_assert(resources, "No resources found.")
end

#run_revinclude_search_testObject



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 231

def run_revinclude_search_test
  skip_if !any_valid_search_params?(all_revinclude_search_params), "Invalid parameter.  Please provide a different id for revinclude testing"
  resources =
    all_revinclude_search_params.flat_map do |_resource_id, params_list|
      params_list.flat_map do |params|
        fhir_search resource_type, params: params
        perform_search_with_status(params, resource_id) if response[:status] == 400 && possible_status_search?

        check_search_response
        
        matching_resources = fetch_all_bundled_resources(additional_resource_types: [additional_resource_type])
          .select { |res| res.resourceType == additional_resource_type }
          .reject { |res| res.id == params[:_id] }
        
        matching_resources.each { |res| check_resource_against_params(res, {"#{rev_param_sp}": "#{params[:_id]}"}) }
        matching_resources
      end
    end
  
  save_delayed_references(resources, additional_resource_type)
  additional_scratch_resources.concat(resources).uniq!

  input_based_skip_assert(resources, no_resources_skip_message(resource_type))
end

#run_search_no_params_test(profile_instance_id_string) ⇒ Object



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 269

def run_search_no_params_test(profile_instance_id_string)
   
  # read ids provided by user input
   if profile_instance_id_string
    input_instance_id_list = profile_instance_id_string.split(',').map(&:strip)

    input_instance_id_list.each do |id|
      fhir_read resource_type, id
      assert_response_status(200)
      assert_resource_type(resource_type)
      all_scratch_resources << resource
    end
  end

  # perform parameterless search for the profile's resourceType
  if no_param_search == 'true'
    fhir_search resource_type
  
    check_search_response
    
    resources_returned = fetch_matching_bundled_resources(max_pages: max_pages.to_i, max_instances: max_instances.to_i)

    if first_search? && !resources_returned.empty?
      all_scratch_resources.concat(resources_returned).uniq!
    end
  end

  info "Found #{all_scratch_resources.size} instances to use for testing profile #{.profile_name}."

  assert !all_scratch_resources.empty?, "No instances found for testing profile #{.profile_name}."

end

#run_search_on_additional_resource_type(param) ⇒ Object



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 302

def run_search_on_additional_resource_type(param)
  additional_resource_params = {"#{param}": additional_resource(param.to_sym)}
  skip_if !any_valid_search_params?(additional_resource_params), "Invalid Params"
    
  fhir_search additional_resource_type, params: additional_resource_params

  check_search_response
  additional_resources = fetch_all_bundled_resources(additional_resource_types: [additional_resource_type])
    .select { |res| res.resourceType == additional_resource_type }

  additional_resources.each { |res| check_resource_against_params(res, additional_resource_params) }

  save_delayed_references(additional_resources, additional_resource_type)
  additional_scratch_resources.concat(additional_resources).uniq!

  assert !additional_resources.empty?, "Search on #{additional_resource_type}'s #{param} failed to retrieve any resources."
  additional_resources
end

#run_search_testObject



256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 256

def run_search_test
  # TODO: skip if not supported?
  skip_if !any_valid_search_params?(all_search_params), unable_to_resolve_params_message
  resources_returned =
    all_search_params.flat_map do |resource_id, params_list|
      params_list.flat_map { |params| perform_search(params, resource_id) }
    end

  assert !resources_returned.empty?, no_resources_skip_message

  perform_multiple_or_search_test if multiple_or_search_params.present?
end

#save_delayed_references(resources, containing_resource_type = self.resource_type) ⇒ Object



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 1029

def save_delayed_references(resources, containing_resource_type = self.resource_type)
  resources.each do |resource|
    references_to_save(containing_resource_type).each do |reference_to_save|
      resolve_path(resource, reference_to_save[:path])
        .select { |reference| reference.is_a?(FHIR::Reference) && !reference.contained? }
        .each do |reference|
          resource_type = reference.resource_class.name.demodulize
          need_to_save = reference_to_save[:resources].include?(resource_type)
          next unless need_to_save

          save_resource_reference(resource_type, reference)
        end
    end
  end
end

#save_resource_reference(resource_type, reference) ⇒ Object



1023
1024
1025
1026
1027
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 1023

def save_resource_reference(resource_type, reference)
  scratch[:references] ||= {}
  scratch[:references][resource_type] ||= Set.new
  scratch[:references][resource_type] << reference
end

#scratch_resources_for_resource(resource_id) ⇒ Object



701
702
703
704
705
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 701

def scratch_resources_for_resource(resource_id)
  return all_scratch_resources if resource_id.nil?

  scratch_resources[resource_id] ||= []
end

#search_and_check_response(params, resource_type = self.resource_type) ⇒ Object



496
497
498
499
500
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 496

def search_and_check_response(params, resource_type = self.resource_type)
  fhir_search resource_type, params: params

  check_search_response
end

#search_param_paths(name, resource = resource_type) ⇒ Object



781
782
783
784
785
786
787
788
789
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 781

def search_param_paths(name, resource = resource_type)
   = resource == resource_type ?  : 
  paths = .search_definitions[name.to_sym][:paths]
  if paths.first =='class'
    paths[0] = 'local_class'
  end

  paths.map { |path| path.delete_prefix("Resource.") }  
end

#search_param_value(name, resource, include_system: false) ⇒ Object



953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 953

def search_param_value(name, resource, include_system: false)
  paths = search_param_paths(name, resource.resourceType)
  search_value = nil
  paths.each do |path|
    element = find_a_value_at(resource, path) { |element| element_has_valid_value?(element, include_system) }
    search_value =
      case element
      when FHIR::Period
        if element.start.present?
          'gt' + (DateTime.xmlschema(element.start) - 1).xmlschema
        else
          end_datetime = get_fhir_datetime_range(element.end)[:end]
          'lt' + (end_datetime + 1).xmlschema
        end
      when FHIR::Reference
        element.reference
      when FHIR::CodeableConcept
        if include_system
          coding =
            find_a_value_at(element, 'coding') { |coding| coding.code.present? && coding.system.present? }
          "#{coding.system}|#{coding.code}"
        else
          find_a_value_at(element, 'coding.code')
        end
      when FHIR::Identifier
        include_system ? "#{element.system}|#{element.value}" : element.value
      when FHIR::Coding
        include_system ? "#{element.system}|#{element.code}" : element.code
      when FHIR::HumanName
        element.family || element.given&.first || element.text
      when FHIR::Address
        element.text || element.city || element.state || element.postalCode || element.country
      when FHIR::Extension
        element.valueReference.reference #Should this be more flexible? Does it need to read for any value[x]?  PDEX Plan Net only
      else
        element
      end

    break if search_value.present?
  end

  escaped_value = search_value&.gsub(',', '\,')
  escaped_value
end

#search_param_values_from_same_resource(search_param_names, resource) ⇒ Object



760
761
762
763
764
765
766
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 760

def search_param_values_from_same_resource(search_param_names, resource)
  param_hash = search_param_names.each_with_object({}) do |name, params|
    value = search_param_value(name, resource)
    params[name] = value
  end
  param_hash
end

#search_params_with_values(search_param_names, resource_id, include_system: false) ⇒ Object



726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 726

def search_params_with_values(search_param_names, resource_id, include_system: false)
  resources = scratch_resources_for_resource(resource_id)
  if resources.empty?
    return search_param_names.each_with_object({}) do |name, params|
      value = resource_id_param?(name) ? resource_id : nil
      params[name] = value
    end
  end

  params_with_partial_value = resources.each_with_object({}) do |resource, outer_params|
    results_from_one_resource = search_param_names.each_with_object({}) do |name, params|
      value = search_param_value(name, resource, include_system: include_system)
      params[name] = value
    end

    outer_params.merge!(results_from_one_resource)

    # stop if all parameter values are found
    return outer_params if outer_params.all? { |_key, value| value.present? }
  end

  params_with_partial_value
end

#search_variant_test_recordsObject



508
509
510
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 508

def search_variant_test_records
  @search_variant_test_records ||= initial_search_variant_test_records
end

#set_additional_resource(additional_resource) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 51

def set_additional_resource(additional_resource)
  scratch[:additional_resource_for_test] ||= {}
  scratch[:additional_resource_for_test][:resource] = additional_resource
  scratch[:additional_resource_for_test][:id] = search_param_value("_id", additional_resource)
  scratch[:additional_resource_for_test][:"#{chain_param}"] = search_param_value(chain_param, additional_resource) if chain_param
  scratch[:additional_resource_for_test][:"#{inc_param_sp}"] = search_param_value(inc_param_sp, additional_resource) if inc_param_sp
  scratch[:additional_resource_for_test][:"#{rev_param_sp}"] = search_param_value(rev_param_sp, additional_resource) if rev_param_sp
  scratch[:additional_resource_for_test][:"#{reverse_chain_param}"] = search_param_value(reverse_chain_param, additional_resource) if reverse_chain_param
end

#status_search_param_nameObject



634
635
636
637
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 634

def status_search_param_name
  @status_search_param_name ||=
    .search_definitions.keys.find { |key| key.to_s.include? 'status' }
end

#status_search_valuesObject



639
640
641
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 639

def status_search_values
  default_search_values(status_search_param_name)
end

#unable_to_find_base_message(resource_type, param) ⇒ Object



803
804
805
806
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 803

def unable_to_find_base_message(resource_type, param)
  "Unable to find any #{resource_type} with the #{param} field populated from
  previously gathered resources. Please return more resources or provide a base id."
end

#unable_to_resolve_params_messageObject



799
800
801
# File 'lib/davinci_plan_net_test_kit/search_test.rb', line 799

def unable_to_resolve_params_message
  "Could not find values for all search params #{array_of_codes(search_param_names)}"
end