Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Nov 15, 2024
1 parent 2aadbec commit 983f4b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package ca.uhn.fhir.jpa.mdm.interceptor;

import ca.uhn.fhir.interceptor.api.Hook;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor;
import ca.uhn.fhir.interceptor.api.IPointcut;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
import ca.uhn.fhir.jpa.mdm.helper.MdmHelperConfig;
import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4;
import ca.uhn.fhir.jpa.mdm.helper.MdmLinkHelper;
import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMLinkResults;
import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMState;
import ca.uhn.fhir.jpa.model.dao.JpaPid;
import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.mdm.interceptor.MdmReadVirtualizationInterceptor;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
Expand All @@ -34,7 +28,6 @@
import org.springframework.test.context.ContextConfiguration;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -166,7 +159,7 @@ public void testSearch_Patient_FetchAll_AlsoRevIncludeDependentResources(boolean
registerVirtualizationInterceptor();

// Test
SearchParameterMap params = SearchParameterMap.newSynchronous();
SearchParameterMap params = new SearchParameterMap();
params.addRevInclude(IBaseResource.INCLUDE_ALL);
IBundleProvider outcome = myPatientDao.search(params, mySrd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
*/
public class MdmReadVirtualizationInterceptor<P extends IResourcePersistentId<?>> {

public static final String CURRENTLY_PROCESSING_FLAG =
MdmReadVirtualizationInterceptor.class.getName() + "-CURRENTLY-PROCESSING";

@Autowired
private FhirContext myFhirContext;

Expand All @@ -101,6 +104,9 @@ public void hook(RequestDetails theRequestDetails, SearchParameterMap theSearchP

@Hook(Pointcut.STORAGE_PRESHOW_RESOURCES)
public void preShowResources(RequestDetails theRequestDetails, IPreResourceShowDetails theDetails) {
if (theRequestDetails.getUserData().get(CURRENTLY_PROCESSING_FLAG) == Boolean.TRUE) {
return;
}

// Gather all the resource IDs we might need to remap
ListMultimap<String, Integer> candidateResourceIds = extractRemapCandidateResources(theDetails);
Expand Down Expand Up @@ -148,8 +154,14 @@ public void preShowResources(RequestDetails theRequestDetails, IPreResourceShowD
// then we'll manually add it
IIdType targetResourceId = newIdType(targetId);
IFhirResourceDao<?> dao = myDaoRegistry.getResourceDao(targetResourceId.getResourceType());
IBaseResource goldenResource = dao.read(targetResourceId, theRequestDetails);

theRequestDetails.getUserData().put(CURRENTLY_PROCESSING_FLAG, Boolean.TRUE);
IBaseResource goldenResource;
try {
goldenResource = dao.read(targetResourceId, theRequestDetails);
} finally {
theRequestDetails.getUserData().remove(CURRENTLY_PROCESSING_FLAG);
}
theDetails.setResource(filteredIndex, goldenResource);
candidateResourceIds.put(targetId, filteredIndex);
}
Expand Down

0 comments on commit 983f4b6

Please sign in to comment.