Profile reference param (#6501)
* updated QueryStack to not throw error with _profile as a ReferenceParam * update QueryStack * remove warnings * cleanup cast * cleanup test * add changelog * cleanup imports * updates per review feedback * updates per review feedback --------- Co-authored-by: taha.attari@smilecdr.com <taha.attari@smilecdr.com>
This commit is contained in:
parent
df642ac0cd
commit
890affc719
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 6502
|
||||
title: "Support ReferenceParam in addition to UriParam for `_profile` in queries using the SearchParameterMap to match the change in the specification from DSTU3 to R4."
|
|
@ -210,7 +210,7 @@ public class QueryStack {
|
|||
CoordsPredicateBuilder coordsBuilder = (CoordsPredicateBuilder) builder;
|
||||
|
||||
List<List<IQueryParameterType>> params = theParams.get(theParamName);
|
||||
if (params.size() > 0 && params.get(0).size() > 0) {
|
||||
if (!params.isEmpty() && !params.get(0).isEmpty()) {
|
||||
IQueryParameterType param = params.get(0).get(0);
|
||||
ParsedLocationParam location = ParsedLocationParam.from(theParams, param);
|
||||
double latitudeValue = location.getLatitudeValue();
|
||||
|
@ -2128,6 +2128,10 @@ public class QueryStack {
|
|||
if (nextParam.getModifier() == TokenParamModifier.NOT) {
|
||||
paramInverted = true;
|
||||
}
|
||||
} else if (nextOrParam instanceof ReferenceParam) {
|
||||
ReferenceParam nextParam = (ReferenceParam) nextOrParam;
|
||||
code = nextParam.getValue();
|
||||
system = null;
|
||||
} else {
|
||||
UriParam nextParam = (UriParam) nextOrParam;
|
||||
code = nextParam.getValue();
|
||||
|
@ -2154,8 +2158,10 @@ public class QueryStack {
|
|||
}
|
||||
}
|
||||
|
||||
UriParam nextParam = (UriParam) nextParamUncasted;
|
||||
if (isNotBlank(nextParam.getValue())) {
|
||||
if (nextParamUncasted instanceof ReferenceParam
|
||||
&& isNotBlank(((ReferenceParam) nextParamUncasted).getValue())) {
|
||||
return true;
|
||||
} else if (nextParamUncasted instanceof UriParam && isNotBlank(((UriParam) nextParamUncasted).getValue())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
@ -54,6 +55,25 @@ public class HapiFhirRepositoryR4Test extends BaseCrR4TestServer {
|
|||
assertTrue(crudTest(repository));
|
||||
}
|
||||
|
||||
@Test
|
||||
void _profileCanBeReferenceParam() {
|
||||
// as per https://www.hl7.org/fhir/r4/search.html#all _profile is a reference param
|
||||
var repository = new HapiFhirRepository(myDaoRegistry, setupRequestDetails(), myRestfulServer);
|
||||
var profileToFind = "http://www.a-test-profile.com";
|
||||
var encounterWithProfile = new Encounter();
|
||||
encounterWithProfile.getMeta().addProfile(profileToFind);
|
||||
repository.create(encounterWithProfile);
|
||||
repository.create(new Encounter());
|
||||
Map<String, List<IQueryParameterType>> map = new HashMap<>();
|
||||
map.put("_profile", Collections.singletonList(new ReferenceParam(profileToFind)));
|
||||
assertDoesNotThrow(() -> {
|
||||
var returnBundle = repository.search(Bundle.class, Encounter.class, map);
|
||||
assertTrue(returnBundle.hasEntry());
|
||||
assertEquals(1,returnBundle.getEntry().size());
|
||||
assertEquals(profileToFind, returnBundle.getEntryFirstRep().getResource().getMeta().getProfile().get(0).getValue());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Boolean crudTest(HapiFhirRepository theRepository) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue