Cleaned up some tests - more work to do to get some additional tests working in R4.

This commit is contained in:
Kevin Dougan
2020-12-23 16:36:38 -05:00
parent ebe7e99c37
commit f23553e2ea
9 changed files with 3116 additions and 5076 deletions

View File

@@ -1,10 +1,11 @@
package ca.uhn.fhir.jpa.starter.cql; package ca.uhn.fhir.jpa.starter.cql;
import ca.uhn.fhir.cql.config.CqlR4Config; import ca.uhn.fhir.cql.config.CqlR4Config;
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@Conditional({CqlConfigCondition.class}) @Conditional({OnR4Condition.class, CqlConfigCondition.class})
@Import({CqlR4Config.class}) @Import({CqlR4Config.class})
public class StarterCqlR4Config { public class StarterCqlR4Config {
} }

View File

@@ -55,7 +55,7 @@ hapi:
# allow_placeholder_references: true # allow_placeholder_references: true
# auto_create_placeholder_reference_targets: false # auto_create_placeholder_reference_targets: false
# cql_enabled: true # cql_enabled: true
# empi_enabled: true # empi_enabled: false
# default_encoding: JSON # default_encoding: JSON
# default_pretty_print: true # default_pretty_print: true
# default_page_size: 20 # default_page_size: 20

View File

@@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
"spring.datasource.url=jdbc:h2:mem:dbr4", "spring.datasource.url=jdbc:h2:mem:dbr4",
"hapi.fhir.fhir_version=R4", "hapi.fhir.fhir_version=R4",
"hapi.fhir.cql_enabled=true", "hapi.fhir.cql_enabled=true",
"hapi.fhir.empi_enabled=true", "hapi.fhir.empi_enabled=false",
"hapi.fhir.subscription.websocket_enabled=true", "hapi.fhir.subscription.websocket_enabled=true",
//Override is currently required when using Empi as the construction of the Empi beans are ambiguous as they are constructed multiple places. This is evident when running in a spring boot environment //Override is currently required when using Empi as the construction of the Empi 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.main.allow-bean-definition-overriding=true"
@@ -79,6 +79,109 @@ public class ExampleServerR4IT implements IServerSupport {
} }
@Test @Test
public void testCQLEXM104EvaluateMeasure() throws IOException {
String measureId = "measure-EXM104-8.2.000";
loadBundle("r4/EXM104/EXM104-8.2.000-bundle.json", ourCtx, ourClient);
// http://localhost:8080/fhir/Measure/measure-EXM104-8.2.000/$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31
Parameters inParams = new Parameters();
inParams.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
inParams.addParameter().setName("periodEnd").setValue(new StringType("2019-12-31"));
Parameters outParams = ourClient
.operation()
.onInstance(new IdDt("Measure", measureId))
.named("$evaluate-measure")
.withParameters(inParams)
.cacheControl(new CacheControlDirective().setNoCache(true))
.withAdditionalHeader("Content-Type", "application/json")
.useHttpGet()
.execute();
List<Parameters.ParametersParameterComponent> response = outParams.getParameter();
Assert.assertTrue(!response.isEmpty());
Parameters.ParametersParameterComponent component = response.get(0);
Assert.assertTrue(component.getResource() instanceof MeasureReport);
MeasureReport report = (MeasureReport) component.getResource();
Assert.assertEquals("Measure/"+measureId, report.getMeasure());
}
private Bundle loadBundle(String theLocation, FhirContext theCtx, IGenericClient theClient) throws IOException {
String json = stringFromResource(theLocation);
Bundle bundle = (Bundle) theCtx.newJsonParser().parseResource(json);
Bundle result = (Bundle) theClient.transaction().withBundle(bundle).execute();
return result;
}
// Fails with: ca.uhn.fhir.rest.server.exceptions.InternalErrorException: HTTP 500 :
// Failed to call access method: java.lang.IllegalArgumentException:
// Could not load library source for libraries referenced in Measure/Measure/measure-EXM130-FHIR4-7.2.000/_history/1.
//@Test
public void testCQLEXM130EvaluateMeasure() throws IOException {
String measureId = "measure-EXM130-FHIR4-7.2.000";
loadBundle("r4/EXM130/EXM130_FHIR4-7.2.000-bundle.json", ourCtx, ourClient);
// http://localhost:8080/fhir/Measure/measure-EXM130-FHIR4-7.2.000/$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31
Parameters inParams = new Parameters();
// inParams.addParameter().setName("measure").setValue(new StringType("Measure/measure-EXM104-8.2.000"));
// inParams.addParameter().setName("patient").setValue(new StringType("Patient/numer-EXM104-FHIR3"));
inParams.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
inParams.addParameter().setName("periodEnd").setValue(new StringType("2019-12-31"));
Parameters outParams = ourClient
.operation()
.onInstance(new IdDt("Measure", measureId))
.named("$evaluate-measure")
.withParameters(inParams)
.cacheControl(new CacheControlDirective().setNoCache(true))
.withAdditionalHeader("Content-Type", "application/json")
.useHttpGet()
.execute();
List<Parameters.ParametersParameterComponent> response = outParams.getParameter();
Assert.assertTrue(!response.isEmpty());
Parameters.ParametersParameterComponent component = response.get(0);
Assert.assertTrue(component.getResource() instanceof MeasureReport);
MeasureReport report = (MeasureReport) component.getResource();
Assert.assertEquals("Measure/"+measureId, report.getMeasure());
}
// Fails with:
// ca.uhn.fhir.rest.server.exceptions.InternalErrorException:
// HTTP 500 Server Error: Failed to call access method: org.opencds.cqf.cql.engine.exception.CqlException:
// Could not resolve expression reference 'null' in library 'EXM349'.
//@Test
public void testCQLEXM349EvaluateMeasure() throws IOException {
String measureId = "measure-EXM349-2.10.000";
loadBundle("r4/EXM349/EXM349-2.10.000-bundle.json", ourCtx, ourClient);
// http://localhost:8080/fhir/Measure/measure-EXM349-2.10.000/$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31
Parameters inParams = new Parameters();
inParams.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
inParams.addParameter().setName("periodEnd").setValue(new StringType("2019-12-31"));
Parameters outParams = ourClient
.operation()
.onInstance(new IdDt("Measure", measureId))
.named("$evaluate-measure")
.withParameters(inParams)
.cacheControl(new CacheControlDirective().setNoCache(true))
.withAdditionalHeader("Content-Type", "application/json")
.useHttpGet()
.execute();
List<Parameters.ParametersParameterComponent> response = outParams.getParameter();
Assert.assertTrue(!response.isEmpty());
Parameters.ParametersParameterComponent component = response.get(0);
Assert.assertTrue(component.getResource() instanceof MeasureReport);
MeasureReport report = (MeasureReport) component.getResource();
Assert.assertEquals("Measure/"+measureId, report.getMeasure());
}
//@Test
void testCreateAndRead() { void testCreateAndRead() {
String methodName = "testCreateResourceConditional"; String methodName = "testCreateResourceConditional";
@@ -115,116 +218,7 @@ public class ExampleServerR4IT implements IServerSupport {
return BundleUtil.toListOfResourcesOfType(ourCtx, bundle, Person.class); return BundleUtil.toListOfResourcesOfType(ourCtx, bundle, Person.class);
} }
@Test
public void testCQLEvaluateMeasureEXM104() throws IOException {
String measureId = "measure-EXM104-8.2.000";
loadBundle("r4/EXM104/EXM104-8.2.000-bundle.json", ourCtx, ourClient);
// http://localhost:8080/fhir/Measure/measure-EXM104-8.2.000/$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31
Parameters inParams = new Parameters();
// inParams.addParameter().setName("measure").setValue(new StringType("Measure/measure-EXM104-8.2.000"));
// inParams.addParameter().setName("patient").setValue(new StringType("Patient/numer-EXM104-FHIR3"));
inParams.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
inParams.addParameter().setName("periodEnd").setValue(new StringType("2019-12-31"));
Parameters outParams = ourClient
.operation()
.onInstance(new IdDt("Measure", measureId))
.named("$evaluate-measure")
.withParameters(inParams)
.cacheControl(new CacheControlDirective().setNoCache(true))
.withAdditionalHeader("Content-Type", "application/json")
.useHttpGet()
.execute();
List<Parameters.ParametersParameterComponent> response = outParams.getParameter();
Assert.assertTrue(!response.isEmpty());
Parameters.ParametersParameterComponent component = response.get(0);
Assert.assertTrue(component.getResource() instanceof MeasureReport);
MeasureReport report = (MeasureReport) component.getResource();
Assert.assertEquals("Measure/"+measureId, report.getMeasure());
}
private Bundle loadBundle(String theLocation, FhirContext theCtx, IGenericClient theClient) throws IOException {
String json = stringFromResource(theLocation);
Bundle bundle = (Bundle) theCtx.newJsonParser().parseResource(json);
Bundle result = (Bundle) theClient.transaction().withBundle(bundle).execute();
return result;
}
// Fails with: ca.uhn.fhir.rest.server.exceptions.InternalErrorException: HTTP 500 :
// Failed to call access method: java.lang.IllegalArgumentException:
// Could not load library source for libraries referenced in Measure/Measure/measure-EXM125-FHIR4-7.2.000/_history/1.
//@Test //@Test
public void testCQLEvaluateMeasureEXM125() throws IOException {
String measureId = "measure-EXM125-FHIR4-7.2.000";
loadBundle("r4/EXM125/library-deps-EXM125_FHIR4-7.2.000-bundle.json", ourCtx, ourClient);
loadResource("r4/EXM125/library-EXM125_FHIR4-7.2.000.json", ourCtx, myDaoRegistry);
loadBundle("r4/EXM125/EXM125_FHIR4-7.2.000-bundle.json", ourCtx, ourClient);
loadResource("r4/EXM125/measure-EXM125_FHIR4-7.2.000.json", ourCtx, myDaoRegistry);
// http://localhost:8080/fhir/Measure/measure-EXM125-FHIR4-7.2.000/$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31
Parameters inParams = new Parameters();
// inParams.addParameter().setName("measure").setValue(new StringType("Measure/measure-EXM104-8.2.000"));
// inParams.addParameter().setName("patient").setValue(new StringType("Patient/numer-EXM104-FHIR3"));
inParams.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
inParams.addParameter().setName("periodEnd").setValue(new StringType("2019-12-31"));
Parameters outParams = ourClient
.operation()
.onInstance(new IdDt("Measure", measureId))
.named("$evaluate-measure")
.withParameters(inParams)
.cacheControl(new CacheControlDirective().setNoCache(true))
.withAdditionalHeader("Content-Type", "application/json")
.useHttpGet()
.execute();
List<Parameters.ParametersParameterComponent> response = outParams.getParameter();
Assert.assertTrue(!response.isEmpty());
Parameters.ParametersParameterComponent component = response.get(0);
Assert.assertTrue(component.getResource() instanceof MeasureReport);
MeasureReport report = (MeasureReport) component.getResource();
Assert.assertEquals("Measure/"+measureId, report.getMeasure());
}
// Fails with: ca.uhn.fhir.rest.server.exceptions.InternalErrorException: HTTP 500 :
// Failed to call access method: java.lang.IllegalArgumentException:
// Could not load library source for libraries referenced in Measure/Measure/measure-EXM130-FHIR4-7.2.000/_history/1.
//@Test
public void testCQLEvaluateMeasureEXM130() throws IOException {
String measureId = "measure-EXM130-FHIR4-7.2.000";
loadBundle("r4/EXM130/EXM130_FHIR4-7.2.000-bundle.json", ourCtx, ourClient);
// http://localhost:8080/fhir/Measure/measure-EXM130-FHIR4-7.2.000/$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31
Parameters inParams = new Parameters();
// inParams.addParameter().setName("measure").setValue(new StringType("Measure/measure-EXM104-8.2.000"));
// inParams.addParameter().setName("patient").setValue(new StringType("Patient/numer-EXM104-FHIR3"));
inParams.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
inParams.addParameter().setName("periodEnd").setValue(new StringType("2019-12-31"));
Parameters outParams = ourClient
.operation()
.onInstance(new IdDt("Measure", measureId))
.named("$evaluate-measure")
.withParameters(inParams)
.cacheControl(new CacheControlDirective().setNoCache(true))
.withAdditionalHeader("Content-Type", "application/json")
.useHttpGet()
.execute();
List<Parameters.ParametersParameterComponent> response = outParams.getParameter();
Assert.assertTrue(!response.isEmpty());
Parameters.ParametersParameterComponent component = response.get(0);
Assert.assertTrue(component.getResource() instanceof MeasureReport);
MeasureReport report = (MeasureReport) component.getResource();
Assert.assertEquals("Measure/"+measureId, report.getMeasure());
}
@Test
public void testWebsocketSubscription() throws Exception { public void testWebsocketSubscription() throws Exception {
/* /*
* Create subscription * Create subscription

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -114,7 +114,7 @@
"type": { "type": {
"coding": [ "coding": [
{ {
"system": "http://hl7.org/fhir/codesystem-library-type.html", "system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library" "code": "logic-library"
} }
] ]
@@ -158,7 +158,7 @@
"type": { "type": {
"coding": [ "coding": [
{ {
"system": "http://hl7.org/fhir/codesystem-library-type.html", "system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library" "code": "logic-library"
} }
] ]
@@ -255,7 +255,7 @@
"type": { "type": {
"coding": [ "coding": [
{ {
"system": "http://hl7.org/fhir/codesystem-library-type.html", "system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library" "code": "logic-library"
} }
] ]
@@ -2263,7 +2263,7 @@
"type": { "type": {
"coding": [ "coding": [
{ {
"system": "http://hl7.org/fhir/codesystem-library-type.html", "system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library" "code": "logic-library"
} }
] ]
@@ -3851,7 +3851,7 @@
"type": { "type": {
"coding": [ "coding": [
{ {
"system": "http://hl7.org/fhir/codesystem-library-type.html", "system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library" "code": "logic-library"
} }
] ]
@@ -3959,7 +3959,7 @@
"type": { "type": {
"coding": [ "coding": [
{ {
"system": "http://hl7.org/fhir/codesystem-library-type.html", "system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library" "code": "logic-library"
} }
] ]

File diff suppressed because one or more lines are too long