Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
type: fix
issue: 7384
jira: SMILE-11171
title: "When MDM expansion search was enabled, search operations with chained references returned 404 Not Found errors.
The OperationOutcome in the response indicated that the wrong resource name had been used for the search.
This issue has now been resolved.
"
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
import ca.uhn.fhir.rest.param.TokenParam;
import jakarta.servlet.http.HttpServletRequest;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.AllergyIntolerance;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Reference;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

Expand All @@ -36,10 +38,13 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.slf4j.LoggerFactory.getLogger;

@ContextConfiguration(classes = {MdmHelperConfig.class})
public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {

private static final Logger ourLog = getLogger(MdmSearchExpandingInterceptorIT.class);

@RegisterExtension
@Autowired
public MdmHelperR4 myMdmHelper;
Expand Down Expand Up @@ -266,6 +271,32 @@ public void testReferenceExpansionQuietlyFailsOnMissingMdmMatches() throws Inter
assertEquals(1, search.size());
}

@Test
public void testChainedReferenceSearch_whenMdmExpansionEnabled_shouldGetSearchResult() throws InterruptedException {
// setup
myStorageSettings.setAllowMdmExpansion(true);

Patient patient = buildResource(("Patient"), withIdentifier("http://foo.bar/test", "abc"));
String pid = myMdmHelper.executeWithLatch(() -> myMdmHelper.doCreateResource(patient, true)).getId().getIdPart();
AllergyIntolerance allergy = new AllergyIntolerance();
allergy.setPatient(new Reference("Patient/" + pid));
doCreateResource(allergy);

SearchParameterMap paramMap = new SearchParameterMap();
ReferenceParam param = new ReferenceParam("identifier", "http://foo.bar/test|abc");
param.setValueAsQueryToken(myFhirContext, "patient", ":Patient.identifier", "http://foo.bar/test|abc");
paramMap.add("patient", param);

// execute
myCaptureQueriesListener.clear();
IBundleProvider search = myAllergyIntoleranceDao.search(paramMap, mySrd);
myCaptureQueriesListener.logAllQueriesForCurrentThread();

// validate
assertEquals(1, search.size());
ourLog.info(myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, true));
}

private Observation createObservationWithSubject(String thePatientId) {
Observation observation = new Observation();
observation.setSubject(new Reference("Patient/" + thePatientId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private void expandAnyReferenceParameters(
List<IQueryParameterType> toRemove = new ArrayList<>();
List<IQueryParameterType> toAdd = new ArrayList<>();
for (IQueryParameterType iQueryParameterType : orList) {
if (iQueryParameterType instanceof ReferenceParam refParam) {
if (iQueryParameterType instanceof ReferenceParam refParam && !refParam.hasChain()) {
if (theParamTester.shouldExpand(theParamName, refParam)) {
ourLog.debug("Found a reference parameter to expand: {}", refParam);
// First, attempt to expand as a source resource.
Expand Down
Loading