Revert "Changes for empi (as well as subscriptions and partitions)"

This commit is contained in:
James Agnew
2020-05-29 10:23:52 -04:00
committed by GitHub
parent 2567dcd429
commit 0c4e822424
12 changed files with 117 additions and 286 deletions

View File

@@ -8,7 +8,6 @@ import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.test.utilities.JettyUtil;
import ca.uhn.fhir.util.BundleUtil;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
@@ -18,8 +17,6 @@ import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.Subscription;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -27,16 +24,11 @@ import org.junit.Test;
import java.net.URI;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static ca.uhn.fhir.util.TestUtil.waitForSize;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ExampleServerR4IT {
@@ -51,7 +43,6 @@ public class ExampleServerR4IT {
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:h2:mem:dbr4");
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "R4");
HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true");
HapiProperties.setProperty(HapiProperties.EMPI_ENABLED, "true");
ourCtx = FhirContext.forR4();
}
@@ -66,30 +57,9 @@ public class ExampleServerR4IT {
Patient pt2 = ourClient.read().resource(Patient.class).withId(id).execute();
assertEquals(methodName, pt2.getName().get(0).getFamily());
// Test EMPI
// Wait until the EMPI message has been processed
await().until(() -> getPeople().size() > 0);
List<Person> persons = getPeople();
// Verify a Person was created that links to our Patient
Optional<String> personLinkToCreatedPatient = persons.stream()
.map(Person::getLink)
.flatMap(Collection::stream)
.map(Person.PersonLinkComponent::getTarget)
.map(Reference::getReference)
.filter(pid -> id.toUnqualifiedVersionless().getValue().equals(pid))
.findAny();
assertTrue(personLinkToCreatedPatient.isPresent());
}
private List<Person> getPeople() {
Bundle bundle = ourClient.search().forResource(Person.class).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute();
return BundleUtil.toListOfResourcesOfType(ourCtx, bundle, Person.class);
}
@Test
@Test
public void testWebsocketSubscription() throws Exception {
/*
* Create subscription
@@ -108,7 +78,7 @@ public class ExampleServerR4IT {
IIdType mySubscriptionId = methodOutcome.getId();
// Wait for the subscription to be activated
await().until(() -> activeSubscriptionCount() == 3);
waitForSize(1, () -> ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size());
/*
* Attach websocket
@@ -147,11 +117,7 @@ public class ExampleServerR4IT {
ourClient.delete().resourceById(mySubscriptionId).execute();
}
private int activeSubscriptionCount() {
return ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size();
}
@AfterClass
@AfterClass
public static void afterClass() throws Exception {
ourServer.stop();
}