Search in sources :

Example 11 with TemporalPrecisionEnum

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);
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Precision(org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp.Precision) TemporalPrecisionEnum(ca.uhn.fhir.model.api.TemporalPrecisionEnum) Date(java.util.Date)

Aggregations

TemporalPrecisionEnum (ca.uhn.fhir.model.api.TemporalPrecisionEnum)11 Calendar (java.util.Calendar)6 GregorianCalendar (java.util.GregorianCalendar)5 Date (java.util.Date)3 Precision (org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp.Precision)2 DateAndListParam (ca.uhn.fhir.rest.param.DateAndListParam)1 DateOrListParam (ca.uhn.fhir.rest.param.DateOrListParam)1 DateParam (ca.uhn.fhir.rest.param.DateParam)1 ParamPrefixEnum (ca.uhn.fhir.rest.param.ParamPrefixEnum)1 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)1 StringParam (ca.uhn.fhir.rest.param.StringParam)1 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)1 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)1 TokenParam (ca.uhn.fhir.rest.param.TokenParam)1 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 AD (net.ihe.gazelle.hl7v3.datatypes.AD)1 CD (net.ihe.gazelle.hl7v3.datatypes.CD)1 CE (net.ihe.gazelle.hl7v3.datatypes.CE)1 CS (net.ihe.gazelle.hl7v3.datatypes.CS)1