use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureCLITest method testCohortMeasureByURLSinglePatientCommandLineInput.
@Test
public void testCohortMeasureByURLSinglePatientCommandLineInput() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1592-14-03");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("Test", DEFAULT_RESOURCE_VERSION, "cql/basic/Test-1.0.0.cql");
Measure measure = getCohortMeasure("Test", library, "Female");
mockMeasureRetrieval(measure);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(getFhirServerConfig()));
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
try {
MeasureCLI cli = new MeasureCLI();
cli.runWithArgs(new String[] { "-d", tmpFile.getAbsolutePath(), "-p", "p1:interval:decimal,1.0,100.5", "-p", "p2:integer:1", "-r", CanonicalHelper.toCanonicalUrl(measure.getUrl(), measure.getVersion()), "-c", patient.getId() }, out);
} finally {
tmpFile.delete();
}
String output = new String(baos.toByteArray());
String[] lines = output.split(System.getProperty("line.separator"));
assertEquals(output, 4, lines.length);
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureCLITest method testProportionRatioSinglePatient.
@Test
public void testProportionRatioSinglePatient() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = new Patient();
patient.setId("123");
patient.setGender(AdministrativeGender.MALE);
OffsetDateTime birthDate = OffsetDateTime.now().minusYears(30);
patient.setBirthDate(Date.from(birthDate.toInstant()));
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("Test", DEFAULT_RESOURCE_VERSION, "cql/basic/Test-1.0.0.cql");
expressionsByPopulationType.clear();
expressionsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, "Male");
expressionsByPopulationType.put(MeasurePopulationType.DENOMINATOR, "Male");
expressionsByPopulationType.put(MeasurePopulationType.NUMERATOR, "Over the hill");
expectationsByPopulationType.clear();
expectationsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, 1);
expectationsByPopulationType.put(MeasurePopulationType.DENOMINATOR, 1);
expectationsByPopulationType.put(MeasurePopulationType.NUMERATOR, 0);
Measure measure = getProportionMeasure("Test", library, expressionsByPopulationType);
mockFhirResourceRetrieval(measure);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(getFhirServerConfig()));
}
File tmpMeasureConfigurationsFile = createTmpConfigurationsFileForSingleMeasure(measure.getId());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
try {
MeasureCLI cli = new MeasureCLI();
cli.runWithArgs(new String[] { "-d", tmpFile.getAbsolutePath(), "-j", tmpMeasureConfigurationsFile.getAbsolutePath(), "-c", patient.getId() }, out);
} finally {
tmpFile.delete();
tmpMeasureConfigurationsFile.delete();
}
String output = new String(baos.toByteArray());
System.out.println(output);
String[] lines = output.split(System.getProperty("line.separator"));
assertEquals(output, 6, lines.length);
assertTextPopulationExpectations(lines);
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureCLITest method testJsonFormattedOutput.
@Test
public void testJsonFormattedOutput() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1592-14-03");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("Test", DEFAULT_RESOURCE_VERSION, "cql/basic/Test-1.0.0.cql");
Measure measure = getCohortMeasure("Test", library, "Male");
mockFhirResourceRetrieval(measure);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(getFhirServerConfig()));
}
File tmpMeasureConfigurationsFile = createTmpConfigurationsFileForSingleMeasure(measure.getId());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
try {
MeasureCLI cli = new MeasureCLI();
cli.runWithArgs(new String[] { "-d", tmpFile.getAbsolutePath(), "-j", tmpMeasureConfigurationsFile.getAbsolutePath(), "-c", patient.getId(), "-f", "JSON" }, out);
} finally {
tmpFile.delete();
tmpMeasureConfigurationsFile.delete();
}
String output = new String(baos.toByteArray());
System.out.println(output);
assertTrue(output.contains("\"resourceType\": \"MeasureReport\""));
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureCLITest method testCohortMeasureSinglePatientJsonInputWithCacheDisabled.
@Test
public void testCohortMeasureSinglePatientJsonInputWithCacheDisabled() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1592-14-03");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("Test", DEFAULT_RESOURCE_VERSION, "cql/basic/Test-1.0.0.cql");
Measure measure = getCohortMeasure("Test", library, "Female");
mockFhirResourceRetrieval(measure);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(getFhirServerConfig()));
}
File tmpMeasureConfigurationsFile = createTmpConfigurationsFileForSingleMeasure(measure.getId());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
try {
MeasureCLI cli = new MeasureCLI();
cli.runWithArgs(new String[] { "-d", tmpFile.getAbsolutePath(), "-j", tmpMeasureConfigurationsFile.getAbsolutePath(), "-c", patient.getId(), "--disable-retrieve-cache" }, out);
} finally {
tmpFile.delete();
tmpMeasureConfigurationsFile.delete();
}
String output = new String(baos.toByteArray());
String[] lines = output.split(System.lineSeparator());
assertEquals(output, 4, lines.length);
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureCLITest method testCohortMeasureByIDSinglePatientCommandLineInput.
@Test
public void testCohortMeasureByIDSinglePatientCommandLineInput() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1592-14-03");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("Test", DEFAULT_RESOURCE_VERSION, "cql/basic/Test-1.0.0.cql");
Measure measure = getCohortMeasure("Test", library, "Female");
mockFhirResourceRetrieval(measure);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(getFhirServerConfig()));
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
try {
MeasureCLI cli = new MeasureCLI();
cli.runWithArgs(new String[] { "-d", tmpFile.getAbsolutePath(), "-p", "p1:interval:decimal,1.0,100.5", "-p", "p2:integer:1", "-r", measure.getId(), "-c", patient.getId() }, out);
} finally {
tmpFile.delete();
}
String output = new String(baos.toByteArray());
String[] lines = output.split(System.getProperty("line.separator"));
assertEquals(output, 4, lines.length);
}
Aggregations