001package org.hl7.fhir.convertors.conv14_50.datatypes14_50; 002 003import org.hl7.fhir.convertors.VersionConvertorConstants; 004import org.hl7.fhir.convertors.context.ConversionContext14_50; 005import org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50; 006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Uri14_50; 007import org.hl7.fhir.dstu2016may.model.Reference; 008import org.hl7.fhir.exceptions.FHIRException; 009import org.hl7.fhir.r5.model.CanonicalType; 010 011public class Extension14_50 { 012 public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu2016may.model.Extension src) throws FHIRException { 013 if (src == null || src.isEmpty()) return null; 014 org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); 015 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 016 if (src.hasUrlElement()) tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement())); 017 if (src.hasValue()) 018 if (VersionConvertor_14_50.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2016may.model.Reference) 019 tgt.setValue(Reference14_50.convertReferenceToCanonical((Reference) src.getValue())); 020 else tgt.setValue(ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().convertType(src.getValue())); 021 return tgt; 022 } 023 024 public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { 025 if (src == null || src.isEmpty()) return null; 026 org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); 027 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 028 if (src.hasUrlElement()) tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement())); 029 if (src.hasValue()) 030 if (VersionConvertor_14_50.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) 031 tgt.setValue(Reference14_50.convertCanonicalToReference((CanonicalType) src.getValue())); 032 else tgt.setValue(ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().convertType(src.getValue())); 033 return tgt; 034 } 035 036 static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { 037 boolean ok = false; 038 for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; 039 return ok; 040 } 041 042 static public boolean mappedExtension(String url) { 043 return url.equals(VersionConvertorConstants.PROFILE_EXTENSION) || url.equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || url.equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION) || url.equals(VersionConvertorConstants.IG_CONFORMANCE_MESSAGE_EVENT); 044 } 045}