use of ca.uhn.fhir.model.api.TemporalPrecisionEnum in project MobileAccessGateway by i4mi.
the class BaseQueryResponseConverter method transform.
/**
* XDS timestamp -> FHIR DateTime
* @param timestamp
* @return
*/
public DateTimeType transform(Timestamp timestamp) {
if (timestamp == null)
return null;
Date date = Date.from(timestamp.getDateTime().toInstant());
Precision precision = timestamp.getPrecision();
TemporalPrecisionEnum fhirPrecision;
switch(precision) {
case YEAR:
fhirPrecision = TemporalPrecisionEnum.YEAR;
break;
case DAY:
fhirPrecision = TemporalPrecisionEnum.DAY;
break;
// There is no mapping for HOUR; MINUTE is not accepted
case HOUR:
fhirPrecision = TemporalPrecisionEnum.SECOND;
break;
case MINUTE:
fhirPrecision = TemporalPrecisionEnum.SECOND;
break;
case SECOND:
fhirPrecision = TemporalPrecisionEnum.SECOND;
break;
default:
fhirPrecision = TemporalPrecisionEnum.MILLI;
break;
}
return new DateTimeType(date, fhirPrecision);
}
Aggregations