Wip
This commit is contained in:
parent
659a877100
commit
e6cfb77c79
|
@ -59,6 +59,7 @@ import ca.uhn.fhir.jpa.entity.Search;
|
|||
import ca.uhn.fhir.jpa.graphql.JpaStorageServices;
|
||||
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
|
||||
import ca.uhn.fhir.jpa.interceptor.JpaConsentContextServices;
|
||||
import ca.uhn.fhir.jpa.interceptor.MdmSearchExpandingInterceptorInterceptor;
|
||||
import ca.uhn.fhir.jpa.interceptor.OverridePathBasedReferentialIntegrityForDeletesInterceptor;
|
||||
import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingRuleBuilder;
|
||||
import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
|
||||
|
@ -457,6 +458,12 @@ public abstract class BaseConfig {
|
|||
return new RequestTenantPartitionInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public MdmSearchExpandingInterceptorInterceptor mdmSearchExpandingInterceptorInterceptor() {
|
||||
return new MdmSearchExpandingInterceptorInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public TerminologyUploaderProvider terminologyUploaderProvider() {
|
||||
|
|
|
@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.dao.mdm;
|
|||
import ca.uhn.fhir.jpa.dao.data.IMdmLinkDao;
|
||||
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
|
||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||
import ca.uhn.fhir.mdm.log.Logs;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
@ -39,7 +40,7 @@ import java.util.Set;
|
|||
|
||||
@Service
|
||||
public class MdmLinkExpandSvc {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(MdmLinkExpandSvc.class);
|
||||
private static final Logger ourLog = Logs.getMdmTroubleshootingLog();
|
||||
|
||||
@Autowired
|
||||
private IMdmLinkDao myMdmLinkDao;
|
||||
|
@ -54,6 +55,7 @@ public class MdmLinkExpandSvc {
|
|||
* @return A set of strings representing the FHIR IDs of the expanded resources.
|
||||
*/
|
||||
public Set<String> expandMdmBySourceResource(IBaseResource theResource) {
|
||||
ourLog.debug("About to MDM-expand source resource {}", theResource);
|
||||
return expandMdmBySourceResourceId(theResource.getIdElement());
|
||||
}
|
||||
|
||||
|
@ -65,6 +67,7 @@ public class MdmLinkExpandSvc {
|
|||
* @return A set of strings representing the FHIR ids of the expanded resources.
|
||||
*/
|
||||
public Set<String> expandMdmBySourceResourceId(IIdType theId) {
|
||||
ourLog.debug("About to expand source resource with resource id {}", theId);
|
||||
Long pidOrThrowException = myIdHelperService.getPidOrThrowException(theId);
|
||||
return expandMdmBySourceResourcePid(pidOrThrowException);
|
||||
}
|
||||
|
@ -77,11 +80,12 @@ public class MdmLinkExpandSvc {
|
|||
* @return A set of strings representing the FHIR ids of the expanded resources.
|
||||
*/
|
||||
public Set<String> expandMdmBySourceResourcePid(Long theSourceResourcePid) {
|
||||
ourLog.debug("About to expand source resource with PID {}", theSourceResourcePid);
|
||||
List<List<Long>> goldenPidSourcePidTuples = myMdmLinkDao.expandPidsBySourcePidAndMatchResult(theSourceResourcePid, MdmMatchResultEnum.MATCH);
|
||||
Set<Long> flattenedPids = new HashSet<>();
|
||||
goldenPidSourcePidTuples.forEach(flattenedPids::addAll);
|
||||
|
||||
Set<String> resourceIds = myIdHelperService.translatePidsToFhirResourceIds(flattenedPids);
|
||||
ourLog.debug("Pid {} has been expanded to [{}]", theSourceResourcePid, String.join(",", resourceIds));
|
||||
return resourceIds;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import ca.uhn.fhir.jpa.dao.index.IdHelperService;
|
|||
import ca.uhn.fhir.jpa.dao.mdm.MdmLinkExpandSvc;
|
||||
import ca.uhn.fhir.jpa.search.helper.SearchParamHelper;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.mdm.log.Logs;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
@ -56,7 +57,7 @@ import static org.slf4j.LoggerFactory.getLogger;
|
|||
*/
|
||||
@Interceptor
|
||||
public class MdmSearchExpandingInterceptorInterceptor {
|
||||
private static final Logger ourLog = getLogger(MdmSearchExpandingInterceptorInterceptor.class);
|
||||
private static final Logger ourLog = Logs.getMdmTroubleshootingLog();
|
||||
|
||||
@Autowired
|
||||
private MdmLinkExpandSvc myMdmLinkExpandSvc;
|
||||
|
@ -67,7 +68,6 @@ public class MdmSearchExpandingInterceptorInterceptor {
|
|||
@Autowired
|
||||
private IdHelperService myIdHelperService;
|
||||
|
||||
|
||||
@Hook(Pointcut.STORAGE_PRECHECK_FOR_CACHED_SEARCH)
|
||||
public boolean hook(RequestDetails theRequestDetails, SearchParameterMap theSearchParameterMap) {
|
||||
Map<String, String[]> parameters =theRequestDetails.getParameters();
|
||||
|
@ -75,11 +75,11 @@ public class MdmSearchExpandingInterceptorInterceptor {
|
|||
if (parameters.containsKey("_mdm")) {
|
||||
shouldExpandMdm = parameters.get("_mdm").length == 1 && parameters.get("_mdm")[0].equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
|
||||
if (shouldExpandMdm) {
|
||||
ourLog.debug("Detected that incoming request has _mdm=true. The request was: {}", theRequestDetails.getRequestPath());
|
||||
String resourceName = theRequestDetails.getResourceName();
|
||||
Collection<RuntimeSearchParam> patientSearchParams = mySearchParamHelper.getPatientSearchParamsForResourceType(resourceName);
|
||||
ourLog.debug("Resource type {} has patient search parameters [{}]", resourceName, patientSearchParams.stream().map(RuntimeSearchParam::getName).collect(Collectors.joining(", ")));
|
||||
for (RuntimeSearchParam patientSearchParam: patientSearchParams) {
|
||||
if (!theSearchParameterMap.containsKey(patientSearchParam.getName())) {
|
||||
continue;
|
||||
|
|
|
@ -129,6 +129,7 @@ import org.hl7.fhir.r4.model.DocumentReference;
|
|||
import org.hl7.fhir.r4.model.Encounter;
|
||||
import org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.hl7.fhir.r4.model.EpisodeOfCare;
|
||||
import org.hl7.fhir.r4.model.ExplanationOfBenefit;
|
||||
import org.hl7.fhir.r4.model.Group;
|
||||
import org.hl7.fhir.r4.model.Immunization;
|
||||
import org.hl7.fhir.r4.model.ImmunizationRecommendation;
|
||||
|
@ -378,6 +379,9 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil
|
|||
@Qualifier("myPatientDaoR4")
|
||||
protected IFhirResourceDaoPatient<Patient> myPatientDao;
|
||||
@Autowired
|
||||
@Qualifier("myExplanationOfBenefitDaoR4")
|
||||
protected IFhirResourceDao<ExplanationOfBenefit> myExplanationOfBenefitDao;
|
||||
@Autowired
|
||||
protected IResourceTableDao myResourceTableDao;
|
||||
@Autowired
|
||||
protected IResourceHistoryTableDao myResourceHistoryTableDao;
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.hl7.fhir.r4.model.DiagnosticReport;
|
|||
import org.hl7.fhir.r4.model.Encounter;
|
||||
import org.hl7.fhir.r4.model.Enumerations;
|
||||
import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender;
|
||||
import org.hl7.fhir.r4.model.ExplanationOfBenefit;
|
||||
import org.hl7.fhir.r4.model.Extension;
|
||||
import org.hl7.fhir.r4.model.Group;
|
||||
import org.hl7.fhir.r4.model.IntegerType;
|
||||
|
@ -193,10 +194,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
|
|||
|
||||
search = myPatientDao.search(SearchParameterMap.newSynchronous("future-appointment-count", new NumberParam("lt0")));
|
||||
assertEquals(0, search.size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draft search parameters should be ok even if they aren't completely valid
|
||||
*/
|
||||
|
|
|
@ -13,8 +13,11 @@ import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
|||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.gclient.DateClientParam;
|
||||
import ca.uhn.fhir.rest.gclient.ReferenceClientParam;
|
||||
import ca.uhn.fhir.rest.gclient.StringClientParam;
|
||||
import ca.uhn.fhir.rest.gclient.TokenClientParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.util.BundleUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -31,6 +34,7 @@ import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResource
|
|||
import org.hl7.fhir.r4.model.CodeType;
|
||||
import org.hl7.fhir.r4.model.Enumerations;
|
||||
import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender;
|
||||
import org.hl7.fhir.r4.model.ExplanationOfBenefit;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Observation.ObservationStatus;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
|
@ -54,6 +58,8 @@ import java.util.stream.Collectors;
|
|||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
@ -328,9 +334,9 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
|
|||
|
||||
List<String> foundResources = toUnqualifiedVersionlessIdValues(bundle);
|
||||
assertThat(foundResources, contains(p1id.getValue()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchQualifiedWithCustomReferenceParam() {
|
||||
|
@ -416,6 +422,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See #1300
|
||||
*/
|
||||
|
|
|
@ -36,6 +36,8 @@ import ca.uhn.fhir.rest.api.server.RequestDetails;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.Extension;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -57,13 +59,10 @@ public class MdmStorageInterceptor implements IMdmStorageInterceptor {
|
|||
private EIDHelper myEIDHelper;
|
||||
@Autowired
|
||||
private IMdmSettings myMdmSettings;
|
||||
@Autowired
|
||||
private GoldenResourceHelper myGoldenResourceHelper;
|
||||
|
||||
|
||||
@Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_CREATED)
|
||||
public void blockManualResourceManipulationOnCreate(IBaseResource theBaseResource, RequestDetails theRequestDetails, ServletRequestDetails theServletRequestDetails) {
|
||||
|
||||
//If running in single EID mode, forbid multiple eids.
|
||||
if (myMdmSettings.isPreventMultipleEids()) {
|
||||
forbidIfHasMultipleEids(theBaseResource);
|
||||
|
|
Loading…
Reference in New Issue