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);
}
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);
}
}
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());
}
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());
}
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));
}
Aggregations