Correctly handle searching by source in JPA server
This commit is contained in:
parent
be3ce538ed
commit
0d3f7d4a03
|
@ -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("<issue><severity value=\"error\"/><code value=\"processing\"/><diagnostics value=\"SHALL at least contain a contact's details or a reference to an organization [name.exists() or telecom.exists() or address.exists() or organization.exists()]\"/><location value=\"Patient.contact[0]\"/><location value=\"Line 0, Col 0\"/></issue>"));
|
||||
assertThat(resp, containsString("<issue><severity value=\"error\"/><code value=\"processing\"/><diagnostics value=\"SHALL at least contain a contact's details or a reference to an organization [name.exists() or telecom.exists() or address.exists() or organization.exists()]\"/><location value=\"Patient.contact[0]\"/><location value=\"Line 0, Col 0\"/></issue>"));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.close();
|
||||
|
|
|
@ -67,6 +67,10 @@ public class ${className}ResourceProvider extends
|
|||
@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
|
||||
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")
|
||||
HasAndListParam theHas,
|
||||
|
@ -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});
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
<action type="add">
|
||||
<![CDATA[
|
||||
<b>New Feature</b>:
|
||||
The JPA server now saves and supports searching on <code>Resource.meta.source</code>. The server automatically
|
||||
The JPA server now saves and supports searching on <code>Resource.meta.source</code> via the
|
||||
<code>_source</code> 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.
|
||||
]]>
|
||||
|
|
Loading…
Reference in New Issue