use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.
the class DefaultVT method testMeasureEvaluationByMeasureID.
// to tag a specific test to be part of DVT (deployment verification test)
@Category(DVT.class)
@Test
public /**
* Test a successful measure evaluation using Resource.id as the lookup key
*/
void testMeasureEvaluationByMeasureID() throws Exception {
// You want -Denabled.dark.features=all in your Liberty jvm.options
Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_MEASURE_EVALUATION));
final String RESOURCE = getUrlBase() + CohortServiceAPISpec.CREATE_DELETE_EVALUATION_PATH;
FhirContext fhirContext = FhirContext.forR4();
IParser parser = fhirContext.newJsonParser().setPrettyPrint(true);
Library library = TestHelper.getTemplateLibrary();
Measure measure = TestHelper.getTemplateMeasure(library);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
TestHelper.createMeasureArtifact(baos, parser, measure, library);
// Files.write( baos.toByteArray(), new File("target/test_measure_v1_0_0.zip"));
Map<String, Parameter> parameterOverrides = new HashMap<>();
parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
MeasureEvaluation requestData = new MeasureEvaluation();
requestData.setDataServerConfig(dataServerConfig);
requestData.setTerminologyServerConfig(termServerConfig);
// This is a patient ID that is assumed to exist in the target FHIR server
requestData.setPatientId(VALID_PATIENT_ID);
requestData.setMeasureContext(new MeasureContext(measure.getId(), parameterOverrides));
requestData.setEvidenceOptions(new MeasureEvidenceOptions(false, MeasureEvidenceOptions.DefineReturnOptions.NONE));
ObjectMapper om = new ObjectMapper();
System.out.println(om.writeValueAsString(requestData));
RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.MEASURE_PART, "test_measure_v1_0_0.zip", new ByteArrayInputStream(baos.toByteArray()));
ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
String expected = getJsonFromFile(ServiceAPIGlobalSpec.EXP_FOLDER_TYPE, "measure_evaluation_exp.json");
String actual = vr.extract().asString();
assertMeasureReportEquals(parser, expected, actual, false);
}
use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.
the class DefaultVT method testValueSetUpload.
@Test
public void testValueSetUpload() {
final String RESOURCE = getUrlBase() + "/{version}/valueset";
Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_VALUE_SET_UPLOAD));
// Create the metadata part of the request
ObjectMapper om = new ObjectMapper();
String fhirConfigjson = "";
try {
fhirConfigjson = om.writeValueAsString(dataServerConfig);
} catch (JsonProcessingException e) {
e.printStackTrace();
fail();
}
RequestSpecification request = buildBaseRequest(new Headers()).param(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).queryParam(CohortEngineRestHandler.UPDATE_IF_EXISTS_PARM, false).multiPart(CohortEngineRestHandler.FHIR_DATA_SERVER_CONFIG_PART, fhirConfigjson, "application/json").multiPart(CohortEngineRestHandler.VALUE_SET_PART, new File("src/test/resources/2.16.840.1.113762.1.4.1114.7.xlsx"));
ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_CREATED);
}
use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.
the class DefaultVT method testPatientListMeasureEvaluation.
// to tag a specific test to be part of DVT (deployment verification test)
@Category(DVT.class)
@Test
public /**
* Test a successful measure evaluation using Resource.id as the lookup key
*/
void testPatientListMeasureEvaluation() throws Exception {
// You want -Denabled.dark.features=all in your Liberty jvm.options
Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_PATIENT_LIST_MEASURE_EVALUATION));
final String RESOURCE = getUrlBase() + CohortServiceAPISpec.POST_PATIENT_LIST_EVALUATION_PATH;
FhirContext fhirContext = FhirContext.forR4();
IParser parser = fhirContext.newJsonParser().setPrettyPrint(true);
Library library = TestHelper.getTemplateLibrary();
Measure measure = TestHelper.getTemplateMeasure(library);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
TestHelper.createMeasureArtifact(baos, parser, measure, library);
Map<String, Parameter> parameterOverrides = new HashMap<>();
parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
;
PatientListMeasureEvaluation requestData = new PatientListMeasureEvaluation();
requestData.setDataServerConfig(dataServerConfig);
requestData.setTerminologyServerConfig(termServerConfig);
// These patients are assumed to exist in the target FHIR server
List<String> patientIds = new ArrayList<>();
patientIds.add(VALID_PATIENT_ID);
patientIds.add(ANOTHER_VALID_PATIENT_ID);
requestData.setPatientIds(patientIds);
requestData.setMeasureContext(new MeasureContext(measure.getId(), parameterOverrides));
requestData.setEvidenceOptions(new MeasureEvidenceOptions(false, MeasureEvidenceOptions.DefineReturnOptions.NONE));
ObjectMapper om = new ObjectMapper();
System.out.println(om.writeValueAsString(requestData));
RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.MEASURE_PART, "test_measure_v1_0_0.zip", new ByteArrayInputStream(baos.toByteArray()));
ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
String expected = getJsonFromFile(ServiceAPIGlobalSpec.EXP_FOLDER_TYPE, "patient_list_measure_evaluation_exp.json");
String actual = vr.extract().asString();
assertMeasureReportEquals(parser, expected, actual, true);
}
use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.
the class DefaultVT method testCohortEvaluationList.
@Test
public void testCohortEvaluationList() {
final String RESOURCE = getUrlBase() + "/{version}/cohort-evaluation";
Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_VALUE_SET_UPLOAD));
String SECOND_VALID_PATIENT_ID = "47c883bb-160a-7117-c5df-9344041ef048";
String patientInput = VALID_PATIENT_ID + "," + SECOND_VALID_PATIENT_ID;
// Create the metadata part of the request
CohortEvaluation requestData = new CohortEvaluation();
requestData.setDataServerConfig(dataServerConfig);
requestData.setTerminologyServerConfig(dataServerConfig);
requestData.setDefineToRun("Female");
requestData.setEntrypoint("cql/basic/Test-1.0.0.cql");
requestData.setPatientIds(patientInput);
requestData.setLoggingLevel(CqlDebug.TRACE);
RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.CQL_DEFINITION, new File("src/test/resources/cql/zip/Test-1.0.0.zip"));
ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
String actual = vr.extract().response().getBody().prettyPrint();
String expected = "{\n \"result\": [\n \"" + VALID_PATIENT_ID + "\",\n \"" + SECOND_VALID_PATIENT_ID + "\"\n ]\n}";
assertEquals(expected, actual);
}
use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.
the class DefaultVT method testCohortEvaluationTrue.
@Test
public void testCohortEvaluationTrue() {
final String RESOURCE = getUrlBase() + "/{version}/cohort-evaluation";
Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_VALUE_SET_UPLOAD));
// Create the metadata part of the request
CohortEvaluation requestData = new CohortEvaluation();
requestData.setDataServerConfig(dataServerConfig);
requestData.setTerminologyServerConfig(dataServerConfig);
requestData.setDefineToRun("Female");
requestData.setEntrypoint("Test-1.0.0.cql");
requestData.setPatientIds(VALID_PATIENT_ID);
RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.CQL_DEFINITION, new File("src/test/resources/cql/zip/Test-1.0.0.zip"));
ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
CohortResult actual = vr.extract().response().getBody().as(CohortResult.class);
CohortResult expected = new CohortResult(Collections.singletonList(VALID_PATIENT_ID));
assertEquals(expected, actual);
}
Aggregations