001package org.hl7.fhir.convertors.conv30_40.datatypes30_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_40; 004import org.hl7.fhir.convertors.conv30_40.VersionConvertor_30_40; 005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Uri30_40; 006import org.hl7.fhir.exceptions.FHIRException; 007 008public class Extension30_40 { 009 public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { 010 if (src == null) return null; 011 org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); 012 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 013 if (src.hasUrl()) tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement())); 014 if (src.hasValue()) 015 if (VersionConvertor_30_40.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu3.model.Reference) 016 tgt.setValue(Reference30_40.convertReferenceToCanonical((org.hl7.fhir.dstu3.model.Reference) src.getValue())); 017 else tgt.setValue(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getValue())); 018 return tgt; 019 } 020 021 public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.r4.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_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 025 if (src.hasUrl()) tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement())); 026 if (src.hasValue()) 027 if (VersionConvertor_30_40.CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) 028 tgt.setValue(Reference30_40.convertCanonicalToReference((org.hl7.fhir.r4.model.CanonicalType) src.getValue())); 029 else tgt.setValue(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getValue())); 030 return tgt; 031 } 032 033 static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { 034 boolean ok = false; 035 for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; 036 return ok; 037 } 038}