Supported search (#3549)
* wip * Revert some work * Add changelog * refactor method into SeachParamRegistryImpl * Javadocs
This commit is contained in:
parent
578d42c955
commit
612ee0af32
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 3548
|
||||
jira: SMILE-4023
|
||||
title: "A recent change caused searches that use _has in conjuction with a `Resource` search param (e.g. _id, _text) to fail. This has been fixed."
|
||||
|
|
@ -546,17 +546,12 @@ public class QueryStack {
|
|||
//Ensure that the name of the search param
|
||||
// (e.g. the `code` in Patient?_has:Observation:subject:code=sys|val)
|
||||
// exists on the target resource type.
|
||||
RuntimeSearchParam owningParameterDef = mySearchParamRegistry.getActiveSearchParam(targetResourceType, paramName);
|
||||
if (owningParameterDef == null) {
|
||||
throw new InvalidRequestException(Msg.code(1209) + "Unknown parameter name: " + targetResourceType + ':' + parameterName);
|
||||
}
|
||||
RuntimeSearchParam owningParameterDef = mySearchParamRegistry.getRuntimeSearchParam(targetResourceType, paramName);
|
||||
|
||||
//Ensure that the name of the back-referenced search param on the target (e.g. the `subject` in Patient?_has:Observation:subject:code=sys|val)
|
||||
//exists on the target resource.
|
||||
RuntimeSearchParam joiningParameterDef = mySearchParamRegistry.getActiveSearchParam(targetResourceType, paramReference);
|
||||
if (joiningParameterDef == null) {
|
||||
throw new InvalidRequestException(Msg.code(1210) + "Unknown parameter name: " + targetResourceType + ':' + paramReference);
|
||||
}
|
||||
//exists on the target resource, or in the top-level Resource resource.
|
||||
mySearchParamRegistry.getRuntimeSearchParam(targetResourceType, paramReference);
|
||||
|
||||
|
||||
IQueryParameterAnd<?> parsedParam = JpaParamUtil.parseQueryParams(mySearchParamRegistry, myFhirContext, owningParameterDef, paramName, parameters);
|
||||
|
||||
|
|
|
@ -499,7 +499,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
myPatientDao.search(params);
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
assertEquals(Msg.code(1210) + "Unknown parameter name: Observation:soooooobject", e.getMessage());
|
||||
assertEquals(Msg.code(1209) + "Unknown parameter name: Observation:soooooobject", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1157,7 +1157,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
myPatientDao.search(params);
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
assertEquals(Msg.code(1210) + "Unknown parameter name: Observation:soooooobject", e.getMessage());
|
||||
assertEquals(Msg.code(1209) + "Unknown parameter name: Observation:soooooobject", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -639,7 +639,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
myPatientDao.search(params);
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
assertEquals(Msg.code(1210) + "Unknown parameter name: Observation:soooooobject", e.getMessage());
|
||||
assertEquals(Msg.code(1209) + "Unknown parameter name: Observation:soooooobject", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ import java.util.IdentityHashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
|
|
@ -22,7 +22,9 @@ package ca.uhn.fhir.rest.server.util;
|
|||
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.context.phonetic.IPhoneticEncoder;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -40,6 +42,7 @@ public interface ISearchParamRegistry {
|
|||
*/
|
||||
RuntimeSearchParam getActiveSearchParam(String theResourceName, String theParamName);
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns all active search params for the given resource
|
||||
*/
|
||||
|
@ -57,7 +60,6 @@ public interface ISearchParamRegistry {
|
|||
default void requestRefresh() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* When indexing a HumanName, if a StringEncoder is set in the context, then the "phonetic" search parameter will normalize
|
||||
* the String using this encoder.
|
||||
|
@ -101,4 +103,22 @@ public interface ISearchParamRegistry {
|
|||
@Nullable
|
||||
RuntimeSearchParam getActiveSearchParamByUrl(String theUrl);
|
||||
|
||||
/**
|
||||
* Find a search param for a resource. First, check the resource itself, then check the top-level `Resource` resource.
|
||||
*
|
||||
* @param theResourceType the resource type.
|
||||
* @param theParamName the search parameter name.
|
||||
*
|
||||
* @return the {@link RuntimeSearchParam} that is found.
|
||||
*/
|
||||
default RuntimeSearchParam getRuntimeSearchParam(String theResourceType, String theParamName) {
|
||||
RuntimeSearchParam availableSearchParamDef = getActiveSearchParam(theResourceType, theParamName);
|
||||
if (availableSearchParamDef == null) {
|
||||
availableSearchParamDef = getActiveSearchParam("Resource", theParamName);
|
||||
}
|
||||
if (availableSearchParamDef == null) {
|
||||
throw new InvalidRequestException(Msg.code(1209) + "Unknown parameter name: " + theResourceType + ':' + theParamName);
|
||||
}
|
||||
return availableSearchParamDef;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue