mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-16 18:05:19 +00:00
MDM expansion doesn't work when using the :mdm qualifier in query string (#5803)
* wip * cleaning up test * adding changelog and passing spotless. --------- Co-authored-by: peartree <etienne.poirier@smilecdr.com>
This commit is contained in:
parent
4d4d8b25d4
commit
2f9693a1e4
@ -24,6 +24,7 @@ import ca.uhn.fhir.i18n.Msg;
|
|||||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
||||||
import ca.uhn.fhir.model.primitive.UriDt;
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
@ -147,18 +148,22 @@ public class TokenParam extends BaseParam /*implements IQueryParameterType*/ {
|
|||||||
@Override
|
@Override
|
||||||
void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theParameter) {
|
void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theParameter) {
|
||||||
setModifier(null);
|
setModifier(null);
|
||||||
|
setSystem(null);
|
||||||
|
|
||||||
if (theQualifier != null) {
|
if (theQualifier != null) {
|
||||||
|
if (Constants.PARAMQUALIFIER_MDM.equals(theQualifier)) {
|
||||||
|
setMdmExpand(true);
|
||||||
|
}
|
||||||
|
|
||||||
TokenParamModifier modifier = TokenParamModifier.forValue(theQualifier);
|
TokenParamModifier modifier = TokenParamModifier.forValue(theQualifier);
|
||||||
setModifier(modifier);
|
setModifier(modifier);
|
||||||
|
|
||||||
if (modifier == TokenParamModifier.TEXT) {
|
if (modifier == TokenParamModifier.TEXT) {
|
||||||
setSystem(null);
|
|
||||||
setValue(ParameterUtil.unescape(theParameter));
|
setValue(ParameterUtil.unescape(theParameter));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSystem(null);
|
|
||||||
if (theParameter == null) {
|
if (theParameter == null) {
|
||||||
setValue(null);
|
setValue(null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.rest.param;
|
|||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import ch.qos.logback.classic.Level;
|
import ch.qos.logback.classic.Level;
|
||||||
import ch.qos.logback.classic.Logger;
|
import ch.qos.logback.classic.Logger;
|
||||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
@ -132,6 +133,23 @@ public class StringParamTest {
|
|||||||
assertNicknameWarningLogged(false);
|
assertNicknameWarningLogged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNameNickname() {
|
||||||
|
StringParam param = new StringParam();
|
||||||
|
assertFalse(param.isNicknameExpand());
|
||||||
|
param.setValueAsQueryToken(myContext, "name", Constants.PARAMQUALIFIER_NICKNAME, "kenny");
|
||||||
|
assertTrue(param.isNicknameExpand());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGivenNickname() {
|
||||||
|
StringParam param = new StringParam();
|
||||||
|
assertFalse(param.isNicknameExpand());
|
||||||
|
param.setValueAsQueryToken(myContext, "given", Constants.PARAMQUALIFIER_NICKNAME, "kenny");
|
||||||
|
assertTrue(param.isNicknameExpand());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void assertNicknameQualifierSearchParameterIsValid(StringParam theStringParam, String theExpectedValue){
|
private void assertNicknameQualifierSearchParameterIsValid(StringParam theStringParam, String theExpectedValue){
|
||||||
assertTrue(theStringParam.isNicknameExpand());
|
assertTrue(theStringParam.isNicknameExpand());
|
||||||
assertFalse(theStringParam.isExact());
|
assertFalse(theStringParam.isExact());
|
||||||
@ -164,5 +182,5 @@ public class StringParamTest {
|
|||||||
assertTrue(warningLogs.isEmpty());
|
assertTrue(warningLogs.isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 5802
|
||||||
|
title: "Previously, using the ':mdm' qualifier with the '_id' search parameter would not included expanded resources in
|
||||||
|
search result. This issue has been fixed."
|
@ -2,14 +2,13 @@ package ca.uhn.fhir.rest.param;
|
|||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
public class TokenParamTest {
|
public class TokenParamTest {
|
||||||
private static final FhirContext ourCtx = FhirContext.forR4Cached();
|
private static final FhirContext ourCtx = FhirContext.forR4Cached();
|
||||||
@ -51,19 +50,16 @@ public class TokenParamTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameNickname() {
|
public void testMdmQualifier() {
|
||||||
StringParam param = new StringParam();
|
final String value = "Patient/PJANE1";
|
||||||
assertFalse(param.isNicknameExpand());
|
|
||||||
param.setValueAsQueryToken(ourCtx, "name", Constants.PARAMQUALIFIER_NICKNAME, "kenny");
|
TokenParam param = new TokenParam();
|
||||||
assertTrue(param.isNicknameExpand());
|
param.setValueAsQueryToken(ourCtx, "_id", Constants.PARAMQUALIFIER_MDM, value);
|
||||||
|
assertNull(param.getModifier());
|
||||||
|
assertNull(param.getSystem());
|
||||||
|
assertTrue(param.isMdmExpand());
|
||||||
|
assertEquals(value, param.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGivenNickname() {
|
|
||||||
StringParam param = new StringParam();
|
|
||||||
assertFalse(param.isNicknameExpand());
|
|
||||||
param.setValueAsQueryToken(ourCtx, "given", Constants.PARAMQUALIFIER_NICKNAME, "kenny");
|
|
||||||
assertTrue(param.isNicknameExpand());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user