Search in sources :

Example 11 with Code

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

the class R4FileSystemFhirTerminologyProvider method expand.

/* (non-Javadoc)
	 * 
	 * Returns the list of Codes in the given ValueSet
	 * 
	 * @see org.opencds.cqf.cql.engine.terminology.TerminologyProvider#expand(org.opencds.cqf.cql.engine.terminology.ValueSetInfo)
	 */
@Override
public Iterable<Code> expand(ValueSetInfo valueSetInfo) {
    LOG.debug("Entry: expand() ValueSet.getId=[{}] version=[{}]", valueSetInfo.getId(), valueSetInfo.getVersion());
    loadFromFile(valueSetInfo);
    VersionedIdentifier valueSetIdentifier = createVersionedIdentifierForValueSet(valueSetInfo);
    List<Code> codes = valueSetCodeCache.get(valueSetIdentifier);
    LOG.debug("Exit: expand() ValueSet.getId=[{}] version=[{}] found {} codes", valueSetInfo.getId(), valueSetInfo.getVersion(), codes.size());
    return codes;
}
Also used : VersionedIdentifier(org.cqframework.cql.elm.execution.VersionedIdentifier) Code(org.opencds.cqf.cql.engine.runtime.Code)

Example 12 with Code

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

the class SparkTypeConverter method toSparkCode.

public Object toSparkCode(Object obj) {
    Object result = null;
    if (obj != null) {
        if (obj instanceof Code) {
            Code code = (Code) obj;
            Map<String, Object> map = new HashMap<>();
            map.put(SYSTEM_TYPE_PROPERTY, "Code");
            map.put("code", code.getCode());
            map.put("system", code.getSystem());
            map.put("display", code.getDisplay());
            result = JavaConverters.mapAsScalaMap(map);
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Code(org.opencds.cqf.cql.engine.runtime.Code)

Example 13 with Code

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

the class CodeKeyTest method testCodeKeysEqualDifferentVersion.

@Test
public void testCodeKeysEqualDifferentVersion() {
    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.withVersion(right.getVersion() + ".rc1");
    assertEquals(left, right);
}
Also used : Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Example 14 with Code

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

the class CodeKeyTest method testCodeKeyMirrorsCodeFields.

@Test
public void testCodeKeyMirrorsCodeFields() {
    Code expected = new Code().withCode("123").withSystem("http://snomed.info/sct").withDisplay("display").withVersion("20200809");
    CodeKey actual = new CodeKey(expected);
    assertEquals(expected.getCode(), actual.getCode());
    assertEquals(expected.getSystem(), actual.getSystem());
    assertEquals(expected.getDisplay(), actual.getDisplay());
    assertEquals(expected.getVersion(), actual.getVersion());
}
Also used : Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Example 15 with Code

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

the class CodeKeyTest method testCodeKeysNotEqualMissingSystem.

@Test
public void testCodeKeysNotEqualMissingSystem() {
    Code data = new Code().withCode("123").withSystem("http://snomed.info/sct").withDisplay("display").withVersion("20200809");
    CodeKey codeKeyWithSystem = new CodeKey(data);
    CodeKey codeKeyWithoutSystem = new CodeKey(data.withSystem(null));
    assertNotEquals(codeKeyWithSystem, codeKeyWithoutSystem);
}
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