This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 75fb2696eb19e05999ec704d49e42e776bd2c98d
Author: cjmamo <823038+cjm...@users.noreply.github.com>
AuthorDate: Mon Sep 30 19:51:05 2024 +0200

    feat: implement search by resource operation in FHIR component in order 
transmit sensitive search parameters in request body
---
 .../camel/component/fhir/api/FhirSearch.java       | 24 ++++++++++++++
 components/camel-fhir/camel-fhir-component/pom.xml |  2 ++
 .../component/fhir/FhirEndpointUriFactory.java     |  5 ++-
 .../fhir/FhirSearchEndpointConfiguration.java      | 37 ++++++++++++++++++++--
 .../FhirSearchEndpointConfigurationConfigurer.java | 23 ++++++++++++++
 .../component/fhir/internal/FhirApiCollection.java |  2 +-
 .../fhir/internal/FhirSearchApiMethod.java         |  8 +++++
 .../org/apache/camel/component/fhir/fhir.json      |  4 +--
 .../apache/camel/component/fhir/FhirSearchIT.java  | 27 ++++++++++++++++
 9 files changed, 126 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-fhir/camel-fhir-api/src/main/java/org/apache/camel/component/fhir/api/FhirSearch.java
 
b/components/camel-fhir/camel-fhir-api/src/main/java/org/apache/camel/component/fhir/api/FhirSearch.java
index 72195343eb3..fc5b7dd6062 100644
--- 
a/components/camel-fhir/camel-fhir-api/src/main/java/org/apache/camel/component/fhir/api/FhirSearch.java
+++ 
b/components/camel-fhir/camel-fhir-api/src/main/java/org/apache/camel/component/fhir/api/FhirSearch.java
@@ -16,8 +16,11 @@
  */
 package org.apache.camel.component.fhir.api;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
+import ca.uhn.fhir.rest.api.SearchStyleEnum;
 import ca.uhn.fhir.rest.client.api.IGenericClient;
 import ca.uhn.fhir.rest.gclient.IQuery;
 import org.hl7.fhir.instance.model.api.IBaseBundle;
@@ -51,4 +54,25 @@ public class FhirSearch {
         return query.execute();
     }
 
+    /**
+     * Perform a search by resource name.
+     *
+     * @param  resourceName     The resource to search for.
+     * @param  searchParameters A set of search parameters to the query.
+     * @param  searchStyle      Forces the query to perform the search using 
the given method (allowable methods are
+     *                          described in the <a 
href="http://www.hl7.org/fhir/search.html";>FHIR Search
+     *                          Specification</a>). The default search style 
is HTTP POST.
+     * @param  extraParameters  see {@link ExtraParameters} for a full list of 
parameters that can be passed, may be
+     *                          NULL
+     * @return                  the {@link IBaseBundle}
+     */
+    public IBaseBundle searchByResource(
+            String resourceName, Map<String, List<String>> searchParameters, 
SearchStyleEnum searchStyle,
+            Map<ExtraParameters, Object> extraParameters) {
+        IQuery<IBaseBundle> query = client.search().forResource(resourceName);
+        query.whereMap(Objects.requireNonNullElse(searchParameters, Map.of()));
+        query.usingStyle(Objects.requireNonNullElse(searchStyle, 
SearchStyleEnum.POST));
+        ExtraParameters.process(extraParameters, query);
+        return query.execute();
+    }
 }
diff --git a/components/camel-fhir/camel-fhir-component/pom.xml 
b/components/camel-fhir/camel-fhir-component/pom.xml
index 71dd5db541c..5e28583f282 100644
--- a/components/camel-fhir/camel-fhir-component/pom.xml
+++ b/components/camel-fhir/camel-fhir-component/pom.xml
@@ -284,6 +284,8 @@
                                     
<proxyClass>org.apache.camel.component.fhir.api.FhirSearch</proxyClass>
                                     <fromJavasource />
                                     <nullableOptions>
+                                        
<nullableOption>searchParameters</nullableOption>
+                                        
<nullableOption>searchStyle</nullableOption>
                                         
<nullableOption>extraParameters</nullableOption>
                                     </nullableOptions>
                                 </api>
diff --git 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirEndpointUriFactory.java
 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirEndpointUriFactory.java
index afb0b239d25..b4603a9ba2e 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirEndpointUriFactory.java
+++ 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirEndpointUriFactory.java
@@ -23,7 +23,7 @@ public class FhirEndpointUriFactory extends 
org.apache.camel.support.component.E
     private static final Set<String> SECRET_PROPERTY_NAMES;
     private static final Set<String> MULTI_VALUE_PREFIXES;
     static {
-        Set<String> props = new HashSet<>(81);
+        Set<String> props = new HashSet<>(84);
         props.add("accessToken");
         props.add("apiName");
         props.add("asynchronous");
@@ -77,6 +77,7 @@ public class FhirEndpointUriFactory extends 
org.apache.camel.support.component.E
         props.add("resource");
         props.add("resourceAsString");
         props.add("resourceClass");
+        props.add("resourceName");
         props.add("resourceType");
         props.add("resources");
         props.add("respondToUri");
@@ -88,6 +89,8 @@ public class FhirEndpointUriFactory extends 
org.apache.camel.support.component.E
         props.add("scheduledExecutorService");
         props.add("scheduler");
         props.add("schedulerProperties");
+        props.add("searchParameters");
+        props.add("searchStyle");
         props.add("sendEmptyMessageWhenIdle");
         props.add("serverUrl");
         props.add("sessionCookie");
diff --git 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfiguration.java
 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfiguration.java
index d813456ecc3..17ffac5c8e1 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfiguration.java
+++ 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfiguration.java
@@ -15,14 +15,23 @@ import org.apache.camel.spi.UriParams;
  */
 @ApiParams(apiName = "search", 
            description = "API to search for resources matching a given set of 
criteria",
-           apiMethods = {@ApiMethod(methodName = "searchByUrl", 
description="Perform a search directly by URL", 
signatures={"org.hl7.fhir.instance.model.api.IBaseBundle searchByUrl(String 
url, java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, Object> 
extraParameters)"})}, aliases = {})
+           apiMethods = {@ApiMethod(methodName = "searchByResource", 
description="Perform a search by resource name", 
signatures={"org.hl7.fhir.instance.model.api.IBaseBundle 
searchByResource(String resourceName, java.util.Map<String, 
java.util.List<String>> searchParameters, ca.uhn.fhir.rest.api.SearchStyleEnum 
searchStyle, java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
Object> extraParameters)"}), @ApiMethod(methodName = "searchByUrl", 
description="Perform a search  [...]
 @UriParams
 @Configurer(extended = true)
 public final class FhirSearchEndpointConfiguration extends FhirConfiguration {
     @UriParam
-    @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = 
"searchByUrl", description="See ExtraParameters for a full list of parameters 
that can be passed, may be NULL")})
+    @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = 
"searchByResource", description="See ExtraParameters for a full list of 
parameters that can be passed, may be NULL"), @ApiMethod(methodName = 
"searchByUrl", description="See ExtraParameters for a full list of parameters 
that can be passed, may be NULL")})
     private java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
Object> extraParameters;
     @UriParam
+    @ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = 
"searchByResource", description="The resource to search for")})
+    private String resourceName;
+    @UriParam
+    @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = 
"searchByResource", description="A set of search parameters to the query")})
+    private java.util.Map<String, java.util.List<String>> searchParameters;
+    @UriParam
+    @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = 
"searchByResource", description="Forces the query to perform the search using 
the given method (allowable methods are described in the FHIR Search 
Specification). The default search style is HTTP POST.")})
+    private ca.uhn.fhir.rest.api.SearchStyleEnum searchStyle;
+    @UriParam
     @ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = 
"searchByUrl", description="The URL to search for. Note that this URL may be 
complete (e.g. http://example.com/base/Patientname=foo) in which case the 
client's base URL will be ignored. Or it can be relative (e.g. Patientname=foo) 
in which case the client's base URL will be used.")})
     private String url;
 
@@ -34,6 +43,30 @@ public final class FhirSearchEndpointConfiguration extends 
FhirConfiguration {
         this.extraParameters = extraParameters;
     }
 
+    public String getResourceName() {
+        return resourceName;
+    }
+
+    public void setResourceName(String resourceName) {
+        this.resourceName = resourceName;
+    }
+
+    public java.util.Map<String, java.util.List<String>> getSearchParameters() 
{
+        return searchParameters;
+    }
+
+    public void setSearchParameters(java.util.Map<String, 
java.util.List<String>> searchParameters) {
+        this.searchParameters = searchParameters;
+    }
+
+    public ca.uhn.fhir.rest.api.SearchStyleEnum getSearchStyle() {
+        return searchStyle;
+    }
+
+    public void setSearchStyle(ca.uhn.fhir.rest.api.SearchStyleEnum 
searchStyle) {
+        this.searchStyle = searchStyle;
+    }
+
     public String getUrl() {
         return url;
     }
diff --git 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfigurationConfigurer.java
 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfigurationConfigurer.java
index f4614cfecf9..c892af6c84b 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfigurationConfigurer.java
+++ 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirSearchEndpointConfigurationConfigurer.java
@@ -42,6 +42,9 @@ public class FhirSearchEndpointConfigurationConfigurer 
extends org.apache.camel.
         map.put("ProxyPassword", java.lang.String.class);
         map.put("ProxyPort", java.lang.Integer.class);
         map.put("ProxyUser", java.lang.String.class);
+        map.put("ResourceName", java.lang.String.class);
+        map.put("SearchParameters", java.util.Map.class);
+        map.put("SearchStyle", ca.uhn.fhir.rest.api.SearchStyleEnum.class);
         map.put("ServerUrl", java.lang.String.class);
         map.put("SessionCookie", java.lang.String.class);
         map.put("SocketTimeout", java.lang.Integer.class);
@@ -91,6 +94,12 @@ public class FhirSearchEndpointConfigurationConfigurer 
extends org.apache.camel.
         case "proxyPort": target.setProxyPort(property(camelContext, 
java.lang.Integer.class, value)); return true;
         case "proxyuser":
         case "proxyUser": target.setProxyUser(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "resourcename":
+        case "resourceName": target.setResourceName(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "searchparameters":
+        case "searchParameters": 
target.setSearchParameters(property(camelContext, java.util.Map.class, value)); 
return true;
+        case "searchstyle":
+        case "searchStyle": target.setSearchStyle(property(camelContext, 
ca.uhn.fhir.rest.api.SearchStyleEnum.class, value)); return true;
         case "serverurl":
         case "serverUrl": target.setServerUrl(property(camelContext, 
java.lang.String.class, value)); return true;
         case "sessioncookie":
@@ -149,6 +158,12 @@ public class FhirSearchEndpointConfigurationConfigurer 
extends org.apache.camel.
         case "proxyPort": return java.lang.Integer.class;
         case "proxyuser":
         case "proxyUser": return java.lang.String.class;
+        case "resourcename":
+        case "resourceName": return java.lang.String.class;
+        case "searchparameters":
+        case "searchParameters": return java.util.Map.class;
+        case "searchstyle":
+        case "searchStyle": return ca.uhn.fhir.rest.api.SearchStyleEnum.class;
         case "serverurl":
         case "serverUrl": return java.lang.String.class;
         case "sessioncookie":
@@ -203,6 +218,12 @@ public class FhirSearchEndpointConfigurationConfigurer 
extends org.apache.camel.
         case "proxyPort": return target.getProxyPort();
         case "proxyuser":
         case "proxyUser": return target.getProxyUser();
+        case "resourcename":
+        case "resourceName": return target.getResourceName();
+        case "searchparameters":
+        case "searchParameters": return target.getSearchParameters();
+        case "searchstyle":
+        case "searchStyle": return target.getSearchStyle();
         case "serverurl":
         case "serverUrl": return target.getServerUrl();
         case "sessioncookie":
@@ -223,6 +244,8 @@ public class FhirSearchEndpointConfigurationConfigurer 
extends org.apache.camel.
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "extraparameters":
         case "extraParameters": return java.lang.Object.class;
+        case "searchparameters":
+        case "searchParameters": return java.util.List.class;
         default: return null;
         }
     }
diff --git 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirApiCollection.java
 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirApiCollection.java
index c57462a24e6..75918c582e0 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirApiCollection.java
+++ 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirApiCollection.java
@@ -86,7 +86,7 @@ public final class FhirApiCollection extends 
ApiCollection<FhirApiName, FhirConf
         apiMethods.put(FhirReadApiMethod.class, FhirApiName.READ);
 
         aliases.clear();
-        nullableArgs = Arrays.asList("extraParameters");
+        nullableArgs = Arrays.asList("searchParameters", "searchStyle", 
"extraParameters");
         apiHelpers.put(FhirApiName.SEARCH, new 
ApiMethodHelper<>(FhirSearchApiMethod.class, aliases, nullableArgs));
         apiMethods.put(FhirSearchApiMethod.class, FhirApiName.SEARCH);
 
diff --git 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirSearchApiMethod.java
 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirSearchApiMethod.java
index 8442c6e7863..057542881ce 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirSearchApiMethod.java
+++ 
b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/internal/FhirSearchApiMethod.java
@@ -19,6 +19,14 @@ import static 
org.apache.camel.support.component.ApiMethodArg.arg;
  */
 public enum FhirSearchApiMethod implements ApiMethod {
 
+    SEARCH_BY_RESOURCE(
+        org.hl7.fhir.instance.model.api.IBaseBundle.class,
+        "searchByResource",
+        arg("resourceName", String.class),
+        arg("searchParameters", java.util.Map.class),
+        arg("searchStyle", ca.uhn.fhir.rest.api.SearchStyleEnum.class),
+        arg("extraParameters", java.util.Map.class)),
+
     SEARCH_BY_URL(
         org.hl7.fhir.instance.model.api.IBaseBundle.class,
         "searchByUrl",
diff --git 
a/components/camel-fhir/camel-fhir-component/src/generated/resources/META-INF/org/apache/camel/component/fhir/fhir.json
 
b/components/camel-fhir/camel-fhir-component/src/generated/resources/META-INF/org/apache/camel/component/fhir/fhir.json
index f126f94585d..c123c747f67 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/generated/resources/META-INF/org/apache/camel/component/fhir/fhir.json
+++ 
b/components/camel-fhir/camel-fhir-component/src/generated/resources/META-INF/org/apache/camel/component/fhir/fhir.json
@@ -111,7 +111,7 @@
     "operation": { "consumerOnly": false, "producerOnly": false, 
"description": "API for extended FHIR operations", "methods": { "onInstance": { 
"description": "Perform the operation across all versions of a specific 
resource (by ID and type) on the server", "signatures": [ 
"org.hl7.fhir.instance.model.api.IBaseResource 
onInstance(org.hl7.fhir.instance.model.api.IIdType id, String name, 
org.hl7.fhir.instance.model.api.IBaseParameters parameters, 
Class<org.hl7.fhir.instance.model.api.IBas [...]
     "patch": { "consumerOnly": false, "producerOnly": false, "description": 
"API for the patch operation, which performs a logical patch on a server 
resource", "methods": { "patchById": { "description": "Applies the patch to the 
given resource ID", "signatures": [ "ca.uhn.fhir.rest.api.MethodOutcome 
patchById(String patchBody, String stringId, 
ca.uhn.fhir.rest.api.PreferReturnEnum preferReturn, 
java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, Object> 
extraParameters)",  [...]
     "read": { "consumerOnly": false, "producerOnly": false, "description": 
"API method for read operations", "methods": { "resourceById": { "description": 
"Reads a IBaseResource on the server by id", "signatures": [ 
"org.hl7.fhir.instance.model.api.IBaseResource 
resourceById(Class<org.hl7.fhir.instance.model.api.IBaseResource> resource, 
Long longId, String ifVersionMatches, Boolean returnNull, 
org.hl7.fhir.instance.model.api.IBaseResource returnResource, Boolean 
throwError, java.util.Map [...]
-    "search": { "consumerOnly": false, "producerOnly": false, "description": 
"API to search for resources matching a given set of criteria", "methods": { 
"searchByUrl": { "description": "Perform a search directly by URL", 
"signatures": [ "org.hl7.fhir.instance.model.api.IBaseBundle searchByUrl(String 
url, java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, Object> 
extraParameters)" ] } } },
+    "search": { "consumerOnly": false, "producerOnly": false, "description": 
"API to search for resources matching a given set of criteria", "methods": { 
"searchByResource": { "description": "Perform a search by resource name", 
"signatures": [ "org.hl7.fhir.instance.model.api.IBaseBundle 
searchByResource(String resourceName, java.util.Map<String, 
java.util.List<String>> searchParameters, ca.uhn.fhir.rest.api.SearchStyleEnum 
searchStyle, java.util.Map<org.apache.camel.component.fhir.api.E [...]
     "transaction": { "consumerOnly": false, "producerOnly": false, 
"description": "API for sending a transaction (collection of resources) to the 
server to be executed as a single unit", "methods": { "withBundle": { 
"description": "Use the given raw text (should be a Bundle resource) as the 
transaction input", "signatures": [ "String withBundle(String stringBundle, 
java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, Object> 
extraParameters)", "org.hl7.fhir.instance.model.a [...]
     "update": { "consumerOnly": false, "producerOnly": false, "description": 
"API for the update operation, which performs a logical delete on a server 
resource", "methods": { "resource": { "description": "Updates a IBaseResource 
on the server by id", "signatures": [ "ca.uhn.fhir.rest.api.MethodOutcome 
resource(String resourceAsString, String stringId, 
ca.uhn.fhir.rest.api.PreferReturnEnum preferReturn, 
java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, Object> 
extraParam [...]
     "validate": { "consumerOnly": false, "producerOnly": false, "description": 
"API for validating resources", "methods": { "resource": { "description": 
"Validates the resource", "signatures": [ "ca.uhn.fhir.rest.api.MethodOutcome 
resource(String resourceAsString, 
java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, Object> 
extraParameters)", "ca.uhn.fhir.rest.api.MethodOutcome 
resource(org.hl7.fhir.instance.model.api.IBaseResource resource, 
java.util.Map<org.apache.camel.c [...]
@@ -126,7 +126,7 @@
     "operation": { "methods": { "onInstance": { "properties": { 
"extraParameters": { "index": 0, "kind": "parameter", "displayName": "Extra 
Parameters", "group": "common", "label": "", "required": false, "type": 
"object", "javaType": 
"java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, 
"description": "See ExtraParameters for a full list of parameters that can be 
passed, may be NULL", "optional":  [...]
     "patch": { "methods": { "patchById": { "properties": { "extraParameters": 
{ "index": 1, "kind": "parameter", "displayName": "Extra Parameters", "group": 
"common", "label": "", "required": false, "type": "object", "javaType": 
"java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, 
"description": "See ExtraParameters for a full list of parameters that can be 
passed, may be NULL", "optional": true  [...]
     "read": { "methods": { "resourceById": { "properties": { 
"extraParameters": { "index": 5, "kind": "parameter", "displayName": "Extra 
Parameters", "group": "common", "label": "", "required": false, "type": 
"object", "javaType": 
"java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, 
"description": "See ExtraParameters for a full list of parameters that can be 
passed, may be NULL", "optional": tru [...]
-    "search": { "methods": { "searchByUrl": { "properties": { 
"extraParameters": { "index": 0, "kind": "parameter", "displayName": "Extra 
Parameters", "group": "common", "label": "", "required": false, "type": 
"object", "javaType": 
"java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, 
"description": "See ExtraParameters for a full list of parameters that can be 
passed, may be NULL", "optional": tr [...]
+    "search": { "methods": { "searchByResource": { "properties": { 
"extraParameters": { "index": 0, "kind": "parameter", "displayName": "Extra 
Parameters", "group": "common", "label": "", "required": false, "type": 
"object", "javaType": 
"java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, 
"description": "See ExtraParameters for a full list of parameters that can be 
passed, may be NULL", "optional [...]
     "transaction": { "methods": { "withBundle": { "properties": { "bundle": { 
"index": 0, "kind": "parameter", "displayName": "Bundle", "group": "common", 
"label": "", "required": false, "type": "object", "javaType": 
"org.hl7.fhir.instance.model.api.IBaseBundle", "deprecated": false, 
"autowired": false, "secret": false, "description": "Bundle to use in the 
transaction", "optional": false }, "extraParameters": { "index": 2, "kind": 
"parameter", "displayName": "Extra Parameters", "group":  [...]
     "update": { "methods": { "resource": { "properties": { "extraParameters": 
{ "index": 3, "kind": "parameter", "displayName": "Extra Parameters", "group": 
"common", "label": "", "required": false, "type": "object", "javaType": 
"java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, 
"description": "See ExtraParameters for a full list of parameters that can be 
passed, may be NULL", "optional": true  [...]
     "validate": { "methods": { "resource": { "properties": { 
"extraParameters": { "index": 1, "kind": "parameter", "displayName": "Extra 
Parameters", "group": "common", "label": "", "required": false, "type": 
"object", "javaType": 
"java.util.Map<org.apache.camel.component.fhir.api.ExtraParameters, 
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, 
"description": "See ExtraParameters for a full list of parameters that can be 
passed, may be NULL", "optional": tru [...]
diff --git 
a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirSearchIT.java
 
b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirSearchIT.java
index bc9315b4a3b..907c1744ee7 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirSearchIT.java
+++ 
b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirSearchIT.java
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.component.fhir;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.fhir.internal.FhirApiCollection;
 import org.apache.camel.component.fhir.internal.FhirSearchApiMethod;
@@ -27,6 +31,7 @@ import org.slf4j.LoggerFactory;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Test class for {@link org.apache.camel.component.fhir.api.FhirSearch} APIs. 
The class source won't be generated again
@@ -47,6 +52,23 @@ public class FhirSearchIT extends AbstractFhirTestSupport {
         Patient patient = (Patient) result.getEntry().get(0).getResource();
         assertNotNull(patient);
         assertEquals("Freeman", patient.getName().get(0).getFamily());
+        
assertTrue(result.getLinkFirstRep().getUrl().endsWith("/fhir/Patient?_format=json&family=Freeman&given=Vincent"));
+    }
+
+    @Test
+    public void testSearchByResource() {
+        String resourceName = "Patient";
+
+        Map<String, Object> headers = new HashMap<>();
+        headers.put("CamelFhir.searchParameters", Map.of("given", 
List.of("Vincent"), "family", List.of("Freeman")));
+        Bundle result = requestBodyAndHeaders("direct://SEARCH_BY_RESOURCE", 
resourceName, headers);
+
+        LOG.debug("searchByResource: {}", result);
+        assertNotNull(result, "searchByResource result");
+        Patient patient = (Patient) result.getEntry().get(0).getResource();
+        assertNotNull(patient);
+        assertEquals("Freeman", patient.getName().get(0).getFamily());
+        
assertTrue(result.getLinkFirstRep().getUrl().endsWith("/fhir/Patient/_search"));
     }
 
     @Override
@@ -57,7 +79,12 @@ public class FhirSearchIT extends AbstractFhirTestSupport {
                 from("direct://SEARCH_BY_URL")
                         .to("fhir://" + PATH_PREFIX + 
"/searchByUrl?inBody=url");
 
+                // test route for searchByResource
+                from("direct://SEARCH_BY_RESOURCE")
+                        .to("fhir://" + PATH_PREFIX
+                            + "/searchByResource?inBody=resourceName");
             }
+
         };
     }
 }

Reply via email to