title: Hapi Fhir query with AND / OR with map
body: <p>Using Hapi Fhir, I try to write a query to use a map to pass in where condition, as follow:</p>
  <pre><code>Map&lt;String, List&lt;IQueryParameterType&gt;&gt; hmParameter = criteria.getMapForWhere();
  
  Bundle bundle = fhirClientR4Configuration.clientFhihrR4().search().forResource(ServiceRequest.class)
              .where(hmParameter).returnBundle(Bundle.class).execute();
  </code></pre>
  <p>My criteria object has a method <code>getMapForWhere()</code> where I populate this map with information inside my wrapper front end object as follow:</p>
  <pre><code>public Map&lt;String, List&lt;IQueryParameterType&gt;&gt; getMapForWhere() {
      Map&lt;String, List&lt;IQueryParameterType&gt;&gt; hmOut = new HashMap&lt;String, List&lt;IQueryParameterType&gt;&gt;();
      // Adding STATUS
      if (this.status != null &amp;&amp; !this.status.equals(&quot;&quot;)) {
          StringParam sp = new StringParam();
          sp.setValue(this.status);
          List&lt;IQueryParameterType&gt; lst = new ArrayList&lt;IQueryParameterType&gt;();
          lst.add(sp);
          hmOut.put(ServiceRequest.SP_STATUS, lst);
      }
  
      // Adding INTENT
      if (this.intent != null &amp;&amp; !this.intent.equals(&quot;&quot;)) {
          StringParam sp = new StringParam();
          sp.setValue(this.intent);
          List&lt;IQueryParameterType&gt; lst = new ArrayList&lt;IQueryParameterType&gt;();
          lst.add(sp);
          hmOut.put(ServiceRequest.SP_INTENT, lst);
      }
  
      return hmOut;
  }
  </code></pre>
  <p>This code works fine when I want to wirte a query with all AND.</p>
  <p>But if I want to add another condition as follow:</p>
  <pre><code>    List&lt;IQueryParameterOr&gt; lstOr = new ArrayList&lt;IQueryParameterOr&gt;();
      
      StringOrListParam lstServices = new StringOrListParam();
      
      StringParam sp = new StringParam();
      StringParam sg = new StringParam();
      
      sp.setValue(MEDICAL_SERVICE_PAI);
      sg.setValue(SOCIAL_SERVICE_PAI);
      lstServices.addOr(sp);
      lstServices.addOr(sg);
      lstOr.add(lstServices);
      
      hmOut.put(ServiceRequest.SP_CATEGORY, lstOr);
  </code></pre>
  <p>Obviously hmOut goes in error because definition of that map is different. But I don't know how to convert <code>IParameterOr</code> with <code>IParameterType</code>.</p>