fixing canonical search (#6105)
This commit is contained in:
parent
d2c12a7ac3
commit
875b224ac6
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 6094
|
||||
title: "Fix for regression of searches for canonical uris using a version
|
||||
(eg: http://example.com|1.2.3).
|
||||
"
|
|
@ -2171,14 +2171,32 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
if (parsed.isAbsolute()) {
|
||||
String refValue =
|
||||
fakeReference.getReferenceElement().getValue();
|
||||
|
||||
myPathAndRef = new PathAndRef(theSearchParam.getName(), thePath, fakeReference, true);
|
||||
theParams.add(myPathAndRef);
|
||||
|
||||
/*
|
||||
* If we have a versioned canonical uri,
|
||||
* we will index both the version and unversioned uri
|
||||
* (ie: uri|version and uri)
|
||||
* This will allow searching to work on both versioned and non-versioned.
|
||||
*
|
||||
* HOWEVER
|
||||
* This doesn't actually fix chained searching (MeasureReport?measure.identifier=...)
|
||||
*/
|
||||
if (refValue.contains("|")) {
|
||||
// extract the non-versioned AND the versioned above so both searches work.
|
||||
fakeReference = (IBaseReference) myContext
|
||||
.getElementDefinition("Reference")
|
||||
.newInstance();
|
||||
fakeReference.setReference(refValue.substring(0, refValue.indexOf('|')));
|
||||
}
|
||||
|
||||
myPathAndRef = new PathAndRef(theSearchParam.getName(), thePath, fakeReference, true);
|
||||
theParams.add(myPathAndRef);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
theParams.addWarning("Ignoring canonical reference (indexing canonical is not yet supported)");
|
||||
|
|
|
@ -48,6 +48,7 @@ import java.util.stream.IntStream;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
@ -121,7 +122,6 @@ public class FhirResourceDaoR4SearchIncludeTest extends BaseJpaR4Test {
|
|||
qrIrrelevant.setQuestionnaire("http://fooIrrelevant");
|
||||
myQuestionnaireResponseDao.update(qrIrrelevant, mySrd);
|
||||
|
||||
|
||||
IBundleProvider outcome;
|
||||
IFhirResourceDao<?> dao;
|
||||
SearchParameterMap map;
|
||||
|
@ -182,7 +182,11 @@ public class FhirResourceDaoR4SearchIncludeTest extends BaseJpaR4Test {
|
|||
// (or somehow made things worse) and the search for the canonical target is no longer the 4th
|
||||
// SQL query
|
||||
assertThat(searchForCanonicalReferencesQuery.getSql(true, false)).contains("rispu1_0.HASH_IDENTITY in ('-600769180185160063')");
|
||||
assertThat(searchForCanonicalReferencesQuery.getSql(true, false)).contains("rispu1_0.SP_URI in ('http://foo')");
|
||||
assertTrue(
|
||||
searchForCanonicalReferencesQuery.getSql(true, false).contains("rispu1_0.SP_URI in ('http://foo')")
|
||||
|| searchForCanonicalReferencesQuery.getSql(true, false).contains("rispu1_0.SP_URI in ('http://foo','http://foo|1.0')"),
|
||||
searchForCanonicalReferencesQuery.getSql(true, false)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -515,6 +515,49 @@ public class FhirResourceDaoR4StandardQueriesNoFTTest extends BaseJpaTest {
|
|||
myTestDaoSearch.assertSearchFindsOnly("search by server assigned id", "Patient?family=smith&_pid=" + id, id);
|
||||
}
|
||||
|
||||
@Nested
|
||||
public class CanonicalReferences {
|
||||
|
||||
@Test
|
||||
void testCanonicalReferenceSearchNoVersion() {
|
||||
// given
|
||||
IIdType reportId = myDataBuilder.createResourceFromJson("""
|
||||
{
|
||||
"resourceType": "MeasureReport",
|
||||
"measure": "http://StructureDefinition.com"
|
||||
}
|
||||
""");
|
||||
|
||||
myTestDaoSearch.assertSearchNotFound("unversioned search finds MeasureReport by canonical reference",
|
||||
"MeasureReport?measure=http://StructureDefinition.com|1.2.3", reportId);
|
||||
myTestDaoSearch.assertSearchFinds("versioned search finds MeasureReport by canonical reference with right version",
|
||||
"MeasureReport?measure=http://StructureDefinition.com", reportId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hapi bug - https://github.com/hapifhir/hapi-fhir/issues/6094
|
||||
*/
|
||||
@Test
|
||||
void testCanonicalReferenceSearch() {
|
||||
// given
|
||||
IIdType reportId = myDataBuilder.createResourceFromJson("""
|
||||
{
|
||||
"resourceType": "MeasureReport",
|
||||
"measure": "http://StructureDefinition.com|1.2.3"
|
||||
}
|
||||
""");
|
||||
|
||||
// when
|
||||
myTestDaoSearch.assertSearchFinds("unversioned search finds MeasureReport by canonical reference",
|
||||
"MeasureReport?measure=http://StructureDefinition.com", reportId);
|
||||
myTestDaoSearch.assertSearchFinds("versioned search finds MeasureReport by canonical reference with right version",
|
||||
"MeasureReport?measure=http://StructureDefinition.com|1.2.3", reportId);
|
||||
myTestDaoSearch.assertSearchNotFound("versioned search does not find MeasureReport by canonical reference with wrong version",
|
||||
"MeasureReport?measure=http://StructureDefinition.com|2.0", reportId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSortByPid() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue