001package org.hl7.fhir.convertors.conv10_50.datatypes10_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_50; 004import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50; 005import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Uri10_50; 006import org.hl7.fhir.dstu2.model.Reference; 007import org.hl7.fhir.exceptions.FHIRException; 008import org.hl7.fhir.r5.model.CanonicalType; 009 010public class Extension10_50 { 011 public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { 012 if (src == null || src.isEmpty()) return null; 013 org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); 014 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 015 if (src.hasUrlElement()) tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement())); 016 if (src.hasValue()) 017 if (VersionConvertor_10_50.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2.model.Reference) 018 tgt.setValue(Reference10_50.convertReferenceToCanonical((Reference) src.getValue())); 019 else tgt.setValue(ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().convertType(src.getValue())); 020 return tgt; 021 } 022 023 public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { 024 if (src == null || src.isEmpty()) return null; 025 org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); 026 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 027 if (src.hasUrlElement()) tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement())); 028 if (src.hasValue()) 029 if (VersionConvertor_10_50.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) 030 tgt.setValue(Reference10_50.convertCanonicalToReference((CanonicalType) src.getValue())); 031 else if (src.hasValue()) 032 tgt.setValue(ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().convertType(src.getValue())); 033 if (src.hasValue()) 034 tgt.setValue(ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().convertType(src.getValue())); 035 return tgt; 036 } 037}