Search in sources :

Example 96 with DateTime

use of org.hl7.elm.r1.DateTime in project odm2fhir by num-codex.

the class OrganRecipient method createCondition.

private Condition createCondition(ItemData transplantCoding) {
    var condition = (Condition) new Condition().addIdentifier(createIdentifier(CONDITION, transplantCoding)).setRecordedDateElement(// TODO Set actual DateTime value
    UNKNOWN_DATE_TIME).addCategory(createCodeableConcept(createCoding(SNOMED_CT, "788415003", "Transplant medicine (qualifier value)"))).setMeta(createMeta(ORGAN_RECIPIENT));
    var codeCodeableConcept = new CodeableConcept();
    var bodySiteCodeableConcept = new CodeableConcept();
    for (var coding : createCodings(transplantCoding)) {
        switch(coding.getCode()) {
            case // YES
            "410605003":
                condition.setClinicalStatus(ACTIVE).setVerificationStatus(CONFIRMED);
                break;
            case // NO
            "410594000":
                condition.setVerificationStatus(REFUTED);
                break;
            case // UNKNOWN
            "261665006":
                condition.addModifierExtension(DATA_PRESENCE_UNKNOWN);
                break;
            default:
                if (ICD_10_GM.getUrl().equals(coding.getSystem())) {
                    // add ICD Code
                    codeCodeableConcept.addCoding(coding);
                } else if (SNOMED_CT.getUrl().equals(coding.getSystem())) {
                    // add SNOMED Code of bodySite
                    bodySiteCodeableConcept.addCoding(coding);
                }
        }
    }
    if (!bodySiteCodeableConcept.isEmpty()) {
        condition.addBodySite(bodySiteCodeableConcept);
    }
    // bodySite CAN be empty, but Code MUST NOT be empty
    return codeCodeableConcept.isEmpty() ? new Condition() : condition.setCode(codeCodeableConcept);
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 97 with DateTime

use of org.hl7.elm.r1.DateTime in project pathling by aehrc.

the class DateTimePath method valueFromRow.

/**
 * Gets a value from a row for a DateTime or DateTime literal.
 *
 * @param row The {@link Row} from which to extract the value
 * @param columnNumber The column number to extract the value from
 * @param fhirType The FHIR type to assume when extracting the value
 * @return A {@link BaseDateTimeType}, or the absence of a value
 */
@Nonnull
public static Optional<BaseDateTimeType> valueFromRow(@Nonnull final Row row, final int columnNumber, final FHIRDefinedType fhirType) {
    if (row.isNullAt(columnNumber)) {
        return Optional.empty();
    }
    if (fhirType == FHIRDefinedType.INSTANT) {
        final InstantType value = new InstantType(row.getTimestamp(columnNumber));
        value.setTimeZone(TIME_ZONE);
        return Optional.of(value);
    } else {
        final DateTimeType value = new DateTimeType(row.getString(columnNumber));
        value.setTimeZone(TIME_ZONE);
        return Optional.of(value);
    }
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) BaseDateTimeType(org.hl7.fhir.r4.model.BaseDateTimeType) InstantType(org.hl7.fhir.r4.model.InstantType) Nonnull(javax.annotation.Nonnull)

Example 98 with DateTime

use of org.hl7.elm.r1.DateTime in project quality-measure-and-cohort-service by Alvearie.

the class CQLToFHIRMeasureReportHelperTest method testIntervalDateTime_shouldReturnPeriodInUTC.

@Test
public void testIntervalDateTime_shouldReturnPeriodInUTC() {
    DateTime startDateTime = new DateTime(OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 0, 10, 5, 0), ZoneOffset.of("Z")));
    DateTime endDateTime = new DateTime(OffsetDateTime.of(LocalDateTime.of(2020, 2, 15, 15, 10, 0, 0), ZoneOffset.of("+01:00")));
    Interval interval = new Interval(startDateTime, true, endDateTime, true);
    IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(interval);
    // Expect output expressed in UTC
    DateTimeType expectedStart = new DateTimeType("2020-01-01T00:10:05+00:00");
    DateTimeType expectedEnd = new DateTimeType("2020-02-15T14:10:00+00:00");
    assertTrue(fhirTypeValue instanceof Period);
    Period castResult = (Period) fhirTypeValue;
    assertEquals(expectedStart.toHumanDisplay(), castResult.getStartElement().toHumanDisplay());
    assertEquals(expectedEnd.toHumanDisplay(), castResult.getEndElement().toHumanDisplay());
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) IBaseDatatype(org.hl7.fhir.instance.model.api.IBaseDatatype) Period(org.hl7.fhir.r4.model.Period) LocalDateTime(java.time.LocalDateTime) 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 99 with DateTime

use of org.hl7.elm.r1.DateTime in project quality-measure-and-cohort-service by Alvearie.

the class CQLToFHIRMeasureReportHelperTest method testDateTime_returnsSameDateTimeInUTC.

@Test
public void testDateTime_returnsSameDateTimeInUTC() {
    String inputDateTimeString = "2020-01-02T00:00:00.000-04:00";
    DateTime expected = new DateTime(inputDateTimeString, OffsetDateTime.now().getOffset());
    IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(expected);
    assertTrue(fhirTypeValue instanceof DateTimeType);
    assertEquals("2020-01-02T04:00:00.000+00:00", ((DateTimeType) fhirTypeValue).getValueAsString());
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) IBaseDatatype(org.hl7.fhir.instance.model.api.IBaseDatatype) LocalDateTime(java.time.LocalDateTime) OffsetDateTime(java.time.OffsetDateTime) DateTime(org.opencds.cqf.cql.engine.runtime.DateTime) Test(org.junit.Test)

Example 100 with DateTime

use of org.hl7.elm.r1.DateTime in project quality-measure-and-cohort-service by Alvearie.

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testDateTimeWithTimezone__shouldReturnDatetimeParameter.

@Test
public void testDateTimeWithTimezone__shouldReturnDatetimeParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("dateTime");
    String dateString = "2020-01-01T00:00:00.0+04:00";
    DateTimeType fhirValue = new DateTimeType(dateString);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    assertEquals(new DatetimeParameter(dateString), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)30 List (java.util.List)21 LinkedHashSet (java.util.LinkedHashSet)20 Test (org.junit.Test)18 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)16 FHIRException (org.hl7.fhir.exceptions.FHIRException)15 Before (org.junit.Before)11 Set (java.util.Set)10 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 Condition (org.hl7.fhir.r4.model.Condition)8 MergedList (org.hl7.fhir.utilities.MergedList)8 Date (java.util.Date)5 HashMap (java.util.HashMap)4 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)4 Period (org.hl7.fhir.r4.model.Period)4 Procedure (org.hl7.fhir.r4.model.Procedure)4 CodeType (org.hl7.fhir.r5.model.CodeType)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)4