Merge branch 'master' into minute_precision_in_searchparams

This commit is contained in:
James Agnew 2017-06-12 11:50:01 -04:00 committed by GitHub
commit d59b832e74
3 changed files with 79 additions and 26 deletions

View File

@ -76,13 +76,6 @@ import ca.uhn.fhir.context.RuntimeChildChoiceDefinition;
import ca.uhn.fhir.context.RuntimeChildResourceDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IDao;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
import ca.uhn.fhir.jpa.dao.data.IForcedIdDao;
import ca.uhn.fhir.jpa.dao.data.IResourceIndexedSearchParamUriDao;
import ca.uhn.fhir.jpa.entity.BaseHasResource;
@ -1768,6 +1761,39 @@ public class SearchBuilder implements ISearchBuilder {
}
private void searchForIdsWithAndOr(String theResourceName, String theParamName, List<List<? extends IQueryParameterType>> theAndOrParams) {
for (int andListIdx = 0; andListIdx < theAndOrParams.size(); andListIdx++) {
List<? extends IQueryParameterType> nextOrList = theAndOrParams.get(andListIdx);
for (int orListIdx = 0; orListIdx < nextOrList.size(); orListIdx++) {
IQueryParameterType nextOr = nextOrList.get(orListIdx);
boolean hasNoValue = false;
if (nextOr.getMissing() != null) {
continue;
}
if (nextOr instanceof QuantityParam) {
if (isBlank(((QuantityParam) nextOr).getValueAsString())) {
hasNoValue = true;
}
}
if (hasNoValue) {
ourLog.debug("Ignoring empty parameter: {}", theParamName);
nextOrList.remove(orListIdx);
orListIdx--;
}
}
if (nextOrList.isEmpty()) {
theAndOrParams.remove(andListIdx);
andListIdx--;
}
}
if (theAndOrParams.isEmpty()) {
return;
}
if (theParamName.equals(BaseResource.SP_RES_ID)) {
addPredicateResourceId(theAndOrParams);

View File

@ -97,6 +97,33 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
myDaoConfig.setAllowMultipleDelete(true);
}
@Test
public void testSearchWithEmptyParameter() throws Exception {
Observation obs= new Observation();
obs.setStatus(ObservationStatus.FINAL);
obs.getCode().addCoding().setSystem("foo").setCode("bar");
ourClient.create().resource(obs).execute();
testSearchWithEmptyParameter("/Observation?value-quantity=");
testSearchWithEmptyParameter("/Observation?code=bar&value-quantity=");
testSearchWithEmptyParameter("/Observation?value-date=");
testSearchWithEmptyParameter("/Observation?code=bar&value-date=");
testSearchWithEmptyParameter("/Observation?value-concept=");
testSearchWithEmptyParameter("/Observation?code=bar&value-concept=");
}
private void testSearchWithEmptyParameter(String url) throws IOException, ClientProtocolException {
HttpGet get = new HttpGet(ourServerBase + url);
CloseableHttpResponse resp = ourHttpClient.execute(get);
try {
assertEquals(200, resp.getStatusLine().getStatusCode());
String respString = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, respString);
assertEquals(1, bundle.getEntry().size());
} finally {
IOUtils.closeQuietly(resp.getEntity().getContent());
}
}
@Test
public void testSearchWithMissingDate2() throws Exception {
@ -121,8 +148,6 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
IOUtils.closeQuietly(resp);
}
}
@Test
@ -144,8 +169,6 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
assertEquals(1, response.getEntry().size());
}
@Test
public void testSaveAndRetrieveResourceWithExtension() {
Patient nextPatient = new Patient();

View File

@ -28,6 +28,10 @@
Allow DateParam (used in servers) to handle values with MINUTE precision. Thanks to
Christian Ohr for the pull request!
</action>
<action type="fix">
Fix HTTP 500 error in JPA server if a numeric search parameter was supplied with no value, e.g.
<![CDATA[<code>GET /Observation?value-quantity=</code>]]>
</action>
</release>
<release version="2.5" date="2017-06-08">
<action type="fix">