Search in sources :

Example 1 with Time

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

the class CQLToFHIRMeasureReportHelperTest method testTime.

@Test
public void testTime() {
    String timeString = "00:10:00.000";
    Time expected = new Time(timeString);
    IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(expected);
    assertTrue(fhirTypeValue instanceof TimeType);
    assertEquals(timeString, ((TimeType) fhirTypeValue).getValueAsString());
}
Also used : IBaseDatatype(org.hl7.fhir.instance.model.api.IBaseDatatype) LocalDateTime(java.time.LocalDateTime) Time(org.opencds.cqf.cql.engine.runtime.Time) OffsetDateTime(java.time.OffsetDateTime) DateTime(org.opencds.cqf.cql.engine.runtime.DateTime) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) TimeType(org.hl7.fhir.r4.model.TimeType) Test(org.junit.Test)

Example 2 with Time

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

the class CQLToFHIRMeasureReportHelperTest method testIntervalTime_shouldReturnNull.

/*
	 *  Currently only supporting CQL intervals of type DateTime or Quantity.
	 *  Support for intervals of other types may be added in the future.
	 */
@Test
public void testIntervalTime_shouldReturnNull() {
    String startTimeString = "00:10:00.000";
    String endTimeString = "00:15:00.000";
    Time startTime = new Time(startTimeString);
    Time endTime = new Time(endTimeString);
    Interval interval = new Interval(startTime, true, endTime, true);
    assertNull(CQLToFHIRMeasureReportHelper.getFhirTypeValue(interval));
}
Also used : LocalDateTime(java.time.LocalDateTime) Time(org.opencds.cqf.cql.engine.runtime.Time) OffsetDateTime(java.time.OffsetDateTime) DateTime(org.opencds.cqf.cql.engine.runtime.DateTime) Interval(org.opencds.cqf.cql.engine.runtime.Interval) Test(org.junit.Test)

Example 3 with Time

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

the class SparkTypeConverter method toSparkTime.

public Object toSparkTime(Object obj) {
    Object result = null;
    if (obj != null) {
        if (obj instanceof Time) {
            Time time = (Time) obj;
            Map<String, Object> map = new HashMap<>();
            map.put(SYSTEM_TYPE_PROPERTY, "Time");
            map.put("value", toSparkType(time.getTime().toString()));
            result = JavaConverters.mapAsScalaMap(map);
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) DateTime(org.opencds.cqf.cql.engine.runtime.DateTime) Time(org.opencds.cqf.cql.engine.runtime.Time)

Aggregations

DateTime (org.opencds.cqf.cql.engine.runtime.DateTime)3 Time (org.opencds.cqf.cql.engine.runtime.Time)3 LocalDateTime (java.time.LocalDateTime)2 OffsetDateTime (java.time.OffsetDateTime)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 IBaseDatatype (org.hl7.fhir.instance.model.api.IBaseDatatype)1 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)1 TimeType (org.hl7.fhir.r4.model.TimeType)1 Interval (org.opencds.cqf.cql.engine.runtime.Interval)1