001package org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_50;
004import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Base64Binary10_50;
005import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Code10_50;
006import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.DateTime10_50;
007import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.String10_50;
008import org.hl7.fhir.exceptions.FHIRException;
009
010public class Attachment10_50 {
011  public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException {
012    if (src == null || src.isEmpty()) return null;
013    org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment();
014    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
015    if (src.hasContentTypeElement()) tgt.setContentTypeElement(Code10_50.convertCode(src.getContentTypeElement()));
016    if (src.hasLanguageElement()) tgt.setLanguageElement(Code10_50.convertCode(src.getLanguageElement()));
017    if (src.hasDataElement()) tgt.setDataElement(Base64Binary10_50.convertBase64Binary(src.getDataElement()));
018    if (src.hasUrl()) tgt.setUrl(src.getUrl());
019    if (src.hasSize()) tgt.setSize(Long.valueOf(src.getSize()));
020    if (src.hasHashElement()) tgt.setHashElement(Base64Binary10_50.convertBase64Binary(src.getHashElement()));
021    if (src.hasTitleElement()) tgt.setTitleElement(String10_50.convertString(src.getTitleElement()));
022    if (src.hasCreationElement()) tgt.setCreationElement(DateTime10_50.convertDateTime(src.getCreationElement()));
023    return tgt;
024  }
025
026  public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException {
027    if (src == null || src.isEmpty()) return null;
028    org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment();
029    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
030    if (src.hasContentTypeElement()) tgt.setContentTypeElement(Code10_50.convertCode(src.getContentTypeElement()));
031    if (src.hasLanguageElement()) tgt.setLanguageElement(Code10_50.convertCode(src.getLanguageElement()));
032    if (src.hasDataElement()) tgt.setDataElement(Base64Binary10_50.convertBase64Binary(src.getDataElement()));
033    if (src.hasUrl()) tgt.setUrl(src.getUrl());
034    if (src.hasSize()) tgt.setSize(Math.toIntExact(src.getSize()));
035    if (src.hasHashElement()) tgt.setHashElement(Base64Binary10_50.convertBase64Binary(src.getHashElement()));
036    if (src.hasTitleElement()) tgt.setTitleElement(String10_50.convertString(src.getTitleElement()));
037    if (src.hasCreationElement()) tgt.setCreationElement(DateTime10_50.convertDateTime(src.getCreationElement()));
038    return tgt;
039  }
040}