use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainNoParams.
@Test
public void testMainNoParams() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
setupTestFor(patient, fhirConfig, "cql.no-version");
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-t", tmpFile.getAbsolutePath(), "-f", "src/test/resources/cql/no-version", "-l", "Test", "-e", "Female", "-e", "Male", "-e", "Over the hill", "-c", "123" });
} finally {
System.setOut(originalOut);
}
String output = new String(baos.toByteArray());
String[] lines = output.split("\r?\n");
assertEquals(6, lines.length);
verify(1, getRequestedFor(urlEqualTo("/Patient/123?_format=json")));
} finally {
tmpFile.delete();
}
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainFHIRLibrariesWithDependencies.
@Test
public void testMainFHIRLibrariesWithDependencies() throws Exception {
FhirServerConfig fhirConfig = getFhirServerConfig();
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
mockFhirResourceRetrieval(patient);
Library root = getLibrary("Breast-Cancer-Screening", DEFAULT_RESOURCE_VERSION, "cql/includes/Breast-Cancer-Screening.cql");
Library helpers = getLibrary("FHIRHelpers", "4.0.0", "cql/fhir-helpers/FHIRHelpers.cql", "text/cql", "cql/fhir-helpers/FHIRHelpers.xml", "application/elm+json");
RelatedArtifact related = new RelatedArtifact();
related.setType(RelatedArtifactType.DEPENDSON);
related.setResource("/Library/" + helpers.getId());
root.addRelatedArtifact(related);
mockFhirResourceRetrieval(root);
mockFhirSingletonBundleRetrieval(helpers);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-f", root.getId(), "-l", root.getName(), "-v", root.getVersion(), "-c", patient.getId(), "-s", "CQL" });
} finally {
System.setOut(originalOut);
}
String output = new String(baos.toByteArray());
String[] lines = output.split("\r?\n");
assertEquals(output, 12, lines.length);
System.out.println(output);
verify(1, getRequestedFor(urlEqualTo("/Patient/" + patient.getId() + "?_format=json")));
verify(1, getRequestedFor(urlEqualTo("/Library/" + root.getId() + "?_format=json")));
} finally {
tmpFile.delete();
}
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainWithParams.
@Test
public void testMainWithParams() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
setupTestFor(patient, fhirConfig, "cql.parameters");
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-t", tmpFile.getAbsolutePath(), "-f", "src/test/resources/cql/parameters", "-l", "test-with", "-v", "params", "-e", "Female", "-e", "Male", "-c", "123", "-p", "MaxAge:integer:40" });
} finally {
System.setOut(originalOut);
}
String output = new String(baos.toByteArray());
String[] lines = output.split("\r?\n");
assertEquals(5, lines.length);
verify(1, getRequestedFor(urlEqualTo("/Patient/123?_format=json")));
} finally {
tmpFile.delete();
}
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainMultiFolder.
@Test
public void testMainMultiFolder() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
setupTestFor(patient, fhirConfig, "cql.multi-folder");
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-t", tmpFile.getAbsolutePath(), "-f", "src/test/resources/cql/multi-folder", "-l", "Cohort1", "-v", "1.0.0", "-c", "123" });
} finally {
System.setOut(originalOut);
}
String output = new String(baos.toByteArray());
String[] lines = output.split("\r?\n");
assertEquals(String.join("\n", lines), 5, lines.length);
verify(1, getRequestedFor(urlEqualTo("/Patient/123?_format=json")));
} finally {
tmpFile.delete();
}
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainNoContext.
@Test
public void testMainNoContext() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
setupTestFor(patient, fhirConfig, "cql.unfiltered-context");
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-t", tmpFile.getAbsolutePath(), "-f", "src/test/resources/cql/unfiltered-context", "-l", "UnfilteredContext", "-v", "1.0.0", "-e", "ValidateMath" });
} finally {
System.setOut(originalOut);
}
String output = baos.toString();
Assert.assertTrue(output.contains("Expression: \"ValidateMath\", Result: true"));
verify(0, getRequestedFor(urlEqualTo("/Patient/123?_format=json")));
} finally {
tmpFile.delete();
}
}
Aggregations