use of org.hl7.fhir.dstu2.model.InstantType in project fhir-bridge by ehrbase.
the class ProvideResourceAuditHandler method process.
@Override
public void process(Exchange exchange) throws Exception {
RequestDetails requestDetails = getRequestDetails(exchange);
AuditEvent auditEvent = new AuditEvent(new Coding("http://terminology.hl7.org/CodeSystem/audit-event-type", "rest", "RESTful Operation"), new InstantType(new Date()), getSource());
getSubtype(requestDetails).ifPresent(auditEvent::addSubtype);
getAction(requestDetails).ifPresent(auditEvent::setAction);
Throwable ex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
if (ex == null) {
auditEvent.setOutcome(AuditEvent.AuditEventOutcome._0);
auditEvent.setOutcomeDesc("Operation completed successfully");
} else {
auditEvent.setOutcome(AuditEvent.AuditEventOutcome._8);
auditEvent.setOutcomeDesc("Operation failed: " + ex.getMessage());
}
auditEvent.addAgent(getAgent(exchange));
getEntity(exchange, requestDetails).ifPresent(auditEvent::addEntity);
MethodOutcome outcome = auditEventDao.create(auditEvent, requestDetails);
LOG.debug("Created AuditEvent: id={}", outcome.getId());
}
use of org.hl7.fhir.dstu2.model.InstantType in project integration-adaptor-111 by nhsconnect.
the class DateUtil method parseToInstantType.
public static InstantType parseToInstantType(String dateToParse) {
DateFormat format = getFormat(dateToParse);
SimpleDateFormat formatter = getFormatter(format);
try {
Date date = formatter.parse(dateToParse);
return new InstantType(date, TemporalPrecisionEnum.MILLI, TimeZone.getTimeZone(ZoneOffset.UTC));
} catch (ParseException e) {
throw new IllegalStateException(String.format(ERROR_MESSAGE, dateToParse), e);
}
}
use of org.hl7.fhir.dstu2.model.InstantType 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.fhir.dstu2.model.InstantType in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverter method toCohortParameter.
public static Parameter toCohortParameter(Extension extension) {
Parameter parameter;
Type extensionValue = extension.getValue();
if (extensionValue instanceof Base64BinaryType) {
parameter = new StringParameter(((Base64BinaryType) extensionValue).asStringValue());
} else if (extensionValue instanceof BooleanType) {
parameter = new BooleanParameter(((BooleanType) extensionValue).booleanValue());
} else if (extensionValue instanceof DateType) {
parameter = new DateParameter(((DateType) extensionValue).asStringValue());
} else if (extensionValue instanceof DateTimeType) {
parameter = convertDateTimeType((DateTimeType) extensionValue);
} else if (extensionValue instanceof DecimalType) {
parameter = new DecimalParameter(((DecimalType) extensionValue).getValueAsString());
} else if (extensionValue instanceof InstantType) {
parameter = new DatetimeParameter(((InstantType) extensionValue).getValueAsString());
} else if (extensionValue instanceof IntegerType) {
parameter = new IntegerParameter(((IntegerType) extensionValue).getValue());
} else if (extensionValue instanceof StringType) {
parameter = new StringParameter(((StringType) extensionValue).getValue());
} else if (extensionValue instanceof TimeType) {
parameter = new TimeParameter(((TimeType) extensionValue).asStringValue());
} else if (extensionValue instanceof UriType) {
parameter = new StringParameter(((UriType) extensionValue).getValue());
} else if (extensionValue instanceof Coding) {
parameter = convertCoding((Coding) extensionValue);
} else if (extensionValue instanceof CodeableConcept) {
parameter = convertCodeableConcept((CodeableConcept) extensionValue);
} else if (extensionValue instanceof Period) {
Period castValue = (Period) extensionValue;
parameter = new IntervalParameter(convertDateTimeType(castValue.getStartElement()), true, convertDateTimeType(castValue.getEndElement()), true);
} else if (extensionValue instanceof Quantity) {
parameter = convertQuantity((Quantity) extensionValue);
} else if (extensionValue instanceof Range) {
Range castValue = (Range) extensionValue;
parameter = new IntervalParameter(convertQuantity(castValue.getLow()), true, convertQuantity(castValue.getHigh()), true);
} else if (extensionValue instanceof Ratio) {
Ratio castValue = (Ratio) extensionValue;
parameter = new RatioParameter().setDenominator(convertQuantity(castValue.getDenominator())).setNumerator(convertQuantity(castValue.getNumerator()));
} else {
throw new UnsupportedFhirTypeException(extensionValue);
}
return parameter;
}
use of org.hl7.fhir.dstu2.model.InstantType in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testInstant__shouldReturnDateTimeParameter.
@Test
public void testInstant__shouldReturnDateTimeParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("instant");
String instantString = "2020-01-01T12:30:00.0Z";
InstantType fhirValue = new InstantType(instantString);
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
assertEquals(new DatetimeParameter(instantString), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Aggregations