use of org.hl7.fhir.r5.model.Expression in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testDataBundleCqlExecutionProviderWithSubject.
@Test
public void testDataBundleCqlExecutionProviderWithSubject() throws Exception {
Parameters params = new Parameters();
Parameters libraryParameter = new Parameters();
params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
params.addParameter().setName("data").setResource(data);
params.addParameter().setName("useServerData").setValue(new BooleanType(false));
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r5.model.Expression in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testDataBundleCqlExecutionProvider.
@Test
public void testDataBundleCqlExecutionProvider() throws Exception {
Parameters params = new Parameters();
Parameters libraryParameter = new Parameters();
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
params.addParameter().setName("data").setResource(data);
params.addParameter().setName("useServerData").setValue(new BooleanType(false));
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r5.model.Expression in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testReferencedLibraryCqlExecutionProvider.
@Test
public void testReferencedLibraryCqlExecutionProvider() throws Exception {
Parameters params = new Parameters();
params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
Parameters libraryParameter = new Parameters();
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"simpleBooleanExpression\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(0).getValue()).asStringValue().equals("true"));
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("Boolean"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r5.model.Expression in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainNonPatientContext.
@Test
public void testMainNonPatientContext() throws Exception {
Encounter encounter = new Encounter();
encounter.setId("123");
encounter.setStatus(Encounter.EncounterStatus.FINISHED);
Encounter otherEncounter = new Encounter();
otherEncounter.setId("234");
otherEncounter.setStatus(Encounter.EncounterStatus.FINISHED);
FhirServerConfig fhirConfig = getFhirServerConfig();
String resourcePath = "/Encounter?_count=1000&_format=json";
mockFhirResourceRetrieval(resourcePath, getFhirParser(), makeBundle(encounter, otherEncounter));
setupTestFor(encounter, fhirConfig, "cql.encounter-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/encounter-context", "-l", "EncounterContext", "-v", "1.0.0", "-e", "ValidEncounterCount", "-n", "Encounter" });
} finally {
System.setOut(originalOut);
}
String output = baos.toString();
assertTrue(output.contains("Expression: \"ValidEncounterCount\", Result: 2"));
verify(1, getRequestedFor(urlEqualTo(resourcePath)));
} finally {
tmpFile.delete();
}
}
use of org.hl7.fhir.r5.model.Expression in project quality-measure-and-cohort-service by Alvearie.
the class FhirTestBase method createSupplementalDataComponent.
protected MeasureSupplementalDataComponent createSupplementalDataComponent(String defineName, String text) {
MeasureSupplementalDataComponent supplementalDataComponent = new MeasureSupplementalDataComponent();
CodeableConcept supplementalCC = new CodeableConcept();
Coding supplementalCoding = new Coding();
supplementalCoding.setCode("supplemental-data-coding");
supplementalCC.setCoding(Arrays.asList(supplementalCoding));
supplementalCC.setText(text);
supplementalDataComponent.setCode(supplementalCC);
CodeableConcept usage = new CodeableConcept();
Coding usageCoding = new Coding();
usageCoding.setCode("supplemental-data");
usage.setCoding(Arrays.asList(usageCoding));
supplementalDataComponent.setUsage(Arrays.asList(usage));
Expression supplementalExpression = new Expression();
supplementalExpression.setExpression(defineName);
supplementalExpression.setLanguage("text/cql.identifier");
supplementalDataComponent.setCriteria(supplementalExpression);
return supplementalDataComponent;
}
Aggregations