001package org.hl7.fhir.convertors.conv30_50.datatypes30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
006import org.hl7.fhir.exceptions.FHIRException;
007
008public class Extension30_50 {
009  public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException {
010    if (src == null) return null;
011    org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension();
012    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
013    if (src.hasUrl()) tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
014    if (src.hasValue())
015      if (VersionConvertor_30_50.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu3.model.Reference)
016        tgt.setValue(Reference30_50.convertReferenceToCanonical((org.hl7.fhir.dstu3.model.Reference) src.getValue()));
017      else tgt.setValue(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValue()));
018    return tgt;
019  }
020
021  public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException {
022    if (src == null) return null;
023    org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension();
024    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
025    if (src.hasUrl()) tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
026    if (src.hasValue())
027      if (VersionConvertor_30_50.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType)
028        tgt.setValue(Reference30_50.convertCanonicalToReference((org.hl7.fhir.r5.model.CanonicalType) src.getValue()));
029      else tgt.setValue(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValue()));
030    return tgt;
031  }
032
033}