Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threaded Measure Evaluation #511

Merged
merged 2 commits into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"projectName": "cqf-ruler-server",
"vmArgs": [
"-XX:TieredStopAtLevel=1",
"-Xverify:none",
"-Dspring.main.lazy-initialization=true",
"-Ddebug=true",
"-Dloader.debug=true"
Expand All @@ -32,23 +31,6 @@
"$Runtime"
]
},
{
"type": "java",
"name": "Attach",
"request": "attach",
"hostName": "localhost",
"port": "5005",
"stepFilters": {
"classNameFilters": [
"java.*",
"javax.*",
"com.sun.*",
"sun.*",
"sunw.*",
"org.omg.*"
]
}
},
{
"type": "java",
"name": "Launch Server DSTU3 (Live Reload)",
Expand All @@ -57,7 +39,6 @@
"projectName": "cqf-ruler-server",
"vmArgs": [
"-XX:TieredStopAtLevel=1",
"-Xverify:none",
"-Dspring.main.lazy-initialization=true",
"-Ddebug=true",
"-Dloader.debug=true",
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"name": "test-config",
"vmArgs": [
"-XX:TieredStopAtLevel=1",
"-Xverify:none",
"-Dspring.main.lazy-initialization=true"
]
},
Expand Down
4 changes: 1 addition & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opencds.cqf.ruler</groupId>
Expand All @@ -16,7 +15,6 @@
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
</dependency>

<dependency>
<groupId>org.opencds.cqf.ruler</groupId>
<artifactId>cqf-ruler-external</artifactId>
Expand Down
6 changes: 0 additions & 6 deletions core/src/main/java/org/opencds/cqf/ruler/Application.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opencds.cqf.ruler;

import org.opencds.cqf.ruler.config.BeanFinderConfig;
import org.opencds.cqf.ruler.config.ServerProperties;
import org.opencds.cqf.ruler.config.TesterUIConfig;
import org.opencds.cqf.ruler.external.FhirTesterConfig;
import org.opencds.cqf.ruler.external.annotations.OnEitherVersion;
Expand Down Expand Up @@ -69,9 +68,4 @@ public ServletRegistrationBean<Server> hapiServletRegistration() {

return servletRegistrationBean;
}

@Bean
public ServerProperties serverProperties() {
return new ServerProperties();
}
}
22 changes: 10 additions & 12 deletions core/src/test/java/org/opencds/cqf/ruler/ExampleServerDstu2IT.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;


@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties =
{
"spring.batch.job.enabled=false",
"hapi.fhir.fhir_version=dstu2",
"spring.datasource.url=jdbc:h2:mem:dbr2"
})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = {
"spring.batch.job.enabled=false",
"hapi.fhir.fhir_version=dstu2",
"spring.datasource.url=jdbc:h2:mem:dbr2",
"spring.flyway.enabled=false"
})
public class ExampleServerDstu2IT {

private IGenericClient ourClient;
private FhirContext ourCtx;

@LocalServerPort
private int port;
@LocalServerPort
private int port;

@Test
@Test
void testCreateAndRead() {

String methodName = "testCreateResourceConditional";
Expand All @@ -42,11 +41,10 @@ void testCreateAndRead() {
assertEquals(methodName, pt2.getName().get(0).getFamily().get(0).getValue());
}


@BeforeEach
void beforeEach() {

ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU2);
ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU2);
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
String ourServerBase = "http://localhost:" + port + "/fhir/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;


@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = {
"spring.datasource.url=jdbc:h2:mem:dbr3",
"hapi.fhir.fhir_version=dstu3",
"hapi.fhir.subscription.websocket_enabled=true",
"hapi.fhir.allow_external_references=true",
"hapi.fhir.allow_placeholder_references=true",
"spring.flyway.enabled=false"
})

public class ExampleServerDstu3IT {
Expand Down
164 changes: 87 additions & 77 deletions core/src/test/java/org/opencds/cqf/ruler/ExampleServerR4IT.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.util.BundleUtil;


@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties =
{
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = {
"spring.batch.job.enabled=false",
"spring.datasource.url=jdbc:h2:mem:dbr4",
"hapi.fhir.enable_repository_validating_interceptor=true",
"hapi.fhir.fhir_version=r4",
"hapi.fhir.subscription.websocket_enabled=true",
"hapi.fhir.mdm_enabled=true",
//Override is currently required when using MDM as the construction of the MDM beans are ambiguous as they are constructed multiple places. This is evident when running in a spring boot environment
"spring.main.allow-bean-definition-overriding=true"
})
// Override is currently required when using MDM as the construction of the MDM
// beans are ambiguous as they are constructed multiple places. This is evident
// when running in a spring boot environment
"spring.main.allow-bean-definition-overriding=true",
"spring.flyway.enabled=false"
})
public class ExampleServerR4IT {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR4IT.class);
private IGenericClient ourClient;
Expand All @@ -44,7 +45,6 @@ public class ExampleServerR4IT {
@LocalServerPort
private int port;


@Test
@Order(0)
void testCreateAndRead() {
Expand All @@ -63,99 +63,109 @@ void testCreateAndRead() {

// Wait until the MDM message has been processed
// await().until(() -> {
// sleep(1000);
// return getGoldenResourcePatient() != null;
// sleep(1000);
// return getGoldenResourcePatient() != null;
// });
// Patient goldenRecord = getGoldenResourcePatient();

// // Verify that a golden record Patient was created
// assertNotNull(goldenRecord.getMeta().getTag("http://hapifhir.io/fhir/NamingSystem/mdm-record-status", "GOLDEN_RECORD"));
// assertNotNull(goldenRecord.getMeta().getTag("http://hapifhir.io/fhir/NamingSystem/mdm-record-status",
// "GOLDEN_RECORD"));
}

@SuppressWarnings("unused")
private List<Patient> getPatients() {
Bundle bundle = ourClient.search().forResource(Patient.class).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute();
Bundle bundle = ourClient.search().forResource(Patient.class)
.cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute();
List<Patient> retVal = BundleUtil.toListOfResourcesOfType(ourCtx, bundle, Patient.class);
retVal.sort(comparing(o -> ((Patient) o).getMeta().getLastUpdated()).reversed());
return retVal;
}

// private Patient getGoldenResourcePatient() {
// Bundle bundle = ourClient.search()
// .forResource(Patient.class)
// .withTag("http://hapifhir.io/fhir/NamingSystem/mdm-record-status", "GOLDEN_RECORD")
// .cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute();
// if (bundle.getEntryFirstRep() != null) {
// return (Patient) bundle.getEntryFirstRep().getResource();
// } else {
// return null;
// }
// Bundle bundle = ourClient.search()
// .forResource(Patient.class)
// .withTag("http://hapifhir.io/fhir/NamingSystem/mdm-record-status",
// "GOLDEN_RECORD")
// .cacheControl(new
// CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute();
// if (bundle.getEntryFirstRep() != null) {
// return (Patient) bundle.getEntryFirstRep().getResource();
// } else {
// return null;
// }
// }

// @Test
// @Order(1)
// public void testWebsocketSubscription() throws Exception {
// /*
// * Create subscription
// */
// Subscription subscription = new Subscription();
// subscription.setReason("Monitor new neonatal function (note, age will be determined by the monitor)");
// subscription.setStatus(Subscription.SubscriptionStatus.REQUESTED);
// subscription.setCriteria("Observation?status=final");

// Subscription.SubscriptionChannelComponent channel = new Subscription.SubscriptionChannelComponent();
// channel.setType(Subscription.SubscriptionChannelType.WEBSOCKET);
// channel.setPayload("application/json");
// subscription.setChannel(channel);

// MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
// IIdType mySubscriptionId = methodOutcome.getId();

// // Wait for the subscription to be activated
// await().until(() -> activeSubscriptionCount() == 3);

// /*
// * Attach websocket
// */

// WebSocketClient myWebSocketClient = new WebSocketClient();
// SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);

// myWebSocketClient.start();
// URI echoUri = new URI("ws://localhost:" + port + "/websocket");
// ClientUpgradeRequest request = new ClientUpgradeRequest();
// ourLog.info("Connecting to : {}", echoUri);
// Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
// Session session = connection.get(2, TimeUnit.SECONDS);

// ourLog.info("Connected to WS: {}", session.isOpen());

// /*
// * Create a matching resource
// */
// Observation obs = new Observation();
// obs.setStatus(Observation.ObservationStatus.FINAL);
// ourClient.create().resource(obs).execute();

// // Give some time for the subscription to deliver
// sleep(2000);

// /*
// * Ensure that we receive a ping on the websocket
// */
// waitForSize(1, () -> mySocketImplementation.myPingCount);

// /*
// * Clean up
// */
// ourClient.delete().resourceById(mySubscriptionId).execute();
// /*
// * Create subscription
// */
// Subscription subscription = new Subscription();
// subscription.setReason("Monitor new neonatal function (note, age will be
// determined by the monitor)");
// subscription.setStatus(Subscription.SubscriptionStatus.REQUESTED);
// subscription.setCriteria("Observation?status=final");

// Subscription.SubscriptionChannelComponent channel = new
// Subscription.SubscriptionChannelComponent();
// channel.setType(Subscription.SubscriptionChannelType.WEBSOCKET);
// channel.setPayload("application/json");
// subscription.setChannel(channel);

// MethodOutcome methodOutcome =
// ourClient.create().resource(subscription).execute();
// IIdType mySubscriptionId = methodOutcome.getId();

// // Wait for the subscription to be activated
// await().until(() -> activeSubscriptionCount() == 3);

// /*
// * Attach websocket
// */

// WebSocketClient myWebSocketClient = new WebSocketClient();
// SocketImplementation mySocketImplementation = new
// SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);

// myWebSocketClient.start();
// URI echoUri = new URI("ws://localhost:" + port + "/websocket");
// ClientUpgradeRequest request = new ClientUpgradeRequest();
// ourLog.info("Connecting to : {}", echoUri);
// Future<Session> connection =
// myWebSocketClient.connect(mySocketImplementation, echoUri, request);
// Session session = connection.get(2, TimeUnit.SECONDS);

// ourLog.info("Connected to WS: {}", session.isOpen());

// /*
// * Create a matching resource
// */
// Observation obs = new Observation();
// obs.setStatus(Observation.ObservationStatus.FINAL);
// ourClient.create().resource(obs).execute();

// // Give some time for the subscription to deliver
// sleep(2000);

// /*
// * Ensure that we receive a ping on the websocket
// */
// waitForSize(1, () -> mySocketImplementation.myPingCount);

// /*
// * Clean up
// */
// 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();
// return
// ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new
// CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size();
// }


@BeforeEach
void beforeEach() {

Expand All @@ -164,7 +174,7 @@ void beforeEach() {
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
String ourServerBase = "http://localhost:" + port + "/fhir/";
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
// ourClient.registerInterceptor(new LoggingInterceptor(false));
// ourClient.registerInterceptor(new LoggingInterceptor(false));
}

@BeforeAll
Expand Down
Loading