Subscription NPE fix
This commit is contained in:
parent
10c59fceeb
commit
503d1d8aff
|
@ -149,7 +149,10 @@ public class ResourceModifiedMessage implements IResourceMessage {
|
||||||
for (ResourceReferenceInfo next : refs) {
|
for (ResourceReferenceInfo next : refs) {
|
||||||
String ref = next.getResourceReference().getReferenceElement().getValue();
|
String ref = next.getResourceReference().getReferenceElement().getValue();
|
||||||
if (isBlank(ref)) {
|
if (isBlank(ref)) {
|
||||||
ref = next.getResourceReference().getResource().getIdElement().getValue();
|
IBaseResource resource = next.getResourceReference().getResource();
|
||||||
|
if (resource != null) {
|
||||||
|
ref = resource.getIdElement().getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isNotBlank(ref)) {
|
if (isNotBlank(ref)) {
|
||||||
if (ref.startsWith("#")) {
|
if (ref.startsWith("#")) {
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
package ca.uhn.fhir.jpa.subscription.module.matcher;
|
package ca.uhn.fhir.jpa.subscription.module.matcher;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR Subscription Server
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 - 2019 University Health Network
|
||||||
|
* %%
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
public enum SubscriptionMatchingStrategy {
|
public enum SubscriptionMatchingStrategy {
|
||||||
/**
|
/**
|
||||||
* Resources can be matched against this subcription in-memory without needing to make a call out to a FHIR Repository
|
* Resources can be matched against this subcription in-memory without needing to make a call out to a FHIR Repository
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
package ca.uhn.fhir.jpa.subscription.module.matcher;
|
package ca.uhn.fhir.jpa.subscription.module.matcher;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR Subscription Server
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 - 2019 University Health Network
|
||||||
|
* %%
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ public abstract class BaseBlockingQueueSubscribableChannelDstu3Test extends Base
|
||||||
protected static List<String> ourContentTypes = Collections.synchronizedList(new ArrayList<>());
|
protected static List<String> ourContentTypes = Collections.synchronizedList(new ArrayList<>());
|
||||||
private static SubscribableChannel ourSubscribableChannel;
|
private static SubscribableChannel ourSubscribableChannel;
|
||||||
private List<IIdType> mySubscriptionIds = Collections.synchronizedList(new ArrayList<>());
|
private List<IIdType> mySubscriptionIds = Collections.synchronizedList(new ArrayList<>());
|
||||||
private static AtomicLong idCounter = new AtomicLong();
|
protected static AtomicLong idCounter = new AtomicLong();
|
||||||
protected PointcutLatch mySubscriptionMatchingPost = new PointcutLatch(Pointcut.SUBSCRIPTION_AFTER_PERSISTED_RESOURCE_CHECKED);
|
protected PointcutLatch mySubscriptionMatchingPost = new PointcutLatch(Pointcut.SUBSCRIPTION_AFTER_PERSISTED_RESOURCE_CHECKED);
|
||||||
protected PointcutLatch mySubscriptionActivatedPost = new PointcutLatch(Pointcut.SUBSCRIPTION_AFTER_ACTIVE_SUBSCRIPTION_REGISTERED);
|
protected PointcutLatch mySubscriptionActivatedPost = new PointcutLatch(Pointcut.SUBSCRIPTION_AFTER_ACTIVE_SUBSCRIPTION_REGISTERED);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package ca.uhn.fhir.jpa.subscription.module.subscriber;
|
package ca.uhn.fhir.jpa.subscription.module.subscriber;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
|
|
||||||
import ca.uhn.fhir.jpa.subscription.module.standalone.BaseBlockingQueueSubscribableChannelDstu3Test;
|
import ca.uhn.fhir.jpa.subscription.module.standalone.BaseBlockingQueueSubscribableChannelDstu3Test;
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
|
import org.hl7.fhir.dstu3.model.CodeableConcept;
|
||||||
|
import org.hl7.fhir.dstu3.model.Coding;
|
||||||
|
import org.hl7.fhir.dstu3.model.IdType;
|
||||||
|
import org.hl7.fhir.dstu3.model.Observation;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -77,4 +79,41 @@ public class SubscriptionCheckingSubscriberTest extends BaseBlockingQueueSubscri
|
||||||
|
|
||||||
assertEquals(0, ourContentTypes.size());
|
assertEquals(0, ourContentTypes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReferenceWithDisplayOnly() throws Exception {
|
||||||
|
String payload = "application/fhir+json";
|
||||||
|
|
||||||
|
String code = "1000000050";
|
||||||
|
String criteria1 = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
|
||||||
|
String criteria2 = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
|
||||||
|
|
||||||
|
sendSubscription(criteria1, payload, ourListenerServerBase);
|
||||||
|
sendSubscription(criteria2, payload, ourListenerServerBase);
|
||||||
|
|
||||||
|
assertEquals(2, mySubscriptionRegistry.size());
|
||||||
|
|
||||||
|
ourObservationListener.setExpectedCount(1);
|
||||||
|
Observation observation = new Observation();
|
||||||
|
IdType id = new IdType("Observation", idCounter.incrementAndGet());
|
||||||
|
observation.setId(id);
|
||||||
|
|
||||||
|
// Reference has display only!
|
||||||
|
observation.getSubject().setDisplay("Mr Jones");
|
||||||
|
|
||||||
|
CodeableConcept codeableConcept = new CodeableConcept();
|
||||||
|
observation.setCode(codeableConcept);
|
||||||
|
Coding coding = codeableConcept.addCoding();
|
||||||
|
coding.setCode(code);
|
||||||
|
coding.setSystem("SNOMED-CT");
|
||||||
|
|
||||||
|
observation.setStatus(Observation.ObservationStatus.FINAL);
|
||||||
|
|
||||||
|
sendResource(observation);
|
||||||
|
ourObservationListener.awaitExpected();
|
||||||
|
|
||||||
|
assertEquals(1, ourContentTypes.size());
|
||||||
|
assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue