diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java index 7ce8cd16bfe..bf371971207 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java @@ -96,6 +96,36 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { } + @Test + public void testSearchBySourceTransactionId() { + + Patient p1 = new Patient(); + p1.setActive(true); + ourClient + .create() + .resource(p1) + .withAdditionalHeader(Constants.HEADER_REQUEST_ID, "11111") + .execute(); + + Patient p2 = new Patient(); + p2.setActive(true); + ourClient + .create() + .resource(p2) + .withAdditionalHeader(Constants.HEADER_REQUEST_ID, "22222") + .execute(); + + Bundle results = ourClient + .search() + .byUrl(ourServerBase + "/Patient?_source=%2311111") + .returnBundle(Bundle.class) + .execute(); + + assertEquals(1, results.getEntry().size()); + + } + + @Test public void testSearchByExternalReference() { myDaoConfig.setAllowExternalReferences(true); @@ -4063,7 +4093,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { ourLog.info(resp); assertEquals(412, response.getStatusLine().getStatusCode()); assertThat(resp, not(containsString("Resource has no id"))); - assertThat(resp, containsString("")); + assertThat(resp, containsString("")); } finally { IOUtils.closeQuietly(response.getEntity().getContent()); response.close(); diff --git a/hapi-tinder-plugin/src/main/resources/vm/jpa_resource_provider.vm b/hapi-tinder-plugin/src/main/resources/vm/jpa_resource_provider.vm index 9540cc488b2..77ffd948fbf 100644 --- a/hapi-tinder-plugin/src/main/resources/vm/jpa_resource_provider.vm +++ b/hapi-tinder-plugin/src/main/resources/vm/jpa_resource_provider.vm @@ -65,7 +65,11 @@ public class ${className}ResourceProvider extends @Description(shortDefinition="Search for resources which have the given profile") @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE) - UriAndListParam theSearchForProfile, + UriAndListParam theSearchForProfile, + + @Description(shortDefinition="Search for resources which have the given source value (Resource.meta.source)") + @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE) + UriAndListParam theSearchForSource, @Description(shortDefinition="Return resources linked to by the given target") @OptionalParam(name="_has") @@ -143,6 +147,7 @@ public class ${className}ResourceProvider extends paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag); paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity); paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile); + paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource); paramMap.add("_has", theHas); #foreach ( $param in $searchParams ) paramMap.add("${param.name}", the${param.nameCapitalized}); diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 9301026d616..6abe975bb21 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -31,7 +31,8 @@ New Feature: - The JPA server now saves and supports searching on Resource.meta.source. The server automatically + The JPA server now saves and supports searching on Resource.meta.source via the + _source search parameter. The server automatically appends the Request ID as a hash value on the URI as well in order to provide request level tracking. Searches can use either the source URI, the request ID, or both. ]]>