Added a new Integration Test to verify the Measure resource's evaluate-measure Operation.
This commit is contained in:
@@ -2,28 +2,38 @@ package ca.uhn.fhir.jpa.starter;
|
|||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.cql.provider.CqlProviderLoader;
|
import ca.uhn.fhir.cql.provider.CqlProviderLoader;
|
||||||
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.rest.api.CacheControlDirective;
|
import ca.uhn.fhir.rest.api.CacheControlDirective;
|
||||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.eclipse.jetty.websocket.api.Session;
|
import org.eclipse.jetty.websocket.api.Session;
|
||||||
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
|
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
|
||||||
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
||||||
import org.hl7.fhir.dstu3.model.Bundle;
|
import org.hl7.fhir.dstu3.model.*;
|
||||||
import org.hl7.fhir.dstu3.model.Observation;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.dstu3.model.Patient;
|
|
||||||
import org.hl7.fhir.dstu3.model.Subscription;
|
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.web.server.LocalServerPort;
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
import org.springframework.core.io.DefaultResourceLoader;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -66,14 +76,78 @@ public class ExampleServerDstu3IT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCQLAvailable() {
|
public void testCQLEvaluateMeasure() throws IOException {
|
||||||
CqlProviderLoader cqlProviderLoader = null;
|
CqlProviderLoader cqlProviderLoader = null;
|
||||||
|
|
||||||
// FIXME KBD Remove this and put some Unit Test code here
|
// FIXME KBD Remove this and put some Unit Test code here
|
||||||
for (String resourceType : ourCtx.getResourceTypes()) {
|
loadBundle("dstu3/EXM104/EXM104_FHIR3-8.1.000-bundle.json");
|
||||||
System.out.println("resourceType = '" + resourceType + "'");
|
|
||||||
|
Parameters inParams = new Parameters();
|
||||||
|
inParams.addParameter().setName("patientId").setValue(new StringType("Patient/numer-EXM104-FHIR3"));
|
||||||
|
inParams.addParameter().setName("periodStart").setValue(new DateType("2019-01-01"));
|
||||||
|
inParams.addParameter().setName("periodEnd").setValue(new DateType("2019-12-31"));
|
||||||
|
|
||||||
|
Parameters outParams = ourClient
|
||||||
|
.operation()
|
||||||
|
.onInstance(new IdDt("Measure", "measure-EXM104-FHIR3-8.1.000"))
|
||||||
|
.named("$evaluate-measure")
|
||||||
|
.withParameters(inParams)
|
||||||
|
.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();
|
||||||
|
|
||||||
|
for (MeasureReport.MeasureReportGroupComponent group : report.getGroup()) {
|
||||||
|
for (MeasureReport.MeasureReportGroupPopulationComponent population : group.getPopulation()) {
|
||||||
|
Assert.assertTrue(population.getCount() > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void putResource(String resourceFileName, String id) {
|
||||||
|
InputStream is = ExampleServerDstu3IT.class.getResourceAsStream(resourceFileName);
|
||||||
|
Scanner scanner = new Scanner(is).useDelimiter("\\A");
|
||||||
|
String json = scanner.hasNext() ? scanner.next() : "";
|
||||||
|
|
||||||
|
boolean isJson = resourceFileName.endsWith("json");
|
||||||
|
|
||||||
|
IBaseResource resource = isJson ? ourCtx.newJsonParser().parseResource(json) : ourCtx.newXmlParser().parseResource(json);
|
||||||
|
|
||||||
|
if (resource instanceof Bundle) {
|
||||||
|
ourClient.transaction().withBundle((Bundle) resource).execute();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ourClient.update().resource(resource).withId(id).execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bundle loadBundle(String theLocation) throws IOException {
|
||||||
|
String json = stringFromResource(theLocation);
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newJsonParser().parseResource(json);
|
||||||
|
Bundle result = (Bundle) ourClient.transaction().withBundle(bundle).execute();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String stringFromResource(String theLocation) throws IOException {
|
||||||
|
InputStream is = null;
|
||||||
|
if (theLocation.startsWith(File.separator)) {
|
||||||
|
is = new FileInputStream(theLocation);
|
||||||
|
} else {
|
||||||
|
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||||
|
Resource resource = resourceLoader.getResource(theLocation);
|
||||||
|
is = resource.getInputStream();
|
||||||
|
}
|
||||||
|
return IOUtils.toString(is, Charsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWebsocketSubscription() throws Exception {
|
public void testWebsocketSubscription() throws Exception {
|
||||||
/*
|
/*
|
||||||
|
|||||||
4409
src/test/resources/dstu3/EXM104/EXM104_FHIR3-8.1.000-bundle.json
Normal file
4409
src/test/resources/dstu3/EXM104/EXM104_FHIR3-8.1.000-bundle.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user