Merge branch 'rel_7_4' into rel_7_4_mb_20240813

This commit is contained in:
Tadgh 2024-08-19 16:36:49 -07:00
commit a3f19a1b15
4 changed files with 49 additions and 6 deletions

View File

@ -56,7 +56,7 @@ public interface IAnyResource extends IBaseResource {
@SearchParamDefinition( @SearchParamDefinition(
name = SP_RES_LAST_UPDATED, name = SP_RES_LAST_UPDATED,
path = "Resource.meta.lastUpdated", path = "Resource.meta.lastUpdated",
description = "The last updated date of the resource", description = "Only return resources which were last updated as specified by the given range",
type = "date") type = "date")
/** /**

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 6208
title: "A regression was temporarily introduced which caused searches by `_lastUpdated` to fail with a NullPointerException when using Lucene as the backing search engine. This has been corrected"

View File

@ -29,6 +29,7 @@ import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.UriDt; import ca.uhn.fhir.model.primitive.UriDt;
import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.parser.StrictErrorHandler; import ca.uhn.fhir.parser.StrictErrorHandler;
import ca.uhn.fhir.rest.api.CacheControlDirective;
import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.api.PreferReturnEnum;
@ -1112,6 +1113,34 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
} }
@Test
public void testSearchByUrl() {
// setup
DateType dt = new DateType(new Date());
String nowStr = dt.getValueAsString();
boolean storeResourceInHSearch = myStorageSettings.isStoreResourceInHSearchIndex();
boolean advancedHSearch = myStorageSettings.isAdvancedHSearchIndexing();
try {
// use full text search
myStorageSettings.setStoreResourceInHSearchIndex(true);
myStorageSettings.setAdvancedHSearchIndexing(true);
// test
Bundle b = myClient.search()
.byUrl("Patient?_lastUpdated=" + nowStr)
.returnBundle(Bundle.class)
.cacheControl(CacheControlDirective.noCache())
.execute();
assertNotNull(b);
} finally {
// reset back to previous
myStorageSettings.setAdvancedHSearchIndexing(advancedHSearch);
myStorageSettings.setStoreResourceInHSearchIndex(storeResourceInHSearch);
}
}
@Test @Test
public void testCreateConditionalWithPreferRepresentation() { public void testCreateConditionalWithPreferRepresentation() {
Patient p = new Patient(); Patient p = new Patient();

View File

@ -121,9 +121,12 @@ public class ${className}ResourceProvider extends
@RawParam @RawParam
Map<String, List<String>> theAdditionalRawParams, Map<String, List<String>> theAdditionalRawParams,
##DSTU2 is not an IAnyResource, yet supports LastUpdated, so we keep the magic SP in this case.
#if ( $version == 'dstu2' )
@Description(shortDefinition="Only return resources which were last updated as specified by the given range") @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
@OptionalParam(name="_lastUpdated") @OptionalParam(name="_lastUpdated")
DateRangeParam theLastUpdated, DateRangeParam the_lastUpdated,
#end
@IncludeParam @IncludeParam
Set<Include> theIncludes, Set<Include> theIncludes,
@ -161,12 +164,19 @@ public class ${className}ResourceProvider extends
paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_LANGUAGE, theResourceLanguage); paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_LANGUAGE, theResourceLanguage);
paramMap.add("_has", theHas); paramMap.add("_has", theHas);
#foreach ( $param in $searchParams ) #foreach ( $param in $searchParams )
paramMap.add("${param.name}", the${param.nameCapitalized}); #if( ${param.name} == "_lastUpdated")
## Skip Last Updated since its handled by param defined below.
#else
paramMap.add("${param.name}", the${param.nameCapitalized});
#end
#end #end
#if ( $version != 'dstu' ) #if ( $version != 'dstu' )
paramMap.setRevIncludes(theRevIncludes); paramMap.setRevIncludes(theRevIncludes);
paramMap.setLastUpdated(theLastUpdated); ## Note that since we have added an SearchParamDefinition on IAnyResource for this, we had to remove
## the magic _lastUpdated that was previously hardcoded as an OperationParam. However, we still need to populate
## This special variable in the SP map.
paramMap.setLastUpdated(the_lastUpdated);
#end #end
paramMap.setIncludes(theIncludes); paramMap.setIncludes(theIncludes);
paramMap.setSort(theSort); paramMap.setSort(theSort);