001package org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_40;
004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Reference10_40;
005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Base64Binary10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Code10_40;
007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Instant10_40;
008import org.hl7.fhir.exceptions.FHIRException;
009
010public class Signature10_40 {
011  public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu2.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    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
015    for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(Coding10_40.convertCoding(t));
016    if (src.hasWhenElement()) tgt.setWhenElement(Instant10_40.convertInstant(src.getWhenElement()));
017    if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue()));
018    else tgt.setWho(Reference10_40.convertReference(src.getWhoReference()));
019    if (src.hasContentTypeElement()) tgt.setSigFormatElement(Code10_40.convertCode(src.getContentTypeElement()));
020    if (src.hasBlobElement()) tgt.setDataElement(Base64Binary10_40.convertBase64Binary(src.getBlobElement()));
021    return tgt;
022  }
023
024  public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException {
025    if (src == null || src.isEmpty()) return null;
026    org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature();
027    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
028    for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(Coding10_40.convertCoding(t));
029    if (src.hasWhenElement()) tgt.setWhenElement(Instant10_40.convertInstant(src.getWhenElement()));
030    if (src.hasWho()) tgt.setWho(ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().convertType(src.getWho()));
031    if (src.hasSigFormatElement()) tgt.setContentTypeElement(Code10_40.convertCode(src.getSigFormatElement()));
032    if (src.hasDataElement()) tgt.setBlobElement(Base64Binary10_40.convertBase64Binary(src.getDataElement()));
033    return tgt;
034  }
035}