001package org.hl7.fhir.convertors.conv14_40.datatypes14_40; 002 003import java.util.Arrays; 004 005import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_40; 006import org.hl7.fhir.exceptions.FHIRException; 007 008public class Element14_40 { 009 010 public final BaseAdvisor_14_40 advisor; 011 012 public Element14_40(BaseAdvisor_14_40 advisor) { 013 this.advisor = advisor; 014 } 015 016 public boolean isExemptExtension(String url, String[] extensionsToIgnore) { 017 return Arrays.asList(extensionsToIgnore).contains(url); 018 } 019 020 public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, 021 org.hl7.fhir.r4.model.Element tgt, 022 String path, 023 String... extensionUrlsToIgnore) throws FHIRException { 024 if (src.hasId()) tgt.setId(src.getId()); 025 src.getExtension().stream() 026 .filter(e -> !isExemptExtension(e.getUrl(), extensionUrlsToIgnore)) 027 .forEach(e -> { 028 if (advisor.useAdvisorForExtension(path, e)) { 029 org.hl7.fhir.r4.model.Extension convertedExtension = new org.hl7.fhir.r4.model.Extension(); 030 advisor.handleExtension(path, e, convertedExtension); 031 tgt.addExtension(convertedExtension); 032 } else { 033 tgt.addExtension(Extension14_40.convertExtension(e)); 034 } 035 }); 036 } 037 038 public void copyElement(org.hl7.fhir.r4.model.Element src, 039 org.hl7.fhir.dstu2016may.model.Element tgt, 040 String path, 041 String... extensionUrlsToIgnore) throws FHIRException { 042 if (src.hasId()) tgt.setId(src.getId()); 043 src.getExtension().stream() 044 .filter(e -> !isExemptExtension(e.getUrl(), extensionUrlsToIgnore)) 045 .forEach(e -> { 046 if (advisor.useAdvisorForExtension(path, e)) { 047 org.hl7.fhir.dstu2016may.model.Extension convertedExtension = new org.hl7.fhir.dstu2016may.model.Extension(); 048 advisor.handleExtension(path, e, convertedExtension); 049 tgt.addExtension(convertedExtension); 050 } else { 051 tgt.addExtension(Extension14_40.convertExtension(e)); 052 } 053 }); 054 } 055}