Search in sources :

Example 1 with CodeSystemInfo

use of org.opencds.cqf.cql.engine.terminology.CodeSystemInfo in project quality-measure-and-cohort-service by Alvearie.

the class CQLParameterTests method runTest.

public void runTest(String type, Object expectedOutput, String defaultValue) throws Exception {
    String cql = "library \"Test\" version '1.0.0'\n";
    cql += "codesystem \"DUMMY\": 'urn:mysystem'\n";
    cql += "parameter Input " + type;
    if (defaultValue != null) {
        cql += " default ";
        cql += defaultValue;
    }
    cql += "\n";
    cql += "define Output:\n\tInput\n";
    Map<String, Object> parameters = null;
    if (defaultValue == null) {
        parameters = new HashMap<>();
        parameters.put("Input", expectedOutput);
    }
    TerminologyProvider tp = new TerminologyProvider() {

        @Override
        public boolean in(Code code, ValueSetInfo valueSet) {
            return false;
        }

        @Override
        public Iterable<Code> expand(ValueSetInfo valueSet) {
            return null;
        }

        @Override
        public Code lookup(Code code, CodeSystemInfo codeSystem) {
            return code;
        }
    };
    LibraryLoader ll = new InMemoryLibraryLoader(Arrays.asList(toLibrary(cql)));
    CqlEngine engine = new CqlEngine(ll, Collections.<String, DataProvider>emptyMap(), tp);
    EvaluationResult result = engine.evaluate("Test", parameters);
    assertEquals(1, result.expressionResults.size());
    Object actual = result.forExpression("Output");
    assertEquals(expectedOutput.toString(), actual.toString());
}
Also used : CodeSystemInfo(org.opencds.cqf.cql.engine.terminology.CodeSystemInfo) TerminologyProvider(org.opencds.cqf.cql.engine.terminology.TerminologyProvider) CqlEngine(org.opencds.cqf.cql.engine.execution.CqlEngine) Code(org.opencds.cqf.cql.engine.runtime.Code) ValueSetInfo(org.opencds.cqf.cql.engine.terminology.ValueSetInfo) LibraryLoader(org.opencds.cqf.cql.engine.execution.LibraryLoader) InMemoryLibraryLoader(org.opencds.cqf.cql.engine.execution.InMemoryLibraryLoader) InMemoryLibraryLoader(org.opencds.cqf.cql.engine.execution.InMemoryLibraryLoader) EvaluationResult(org.opencds.cqf.cql.engine.execution.EvaluationResult)

Example 2 with CodeSystemInfo

use of org.opencds.cqf.cql.engine.terminology.CodeSystemInfo in project quality-measure-and-cohort-service by Alvearie.

the class R4RestFhirTerminologyProviderTest method nonNullCodesystemsUnsupported.

@Test(expected = UnsupportedOperationException.class)
public void nonNullCodesystemsUnsupported() {
    CodeSystemInfo codeSystem = new CodeSystemInfo();
    codeSystem.setId("SNOMED-CT");
    codeSystem.setVersion("2013-09");
    ValueSetInfo info = new ValueSetInfo();
    info.setId("urn:oid:Test");
    info.getCodeSystems().add(codeSystem);
    provider.resolveByUrl(info);
}
Also used : CodeSystemInfo(org.opencds.cqf.cql.engine.terminology.CodeSystemInfo) ValueSetInfo(org.opencds.cqf.cql.engine.terminology.ValueSetInfo) Test(org.junit.Test)

Example 3 with CodeSystemInfo

use of org.opencds.cqf.cql.engine.terminology.CodeSystemInfo in project quality-measure-and-cohort-service by Alvearie.

the class R4RestFhirTerminologyProviderTest method lookupOperationSuccess.

@Test
public void lookupOperationSuccess() throws Exception {
    CodeSystemInfo info = new CodeSystemInfo();
    info.setId(TEST_SYSTEM);
    info.setVersion(TEST_SYSTEM_VERSION);
    Code code = new Code();
    code.setCode(TEST_CODE);
    code.setSystem(TEST_SYSTEM);
    code.setDisplay(TEST_DISPLAY);
    Parameters parameters = new Parameters();
    parameters.addParameter().setName("name").setValue(new StringType(code.getCode()));
    parameters.addParameter().setName("version").setValue(new StringType(info.getVersion()));
    parameters.addParameter().setName("display").setValue(new StringType(code.getDisplay()));
    mockFhirResourceRetrieval(post(urlEqualTo("/CodeSystem/$lookup?_format=json")), parameters);
    Code result = provider.lookup(code, info);
    assertNotNull(result);
    assertEquals(result.getSystem(), code.getSystem());
    assertEquals(result.getCode(), code.getCode());
    assertEquals(result.getDisplay(), code.getDisplay());
}
Also used : CodeSystemInfo(org.opencds.cqf.cql.engine.terminology.CodeSystemInfo) Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Example 4 with CodeSystemInfo

use of org.opencds.cqf.cql.engine.terminology.CodeSystemInfo in project quality-measure-and-cohort-service by Alvearie.

the class R4FileSystemFhirTerminologyProviderTest method lookupOperationSuccess.

@Test(expected = UnsupportedOperationException.class)
public void lookupOperationSuccess() throws Exception {
    CodeSystemInfo info = new CodeSystemInfo();
    info.setId(TEST_SYSTEM);
    info.setVersion(TEST_SYSTEM_VERSION1);
    Code code = new Code();
    code.setCode(TEST_CODE);
    code.setSystem(TEST_SYSTEM);
    code.setDisplay(TEST_DISPLAY);
    provider.lookup(code, info);
}
Also used : CodeSystemInfo(org.opencds.cqf.cql.engine.terminology.CodeSystemInfo) Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Aggregations

CodeSystemInfo (org.opencds.cqf.cql.engine.terminology.CodeSystemInfo)4 Test (org.junit.Test)3 Code (org.opencds.cqf.cql.engine.runtime.Code)3 ValueSetInfo (org.opencds.cqf.cql.engine.terminology.ValueSetInfo)2 Parameters (org.hl7.fhir.r4.model.Parameters)1 StringType (org.hl7.fhir.r4.model.StringType)1 CqlEngine (org.opencds.cqf.cql.engine.execution.CqlEngine)1 EvaluationResult (org.opencds.cqf.cql.engine.execution.EvaluationResult)1 InMemoryLibraryLoader (org.opencds.cqf.cql.engine.execution.InMemoryLibraryLoader)1 LibraryLoader (org.opencds.cqf.cql.engine.execution.LibraryLoader)1 TerminologyProvider (org.opencds.cqf.cql.engine.terminology.TerminologyProvider)1