Work on rationalizing search param extractor
This commit is contained in:
parent
ac4d108126
commit
51a0006548
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.jpa.dao.dstu3;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.term.TranslationMatch;
|
||||
import ca.uhn.fhir.jpa.term.TranslationRequest;
|
||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.jpa.dao.r4;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElement;
|
||||
|
|
|
@ -69,88 +69,6 @@ public class FhirResourceDaoR4InvalidSubscriptionTest extends BaseJpaR4Test {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that bad data in the database doesn't prevent startup
|
||||
*/
|
||||
@Test
|
||||
public void testSubscriptionMarkedDeleted() {
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(true);
|
||||
|
||||
Subscription s = new Subscription();
|
||||
s.setStatus(Subscription.SubscriptionStatus.REQUESTED);
|
||||
s.getChannel().setEndpoint("http://foo");
|
||||
s.getChannel().setPayload("application/fhir+json");
|
||||
s.setCriteria("Patient?foo");
|
||||
final IIdType id = mySubscriptionDao.create(s).getId().toUnqualifiedVersionless();
|
||||
assertNotNull(id.getIdPart());
|
||||
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(false);
|
||||
|
||||
new TransactionTemplate(myTransactionMgr).execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
Query q = myEntityManager.createNativeQuery("UPDATE HFJ_RESOURCE SET RES_DELETED_AT = RES_UPDATED WHERE RES_ID = " + id.getIdPart());
|
||||
q.executeUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
myEntityManager.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that bad data in the database doesn't prevent startup
|
||||
*/
|
||||
@Test
|
||||
public void testSubscriptionWithInvalidCriteria() throws InterruptedException {
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(true);
|
||||
|
||||
Subscription s = new Subscription();
|
||||
s.setStatus(Subscription.SubscriptionStatus.REQUESTED);
|
||||
s.getChannel().setType(Subscription.SubscriptionChannelType.RESTHOOK);
|
||||
s.getChannel().setEndpoint("http://foo");
|
||||
s.getChannel().setPayload("application/fhir+json");
|
||||
s.setCriteria("BLAH");
|
||||
IIdType id = mySubscriptionDao.create(s).getId().toUnqualifiedVersionless();
|
||||
assertNotNull(id.getIdPart());
|
||||
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that bad data in the database doesn't prevent startup
|
||||
*/
|
||||
@Test
|
||||
public void testSubscriptionWithNoStatus() {
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(true);
|
||||
|
||||
Subscription s = new Subscription();
|
||||
s.getChannel().setType(Subscription.SubscriptionChannelType.RESTHOOK);
|
||||
s.getChannel().setEndpoint("http://foo");
|
||||
s.getChannel().setPayload("application/fhir+json");
|
||||
s.setCriteria("Patient?active=true");
|
||||
IIdType id = mySubscriptionDao.create(s).getId().toUnqualifiedVersionless();
|
||||
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that bad data in the database doesn't prevent startup
|
||||
*/
|
||||
@Test
|
||||
public void testSubscriptionWithNoType() {
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(true);
|
||||
|
||||
Subscription s = new Subscription();
|
||||
s.setStatus(Subscription.SubscriptionStatus.REQUESTED);
|
||||
s.getChannel().setEndpoint("http://foo");
|
||||
s.getChannel().setPayload("application/fhir+json");
|
||||
s.setCriteria("Patient?foo");
|
||||
IIdType id = mySubscriptionDao.create(s).getId().toUnqualifiedVersionless();
|
||||
assertNotNull(id.getIdPart());
|
||||
|
||||
BaseHapiFhirDao.setValidationDisabledForUnitTest(false);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
|
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.provider.BaseResourceProviderDstu2Test;
|
||||
import ca.uhn.fhir.jpa.subscription.SubscriptionTestUtil;
|
||||
import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
|
@ -19,7 +20,9 @@ import ca.uhn.fhir.rest.annotation.Update;
|
|||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
|
@ -31,6 +34,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Test the rest-hook subscriptions
|
||||
*/
|
||||
|
@ -43,7 +48,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B
|
|||
private static Server ourListenerServer;
|
||||
private static String ourListenerServerBase;
|
||||
private static List<Observation> ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList());
|
||||
|
||||
@Autowired
|
||||
protected SubscriptionRegistry mySubscriptionRegistry;
|
||||
@Autowired
|
||||
private SubscriptionTestUtil mySubscriptionTestUtil;
|
||||
|
||||
|
@ -76,6 +82,22 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B
|
|||
mySubscriptionTestUtil.waitForQueueToDrain();
|
||||
}
|
||||
|
||||
protected void waitForActivatedSubscriptionCount(int theSize) throws Exception {
|
||||
for (int i = 0; ; i++) {
|
||||
if (i == 10) {
|
||||
fail("Failed to init subscriptions");
|
||||
}
|
||||
try {
|
||||
mySubscriptionLoader.doSyncSubscriptionsForUnitTest();
|
||||
break;
|
||||
} catch (ResourceVersionConflictException e) {
|
||||
Thread.sleep(250);
|
||||
}
|
||||
}
|
||||
|
||||
TestUtil.waitForSize(theSize, () -> mySubscriptionRegistry.size());
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
private Subscription createSubscription(String criteria, String payload, String endpoint) throws InterruptedException {
|
||||
Subscription subscription = new Subscription();
|
||||
|
@ -125,6 +147,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B
|
|||
|
||||
Subscription subscription1 = createSubscription(criteria1, payload, ourListenerServerBase);
|
||||
Subscription subscription2 = createSubscription(criteria2, payload, ourListenerServerBase);
|
||||
waitForActivatedSubscriptionCount(2);
|
||||
|
||||
Observation observation1 = sendObservation(code, "SNOMED-CT");
|
||||
|
||||
|
@ -198,11 +221,11 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B
|
|||
|
||||
Subscription subscription1 = createSubscription(criteria1, payload, ourListenerServerBase);
|
||||
Subscription subscription2 = createSubscription(criteria2, payload, ourListenerServerBase);
|
||||
waitForActivatedSubscriptionCount(2);
|
||||
|
||||
Observation observation1 = sendObservation(code, "SNOMED-CT");
|
||||
|
||||
// Should see 1 subscription notification
|
||||
waitForQueueToDrain();
|
||||
waitForSize(0, ourCreatedObservations);
|
||||
waitForSize(1, ourUpdatedObservations);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
IBaseEnumeration<?> obj = (IBaseEnumeration<?>) value;
|
||||
String system = extractSystem(obj);
|
||||
String code = obj.getValueAsString();
|
||||
addTokenIfNotBlank(resourceTypeName, params, searchParam, system, code);
|
||||
createTokenIndexIfNotBlank(resourceTypeName, params, searchParam, system, code);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
system = boundCode.getBinder().toSystemString(valueAsEnum);
|
||||
}
|
||||
String code = boundCode.getValueAsString();
|
||||
addTokenIfNotBlank(resourceTypeName, params, searchParam, system, code);
|
||||
createTokenIndexIfNotBlank(resourceTypeName, params, searchParam, system, code);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
systemAsString = useSystem;
|
||||
}
|
||||
|
||||
addTokenIfNotBlank(resourceTypeName, params, searchParam, systemAsString, valueAsString);
|
||||
createTokenIndexIfNotBlank(resourceTypeName, params, searchParam, systemAsString, valueAsString);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
if (value instanceof IPrimitiveType) {
|
||||
IPrimitiveType<?> nextValue = (IPrimitiveType<?>) value;
|
||||
String valueAsString = nextValue.getValueAsString();
|
||||
addSearchTermIfNotBlank(resourceType, params, searchParam, valueAsString);
|
||||
createStringIndexIfNotBlank(resourceType, params, searchParam, valueAsString);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -482,13 +482,13 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
String system = extractValueAsString(identifierSystemValueChild, theValue);
|
||||
String value = extractValueAsString(identifierValueValueChild, theValue);
|
||||
if (isNotBlank(value)) {
|
||||
addTokenIfNotBlank(theResourceType, theParams, theSearchParam, system, value);
|
||||
createTokenIndexIfNotBlank(theResourceType, theParams, theSearchParam, system, value);
|
||||
}
|
||||
|
||||
Optional<IBase> type = identifierTypeValueChild.getAccessor().getFirstValueOrNull(theValue);
|
||||
if (type.isPresent()) {
|
||||
String text = extractValueAsString(identifierTypeTextValueChild, type.get());
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, text);
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, text);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
|
||||
String text = extractValueAsString(codeableConceptTextValueChild, theValue);
|
||||
if (isNotBlank(text)) {
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, text);
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,10 +517,10 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
|
||||
String system = extractValueAsString(codingSystemValueChild, theValue);
|
||||
String code = extractValueAsString(codingCodeValueChild, theValue);
|
||||
addTokenIfNotBlank(theResourceType, theParams, theSearchParam, system, code);
|
||||
createTokenIndexIfNotBlank(theResourceType, theParams, theSearchParam, system, code);
|
||||
|
||||
String text = extractValueAsString(codingDisplayValueChild, theValue);
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, text);
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, text);
|
||||
}
|
||||
|
||||
private void addToken_ContactPoint(String theResourceType, Set<BaseResourceIndexedSearchParam> theParams, RuntimeSearchParam theSearchParam, IBase theValue) {
|
||||
|
@ -530,7 +530,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
|
||||
String system = extractValueAsString(contactPointSystemValueChild, theValue);
|
||||
String value = extractValueAsString(contactPointValueValueChild, theValue);
|
||||
addTokenIfNotBlank(theResourceType, theParams, theSearchParam, system, value);
|
||||
createTokenIndexIfNotBlank(theResourceType, theParams, theSearchParam, system, value);
|
||||
}
|
||||
|
||||
private void addToken_PatientCommunication(String theResourceType, Set<BaseResourceIndexedSearchParam> theParams, RuntimeSearchParam theSearchParam, IBase theValue) {
|
||||
|
@ -681,12 +681,12 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
|
||||
List<String> families = extractValuesAsStrings(humanNameFamilyValueChild, theValue);
|
||||
for (String next : families) {
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
}
|
||||
|
||||
List<String> givens = extractValuesAsStrings(humanNameGivenValueChild, theValue);
|
||||
for (String next : givens) {
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
|
||||
BigDecimal value = extractValueAsBigDecimal(quantityValueChild, theValue);
|
||||
if (value != null) {
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, value.toPlainString());
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, value.toPlainString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
|
||||
BigDecimal value = extractValueAsBigDecimal(rangeLowValueChild, theValue);
|
||||
if (value != null) {
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, value.toPlainString());
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, value.toPlainString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -717,7 +717,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
|
||||
String value = extractValueAsString(contactPointValueValueChild, theValue);
|
||||
if (isNotBlank(value)) {
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, value);
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
}
|
||||
|
||||
for (String nextName : allNames) {
|
||||
addSearchTermIfNotBlank(theResourceType, theParams, theSearchParam, nextName);
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, nextName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -809,7 +809,28 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
}
|
||||
}
|
||||
|
||||
private void addTokenIfNotBlank(String theResourceType, Set<BaseResourceIndexedSearchParam> theParams, RuntimeSearchParam theSearchParam, String theSystem, String theValue) {
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
private void createStringIndexIfNotBlank(String theResourceType, Set<? extends BaseResourceIndexedSearchParam> theParams, RuntimeSearchParam theSearchParam, String theValue) {
|
||||
String value = theValue;
|
||||
if (isNotBlank(value)) {
|
||||
if (value.length() > ResourceIndexedSearchParamString.MAX_LENGTH) {
|
||||
value = value.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH);
|
||||
}
|
||||
|
||||
String searchParamName = theSearchParam.getName();
|
||||
String valueNormalized = StringNormalizer.normalizeString(value);
|
||||
if (valueNormalized.length() > ResourceIndexedSearchParamString.MAX_LENGTH) {
|
||||
valueNormalized = valueNormalized.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH);
|
||||
}
|
||||
|
||||
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(getModelConfig(), theResourceType, searchParamName, valueNormalized, value);
|
||||
|
||||
Set params = theParams;
|
||||
params.add(nextEntity);
|
||||
}
|
||||
}
|
||||
|
||||
private void createTokenIndexIfNotBlank(String theResourceType, Set<BaseResourceIndexedSearchParam> theParams, RuntimeSearchParam theSearchParam, String theSystem, String theValue) {
|
||||
String system = theSystem;
|
||||
String value = theValue;
|
||||
if (isNotBlank(system) || isNotBlank(value)) {
|
||||
|
@ -826,22 +847,6 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
private void addSearchTermIfNotBlank(String theResourceType, Set<? extends BaseResourceIndexedSearchParam> theParams, RuntimeSearchParam theSearchParam, String theValue) {
|
||||
if (isNotBlank(theValue)) {
|
||||
if (theValue.length() > ResourceIndexedSearchParamString.MAX_LENGTH) {
|
||||
theValue = theValue.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH);
|
||||
}
|
||||
|
||||
String searchParamName = theSearchParam.getName();
|
||||
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(getModelConfig(), theResourceType, searchParamName, StringNormalizer.normalizeString(theValue), theValue);
|
||||
|
||||
Set params = theParams;
|
||||
params.add(nextEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] split(String thePaths) {
|
||||
if (getContext().getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.R4)) {
|
||||
|
|
|
@ -28,9 +28,6 @@ import org.hl7.fhir.dstu3.context.IWorkerContext;
|
|||
import org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext;
|
||||
import org.hl7.fhir.dstu3.hapi.ctx.IValidationSupport;
|
||||
import org.hl7.fhir.dstu3.model.Base;
|
||||
import org.hl7.fhir.dstu3.model.CodeSystem;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
@ -38,7 +35,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -64,19 +60,17 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
|
|||
public SearchParamExtractorDstu3(ModelConfig theModelConfig, FhirContext theCtx, IValidationSupport theValidationSupport, ISearchParamRegistry theSearchParamRegistry) {
|
||||
super(theCtx, theSearchParamRegistry);
|
||||
myValidationSupport = theValidationSupport;
|
||||
start(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IValueExtractor getPathValueExtractor(IBaseResource theResource, String thePaths) {
|
||||
protected IValueExtractor getPathValueExtractor(IBaseResource theResource, String theSinglePath) {
|
||||
return () -> {
|
||||
List<IBase> values = new ArrayList<>();
|
||||
String[] nextPathsSplit = split(thePaths);
|
||||
for (String nextPath : nextPathsSplit) {
|
||||
List<Base> allValues = myFhirPathEngine.evaluate((Base) theResource, trim(nextPath));
|
||||
List<Base> allValues = myFhirPathEngine.evaluate((Base) theResource, theSinglePath);
|
||||
if (allValues.isEmpty() == false) {
|
||||
values.addAll(allValues);
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
};
|
||||
|
@ -84,7 +78,9 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
|
|||
|
||||
@EventListener
|
||||
public void start(ContextRefreshedEvent theEvent) {
|
||||
if (myValidationSupport == null) {
|
||||
myValidationSupport = myApplicationContext.getBean(IValidationSupport.class);
|
||||
}
|
||||
IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport);
|
||||
myFhirPathEngine = new FHIRPathEngine(worker);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.PathEngineException;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
@ -33,9 +32,7 @@ import org.hl7.fhir.r4.context.IWorkerContext;
|
|||
import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext;
|
||||
import org.hl7.fhir.r4.hapi.ctx.IValidationSupport;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
import org.hl7.fhir.r4.model.Location.LocationPositionComponent;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
|
@ -63,16 +60,10 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IValueExtractor getPathValueExtractor(IBaseResource theResource, String thePaths) {
|
||||
protected IValueExtractor getPathValueExtractor(IBaseResource theResource, String theSinglePath) {
|
||||
return () -> {
|
||||
List<IBase> values = new ArrayList<>();
|
||||
String[] nextPathsSplit = split(thePaths);
|
||||
for (String nextPath : nextPathsSplit) {
|
||||
List<Base> allValues = myFhirPathEngine.evaluate((Base) theResource, nextPath);
|
||||
values.addAll(allValues);
|
||||
}
|
||||
|
||||
return values;
|
||||
List<Base> allValues = myFhirPathEngine.evaluate((Base) theResource, theSinglePath);
|
||||
return (List<IBase>) new ArrayList<IBase>(allValues);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -76,10 +76,10 @@ public class Retrier<T> {
|
|||
@Override
|
||||
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
|
||||
super.onError(context, callback, throwable);
|
||||
if (throwable instanceof NullPointerException) {
|
||||
if (throwable instanceof NullPointerException || throwable instanceof UnsupportedOperationException) {
|
||||
ourLog.error("Retry failure {}/{}: {}", context.getRetryCount(), theMaxRetries, throwable.getMessage(), throwable);
|
||||
} else {
|
||||
ourLog.error("Retry failure {}/{}: {}", context.getRetryCount(), theMaxRetries, throwable.getMessage());
|
||||
ourLog.error("Retry failure {}/{}: {}", context.getRetryCount(), theMaxRetries, throwable.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -31,10 +31,7 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
import org.hl7.fhir.r4.model.Extension;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -371,7 +368,15 @@ public class SubscriptionCanonicalizer {
|
|||
IBaseMetaType meta = theSubscription.getMeta();
|
||||
|
||||
// Remove any existing strategy tag
|
||||
meta.getTag().removeIf(t -> JpaConstants.EXT_SUBSCRIPTION_MATCHING_STRATEGY.equals(t.getSystem()));
|
||||
meta
|
||||
.getTag()
|
||||
.stream()
|
||||
.filter(t->JpaConstants.EXT_SUBSCRIPTION_MATCHING_STRATEGY.equals(t.getSystem()))
|
||||
.forEach(t->{
|
||||
t.setCode(null);
|
||||
t.setSystem(null);
|
||||
t.setDisplay(null);
|
||||
});
|
||||
|
||||
if (theStrategy == null) {
|
||||
return;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.xml.sax.SAXException;
|
|||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1133,7 +1134,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
@Test
|
||||
public void testSimpleResourceEncode() throws IOException {
|
||||
|
||||
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
|
||||
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), StandardCharsets.UTF_8);
|
||||
Patient obs = ourCtx.newXmlParser().parseResource(Patient.class, xmlString);
|
||||
|
||||
List<Extension> undeclaredExtensions = obs.getContact().get(0).getName().getFamily().get(0).getExtension();
|
||||
|
@ -1146,7 +1147,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
String encoded = jsonParser.encodeResourceToString(obs);
|
||||
ourLog.info(encoded);
|
||||
|
||||
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
|
||||
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), StandardCharsets.UTF_8);
|
||||
|
||||
JSON expected = JSONSerializer.toJSON(jsonString);
|
||||
JSON actual = JSONSerializer.toJSON(encoded.trim());
|
||||
|
@ -1203,7 +1204,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
@Test
|
||||
public void testSimpleResourceEncodeWithCustomType() throws IOException, SAXException {
|
||||
|
||||
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
|
||||
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), StandardCharsets.UTF_8);
|
||||
MyObservationWithExtensions obs = ourCtx.newJsonParser().parseResource(MyObservationWithExtensions.class, jsonString);
|
||||
|
||||
{
|
||||
|
@ -1226,7 +1227,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
String encoded = xmlParser.encodeResourceToString(obs);
|
||||
encoded = encoded.replaceAll("<!--.*-->", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
|
||||
|
||||
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
|
||||
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), StandardCharsets.UTF_8);
|
||||
xmlString = xmlString.replaceAll("<!--.*-->", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
|
||||
|
||||
ourLog.info("Expected: " + xmlString);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"resourceType":"Patient",
|
||||
"text":{
|
||||
"status":"generated",
|
||||
"div":"<div>\n <table>\n <tbody>\n <tr>\n <td>Name</td>\n <td>Peter James <b>Chalmers</b> (\"Jim\")</td>\n </tr>\n <tr>\n <td>Address</td>\n <td>534 Erewhon, Pleasantville, Vic, 3999</td>\n </tr>\n <tr>\n <td>Contacts</td>\n <td>Home: unknown. Work: (03) 5555 6473</td>\n </tr>\n <tr>\n <td>Id</td>\n <td>MRN: 12345 (Acme Healthcare)</td>\n </tr>\n </tbody>\n </table>\n </div>"
|
||||
"div":"<div>\n <table>\n <tbody>\n <tr>\n <td>Name</td>\n <td>Peter James <b>Chalmers</b> ("Jim")</td>\n </tr>\n <tr>\n <td>Address</td>\n <td>534 Erewhon, Pleasantville, Vic, 3999</td>\n </tr>\n <tr>\n <td>Contacts</td>\n <td>Home: unknown. Work: (03) 5555 6473</td>\n </tr>\n <tr>\n <td>Id</td>\n <td>MRN: 12345 (Acme Healthcare)</td>\n </tr>\n </tbody>\n </table>\n </div>"
|
||||
},
|
||||
"extension":[
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue