Search in sources :

Example 41 with Code

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

the class DataRowRetrieveProviderTest method testRetrieveFilterByProvidedCodes_dataForCodeIsString.

@Test
public void testRetrieveFilterByProvidedCodes_dataForCodeIsString() {
    String maleId = "789";
    List<Object> people = makePeopleTestData(maleId);
    data.put(DATATYPE_PERSON, people);
    List<Code> codes = Arrays.asList(GENDER_MALE).stream().map(this::code).collect(Collectors.toList());
    Iterable<Object> rows = retrieveProvider.retrieve(CONTEXT_CLAIM, FIELD_PERSON_ID, null, DATATYPE_PERSON, null, FIELD_GENDER, codes, null, null, null, null, null);
    int count = 0;
    for (Object obj : rows) {
        count++;
        DataRow actual = (DataRow) obj;
        assertEquals(maleId, actual.getValue(FIELD_PERSON_ID));
    }
    assertEquals(1, count);
}
Also used : Code(org.opencds.cqf.cql.engine.runtime.Code) SimpleDataRow(com.ibm.cohort.datarow.model.SimpleDataRow) DataRow(com.ibm.cohort.datarow.model.DataRow) Test(org.junit.Test)

Example 42 with Code

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

the class CodeKeyTest method testCodeKeysEqualDifferentDisplay.

@Test
public void testCodeKeysEqualDifferentDisplay() {
    Code baseline = new Code().withCode("123").withSystem("http://snomed.info/sct").withDisplay("display").withVersion("20200809");
    CodeKey left = new CodeKey(baseline);
    CodeKey right = new CodeKey(baseline);
    right.withDisplay(right.getDisplay() + " does not match");
    assertEquals(left, right);
}
Also used : Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Example 43 with Code

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

the class CodeKeyTest method testUseCodeAsMapKeyFails.

@Test
public void testUseCodeAsMapKeyFails() {
    Map<Object, String> map = new HashMap<>();
    map.put(new Code().withCode("123"), "123");
    map.put(new Code().withCode("456"), "456");
    map.put(new Code().withCode("789"), "789");
    map.put(new Code().withCode("123").withSystem("http://snomed.info/sct"), "SNOMED");
    map.put(new Code().withCode("123").withSystem("http://snomed.info/sct").withDisplay("display"), "Display");
    assertEquals(5, map.size());
    String value = map.get(new Code().withCode("123"));
    assertNull("Lookup by Code shouldn't work", value);
}
Also used : HashMap(java.util.HashMap) Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Example 44 with Code

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

the class CodeKeyTest method testCodeKeysAreEqual.

@Test
public void testCodeKeysAreEqual() {
    Code data = new Code().withCode("123").withSystem("http://snomed.info/sct").withDisplay("display").withVersion("20200809");
    CodeKey left = new CodeKey(data);
    CodeKey right = new CodeKey(data);
    assertEquals(left, right);
}
Also used : Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Example 45 with Code

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

the class CodeKeyTest method testCodeKeysEqualCodeOnly.

@Test
public void testCodeKeysEqualCodeOnly() {
    Code baseline = new Code().withCode("123");
    CodeKey left = new CodeKey(baseline);
    CodeKey right = new CodeKey(baseline);
    assertEquals(left, right);
}
Also used : Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Aggregations

Code (org.opencds.cqf.cql.engine.runtime.Code)45 Test (org.junit.Test)35 ValueSetInfo (org.opencds.cqf.cql.engine.terminology.ValueSetInfo)17 Parameters (org.hl7.fhir.r4.model.Parameters)6 HashMap (java.util.HashMap)5 Metadata (org.apache.spark.sql.types.Metadata)4 ValueSet (org.hl7.fhir.r4.model.ValueSet)4 BaseSparkTest (com.ibm.cohort.cql.spark.BaseSparkTest)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 MetadataBuilder (org.apache.spark.sql.types.MetadataBuilder)3 BooleanType (org.hl7.fhir.r4.model.BooleanType)3 CodeSystemInfo (org.opencds.cqf.cql.engine.terminology.CodeSystemInfo)3 DataRow (com.ibm.cohort.datarow.model.DataRow)2 VersionedIdentifier (org.cqframework.cql.elm.execution.VersionedIdentifier)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 ConfigurationException (ca.uhn.fhir.context.ConfigurationException)1 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 CodeKey (com.ibm.cohort.datarow.model.CodeKey)1 SimpleDataRow (com.ibm.cohort.datarow.model.SimpleDataRow)1