001package org.hl7.fhir.convertors.conv14_40.datatypes14_40.complextypes14_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext14_40; 004import org.hl7.fhir.convertors.conv14_40.datatypes14_40.Reference14_40; 005import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Base64Binary14_40; 006import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Code14_40; 007import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Instant14_40; 008import org.hl7.fhir.exceptions.FHIRException; 009 010public class Signature14_40 { 011 public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu2016may.model.Signature src) throws FHIRException { 012 if (src == null || src.isEmpty()) return null; 013 org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); 014 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 015 for (org.hl7.fhir.dstu2016may.model.Coding t : src.getType()) tgt.addType(Coding14_40.convertCoding(t)); 016 if (src.hasWhenElement()) tgt.setWhenElement(Instant14_40.convertInstant(src.getWhenElement())); 017 if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue())); 018 else tgt.setWho(Reference14_40.convertReference(src.getWhoReference())); 019 if (src.hasContentType()) tgt.setSigFormatElement(Code14_40.convertCode(src.getContentTypeElement())); 020 if (src.hasBlob()) tgt.setDataElement(Base64Binary14_40.convertBase64Binary(src.getBlobElement())); 021 return tgt; 022 } 023 024 public static org.hl7.fhir.dstu2016may.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { 025 if (src == null || src.isEmpty()) return null; 026 org.hl7.fhir.dstu2016may.model.Signature tgt = new org.hl7.fhir.dstu2016may.model.Signature(); 027 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 028 for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(Coding14_40.convertCoding(t)); 029 if (src.hasWhenElement()) tgt.setWhenElement(Instant14_40.convertInstant(src.getWhenElement())); 030 if (src.hasWho()) tgt.setWho(ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().convertType(src.getWho())); 031 if (src.hasSigFormat()) tgt.setContentTypeElement(Code14_40.convertCode(src.getSigFormatElement())); 032 if (src.hasData()) tgt.setBlobElement(Base64Binary14_40.convertBase64Binary(src.getDataElement())); 033 return tgt; 034 } 035}