package org.hl7.fhir.convertors;

/*-
 * #%L
 * HAPI FHIR - Converter
 * %%
 * Copyright (C) 2014 - 2017 University Health Network
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Base64BinaryType;
import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule;


/*
  Copyright (c) 2011+, HL7, Inc.
  All rights reserved.
  
  Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:
  
   * Redistributions of source code must retain the above copyright notice, this 
     list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright notice, 
     this list of conditions and the following disclaimer in the documentation 
     and/or other materials provided with the distribution.
   * Neither the name of HL7 nor the names of its contributors may be used to 
     endorse or promote products derived from this software without specific 
     prior written permission.
  
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  POSSIBILITY OF SUCH DAMAGE.
  
*/

// Generated on Mon, Apr 24, 2017 09:30+1000 for FHIR v3.1.0


public class VersionConvertor_30_40 {

  public static org.hl7.fhir.r4.model.Claim.AccidentComponent convertAccidentComponent(org.hl7.fhir.dstu3.model.Claim.AccidentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.AccidentComponent tgt = new org.hl7.fhir.r4.model.Claim.AccidentComponent();
    copyElement(src, tgt);
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasLocation())
      tgt.setLocation(convertType(src.getLocation()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.AccidentComponent convertAccidentComponent(org.hl7.fhir.r4.model.Claim.AccidentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.AccidentComponent tgt = new org.hl7.fhir.dstu3.model.Claim.AccidentComponent();
    copyElement(src, tgt);
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasLocation())
      tgt.setLocation(convertType(src.getLocation()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Account convertAccount(org.hl7.fhir.dstu3.model.Account src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Account tgt = new org.hl7.fhir.r4.model.Account();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertAccountStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasActive())
      tgt.setActive(convertPeriod(src.getActive()));
    if (src.hasBalance())
      tgt.setBalance(convertMoney(src.getBalance()));
    for (org.hl7.fhir.dstu3.model.Account.CoverageComponent t : src.getCoverage())
      tgt.addCoverage(convertCoverageComponent(t));
    if (src.hasOwner())
      tgt.setOwner(convertReference(src.getOwner()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Account.GuarantorComponent t : src.getGuarantor())
      tgt.addGuarantor(convertGuarantorComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Account convertAccount(org.hl7.fhir.r4.model.Account src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Account tgt = new org.hl7.fhir.dstu3.model.Account();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertAccountStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasActive())
      tgt.setActive(convertPeriod(src.getActive()));
    if (src.hasBalance())
      tgt.setBalance(convertMoney(src.getBalance()));
    for (org.hl7.fhir.r4.model.Account.CoverageComponent t : src.getCoverage())
      tgt.addCoverage(convertCoverageComponent(t));
    if (src.hasOwner())
      tgt.setOwner(convertReference(src.getOwner()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.Account.GuarantorComponent t : src.getGuarantor())
      tgt.addGuarantor(convertGuarantorComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Account.AccountStatus convertAccountStatus(org.hl7.fhir.dstu3.model.Account.AccountStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Account.AccountStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.r4.model.Account.AccountStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Account.AccountStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Account.AccountStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Account.AccountStatus convertAccountStatus(org.hl7.fhir.r4.model.Account.AccountStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Account.AccountStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Account.AccountStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Account.AccountStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Account.AccountStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.TestScript.ActionAssertRuleComponent convertActionAssertRuleComponent(org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.ActionAssertRuleComponent tgt = new org.hl7.fhir.r4.model.TestScript.ActionAssertRuleComponent();
    copyElement(src, tgt);
    if (src.hasRuleId())
      tgt.setRuleId(src.getRuleId());
    for (org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleParamComponent t : src.getParam())
      tgt.addParam(convertActionAssertRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleComponent convertActionAssertRuleComponent(org.hl7.fhir.r4.model.TestScript.ActionAssertRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleComponent();
    copyElement(src, tgt);
    if (src.hasRuleId())
      tgt.setRuleId(src.getRuleId());
    for (org.hl7.fhir.r4.model.TestScript.ActionAssertRuleParamComponent t : src.getParam())
      tgt.addParam(convertActionAssertRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.ActionAssertRuleParamComponent convertActionAssertRuleParamComponent(org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.ActionAssertRuleParamComponent tgt = new org.hl7.fhir.r4.model.TestScript.ActionAssertRuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleParamComponent convertActionAssertRuleParamComponent(org.hl7.fhir.r4.model.TestScript.ActionAssertRuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleParamComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.ActionAssertRuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetComponent convertActionAssertRulesetComponent(org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetComponent tgt = new org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetComponent();
    copyElement(src, tgt);
    if (src.hasRulesetId())
      tgt.setRulesetId(src.getRulesetId());
    for (org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleComponent t : src.getRule())
      tgt.addRule(convertActionAssertRulesetRuleComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetComponent convertActionAssertRulesetComponent(org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetComponent();
    copyElement(src, tgt);
    if (src.hasRulesetId())
      tgt.setRulesetId(src.getRulesetId());
    for (org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleComponent t : src.getRule())
      tgt.addRule(convertActionAssertRulesetRuleComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleComponent convertActionAssertRulesetRuleComponent(org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleComponent tgt = new org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleComponent();
    copyElement(src, tgt);
    if (src.hasRuleId())
      tgt.setRuleId(src.getRuleId());
    for (org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleParamComponent t : src.getParam())
      tgt.addParam(convertActionAssertRulesetRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleComponent convertActionAssertRulesetRuleComponent(org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleComponent();
    copyElement(src, tgt);
    if (src.hasRuleId())
      tgt.setRuleId(src.getRuleId());
    for (org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleParamComponent t : src.getParam())
      tgt.addParam(convertActionAssertRulesetRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleParamComponent convertActionAssertRulesetRuleParamComponent(org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleParamComponent tgt = new org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleParamComponent convertActionAssertRulesetRuleParamComponent(org.hl7.fhir.r4.model.TestScript.ActionAssertRulesetRuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleParamComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.ActionAssertRulesetRuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ProcessRequest.ActionList convertActionList(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CANCEL: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.CANCEL;
    case POLL: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.POLL;
    case REPROCESS: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.REPROCESS;
    case STATUS: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.STATUS;
    default: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ProcessRequest.ActionList convertActionList(org.hl7.fhir.r4.model.ProcessRequest.ActionList src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CANCEL: return org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.CANCEL;
    case POLL: return org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.POLL;
    case REPROCESS: return org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.REPROCESS;
    case STATUS: return org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.STATUS;
    default: return org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ActivityDefinition convertActivityDefinition(org.hl7.fhir.dstu3.model.ActivityDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ActivityDefinition tgt = new org.hl7.fhir.r4.model.ActivityDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasUsage())
      tgt.setUsage(src.getUsage());
    if (src.hasApprovalDate())
      tgt.setApprovalDate(src.getApprovalDate());
    if (src.hasLastReviewDate())
      tgt.setLastReviewDate(src.getLastReviewDate());
    if (src.hasEffectivePeriod())
      tgt.setEffectivePeriod(convertPeriod(src.getEffectivePeriod()));
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getTopic())
      tgt.addTopic(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Contributor t : src.getContributor())
      tgt.addContributor(convertContributor(t));
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.dstu3.model.RelatedArtifact t : src.getRelatedArtifact())
      tgt.addRelatedArtifact(convertRelatedArtifact(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getLibrary())
      tgt.addLibrary(convertReference(t));
    if (src.hasKind())
      tgt.setKind(convertActivityDefinitionKind(src.getKind()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasTiming())
      tgt.setTiming(convertType(src.getTiming()));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertActivityDefinitionParticipantComponent(t));
    if (src.hasProduct())
      tgt.setProduct(convertType(src.getProduct()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    for (org.hl7.fhir.dstu3.model.Dosage t : src.getDosage())
      tgt.addDosage(convertDosage(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    if (src.hasTransform())
      tgt.setTransform(convertReference(src.getTransform()));
    for (org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent t : src.getDynamicValue())
      tgt.addDynamicValue(convertActivityDefinitionDynamicValueComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ActivityDefinition convertActivityDefinition(org.hl7.fhir.r4.model.ActivityDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ActivityDefinition tgt = new org.hl7.fhir.dstu3.model.ActivityDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasUsage())
      tgt.setUsage(src.getUsage());
    if (src.hasApprovalDate())
      tgt.setApprovalDate(src.getApprovalDate());
    if (src.hasLastReviewDate())
      tgt.setLastReviewDate(src.getLastReviewDate());
    if (src.hasEffectivePeriod())
      tgt.setEffectivePeriod(convertPeriod(src.getEffectivePeriod()));
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getTopic())
      tgt.addTopic(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Contributor t : src.getContributor())
      tgt.addContributor(convertContributor(t));
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.r4.model.RelatedArtifact t : src.getRelatedArtifact())
      tgt.addRelatedArtifact(convertRelatedArtifact(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getLibrary())
      tgt.addLibrary(convertReference(t));
    if (src.hasKind())
      tgt.setKind(convertActivityDefinitionKind(src.getKind()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasTiming())
      tgt.setTiming(convertType(src.getTiming()));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertActivityDefinitionParticipantComponent(t));
    if (src.hasProduct())
      tgt.setProduct(convertType(src.getProduct()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    for (org.hl7.fhir.r4.model.Dosage t : src.getDosage())
      tgt.addDosage(convertDosage(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    if (src.hasTransform())
      tgt.setTransform(convertReference(src.getTransform()));
    for (org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent t : src.getDynamicValue())
      tgt.addDynamicValue(convertActivityDefinitionDynamicValueComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent convertActivityDefinitionDynamicValueComponent(org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent tgt = new org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent convertActivityDefinitionDynamicValueComponent(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent tgt = new org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionDynamicValueComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind convertActivityDefinitionKind(org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACCOUNT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ACCOUNT;
    case ACTIVITYDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ACTIVITYDEFINITION;
    case ADVERSEEVENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ADVERSEEVENT;
    case ALLERGYINTOLERANCE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ALLERGYINTOLERANCE;
    case APPOINTMENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.APPOINTMENT;
    case APPOINTMENTRESPONSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.APPOINTMENTRESPONSE;
    case AUDITEVENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.AUDITEVENT;
    case BASIC: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.BASIC;
    case BINARY: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.BINARY;
    case BODYSITE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.BODYSTRUCTURE;
    case BUNDLE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.BUNDLE;
    case CAPABILITYSTATEMENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CAPABILITYSTATEMENT;
    case CAREPLAN: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CAREPLAN;
    case CARETEAM: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CARETEAM;
    case CHARGEITEM: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CHARGEITEM;
    case CLAIM: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CLAIM;
    case CLAIMRESPONSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CLAIMRESPONSE;
    case CLINICALIMPRESSION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CLINICALIMPRESSION;
    case CODESYSTEM: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CODESYSTEM;
    case COMMUNICATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.COMMUNICATION;
    case COMMUNICATIONREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.COMMUNICATIONREQUEST;
    case COMPARTMENTDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.COMPARTMENTDEFINITION;
    case COMPOSITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.COMPOSITION;
    case CONCEPTMAP: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CONCEPTMAP;
    case CONDITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CONDITION;
    case CONSENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CONSENT;
    case CONTRACT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.CONTRACT;
    case COVERAGE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.COVERAGE;
    case DETECTEDISSUE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DETECTEDISSUE;
    case DEVICE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DEVICE;
    case DEVICECOMPONENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DEVICECOMPONENT;
    case DEVICEMETRIC: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DEVICEMETRIC;
    case DEVICEREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DEVICEREQUEST;
    case DEVICEUSESTATEMENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DEVICEUSESTATEMENT;
    case DIAGNOSTICREPORT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DIAGNOSTICREPORT;
    case DOCUMENTMANIFEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DOCUMENTMANIFEST;
    case DOCUMENTREFERENCE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DOCUMENTREFERENCE;
    case DOMAINRESOURCE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.DOMAINRESOURCE;
    case ELIGIBILITYREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ELIGIBILITYREQUEST;
    case ELIGIBILITYRESPONSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ELIGIBILITYRESPONSE;
    case ENCOUNTER: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ENCOUNTER;
    case ENDPOINT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ENDPOINT;
    case ENROLLMENTREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ENROLLMENTREQUEST;
    case ENROLLMENTRESPONSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ENROLLMENTRESPONSE;
    case EPISODEOFCARE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.EPISODEOFCARE;
    case EXPANSIONPROFILE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.EXPANSIONPROFILE;
    case EXPLANATIONOFBENEFIT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.EXPLANATIONOFBENEFIT;
    case FAMILYMEMBERHISTORY: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.FAMILYMEMBERHISTORY;
    case FLAG: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.FLAG;
    case GOAL: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.GOAL;
    case GRAPHDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.GRAPHDEFINITION;
    case GROUP: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.GROUP;
    case GUIDANCERESPONSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.GUIDANCERESPONSE;
    case HEALTHCARESERVICE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.HEALTHCARESERVICE;
    case IMAGINGMANIFEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.IMAGINGMANIFEST;
    case IMAGINGSTUDY: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.IMAGINGSTUDY;
    case IMMUNIZATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.IMMUNIZATION;
    case IMMUNIZATIONRECOMMENDATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.IMMUNIZATIONRECOMMENDATION;
    case IMPLEMENTATIONGUIDE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.IMPLEMENTATIONGUIDE;
    case LIBRARY: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.LIBRARY;
    case LINKAGE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.LINKAGE;
    case LIST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.LIST;
    case LOCATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.LOCATION;
    case MEASURE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEASURE;
    case MEASUREREPORT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEASUREREPORT;
    case MEDIA: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEDIA;
    case MEDICATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEDICATION;
    case MEDICATIONADMINISTRATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONADMINISTRATION;
    case MEDICATIONDISPENSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONDISPENSE;
    case MEDICATIONREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONREQUEST;
    case MEDICATIONSTATEMENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONSTATEMENT;
    case MESSAGEDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MESSAGEDEFINITION;
    case MESSAGEHEADER: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.MESSAGEHEADER;
    case NAMINGSYSTEM: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.NAMINGSYSTEM;
    case NUTRITIONORDER: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.NUTRITIONORDER;
    case OBSERVATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.OBSERVATION;
    case OPERATIONDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.OPERATIONDEFINITION;
    case OPERATIONOUTCOME: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.OPERATIONOUTCOME;
    case ORGANIZATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.ORGANIZATION;
    case PARAMETERS: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PARAMETERS;
    case PATIENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PATIENT;
    case PAYMENTNOTICE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PAYMENTNOTICE;
    case PAYMENTRECONCILIATION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PAYMENTRECONCILIATION;
    case PERSON: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PERSON;
    case PLANDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PLANDEFINITION;
    case PRACTITIONER: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PRACTITIONER;
    case PRACTITIONERROLE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PRACTITIONERROLE;
    case PROCEDURE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PROCEDURE;
    case PROCEDUREREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PROCEDUREREQUEST;
    case PROCESSREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PROCESSREQUEST;
    case PROCESSRESPONSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PROCESSRESPONSE;
    case PROVENANCE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PROVENANCE;
    case QUESTIONNAIRE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.QUESTIONNAIRE;
    case QUESTIONNAIRERESPONSE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.QUESTIONNAIRERESPONSE;
    case REFERRALREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.PROCEDUREREQUEST;
    case RELATEDPERSON: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.RELATEDPERSON;
    case REQUESTGROUP: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.REQUESTGROUP;
    case RESEARCHSTUDY: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.RESEARCHSTUDY;
    case RESEARCHSUBJECT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.RESEARCHSUBJECT;
    case RESOURCE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.RESOURCE;
    case RISKASSESSMENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.RISKASSESSMENT;
    case SCHEDULE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SCHEDULE;
    case SEARCHPARAMETER: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SEARCHPARAMETER;
    case SEQUENCE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SEQUENCE;
    case SERVICEDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SERVICEDEFINITION;
    case SLOT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SLOT;
    case SPECIMEN: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SPECIMEN;
    case STRUCTUREDEFINITION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.STRUCTUREDEFINITION;
    case STRUCTUREMAP: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.STRUCTUREMAP;
    case SUBSCRIPTION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SUBSCRIPTION;
    case SUBSTANCE: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SUBSTANCE;
    case SUPPLYDELIVERY: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SUPPLYDELIVERY;
    case SUPPLYREQUEST: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SUPPLYREQUEST;
    case TASK: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.TASK;
    case TESTREPORT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.TESTREPORT;
    case TESTSCRIPT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.TESTSCRIPT;
    case VALUESET: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.VALUESET;
    case VISIONPRESCRIPTION: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.VISIONPRESCRIPTION;
    default: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind convertActivityDefinitionKind(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACCOUNT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ACCOUNT;
    case ACTIVITYDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ACTIVITYDEFINITION;
    case ADVERSEEVENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ADVERSEEVENT;
    case ALLERGYINTOLERANCE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ALLERGYINTOLERANCE;
    case APPOINTMENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.APPOINTMENT;
    case APPOINTMENTRESPONSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.APPOINTMENTRESPONSE;
    case AUDITEVENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.AUDITEVENT;
    case BASIC: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.BASIC;
    case BINARY: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.BINARY;
    case BODYSTRUCTURE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.BODYSITE;
    case BUNDLE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.BUNDLE;
    case CAPABILITYSTATEMENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CAPABILITYSTATEMENT;
    case CAREPLAN: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CAREPLAN;
    case CARETEAM: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CARETEAM;
    case CHARGEITEM: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CHARGEITEM;
    case CLAIM: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CLAIM;
    case CLAIMRESPONSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CLAIMRESPONSE;
    case CLINICALIMPRESSION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CLINICALIMPRESSION;
    case CODESYSTEM: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CODESYSTEM;
    case COMMUNICATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.COMMUNICATION;
    case COMMUNICATIONREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.COMMUNICATIONREQUEST;
    case COMPARTMENTDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.COMPARTMENTDEFINITION;
    case COMPOSITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.COMPOSITION;
    case CONCEPTMAP: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CONCEPTMAP;
    case CONDITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CONDITION;
    case CONSENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CONSENT;
    case CONTRACT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.CONTRACT;
    case COVERAGE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.COVERAGE;
    case DETECTEDISSUE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DETECTEDISSUE;
    case DEVICE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DEVICE;
    case DEVICECOMPONENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DEVICECOMPONENT;
    case DEVICEMETRIC: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DEVICEMETRIC;
    case DEVICEREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DEVICEREQUEST;
    case DEVICEUSESTATEMENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DEVICEUSESTATEMENT;
    case DIAGNOSTICREPORT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DIAGNOSTICREPORT;
    case DOCUMENTMANIFEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DOCUMENTMANIFEST;
    case DOCUMENTREFERENCE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DOCUMENTREFERENCE;
    case DOMAINRESOURCE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.DOMAINRESOURCE;
    case ELIGIBILITYREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ELIGIBILITYREQUEST;
    case ELIGIBILITYRESPONSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ELIGIBILITYRESPONSE;
    case ENCOUNTER: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ENCOUNTER;
    case ENDPOINT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ENDPOINT;
    case ENROLLMENTREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ENROLLMENTREQUEST;
    case ENROLLMENTRESPONSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ENROLLMENTRESPONSE;
    case EPISODEOFCARE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.EPISODEOFCARE;
    case EXPANSIONPROFILE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.EXPANSIONPROFILE;
    case EXPLANATIONOFBENEFIT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.EXPLANATIONOFBENEFIT;
    case FAMILYMEMBERHISTORY: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.FAMILYMEMBERHISTORY;
    case FLAG: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.FLAG;
    case GOAL: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.GOAL;
    case GRAPHDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.GRAPHDEFINITION;
    case GROUP: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.GROUP;
    case GUIDANCERESPONSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.GUIDANCERESPONSE;
    case HEALTHCARESERVICE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.HEALTHCARESERVICE;
    case IMAGINGMANIFEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.IMAGINGMANIFEST;
    case IMAGINGSTUDY: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.IMAGINGSTUDY;
    case IMMUNIZATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.IMMUNIZATION;
    case IMMUNIZATIONRECOMMENDATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.IMMUNIZATIONRECOMMENDATION;
    case IMPLEMENTATIONGUIDE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.IMPLEMENTATIONGUIDE;
    case LIBRARY: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.LIBRARY;
    case LINKAGE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.LINKAGE;
    case LIST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.LIST;
    case LOCATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.LOCATION;
    case MEASURE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEASURE;
    case MEASUREREPORT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEASUREREPORT;
    case MEDIA: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEDIA;
    case MEDICATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEDICATION;
    case MEDICATIONADMINISTRATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONADMINISTRATION;
    case MEDICATIONDISPENSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONDISPENSE;
    case MEDICATIONREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONREQUEST;
    case MEDICATIONSTATEMENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MEDICATIONSTATEMENT;
    case MESSAGEDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MESSAGEDEFINITION;
    case MESSAGEHEADER: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.MESSAGEHEADER;
    case NAMINGSYSTEM: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.NAMINGSYSTEM;
    case NUTRITIONORDER: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.NUTRITIONORDER;
    case OBSERVATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.OBSERVATION;
    case OPERATIONDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.OPERATIONDEFINITION;
    case OPERATIONOUTCOME: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.OPERATIONOUTCOME;
    case ORGANIZATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.ORGANIZATION;
    case PARAMETERS: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PARAMETERS;
    case PATIENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PATIENT;
    case PAYMENTNOTICE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PAYMENTNOTICE;
    case PAYMENTRECONCILIATION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PAYMENTRECONCILIATION;
    case PERSON: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PERSON;
    case PLANDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PLANDEFINITION;
    case PRACTITIONER: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PRACTITIONER;
    case PRACTITIONERROLE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PRACTITIONERROLE;
    case PROCEDURE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PROCEDURE;
    case PROCEDUREREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PROCEDUREREQUEST;
    case PROCESSREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PROCESSREQUEST;
    case PROCESSRESPONSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PROCESSRESPONSE;
    case PROVENANCE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.PROVENANCE;
    case QUESTIONNAIRE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.QUESTIONNAIRE;
    case QUESTIONNAIRERESPONSE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.QUESTIONNAIRERESPONSE;
    case RELATEDPERSON: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.RELATEDPERSON;
    case REQUESTGROUP: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.REQUESTGROUP;
    case RESEARCHSTUDY: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.RESEARCHSTUDY;
    case RESEARCHSUBJECT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.RESEARCHSUBJECT;
    case RESOURCE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.RESOURCE;
    case RISKASSESSMENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.RISKASSESSMENT;
    case SCHEDULE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SCHEDULE;
    case SEARCHPARAMETER: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SEARCHPARAMETER;
    case SEQUENCE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SEQUENCE;
    case SERVICEDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SERVICEDEFINITION;
    case SLOT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SLOT;
    case SPECIMEN: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SPECIMEN;
    case STRUCTUREDEFINITION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.STRUCTUREDEFINITION;
    case STRUCTUREMAP: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.STRUCTUREMAP;
    case SUBSCRIPTION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SUBSCRIPTION;
    case SUBSTANCE: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SUBSTANCE;
    case SUPPLYDELIVERY: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SUPPLYDELIVERY;
    case SUPPLYREQUEST: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.SUPPLYREQUEST;
    case TASK: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.TASK;
    case TESTREPORT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.TESTREPORT;
    case TESTSCRIPT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.TESTSCRIPT;
    case VALUESET: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.VALUESET;
    case VISIONPRESCRIPTION: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.VISIONPRESCRIPTION;
    default: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionKind.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionParticipantComponent convertActivityDefinitionParticipantComponent(org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionParticipantComponent tgt = new org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionParticipantComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertActivityParticipantType(src.getType()));
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionParticipantComponent convertActivityDefinitionParticipantComponent(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionParticipantComponent tgt = new org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityDefinitionParticipantComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertActivityParticipantType(src.getType()));
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ActivityDefinition.ActivityParticipantType convertActivityParticipantType(org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityParticipantType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PATIENT: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityParticipantType.PATIENT;
    case PRACTITIONER: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityParticipantType.PRACTITIONER;
    case RELATEDPERSON: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityParticipantType.RELATEDPERSON;
    default: return org.hl7.fhir.r4.model.ActivityDefinition.ActivityParticipantType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityParticipantType convertActivityParticipantType(org.hl7.fhir.r4.model.ActivityDefinition.ActivityParticipantType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PATIENT: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityParticipantType.PATIENT;
    case PRACTITIONER: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityParticipantType.PRACTITIONER;
    case RELATEDPERSON: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityParticipantType.RELATEDPERSON;
    default: return org.hl7.fhir.dstu3.model.ActivityDefinition.ActivityParticipantType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address();
    copyElement(src, tgt);
    if (src.hasUse())
      tgt.setUse(convertAddressUse(src.getUse()));
    if (src.hasType())
      tgt.setType(convertAddressType(src.getType()));
    if (src.hasText())
      tgt.setText(src.getText());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getLine())
      tgt.addLine(t.getValue());
    if (src.hasCity())
      tgt.setCity(src.getCity());
    if (src.hasDistrict())
      tgt.setDistrict(src.getDistrict());
    if (src.hasState())
      tgt.setState(src.getState());
    if (src.hasPostalCode())
      tgt.setPostalCode(src.getPostalCode());
    if (src.hasCountry())
      tgt.setCountry(src.getCountry());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address();
    copyElement(src, tgt);
    if (src.hasUse())
      tgt.setUse(convertAddressUse(src.getUse()));
    if (src.hasType())
      tgt.setType(convertAddressType(src.getType()));
    if (src.hasText())
      tgt.setText(src.getText());
    for (org.hl7.fhir.r4.model.StringType t : src.getLine())
      tgt.addLine(t.getValue());
    if (src.hasCity())
      tgt.setCity(src.getCity());
    if (src.hasDistrict())
      tgt.setDistrict(src.getDistrict());
    if (src.hasState())
      tgt.setState(src.getState());
    if (src.hasPostalCode())
      tgt.setPostalCode(src.getPostalCode());
    if (src.hasCountry())
      tgt.setCountry(src.getCountry());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Address.AddressType convertAddressType(org.hl7.fhir.dstu3.model.Address.AddressType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case POSTAL: return org.hl7.fhir.r4.model.Address.AddressType.POSTAL;
    case PHYSICAL: return org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL;
    case BOTH: return org.hl7.fhir.r4.model.Address.AddressType.BOTH;
    default: return org.hl7.fhir.r4.model.Address.AddressType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Address.AddressType convertAddressType(org.hl7.fhir.r4.model.Address.AddressType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case POSTAL: return org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL;
    case PHYSICAL: return org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL;
    case BOTH: return org.hl7.fhir.dstu3.model.Address.AddressType.BOTH;
    default: return org.hl7.fhir.dstu3.model.Address.AddressType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Address.AddressUse convertAddressUse(org.hl7.fhir.dstu3.model.Address.AddressUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HOME: return org.hl7.fhir.r4.model.Address.AddressUse.HOME;
    case WORK: return org.hl7.fhir.r4.model.Address.AddressUse.WORK;
    case TEMP: return org.hl7.fhir.r4.model.Address.AddressUse.TEMP;
    case OLD: return org.hl7.fhir.r4.model.Address.AddressUse.OLD;
    default: return org.hl7.fhir.r4.model.Address.AddressUse.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Address.AddressUse convertAddressUse(org.hl7.fhir.r4.model.Address.AddressUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HOME: return org.hl7.fhir.dstu3.model.Address.AddressUse.HOME;
    case WORK: return org.hl7.fhir.dstu3.model.Address.AddressUse.WORK;
    case TEMP: return org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP;
    case OLD: return org.hl7.fhir.dstu3.model.Address.AddressUse.OLD;
    default: return org.hl7.fhir.dstu3.model.Address.AddressUse.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Enumerations.AdministrativeGender convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MALE: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.MALE;
    case FEMALE: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.FEMALE;
    case OTHER: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.OTHER;
    case UNKNOWN: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender convertAdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MALE: return org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE;
    case FEMALE: return org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE;
    case OTHER: return org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Contract.AgentComponent convertAgentComponent(org.hl7.fhir.dstu3.model.Contract.AgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.AgentComponent tgt = new org.hl7.fhir.r4.model.Contract.AgentComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.AgentComponent convertAgentComponent(org.hl7.fhir.r4.model.Contract.AgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.AgentComponent tgt = new org.hl7.fhir.dstu3.model.Contract.AgentComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ElementDefinition.AggregationMode convertAggregationMode(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CONTAINED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED;
    case REFERENCED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED;
    case BUNDLED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED;
    default: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode convertAggregationMode(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CONTAINED: return org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED;
    case REFERENCED: return org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED;
    case BUNDLED: return org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED;
    default: return org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.AllergyIntolerance convertAllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AllergyIntolerance tgt = new org.hl7.fhir.r4.model.AllergyIntolerance();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasClinicalStatus())
      tgt.setClinicalStatus(convertAllergyIntoleranceClinicalStatus(src.getClinicalStatus()));
    if (src.hasVerificationStatus())
      tgt.setVerificationStatus(convertAllergyIntoleranceVerificationStatus(src.getVerificationStatus()));
    if (src.hasType())
      tgt.setType(convertAllergyIntoleranceType(src.getType()));
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory> t : src.getCategory())
      tgt.addCategory(convertAllergyIntoleranceCategory(t.getValue()));
    if (src.hasCriticality())
      tgt.setCriticality(convertAllergyIntoleranceCriticality(src.getCriticality()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasOnset())
      tgt.setOnset(convertType(src.getOnset()));
    if (src.hasAssertedDate())
      tgt.setAssertedDate(src.getAssertedDate());
    if (src.hasRecorder())
      tgt.setRecorder(convertReference(src.getRecorder()));
    if (src.hasAsserter())
      tgt.setAsserter(convertReference(src.getAsserter()));
    if (src.hasLastOccurrence())
      tgt.setLastOccurrence(src.getLastOccurrence());
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent t : src.getReaction())
      tgt.addReaction(convertAllergyIntoleranceReactionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AllergyIntolerance convertAllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AllergyIntolerance tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasClinicalStatus())
      tgt.setClinicalStatus(convertAllergyIntoleranceClinicalStatus(src.getClinicalStatus()));
    if (src.hasVerificationStatus())
      tgt.setVerificationStatus(convertAllergyIntoleranceVerificationStatus(src.getVerificationStatus()));
    if (src.hasType())
      tgt.setType(convertAllergyIntoleranceType(src.getType()));
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory> t : src.getCategory())
      tgt.addCategory(convertAllergyIntoleranceCategory(t.getValue()));
    if (src.hasCriticality())
      tgt.setCriticality(convertAllergyIntoleranceCriticality(src.getCriticality()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasOnset())
      tgt.setOnset(convertType(src.getOnset()));
    if (src.hasAssertedDate())
      tgt.setAssertedDate(src.getAssertedDate());
    if (src.hasRecorder())
      tgt.setRecorder(convertReference(src.getRecorder()));
    if (src.hasAsserter())
      tgt.setAsserter(convertReference(src.getAsserter()));
    if (src.hasLastOccurrence())
      tgt.setLastOccurrence(src.getLastOccurrence());
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent t : src.getReaction())
      tgt.addReaction(convertAllergyIntoleranceReactionComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory convertAllergyIntoleranceCategory(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FOOD: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.FOOD;
    case MEDICATION: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION;
    case ENVIRONMENT: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT;
    case BIOLOGIC: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.BIOLOGIC;
    default: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory convertAllergyIntoleranceCategory(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FOOD: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.FOOD;
    case MEDICATION: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION;
    case ENVIRONMENT: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT;
    case BIOLOGIC: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.BIOLOGIC;
    default: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.NULL;
  }
}

  private static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus convertAllergyIntoleranceClinicalStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.INACTIVE;
    case RESOLVED: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.RESOLVED;
    default: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus convertAllergyIntoleranceClinicalStatus(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.INACTIVE;
    case RESOLVED: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.RESOLVED;
    default: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality convertAllergyIntoleranceCriticality(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LOW: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.LOW;
    case HIGH: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.HIGH;
    case UNABLETOASSESS: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.UNABLETOASSESS;
    default: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality convertAllergyIntoleranceCriticality(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LOW: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.LOW;
    case HIGH: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.HIGH;
    case UNABLETOASSESS: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.UNABLETOASSESS;
    default: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.NULL;
  }
}

  public static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent convertAllergyIntoleranceReactionComponent(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent tgt = new org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent();
    copyElement(src, tgt);
    if (src.hasSubstance())
      tgt.setSubstance(convertCodeableConcept(src.getSubstance()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getManifestation())
      tgt.addManifestation(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasOnset())
      tgt.setOnset(src.getOnset());
    if (src.hasSeverity())
      tgt.setSeverity(convertAllergyIntoleranceSeverity(src.getSeverity()));
    if (src.hasExposureRoute())
      tgt.setExposureRoute(convertCodeableConcept(src.getExposureRoute()));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent convertAllergyIntoleranceReactionComponent(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent();
    copyElement(src, tgt);
    if (src.hasSubstance())
      tgt.setSubstance(convertCodeableConcept(src.getSubstance()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getManifestation())
      tgt.addManifestation(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasOnset())
      tgt.setOnset(src.getOnset());
    if (src.hasSeverity())
      tgt.setSeverity(convertAllergyIntoleranceSeverity(src.getSeverity()));
    if (src.hasExposureRoute())
      tgt.setExposureRoute(convertCodeableConcept(src.getExposureRoute()));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity convertAllergyIntoleranceSeverity(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MILD: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.MILD;
    case MODERATE: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE;
    case SEVERE: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE;
    default: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity convertAllergyIntoleranceSeverity(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MILD: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.MILD;
    case MODERATE: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE;
    case SEVERE: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE;
    default: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.NULL;
  }
}

  private static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType convertAllergyIntoleranceType(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ALLERGY: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType.ALLERGY;
    case INTOLERANCE: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType.INTOLERANCE;
    default: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType convertAllergyIntoleranceType(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ALLERGY: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.ALLERGY;
    case INTOLERANCE: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.INTOLERANCE;
    default: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus convertAllergyIntoleranceVerificationStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case UNCONFIRMED: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.UNCONFIRMED;
    case CONFIRMED: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.CONFIRMED;
    case REFUTED: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.REFUTED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus convertAllergyIntoleranceVerificationStatus(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case UNCONFIRMED: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.UNCONFIRMED;
    case CONFIRMED: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.CONFIRMED;
    case REFUTED: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.REFUTED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.dstu3.model.Patient.AnimalComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Patient.AnimalComponent tgt = new org.hl7.fhir.r4.model.Patient.AnimalComponent();
    copyElement(src, tgt);
    if (src.hasSpecies())
      tgt.setSpecies(convertCodeableConcept(src.getSpecies()));
    if (src.hasBreed())
      tgt.setBreed(convertCodeableConcept(src.getBreed()));
    if (src.hasGenderStatus())
      tgt.setGenderStatus(convertCodeableConcept(src.getGenderStatus()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.r4.model.Patient.AnimalComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Patient.AnimalComponent tgt = new org.hl7.fhir.dstu3.model.Patient.AnimalComponent();
    copyElement(src, tgt);
    if (src.hasSpecies())
      tgt.setSpecies(convertCodeableConcept(src.getSpecies()));
    if (src.hasBreed())
      tgt.setBreed(convertCodeableConcept(src.getBreed()));
    if (src.hasGenderStatus())
      tgt.setGenderStatus(convertCodeableConcept(src.getGenderStatus()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation();
    copyElement(src, tgt);
    if (src.hasAuthor())
      tgt.setAuthor(convertType(src.getAuthor()));
    if (src.hasTime())
      tgt.setTime(src.getTime());
    if (src.hasText())
      tgt.setText(src.getText());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation();
    copyElement(src, tgt);
    if (src.hasAuthor())
      tgt.setAuthor(convertType(src.getAuthor()));
    if (src.hasTime())
      tgt.setTime(src.getTime());
    if (src.hasText())
      tgt.setText(src.getText());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Appointment convertAppointment(org.hl7.fhir.dstu3.model.Appointment src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Appointment tgt = new org.hl7.fhir.r4.model.Appointment();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertAppointmentStatus(src.getStatus()));
    if (src.hasServiceCategory())
      tgt.setServiceCategory(convertCodeableConcept(src.getServiceCategory()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getServiceType())
      tgt.addServiceType(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    if (src.hasAppointmentType())
      tgt.setAppointmentType(convertCodeableConcept(src.getAppointmentType()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getIndication())
      tgt.addIndication(convertReference(t));
    if (src.hasPriority())
      tgt.setPriority(src.getPriority());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasMinutesDuration())
      tgt.setMinutesDuration(src.getMinutesDuration());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSlot())
      tgt.addSlot(convertReference(t));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getIncomingReferral())
      tgt.addIncomingReferral(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertAppointmentParticipantComponent(t));
    for (org.hl7.fhir.dstu3.model.Period t : src.getRequestedPeriod())
      tgt.addRequestedPeriod(convertPeriod(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Appointment convertAppointment(org.hl7.fhir.r4.model.Appointment src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Appointment tgt = new org.hl7.fhir.dstu3.model.Appointment();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertAppointmentStatus(src.getStatus()));
    if (src.hasServiceCategory())
      tgt.setServiceCategory(convertCodeableConcept(src.getServiceCategory()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType())
      tgt.addServiceType(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    if (src.hasAppointmentType())
      tgt.setAppointmentType(convertCodeableConcept(src.getAppointmentType()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getIndication())
      tgt.addIndication(convertReference(t));
    if (src.hasPriority())
      tgt.setPriority(src.getPriority());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasMinutesDuration())
      tgt.setMinutesDuration(src.getMinutesDuration());
    for (org.hl7.fhir.r4.model.Reference t : src.getSlot())
      tgt.addSlot(convertReference(t));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    for (org.hl7.fhir.r4.model.Reference t : src.getIncomingReferral())
      tgt.addIncomingReferral(convertReference(t));
    for (org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertAppointmentParticipantComponent(t));
    for (org.hl7.fhir.r4.model.Period t : src.getRequestedPeriod())
      tgt.addRequestedPeriod(convertPeriod(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasRequired())
      tgt.setRequired(convertParticipantRequired(src.getRequired()));
    if (src.hasStatus())
      tgt.setStatus(convertParticipationStatus(src.getStatus()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasRequired())
      tgt.setRequired(convertParticipantRequired(src.getRequired()));
    if (src.hasStatus())
      tgt.setStatus(convertParticipationStatus(src.getStatus()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.dstu3.model.AppointmentResponse src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AppointmentResponse tgt = new org.hl7.fhir.r4.model.AppointmentResponse();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasAppointment())
      tgt.setAppointment(convertReference(src.getAppointment()));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getParticipantType())
      tgt.addParticipantType(convertCodeableConcept(t));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasParticipantStatus())
      tgt.setParticipantStatus(convertParticipantStatus(src.getParticipantStatus()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.r4.model.AppointmentResponse src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AppointmentResponse tgt = new org.hl7.fhir.dstu3.model.AppointmentResponse();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasAppointment())
      tgt.setAppointment(convertReference(src.getAppointment()));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getParticipantType())
      tgt.addParticipantType(convertCodeableConcept(t));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasParticipantStatus())
      tgt.setParticipantStatus(convertParticipantStatus(src.getParticipantStatus()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Appointment.AppointmentStatus convertAppointmentStatus(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.PROPOSED;
    case PENDING: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.PENDING;
    case BOOKED: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.BOOKED;
    case ARRIVED: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.ARRIVED;
    case FULFILLED: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.FULFILLED;
    case CANCELLED: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.CANCELLED;
    case NOSHOW: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.NOSHOW;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Appointment.AppointmentStatus.NULL;
  }
}
  
  private static org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus convertAppointmentStatus(org.hl7.fhir.r4.model.Appointment.AppointmentStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.PROPOSED;
    case PENDING: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.PENDING;
    case BOOKED: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.BOOKED;
    case ARRIVED: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ARRIVED;
    case FULFILLED: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.FULFILLED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.CANCELLED;
    case NOSHOW: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.NOSHOW;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.TestScript.AssertionDirectionType convertAssertionDirectionType(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RESPONSE: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.RESPONSE;
    case REQUEST: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.REQUEST;
    default: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType convertAssertionDirectionType(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RESPONSE: return org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.RESPONSE;
    case REQUEST: return org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.REQUEST;
    default: return org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.TestScript.AssertionOperatorType convertAssertionOperatorType(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQUALS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EQUALS;
    case NOTEQUALS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEQUALS;
    case IN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.IN;
    case NOTIN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTIN;
    case GREATERTHAN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.GREATERTHAN;
    case LESSTHAN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.LESSTHAN;
    case EMPTY: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EMPTY;
    case NOTEMPTY: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEMPTY;
    case CONTAINS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.CONTAINS;
    case NOTCONTAINS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTCONTAINS;
    case EVAL: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EVAL;
    default: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType convertAssertionOperatorType(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQUALS: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EQUALS;
    case NOTEQUALS: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEQUALS;
    case IN: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.IN;
    case NOTIN: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTIN;
    case GREATERTHAN: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.GREATERTHAN;
    case LESSTHAN: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.LESSTHAN;
    case EMPTY: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EMPTY;
    case NOTEMPTY: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEMPTY;
    case CONTAINS: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.CONTAINS;
    case NOTCONTAINS: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTCONTAINS;
    case EVAL: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EVAL;
    default: return org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes convertAssertionResponseTypes(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OKAY: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.OKAY;
    case CREATED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CREATED;
    case NOCONTENT: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOCONTENT;
    case NOTMODIFIED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTMODIFIED;
    case BAD: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.BAD;
    case FORBIDDEN: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.FORBIDDEN;
    case NOTFOUND: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTFOUND;
    case METHODNOTALLOWED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED;
    case CONFLICT: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CONFLICT;
    case GONE: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.GONE;
    case PRECONDITIONFAILED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED;
    case UNPROCESSABLE: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.UNPROCESSABLE;
    default: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes convertAssertionResponseTypes(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OKAY: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.OKAY;
    case CREATED: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CREATED;
    case NOCONTENT: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOCONTENT;
    case NOTMODIFIED: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTMODIFIED;
    case BAD: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.BAD;
    case FORBIDDEN: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.FORBIDDEN;
    case NOTFOUND: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTFOUND;
    case METHODNOTALLOWED: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED;
    case CONFLICT: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CONFLICT;
    case GONE: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.GONE;
    case PRECONDITIONFAILED: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED;
    case UNPROCESSABLE: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.UNPROCESSABLE;
    default: return org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment();
    copyElement(src, tgt);
    if (src.hasContentType())
      tgt.setContentType(src.getContentType());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasData())
      tgt.setData(src.getData());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasSize())
      tgt.setSize(src.getSize());
    if (src.hasHash())
      tgt.setHash(src.getHash());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasCreation())
      tgt.setCreation(src.getCreation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment();
    copyElement(src, tgt);
    if (src.hasContentType())
      tgt.setContentType(src.getContentType());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasData())
      tgt.setData(src.getData());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasSize())
      tgt.setSize(src.getSize());
    if (src.hasHash())
      tgt.setHash(src.getHash());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasCreation())
      tgt.setCreation(src.getCreation());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.AuditEvent convertAuditEvent(org.hl7.fhir.dstu3.model.AuditEvent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AuditEvent tgt = new org.hl7.fhir.r4.model.AuditEvent();
    copyDomainResource(src, tgt);
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    for (org.hl7.fhir.dstu3.model.Coding t : src.getSubtype())
      tgt.addSubtype(convertCoding(t));
    if (src.hasAction())
      tgt.setAction(convertAuditEventAction(src.getAction()));
    if (src.hasRecorded())
      tgt.setRecorded(src.getRecorded());
    if (src.hasOutcome())
      tgt.setOutcome(convertAuditEventOutcome(src.getOutcome()));
    if (src.hasOutcomeDesc())
      tgt.setOutcomeDesc(src.getOutcomeDesc());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPurposeOfEvent())
      tgt.addPurposeOfEvent(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent t : src.getAgent())
      tgt.addAgent(convertAuditEventAgentComponent(t));
    if (src.hasSource())
      tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
    for (org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent t : src.getEntity())
      tgt.addEntity(convertAuditEventEntityComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AuditEvent convertAuditEvent(org.hl7.fhir.r4.model.AuditEvent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AuditEvent tgt = new org.hl7.fhir.dstu3.model.AuditEvent();
    copyDomainResource(src, tgt);
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    for (org.hl7.fhir.r4.model.Coding t : src.getSubtype())
      tgt.addSubtype(convertCoding(t));
    if (src.hasAction())
      tgt.setAction(convertAuditEventAction(src.getAction()));
    if (src.hasRecorded())
      tgt.setRecorded(src.getRecorded());
    if (src.hasOutcome())
      tgt.setOutcome(convertAuditEventOutcome(src.getOutcome()));
    if (src.hasOutcomeDesc())
      tgt.setOutcomeDesc(src.getOutcomeDesc());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPurposeOfEvent())
      tgt.addPurposeOfEvent(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent t : src.getAgent())
      tgt.addAgent(convertAuditEventAgentComponent(t));
    if (src.hasSource())
      tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
    for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent t : src.getEntity())
      tgt.addEntity(convertAuditEventEntityComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.AuditEvent.AuditEventAction convertAuditEventAction(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case C: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.C;
    case R: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.R;
    case U: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.U;
    case D: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.D;
    case E: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.E;
    default: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction convertAuditEventAction(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case C: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.C;
    case R: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.R;
    case U: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.U;
    case D: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.D;
    case E: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.E;
    default: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.NULL;
  }
}

  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    if (src.hasReference())
      tgt.setReference(convertReference(src.getReference()));
    if (src.hasUserId())
      tgt.setUserId(convertIdentifier(src.getUserId()));
    if (src.hasAltId())
      tgt.setAltId(src.getAltId());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasRequestor())
      tgt.setRequestor(src.getRequestor());
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getPolicy())
      tgt.addPolicy(t.getValue());
    if (src.hasMedia())
      tgt.setMedia(convertCoding(src.getMedia()));
    if (src.hasNetwork())
      tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPurposeOfUse())
      tgt.addPurposeOfUse(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    if (src.hasReference())
      tgt.setReference(convertReference(src.getReference()));
    if (src.hasUserId())
      tgt.setUserId(convertIdentifier(src.getUserId()));
    if (src.hasAltId())
      tgt.setAltId(src.getAltId());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasRequestor())
      tgt.setRequestor(src.getRequestor());
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.r4.model.UriType t : src.getPolicy())
      tgt.addPolicy(t.getValue());
    if (src.hasMedia())
      tgt.setMedia(convertCoding(src.getMedia()));
    if (src.hasNetwork())
      tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPurposeOfUse())
      tgt.addPurposeOfUse(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent();
    copyElement(src, tgt);
    if (src.hasAddress())
      tgt.setAddress(src.getAddress());
    if (src.hasType())
      tgt.setType(convertAuditEventAgentNetworkType(src.getType()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent();
    copyElement(src, tgt);
    if (src.hasAddress())
      tgt.setAddress(src.getAddress());
    if (src.hasType())
      tgt.setType(convertAuditEventAgentNetworkType(src.getType()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType convertAuditEventAgentNetworkType(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case _1: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._1;
    case _2: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._2;
    case _3: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._3;
    case _4: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._4;
    case _5: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._5;
    default: return org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType convertAuditEventAgentNetworkType(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case _1: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._1;
    case _2: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._2;
    case _3: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._3;
    case _4: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._4;
    case _5: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._5;
    default: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasReference())
      tgt.setReference(convertReference(src.getReference()));
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    if (src.hasRole())
      tgt.setRole(convertCoding(src.getRole()));
    if (src.hasLifecycle())
      tgt.setLifecycle(convertCoding(src.getLifecycle()));
    for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurityLabel())
      tgt.addSecurityLabel(convertCoding(t));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasQuery())
      tgt.setQuery(src.getQuery());
    for (org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail())
      tgt.addDetail(convertAuditEventEntityDetailComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasReference())
      tgt.setReference(convertReference(src.getReference()));
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    if (src.hasRole())
      tgt.setRole(convertCoding(src.getRole()));
    if (src.hasLifecycle())
      tgt.setLifecycle(convertCoding(src.getLifecycle()));
    for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel())
      tgt.addSecurityLabel(convertCoding(t));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasQuery())
      tgt.setQuery(src.getQuery());
    for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail())
      tgt.addDetail(convertAuditEventEntityDetailComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasValue())
      tgt.setValue(new Base64BinaryType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome convertAuditEventOutcome(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventOutcome src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case _0: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._0;
    case _4: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._4;
    case _8: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._8;
    case _12: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._12;
    default: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventOutcome convertAuditEventOutcome(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case _0: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventOutcome._0;
    case _4: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventOutcome._4;
    case _8: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventOutcome._8;
    case _12: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventOutcome._12;
    default: return org.hl7.fhir.dstu3.model.AuditEvent.AuditEventOutcome.NULL;
  }
}

  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent();
    copyElement(src, tgt);
    if (src.hasSite())
      tgt.setSite(src.getSite());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.dstu3.model.Coding t : src.getType())
      tgt.addType(convertCoding(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent();
    copyElement(src, tgt);
    if (src.hasSite())
      tgt.setSite(src.getSite());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.r4.model.Coding t : src.getType())
      tgt.addType(convertCoding(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException {
    org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Basic convertBasic(org.hl7.fhir.dstu3.model.Basic src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Basic tgt = new org.hl7.fhir.r4.model.Basic();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Basic convertBasic(org.hl7.fhir.r4.model.Basic src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Basic tgt = new org.hl7.fhir.dstu3.model.Basic();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.EligibilityResponse.BenefitComponent convertBenefitComponent(org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EligibilityResponse.BenefitComponent tgt = new org.hl7.fhir.r4.model.EligibilityResponse.BenefitComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasAllowed())
      tgt.setAllowed(convertType(src.getAllowed()));
    if (src.hasUsed())
      tgt.setUsed(convertType(src.getUsed()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitComponent convertBenefitComponent(org.hl7.fhir.r4.model.EligibilityResponse.BenefitComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitComponent tgt = new org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasAllowed())
      tgt.setAllowed(convertType(src.getAllowed()));
    if (src.hasUsed())
      tgt.setUsed(convertType(src.getUsed()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.EligibilityResponse.BenefitsComponent convertBenefitsComponent(org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EligibilityResponse.BenefitsComponent tgt = new org.hl7.fhir.r4.model.EligibilityResponse.BenefitsComponent();
    copyElement(src, tgt);
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasSubCategory())
      tgt.setSubCategory(convertCodeableConcept(src.getSubCategory()));
    if (src.hasExcluded())
      tgt.setExcluded(src.getExcluded());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasNetwork())
      tgt.setNetwork(convertCodeableConcept(src.getNetwork()));
    if (src.hasUnit())
      tgt.setUnit(convertCodeableConcept(src.getUnit()));
    if (src.hasTerm())
      tgt.setTerm(convertCodeableConcept(src.getTerm()));
    for (org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitComponent t : src.getFinancial())
      tgt.addFinancial(convertBenefitComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitsComponent convertBenefitsComponent(org.hl7.fhir.r4.model.EligibilityResponse.BenefitsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitsComponent tgt = new org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitsComponent();
    copyElement(src, tgt);
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasSubCategory())
      tgt.setSubCategory(convertCodeableConcept(src.getSubCategory()));
    if (src.hasExcluded())
      tgt.setExcluded(src.getExcluded());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasNetwork())
      tgt.setNetwork(convertCodeableConcept(src.getNetwork()));
    if (src.hasUnit())
      tgt.setUnit(convertCodeableConcept(src.getUnit()));
    if (src.hasTerm())
      tgt.setTerm(convertCodeableConcept(src.getTerm()));
    for (org.hl7.fhir.r4.model.EligibilityResponse.BenefitComponent t : src.getFinancial())
      tgt.addFinancial(convertBenefitComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Binary convertBinary(org.hl7.fhir.dstu3.model.Binary src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Binary tgt = new org.hl7.fhir.r4.model.Binary();
    copyResource(src, tgt);
    if (src.hasContentType())
      tgt.setContentType(src.getContentType());
    if (src.hasSecurityContext())
      tgt.setSecurityContext(convertReference(src.getSecurityContext()));
    if (src.hasContent())
      tgt.setContent(src.getContent());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Binary convertBinary(org.hl7.fhir.r4.model.Binary src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Binary tgt = new org.hl7.fhir.dstu3.model.Binary();
    copyResource(src, tgt);
    if (src.hasContentType())
      tgt.setContentType(src.getContentType());
    if (src.hasSecurityContext())
      tgt.setSecurityContext(convertReference(src.getSecurityContext()));
    if (src.hasContent())
      tgt.setContent(src.getContent());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Enumerations.BindingStrength convertBindingStrength(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REQUIRED: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED;
    case EXTENSIBLE: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE;
    case PREFERRED: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED;
    case EXAMPLE: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE;
    default: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Enumerations.BindingStrength convertBindingStrength(org.hl7.fhir.r4.model.Enumerations.BindingStrength src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REQUIRED: return org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED;
    case EXTENSIBLE: return org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE;
    case PREFERRED: return org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED;
    case EXAMPLE: return org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE;
    default: return org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL;
  }
}

  public static org.hl7.fhir.r4.model.BodyStructure convertBodySite(org.hl7.fhir.dstu3.model.BodySite src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.BodyStructure tgt = new org.hl7.fhir.r4.model.BodyStructure();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
//    if (src.hasCode())
//      tgt.setCode(convertCodeableConcept(src.getCode()));
//    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getQualifier())
//      tgt.addQualifier(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Attachment t : src.getImage())
      tgt.addImage(convertAttachment(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.BodySite convertBodySite(org.hl7.fhir.r4.model.BodyStructure src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.BodySite tgt = new org.hl7.fhir.dstu3.model.BodySite();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
//    if (src.hasCode())
//      tgt.setCode(convertCodeableConcept(src.getCode()));
//    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getQualifier())
//      tgt.addQualifier(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.Attachment t : src.getImage())
      tgt.addImage(convertAttachment(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException {
    org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.BooleanType tgt = new org.hl7.fhir.dstu3.model.BooleanType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Bundle convertBundle(org.hl7.fhir.dstu3.model.Bundle src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Bundle tgt = new org.hl7.fhir.r4.model.Bundle();
    copyResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasType())
      tgt.setType(convertBundleType(src.getType()));
    if (src.hasTotal())
      tgt.setTotal(src.getTotal());
    for (org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent t : src.getLink())
      tgt.addLink(convertBundleLinkComponent(t));
    for (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent t : src.getEntry())
      tgt.addEntry(convertBundleEntryComponent(t));
    if (src.hasSignature())
      tgt.setSignature(convertSignature(src.getSignature()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Bundle convertBundle(org.hl7.fhir.r4.model.Bundle src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Bundle tgt = new org.hl7.fhir.dstu3.model.Bundle();
    copyResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasType())
      tgt.setType(convertBundleType(src.getType()));
    if (src.hasTotal())
      tgt.setTotal(src.getTotal());
    for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink())
      tgt.addLink(convertBundleLinkComponent(t));
    for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent t : src.getEntry())
      tgt.addEntry(convertBundleEntryComponent(t));
    if (src.hasSignature())
      tgt.setSignature(convertSignature(src.getSignature()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Bundle.BundleEntryComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntryComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent t : src.getLink())
      tgt.addLink(convertBundleLinkComponent(t));
    if (src.hasFullUrl())
      tgt.setFullUrl(src.getFullUrl());
    if (src.hasResource())
      tgt.setResource(convertResource(src.getResource()));
    if (src.hasSearch())
      tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
    if (src.hasRequest())
      tgt.setRequest(convertBundleEntryRequestComponent(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertBundleEntryResponseComponent(src.getResponse()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent tgt = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink())
      tgt.addLink(convertBundleLinkComponent(t));
    if (src.hasFullUrl())
      tgt.setFullUrl(src.getFullUrl());
    if (src.hasResource())
      tgt.setResource(convertResource(src.getResource()));
    if (src.hasSearch())
      tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
    if (src.hasRequest())
      tgt.setRequest(convertBundleEntryRequestComponent(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertBundleEntryResponseComponent(src.getResponse()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent convertBundleEntryRequestComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryRequestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent();
    copyElement(src, tgt);
    if (src.hasMethod())
      tgt.setMethod(convertHTTPVerb(src.getMethod()));
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIfNoneMatch())
      tgt.setIfNoneMatch(src.getIfNoneMatch());
    if (src.hasIfModifiedSince())
      tgt.setIfModifiedSince(src.getIfModifiedSince());
    if (src.hasIfMatch())
      tgt.setIfMatch(src.getIfMatch());
    if (src.hasIfNoneExist())
      tgt.setIfNoneExist(src.getIfNoneExist());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Bundle.BundleEntryRequestComponent convertBundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Bundle.BundleEntryRequestComponent tgt = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryRequestComponent();
    copyElement(src, tgt);
    if (src.hasMethod())
      tgt.setMethod(convertHTTPVerb(src.getMethod()));
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIfNoneMatch())
      tgt.setIfNoneMatch(src.getIfNoneMatch());
    if (src.hasIfModifiedSince())
      tgt.setIfModifiedSince(src.getIfModifiedSince());
    if (src.hasIfMatch())
      tgt.setIfMatch(src.getIfMatch());
    if (src.hasIfNoneExist())
      tgt.setIfNoneExist(src.getIfNoneExist());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent convertBundleEntryResponseComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryResponseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(src.getStatus());
    if (src.hasLocation())
      tgt.setLocation(src.getLocation());
    if (src.hasEtag())
      tgt.setEtag(src.getEtag());
    if (src.hasLastModified())
      tgt.setLastModified(src.getLastModified());
    if (src.hasOutcome())
      tgt.setOutcome(convertResource(src.getOutcome()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Bundle.BundleEntryResponseComponent convertBundleEntryResponseComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Bundle.BundleEntryResponseComponent tgt = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryResponseComponent();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(src.getStatus());
    if (src.hasLocation())
      tgt.setLocation(src.getLocation());
    if (src.hasEtag())
      tgt.setEtag(src.getEtag());
    if (src.hasLastModified())
      tgt.setLastModified(src.getLastModified());
    if (src.hasOutcome())
      tgt.setOutcome(convertResource(src.getOutcome()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntrySearchComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertSearchEntryMode(src.getMode()));
    if (src.hasScore())
      tgt.setScore(src.getScore());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.dstu3.model.Bundle.BundleEntrySearchComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertSearchEntryMode(src.getMode()));
    if (src.hasScore())
      tgt.setScore(src.getScore());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleLinkComponent();
    copyElement(src, tgt);
    if (src.hasRelation())
      tgt.setRelation(src.getRelation());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.r4.model.Bundle.BundleLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent();
    copyElement(src, tgt);
    if (src.hasRelation())
      tgt.setRelation(src.getRelation());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Bundle.BundleType convertBundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DOCUMENT: return org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT;
    case MESSAGE: return org.hl7.fhir.r4.model.Bundle.BundleType.MESSAGE;
    case TRANSACTION: return org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTION;
    case TRANSACTIONRESPONSE: return org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTIONRESPONSE;
    case BATCH: return org.hl7.fhir.r4.model.Bundle.BundleType.BATCH;
    case BATCHRESPONSE: return org.hl7.fhir.r4.model.Bundle.BundleType.BATCHRESPONSE;
    case HISTORY: return org.hl7.fhir.r4.model.Bundle.BundleType.HISTORY;
    case SEARCHSET: return org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET;
    case COLLECTION: return org.hl7.fhir.r4.model.Bundle.BundleType.COLLECTION;
    default: return org.hl7.fhir.r4.model.Bundle.BundleType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Bundle.BundleType convertBundleType(org.hl7.fhir.r4.model.Bundle.BundleType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DOCUMENT: return org.hl7.fhir.dstu3.model.Bundle.BundleType.DOCUMENT;
    case MESSAGE: return org.hl7.fhir.dstu3.model.Bundle.BundleType.MESSAGE;
    case TRANSACTION: return org.hl7.fhir.dstu3.model.Bundle.BundleType.TRANSACTION;
    case TRANSACTIONRESPONSE: return org.hl7.fhir.dstu3.model.Bundle.BundleType.TRANSACTIONRESPONSE;
    case BATCH: return org.hl7.fhir.dstu3.model.Bundle.BundleType.BATCH;
    case BATCHRESPONSE: return org.hl7.fhir.dstu3.model.Bundle.BundleType.BATCHRESPONSE;
    case HISTORY: return org.hl7.fhir.dstu3.model.Bundle.BundleType.HISTORY;
    case SEARCHSET: return org.hl7.fhir.dstu3.model.Bundle.BundleType.SEARCHSET;
    case COLLECTION: return org.hl7.fhir.dstu3.model.Bundle.BundleType.COLLECTION;
    default: return org.hl7.fhir.dstu3.model.Bundle.BundleType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CapabilityStatement convertCapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement tgt = new org.hl7.fhir.r4.model.CapabilityStatement();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasKind())
      tgt.setKind(convertCapabilityStatementKind(src.getKind()));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getInstantiates())
      tgt.addInstantiates(t.getValue());
    if (src.hasSoftware())
      tgt.setSoftware(convertCapabilityStatementSoftwareComponent(src.getSoftware()));
    if (src.hasImplementation())
      tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation()));
    if (src.hasFhirVersion())
      tgt.setFhirVersion(src.getFhirVersion());
    if (src.hasAcceptUnknown())
      tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown()));
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getFormat())
      tgt.addFormat(t.getValue());
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat())
      tgt.addPatchFormat(t.getValue());
    for (org.hl7.fhir.dstu3.model.UriType t : src.getImplementationGuide())
      tgt.addImplementationGuide(t.getValue());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getProfile())
      tgt.addProfile(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest())
      tgt.addRest(convertCapabilityStatementRestComponent(t));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent t : src.getMessaging())
      tgt.addMessaging(convertCapabilityStatementMessagingComponent(t));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument())
      tgt.addDocument(convertCapabilityStatementDocumentComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement convertCapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasKind())
      tgt.setKind(convertCapabilityStatementKind(src.getKind()));
    for (org.hl7.fhir.r4.model.UriType t : src.getInstantiates())
      tgt.addInstantiates(t.getValue());
    if (src.hasSoftware())
      tgt.setSoftware(convertCapabilityStatementSoftwareComponent(src.getSoftware()));
    if (src.hasImplementation())
      tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation()));
    if (src.hasFhirVersion())
      tgt.setFhirVersion(src.getFhirVersion());
    if (src.hasAcceptUnknown())
      tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown()));
    for (org.hl7.fhir.r4.model.CodeType t : src.getFormat())
      tgt.addFormat(t.getValue());
    for (org.hl7.fhir.r4.model.CodeType t : src.getPatchFormat())
      tgt.addPatchFormat(t.getValue());
    for (org.hl7.fhir.r4.model.UriType t : src.getImplementationGuide())
      tgt.addImplementationGuide(t.getValue());
    for (org.hl7.fhir.r4.model.Reference t : src.getProfile())
      tgt.addProfile(convertReference(t));
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest())
      tgt.addRest(convertCapabilityStatementRestComponent(t));
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent t : src.getMessaging())
      tgt.addMessaging(convertCapabilityStatementMessagingComponent(t));
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument())
      tgt.addDocument(convertCapabilityStatementDocumentComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent convertCapabilityStatementDocumentComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertDocumentMode(src.getMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent convertCapabilityStatementDocumentComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertDocumentMode(src.getMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent convertCapabilityStatementImplementationComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementImplementationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementImplementationComponent convertCapabilityStatementImplementationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementImplementationComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementImplementationComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind convertCapabilityStatementKind(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INSTANCE: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.INSTANCE;
    case CAPABILITY: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.CAPABILITY;
    case REQUIREMENTS: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.REQUIREMENTS;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementKind convertCapabilityStatementKind(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INSTANCE: return org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementKind.INSTANCE;
    case CAPABILITY: return org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementKind.CAPABILITY;
    case REQUIREMENTS: return org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementKind.REQUIREMENTS;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementKind.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent convertCapabilityStatementMessagingComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent t : src.getEndpoint())
      tgt.addEndpoint(convertCapabilityStatementMessagingEndpointComponent(t));
    if (src.hasReliableCache())
      tgt.setReliableCache(src.getReliableCache());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent t : src.getSupportedMessage())
      tgt.addSupportedMessage(convertCapabilityStatementMessagingSupportedMessageComponent(t));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEventComponent t : src.getEvent())
      tgt.addEvent(convertCapabilityStatementMessagingEventComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent convertCapabilityStatementMessagingComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent t : src.getEndpoint())
      tgt.addEndpoint(convertCapabilityStatementMessagingEndpointComponent(t));
    if (src.hasReliableCache())
      tgt.setReliableCache(src.getReliableCache());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent t : src.getSupportedMessage())
      tgt.addSupportedMessage(convertCapabilityStatementMessagingSupportedMessageComponent(t));
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEventComponent t : src.getEvent())
      tgt.addEvent(convertCapabilityStatementMessagingEventComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent convertCapabilityStatementMessagingEndpointComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent();
    copyElement(src, tgt);
    if (src.hasProtocol())
      tgt.setProtocol(convertCoding(src.getProtocol()));
    if (src.hasAddress())
      tgt.setAddress(src.getAddress());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent convertCapabilityStatementMessagingEndpointComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent();
    copyElement(src, tgt);
    if (src.hasProtocol())
      tgt.setProtocol(convertCoding(src.getProtocol()));
    if (src.hasAddress())
      tgt.setAddress(src.getAddress());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEventComponent convertCapabilityStatementMessagingEventComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEventComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEventComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEventComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCoding(src.getCode()));
    if (src.hasCategory())
      tgt.setCategory(convertMessageSignificanceCategory(src.getCategory()));
    if (src.hasMode())
      tgt.setMode(convertEventCapabilityMode(src.getMode()));
    if (src.hasFocus())
      tgt.setFocus(src.getFocus());
    if (src.hasRequest())
      tgt.setRequest(convertReference(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertReference(src.getResponse()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEventComponent convertCapabilityStatementMessagingEventComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEventComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEventComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingEventComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCoding(src.getCode()));
    if (src.hasCategory())
      tgt.setCategory(convertMessageSignificanceCategory(src.getCategory()));
    if (src.hasMode())
      tgt.setMode(convertEventCapabilityMode(src.getMode()));
    if (src.hasFocus())
      tgt.setFocus(src.getFocus());
    if (src.hasRequest())
      tgt.setRequest(convertReference(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertReference(src.getResponse()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent convertCapabilityStatementMessagingSupportedMessageComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertEventCapabilityMode(src.getMode()));
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent convertCapabilityStatementMessagingSupportedMessageComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertEventCapabilityMode(src.getMode()));
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent convertCapabilityStatementRestComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertRestfulCapabilityMode(src.getMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasSecurity())
      tgt.setSecurity(convertCapabilityStatementRestSecurityComponent(src.getSecurity()));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent t : src.getResource())
      tgt.addResource(convertCapabilityStatementRestResourceComponent(t));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.SystemInteractionComponent t : src.getInteraction())
      tgt.addInteraction(convertSystemInteractionComponent(t));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())
      tgt.addSearchParam(convertCapabilityStatementRestResourceSearchParamComponent(t));
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestOperationComponent t : src.getOperation())
      tgt.addOperation(convertCapabilityStatementRestOperationComponent(t));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getCompartment())
      tgt.addCompartment(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent convertCapabilityStatementRestComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertRestfulCapabilityMode(src.getMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasSecurity())
      tgt.setSecurity(convertCapabilityStatementRestSecurityComponent(src.getSecurity()));
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent t : src.getResource())
      tgt.addResource(convertCapabilityStatementRestResourceComponent(t));
    for (org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent t : src.getInteraction())
      tgt.addInteraction(convertSystemInteractionComponent(t));
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())
      tgt.addSearchParam(convertCapabilityStatementRestResourceSearchParamComponent(t));
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent t : src.getOperation())
      tgt.addOperation(convertCapabilityStatementRestOperationComponent(t));
    for (org.hl7.fhir.r4.model.UriType t : src.getCompartment())
      tgt.addCompartment(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent convertCapabilityStatementRestOperationComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestOperationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestOperationComponent convertCapabilityStatementRestOperationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestOperationComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestOperationComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent convertCapabilityStatementRestResourceComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceInteractionComponent t : src.getInteraction())
      tgt.addInteraction(convertResourceInteractionComponent(t));
    if (src.hasVersioning())
      tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning()));
    if (src.hasReadHistory())
      tgt.setReadHistory(src.getReadHistory());
    if (src.hasUpdateCreate())
      tgt.setUpdateCreate(src.getUpdateCreate());
    if (src.hasConditionalCreate())
      tgt.setConditionalCreate(src.getConditionalCreate());
    if (src.hasConditionalRead())
      tgt.setConditionalRead(convertConditionalReadStatus(src.getConditionalRead()));
    if (src.hasConditionalUpdate())
      tgt.setConditionalUpdate(src.getConditionalUpdate());
    if (src.hasConditionalDelete())
      tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete()));
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy> t : src.getReferencePolicy())
      tgt.addReferencePolicy(convertReferenceHandlingPolicy(t.getValue()));
    for (org.hl7.fhir.dstu3.model.StringType t : src.getSearchInclude())
      tgt.addSearchInclude(t.getValue());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getSearchRevInclude())
      tgt.addSearchRevInclude(t.getValue());
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())
      tgt.addSearchParam(convertCapabilityStatementRestResourceSearchParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent convertCapabilityStatementRestResourceComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    for (org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent t : src.getInteraction())
      tgt.addInteraction(convertResourceInteractionComponent(t));
    if (src.hasVersioning())
      tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning()));
    if (src.hasReadHistory())
      tgt.setReadHistory(src.getReadHistory());
    if (src.hasUpdateCreate())
      tgt.setUpdateCreate(src.getUpdateCreate());
    if (src.hasConditionalCreate())
      tgt.setConditionalCreate(src.getConditionalCreate());
    if (src.hasConditionalRead())
      tgt.setConditionalRead(convertConditionalReadStatus(src.getConditionalRead()));
    if (src.hasConditionalUpdate())
      tgt.setConditionalUpdate(src.getConditionalUpdate());
    if (src.hasConditionalDelete())
      tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete()));
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy> t : src.getReferencePolicy())
      tgt.addReferencePolicy(convertReferenceHandlingPolicy(t.getValue()));
    for (org.hl7.fhir.r4.model.StringType t : src.getSearchInclude())
      tgt.addSearchInclude(t.getValue());
    for (org.hl7.fhir.r4.model.StringType t : src.getSearchRevInclude())
      tgt.addSearchRevInclude(t.getValue());
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())
      tgt.addSearchParam(convertCapabilityStatementRestResourceSearchParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent convertCapabilityStatementRestResourceSearchParamComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    if (src.hasType())
      tgt.setType(convertSearchParamType(src.getType()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent convertCapabilityStatementRestResourceSearchParamComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    if (src.hasType())
      tgt.setType(convertSearchParamType(src.getType()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent convertCapabilityStatementRestSecurityCertificateComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasBlob())
      tgt.setBlob(src.getBlob());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent convertCapabilityStatementRestSecurityCertificateComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasBlob())
      tgt.setBlob(src.getBlob());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent convertCapabilityStatementRestSecurityComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent();
    copyElement(src, tgt);
    if (src.hasCors())
      tgt.setCors(src.getCors());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getService())
      tgt.addService(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent t : src.getCertificate())
      tgt.addCertificate(convertCapabilityStatementRestSecurityCertificateComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityComponent convertCapabilityStatementRestSecurityComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestSecurityComponent();
    copyElement(src, tgt);
    if (src.hasCors())
      tgt.setCors(src.getCors());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getService())
      tgt.addService(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent t : src.getCertificate())
      tgt.addCertificate(convertCapabilityStatementRestSecurityCertificateComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent convertCapabilityStatementSoftwareComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementSoftwareComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasReleaseDate())
      tgt.setReleaseDate(src.getReleaseDate());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementSoftwareComponent convertCapabilityStatementSoftwareComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementSoftwareComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementSoftwareComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasReleaseDate())
      tgt.setReleaseDate(src.getReleaseDate());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CarePlan convertCarePlan(org.hl7.fhir.dstu3.model.CarePlan src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CarePlan tgt = new org.hl7.fhir.r4.model.CarePlan();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertCarePlanStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertCarePlanIntent(src.getIntent()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAuthor())
      tgt.addAuthor(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getCareTeam())
      tgt.addCareTeam(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAddresses())
      tgt.addAddresses(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInfo())
      tgt.addSupportingInfo(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getGoal())
      tgt.addGoal(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent t : src.getActivity())
      tgt.addActivity(convertCarePlanActivityComponent(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CarePlan convertCarePlan(org.hl7.fhir.r4.model.CarePlan src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CarePlan tgt = new org.hl7.fhir.dstu3.model.CarePlan();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertCarePlanStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertCarePlanIntent(src.getIntent()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.Reference t : src.getAuthor())
      tgt.addAuthor(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getCareTeam())
      tgt.addCareTeam(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getAddresses())
      tgt.addAddresses(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInfo())
      tgt.addSupportingInfo(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getGoal())
      tgt.addGoal(convertReference(t));
    for (org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent t : src.getActivity())
      tgt.addActivity(convertCarePlanActivityComponent(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getOutcomeCodeableConcept())
      tgt.addOutcomeCodeableConcept(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getOutcomeReference())
      tgt.addOutcomeReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getProgress())
      tgt.addProgress(convertAnnotation(t));
    if (src.hasReference())
      tgt.setReference(convertReference(src.getReference()));
    if (src.hasDetail())
      tgt.setDetail(convertCarePlanActivityDetailComponent(src.getDetail()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getOutcomeCodeableConcept())
      tgt.addOutcomeCodeableConcept(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getOutcomeReference())
      tgt.addOutcomeReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getProgress())
      tgt.addProgress(convertAnnotation(t));
    if (src.hasReference())
      tgt.setReference(convertReference(src.getReference()));
    if (src.hasDetail())
      tgt.setDetail(convertCarePlanActivityDetailComponent(src.getDetail()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent tgt = new org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent();
    copyElement(src, tgt);
//    if (src.hasCategory())
//      tgt.setKind(convertCodeableConcept(src.getCategory()));
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getGoal())
      tgt.addGoal(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertCarePlanActivityStatus(src.getStatus()));
    if (src.hasStatusReason())
      tgt.setStatusReason(src.getStatusReason());
    if (src.hasProhibited())
      tgt.setProhibited(src.getProhibited());
    if (src.hasScheduled())
      tgt.setScheduled(convertType(src.getScheduled()));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPerformer())
      tgt.addPerformer(convertReference(t));
    if (src.hasProduct())
      tgt.setProduct(convertType(src.getProduct()));
    if (src.hasDailyAmount())
      tgt.setDailyAmount(convertSimpleQuantity(src.getDailyAmount()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent tgt = new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent();
    copyElement(src, tgt);
//    if (src.hasKind())
//      tgt.setCategory(convertCodeableConcept(src.getKind()));
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getGoal())
      tgt.addGoal(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertCarePlanActivityStatus(src.getStatus()));
    if (src.hasStatusReason())
      tgt.setStatusReason(src.getStatusReason());
    if (src.hasProhibited())
      tgt.setProhibited(src.getProhibited());
    if (src.hasScheduled())
      tgt.setScheduled(convertType(src.getScheduled()));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.r4.model.Reference t : src.getPerformer())
      tgt.addPerformer(convertReference(t));
    if (src.hasProduct())
      tgt.setProduct(convertType(src.getProduct()));
    if (src.hasDailyAmount())
      tgt.setDailyAmount(convertSimpleQuantity(src.getDailyAmount()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus convertCarePlanActivityStatus(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTSTARTED: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.NOTSTARTED;
    case SCHEDULED: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.SCHEDULED;
    case INPROGRESS: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.COMPLETED;
    case CANCELLED: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.CANCELLED;
    case UNKNOWN: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus convertCarePlanActivityStatus(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTSTARTED: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.NOTSTARTED;
    case SCHEDULED: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.SCHEDULED;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.COMPLETED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.CANCELLED;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.CarePlan.CarePlanIntent convertCarePlanIntent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.PLAN;
    case ORDER: return org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.ORDER;
    case OPTION: return org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.OPTION;
    default: return org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent convertCarePlanIntent(org.hl7.fhir.r4.model.CarePlan.CarePlanIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent.PLAN;
    case ORDER: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent.ORDER;
    case OPTION: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent.OPTION;
    default: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent.NULL;
  }
}

  private static org.hl7.fhir.r4.model.CarePlan.CarePlanStatus convertCarePlanStatus(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.SUSPENDED;
    case COMPLETED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.ENTEREDINERROR;
    case CANCELLED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.CANCELLED;
    case UNKNOWN: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus convertCarePlanStatus(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.SUSPENDED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.ENTEREDINERROR;
    case CANCELLED: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.CANCELLED;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CareTeam convertCareTeam(org.hl7.fhir.dstu3.model.CareTeam src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CareTeam tgt = new org.hl7.fhir.r4.model.CareTeam();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertCareTeamStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertCareTeamParticipantComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getManagingOrganization())
      tgt.addManagingOrganization(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CareTeam convertCareTeam(org.hl7.fhir.r4.model.CareTeam src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CareTeam tgt = new org.hl7.fhir.dstu3.model.CareTeam();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertCareTeamStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertCareTeamParticipantComponent(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getManagingOrganization())
      tgt.addManagingOrganization(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Claim.CareTeamComponent convertCareTeamComponent(org.hl7.fhir.dstu3.model.Claim.CareTeamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.CareTeamComponent tgt = new org.hl7.fhir.r4.model.Claim.CareTeamComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasResponsible())
      tgt.setResponsible(src.getResponsible());
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasQualification())
      tgt.setQualification(convertCodeableConcept(src.getQualification()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.CareTeamComponent convertCareTeamComponent(org.hl7.fhir.r4.model.Claim.CareTeamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.CareTeamComponent tgt = new org.hl7.fhir.dstu3.model.Claim.CareTeamComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasResponsible())
      tgt.setResponsible(src.getResponsible());
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasQualification())
      tgt.setQualification(convertCodeableConcept(src.getQualification()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent convertCareTeamParticipantComponent(org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent tgt = new org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasMember())
      tgt.setMember(convertReference(src.getMember()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent convertCareTeamParticipantComponent(org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent tgt = new org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasMember())
      tgt.setMember(convertReference(src.getMember()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CareTeam.CareTeamStatus convertCareTeamStatus(org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.PROPOSED;
    case ACTIVE: return org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.SUSPENDED;
    case INACTIVE: return org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus convertCareTeamStatus(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus.PROPOSED;
    case ACTIVE: return org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus.SUSPENDED;
    case INACTIVE: return org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ChargeItem convertChargeItem(org.hl7.fhir.dstu3.model.ChargeItem src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ChargeItem tgt = new org.hl7.fhir.r4.model.ChargeItem();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getDefinition())
      tgt.addDefinition(t.getValue());
    if (src.hasStatus())
      tgt.setStatus(convertChargeItemStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    for (org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertChargeItemParticipantComponent(t));
    if (src.hasPerformingOrganization())
      tgt.setPerformingOrganization(convertReference(src.getPerformingOrganization()));
    if (src.hasRequestingOrganization())
      tgt.setRequestingOrganization(convertReference(src.getRequestingOrganization()));
    if (src.hasQuantity())
      tgt.setQuantity(convertQuantity(src.getQuantity()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getBodysite())
      tgt.addBodysite(convertCodeableConcept(t));
    if (src.hasFactorOverride())
      tgt.setFactorOverride(src.getFactorOverride());
    if (src.hasPriceOverride())
      tgt.setPriceOverride(convertMoney(src.getPriceOverride()));
    if (src.hasOverrideReason())
      tgt.setOverrideReason(src.getOverrideReason());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasEnteredDate())
      tgt.setEnteredDate(src.getEnteredDate());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getService())
      tgt.addService(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAccount())
      tgt.addAccount(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ChargeItem convertChargeItem(org.hl7.fhir.r4.model.ChargeItem src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ChargeItem tgt = new org.hl7.fhir.dstu3.model.ChargeItem();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.r4.model.UriType t : src.getDefinition())
      tgt.addDefinition(t.getValue());
    if (src.hasStatus())
      tgt.setStatus(convertChargeItemStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    for (org.hl7.fhir.r4.model.ChargeItem.ChargeItemParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertChargeItemParticipantComponent(t));
    if (src.hasPerformingOrganization())
      tgt.setPerformingOrganization(convertReference(src.getPerformingOrganization()));
    if (src.hasRequestingOrganization())
      tgt.setRequestingOrganization(convertReference(src.getRequestingOrganization()));
    if (src.hasQuantity())
      tgt.setQuantity(convertQuantity(src.getQuantity()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodysite())
      tgt.addBodysite(convertCodeableConcept(t));
    if (src.hasFactorOverride())
      tgt.setFactorOverride(src.getFactorOverride());
    if (src.hasPriceOverride())
      tgt.setPriceOverride(convertMoney(src.getPriceOverride()));
    if (src.hasOverrideReason())
      tgt.setOverrideReason(src.getOverrideReason());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasEnteredDate())
      tgt.setEnteredDate(src.getEnteredDate());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getService())
      tgt.addService(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getAccount())
      tgt.addAccount(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ChargeItem.ChargeItemParticipantComponent convertChargeItemParticipantComponent(org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ChargeItem.ChargeItemParticipantComponent tgt = new org.hl7.fhir.r4.model.ChargeItem.ChargeItemParticipantComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemParticipantComponent convertChargeItemParticipantComponent(org.hl7.fhir.r4.model.ChargeItem.ChargeItemParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemParticipantComponent tgt = new org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemParticipantComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus convertChargeItemStatus(org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.PLANNED;
    case BILLABLE: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.BILLABLE;
    case NOTBILLABLE: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.NOTBILLABLE;
    case ABORTED: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.ABORTED;
    case BILLED: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.BILLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus convertChargeItemStatus(org.hl7.fhir.r4.model.ChargeItem.ChargeItemStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.PLANNED;
    case BILLABLE: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.BILLABLE;
    case NOTBILLABLE: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.NOTBILLABLE;
    case ABORTED: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.ABORTED;
    case BILLED: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.BILLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.ChargeItem.ChargeItemStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Claim convertClaim(org.hl7.fhir.dstu3.model.Claim src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim tgt = new org.hl7.fhir.r4.model.Claim();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertClaimStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSubType())
      tgt.addSubType(convertCodeableConcept(t));
    if (src.hasUse())
      tgt.setUse(convertUse(src.getUse()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasBillablePeriod())
      tgt.setBillablePeriod(convertPeriod(src.getBillablePeriod()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasInsurer())
      tgt.setInsurer(convertReference(src.getInsurer()));
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasFundsReserve())
      tgt.setFundsReserve(convertCodeableConcept(src.getFundsReserve()));
    for (org.hl7.fhir.dstu3.model.Claim.RelatedClaimComponent t : src.getRelated())
      tgt.addRelated(convertRelatedClaimComponent(t));
    if (src.hasPrescription())
      tgt.setPrescription(convertReference(src.getPrescription()));
    if (src.hasOriginalPrescription())
      tgt.setOriginalPrescription(convertReference(src.getOriginalPrescription()));
    if (src.hasPayee())
      tgt.setPayee(convertPayeeComponent(src.getPayee()));
    if (src.hasReferral())
      tgt.setReferral(convertReference(src.getReferral()));
    if (src.hasFacility())
      tgt.setFacility(convertReference(src.getFacility()));
    for (org.hl7.fhir.dstu3.model.Claim.CareTeamComponent t : src.getCareTeam())
      tgt.addCareTeam(convertCareTeamComponent(t));
    for (org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent t : src.getInformation())
      tgt.addInformation(convertSpecialConditionComponent(t));
    for (org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent t : src.getDiagnosis())
      tgt.addDiagnosis(convertDiagnosisComponent(t));
    for (org.hl7.fhir.dstu3.model.Claim.ProcedureComponent t : src.getProcedure())
      tgt.addProcedure(convertProcedureComponent(t));
    for (org.hl7.fhir.dstu3.model.Claim.InsuranceComponent t : src.getInsurance())
      tgt.addInsurance(convertInsuranceComponent(t));
    if (src.hasAccident())
      tgt.setAccident(convertAccidentComponent(src.getAccident()));
    if (src.hasEmploymentImpacted())
      tgt.setEmploymentImpacted(convertPeriod(src.getEmploymentImpacted()));
    if (src.hasHospitalization())
      tgt.setHospitalization(convertPeriod(src.getHospitalization()));
    for (org.hl7.fhir.dstu3.model.Claim.ItemComponent t : src.getItem())
      tgt.addItem(convertItemComponent(t));
    if (src.hasTotal())
      tgt.setTotal(convertMoney(src.getTotal()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim convertClaim(org.hl7.fhir.r4.model.Claim src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim tgt = new org.hl7.fhir.dstu3.model.Claim();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertClaimStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSubType())
      tgt.addSubType(convertCodeableConcept(t));
    if (src.hasUse())
      tgt.setUse(convertUse(src.getUse()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasBillablePeriod())
      tgt.setBillablePeriod(convertPeriod(src.getBillablePeriod()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasInsurer())
      tgt.setInsurer(convertReference(src.getInsurer()));
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasFundsReserve())
      tgt.setFundsReserve(convertCodeableConcept(src.getFundsReserve()));
    for (org.hl7.fhir.r4.model.Claim.RelatedClaimComponent t : src.getRelated())
      tgt.addRelated(convertRelatedClaimComponent(t));
    if (src.hasPrescription())
      tgt.setPrescription(convertReference(src.getPrescription()));
    if (src.hasOriginalPrescription())
      tgt.setOriginalPrescription(convertReference(src.getOriginalPrescription()));
    if (src.hasPayee())
      tgt.setPayee(convertPayeeComponent(src.getPayee()));
    if (src.hasReferral())
      tgt.setReferral(convertReference(src.getReferral()));
    if (src.hasFacility())
      tgt.setFacility(convertReference(src.getFacility()));
    for (org.hl7.fhir.r4.model.Claim.CareTeamComponent t : src.getCareTeam())
      tgt.addCareTeam(convertCareTeamComponent(t));
    for (org.hl7.fhir.r4.model.Claim.SpecialConditionComponent t : src.getInformation())
      tgt.addInformation(convertSpecialConditionComponent(t));
    for (org.hl7.fhir.r4.model.Claim.DiagnosisComponent t : src.getDiagnosis())
      tgt.addDiagnosis(convertDiagnosisComponent(t));
    for (org.hl7.fhir.r4.model.Claim.ProcedureComponent t : src.getProcedure())
      tgt.addProcedure(convertProcedureComponent(t));
    for (org.hl7.fhir.r4.model.Claim.InsuranceComponent t : src.getInsurance())
      tgt.addInsurance(convertInsuranceComponent(t));
    if (src.hasAccident())
      tgt.setAccident(convertAccidentComponent(src.getAccident()));
    if (src.hasEmploymentImpacted())
      tgt.setEmploymentImpacted(convertPeriod(src.getEmploymentImpacted()));
    if (src.hasHospitalization())
      tgt.setHospitalization(convertPeriod(src.getHospitalization()));
    for (org.hl7.fhir.r4.model.Claim.ItemComponent t : src.getItem())
      tgt.addItem(convertItemComponent(t));
    if (src.hasTotal())
      tgt.setTotal(convertMoney(src.getTotal()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Claim.ClaimStatus convertClaimStatus(org.hl7.fhir.dstu3.model.Claim.ClaimStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Claim.ClaimStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.r4.model.Claim.ClaimStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.r4.model.Claim.ClaimStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Claim.ClaimStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Claim.ClaimStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Claim.ClaimStatus convertClaimStatus(org.hl7.fhir.r4.model.Claim.ClaimStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Claim.ClaimStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Claim.ClaimStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.dstu3.model.Claim.ClaimStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Claim.ClaimStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Claim.ClaimStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent convertClassHistoryComponent(org.hl7.fhir.dstu3.model.Encounter.ClassHistoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent tgt = new org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent();
    copyElement(src, tgt);
    if (src.hasClass_())
      tgt.setClass_(convertCoding(src.getClass_()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Encounter.ClassHistoryComponent convertClassHistoryComponent(org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Encounter.ClassHistoryComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.ClassHistoryComponent();
    copyElement(src, tgt);
    if (src.hasClass_())
      tgt.setClass_(convertCoding(src.getClass_()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.dstu3.model.ClinicalImpression src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ClinicalImpression tgt = new org.hl7.fhir.r4.model.ClinicalImpression();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertClinicalImpressionStatus(src.getStatus()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasAssessor())
      tgt.setAssessor(convertReference(src.getAssessor()));
    if (src.hasPrevious())
      tgt.setPrevious(convertReference(src.getPrevious()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getProblem())
      tgt.addProblem(convertReference(t));
    for (org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionInvestigationComponent t : src.getInvestigation())
      tgt.addInvestigation(convertClinicalImpressionInvestigationComponent(t));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getProtocol())
      tgt.addProtocol(t.getValue());
    if (src.hasSummary())
      tgt.setSummary(src.getSummary());
    for (org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding())
      tgt.addFinding(convertClinicalImpressionFindingComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPrognosisCodeableConcept())
      tgt.addPrognosisCodeableConcept(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPrognosisReference())
      tgt.addPrognosisReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAction())
      tgt.addAction(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.r4.model.ClinicalImpression src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ClinicalImpression tgt = new org.hl7.fhir.dstu3.model.ClinicalImpression();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertClinicalImpressionStatus(src.getStatus()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasAssessor())
      tgt.setAssessor(convertReference(src.getAssessor()));
    if (src.hasPrevious())
      tgt.setPrevious(convertReference(src.getPrevious()));
    for (org.hl7.fhir.r4.model.Reference t : src.getProblem())
      tgt.addProblem(convertReference(t));
    for (org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationComponent t : src.getInvestigation())
      tgt.addInvestigation(convertClinicalImpressionInvestigationComponent(t));
    for (org.hl7.fhir.r4.model.UriType t : src.getProtocol())
      tgt.addProtocol(t.getValue());
    if (src.hasSummary())
      tgt.setSummary(src.getSummary());
    for (org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding())
      tgt.addFinding(convertClinicalImpressionFindingComponent(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPrognosisCodeableConcept())
      tgt.addPrognosisCodeableConcept(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPrognosisReference())
      tgt.addPrognosisReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getAction())
      tgt.addAction(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent();
    copyElement(src, tgt);
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    if (src.hasBasis())
      tgt.setBasis(src.getBasis());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent();
    copyElement(src, tgt);
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    if (src.hasBasis())
      tgt.setBasis(src.getBasis());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationComponent convertClinicalImpressionInvestigationComponent(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionInvestigationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationComponent tgt = new org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getItem())
      tgt.addItem(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionInvestigationComponent convertClinicalImpressionInvestigationComponent(org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionInvestigationComponent tgt = new org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionInvestigationComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    for (org.hl7.fhir.r4.model.Reference t : src.getItem())
      tgt.addItem(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionStatus convertClinicalImpressionStatus(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionStatus.DRAFT;
    case COMPLETED: return org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus convertClinicalImpressionStatus(org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.DRAFT;
    case COMPLETED: return org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException {
    org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CodeSystem convertCodeSystem(org.hl7.fhir.dstu3.model.CodeSystem src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CodeSystem tgt = new org.hl7.fhir.r4.model.CodeSystem();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasCaseSensitive())
      tgt.setCaseSensitive(src.getCaseSensitive());
    if (src.hasValueSet())
      tgt.setValueSet(src.getValueSet());
    if (src.hasHierarchyMeaning())
      tgt.setHierarchyMeaning(convertCodeSystemHierarchyMeaning(src.getHierarchyMeaning()));
    if (src.hasCompositional())
      tgt.setCompositional(src.getCompositional());
    if (src.hasVersionNeeded())
      tgt.setVersionNeeded(src.getVersionNeeded());
    if (src.hasContent())
      tgt.setContent(convertCodeSystemContentMode(src.getContent()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    for (org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemFilterComponent t : src.getFilter())
      tgt.addFilter(convertCodeSystemFilterComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeSystem.PropertyComponent t : src.getProperty())
      tgt.addProperty(convertPropertyComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent t : src.getConcept())
      tgt.addConcept(convertConceptDefinitionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeSystem convertCodeSystem(org.hl7.fhir.r4.model.CodeSystem src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CodeSystem tgt = new org.hl7.fhir.dstu3.model.CodeSystem();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasCaseSensitive())
      tgt.setCaseSensitive(src.getCaseSensitive());
    if (src.hasValueSet())
      tgt.setValueSet(src.getValueSet());
    if (src.hasHierarchyMeaning())
      tgt.setHierarchyMeaning(convertCodeSystemHierarchyMeaning(src.getHierarchyMeaning()));
    if (src.hasCompositional())
      tgt.setCompositional(src.getCompositional());
    if (src.hasVersionNeeded())
      tgt.setVersionNeeded(src.getVersionNeeded());
    if (src.hasContent())
      tgt.setContent(convertCodeSystemContentMode(src.getContent()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    for (org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent t : src.getFilter())
      tgt.addFilter(convertCodeSystemFilterComponent(t));
    for (org.hl7.fhir.r4.model.CodeSystem.PropertyComponent t : src.getProperty())
      tgt.addProperty(convertPropertyComponent(t));
    for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent t : src.getConcept())
      tgt.addConcept(convertConceptDefinitionComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode convertCodeSystemContentMode(org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTPRESENT: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.NOTPRESENT;
    case EXAMPLE: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.EXAMPLE;
    case FRAGMENT: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.FRAGMENT;
    case COMPLETE: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.COMPLETE;
    default: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode convertCodeSystemContentMode(org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTPRESENT: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode.NOTPRESENT;
    case EXAMPLE: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode.EXAMPLE;
    case FRAGMENT: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode.FRAGMENT;
    case COMPLETE: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode.COMPLETE;
    default: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent convertCodeSystemFilterComponent(org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemFilterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent tgt = new org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator> t : src.getOperator())
      tgt.addOperator(convertFilterOperator(t.getValue()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemFilterComponent convertCodeSystemFilterComponent(org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemFilterComponent tgt = new org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemFilterComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CodeSystem.FilterOperator> t : src.getOperator())
      tgt.addOperator(convertFilterOperator(t.getValue()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning convertCodeSystemHierarchyMeaning(org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GROUPEDBY: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning.GROUPEDBY;
    case ISA: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning.ISA;
    case PARTOF: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning.PARTOF;
    case CLASSIFIEDWITH: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning.CLASSIFIEDWITH;
    default: return org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning convertCodeSystemHierarchyMeaning(org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GROUPEDBY: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning.GROUPEDBY;
    case ISA: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning.ISA;
    case PARTOF: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning.PARTOF;
    case CLASSIFIEDWITH: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning.CLASSIFIEDWITH;
    default: return org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding())
      tgt.addCoding(convertCoding(t));
    if (src.hasText())
      tgt.setText(src.getText());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Coding t : src.getCoding())
      tgt.addCoding(convertCoding(t));
    if (src.hasText())
      tgt.setText(src.getText());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasUserSelected())
      tgt.setUserSelected(src.getUserSelected());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasUserSelected())
      tgt.setUserSelected(src.getUserSelected());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Communication convertCommunication(org.hl7.fhir.dstu3.model.Communication src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Communication tgt = new org.hl7.fhir.r4.model.Communication();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertCommunicationStatus(src.getStatus()));
    if (src.hasNotDone())
      tgt.setNotDone(src.getNotDone());
    if (src.hasNotDoneReason())
      tgt.setNotDoneReason(convertCodeableConcept(src.getNotDoneReason()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getMedium())
      tgt.addMedium(convertCodeableConcept(t));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getTopic())
      tgt.addTopic(convertReference(t));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasSent())
      tgt.setSent(src.getSent());
    if (src.hasReceived())
      tgt.setReceived(src.getReceived());
    if (src.hasSender())
      tgt.setSender(convertReference(src.getSender()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Communication.CommunicationPayloadComponent t : src.getPayload())
      tgt.addPayload(convertCommunicationPayloadComponent(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Communication convertCommunication(org.hl7.fhir.r4.model.Communication src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Communication tgt = new org.hl7.fhir.dstu3.model.Communication();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertCommunicationStatus(src.getStatus()));
    if (src.hasNotDone())
      tgt.setNotDone(src.getNotDone());
    if (src.hasNotDoneReason())
      tgt.setNotDoneReason(convertCodeableConcept(src.getNotDoneReason()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getMedium())
      tgt.addMedium(convertCodeableConcept(t));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.r4.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getTopic())
      tgt.addTopic(convertReference(t));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasSent())
      tgt.setSent(src.getSent());
    if (src.hasReceived())
      tgt.setReceived(src.getReceived());
    if (src.hasSender())
      tgt.setSender(convertReference(src.getSender()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent t : src.getPayload())
      tgt.addPayload(convertCommunicationPayloadComponent(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent convertCommunicationPayloadComponent(org.hl7.fhir.dstu3.model.Communication.CommunicationPayloadComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent tgt = new org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Communication.CommunicationPayloadComponent convertCommunicationPayloadComponent(org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Communication.CommunicationPayloadComponent tgt = new org.hl7.fhir.dstu3.model.Communication.CommunicationPayloadComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority convertCommunicationPriority(org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.URGENT;
    case ASAP: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.ASAP;
    case STAT: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.STAT;
    default: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationPriority convertCommunicationPriority(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationPriority.URGENT;
    case ASAP: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationPriority.ASAP;
    case STAT: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationPriority.STAT;
    default: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationPriority.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CommunicationRequest convertCommunicationRequest(org.hl7.fhir.dstu3.model.CommunicationRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CommunicationRequest tgt = new org.hl7.fhir.r4.model.CommunicationRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertCommunicationRequestStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasPriority())
      tgt.setPriority(convertCommunicationPriority(src.getPriority()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getMedium())
      tgt.addMedium(convertCodeableConcept(t));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getTopic())
      tgt.addTopic(convertReference(t));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestPayloadComponent t : src.getPayload())
      tgt.addPayload(convertCommunicationRequestPayloadComponent(t));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasSender())
      tgt.setSender(convertReference(src.getSender()));
    if (src.hasRequester())
      tgt.setRequester(convertCommunicationRequestRequesterComponent(src.getRequester()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CommunicationRequest convertCommunicationRequest(org.hl7.fhir.r4.model.CommunicationRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CommunicationRequest tgt = new org.hl7.fhir.dstu3.model.CommunicationRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertCommunicationRequestStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasPriority())
      tgt.setPriority(convertCommunicationPriority(src.getPriority()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getMedium())
      tgt.addMedium(convertCodeableConcept(t));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.r4.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getTopic())
      tgt.addTopic(convertReference(t));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent t : src.getPayload())
      tgt.addPayload(convertCommunicationRequestPayloadComponent(t));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasSender())
      tgt.setSender(convertReference(src.getSender()));
    if (src.hasRequester())
      tgt.setRequester(convertCommunicationRequestRequesterComponent(src.getRequester()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestPayloadComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestRequesterComponent convertCommunicationRequestRequesterComponent(org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestRequesterComponent tgt = new org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestRequesterComponent convertCommunicationRequestRequesterComponent(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestRequesterComponent tgt = new org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus convertCommunicationRequestStatus(org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus convertCommunicationRequestStatus(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.CommunicationRequest.CommunicationRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Communication.CommunicationStatus convertCommunicationStatus(org.hl7.fhir.dstu3.model.Communication.CommunicationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PREPARATION: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.PREPARATION;
    case INPROGRESS: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.INPROGRESS;
    case SUSPENDED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.SUSPENDED;
    case ABORTED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.ABORTED;
    case COMPLETED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Communication.CommunicationStatus convertCommunicationStatus(org.hl7.fhir.r4.model.Communication.CommunicationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PREPARATION: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.PREPARATION;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.INPROGRESS;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.SUSPENDED;
    case ABORTED: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.ABORTED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Communication.CommunicationStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode convertCompartmentCode(org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PATIENT: return org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode.PATIENT;
    case ENCOUNTER: return org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode.ENCOUNTER;
    case RELATEDPERSON: return org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode.RELATEDPERSON;
    case PRACTITIONER: return org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode.PRACTITIONER;
    case DEVICE: return org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode.DEVICE;
    default: return org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode convertCompartmentCode(org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PATIENT: return org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.PATIENT;
    case ENCOUNTER: return org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.ENCOUNTER;
    case RELATEDPERSON: return org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.RELATEDPERSON;
    case PRACTITIONER: return org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.PRACTITIONER;
    case DEVICE: return org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.DEVICE;
    default: return org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.dstu3.model.CompartmentDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CompartmentDefinition tgt = new org.hl7.fhir.r4.model.CompartmentDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCompartmentType(src.getCode()));
    if (src.hasSearch())
      tgt.setSearch(src.getSearch());
    for (org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource())
      tgt.addResource(convertCompartmentDefinitionResourceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.r4.model.CompartmentDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CompartmentDefinition tgt = new org.hl7.fhir.dstu3.model.CompartmentDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCompartmentType(src.getCode()));
    if (src.hasSearch())
      tgt.setSearch(src.getSearch());
    for (org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource())
      tgt.addResource(convertCompartmentDefinitionResourceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentDefinitionResourceComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getParam())
      tgt.addParam(t.getValue());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    for (org.hl7.fhir.r4.model.StringType t : src.getParam())
      tgt.addParam(t.getValue());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType convertCompartmentType(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PATIENT: return org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType.PATIENT;
    case ENCOUNTER: return org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType.ENCOUNTER;
    case RELATEDPERSON: return org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType.RELATEDPERSON;
    case PRACTITIONER: return org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType.PRACTITIONER;
    case DEVICE: return org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType.DEVICE;
    default: return org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType convertCompartmentType(org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PATIENT: return org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.PATIENT;
    case ENCOUNTER: return org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.ENCOUNTER;
    case RELATEDPERSON: return org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.RELATEDPERSON;
    case PRACTITIONER: return org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.PRACTITIONER;
    case DEVICE: return org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.DEVICE;
    default: return org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Composition convertComposition(org.hl7.fhir.dstu3.model.Composition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Composition tgt = new org.hl7.fhir.r4.model.Composition();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertCompositionStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasClass_())
      tgt.setClass_(convertCodeableConcept(src.getClass_()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAuthor())
      tgt.addAuthor(convertReference(t));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasConfidentiality())
      tgt.setConfidentiality(convertDocumentConfidentiality(src.getConfidentiality()));
    for (org.hl7.fhir.dstu3.model.Composition.CompositionAttesterComponent t : src.getAttester())
      tgt.addAttester(convertCompositionAttesterComponent(t));
    if (src.hasCustodian())
      tgt.setCustodian(convertReference(src.getCustodian()));
    for (org.hl7.fhir.dstu3.model.Composition.CompositionRelatesToComponent t : src.getRelatesTo())
      tgt.addRelatesTo(convertCompositionRelatesToComponent(t));
    for (org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent t : src.getEvent())
      tgt.addEvent(convertCompositionEventComponent(t));
    for (org.hl7.fhir.dstu3.model.Composition.SectionComponent t : src.getSection())
      tgt.addSection(convertSectionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Composition convertComposition(org.hl7.fhir.r4.model.Composition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Composition tgt = new org.hl7.fhir.dstu3.model.Composition();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertCompositionStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasClass_())
      tgt.setClass_(convertCodeableConcept(src.getClass_()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    for (org.hl7.fhir.r4.model.Reference t : src.getAuthor())
      tgt.addAuthor(convertReference(t));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasConfidentiality())
      tgt.setConfidentiality(convertDocumentConfidentiality(src.getConfidentiality()));
    for (org.hl7.fhir.r4.model.Composition.CompositionAttesterComponent t : src.getAttester())
      tgt.addAttester(convertCompositionAttesterComponent(t));
    if (src.hasCustodian())
      tgt.setCustodian(convertReference(src.getCustodian()));
    for (org.hl7.fhir.r4.model.Composition.CompositionRelatesToComponent t : src.getRelatesTo())
      tgt.addRelatesTo(convertCompositionRelatesToComponent(t));
    for (org.hl7.fhir.r4.model.Composition.CompositionEventComponent t : src.getEvent())
      tgt.addEvent(convertCompositionEventComponent(t));
    for (org.hl7.fhir.r4.model.Composition.SectionComponent t : src.getSection())
      tgt.addSection(convertSectionComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Composition.CompositionAttestationMode convertCompositionAttestationMode(org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PERSONAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.PERSONAL;
    case PROFESSIONAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.PROFESSIONAL;
    case LEGAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.LEGAL;
    case OFFICIAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.OFFICIAL;
    default: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode convertCompositionAttestationMode(org.hl7.fhir.r4.model.Composition.CompositionAttestationMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PERSONAL: return org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode.PERSONAL;
    case PROFESSIONAL: return org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode.PROFESSIONAL;
    case LEGAL: return org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode.LEGAL;
    case OFFICIAL: return org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode.OFFICIAL;
    default: return org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Composition.CompositionAttesterComponent convertCompositionAttesterComponent(org.hl7.fhir.dstu3.model.Composition.CompositionAttesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Composition.CompositionAttesterComponent tgt = new org.hl7.fhir.r4.model.Composition.CompositionAttesterComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode> t : src.getMode())
      tgt.addMode(convertCompositionAttestationMode(t.getValue()));
    if (src.hasTime())
      tgt.setTime(src.getTime());
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Composition.CompositionAttesterComponent convertCompositionAttesterComponent(org.hl7.fhir.r4.model.Composition.CompositionAttesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Composition.CompositionAttesterComponent tgt = new org.hl7.fhir.dstu3.model.Composition.CompositionAttesterComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Composition.CompositionAttestationMode> t : src.getMode())
      tgt.addMode(convertCompositionAttestationMode(t.getValue()));
    if (src.hasTime())
      tgt.setTime(src.getTime());
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Composition.CompositionEventComponent convertCompositionEventComponent(org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Composition.CompositionEventComponent tgt = new org.hl7.fhir.r4.model.Composition.CompositionEventComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCode())
      tgt.addCode(convertCodeableConcept(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDetail())
      tgt.addDetail(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent convertCompositionEventComponent(org.hl7.fhir.r4.model.Composition.CompositionEventComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent tgt = new org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCode())
      tgt.addCode(convertCodeableConcept(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.Reference t : src.getDetail())
      tgt.addDetail(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Composition.CompositionRelatesToComponent convertCompositionRelatesToComponent(org.hl7.fhir.dstu3.model.Composition.CompositionRelatesToComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Composition.CompositionRelatesToComponent tgt = new org.hl7.fhir.r4.model.Composition.CompositionRelatesToComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertDocumentRelationshipType(src.getCode()));
    if (src.hasTarget())
      tgt.setTarget(convertType(src.getTarget()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Composition.CompositionRelatesToComponent convertCompositionRelatesToComponent(org.hl7.fhir.r4.model.Composition.CompositionRelatesToComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Composition.CompositionRelatesToComponent tgt = new org.hl7.fhir.dstu3.model.Composition.CompositionRelatesToComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertDocumentRelationshipType(src.getCode()));
    if (src.hasTarget())
      tgt.setTarget(convertType(src.getTarget()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Composition.CompositionStatus convertCompositionStatus(org.hl7.fhir.dstu3.model.Composition.CompositionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRELIMINARY: return org.hl7.fhir.r4.model.Composition.CompositionStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.r4.model.Composition.CompositionStatus.FINAL;
    case AMENDED: return org.hl7.fhir.r4.model.Composition.CompositionStatus.AMENDED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Composition.CompositionStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Composition.CompositionStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Composition.CompositionStatus convertCompositionStatus(org.hl7.fhir.r4.model.Composition.CompositionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRELIMINARY: return org.hl7.fhir.dstu3.model.Composition.CompositionStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.dstu3.model.Composition.CompositionStatus.FINAL;
    case AMENDED: return org.hl7.fhir.dstu3.model.Composition.CompositionStatus.AMENDED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Composition.CompositionStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Composition.CompositionStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent convertComputableLanguageComponent(org.hl7.fhir.dstu3.model.Contract.ComputableLanguageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.ComputableLanguageComponent convertComputableLanguageComponent(org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.ComputableLanguageComponent tgt = new org.hl7.fhir.dstu3.model.Contract.ComputableLanguageComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent convertConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent tgt = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertConceptDefinitionDesignationComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptPropertyComponent t : src.getProperty())
      tgt.addProperty(convertConceptPropertyComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent t : src.getConcept())
      tgt.addConcept(convertConceptDefinitionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent convertConceptDefinitionComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertConceptDefinitionDesignationComponent(t));
    for (org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent t : src.getProperty())
      tgt.addProperty(convertConceptPropertyComponent(t));
    for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent t : src.getConcept())
      tgt.addConcept(convertConceptDefinitionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent convertConceptDefinitionDesignationComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent convertConceptDefinitionDesignationComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ConceptMap convertConceptMap(org.hl7.fhir.dstu3.model.ConceptMap src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ConceptMap tgt = new org.hl7.fhir.r4.model.ConceptMap();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasSource())
      tgt.setSource(convertType(src.getSource()));
    if (src.hasTarget())
      tgt.setTarget(convertType(src.getTarget()));
    for (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent t : src.getGroup())
      tgt.addGroup(convertConceptMapGroupComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ConceptMap convertConceptMap(org.hl7.fhir.r4.model.ConceptMap src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ConceptMap tgt = new org.hl7.fhir.dstu3.model.ConceptMap();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasSource())
      tgt.setSource(convertType(src.getSource()));
    if (src.hasTarget())
      tgt.setTarget(convertType(src.getTarget()));
    for (org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent t : src.getGroup())
      tgt.addGroup(convertConceptMapGroupComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence convertConceptMapEquivalence(org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RELATEDTO: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.RELATEDTO;
    case EQUIVALENT: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.EQUIVALENT;
    case EQUAL: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.EQUAL;
    case WIDER: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.WIDER;
    case SUBSUMES: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.SUBSUMES;
    case NARROWER: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.NARROWER;
    case SPECIALIZES: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.SPECIALIZES;
    case INEXACT: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.INEXACT;
    case UNMATCHED: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.UNMATCHED;
    case DISJOINT: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.DISJOINT;
    default: return org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence convertConceptMapEquivalence(org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RELATEDTO: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.RELATEDTO;
    case EQUIVALENT: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.EQUIVALENT;
    case EQUAL: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.EQUAL;
    case WIDER: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.WIDER;
    case SUBSUMES: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.SUBSUMES;
    case NARROWER: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.NARROWER;
    case SPECIALIZES: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.SPECIALIZES;
    case INEXACT: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.INEXACT;
    case UNMATCHED: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.UNMATCHED;
    case DISJOINT: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.DISJOINT;
    default: return org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent convertConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent();
    copyElement(src, tgt);
    if (src.hasSource())
      tgt.setSource(src.getSource());
    if (src.hasSourceVersion())
      tgt.setSourceVersion(src.getSourceVersion());
    if (src.hasTarget())
      tgt.setTarget(src.getTarget());
    if (src.hasTargetVersion())
      tgt.setTargetVersion(src.getTargetVersion());
    for (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent t : src.getElement())
      tgt.addElement(convertSourceElementComponent(t));
    if (src.hasUnmapped())
      tgt.setUnmapped(convertConceptMapGroupUnmappedComponent(src.getUnmapped()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent convertConceptMapGroupComponent(org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent();
    copyElement(src, tgt);
    if (src.hasSource())
      tgt.setSource(src.getSource());
    if (src.hasSourceVersion())
      tgt.setSourceVersion(src.getSourceVersion());
    if (src.hasTarget())
      tgt.setTarget(src.getTarget());
    if (src.hasTargetVersion())
      tgt.setTargetVersion(src.getTargetVersion());
    for (org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent t : src.getElement())
      tgt.addElement(convertSourceElementComponent(t));
    if (src.hasUnmapped())
      tgt.setUnmapped(convertConceptMapGroupUnmappedComponent(src.getUnmapped()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedComponent convertConceptMapGroupUnmappedComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertConceptMapGroupUnmappedMode(src.getMode()));
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent convertConceptMapGroupUnmappedComponent(org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent();
    copyElement(src, tgt);
    if (src.hasMode())
      tgt.setMode(convertConceptMapGroupUnmappedMode(src.getMode()));
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedMode convertConceptMapGroupUnmappedMode(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROVIDED: return org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedMode.PROVIDED;
    case FIXED: return org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedMode.FIXED;
    case OTHERMAP: return org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedMode.OTHERMAP;
    default: return org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode convertConceptMapGroupUnmappedMode(org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupUnmappedMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROVIDED: return org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.PROVIDED;
    case FIXED: return org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.FIXED;
    case OTHERMAP: return org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.OTHERMAP;
    default: return org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent convertConceptPropertyComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptPropertyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent tgt = new org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeSystem.ConceptPropertyComponent convertConceptPropertyComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CodeSystem.ConceptPropertyComponent tgt = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptPropertyComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    for (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    for (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent t : src.getConcept())
      tgt.addConcept(convertConceptReferenceComponent(t));
    for (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent t : src.getFilter())
      tgt.addFilter(convertConceptSetFilterComponent(t));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getValueSet())
      tgt.addValueSet(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent t : src.getConcept())
      tgt.addConcept(convertConceptReferenceComponent(t));
    for (org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent t : src.getFilter())
      tgt.addFilter(convertConceptSetFilterComponent(t));
    for (org.hl7.fhir.r4.model.UriType t : src.getValueSet())
      tgt.addValueSet(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent();
    copyElement(src, tgt);
    if (src.hasProperty())
      tgt.setProperty(src.getProperty());
    if (src.hasOp())
      tgt.setOp(convertFilterOperator(src.getOp()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent();
    copyElement(src, tgt);
    if (src.hasProperty())
      tgt.setProperty(src.getProperty());
    if (src.hasOp())
      tgt.setOp(convertFilterOperator(src.getOp()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Condition convertCondition(org.hl7.fhir.dstu3.model.Condition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Condition tgt = new org.hl7.fhir.r4.model.Condition();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasClinicalStatus())
      tgt.setClinicalStatus(convertConditionClinicalStatus(src.getClinicalStatus()));
    if (src.hasVerificationStatus())
      tgt.setVerificationStatus(convertConditionVerificationStatus(src.getVerificationStatus()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasSeverity())
      tgt.setSeverity(convertCodeableConcept(src.getSeverity()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOnset())
      tgt.setOnset(convertType(src.getOnset()));
    if (src.hasAbatement())
      tgt.setAbatement(convertType(src.getAbatement()));
    if (src.hasAssertedDate())
      tgt.setAssertedDate(src.getAssertedDate());
    if (src.hasAsserter())
      tgt.setAsserter(convertReference(src.getAsserter()));
    if (src.hasStage())
      tgt.addStage(convertConditionStageComponent(src.getStage()));
    for (org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent t : src.getEvidence())
      tgt.addEvidence(convertConditionEvidenceComponent(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Condition convertCondition(org.hl7.fhir.r4.model.Condition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Condition tgt = new org.hl7.fhir.dstu3.model.Condition();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasClinicalStatus())
      tgt.setClinicalStatus(convertConditionClinicalStatus(src.getClinicalStatus()));
    if (src.hasVerificationStatus())
      tgt.setVerificationStatus(convertConditionVerificationStatus(src.getVerificationStatus()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasSeverity())
      tgt.setSeverity(convertCodeableConcept(src.getSeverity()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOnset())
      tgt.setOnset(convertType(src.getOnset()));
    if (src.hasAbatement())
      tgt.setAbatement(convertType(src.getAbatement()));
    if (src.hasAssertedDate())
      tgt.setAssertedDate(src.getAssertedDate());
    if (src.hasAsserter())
      tgt.setAsserter(convertReference(src.getAsserter()));
    if (src.hasStage())
      tgt.setStage(convertConditionStageComponent(src.getStageFirstRep()));
    for (org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent t : src.getEvidence())
      tgt.addEvidence(convertConditionEvidenceComponent(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus convertConditionClinicalStatus(org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus.ACTIVE;
    case RECURRENCE: return org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus.RECURRENCE;
    case INACTIVE: return org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus.INACTIVE;
    case REMISSION: return org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus.REMISSION;
    case RESOLVED: return org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus.RESOLVED;
    default: return org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus convertConditionClinicalStatus(org.hl7.fhir.r4.model.Condition.ConditionClinicalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.ACTIVE;
    case RECURRENCE: return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RECURRENCE;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.INACTIVE;
    case REMISSION: return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.REMISSION;
    case RESOLVED: return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RESOLVED;
    default: return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCode())
      tgt.addCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDetail())
      tgt.addDetail(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCode())
      tgt.addCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDetail())
      tgt.addDetail(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionStageComponent();
    copyElement(src, tgt);
    if (src.hasSummary())
      tgt.setSummary(convertCodeableConcept(src.getSummary()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAssessment())
      tgt.addAssessment(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.r4.model.Condition.ConditionStageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent();
    copyElement(src, tgt);
    if (src.hasSummary())
      tgt.setSummary(convertCodeableConcept(src.getSummary()));
    for (org.hl7.fhir.r4.model.Reference t : src.getAssessment())
      tgt.addAssessment(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus convertConditionVerificationStatus(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROVISIONAL: return org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus.PROVISIONAL;
    case DIFFERENTIAL: return org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus.DIFFERENTIAL;
    case CONFIRMED: return org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus.CONFIRMED;
    case REFUTED: return org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus.REFUTED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus convertConditionVerificationStatus(org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROVISIONAL: return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.PROVISIONAL;
    case DIFFERENTIAL: return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.DIFFERENTIAL;
    case CONFIRMED: return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.CONFIRMED;
    case REFUTED: return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.REFUTED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus convertConditionalDeleteStatus(org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalDeleteStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTSUPPORTED: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NOTSUPPORTED;
    case SINGLE: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.SINGLE;
    case MULTIPLE: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.MULTIPLE;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalDeleteStatus convertConditionalDeleteStatus(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTSUPPORTED: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalDeleteStatus.NOTSUPPORTED;
    case SINGLE: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalDeleteStatus.SINGLE;
    case MULTIPLE: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalDeleteStatus.MULTIPLE;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalDeleteStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.CapabilityStatement.ConditionalReadStatus convertConditionalReadStatus(org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalReadStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTSUPPORTED: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalReadStatus.NOTSUPPORTED;
    case MODIFIEDSINCE: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalReadStatus.MODIFIEDSINCE;
    case NOTMATCH: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalReadStatus.NOTMATCH;
    case FULLSUPPORT: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalReadStatus.FULLSUPPORT;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalReadStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalReadStatus convertConditionalReadStatus(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalReadStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTSUPPORTED: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalReadStatus.NOTSUPPORTED;
    case MODIFIEDSINCE: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalReadStatus.MODIFIEDSINCE;
    case NOTMATCH: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalReadStatus.NOTMATCH;
    case FULLSUPPORT: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalReadStatus.FULLSUPPORT;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.ConditionalReadStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Consent convertConsent(org.hl7.fhir.dstu3.model.Consent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Consent tgt = new org.hl7.fhir.r4.model.Consent();
//    copyDomainResource(src, tgt);
//    if (src.hasIdentifier())
//      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
//    if (src.hasStatus())
//      tgt.setStatus(convertConsentState(src.getStatus()));
//    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
//      tgt.addCategory(convertCodeableConcept(t));
//    if (src.hasPatient())
//      tgt.setPatient(convertReference(src.getPatient()));
//    if (src.hasPeriod())
//      tgt.setPeriod(convertPeriod(src.getPeriod()));
//    if (src.hasDateTime())
//      tgt.setDateTime(src.getDateTime());
//    for (org.hl7.fhir.dstu3.model.Reference t : src.getConsentingParty())
//      tgt.addConsentingParty(convertReference(t));
//    for (org.hl7.fhir.dstu3.model.Consent.ConsentActorComponent t : src.getActor())
//      tgt.addActor(convertConsentActorComponent(t));
//    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAction())
//      tgt.addAction(convertCodeableConcept(t));
//    for (org.hl7.fhir.dstu3.model.Reference t : src.getOrganization())
//      tgt.addOrganization(convertReference(t));
//    if (src.hasSource())
//      tgt.setSource(convertType(src.getSource()));
//    for (org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent t : src.getPolicy())
//      tgt.addPolicy(convertConsentPolicyComponent(t));
//    if (src.hasPolicyRule())
//      tgt.setPolicyRule(src.getPolicyRule());
//    for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurityLabel())
//      tgt.addSecurityLabel(convertCoding(t));
//    for (org.hl7.fhir.dstu3.model.Coding t : src.getPurpose())
//      tgt.addPurpose(convertCoding(t));
//    if (src.hasDataPeriod())
//      tgt.setDataPeriod(convertPeriod(src.getDataPeriod()));
//    for (org.hl7.fhir.dstu3.model.Consent.ConsentDataComponent t : src.getData())
//      tgt.addData(convertConsentDataComponent(t));
//    for (org.hl7.fhir.dstu3.model.Consent.ExceptComponent t : src.getExcept())
//      tgt.addExcept(convertExceptComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Consent convertConsent(org.hl7.fhir.r4.model.Consent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Consent tgt = new org.hl7.fhir.dstu3.model.Consent();
//    copyDomainResource(src, tgt);
//    if (src.hasIdentifier())
//      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
//    if (src.hasStatus())
//      tgt.setStatus(convertConsentState(src.getStatus()));
//    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
//      tgt.addCategory(convertCodeableConcept(t));
//    if (src.hasPatient())
//      tgt.setPatient(convertReference(src.getPatient()));
//    if (src.hasPeriod())
//      tgt.setPeriod(convertPeriod(src.getPeriod()));
//    if (src.hasDateTime())
//      tgt.setDateTime(src.getDateTime());
//    for (org.hl7.fhir.r4.model.Reference t : src.getConsentingParty())
//      tgt.addConsentingParty(convertReference(t));
//    for (org.hl7.fhir.r4.model.Consent.ConsentActorComponent t : src.getActor())
//      tgt.addActor(convertConsentActorComponent(t));
//    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAction())
//      tgt.addAction(convertCodeableConcept(t));
//    for (org.hl7.fhir.r4.model.Reference t : src.getOrganization())
//      tgt.addOrganization(convertReference(t));
//    if (src.hasSource())
//      tgt.setSource(convertType(src.getSource()));
//    for (org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent t : src.getPolicy())
//      tgt.addPolicy(convertConsentPolicyComponent(t));
//    if (src.hasPolicyRule())
//      tgt.setPolicyRule(src.getPolicyRule());
//    for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel())
//      tgt.addSecurityLabel(convertCoding(t));
//    for (org.hl7.fhir.r4.model.Coding t : src.getPurpose())
//      tgt.addPurpose(convertCoding(t));
//    if (src.hasDataPeriod())
//      tgt.setDataPeriod(convertPeriod(src.getDataPeriod()));
//    for (org.hl7.fhir.r4.model.Consent.ConsentDataComponent t : src.getData())
//      tgt.addData(convertConsentDataComponent(t));
//    for (org.hl7.fhir.r4.model.Consent.ExceptComponent t : src.getExcept())
//      tgt.addExcept(convertExceptComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Consent.ConsentDataMeaning convertConsentDataMeaning(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INSTANCE: return org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.INSTANCE;
    case RELATED: return org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.RELATED;
    case DEPENDENTS: return org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.DEPENDENTS;
    case AUTHOREDBY: return org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.AUTHOREDBY;
    default: return org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning convertConsentDataMeaning(org.hl7.fhir.r4.model.Consent.ConsentDataMeaning src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INSTANCE: return org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.INSTANCE;
    case RELATED: return org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.RELATED;
    case DEPENDENTS: return org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.DEPENDENTS;
    case AUTHOREDBY: return org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.AUTHOREDBY;
    default: return org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent();
    copyElement(src, tgt);
    if (src.hasAuthority())
      tgt.setAuthority(src.getAuthority());
    if (src.hasUri())
      tgt.setUri(src.getUri());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent();
    copyElement(src, tgt);
    if (src.hasAuthority())
      tgt.setAuthority(src.getAuthority());
    if (src.hasUri())
      tgt.setUri(src.getUri());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Consent.ConsentState convertConsentState(org.hl7.fhir.dstu3.model.Consent.ConsentState src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.Consent.ConsentState.DRAFT;
    case PROPOSED: return org.hl7.fhir.r4.model.Consent.ConsentState.PROPOSED;
    case ACTIVE: return org.hl7.fhir.r4.model.Consent.ConsentState.ACTIVE;
    case REJECTED: return org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED;
    case INACTIVE: return org.hl7.fhir.r4.model.Consent.ConsentState.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Consent.ConsentState.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Consent.ConsentState.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Consent.ConsentState convertConsentState(org.hl7.fhir.r4.model.Consent.ConsentState src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.Consent.ConsentState.DRAFT;
    case PROPOSED: return org.hl7.fhir.dstu3.model.Consent.ConsentState.PROPOSED;
    case ACTIVE: return org.hl7.fhir.dstu3.model.Consent.ConsentState.ACTIVE;
    case REJECTED: return org.hl7.fhir.dstu3.model.Consent.ConsentState.REJECTED;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Consent.ConsentState.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Consent.ConsentState.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Consent.ConsentState.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity convertConstraintSeverity(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ERROR: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR;
    case WARNING: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING;
    default: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity convertConstraintSeverity(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ERROR: return org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR;
    case WARNING: return org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING;
    default: return org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Patient.ContactComponent tgt = new org.hl7.fhir.r4.model.Patient.ContactComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRelationship())
      tgt.addRelationship(convertCodeableConcept(t));
    if (src.hasName())
      tgt.setName(convertHumanName(src.getName()));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasAddress())
      tgt.setAddress(convertAddress(src.getAddress()));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.r4.model.Patient.ContactComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Patient.ContactComponent tgt = new org.hl7.fhir.dstu3.model.Patient.ContactComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRelationship())
      tgt.addRelationship(convertCodeableConcept(t));
    if (src.hasName())
      tgt.setName(convertHumanName(src.getName()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasAddress())
      tgt.setAddress(convertAddress(src.getAddress()));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ContactDetail convertContactDetail(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ContactDetail convertContactDetail(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(convertContactPointSystem(src.getSystem()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasUse())
      tgt.setUse(convertContactPointUse(src.getUse()));
    if (src.hasRank())
      tgt.setRank(src.getRank());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(convertContactPointSystem(src.getSystem()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasUse())
      tgt.setUse(convertContactPointUse(src.getUse()));
    if (src.hasRank())
      tgt.setRank(src.getRank());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem convertContactPointSystem(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PHONE: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE;
    case FAX: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX;
    case EMAIL: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL;
    case PAGER: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER;
    case URL: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL;
    case SMS: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS;
    case OTHER: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER;
    default: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem convertContactPointSystem(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PHONE: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE;
    case FAX: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX;
    case EMAIL: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL;
    case PAGER: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER;
    case URL: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.URL;
    case SMS: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.SMS;
    case OTHER: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER;
    default: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ContactPoint.ContactPointUse convertContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HOME: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME;
    case WORK: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK;
    case TEMP: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP;
    case OLD: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD;
    case MOBILE: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE;
    default: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse convertContactPointUse(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HOME: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME;
    case WORK: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK;
    case TEMP: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP;
    case OLD: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD;
    case MOBILE: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE;
    default: return org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL;
  }
}

  private static org.hl7.fhir.r4.model.TestScript.ContentType convertContentType(org.hl7.fhir.dstu3.model.TestScript.ContentType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case XML: return org.hl7.fhir.r4.model.TestScript.ContentType.XML;
    case JSON: return org.hl7.fhir.r4.model.TestScript.ContentType.JSON;
    case TTL: return org.hl7.fhir.r4.model.TestScript.ContentType.TTL;
    case NONE: return org.hl7.fhir.r4.model.TestScript.ContentType.NONE;
    default: return org.hl7.fhir.r4.model.TestScript.ContentType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestScript.ContentType convertContentType(org.hl7.fhir.r4.model.TestScript.ContentType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case XML: return org.hl7.fhir.dstu3.model.TestScript.ContentType.XML;
    case JSON: return org.hl7.fhir.dstu3.model.TestScript.ContentType.JSON;
    case TTL: return org.hl7.fhir.dstu3.model.TestScript.ContentType.TTL;
    case NONE: return org.hl7.fhir.dstu3.model.TestScript.ContentType.NONE;
    default: return org.hl7.fhir.dstu3.model.TestScript.ContentType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Contract convertContract(org.hl7.fhir.dstu3.model.Contract src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract tgt = new org.hl7.fhir.r4.model.Contract();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertContractStatus(src.getStatus()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    if (src.hasApplies())
      tgt.setApplies(convertPeriod(src.getApplies()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSubject())
      tgt.addSubject(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAuthority())
      tgt.addAuthority(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDomain())
      tgt.addDomain(convertReference(t));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSubType())
      tgt.addSubType(convertCodeableConcept(t));
    if (src.hasContentDerivative())
      tgt.setContentDerivative(convertCodeableConcept(src.getContentDerivative()));
    for (org.hl7.fhir.dstu3.model.Contract.SignatoryComponent t : src.getSigner())
      tgt.addSigner(convertSignatoryComponent(t));
    for (org.hl7.fhir.dstu3.model.Contract.TermComponent t : src.getTerm())
      tgt.addTerm(convertTermComponent(t));
    for (org.hl7.fhir.dstu3.model.Contract.FriendlyLanguageComponent t : src.getFriendly())
      tgt.addFriendly(convertFriendlyLanguageComponent(t));
    for (org.hl7.fhir.dstu3.model.Contract.LegalLanguageComponent t : src.getLegal())
      tgt.addLegal(convertLegalLanguageComponent(t));
    for (org.hl7.fhir.dstu3.model.Contract.ComputableLanguageComponent t : src.getRule())
      tgt.setRule(convertComputableLanguageComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract convertContract(org.hl7.fhir.r4.model.Contract src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract tgt = new org.hl7.fhir.dstu3.model.Contract();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertContractStatus(src.getStatus()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    if (src.hasApplies())
      tgt.setApplies(convertPeriod(src.getApplies()));
    for (org.hl7.fhir.r4.model.Reference t : src.getSubject())
      tgt.addSubject(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getAuthority())
      tgt.addAuthority(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDomain())
      tgt.addDomain(convertReference(t));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSubType())
      tgt.addSubType(convertCodeableConcept(t));
    if (src.hasContentDerivative())
      tgt.setContentDerivative(convertCodeableConcept(src.getContentDerivative()));
    for (org.hl7.fhir.r4.model.Contract.SignatoryComponent t : src.getSigner())
      tgt.addSigner(convertSignatoryComponent(t));
    for (org.hl7.fhir.r4.model.Contract.TermComponent t : src.getTerm())
      tgt.addTerm(convertTermComponent(t));
    for (org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent t : src.getFriendly())
      tgt.addFriendly(convertFriendlyLanguageComponent(t));
    for (org.hl7.fhir.r4.model.Contract.LegalLanguageComponent t : src.getLegal())
      tgt.addLegal(convertLegalLanguageComponent(t));
    if (src.hasRule())
      tgt.addRule(convertComputableLanguageComponent(src.getRule()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Contract.ContractStatus convertContractStatus(org.hl7.fhir.dstu3.model.Contract.ContractStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AMENDED: return org.hl7.fhir.r4.model.Contract.ContractStatus.AMENDED;
    case APPENDED: return org.hl7.fhir.r4.model.Contract.ContractStatus.APPENDED;
    case CANCELLED: return org.hl7.fhir.r4.model.Contract.ContractStatus.CANCELLED;
    case DISPUTED: return org.hl7.fhir.r4.model.Contract.ContractStatus.DISPUTED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Contract.ContractStatus.ENTEREDINERROR;
    case EXECUTABLE: return org.hl7.fhir.r4.model.Contract.ContractStatus.EXECUTABLE;
    case EXECUTED: return org.hl7.fhir.r4.model.Contract.ContractStatus.EXECUTED;
    case NEGOTIABLE: return org.hl7.fhir.r4.model.Contract.ContractStatus.NEGOTIABLE;
    case OFFERED: return org.hl7.fhir.r4.model.Contract.ContractStatus.OFFERED;
    case POLICY: return org.hl7.fhir.r4.model.Contract.ContractStatus.POLICY;
    case REJECTED: return org.hl7.fhir.r4.model.Contract.ContractStatus.REJECTED;
    case RENEWED: return org.hl7.fhir.r4.model.Contract.ContractStatus.RENEWED;
    case REVOKED: return org.hl7.fhir.r4.model.Contract.ContractStatus.REVOKED;
    case RESOLVED: return org.hl7.fhir.r4.model.Contract.ContractStatus.RESOLVED;
    case TERMINATED: return org.hl7.fhir.r4.model.Contract.ContractStatus.TERMINATED;
    default: return org.hl7.fhir.r4.model.Contract.ContractStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Contract.ContractStatus convertContractStatus(org.hl7.fhir.r4.model.Contract.ContractStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AMENDED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.AMENDED;
    case APPENDED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.APPENDED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.CANCELLED;
    case DISPUTED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.DISPUTED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.ENTEREDINERROR;
    case EXECUTABLE: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.EXECUTABLE;
    case EXECUTED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.EXECUTED;
    case NEGOTIABLE: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.NEGOTIABLE;
    case OFFERED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.OFFERED;
    case POLICY: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.POLICY;
    case REJECTED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.REJECTED;
    case RENEWED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.RENEWED;
    case REVOKED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.REVOKED;
    case RESOLVED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.RESOLVED;
    case TERMINATED: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.TERMINATED;
    default: return org.hl7.fhir.dstu3.model.Contract.ContractStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Contributor convertContributor(org.hl7.fhir.dstu3.model.Contributor src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contributor tgt = new org.hl7.fhir.r4.model.Contributor();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertContributorType(src.getType()));
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contributor convertContributor(org.hl7.fhir.r4.model.Contributor src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contributor tgt = new org.hl7.fhir.dstu3.model.Contributor();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertContributorType(src.getType()));
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Contributor.ContributorType convertContributorType(org.hl7.fhir.dstu3.model.Contributor.ContributorType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AUTHOR: return org.hl7.fhir.r4.model.Contributor.ContributorType.AUTHOR;
    case EDITOR: return org.hl7.fhir.r4.model.Contributor.ContributorType.EDITOR;
    case REVIEWER: return org.hl7.fhir.r4.model.Contributor.ContributorType.REVIEWER;
    case ENDORSER: return org.hl7.fhir.r4.model.Contributor.ContributorType.ENDORSER;
    default: return org.hl7.fhir.r4.model.Contributor.ContributorType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Contributor.ContributorType convertContributorType(org.hl7.fhir.r4.model.Contributor.ContributorType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AUTHOR: return org.hl7.fhir.dstu3.model.Contributor.ContributorType.AUTHOR;
    case EDITOR: return org.hl7.fhir.dstu3.model.Contributor.ContributorType.EDITOR;
    case REVIEWER: return org.hl7.fhir.dstu3.model.Contributor.ContributorType.REVIEWER;
    case ENDORSER: return org.hl7.fhir.dstu3.model.Contributor.ContributorType.ENDORSER;
    default: return org.hl7.fhir.dstu3.model.Contributor.ContributorType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Coverage convertCoverage(org.hl7.fhir.dstu3.model.Coverage src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Coverage tgt = new org.hl7.fhir.r4.model.Coverage();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertCoverageStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasPolicyHolder())
      tgt.setPolicyHolder(convertReference(src.getPolicyHolder()));
    if (src.hasSubscriber())
      tgt.setSubscriber(convertReference(src.getSubscriber()));
    if (src.hasSubscriberId())
      tgt.setSubscriberId(src.getSubscriberId());
    if (src.hasBeneficiary())
      tgt.setBeneficiary(convertReference(src.getBeneficiary()));
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPayor())
      tgt.addPayor(convertReference(t));
    if (src.hasGrouping())
      tgt.setGrouping(convertGroupComponent(src.getGrouping()));
    if (src.hasDependent())
      tgt.setDependent(src.getDependent());
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasOrder())
      tgt.setOrder(src.getOrder());
    if (src.hasNetwork())
      tgt.setNetwork(src.getNetwork());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getContract())
      tgt.addContract(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Coverage convertCoverage(org.hl7.fhir.r4.model.Coverage src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Coverage tgt = new org.hl7.fhir.dstu3.model.Coverage();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertCoverageStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasPolicyHolder())
      tgt.setPolicyHolder(convertReference(src.getPolicyHolder()));
    if (src.hasSubscriber())
      tgt.setSubscriber(convertReference(src.getSubscriber()));
    if (src.hasSubscriberId())
      tgt.setSubscriberId(src.getSubscriberId());
    if (src.hasBeneficiary())
      tgt.setBeneficiary(convertReference(src.getBeneficiary()));
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.Reference t : src.getPayor())
      tgt.addPayor(convertReference(t));
    if (src.hasGrouping())
      tgt.setGrouping(convertGroupComponent(src.getGrouping()));
    if (src.hasDependent())
      tgt.setDependent(src.getDependent());
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasOrder())
      tgt.setOrder(src.getOrder());
    if (src.hasNetwork())
      tgt.setNetwork(src.getNetwork());
    for (org.hl7.fhir.r4.model.Reference t : src.getContract())
      tgt.addContract(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Account.CoverageComponent convertCoverageComponent(org.hl7.fhir.dstu3.model.Account.CoverageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Account.CoverageComponent tgt = new org.hl7.fhir.r4.model.Account.CoverageComponent();
    copyElement(src, tgt);
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasPriority())
      tgt.setPriority(src.getPriority());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Account.CoverageComponent convertCoverageComponent(org.hl7.fhir.r4.model.Account.CoverageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Account.CoverageComponent tgt = new org.hl7.fhir.dstu3.model.Account.CoverageComponent();
    copyElement(src, tgt);
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasPriority())
      tgt.setPriority(src.getPriority());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Coverage.CoverageStatus convertCoverageStatus(org.hl7.fhir.dstu3.model.Coverage.CoverageStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Coverage.CoverageStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.r4.model.Coverage.CoverageStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.r4.model.Coverage.CoverageStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Coverage.CoverageStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Coverage.CoverageStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Coverage.CoverageStatus convertCoverageStatus(org.hl7.fhir.r4.model.Coverage.CoverageStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.StructureDefinition convertDataElement(org.hl7.fhir.dstu3.model.DataElement src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureDefinition tgt = new org.hl7.fhir.r4.model.StructureDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl().replace("/DataElement/", "/StructureDefinition/de-"));
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
//    if (src.hasStringency())
//      tgt.setStringency(convertDataElementStringency(src.getStringency()));
    for (org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent t : src.getMapping())
      tgt.addMapping(convertDataElementMappingComponent(t));
    for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement())
      tgt.getSnapshot().addElement(convertElementDefinition(t));
    tgt.setKind(StructureDefinitionKind.LOGICAL);
    tgt.setAbstract(false);
    tgt.setType(tgt.getName());
    tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
    tgt.setDerivation(TypeDerivationRule.SPECIALIZATION);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent convertDataElementMappingComponent(org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent();
    copyElement(src, tgt);
    if (src.hasIdentity())
      tgt.setIdentity(src.getIdentity());
    if (src.hasUri())
      tgt.setUri(src.getUri());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException {
    org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException {
    org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.DateTimeType tgt = new org.hl7.fhir.dstu3.model.DateTimeType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Timing.DayOfWeek convertDayOfWeek(org.hl7.fhir.dstu3.model.Timing.DayOfWeek src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MON: return org.hl7.fhir.r4.model.Timing.DayOfWeek.MON;
    case TUE: return org.hl7.fhir.r4.model.Timing.DayOfWeek.TUE;
    case WED: return org.hl7.fhir.r4.model.Timing.DayOfWeek.WED;
    case THU: return org.hl7.fhir.r4.model.Timing.DayOfWeek.THU;
    case FRI: return org.hl7.fhir.r4.model.Timing.DayOfWeek.FRI;
    case SAT: return org.hl7.fhir.r4.model.Timing.DayOfWeek.SAT;
    case SUN: return org.hl7.fhir.r4.model.Timing.DayOfWeek.SUN;
    default: return org.hl7.fhir.r4.model.Timing.DayOfWeek.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Timing.DayOfWeek convertDayOfWeek(org.hl7.fhir.r4.model.Timing.DayOfWeek src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MON: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.MON;
    case TUE: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.TUE;
    case WED: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.WED;
    case THU: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.THU;
    case FRI: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.FRI;
    case SAT: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SAT;
    case SUN: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SUN;
    default: return org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL;
  }
}

  private static org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MON: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.MON;
    case TUE: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.TUE;
    case WED: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.WED;
    case THU: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.THU;
    case FRI: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.FRI;
    case SAT: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SAT;
    case SUN: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SUN;
    default: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MON: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.MON;
    case TUE: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.TUE;
    case WED: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.WED;
    case THU: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.THU;
    case FRI: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.FRI;
    case SAT: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.SAT;
    case SUN: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.SUN;
    default: return org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.NULL;
  }
}

  private static org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MON: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.MON;
    case TUE: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.TUE;
    case WED: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.WED;
    case THU: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.THU;
    case FRI: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.FRI;
    case SAT: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.SAT;
    case SUN: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.SUN;
    default: return org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MON: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.MON;
    case TUE: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.TUE;
    case WED: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.WED;
    case THU: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.THU;
    case FRI: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.FRI;
    case SAT: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.SAT;
    case SUN: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.SUN;
    default: return org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.NULL;
  }
}

  public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException {
    org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeComponent convertDesignationExcludeComponent(org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeComponent tgt = new org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertDesignationExcludeDesignationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeComponent convertDesignationExcludeComponent(org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeComponent tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertDesignationExcludeDesignationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeDesignationComponent convertDesignationExcludeDesignationComponent(org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeDesignationComponent tgt = new org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeDesignationComponent convertDesignationExcludeDesignationComponent(org.hl7.fhir.r4.model.ExpansionProfile.DesignationExcludeDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeDesignationComponent tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationExcludeDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeComponent convertDesignationIncludeComponent(org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeComponent tgt = new org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertDesignationIncludeDesignationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeComponent convertDesignationIncludeComponent(org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeComponent tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertDesignationIncludeDesignationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeDesignationComponent convertDesignationIncludeDesignationComponent(org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeDesignationComponent tgt = new org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationComponent convertDesignationIncludeDesignationComponent(org.hl7.fhir.r4.model.ExpansionProfile.DesignationIncludeDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationComponent tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasUse())
      tgt.setUse(convertCoding(src.getUse()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Claim.DetailComponent convertDetailComponent(org.hl7.fhir.dstu3.model.Claim.DetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.DetailComponent tgt = new org.hl7.fhir.r4.model.Claim.DetailComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasRevenue())
      tgt.setRevenue(convertCodeableConcept(src.getRevenue()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasService())
      tgt.setService(convertCodeableConcept(src.getService()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getModifier())
      tgt.addModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getProgramCode())
      tgt.addProgramCode(convertCodeableConcept(t));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getUdi())
      tgt.addUdi(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Claim.SubDetailComponent t : src.getSubDetail())
      tgt.addSubDetail(convertSubDetailComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.DetailComponent convertDetailComponent(org.hl7.fhir.r4.model.Claim.DetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.DetailComponent tgt = new org.hl7.fhir.dstu3.model.Claim.DetailComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasRevenue())
      tgt.setRevenue(convertCodeableConcept(src.getRevenue()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasService())
      tgt.setService(convertCodeableConcept(src.getService()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getModifier())
      tgt.addModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProgramCode())
      tgt.addProgramCode(convertCodeableConcept(t));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    for (org.hl7.fhir.r4.model.Reference t : src.getUdi())
      tgt.addUdi(convertReference(t));
    for (org.hl7.fhir.r4.model.Claim.SubDetailComponent t : src.getSubDetail())
      tgt.addSubDetail(convertSubDetailComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DetectedIssue convertDetectedIssue(org.hl7.fhir.dstu3.model.DetectedIssue src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DetectedIssue tgt = new org.hl7.fhir.r4.model.DetectedIssue();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertDetectedIssueStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasSeverity())
      tgt.setSeverity(convertDetectedIssueSeverity(src.getSeverity()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getImplicated())
      tgt.addImplicated(convertReference(t));
    if (src.hasDetail())
      tgt.setDetail(src.getDetail());
    if (src.hasReference())
      tgt.setReference(src.getReference());
    for (org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent t : src.getMitigation())
      tgt.addMitigation(convertDetectedIssueMitigationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DetectedIssue convertDetectedIssue(org.hl7.fhir.r4.model.DetectedIssue src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DetectedIssue tgt = new org.hl7.fhir.dstu3.model.DetectedIssue();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertDetectedIssueStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasSeverity())
      tgt.setSeverity(convertDetectedIssueSeverity(src.getSeverity()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    for (org.hl7.fhir.r4.model.Reference t : src.getImplicated())
      tgt.addImplicated(convertReference(t));
    if (src.hasDetail())
      tgt.setDetail(src.getDetail());
    if (src.hasReference())
      tgt.setReference(src.getReference());
    for (org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueMitigationComponent t : src.getMitigation())
      tgt.addMitigation(convertDetectedIssueMitigationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueMitigationComponent convertDetectedIssueMitigationComponent(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueMitigationComponent tgt = new org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueMitigationComponent();
    copyElement(src, tgt);
    if (src.hasAction())
      tgt.setAction(convertCodeableConcept(src.getAction()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent convertDetectedIssueMitigationComponent(org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueMitigationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent tgt = new org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent();
    copyElement(src, tgt);
    if (src.hasAction())
      tgt.setAction(convertCodeableConcept(src.getAction()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity convertDetectedIssueSeverity(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HIGH: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.HIGH;
    case MODERATE: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.MODERATE;
    case LOW: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.LOW;
    default: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity convertDetectedIssueSeverity(org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HIGH: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.HIGH;
    case MODERATE: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.MODERATE;
    case LOW: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.LOW;
    default: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus convertDetectedIssueStatus(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.REGISTERED;
    case PRELIMINARY: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.FINAL;
    case AMENDED: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.CORRECTED;
    case CANCELLED: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus convertDetectedIssueStatus(org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.REGISTERED;
    case PRELIMINARY: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.FINAL;
    case AMENDED: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.CORRECTED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Device convertDevice(org.hl7.fhir.dstu3.model.Device src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Device tgt = new org.hl7.fhir.r4.model.Device();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasUdi())
      tgt.setUdi(convertDeviceUdiComponent(src.getUdi()));
    if (src.hasStatus())
      tgt.setStatus(convertFHIRDeviceStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasLotNumber())
      tgt.setLotNumber(src.getLotNumber());
    if (src.hasManufacturer())
      tgt.setManufacturer(src.getManufacturer());
    if (src.hasManufactureDate())
      tgt.setManufactureDate(src.getManufactureDate());
    if (src.hasExpirationDate())
      tgt.setExpirationDate(src.getExpirationDate());
    if (src.hasModel())
      tgt.setModel(src.getModel());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasOwner())
      tgt.setOwner(convertReference(src.getOwner()));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getContact())
      tgt.addContact(convertContactPoint(t));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSafety())
      tgt.addSafety(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Device convertDevice(org.hl7.fhir.r4.model.Device src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Device tgt = new org.hl7.fhir.dstu3.model.Device();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasUdi())
      tgt.setUdi(convertDeviceUdiComponent(src.getUdi()));
    if (src.hasStatus())
      tgt.setStatus(convertFHIRDeviceStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasLotNumber())
      tgt.setLotNumber(src.getLotNumber());
    if (src.hasManufacturer())
      tgt.setManufacturer(src.getManufacturer());
    if (src.hasManufactureDate())
      tgt.setManufactureDate(src.getManufactureDate());
    if (src.hasExpirationDate())
      tgt.setExpirationDate(src.getExpirationDate());
    if (src.hasModel())
      tgt.setModel(src.getModel());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasOwner())
      tgt.setOwner(convertReference(src.getOwner()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact())
      tgt.addContact(convertContactPoint(t));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSafety())
      tgt.addSafety(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DeviceComponent convertDeviceComponent(org.hl7.fhir.dstu3.model.DeviceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DeviceComponent tgt = new org.hl7.fhir.r4.model.DeviceComponent();
    copyDomainResource(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasLastSystemChange())
      tgt.setLastSystemChange(src.getLastSystemChange());
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasParent())
      tgt.setParent(convertReference(src.getParent()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getOperationalStatus())
      tgt.addOperationalStatus(convertCodeableConcept(t));
    if (src.hasParameterGroup())
      tgt.setParameterGroup(convertCodeableConcept(src.getParameterGroup()));
    if (src.hasMeasurementPrinciple())
      tgt.setMeasurementPrinciple(convertMeasmntPrinciple(src.getMeasurementPrinciple()));
    for (org.hl7.fhir.dstu3.model.DeviceComponent.DeviceComponentProductionSpecificationComponent t : src.getProductionSpecification())
      tgt.addProductionSpecification(convertDeviceComponentProductionSpecificationComponent(t));
    if (src.hasLanguageCode())
      tgt.setLanguageCode(convertCodeableConcept(src.getLanguageCode()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DeviceComponent convertDeviceComponent(org.hl7.fhir.r4.model.DeviceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DeviceComponent tgt = new org.hl7.fhir.dstu3.model.DeviceComponent();
    copyDomainResource(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasLastSystemChange())
      tgt.setLastSystemChange(src.getLastSystemChange());
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasParent())
      tgt.setParent(convertReference(src.getParent()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getOperationalStatus())
      tgt.addOperationalStatus(convertCodeableConcept(t));
    if (src.hasParameterGroup())
      tgt.setParameterGroup(convertCodeableConcept(src.getParameterGroup()));
    if (src.hasMeasurementPrinciple())
      tgt.setMeasurementPrinciple(convertMeasmntPrinciple(src.getMeasurementPrinciple()));
    for (org.hl7.fhir.r4.model.DeviceComponent.DeviceComponentProductionSpecificationComponent t : src.getProductionSpecification())
      tgt.addProductionSpecification(convertDeviceComponentProductionSpecificationComponent(t));
    if (src.hasLanguageCode())
      tgt.setLanguageCode(convertCodeableConcept(src.getLanguageCode()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DeviceComponent.DeviceComponentProductionSpecificationComponent convertDeviceComponentProductionSpecificationComponent(org.hl7.fhir.dstu3.model.DeviceComponent.DeviceComponentProductionSpecificationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DeviceComponent.DeviceComponentProductionSpecificationComponent tgt = new org.hl7.fhir.r4.model.DeviceComponent.DeviceComponentProductionSpecificationComponent();
    copyElement(src, tgt);
    if (src.hasSpecType())
      tgt.setSpecType(convertCodeableConcept(src.getSpecType()));
    if (src.hasComponentId())
      tgt.setComponentId(convertIdentifier(src.getComponentId()));
    if (src.hasProductionSpec())
      tgt.setProductionSpec(src.getProductionSpec());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DeviceComponent.DeviceComponentProductionSpecificationComponent convertDeviceComponentProductionSpecificationComponent(org.hl7.fhir.r4.model.DeviceComponent.DeviceComponentProductionSpecificationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DeviceComponent.DeviceComponentProductionSpecificationComponent tgt = new org.hl7.fhir.dstu3.model.DeviceComponent.DeviceComponentProductionSpecificationComponent();
    copyElement(src, tgt);
    if (src.hasSpecType())
      tgt.setSpecType(convertCodeableConcept(src.getSpecType()));
    if (src.hasComponentId())
      tgt.setComponentId(convertIdentifier(src.getComponentId()));
    if (src.hasProductionSpec())
      tgt.setProductionSpec(src.getProductionSpec());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DeviceMetric convertDeviceMetric(org.hl7.fhir.dstu3.model.DeviceMetric src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DeviceMetric tgt = new org.hl7.fhir.r4.model.DeviceMetric();
    copyDomainResource(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasUnit())
      tgt.setUnit(convertCodeableConcept(src.getUnit()));
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasParent())
      tgt.setParent(convertReference(src.getParent()));
    if (src.hasOperationalStatus())
      tgt.setOperationalStatus(convertDeviceMetricOperationalStatus(src.getOperationalStatus()));
    if (src.hasColor())
      tgt.setColor(convertDeviceMetricColor(src.getColor()));
    if (src.hasCategory())
      tgt.setCategory(convertDeviceMetricCategory(src.getCategory()));
    if (src.hasMeasurementPeriod())
      tgt.setMeasurementPeriod(convertTiming(src.getMeasurementPeriod()));
    for (org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationComponent t : src.getCalibration())
      tgt.addCalibration(convertDeviceMetricCalibrationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DeviceMetric convertDeviceMetric(org.hl7.fhir.r4.model.DeviceMetric src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DeviceMetric tgt = new org.hl7.fhir.dstu3.model.DeviceMetric();
    copyDomainResource(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasUnit())
      tgt.setUnit(convertCodeableConcept(src.getUnit()));
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasParent())
      tgt.setParent(convertReference(src.getParent()));
    if (src.hasOperationalStatus())
      tgt.setOperationalStatus(convertDeviceMetricOperationalStatus(src.getOperationalStatus()));
    if (src.hasColor())
      tgt.setColor(convertDeviceMetricColor(src.getColor()));
    if (src.hasCategory())
      tgt.setCategory(convertDeviceMetricCategory(src.getCategory()));
    if (src.hasMeasurementPeriod())
      tgt.setMeasurementPeriod(convertTiming(src.getMeasurementPeriod()));
    for (org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent t : src.getCalibration())
      tgt.addCalibration(convertDeviceMetricCalibrationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent convertDeviceMetricCalibrationComponent(org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent tgt = new org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertDeviceMetricCalibrationType(src.getType()));
    if (src.hasState())
      tgt.setState(convertDeviceMetricCalibrationState(src.getState()));
    if (src.hasTime())
      tgt.setTime(src.getTime());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationComponent convertDeviceMetricCalibrationComponent(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationComponent tgt = new org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertDeviceMetricCalibrationType(src.getType()));
    if (src.hasState())
      tgt.setState(convertDeviceMetricCalibrationState(src.getState()));
    if (src.hasTime())
      tgt.setTime(src.getTime());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState convertDeviceMetricCalibrationState(org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationState src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTCALIBRATED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.NOTCALIBRATED;
    case CALIBRATIONREQUIRED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATIONREQUIRED;
    case CALIBRATED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATED;
    case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.UNSPECIFIED;
    default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationState convertDeviceMetricCalibrationState(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOTCALIBRATED: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationState.NOTCALIBRATED;
    case CALIBRATIONREQUIRED: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATIONREQUIRED;
    case CALIBRATED: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATED;
    case UNSPECIFIED: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationState.UNSPECIFIED;
    default: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationState.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType convertDeviceMetricCalibrationType(org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.UNSPECIFIED;
    case OFFSET: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.OFFSET;
    case GAIN: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.GAIN;
    case TWOPOINT: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.TWOPOINT;
    default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationType convertDeviceMetricCalibrationType(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case UNSPECIFIED: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationType.UNSPECIFIED;
    case OFFSET: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationType.OFFSET;
    case GAIN: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationType.GAIN;
    case TWOPOINT: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationType.TWOPOINT;
    default: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCalibrationType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory convertDeviceMetricCategory(org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MEASUREMENT: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.MEASUREMENT;
    case SETTING: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.SETTING;
    case CALCULATION: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.CALCULATION;
    case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.UNSPECIFIED;
    default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCategory convertDeviceMetricCategory(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MEASUREMENT: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCategory.MEASUREMENT;
    case SETTING: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCategory.SETTING;
    case CALCULATION: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCategory.CALCULATION;
    case UNSPECIFIED: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCategory.UNSPECIFIED;
    default: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricCategory.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor convertDeviceMetricColor(org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case BLACK: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.BLACK;
    case RED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.RED;
    case GREEN: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.GREEN;
    case YELLOW: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.YELLOW;
    case BLUE: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.BLUE;
    case MAGENTA: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.MAGENTA;
    case CYAN: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.CYAN;
    case WHITE: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.WHITE;
    default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor convertDeviceMetricColor(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricColor src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case BLACK: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.BLACK;
    case RED: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.RED;
    case GREEN: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.GREEN;
    case YELLOW: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.YELLOW;
    case BLUE: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.BLUE;
    case MAGENTA: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.MAGENTA;
    case CYAN: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.CYAN;
    case WHITE: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.WHITE;
    default: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricColor.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus convertDeviceMetricOperationalStatus(org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricOperationalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ON: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.ON;
    case OFF: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.OFF;
    case STANDBY: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.STANDBY;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricOperationalStatus convertDeviceMetricOperationalStatus(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ON: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricOperationalStatus.ON;
    case OFF: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricOperationalStatus.OFF;
    case STANDBY: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricOperationalStatus.STANDBY;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricOperationalStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.DeviceMetric.DeviceMetricOperationalStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.DeviceRequest convertDeviceRequest(org.hl7.fhir.dstu3.model.DeviceRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DeviceRequest tgt = new org.hl7.fhir.r4.model.DeviceRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPriorRequest())
      tgt.addPriorRequest(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertDeviceRequestStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertCodeableConcept(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertRequestPriority(src.getPriority()));
    if (src.hasCode())
      tgt.setCode(convertType(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertDeviceRequestRequesterComponent(src.getRequester()));
    if (src.hasPerformerType())
      tgt.setPerformerType(convertCodeableConcept(src.getPerformerType()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInfo())
      tgt.addSupportingInfo(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRelevantHistory())
      tgt.addRelevantHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DeviceRequest convertDeviceRequest(org.hl7.fhir.r4.model.DeviceRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DeviceRequest tgt = new org.hl7.fhir.dstu3.model.DeviceRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPriorRequest())
      tgt.addPriorRequest(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertDeviceRequestStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertCodeableConcept(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertRequestPriority(src.getPriority()));
    if (src.hasCode())
      tgt.setCode(convertType(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertDeviceRequestRequesterComponent(src.getRequester()));
    if (src.hasPerformerType())
      tgt.setPerformerType(convertCodeableConcept(src.getPerformerType()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInfo())
      tgt.addSupportingInfo(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getRelevantHistory())
      tgt.addRelevantHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestRequesterComponent convertDeviceRequestRequesterComponent(org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestRequesterComponent tgt = new org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestRequesterComponent convertDeviceRequestRequesterComponent(org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestRequesterComponent tgt = new org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus convertDeviceRequestStatus(org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus convertDeviceRequestStatus(org.hl7.fhir.r4.model.DeviceRequest.DeviceRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.DeviceRequest.DeviceRequestStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Device.DeviceUdiComponent convertDeviceUdiComponent(org.hl7.fhir.dstu3.model.Device.DeviceUdiComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Device.DeviceUdiComponent tgt = new org.hl7.fhir.r4.model.Device.DeviceUdiComponent();
    copyElement(src, tgt);
    if (src.hasDeviceIdentifier())
      tgt.setDeviceIdentifier(src.getDeviceIdentifier());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasJurisdiction())
      tgt.setJurisdiction(src.getJurisdiction());
    if (src.hasCarrierHRF())
      tgt.setCarrierHRF(src.getCarrierHRF());
    if (src.hasCarrierAIDC())
      tgt.setCarrierAIDC(src.getCarrierAIDC());
    if (src.hasIssuer())
      tgt.setIssuer(src.getIssuer());
    if (src.hasEntryType())
      tgt.setEntryType(convertUDIEntryType(src.getEntryType()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Device.DeviceUdiComponent convertDeviceUdiComponent(org.hl7.fhir.r4.model.Device.DeviceUdiComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Device.DeviceUdiComponent tgt = new org.hl7.fhir.dstu3.model.Device.DeviceUdiComponent();
    copyElement(src, tgt);
    if (src.hasDeviceIdentifier())
      tgt.setDeviceIdentifier(src.getDeviceIdentifier());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasJurisdiction())
      tgt.setJurisdiction(src.getJurisdiction());
    if (src.hasCarrierHRF())
      tgt.setCarrierHRF(src.getCarrierHRF());
    if (src.hasCarrierAIDC())
      tgt.setCarrierAIDC(src.getCarrierAIDC());
    if (src.hasIssuer())
      tgt.setIssuer(src.getIssuer());
    if (src.hasEntryType())
      tgt.setEntryType(convertUDIEntryType(src.getEntryType()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DeviceUseStatement convertDeviceUseStatement(org.hl7.fhir.dstu3.model.DeviceUseStatement src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DeviceUseStatement tgt = new org.hl7.fhir.r4.model.DeviceUseStatement();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertDeviceUseStatementStatus(src.getStatus()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasWhenUsed())
      tgt.setWhenUsed(convertPeriod(src.getWhenUsed()));
    if (src.hasTiming())
      tgt.setTiming(convertType(src.getTiming()));
    if (src.hasRecordedOn())
      tgt.setRecordedOn(src.getRecordedOn());
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getIndication())
      tgt.addIndication(convertCodeableConcept(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DeviceUseStatement convertDeviceUseStatement(org.hl7.fhir.r4.model.DeviceUseStatement src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DeviceUseStatement tgt = new org.hl7.fhir.dstu3.model.DeviceUseStatement();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertDeviceUseStatementStatus(src.getStatus()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasWhenUsed())
      tgt.setWhenUsed(convertPeriod(src.getWhenUsed()));
    if (src.hasTiming())
      tgt.setTiming(convertType(src.getTiming()));
    if (src.hasRecordedOn())
      tgt.setRecordedOn(src.getRecordedOn());
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getIndication())
      tgt.addIndication(convertCodeableConcept(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus convertDeviceUseStatementStatus(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.ACTIVE;
    case COMPLETED: return org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.ENTEREDINERROR;
    case INTENDED: return org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.INTENDED;
    case STOPPED: return org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.STOPPED;
    case ONHOLD: return org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.ONHOLD;
    default: return org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus convertDeviceUseStatementStatus(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ACTIVE;
    case COMPLETED: return org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ENTEREDINERROR;
    case INTENDED: return org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.INTENDED;
    case STOPPED: return org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.STOPPED;
    case ONHOLD: return org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ONHOLD;
    default: return org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Claim.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.Claim.DiagnosisComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasDiagnosis())
      tgt.setDiagnosis(convertType(src.getDiagnosis()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasPackageCode())
      tgt.setPackageCode(convertCodeableConcept(src.getPackageCode()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.Claim.DiagnosisComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasDiagnosis())
      tgt.setDiagnosis(convertType(src.getDiagnosis()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasPackageCode())
      tgt.setPackageCode(convertCodeableConcept(src.getPackageCode()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.Encounter.DiagnosisComponent();
    copyElement(src, tgt);
    if (src.hasCondition())
      tgt.setCondition(convertReference(src.getCondition()));
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasRank())
      tgt.setRank(src.getRank());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.Encounter.DiagnosisComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent();
    copyElement(src, tgt);
    if (src.hasCondition())
      tgt.setCondition(convertReference(src.getCondition()));
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasRank())
      tgt.setRank(src.getRank());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent();
    copyElement(src, tgt);
    if (src.hasCondition())
      tgt.setCondition(convertReference(src.getCondition()));
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasRank())
      tgt.setRank(src.getRank());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent();
    copyElement(src, tgt);
    if (src.hasCondition())
      tgt.setCondition(convertReference(src.getCondition()));
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasRank())
      tgt.setRank(src.getRank());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DiagnosticReport convertDiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DiagnosticReport tgt = new org.hl7.fhir.r4.model.DiagnosticReport();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertDiagnosticReportStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
//    for (org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportPerformerComponent t : src.getPerformer())
//      tgt.addPerformer(convertDiagnosticReportPerformerComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSpecimen())
      tgt.addSpecimen(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getResult())
      tgt.addResult(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getImagingStudy())
      tgt.addImagingStudy(convertReference(t));
    for (org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent t : src.getImage())
      tgt.addImage(convertDiagnosticReportImageComponent(t));
    if (src.hasConclusion())
      tgt.setConclusion(src.getConclusion());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCodedDiagnosis())
      tgt.addCodedDiagnosis(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Attachment t : src.getPresentedForm())
      tgt.addPresentedForm(convertAttachment(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DiagnosticReport convertDiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DiagnosticReport tgt = new org.hl7.fhir.dstu3.model.DiagnosticReport();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertDiagnosticReportStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
//    for (org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportPerformerComponent t : src.getPerformer())
//      tgt.addPerformer(convertDiagnosticReportPerformerComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getSpecimen())
      tgt.addSpecimen(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getResult())
      tgt.addResult(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getImagingStudy())
      tgt.addImagingStudy(convertReference(t));
    for (org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent t : src.getImage())
      tgt.addImage(convertDiagnosticReportImageComponent(t));
    if (src.hasConclusion())
      tgt.setConclusion(src.getConclusion());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCodedDiagnosis())
      tgt.addCodedDiagnosis(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Attachment t : src.getPresentedForm())
      tgt.addPresentedForm(convertAttachment(t));
    return tgt;
  }

//  public static org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportPerformerComponent convertDiagnosticReportPerformerComponent(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportPerformerComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportPerformerComponent tgt = new org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportPerformerComponent();
//    copyElement(src, tgt);
//    if (src.hasRole())
//      tgt.setRole(convertCodeableConcept(src.getRole()));
//    if (src.hasActor())
//      tgt.setActor(convertReference(src.getActor()));
//    return tgt;
//  }
//
//  public static org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportPerformerComponent convertDiagnosticReportPerformerComponent(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportPerformerComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportPerformerComponent tgt = new org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportPerformerComponent();
//    copyElement(src, tgt);
//    if (src.hasRole())
//      tgt.setRole(convertCodeableConcept(src.getRole()));
//    if (src.hasActor())
//      tgt.setActor(convertReference(src.getActor()));
//    return tgt;
//  }
//
  public static org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent convertDiagnosticReportImageComponent(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent tgt = new org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent();
    copyElement(src, tgt);
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasLink())
      tgt.setLink(convertReference(src.getLink()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent convertDiagnosticReportImageComponent(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent tgt = new org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent();
    copyElement(src, tgt);
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasLink())
      tgt.setLink(convertReference(src.getLink()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus convertDiagnosticReportStatus(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.REGISTERED;
    case PARTIAL: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.PARTIAL;
    case PRELIMINARY: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.FINAL;
    case AMENDED: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.CORRECTED;
    case APPENDED: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.APPENDED;
    case CANCELLED: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus convertDiagnosticReportStatus(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.REGISTERED;
    case PARTIAL: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.PARTIAL;
    case PRELIMINARY: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.FINAL;
    case AMENDED: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.CORRECTED;
    case APPENDED: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.APPENDED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Media.DigitalMediaType convertDigitalMediaType(org.hl7.fhir.dstu3.model.Media.DigitalMediaType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PHOTO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.PHOTO;
    case VIDEO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.VIDEO;
    case AUDIO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.AUDIO;
    default: return org.hl7.fhir.r4.model.Media.DigitalMediaType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Media.DigitalMediaType convertDigitalMediaType(org.hl7.fhir.r4.model.Media.DigitalMediaType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PHOTO: return org.hl7.fhir.dstu3.model.Media.DigitalMediaType.PHOTO;
    case VIDEO: return org.hl7.fhir.dstu3.model.Media.DigitalMediaType.VIDEO;
    case AUDIO: return org.hl7.fhir.dstu3.model.Media.DigitalMediaType.AUDIO;
    default: return org.hl7.fhir.dstu3.model.Media.DigitalMediaType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType convertDiscriminatorType(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case VALUE: return org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.VALUE;
    case EXISTS: return org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.EXISTS;
    case PATTERN: return org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PATTERN;
    case TYPE: return org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.TYPE;
    case PROFILE: return org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PROFILE;
    default: return org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType convertDiscriminatorType(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case VALUE: return org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.VALUE;
    case EXISTS: return org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.EXISTS;
    case PATTERN: return org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PATTERN;
    case TYPE: return org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.TYPE;
    case PROFILE: return org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PROFILE;
    default: return org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance();
    copyQuantity(src, tgt);
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Composition.DocumentConfidentiality convertDocumentConfidentiality(org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case U: return org.hl7.fhir.r4.model.Composition.DocumentConfidentiality.U;
    case L: return org.hl7.fhir.r4.model.Composition.DocumentConfidentiality.L;
    case M: return org.hl7.fhir.r4.model.Composition.DocumentConfidentiality.M;
    case N: return org.hl7.fhir.r4.model.Composition.DocumentConfidentiality.N;
    case R: return org.hl7.fhir.r4.model.Composition.DocumentConfidentiality.R;
    case V: return org.hl7.fhir.r4.model.Composition.DocumentConfidentiality.V;
    default: return org.hl7.fhir.r4.model.Composition.DocumentConfidentiality.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality convertDocumentConfidentiality(org.hl7.fhir.r4.model.Composition.DocumentConfidentiality src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case U: return org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality.U;
    case L: return org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality.L;
    case M: return org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality.M;
    case N: return org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality.N;
    case R: return org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality.R;
    case V: return org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality.V;
    default: return org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality.NULL;
  }
}

  public static org.hl7.fhir.r4.model.DocumentManifest convertDocumentManifest(org.hl7.fhir.dstu3.model.DocumentManifest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DocumentManifest tgt = new org.hl7.fhir.r4.model.DocumentManifest();
    copyDomainResource(src, tgt);
    if (src.hasMasterIdentifier())
      tgt.setMasterIdentifier(convertIdentifier(src.getMasterIdentifier()));
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertDocumentReferenceStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    if (src.hasSource())
      tgt.setSource(src.getSource());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent t : src.getRelated())
      tgt.addRelated(convertDocumentManifestRelatedComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DocumentManifest convertDocumentManifest(org.hl7.fhir.r4.model.DocumentManifest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DocumentManifest tgt = new org.hl7.fhir.dstu3.model.DocumentManifest();
    copyDomainResource(src, tgt);
    if (src.hasMasterIdentifier())
      tgt.setMasterIdentifier(convertIdentifier(src.getMasterIdentifier()));
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertDocumentReferenceStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    for (org.hl7.fhir.r4.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    if (src.hasSource())
      tgt.setSource(src.getSource());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent t : src.getRelated())
      tgt.addRelated(convertDocumentManifestRelatedComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasRef())
      tgt.setRef(convertReference(src.getRef()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasRef())
      tgt.setRef(convertReference(src.getRef()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode convertDocumentMode(org.hl7.fhir.dstu3.model.CapabilityStatement.DocumentMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRODUCER: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.PRODUCER;
    case CONSUMER: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.CONSUMER;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.DocumentMode convertDocumentMode(org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRODUCER: return org.hl7.fhir.dstu3.model.CapabilityStatement.DocumentMode.PRODUCER;
    case CONSUMER: return org.hl7.fhir.dstu3.model.CapabilityStatement.DocumentMode.CONSUMER;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.DocumentMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.DocumentReference convertDocumentReference(org.hl7.fhir.dstu3.model.DocumentReference src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DocumentReference tgt = new org.hl7.fhir.r4.model.DocumentReference();
    copyDomainResource(src, tgt);
    if (src.hasMasterIdentifier())
      tgt.setMasterIdentifier(convertIdentifier(src.getMasterIdentifier()));
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertDocumentReferenceStatus(src.getStatus()));
    if (src.hasDocStatus())
      tgt.setDocStatus(convertReferredDocumentStatus(src.getDocStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasClass_())
      tgt.setClass_(convertCodeableConcept(src.getClass_()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasAuthenticator())
      tgt.setAuthenticator(convertReference(src.getAuthenticator()));
    if (src.hasCustodian())
      tgt.setCustodian(convertReference(src.getCustodian()));
    for (org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceRelatesToComponent t : src.getRelatesTo())
      tgt.addRelatesTo(convertDocumentReferenceRelatesToComponent(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSecurityLabel())
      tgt.addSecurityLabel(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContentComponent t : src.getContent())
      tgt.addContent(convertDocumentReferenceContentComponent(t));
    if (src.hasContext())
      tgt.setContext(convertDocumentReferenceContextComponent(src.getContext()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DocumentReference convertDocumentReference(org.hl7.fhir.r4.model.DocumentReference src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DocumentReference tgt = new org.hl7.fhir.dstu3.model.DocumentReference();
    copyDomainResource(src, tgt);
    if (src.hasMasterIdentifier())
      tgt.setMasterIdentifier(convertIdentifier(src.getMasterIdentifier()));
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertDocumentReferenceStatus(src.getStatus()));
    if (src.hasDocStatus())
      tgt.setDocStatus(convertReferredDocumentStatus(src.getDocStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasClass_())
      tgt.setClass_(convertCodeableConcept(src.getClass_()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasAuthenticator())
      tgt.setAuthenticator(convertReference(src.getAuthenticator()));
    if (src.hasCustodian())
      tgt.setCustodian(convertReference(src.getCustodian()));
    for (org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent t : src.getRelatesTo())
      tgt.addRelatesTo(convertDocumentReferenceRelatesToComponent(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSecurityLabel())
      tgt.addSecurityLabel(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContentComponent t : src.getContent())
      tgt.addContent(convertDocumentReferenceContentComponent(t));
    if (src.hasContext())
      tgt.setContext(convertDocumentReferenceContextComponent(src.getContext()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContentComponent convertDocumentReferenceContentComponent(org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContentComponent tgt = new org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContentComponent();
    copyElement(src, tgt);
    if (src.hasAttachment())
      tgt.setAttachment(convertAttachment(src.getAttachment()));
    if (src.hasFormat())
      tgt.setFormat(convertCoding(src.getFormat()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContentComponent convertDocumentReferenceContentComponent(org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContentComponent tgt = new org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContentComponent();
    copyElement(src, tgt);
    if (src.hasAttachment())
      tgt.setAttachment(convertAttachment(src.getAttachment()));
    if (src.hasFormat())
      tgt.setFormat(convertCoding(src.getFormat()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent convertDocumentReferenceContextComponent(org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent tgt = new org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent();
    copyElement(src, tgt);
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getEvent())
      tgt.addEvent(convertCodeableConcept(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasFacilityType())
      tgt.setFacilityType(convertCodeableConcept(src.getFacilityType()));
    if (src.hasPracticeSetting())
      tgt.setPracticeSetting(convertCodeableConcept(src.getPracticeSetting()));
    if (src.hasSourcePatientInfo())
      tgt.setSourcePatientInfo(convertReference(src.getSourcePatientInfo()));
    for (org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextRelatedComponent t : src.getRelated())
      tgt.addRelated(convertDocumentReferenceContextRelatedComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextComponent convertDocumentReferenceContextComponent(org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextComponent tgt = new org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextComponent();
    copyElement(src, tgt);
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getEvent())
      tgt.addEvent(convertCodeableConcept(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasFacilityType())
      tgt.setFacilityType(convertCodeableConcept(src.getFacilityType()));
    if (src.hasPracticeSetting())
      tgt.setPracticeSetting(convertCodeableConcept(src.getPracticeSetting()));
    if (src.hasSourcePatientInfo())
      tgt.setSourcePatientInfo(convertReference(src.getSourcePatientInfo()));
    for (org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextRelatedComponent t : src.getRelated())
      tgt.addRelated(convertDocumentReferenceContextRelatedComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextRelatedComponent convertDocumentReferenceContextRelatedComponent(org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextRelatedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextRelatedComponent tgt = new org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextRelatedComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasRef())
      tgt.setRef(convertReference(src.getRef()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextRelatedComponent convertDocumentReferenceContextRelatedComponent(org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextRelatedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextRelatedComponent tgt = new org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContextRelatedComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasRef())
      tgt.setRef(convertReference(src.getRef()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertDocumentRelationshipType(src.getCode()));
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceRelatesToComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertDocumentRelationshipType(src.getCode()));
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus convertDocumentReferenceStatus(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CURRENT: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT;
    case SUPERSEDED: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.SUPERSEDED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus convertDocumentReferenceStatus(org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CURRENT: return org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.CURRENT;
    case SUPERSEDED: return org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.SUPERSEDED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Composition.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.dstu3.model.Composition.DocumentRelationshipType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REPLACES: return org.hl7.fhir.r4.model.Composition.DocumentRelationshipType.REPLACES;
    case TRANSFORMS: return org.hl7.fhir.r4.model.Composition.DocumentRelationshipType.TRANSFORMS;
    case SIGNS: return org.hl7.fhir.r4.model.Composition.DocumentRelationshipType.SIGNS;
    case APPENDS: return org.hl7.fhir.r4.model.Composition.DocumentRelationshipType.APPENDS;
    default: return org.hl7.fhir.r4.model.Composition.DocumentRelationshipType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Composition.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.r4.model.Composition.DocumentRelationshipType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REPLACES: return org.hl7.fhir.dstu3.model.Composition.DocumentRelationshipType.REPLACES;
    case TRANSFORMS: return org.hl7.fhir.dstu3.model.Composition.DocumentRelationshipType.TRANSFORMS;
    case SIGNS: return org.hl7.fhir.dstu3.model.Composition.DocumentRelationshipType.SIGNS;
    case APPENDS: return org.hl7.fhir.dstu3.model.Composition.DocumentRelationshipType.APPENDS;
    default: return org.hl7.fhir.dstu3.model.Composition.DocumentRelationshipType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REPLACES: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.REPLACES;
    case TRANSFORMS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.TRANSFORMS;
    case SIGNS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.SIGNS;
    case APPENDS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.APPENDS;
    default: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REPLACES: return org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.REPLACES;
    case TRANSFORMS: return org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.TRANSFORMS;
    case SIGNS: return org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.SIGNS;
    case APPENDS: return org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.APPENDS;
    default: return org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Dosage convertDosage(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasText())
      tgt.setText(src.getText());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAdditionalInstruction())
      tgt.addAdditionalInstruction(convertCodeableConcept(t));
    if (src.hasPatientInstruction())
      tgt.setPatientInstruction(src.getPatientInstruction());
    if (src.hasTiming())
      tgt.setTiming(convertTiming(src.getTiming()));
    if (src.hasAsNeeded())
      tgt.setAsNeeded(convertType(src.getAsNeeded()));
    if (src.hasSite())
      tgt.setSite(convertCodeableConcept(src.getSite()));
    if (src.hasRoute())
      tgt.setRoute(convertCodeableConcept(src.getRoute()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasDose())
      tgt.setDose(convertType(src.getDose()));
    if (src.hasMaxDosePerPeriod())
      tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod()));
    if (src.hasMaxDosePerAdministration())
      tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration()));
    if (src.hasMaxDosePerLifetime())
      tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime()));
    if (src.hasRate())
      tgt.setRate(convertType(src.getRate()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Dosage convertDosage(org.hl7.fhir.r4.model.Dosage src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasText())
      tgt.setText(src.getText());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAdditionalInstruction())
      tgt.addAdditionalInstruction(convertCodeableConcept(t));
    if (src.hasPatientInstruction())
      tgt.setPatientInstruction(src.getPatientInstruction());
    if (src.hasTiming())
      tgt.setTiming(convertTiming(src.getTiming()));
    if (src.hasAsNeeded())
      tgt.setAsNeeded(convertType(src.getAsNeeded()));
    if (src.hasSite())
      tgt.setSite(convertCodeableConcept(src.getSite()));
    if (src.hasRoute())
      tgt.setRoute(convertCodeableConcept(src.getRoute()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasDose())
      tgt.setDose(convertType(src.getDose()));
    if (src.hasMaxDosePerPeriod())
      tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod()));
    if (src.hasMaxDosePerAdministration())
      tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration()));
    if (src.hasMaxDosePerLifetime())
      tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime()));
    if (src.hasRate())
      tgt.setRate(convertType(src.getRate()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition();
    copyElement(src, tgt);
    if (src.hasPath())
      tgt.setPath(src.getPath());
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation> t : src.getRepresentation())
      tgt.addRepresentation(convertPropertyRepresentation(t.getValue()));
    if (src.hasSliceName())
      tgt.setSliceName(src.getSliceName());
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    for (org.hl7.fhir.dstu3.model.Coding t : src.getCode())
      tgt.addCode(convertCoding(t));
    if (src.hasSlicing())
      tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing()));
    if (src.hasShort())
      tgt.setShort(src.getShort());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasRequirements())
      tgt.setRequirements(src.getRequirements());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias())
      tgt.addAlias(t.getValue());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasBase())
      tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
    if (src.hasContentReference())
      tgt.setContentReference(src.getContentReference());
    for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType())
      tgt.addType(convertTypeRefComponent(t));
    if (src.hasDefaultValue())
      tgt.setDefaultValue(convertType(src.getDefaultValue()));
    if (src.hasMeaningWhenMissing())
      tgt.setMeaningWhenMissing(src.getMeaningWhenMissing());
    if (src.hasOrderMeaning())
      tgt.setOrderMeaning(src.getOrderMeaning());
    if (src.hasFixed())
      tgt.setFixed(convertType(src.getFixed()));
    if (src.hasPattern())
      tgt.setPattern(convertType(src.getPattern()));
    for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample())
      tgt.addExample(convertElementDefinitionExampleComponent(t));
    if (src.hasMinValue())
      tgt.setMinValue(convertType(src.getMinValue()));
    if (src.hasMaxValue())
      tgt.setMaxValue(convertType(src.getMaxValue()));
    if (src.hasMaxLength())
      tgt.setMaxLength(src.getMaxLength());
    for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition())
      tgt.addCondition(t.getValue());
    for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint())
      tgt.addConstraint(convertElementDefinitionConstraintComponent(t));
    if (src.hasMustSupport())
      tgt.setMustSupport(src.getMustSupport());
    if (src.hasIsModifier())
      tgt.setIsModifier(src.getIsModifier());
    if (src.hasIsSummary())
      tgt.setIsSummary(src.getIsSummary());
    if (src.hasBinding())
      tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding()));
    for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping())
      tgt.addMapping(convertElementDefinitionMappingComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition();
    copyElement(src, tgt);
    if (src.hasPath())
      tgt.setPath(src.getPath());
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation> t : src.getRepresentation())
      tgt.addRepresentation(convertPropertyRepresentation(t.getValue()));
    if (src.hasSliceName())
      tgt.setSliceName(src.getSliceName());
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    for (org.hl7.fhir.r4.model.Coding t : src.getCode())
      tgt.addCode(convertCoding(t));
    if (src.hasSlicing())
      tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing()));
    if (src.hasShort())
      tgt.setShort(src.getShort());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasRequirements())
      tgt.setRequirements(src.getRequirements());
    for (org.hl7.fhir.r4.model.StringType t : src.getAlias())
      tgt.addAlias(t.getValue());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasBase())
      tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
    if (src.hasContentReference())
      tgt.setContentReference(src.getContentReference());
    for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType())
      tgt.addType(convertTypeRefComponent(t));
    if (src.hasDefaultValue())
      tgt.setDefaultValue(convertType(src.getDefaultValue()));
    if (src.hasMeaningWhenMissing())
      tgt.setMeaningWhenMissing(src.getMeaningWhenMissing());
    if (src.hasOrderMeaning())
      tgt.setOrderMeaning(src.getOrderMeaning());
    if (src.hasFixed())
      tgt.setFixed(convertType(src.getFixed()));
    if (src.hasPattern())
      tgt.setPattern(convertType(src.getPattern()));
    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample())
      tgt.addExample(convertElementDefinitionExampleComponent(t));
    if (src.hasMinValue())
      tgt.setMinValue(convertType(src.getMinValue()));
    if (src.hasMaxValue())
      tgt.setMaxValue(convertType(src.getMaxValue()));
    if (src.hasMaxLength())
      tgt.setMaxLength(src.getMaxLength());
    for (org.hl7.fhir.r4.model.IdType t : src.getCondition())
      tgt.addCondition(t.getValue());
    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint())
      tgt.addConstraint(convertElementDefinitionConstraintComponent(t));
    if (src.hasMustSupport())
      tgt.setMustSupport(src.getMustSupport());
    if (src.hasIsModifier())
      tgt.setIsModifier(src.getIsModifier());
    if (src.hasIsSummary())
      tgt.setIsSummary(src.getIsSummary());
    if (src.hasBinding())
      tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding()));
    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping())
      tgt.addMapping(convertElementDefinitionMappingComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent();
    copyElement(src, tgt);
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent();
    copyElement(src, tgt);
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent();
    copyElement(src, tgt);
    if (src.hasStrength())
      tgt.setStrength(convertBindingStrength(src.getStrength()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasValueSet())
      tgt.setValueSet(convertType(src.getValueSet()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent();
    copyElement(src, tgt);
    if (src.hasStrength())
      tgt.setStrength(convertBindingStrength(src.getStrength()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasValueSet())
      tgt.setValueSet(convertType(src.getValueSet()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent();
    copyElement(src, tgt);
    if (src.hasKey())
      tgt.setKey(src.getKey());
    if (src.hasRequirements())
      tgt.setRequirements(src.getRequirements());
    if (src.hasSeverity())
      tgt.setSeverity(convertConstraintSeverity(src.getSeverity()));
    if (src.hasHuman())
      tgt.setHuman(src.getHuman());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasXpath())
      tgt.setXpath(src.getXpath());
    if (src.hasSource())
      tgt.setSource(src.getSource());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent();
    copyElement(src, tgt);
    if (src.hasKey())
      tgt.setKey(src.getKey());
    if (src.hasRequirements())
      tgt.setRequirements(src.getRequirements());
    if (src.hasSeverity())
      tgt.setSeverity(convertConstraintSeverity(src.getSeverity()));
    if (src.hasHuman())
      tgt.setHuman(src.getHuman());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasXpath())
      tgt.setXpath(src.getXpath());
    if (src.hasSource())
      tgt.setSource(src.getSource());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent();
    copyElement(src, tgt);
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent();
    copyElement(src, tgt);
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent();
    copyElement(src, tgt);
    if (src.hasIdentity())
      tgt.setIdentity(src.getIdentity());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasMap())
      tgt.setMap(src.getMap());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent();
    copyElement(src, tgt);
    if (src.hasIdentity())
      tgt.setIdentity(src.getIdentity());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
    if (src.hasMap())
      tgt.setMap(src.getMap());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator())
      tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasOrdered())
      tgt.setOrdered(src.getOrdered());
    if (src.hasRules())
      tgt.setRules(convertSlicingRules(src.getRules()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator())
      tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasOrdered())
      tgt.setOrdered(src.getOrdered());
    if (src.hasRules())
      tgt.setRules(convertSlicingRules(src.getRules()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertDiscriminatorType(src.getType()));
    if (src.hasPath())
      tgt.setPath(src.getPath());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertDiscriminatorType(src.getType()));
    if (src.hasPath())
      tgt.setPath(src.getPath());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.EligibilityRequest convertEligibilityRequest(org.hl7.fhir.dstu3.model.EligibilityRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EligibilityRequest tgt = new org.hl7.fhir.r4.model.EligibilityRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEligibilityRequestStatus(src.getStatus()));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasServiced())
      tgt.setServiced(convertType(src.getServiced()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasInsurer())
      tgt.setInsurer(convertReference(src.getInsurer()));
    if (src.hasFacility())
      tgt.setFacility(convertReference(src.getFacility()));
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasBusinessArrangement())
      tgt.setBusinessArrangement(src.getBusinessArrangement());
    if (src.hasBenefitCategory())
      tgt.setBenefitCategory(convertCodeableConcept(src.getBenefitCategory()));
    if (src.hasBenefitSubCategory())
      tgt.setBenefitSubCategory(convertCodeableConcept(src.getBenefitSubCategory()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EligibilityRequest convertEligibilityRequest(org.hl7.fhir.r4.model.EligibilityRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EligibilityRequest tgt = new org.hl7.fhir.dstu3.model.EligibilityRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEligibilityRequestStatus(src.getStatus()));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasServiced())
      tgt.setServiced(convertType(src.getServiced()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasInsurer())
      tgt.setInsurer(convertReference(src.getInsurer()));
    if (src.hasFacility())
      tgt.setFacility(convertReference(src.getFacility()));
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasBusinessArrangement())
      tgt.setBusinessArrangement(src.getBusinessArrangement());
    if (src.hasBenefitCategory())
      tgt.setBenefitCategory(convertCodeableConcept(src.getBenefitCategory()));
    if (src.hasBenefitSubCategory())
      tgt.setBenefitSubCategory(convertCodeableConcept(src.getBenefitSubCategory()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.EligibilityRequest.EligibilityRequestStatus convertEligibilityRequestStatus(org.hl7.fhir.dstu3.model.EligibilityRequest.EligibilityRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.EligibilityRequest.EligibilityRequestStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.r4.model.EligibilityRequest.EligibilityRequestStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.r4.model.EligibilityRequest.EligibilityRequestStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.EligibilityRequest.EligibilityRequestStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.EligibilityRequest.EligibilityRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.EligibilityRequest.EligibilityRequestStatus convertEligibilityRequestStatus(org.hl7.fhir.r4.model.EligibilityRequest.EligibilityRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.EligibilityRequest.EligibilityRequestStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.dstu3.model.EligibilityRequest.EligibilityRequestStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.dstu3.model.EligibilityRequest.EligibilityRequestStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.EligibilityRequest.EligibilityRequestStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.EligibilityRequest.EligibilityRequestStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Encounter convertEncounter(org.hl7.fhir.dstu3.model.Encounter src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Encounter tgt = new org.hl7.fhir.r4.model.Encounter();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEncounterStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.Encounter.StatusHistoryComponent t : src.getStatusHistory())
      tgt.addStatusHistory(convertStatusHistoryComponent(t));
    if (src.hasClass_())
      tgt.setClass_(convertCoding(src.getClass_()));
    for (org.hl7.fhir.dstu3.model.Encounter.ClassHistoryComponent t : src.getClassHistory())
      tgt.addClassHistory(convertClassHistoryComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEpisodeOfCare())
      tgt.addEpisodeOfCare(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getIncomingReferral())
      tgt.addIncomingReferral(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertEncounterParticipantComponent(t));
    if (src.hasAppointment())
      tgt.setAppointment(convertReference(src.getAppointment()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasLength())
      tgt.setLength(convertDuration(src.getLength()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent t : src.getDiagnosis())
      tgt.addDiagnosis(convertDiagnosisComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAccount())
      tgt.addAccount(convertReference(t));
    if (src.hasHospitalization())
      tgt.setHospitalization(convertEncounterHospitalizationComponent(src.getHospitalization()));
    for (org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent t : src.getLocation())
      tgt.addLocation(convertEncounterLocationComponent(t));
    if (src.hasServiceProvider())
      tgt.setServiceProvider(convertReference(src.getServiceProvider()));
    if (src.hasPartOf())
      tgt.setPartOf(convertReference(src.getPartOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Encounter convertEncounter(org.hl7.fhir.r4.model.Encounter src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Encounter tgt = new org.hl7.fhir.dstu3.model.Encounter();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEncounterStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent t : src.getStatusHistory())
      tgt.addStatusHistory(convertStatusHistoryComponent(t));
    if (src.hasClass_())
      tgt.setClass_(convertCoding(src.getClass_()));
    for (org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent t : src.getClassHistory())
      tgt.addClassHistory(convertClassHistoryComponent(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.r4.model.Reference t : src.getEpisodeOfCare())
      tgt.addEpisodeOfCare(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getIncomingReferral())
      tgt.addIncomingReferral(convertReference(t));
    for (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertEncounterParticipantComponent(t));
    if (src.hasAppointment())
      tgt.setAppointment(convertReference(src.getAppointment()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasLength())
      tgt.setLength(convertDuration(src.getLength()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Encounter.DiagnosisComponent t : src.getDiagnosis())
      tgt.addDiagnosis(convertDiagnosisComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getAccount())
      tgt.addAccount(convertReference(t));
    if (src.hasHospitalization())
      tgt.setHospitalization(convertEncounterHospitalizationComponent(src.getHospitalization()));
    for (org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent t : src.getLocation())
      tgt.addLocation(convertEncounterLocationComponent(t));
    if (src.hasServiceProvider())
      tgt.setServiceProvider(convertReference(src.getServiceProvider()));
    if (src.hasPartOf())
      tgt.setPartOf(convertReference(src.getPartOf()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent convertEncounterHospitalizationComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterHospitalizationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent();
    copyElement(src, tgt);
    if (src.hasPreAdmissionIdentifier())
      tgt.setPreAdmissionIdentifier(convertIdentifier(src.getPreAdmissionIdentifier()));
    if (src.hasOrigin())
      tgt.setOrigin(convertReference(src.getOrigin()));
    if (src.hasAdmitSource())
      tgt.setAdmitSource(convertCodeableConcept(src.getAdmitSource()));
    if (src.hasReAdmission())
      tgt.setReAdmission(convertCodeableConcept(src.getReAdmission()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getDietPreference())
      tgt.addDietPreference(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialCourtesy())
      tgt.addSpecialCourtesy(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialArrangement())
      tgt.addSpecialArrangement(convertCodeableConcept(t));
    if (src.hasDestination())
      tgt.setDestination(convertReference(src.getDestination()));
    if (src.hasDischargeDisposition())
      tgt.setDischargeDisposition(convertCodeableConcept(src.getDischargeDisposition()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Encounter.EncounterHospitalizationComponent convertEncounterHospitalizationComponent(org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Encounter.EncounterHospitalizationComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.EncounterHospitalizationComponent();
    copyElement(src, tgt);
    if (src.hasPreAdmissionIdentifier())
      tgt.setPreAdmissionIdentifier(convertIdentifier(src.getPreAdmissionIdentifier()));
    if (src.hasOrigin())
      tgt.setOrigin(convertReference(src.getOrigin()));
    if (src.hasAdmitSource())
      tgt.setAdmitSource(convertCodeableConcept(src.getAdmitSource()));
    if (src.hasReAdmission())
      tgt.setReAdmission(convertCodeableConcept(src.getReAdmission()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getDietPreference())
      tgt.addDietPreference(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialCourtesy())
      tgt.addSpecialCourtesy(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialArrangement())
      tgt.addSpecialArrangement(convertCodeableConcept(t));
    if (src.hasDestination())
      tgt.setDestination(convertReference(src.getDestination()));
    if (src.hasDischargeDisposition())
      tgt.setDischargeDisposition(convertCodeableConcept(src.getDischargeDisposition()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent convertEncounterLocationComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent();
    copyElement(src, tgt);
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    if (src.hasStatus())
      tgt.setStatus(convertEncounterLocationStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent convertEncounterLocationComponent(org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent();
    copyElement(src, tgt);
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    if (src.hasStatus())
      tgt.setStatus(convertEncounterLocationStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus convertEncounterLocationStatus(org.hl7.fhir.dstu3.model.Encounter.EncounterLocationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.PLANNED;
    case ACTIVE: return org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.ACTIVE;
    case RESERVED: return org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.RESERVED;
    case COMPLETED: return org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.COMPLETED;
    default: return org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Encounter.EncounterLocationStatus convertEncounterLocationStatus(org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.dstu3.model.Encounter.EncounterLocationStatus.PLANNED;
    case ACTIVE: return org.hl7.fhir.dstu3.model.Encounter.EncounterLocationStatus.ACTIVE;
    case RESERVED: return org.hl7.fhir.dstu3.model.Encounter.EncounterLocationStatus.RESERVED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.Encounter.EncounterLocationStatus.COMPLETED;
    default: return org.hl7.fhir.dstu3.model.Encounter.EncounterLocationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasIndividual())
      tgt.setIndividual(convertReference(src.getIndividual()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasIndividual())
      tgt.setIndividual(convertReference(src.getIndividual()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Encounter.EncounterStatus convertEncounterStatus(org.hl7.fhir.dstu3.model.Encounter.EncounterStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.PLANNED;
    case ARRIVED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.ARRIVED;
    case TRIAGED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.TRIAGED;
    case INPROGRESS: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.INPROGRESS;
    case ONLEAVE: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.ONLEAVE;
    case FINISHED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED;
    case CANCELLED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Encounter.EncounterStatus convertEncounterStatus(org.hl7.fhir.r4.model.Encounter.EncounterStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.PLANNED;
    case ARRIVED: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.ARRIVED;
    case TRIAGED: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.TRIAGED;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.INPROGRESS;
    case ONLEAVE: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.ONLEAVE;
    case FINISHED: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.FINISHED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Endpoint convertEndpoint(org.hl7.fhir.dstu3.model.Endpoint src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Endpoint tgt = new org.hl7.fhir.r4.model.Endpoint();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEndpointStatus(src.getStatus()));
    if (src.hasConnectionType())
      tgt.setConnectionType(convertCoding(src.getConnectionType()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getContact())
      tgt.addContact(convertContactPoint(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPayloadType())
      tgt.addPayloadType(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getPayloadMimeType())
      tgt.addPayloadMimeType(t.getValue());
    if (src.hasAddress())
      tgt.setAddress(src.getAddress());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getHeader())
      tgt.addHeader(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Endpoint convertEndpoint(org.hl7.fhir.r4.model.Endpoint src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Endpoint tgt = new org.hl7.fhir.dstu3.model.Endpoint();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEndpointStatus(src.getStatus()));
    if (src.hasConnectionType())
      tgt.setConnectionType(convertCoding(src.getConnectionType()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact())
      tgt.addContact(convertContactPoint(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPayloadType())
      tgt.addPayloadType(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeType t : src.getPayloadMimeType())
      tgt.addPayloadMimeType(t.getValue());
    if (src.hasAddress())
      tgt.setAddress(src.getAddress());
    for (org.hl7.fhir.r4.model.StringType t : src.getHeader())
      tgt.addHeader(t.getValue());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Endpoint.EndpointStatus convertEndpointStatus(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Endpoint.EndpointStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.Endpoint.EndpointStatus.SUSPENDED;
    case ERROR: return org.hl7.fhir.r4.model.Endpoint.EndpointStatus.ERROR;
    case OFF: return org.hl7.fhir.r4.model.Endpoint.EndpointStatus.OFF;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Endpoint.EndpointStatus.ENTEREDINERROR;
    case TEST: return org.hl7.fhir.r4.model.Endpoint.EndpointStatus.TEST;
    default: return org.hl7.fhir.r4.model.Endpoint.EndpointStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus convertEndpointStatus(org.hl7.fhir.r4.model.Endpoint.EndpointStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.SUSPENDED;
    case ERROR: return org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.ERROR;
    case OFF: return org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.OFF;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.ENTEREDINERROR;
    case TEST: return org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.TEST;
    default: return org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.dstu3.model.EpisodeOfCare src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EpisodeOfCare tgt = new org.hl7.fhir.r4.model.EpisodeOfCare();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEpisodeOfCareStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory())
      tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis())
      tgt.addDiagnosis(convertDiagnosisComponent(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReferralRequest())
      tgt.addReferralRequest(convertReference(t));
    if (src.hasCareManager())
      tgt.setCareManager(convertReference(src.getCareManager()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getTeam())
      tgt.addTeam(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAccount())
      tgt.addAccount(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.r4.model.EpisodeOfCare src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EpisodeOfCare tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertEpisodeOfCareStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory())
      tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis())
      tgt.addDiagnosis(convertDiagnosisComponent(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.Reference t : src.getReferralRequest())
      tgt.addReferralRequest(convertReference(t));
    if (src.hasCareManager())
      tgt.setCareManager(convertReference(src.getCareManager()));
    for (org.hl7.fhir.r4.model.Reference t : src.getTeam())
      tgt.addTeam(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getAccount())
      tgt.addAccount(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus convertEpisodeOfCareStatus(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.PLANNED;
    case WAITLIST: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.WAITLIST;
    case ACTIVE: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.ACTIVE;
    case ONHOLD: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.ONHOLD;
    case FINISHED: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.FINISHED;
    case CANCELLED: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus convertEpisodeOfCareStatus(org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PLANNED: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.PLANNED;
    case WAITLIST: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.WAITLIST;
    case ACTIVE: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ACTIVE;
    case ONHOLD: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ONHOLD;
    case FINISHED: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.FINISHED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertEpisodeOfCareStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.r4.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertEpisodeOfCareStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }
//
//  public static org.hl7.fhir.r4.model.Consent.ConsentActorComponent convertConsentActorComponent(org.hl7.fhir.dstu3.model.Consent.ConsentActorComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.r4.model.Consent.ConsentActorComponent tgt = new org.hl7.fhir.r4.model.Consent.ConsentActorComponent();
//    copyElement(src, tgt);
//    if (src.hasRole())
//      tgt.setRole(convertCodeableConcept(src.getRole()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }
//
//  public static org.hl7.fhir.dstu3.model.Consent.ConsentActorComponent convertConsentActorComponent(org.hl7.fhir.r4.model.Consent.ConsentActorComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.Consent.ConsentActorComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ConsentActorComponent();
//    copyElement(src, tgt);
//    if (src.hasRole())
//      tgt.setRole(convertCodeableConcept(src.getRole()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }

  public static org.hl7.fhir.r4.model.EligibilityResponse.ErrorsComponent convertErrorsComponent(org.hl7.fhir.dstu3.model.EligibilityResponse.ErrorsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EligibilityResponse.ErrorsComponent tgt = new org.hl7.fhir.r4.model.EligibilityResponse.ErrorsComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EligibilityResponse.ErrorsComponent convertErrorsComponent(org.hl7.fhir.r4.model.EligibilityResponse.ErrorsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EligibilityResponse.ErrorsComponent tgt = new org.hl7.fhir.dstu3.model.EligibilityResponse.ErrorsComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    return tgt;
  }
//
//  public static org.hl7.fhir.r4.model.Consent.ConsentDataComponent convertConsentDataComponent(org.hl7.fhir.dstu3.model.Consent.ConsentDataComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.r4.model.Consent.ConsentDataComponent tgt = new org.hl7.fhir.r4.model.Consent.ConsentDataComponent();
//    copyElement(src, tgt);
//    if (src.hasMeaning())
//      tgt.setMeaning(convertConsentDataMeaning(src.getMeaning()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }
//
//  public static org.hl7.fhir.dstu3.model.Consent.ConsentDataComponent convertConsentDataComponent(org.hl7.fhir.r4.model.Consent.ConsentDataComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.Consent.ConsentDataComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ConsentDataComponent();
//    copyElement(src, tgt);
//    if (src.hasMeaning())
//      tgt.setMeaning(convertConsentDataMeaning(src.getMeaning()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode convertEventCapabilityMode(org.hl7.fhir.dstu3.model.CapabilityStatement.EventCapabilityMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SENDER: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER;
    case RECEIVER: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.EventCapabilityMode convertEventCapabilityMode(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SENDER: return org.hl7.fhir.dstu3.model.CapabilityStatement.EventCapabilityMode.SENDER;
    case RECEIVER: return org.hl7.fhir.dstu3.model.CapabilityStatement.EventCapabilityMode.RECEIVER;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.EventCapabilityMode.NULL;
  }
}

//  public static org.hl7.fhir.r4.model.Consent.ExceptComponent convertExceptComponent(org.hl7.fhir.dstu3.model.Consent.ExceptComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.r4.model.Consent.ExceptComponent tgt = new org.hl7.fhir.r4.model.Consent.ExceptComponent();
//    copyElement(src, tgt);
//    if (src.hasType())
//      tgt.setType(convertConsentExceptType(src.getType()));
//    if (src.hasPeriod())
//      tgt.setPeriod(convertPeriod(src.getPeriod()));
//    for (org.hl7.fhir.dstu3.model.Consent.ExceptActorComponent t : src.getActor())
//      tgt.addActor(convertExceptActorComponent(t));
//    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAction())
//      tgt.addAction(convertCodeableConcept(t));
//    for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurityLabel())
//      tgt.addSecurityLabel(convertCoding(t));
//    for (org.hl7.fhir.dstu3.model.Coding t : src.getPurpose())
//      tgt.addPurpose(convertCoding(t));
//    for (org.hl7.fhir.dstu3.model.Coding t : src.getClass_())
//      tgt.addClass_(convertCoding(t));
//    for (org.hl7.fhir.dstu3.model.Coding t : src.getCode())
//      tgt.addCode(convertCoding(t));
//    if (src.hasDataPeriod())
//      tgt.setDataPeriod(convertPeriod(src.getDataPeriod()));
//    for (org.hl7.fhir.dstu3.model.Consent.ExceptDataComponent t : src.getData())
//      tgt.addData(convertExceptDataComponent(t));
//    return tgt;
//  }
//
//  public static org.hl7.fhir.dstu3.model.Consent.ExceptComponent convertExceptComponent(org.hl7.fhir.r4.model.Consent.ExceptComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.Consent.ExceptComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ExceptComponent();
//    copyElement(src, tgt);
//    if (src.hasType())
//      tgt.setType(convertConsentExceptType(src.getType()));
//    if (src.hasPeriod())
//      tgt.setPeriod(convertPeriod(src.getPeriod()));
//    for (org.hl7.fhir.r4.model.Consent.ExceptActorComponent t : src.getActor())
//      tgt.addActor(convertExceptActorComponent(t));
//    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAction())
//      tgt.addAction(convertCodeableConcept(t));
//    for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel())
//      tgt.addSecurityLabel(convertCoding(t));
//    for (org.hl7.fhir.r4.model.Coding t : src.getPurpose())
//      tgt.addPurpose(convertCoding(t));
//    for (org.hl7.fhir.r4.model.Coding t : src.getClass_())
//      tgt.addClass_(convertCoding(t));
//    for (org.hl7.fhir.r4.model.Coding t : src.getCode())
//      tgt.addCode(convertCoding(t));
//    if (src.hasDataPeriod())
//      tgt.setDataPeriod(convertPeriod(src.getDataPeriod()));
//    for (org.hl7.fhir.r4.model.Consent.ExceptDataComponent t : src.getData())
//      tgt.addData(convertExceptDataComponent(t));
//    return tgt;
//  }
//
//  private static org.hl7.fhir.r4.model.Consent.ConsentExceptType convertConsentExceptType(org.hl7.fhir.dstu3.model.Consent.ConsentExceptType src) throws FHIRException {
//    if (src == null)
//      return null;
//    switch (src) {
//    case DENY: return org.hl7.fhir.r4.model.Consent.ConsentExceptType.DENY;
//    case PERMIT: return org.hl7.fhir.r4.model.Consent.ConsentExceptType.PERMIT;
//    default: return org.hl7.fhir.r4.model.Consent.ConsentExceptType.NULL;
//  }
//}
//
//  private static org.hl7.fhir.dstu3.model.Consent.ConsentExceptType convertConsentExceptType(org.hl7.fhir.r4.model.Consent.ConsentExceptType src) throws FHIRException {
//    if (src == null)
//      return null;
//    switch (src) {
//    case DENY: return org.hl7.fhir.dstu3.model.Consent.ConsentExceptType.DENY;
//    case PERMIT: return org.hl7.fhir.dstu3.model.Consent.ConsentExceptType.PERMIT;
//    default: return org.hl7.fhir.dstu3.model.Consent.ConsentExceptType.NULL;
//  }
//}
//
//  public static org.hl7.fhir.r4.model.Consent.ExceptActorComponent convertExceptActorComponent(org.hl7.fhir.dstu3.model.Consent.ExceptActorComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.r4.model.Consent.ExceptActorComponent tgt = new org.hl7.fhir.r4.model.Consent.ExceptActorComponent();
//    copyElement(src, tgt);
//    if (src.hasRole())
//      tgt.setRole(convertCodeableConcept(src.getRole()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }
//
//  public static org.hl7.fhir.dstu3.model.Consent.ExceptActorComponent convertExceptActorComponent(org.hl7.fhir.r4.model.Consent.ExceptActorComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.Consent.ExceptActorComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ExceptActorComponent();
//    copyElement(src, tgt);
//    if (src.hasRole())
//      tgt.setRole(convertCodeableConcept(src.getRole()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }
//
//  public static org.hl7.fhir.r4.model.Consent.ExceptDataComponent convertExceptDataComponent(org.hl7.fhir.dstu3.model.Consent.ExceptDataComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.r4.model.Consent.ExceptDataComponent tgt = new org.hl7.fhir.r4.model.Consent.ExceptDataComponent();
//    copyElement(src, tgt);
//    if (src.hasMeaning())
//      tgt.setMeaning(convertConsentDataMeaning(src.getMeaning()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }
//
//  public static org.hl7.fhir.dstu3.model.Consent.ExceptDataComponent convertExceptDataComponent(org.hl7.fhir.r4.model.Consent.ExceptDataComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.Consent.ExceptDataComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ExceptDataComponent();
//    copyElement(src, tgt);
//    if (src.hasMeaning())
//      tgt.setMeaning(convertConsentDataMeaning(src.getMeaning()));
//    if (src.hasReference())
//      tgt.setReference(convertReference(src.getReference()));
//    return tgt;
//  }

  private static org.hl7.fhir.r4.model.Timing.EventTiming convertEventTiming(org.hl7.fhir.dstu3.model.Timing.EventTiming src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MORN: return org.hl7.fhir.r4.model.Timing.EventTiming.MORN;
    case AFT: return org.hl7.fhir.r4.model.Timing.EventTiming.AFT;
    case EVE: return org.hl7.fhir.r4.model.Timing.EventTiming.EVE;
    case NIGHT: return org.hl7.fhir.r4.model.Timing.EventTiming.NIGHT;
    case PHS: return org.hl7.fhir.r4.model.Timing.EventTiming.PHS;
    case HS: return org.hl7.fhir.r4.model.Timing.EventTiming.HS;
    case WAKE: return org.hl7.fhir.r4.model.Timing.EventTiming.WAKE;
    case C: return org.hl7.fhir.r4.model.Timing.EventTiming.C;
    case CM: return org.hl7.fhir.r4.model.Timing.EventTiming.CM;
    case CD: return org.hl7.fhir.r4.model.Timing.EventTiming.CD;
    case CV: return org.hl7.fhir.r4.model.Timing.EventTiming.CV;
    case AC: return org.hl7.fhir.r4.model.Timing.EventTiming.AC;
    case ACM: return org.hl7.fhir.r4.model.Timing.EventTiming.ACM;
    case ACD: return org.hl7.fhir.r4.model.Timing.EventTiming.ACD;
    case ACV: return org.hl7.fhir.r4.model.Timing.EventTiming.ACV;
    case PC: return org.hl7.fhir.r4.model.Timing.EventTiming.PC;
    case PCM: return org.hl7.fhir.r4.model.Timing.EventTiming.PCM;
    case PCD: return org.hl7.fhir.r4.model.Timing.EventTiming.PCD;
    case PCV: return org.hl7.fhir.r4.model.Timing.EventTiming.PCV;
    default: return org.hl7.fhir.r4.model.Timing.EventTiming.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Timing.EventTiming convertEventTiming(org.hl7.fhir.r4.model.Timing.EventTiming src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MORN: return org.hl7.fhir.dstu3.model.Timing.EventTiming.MORN;
    case AFT: return org.hl7.fhir.dstu3.model.Timing.EventTiming.AFT;
    case EVE: return org.hl7.fhir.dstu3.model.Timing.EventTiming.EVE;
    case NIGHT: return org.hl7.fhir.dstu3.model.Timing.EventTiming.NIGHT;
    case PHS: return org.hl7.fhir.dstu3.model.Timing.EventTiming.PHS;
    case HS: return org.hl7.fhir.dstu3.model.Timing.EventTiming.HS;
    case WAKE: return org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE;
    case C: return org.hl7.fhir.dstu3.model.Timing.EventTiming.C;
    case CM: return org.hl7.fhir.dstu3.model.Timing.EventTiming.CM;
    case CD: return org.hl7.fhir.dstu3.model.Timing.EventTiming.CD;
    case CV: return org.hl7.fhir.dstu3.model.Timing.EventTiming.CV;
    case AC: return org.hl7.fhir.dstu3.model.Timing.EventTiming.AC;
    case ACM: return org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM;
    case ACD: return org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD;
    case ACV: return org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV;
    case PC: return org.hl7.fhir.dstu3.model.Timing.EventTiming.PC;
    case PCM: return org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM;
    case PCD: return org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD;
    case PCV: return org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV;
    default: return org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ExpansionProfile convertExpansionProfile(org.hl7.fhir.dstu3.model.ExpansionProfile src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile tgt = new org.hl7.fhir.r4.model.ExpansionProfile();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileFixedVersionComponent t : src.getFixedVersion())
      tgt.addFixedVersion(convertExpansionProfileFixedVersionComponent(t));
    if (src.hasExcludedSystem())
      tgt.setExcludedSystem(convertExpansionProfileExcludedSystemComponent(src.getExcludedSystem()));
    if (src.hasIncludeDesignations())
      tgt.setIncludeDesignations(src.getIncludeDesignations());
    if (src.hasDesignation())
      tgt.setDesignation(convertExpansionProfileDesignationComponent(src.getDesignation()));
    if (src.hasIncludeDefinition())
      tgt.setIncludeDefinition(src.getIncludeDefinition());
    if (src.hasActiveOnly())
      tgt.setActiveOnly(src.getActiveOnly());
    if (src.hasExcludeNested())
      tgt.setExcludeNested(src.getExcludeNested());
    if (src.hasExcludeNotForUI())
      tgt.setExcludeNotForUI(src.getExcludeNotForUI());
    if (src.hasExcludePostCoordinated())
      tgt.setExcludePostCoordinated(src.getExcludePostCoordinated());
    if (src.hasDisplayLanguage())
      tgt.setDisplayLanguage(src.getDisplayLanguage());
    if (src.hasLimitedExpansion())
      tgt.setLimitedExpansion(src.getLimitedExpansion());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile convertExpansionProfile(org.hl7.fhir.r4.model.ExpansionProfile src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileFixedVersionComponent t : src.getFixedVersion())
      tgt.addFixedVersion(convertExpansionProfileFixedVersionComponent(t));
    if (src.hasExcludedSystem())
      tgt.setExcludedSystem(convertExpansionProfileExcludedSystemComponent(src.getExcludedSystem()));
    if (src.hasIncludeDesignations())
      tgt.setIncludeDesignations(src.getIncludeDesignations());
    if (src.hasDesignation())
      tgt.setDesignation(convertExpansionProfileDesignationComponent(src.getDesignation()));
    if (src.hasIncludeDefinition())
      tgt.setIncludeDefinition(src.getIncludeDefinition());
    if (src.hasActiveOnly())
      tgt.setActiveOnly(src.getActiveOnly());
    if (src.hasExcludeNested())
      tgt.setExcludeNested(src.getExcludeNested());
    if (src.hasExcludeNotForUI())
      tgt.setExcludeNotForUI(src.getExcludeNotForUI());
    if (src.hasExcludePostCoordinated())
      tgt.setExcludePostCoordinated(src.getExcludePostCoordinated());
    if (src.hasDisplayLanguage())
      tgt.setDisplayLanguage(src.getDisplayLanguage());
    if (src.hasLimitedExpansion())
      tgt.setLimitedExpansion(src.getLimitedExpansion());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileDesignationComponent convertExpansionProfileDesignationComponent(org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileDesignationComponent tgt = new org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileDesignationComponent();
    copyElement(src, tgt);
    if (src.hasInclude())
      tgt.setInclude(convertDesignationIncludeComponent(src.getInclude()));
    if (src.hasExclude())
      tgt.setExclude(convertDesignationExcludeComponent(src.getExclude()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileDesignationComponent convertExpansionProfileDesignationComponent(org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileDesignationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileDesignationComponent tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileDesignationComponent();
    copyElement(src, tgt);
    if (src.hasInclude())
      tgt.setInclude(convertDesignationIncludeComponent(src.getInclude()));
    if (src.hasExclude())
      tgt.setExclude(convertDesignationExcludeComponent(src.getExclude()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent convertExpansionProfileExcludedSystemComponent(org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent tgt = new org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent convertExpansionProfileExcludedSystemComponent(org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileExcludedSystemComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileFixedVersionComponent convertExpansionProfileFixedVersionComponent(org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileFixedVersionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileFixedVersionComponent tgt = new org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileFixedVersionComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasMode())
      tgt.setMode(convertSystemVersionProcessingMode(src.getMode()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileFixedVersionComponent convertExpansionProfileFixedVersionComponent(org.hl7.fhir.r4.model.ExpansionProfile.ExpansionProfileFixedVersionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileFixedVersionComponent tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileFixedVersionComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasMode())
      tgt.setMode(convertSystemVersionProcessingMode(src.getMode()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension();
    copyElement(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension();
    copyElement(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext convertExtensionContext(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RESOURCE: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.RESOURCE;
    case DATATYPE: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.DATATYPE;
    case EXTENSION: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.EXTENSION;
    default: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext convertExtensionContext(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RESOURCE: return org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.RESOURCE;
    case DATATYPE: return org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.DATATYPE;
    case EXTENSION: return org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.EXTENSION;
    default: return org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Device.FHIRDeviceStatus convertFHIRDeviceStatus(org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus convertFHIRDeviceStatus(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Substance.FHIRSubstanceStatus convertFHIRSubstanceStatus(org.hl7.fhir.dstu3.model.Substance.FHIRSubstanceStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Substance.FHIRSubstanceStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.r4.model.Substance.FHIRSubstanceStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Substance.FHIRSubstanceStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Substance.FHIRSubstanceStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Substance.FHIRSubstanceStatus convertFHIRSubstanceStatus(org.hl7.fhir.r4.model.Substance.FHIRSubstanceStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Substance.FHIRSubstanceStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Substance.FHIRSubstanceStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Substance.FHIRSubstanceStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Substance.FHIRSubstanceStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus convertFamilyHistoryStatus(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PARTIAL: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL;
    case COMPLETED: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR;
    case HEALTHUNKNOWN: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN;
    default: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus convertFamilyHistoryStatus(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PARTIAL: return org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL;
    case COMPLETED: return org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR;
    case HEALTHUNKNOWN: return org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN;
    default: return org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.FamilyMemberHistory convertFamilyMemberHistory(org.hl7.fhir.dstu3.model.FamilyMemberHistory src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.FamilyMemberHistory tgt = new org.hl7.fhir.r4.model.FamilyMemberHistory();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertFamilyHistoryStatus(src.getStatus()));
    if (src.hasNotDoneReason())
      tgt.setDataAbsentReason(convertCodeableConcept(src.getNotDoneReason()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBorn())
      tgt.setBorn(convertType(src.getBorn()));
    if (src.hasAge())
      tgt.setAge(convertType(src.getAge()));
    if (src.hasEstimatedAge())
      tgt.setEstimatedAge(src.getEstimatedAge());
    if (src.hasDeceased())
      tgt.setDeceased(convertType(src.getDeceased()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent t : src.getCondition())
      tgt.addCondition(convertFamilyMemberHistoryConditionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.FamilyMemberHistory convertFamilyMemberHistory(org.hl7.fhir.r4.model.FamilyMemberHistory src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.FamilyMemberHistory tgt = new org.hl7.fhir.dstu3.model.FamilyMemberHistory();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertFamilyHistoryStatus(src.getStatus()));
    if (src.hasDataAbsentReason())
      tgt.setNotDoneReason(convertCodeableConcept(src.getDataAbsentReason()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBorn())
      tgt.setBorn(convertType(src.getBorn()));
    if (src.hasAge())
      tgt.setAge(convertType(src.getAge()));
    if (src.hasEstimatedAge())
      tgt.setEstimatedAge(src.getEstimatedAge());
    if (src.hasDeceased())
      tgt.setDeceased(convertType(src.getDeceased()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent t : src.getCondition())
      tgt.addCondition(convertFamilyMemberHistoryConditionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent convertFamilyMemberHistoryConditionComponent(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent tgt = new org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasOutcome())
      tgt.setOutcome(convertCodeableConcept(src.getOutcome()));
    if (src.hasOnset())
      tgt.setOnset(convertType(src.getOnset()));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent convertFamilyMemberHistoryConditionComponent(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent tgt = new org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasOutcome())
      tgt.setOutcome(convertCodeableConcept(src.getOutcome()));
    if (src.hasOnset())
      tgt.setOnset(convertType(src.getOnset()));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CodeSystem.FilterOperator convertFilterOperator(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQUAL: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.EQUAL;
    case ISA: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.ISA;
    case DESCENDENTOF: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.DESCENDENTOF;
    case ISNOTA: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.ISNOTA;
    case REGEX: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.REGEX;
    case IN: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.IN;
    case NOTIN: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.NOTIN;
    case GENERALIZES: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.GENERALIZES;
    case EXISTS: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.EXISTS;
    default: return org.hl7.fhir.r4.model.CodeSystem.FilterOperator.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator convertFilterOperator(org.hl7.fhir.r4.model.CodeSystem.FilterOperator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQUAL: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.EQUAL;
    case ISA: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.ISA;
    case DESCENDENTOF: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.DESCENDENTOF;
    case ISNOTA: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.ISNOTA;
    case REGEX: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.REGEX;
    case IN: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.IN;
    case NOTIN: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.NOTIN;
    case GENERALIZES: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.GENERALIZES;
    case EXISTS: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.EXISTS;
    default: return org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ValueSet.FilterOperator convertFilterOperator(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQUAL: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.EQUAL;
    case ISA: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISA;
    case DESCENDENTOF: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.DESCENDENTOF;
    case ISNOTA: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISNOTA;
    case REGEX: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.REGEX;
    case IN: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.IN;
    case NOTIN: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.NOTIN;
    case GENERALIZES: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.GENERALIZES;
    case EXISTS: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.EXISTS;
    default: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ValueSet.FilterOperator convertFilterOperator(org.hl7.fhir.r4.model.ValueSet.FilterOperator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQUAL: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.EQUAL;
    case ISA: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISA;
    case DESCENDENTOF: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.DESCENDENTOF;
    case ISNOTA: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISNOTA;
    case REGEX: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.REGEX;
    case IN: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.IN;
    case NOTIN: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NOTIN;
    case GENERALIZES: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.GENERALIZES;
    case EXISTS: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.EXISTS;
    default: return org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Flag convertFlag(org.hl7.fhir.dstu3.model.Flag src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Flag tgt = new org.hl7.fhir.r4.model.Flag();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertFlagStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.addCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    return tgt;
  }

//  public static org.hl7.fhir.dstu3.model.DataElement convertDataElement(org.hl7.fhir.r4.model.DataElement src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.DataElement tgt = new org.hl7.fhir.dstu3.model.DataElement();
//    copyDomainResource(src, tgt);
//    if (src.hasUrl())
//      tgt.setUrl(src.getUrl());
//    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
//      tgt.addIdentifier(convertIdentifier(t));
//    if (src.hasVersion())
//      tgt.setVersion(src.getVersion());
//    if (src.hasStatus())
//      tgt.setStatus(convertPublicationStatus(src.getStatus()));
//    if (src.hasExperimental())
//      tgt.setExperimental(src.getExperimental());
//    if (src.hasDate())
//      tgt.setDate(src.getDate());
//    if (src.hasPublisher())
//      tgt.setPublisher(src.getPublisher());
//    if (src.hasName())
//      tgt.setName(src.getName());
//    if (src.hasTitle())
//      tgt.setTitle(src.getTitle());
//    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
//      tgt.addContact(convertContactDetail(t));
//    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
//      tgt.addUseContext(convertUsageContext(t));
//    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
//      tgt.addJurisdiction(convertCodeableConcept(t));
//    if (src.hasCopyright())
//      tgt.setCopyright(src.getCopyright());
//    if (src.hasStringency())
//      tgt.setStringency(convertDataElementStringency(src.getStringency()));
//    for (org.hl7.fhir.r4.model.DataElement.DataElementMappingComponent t : src.getMapping())
//      tgt.addMapping(convertDataElementMappingComponent(t));
//    for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement())
//      tgt.addElement(convertElementDefinition(t));
//    return tgt;
//  }

//  private static org.hl7.fhir.r4.model.DataElement.DataElementStringency convertDataElementStringency(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency src) throws FHIRException {
//    if (src == null)
//      return null;
//    switch (src) {
//    case COMPARABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.COMPARABLE;
//    case FULLYSPECIFIED: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.FULLYSPECIFIED;
//    case EQUIVALENT: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.EQUIVALENT;
//    case CONVERTABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.CONVERTABLE;
//    case SCALEABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.SCALEABLE;
//    case FLEXIBLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.FLEXIBLE;
//    default: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.NULL;
//  }
//}
//
//  private static org.hl7.fhir.dstu3.model.DataElement.DataElementStringency convertDataElementStringency(org.hl7.fhir.r4.model.DataElement.DataElementStringency src) throws FHIRException {
//    if (src == null)
//      return null;
//    switch (src) {
//    case COMPARABLE: return org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.COMPARABLE;
//    case FULLYSPECIFIED: return org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.FULLYSPECIFIED;
//    case EQUIVALENT: return org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.EQUIVALENT;
//    case CONVERTABLE: return org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.CONVERTABLE;
//    case SCALEABLE: return org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.SCALEABLE;
//    case FLEXIBLE: return org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.FLEXIBLE;
//    default: return org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.NULL;
//  }
//}

  public static org.hl7.fhir.dstu3.model.Flag convertFlag(org.hl7.fhir.r4.model.Flag src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Flag tgt = new org.hl7.fhir.dstu3.model.Flag();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertFlagStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategoryFirstRep()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    return tgt;
  }

//  public static org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent convertDataElementMappingComponent(org.hl7.fhir.r4.model.DataElement.DataElementMappingComponent src) throws FHIRException {
//    if (src == null)
//      return null;
//    org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent tgt = new org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent();
//    copyElement(src, tgt);
//    if (src.hasIdentity())
//      tgt.setIdentity(src.getIdentity());
//    if (src.hasUri())
//      tgt.setUri(src.getUri());
//    if (src.hasName())
//      tgt.setName(src.getName());
//    if (src.hasComment())
//      tgt.setComment(src.getComment());
//    return tgt;
//  }

  private static org.hl7.fhir.r4.model.Flag.FlagStatus convertFlagStatus(org.hl7.fhir.dstu3.model.Flag.FlagStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Flag.FlagStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.r4.model.Flag.FlagStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Flag.FlagStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Flag.FlagStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Flag.FlagStatus convertFlagStatus(org.hl7.fhir.r4.model.Flag.FlagStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Flag.FlagStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Flag.FlagStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Flag.FlagStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Flag.FlagStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent convertFriendlyLanguageComponent(org.hl7.fhir.dstu3.model.Contract.FriendlyLanguageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.FriendlyLanguageComponent convertFriendlyLanguageComponent(org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.FriendlyLanguageComponent tgt = new org.hl7.fhir.dstu3.model.Contract.FriendlyLanguageComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Goal convertGoal(org.hl7.fhir.dstu3.model.Goal src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Goal tgt = new org.hl7.fhir.r4.model.Goal();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertGoalStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasDescription())
      tgt.setDescription(convertCodeableConcept(src.getDescription()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasStart())
      tgt.setStart(convertType(src.getStart()));
    if (src.hasTarget())
      tgt.setTarget(convertGoalTargetComponent(src.getTarget()));
    if (src.hasStatusDate())
      tgt.setStatusDate(src.getStatusDate());
    if (src.hasStatusReason())
      tgt.setStatusReason(src.getStatusReason());
    if (src.hasExpressedBy())
      tgt.setExpressedBy(convertReference(src.getExpressedBy()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAddresses())
      tgt.addAddresses(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getOutcomeCode())
      tgt.addOutcomeCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getOutcomeReference())
      tgt.addOutcomeReference(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Goal convertGoal(org.hl7.fhir.r4.model.Goal src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Goal tgt = new org.hl7.fhir.dstu3.model.Goal();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertGoalStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasPriority())
      tgt.setPriority(convertCodeableConcept(src.getPriority()));
    if (src.hasDescription())
      tgt.setDescription(convertCodeableConcept(src.getDescription()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasStart())
      tgt.setStart(convertType(src.getStart()));
    if (src.hasTarget())
      tgt.setTarget(convertGoalTargetComponent(src.getTarget()));
    if (src.hasStatusDate())
      tgt.setStatusDate(src.getStatusDate());
    if (src.hasStatusReason())
      tgt.setStatusReason(src.getStatusReason());
    if (src.hasExpressedBy())
      tgt.setExpressedBy(convertReference(src.getExpressedBy()));
    for (org.hl7.fhir.r4.model.Reference t : src.getAddresses())
      tgt.addAddresses(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getOutcomeCode())
      tgt.addOutcomeCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getOutcomeReference())
      tgt.addOutcomeReference(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Goal.GoalStatus convertGoalStatus(org.hl7.fhir.dstu3.model.Goal.GoalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.r4.model.Goal.GoalStatus.PROPOSED;
    case ACCEPTED: return org.hl7.fhir.r4.model.Goal.GoalStatus.ACCEPTED;
    case PLANNED: return org.hl7.fhir.r4.model.Goal.GoalStatus.PLANNED;
    case INPROGRESS: return org.hl7.fhir.r4.model.Goal.GoalStatus.INPROGRESS;
    case ONTARGET: return org.hl7.fhir.r4.model.Goal.GoalStatus.ONTARGET;
    case AHEADOFTARGET: return org.hl7.fhir.r4.model.Goal.GoalStatus.AHEADOFTARGET;
    case BEHINDTARGET: return org.hl7.fhir.r4.model.Goal.GoalStatus.BEHINDTARGET;
    case SUSTAINING: return org.hl7.fhir.r4.model.Goal.GoalStatus.SUSTAINING;
    case ACHIEVED: return org.hl7.fhir.r4.model.Goal.GoalStatus.ACHIEVED;
    case ONHOLD: return org.hl7.fhir.r4.model.Goal.GoalStatus.ONHOLD;
    case CANCELLED: return org.hl7.fhir.r4.model.Goal.GoalStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Goal.GoalStatus.ENTEREDINERROR;
    case REJECTED: return org.hl7.fhir.r4.model.Goal.GoalStatus.REJECTED;
    default: return org.hl7.fhir.r4.model.Goal.GoalStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Goal.GoalStatus convertGoalStatus(org.hl7.fhir.r4.model.Goal.GoalStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.PROPOSED;
    case ACCEPTED: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.ACCEPTED;
    case PLANNED: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.PLANNED;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.INPROGRESS;
    case ONTARGET: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.ONTARGET;
    case AHEADOFTARGET: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.AHEADOFTARGET;
    case BEHINDTARGET: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.BEHINDTARGET;
    case SUSTAINING: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.SUSTAINING;
    case ACHIEVED: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.ACHIEVED;
    case ONHOLD: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.ONHOLD;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.ENTEREDINERROR;
    case REJECTED: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.REJECTED;
    default: return org.hl7.fhir.dstu3.model.Goal.GoalStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Goal.GoalTargetComponent convertGoalTargetComponent(org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Goal.GoalTargetComponent tgt = new org.hl7.fhir.r4.model.Goal.GoalTargetComponent();
    copyElement(src, tgt);
    if (src.hasMeasure())
      tgt.setMeasure(convertCodeableConcept(src.getMeasure()));
    if (src.hasDetail())
      tgt.setDetail(convertType(src.getDetail()));
    if (src.hasDue())
      tgt.setDue(convertType(src.getDue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent convertGoalTargetComponent(org.hl7.fhir.r4.model.Goal.GoalTargetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent tgt = new org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent();
    copyElement(src, tgt);
    if (src.hasMeasure())
      tgt.setMeasure(convertCodeableConcept(src.getMeasure()));
    if (src.hasDetail())
      tgt.setDetail(convertType(src.getDetail()));
    if (src.hasDue())
      tgt.setDue(convertType(src.getDue()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule convertGraphCompartmentRule(org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case IDENTICAL: return org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule.IDENTICAL;
    case MATCHING: return org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule.MATCHING;
    case DIFFERENT: return org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule.DIFFERENT;
    case CUSTOM: return org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule.CUSTOM;
    default: return org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule convertGraphCompartmentRule(org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case IDENTICAL: return org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.IDENTICAL;
    case MATCHING: return org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.MATCHING;
    case DIFFERENT: return org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.DIFFERENT;
    case CUSTOM: return org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.CUSTOM;
    default: return org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.NULL;
  }
}

  public static org.hl7.fhir.r4.model.GraphDefinition convertGraphDefinition(org.hl7.fhir.dstu3.model.GraphDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.GraphDefinition tgt = new org.hl7.fhir.r4.model.GraphDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasProfile())
      tgt.setProfile(src.getProfile());
    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
      tgt.addLink(convertGraphDefinitionLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.GraphDefinition convertGraphDefinition(org.hl7.fhir.r4.model.GraphDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.GraphDefinition tgt = new org.hl7.fhir.dstu3.model.GraphDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasProfile())
      tgt.setProfile(src.getProfile());
    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
      tgt.addLink(convertGraphDefinitionLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent convertGraphDefinitionLinkComponent(org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent tgt = new org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent();
    copyElement(src, tgt);
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasSliceName())
      tgt.setSliceName(src.getSliceName());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent t : src.getTarget())
      tgt.addTarget(convertGraphDefinitionLinkTargetComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent convertGraphDefinitionLinkComponent(org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent tgt = new org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent();
    copyElement(src, tgt);
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasSliceName())
      tgt.setSliceName(src.getSliceName());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent t : src.getTarget())
      tgt.addTarget(convertGraphDefinitionLinkTargetComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent convertGraphDefinitionLinkTargetCompartmentComponent(org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent tgt = new org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCompartmentCode(src.getCode()));
    if (src.hasRule())
      tgt.setRule(convertGraphCompartmentRule(src.getRule()));
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent convertGraphDefinitionLinkTargetCompartmentComponent(org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent tgt = new org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCompartmentCode(src.getCode()));
    if (src.hasRule())
      tgt.setRule(convertGraphCompartmentRule(src.getRule()));
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent convertGraphDefinitionLinkTargetComponent(org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent tgt = new org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(src.getProfile());
    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent t : src.getCompartment())
      tgt.addCompartment(convertGraphDefinitionLinkTargetCompartmentComponent(t));
    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
      tgt.addLink(convertGraphDefinitionLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent convertGraphDefinitionLinkTargetComponent(org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent tgt = new org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(src.getProfile());
    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent t : src.getCompartment())
      tgt.addCompartment(convertGraphDefinitionLinkTargetCompartmentComponent(t));
    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
      tgt.addLink(convertGraphDefinitionLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Group convertGroup(org.hl7.fhir.dstu3.model.Group src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Group tgt = new org.hl7.fhir.r4.model.Group();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasType())
      tgt.setType(convertGroupType(src.getType()));
    if (src.hasActual())
      tgt.setActual(src.getActual());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasQuantity())
      tgt.setQuantity(src.getQuantity());
    for (org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
    for (org.hl7.fhir.dstu3.model.Group.GroupMemberComponent t : src.getMember())
      tgt.addMember(convertGroupMemberComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Group convertGroup(org.hl7.fhir.r4.model.Group src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Group tgt = new org.hl7.fhir.dstu3.model.Group();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasType())
      tgt.setType(convertGroupType(src.getType()));
    if (src.hasActual())
      tgt.setActual(src.getActual());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasQuantity())
      tgt.setQuantity(src.getQuantity());
    for (org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
    for (org.hl7.fhir.r4.model.Group.GroupMemberComponent t : src.getMember())
      tgt.addMember(convertGroupMemberComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasExclude())
      tgt.setExclude(src.getExclude());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasExclude())
      tgt.setExclude(src.getExclude());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Coverage.GroupComponent convertGroupComponent(org.hl7.fhir.dstu3.model.Coverage.GroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Coverage.GroupComponent tgt = new org.hl7.fhir.r4.model.Coverage.GroupComponent();
    copyElement(src, tgt);
    if (src.hasGroup())
      tgt.setGroup(src.getGroup());
    if (src.hasGroupDisplay())
      tgt.setGroupDisplay(src.getGroupDisplay());
    if (src.hasSubGroup())
      tgt.setSubGroup(src.getSubGroup());
    if (src.hasSubGroupDisplay())
      tgt.setSubGroupDisplay(src.getSubGroupDisplay());
    if (src.hasPlan())
      tgt.setPlan(src.getPlan());
    if (src.hasPlanDisplay())
      tgt.setPlanDisplay(src.getPlanDisplay());
    if (src.hasSubPlan())
      tgt.setSubPlan(src.getSubPlan());
    if (src.hasSubPlanDisplay())
      tgt.setSubPlanDisplay(src.getSubPlanDisplay());
    if (src.hasClass_())
      tgt.setClass_(src.getClass_());
    if (src.hasClassDisplay())
      tgt.setClassDisplay(src.getClassDisplay());
    if (src.hasSubClass())
      tgt.setSubClass(src.getSubClass());
    if (src.hasSubClassDisplay())
      tgt.setSubClassDisplay(src.getSubClassDisplay());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Coverage.GroupComponent convertGroupComponent(org.hl7.fhir.r4.model.Coverage.GroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Coverage.GroupComponent tgt = new org.hl7.fhir.dstu3.model.Coverage.GroupComponent();
    copyElement(src, tgt);
    if (src.hasGroup())
      tgt.setGroup(src.getGroup());
    if (src.hasGroupDisplay())
      tgt.setGroupDisplay(src.getGroupDisplay());
    if (src.hasSubGroup())
      tgt.setSubGroup(src.getSubGroup());
    if (src.hasSubGroupDisplay())
      tgt.setSubGroupDisplay(src.getSubGroupDisplay());
    if (src.hasPlan())
      tgt.setPlan(src.getPlan());
    if (src.hasPlanDisplay())
      tgt.setPlanDisplay(src.getPlanDisplay());
    if (src.hasSubPlan())
      tgt.setSubPlan(src.getSubPlan());
    if (src.hasSubPlanDisplay())
      tgt.setSubPlanDisplay(src.getSubPlanDisplay());
    if (src.hasClass_())
      tgt.setClass_(src.getClass_());
    if (src.hasClassDisplay())
      tgt.setClassDisplay(src.getClassDisplay());
    if (src.hasSubClass())
      tgt.setSubClass(src.getSubClass());
    if (src.hasSubClassDisplay())
      tgt.setSubClassDisplay(src.getSubClassDisplay());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.dstu3.model.Group.GroupMemberComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r4.model.Group.GroupMemberComponent();
    copyElement(src, tgt);
    if (src.hasEntity())
      tgt.setEntity(convertReference(src.getEntity()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasInactive())
      tgt.setInactive(src.getInactive());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r4.model.Group.GroupMemberComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.dstu3.model.Group.GroupMemberComponent();
    copyElement(src, tgt);
    if (src.hasEntity())
      tgt.setEntity(convertReference(src.getEntity()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasInactive())
      tgt.setInactive(src.getInactive());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Group.GroupType convertGroupType(org.hl7.fhir.dstu3.model.Group.GroupType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PERSON: return org.hl7.fhir.r4.model.Group.GroupType.PERSON;
    case ANIMAL: return org.hl7.fhir.r4.model.Group.GroupType.ANIMAL;
    case PRACTITIONER: return org.hl7.fhir.r4.model.Group.GroupType.PRACTITIONER;
    case DEVICE: return org.hl7.fhir.r4.model.Group.GroupType.DEVICE;
    case MEDICATION: return org.hl7.fhir.r4.model.Group.GroupType.MEDICATION;
    case SUBSTANCE: return org.hl7.fhir.r4.model.Group.GroupType.SUBSTANCE;
    default: return org.hl7.fhir.r4.model.Group.GroupType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Group.GroupType convertGroupType(org.hl7.fhir.r4.model.Group.GroupType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PERSON: return org.hl7.fhir.dstu3.model.Group.GroupType.PERSON;
    case ANIMAL: return org.hl7.fhir.dstu3.model.Group.GroupType.ANIMAL;
    case PRACTITIONER: return org.hl7.fhir.dstu3.model.Group.GroupType.PRACTITIONER;
    case DEVICE: return org.hl7.fhir.dstu3.model.Group.GroupType.DEVICE;
    case MEDICATION: return org.hl7.fhir.dstu3.model.Group.GroupType.MEDICATION;
    case SUBSTANCE: return org.hl7.fhir.dstu3.model.Group.GroupType.SUBSTANCE;
    default: return org.hl7.fhir.dstu3.model.Group.GroupType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Account.GuarantorComponent convertGuarantorComponent(org.hl7.fhir.dstu3.model.Account.GuarantorComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Account.GuarantorComponent tgt = new org.hl7.fhir.r4.model.Account.GuarantorComponent();
    copyElement(src, tgt);
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    if (src.hasOnHold())
      tgt.setOnHold(src.getOnHold());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Account.GuarantorComponent convertGuarantorComponent(org.hl7.fhir.r4.model.Account.GuarantorComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Account.GuarantorComponent tgt = new org.hl7.fhir.dstu3.model.Account.GuarantorComponent();
    copyElement(src, tgt);
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    if (src.hasOnHold())
      tgt.setOnHold(src.getOnHold());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType convertGuideDependencyType(org.hl7.fhir.dstu3.model.ImplementationGuide.GuideDependencyType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REFERENCE: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.REFERENCE;
    case INCLUSION: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.INCLUSION;
    default: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ImplementationGuide.GuideDependencyType convertGuideDependencyType(org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REFERENCE: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuideDependencyType.REFERENCE;
    case INCLUSION: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuideDependencyType.INCLUSION;
    default: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuideDependencyType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind convertGuidePageKind(org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PAGE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.PAGE;
    case EXAMPLE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.EXAMPLE;
    case LIST: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.LIST;
    case INCLUDE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.INCLUDE;
    case DIRECTORY: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.DIRECTORY;
    case DICTIONARY: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.DICTIONARY;
    case TOC: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.TOC;
    case RESOURCE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.RESOURCE;
    default: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind convertGuidePageKind(org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PAGE: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.PAGE;
    case EXAMPLE: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.EXAMPLE;
    case LIST: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.LIST;
    case INCLUDE: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.INCLUDE;
    case DIRECTORY: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.DIRECTORY;
    case DICTIONARY: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.DICTIONARY;
    case TOC: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.TOC;
    case RESOURCE: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.RESOURCE;
    default: return org.hl7.fhir.dstu3.model.ImplementationGuide.GuidePageKind.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Bundle.HTTPVerb convertHTTPVerb(org.hl7.fhir.dstu3.model.Bundle.HTTPVerb src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GET: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.GET;
    case POST: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST;
    case PUT: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.PUT;
    case DELETE: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.DELETE;
    default: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Bundle.HTTPVerb convertHTTPVerb(org.hl7.fhir.r4.model.Bundle.HTTPVerb src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GET: return org.hl7.fhir.dstu3.model.Bundle.HTTPVerb.GET;
    case POST: return org.hl7.fhir.dstu3.model.Bundle.HTTPVerb.POST;
    case PUT: return org.hl7.fhir.dstu3.model.Bundle.HTTPVerb.PUT;
    case DELETE: return org.hl7.fhir.dstu3.model.Bundle.HTTPVerb.DELETE;
    default: return org.hl7.fhir.dstu3.model.Bundle.HTTPVerb.NULL;
  }
}

  public static org.hl7.fhir.r4.model.HealthcareService convertHealthcareService(org.hl7.fhir.dstu3.model.HealthcareService src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.HealthcareService tgt = new org.hl7.fhir.r4.model.HealthcareService();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasProvidedBy())
      tgt.setProvidedBy(convertReference(src.getProvidedBy()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getLocation())
      tgt.addLocation(convertReference(t));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasExtraDetails())
      tgt.setExtraDetails(src.getExtraDetails());
    if (src.hasPhoto())
      tgt.setPhoto(convertAttachment(src.getPhoto()));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getCoverageArea())
      tgt.addCoverageArea(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getServiceProvisionCode())
      tgt.addServiceProvisionCode(convertCodeableConcept(t));
    if (src.hasEligibility())
      tgt.setEligibility(convertCodeableConcept(src.getEligibility()));
    if (src.hasEligibilityNote())
      tgt.setEligibilityNote(src.getEligibilityNote());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getProgramName())
      tgt.addProgramName(t.getValue());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCharacteristic())
      tgt.addCharacteristic(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReferralMethod())
      tgt.addReferralMethod(convertCodeableConcept(t));
    if (src.hasAppointmentRequired())
      tgt.setAppointmentRequired(src.getAppointmentRequired());
    for (org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
    for (org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
    if (src.hasAvailabilityExceptions())
      tgt.setAvailabilityExceptions(src.getAvailabilityExceptions());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.HealthcareService convertHealthcareService(org.hl7.fhir.r4.model.HealthcareService src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.HealthcareService tgt = new org.hl7.fhir.dstu3.model.HealthcareService();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasProvidedBy())
      tgt.setProvidedBy(convertReference(src.getProvidedBy()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getLocation())
      tgt.addLocation(convertReference(t));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasExtraDetails())
      tgt.setExtraDetails(src.getExtraDetails());
    if (src.hasPhoto())
      tgt.setPhoto(convertAttachment(src.getPhoto()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getCoverageArea())
      tgt.addCoverageArea(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceProvisionCode())
      tgt.addServiceProvisionCode(convertCodeableConcept(t));
    if (src.hasEligibility())
      tgt.setEligibility(convertCodeableConcept(src.getEligibility()));
    if (src.hasEligibilityNote())
      tgt.setEligibilityNote(src.getEligibilityNote());
    for (org.hl7.fhir.r4.model.StringType t : src.getProgramName())
      tgt.addProgramName(t.getValue());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCharacteristic())
      tgt.addCharacteristic(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReferralMethod())
      tgt.addReferralMethod(convertCodeableConcept(t));
    if (src.hasAppointmentRequired())
      tgt.setAppointmentRequired(src.getAppointmentRequired());
    for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
    for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
    if (src.hasAvailabilityExceptions())
      tgt.setAvailabilityExceptions(src.getAvailabilityExceptions());
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek> t : src.getDaysOfWeek())
      tgt.addDaysOfWeek(convertDaysOfWeek(t.getValue()));
    if (src.hasAllDay())
      tgt.setAllDay(src.getAllDay());
    if (src.hasAvailableStartTime())
      tgt.setAvailableStartTime(src.getAvailableStartTime());
    if (src.hasAvailableEndTime())
      tgt.setAvailableEndTime(src.getAvailableEndTime());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek> t : src.getDaysOfWeek())
      tgt.addDaysOfWeek(convertDaysOfWeek(t.getValue()));
    if (src.hasAllDay())
      tgt.setAllDay(src.getAllDay());
    if (src.hasAvailableStartTime())
      tgt.setAvailableStartTime(src.getAvailableStartTime());
    if (src.hasAvailableEndTime())
      tgt.setAvailableEndTime(src.getAvailableEndTime());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasDuring())
      tgt.setDuring(convertPeriod(src.getDuring()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasDuring())
      tgt.setDuring(convertPeriod(src.getDuring()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName();
    copyElement(src, tgt);
    if (src.hasUse())
      tgt.setUse(convertNameUse(src.getUse()));
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasFamily())
      tgt.setFamily(src.getFamily());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven())
      tgt.addGiven(t.getValue());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix())
      tgt.addPrefix(t.getValue());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix())
      tgt.addSuffix(t.getValue());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName();
    copyElement(src, tgt);
    if (src.hasUse())
      tgt.setUse(convertNameUse(src.getUse()));
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasFamily())
      tgt.setFamily(src.getFamily());
    for (org.hl7.fhir.r4.model.StringType t : src.getGiven())
      tgt.addGiven(t.getValue());
    for (org.hl7.fhir.r4.model.StringType t : src.getPrefix())
      tgt.addPrefix(t.getValue());
    for (org.hl7.fhir.r4.model.StringType t : src.getSuffix())
      tgt.addSuffix(t.getValue());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException {
    org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier();
    copyElement(src, tgt);
    if (src.hasUse())
      tgt.setUse(convertIdentifierUse(src.getUse()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasAssigner())
      tgt.setAssigner(convertReference(src.getAssigner()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier();
    copyElement(src, tgt);
    if (src.hasUse())
      tgt.setUse(convertIdentifierUse(src.getUse()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasAssigner())
      tgt.setAssigner(convertReference(src.getAssigner()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Identifier.IdentifierUse convertIdentifierUse(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case USUAL: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL;
    case OFFICIAL: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL;
    case TEMP: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP;
    case SECONDARY: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY;
    default: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Identifier.IdentifierUse convertIdentifierUse(org.hl7.fhir.r4.model.Identifier.IdentifierUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case USUAL: return org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL;
    case OFFICIAL: return org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL;
    case TEMP: return org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP;
    case SECONDARY: return org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY;
    default: return org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel convertIdentityAssuranceLevel(org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LEVEL1: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL1;
    case LEVEL2: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL2;
    case LEVEL3: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL3;
    case LEVEL4: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL4;
    default: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel convertIdentityAssuranceLevel(org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LEVEL1: return org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL1;
    case LEVEL2: return org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL2;
    case LEVEL3: return org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL3;
    case LEVEL4: return org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL4;
    default: return org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ImagingManifest convertImagingManifest(org.hl7.fhir.dstu3.model.ImagingManifest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImagingManifest tgt = new org.hl7.fhir.r4.model.ImagingManifest();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasAuthoringTime())
      tgt.setAuthoringTime(src.getAuthoringTime());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.ImagingManifest.StudyComponent t : src.getStudy())
      tgt.addStudy(convertStudyComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImagingManifest convertImagingManifest(org.hl7.fhir.r4.model.ImagingManifest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImagingManifest tgt = new org.hl7.fhir.dstu3.model.ImagingManifest();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasAuthoringTime())
      tgt.setAuthoringTime(src.getAuthoringTime());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.ImagingManifest.StudyComponent t : src.getStudy())
      tgt.addStudy(convertStudyComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImagingStudy convertImagingStudy(org.hl7.fhir.dstu3.model.ImagingStudy src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImagingStudy tgt = new org.hl7.fhir.r4.model.ImagingStudy();
    copyDomainResource(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasAccession())
      tgt.setAccession(convertIdentifier(src.getAccession()));
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasAvailability())
      tgt.setAvailability(convertInstanceAvailability(src.getAvailability()));
    for (org.hl7.fhir.dstu3.model.Coding t : src.getModalityList())
      tgt.addModalityList(convertCoding(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasStarted())
      tgt.setStarted(src.getStarted());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasReferrer())
      tgt.setReferrer(convertReference(src.getReferrer()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getInterpreter())
      tgt.addInterpreter(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    if (src.hasNumberOfSeries())
      tgt.setNumberOfSeries(src.getNumberOfSeries());
    if (src.hasNumberOfInstances())
      tgt.setNumberOfInstances(src.getNumberOfInstances());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getProcedureReference())
      tgt.addProcedureReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getProcedureCode())
      tgt.addProcedureCode(convertCodeableConcept(t));
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent t : src.getSeries())
      tgt.addSeries(convertImagingStudySeriesComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImagingStudy convertImagingStudy(org.hl7.fhir.r4.model.ImagingStudy src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImagingStudy tgt = new org.hl7.fhir.dstu3.model.ImagingStudy();
    copyDomainResource(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasAccession())
      tgt.setAccession(convertIdentifier(src.getAccession()));
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasAvailability())
      tgt.setAvailability(convertInstanceAvailability(src.getAvailability()));
    for (org.hl7.fhir.r4.model.Coding t : src.getModalityList())
      tgt.addModalityList(convertCoding(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasStarted())
      tgt.setStarted(src.getStarted());
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasReferrer())
      tgt.setReferrer(convertReference(src.getReferrer()));
    for (org.hl7.fhir.r4.model.Reference t : src.getInterpreter())
      tgt.addInterpreter(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    if (src.hasNumberOfSeries())
      tgt.setNumberOfSeries(src.getNumberOfSeries());
    if (src.hasNumberOfInstances())
      tgt.setNumberOfInstances(src.getNumberOfInstances());
    for (org.hl7.fhir.r4.model.Reference t : src.getProcedureReference())
      tgt.addProcedureReference(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProcedureCode())
      tgt.addProcedureCode(convertCodeableConcept(t));
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent t : src.getSeries())
      tgt.addSeries(convertImagingStudySeriesComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent convertImagingStudySeriesComponent(org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent tgt = new org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasNumber())
      tgt.setNumber(src.getNumber());
    if (src.hasModality())
      tgt.setModality(convertCoding(src.getModality()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasNumberOfInstances())
      tgt.setNumberOfInstances(src.getNumberOfInstances());
    if (src.hasAvailability())
      tgt.setAvailability(convertInstanceAvailability(src.getAvailability()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCoding(src.getBodySite()));
    if (src.hasLaterality())
      tgt.setLaterality(convertCoding(src.getLaterality()));
    if (src.hasStarted())
      tgt.setStarted(src.getStarted());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPerformer())
      tgt.addPerformer(convertReference(t));
    for (org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent t : src.getInstance())
      tgt.addInstance(convertImagingStudySeriesInstanceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent convertImagingStudySeriesComponent(org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent tgt = new org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasNumber())
      tgt.setNumber(src.getNumber());
    if (src.hasModality())
      tgt.setModality(convertCoding(src.getModality()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasNumberOfInstances())
      tgt.setNumberOfInstances(src.getNumberOfInstances());
    if (src.hasAvailability())
      tgt.setAvailability(convertInstanceAvailability(src.getAvailability()));
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCoding(src.getBodySite()));
    if (src.hasLaterality())
      tgt.setLaterality(convertCoding(src.getLaterality()));
    if (src.hasStarted())
      tgt.setStarted(src.getStarted());
    for (org.hl7.fhir.r4.model.Reference t : src.getPerformer())
      tgt.addPerformer(convertReference(t));
    for (org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent t : src.getInstance())
      tgt.addInstance(convertImagingStudySeriesInstanceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent convertImagingStudySeriesInstanceComponent(org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent tgt = new org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasNumber())
      tgt.setNumber(src.getNumber());
    if (src.hasSopClass())
      tgt.setSopClass(src.getSopClass());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent convertImagingStudySeriesInstanceComponent(org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent tgt = new org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasNumber())
      tgt.setNumber(src.getNumber());
    if (src.hasSopClass())
      tgt.setSopClass(src.getSopClass());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Immunization convertImmunization(org.hl7.fhir.dstu3.model.Immunization src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Immunization tgt = new org.hl7.fhir.r4.model.Immunization();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertImmunizationStatus(src.getStatus()));
    if (src.hasNotGiven())
      tgt.setNotGiven(src.getNotGiven());
    if (src.hasVaccineCode())
      tgt.setVaccineCode(convertCodeableConcept(src.getVaccineCode()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPrimarySource())
      tgt.setPrimarySource(src.getPrimarySource());
    if (src.hasReportOrigin())
      tgt.setReportOrigin(convertCodeableConcept(src.getReportOrigin()));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    if (src.hasManufacturer())
      tgt.setManufacturer(convertReference(src.getManufacturer()));
    if (src.hasLotNumber())
      tgt.setLotNumber(src.getLotNumber());
    if (src.hasExpirationDate())
      tgt.setExpirationDate(src.getExpirationDate());
    if (src.hasSite())
      tgt.setSite(convertCodeableConcept(src.getSite()));
    if (src.hasRoute())
      tgt.setRoute(convertCodeableConcept(src.getRoute()));
    if (src.hasDoseQuantity())
      tgt.setDoseQuantity(convertSimpleQuantity(src.getDoseQuantity()));
    for (org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent t : src.getPractitioner())
      tgt.addPractitioner(convertImmunizationPractitionerComponent(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    if (src.hasExplanation())
      tgt.setExplanation(convertImmunizationExplanationComponent(src.getExplanation()));
    for (org.hl7.fhir.dstu3.model.Immunization.ImmunizationReactionComponent t : src.getReaction())
      tgt.addReaction(convertImmunizationReactionComponent(t));
    for (org.hl7.fhir.dstu3.model.Immunization.ImmunizationVaccinationProtocolComponent t : src.getVaccinationProtocol())
      tgt.addVaccinationProtocol(convertImmunizationVaccinationProtocolComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Immunization convertImmunization(org.hl7.fhir.r4.model.Immunization src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Immunization tgt = new org.hl7.fhir.dstu3.model.Immunization();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertImmunizationStatus(src.getStatus()));
    if (src.hasNotGiven())
      tgt.setNotGiven(src.getNotGiven());
    if (src.hasVaccineCode())
      tgt.setVaccineCode(convertCodeableConcept(src.getVaccineCode()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPrimarySource())
      tgt.setPrimarySource(src.getPrimarySource());
    if (src.hasReportOrigin())
      tgt.setReportOrigin(convertCodeableConcept(src.getReportOrigin()));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    if (src.hasManufacturer())
      tgt.setManufacturer(convertReference(src.getManufacturer()));
    if (src.hasLotNumber())
      tgt.setLotNumber(src.getLotNumber());
    if (src.hasExpirationDate())
      tgt.setExpirationDate(src.getExpirationDate());
    if (src.hasSite())
      tgt.setSite(convertCodeableConcept(src.getSite()));
    if (src.hasRoute())
      tgt.setRoute(convertCodeableConcept(src.getRoute()));
    if (src.hasDoseQuantity())
      tgt.setDoseQuantity(convertSimpleQuantity(src.getDoseQuantity()));
    for (org.hl7.fhir.r4.model.Immunization.ImmunizationPractitionerComponent t : src.getPractitioner())
      tgt.addPractitioner(convertImmunizationPractitionerComponent(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    if (src.hasExplanation())
      tgt.setExplanation(convertImmunizationExplanationComponent(src.getExplanation()));
    for (org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent t : src.getReaction())
      tgt.addReaction(convertImmunizationReactionComponent(t));
    for (org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent t : src.getVaccinationProtocol())
      tgt.addVaccinationProtocol(convertImmunizationVaccinationProtocolComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Immunization.ImmunizationExplanationComponent convertImmunizationExplanationComponent(org.hl7.fhir.dstu3.model.Immunization.ImmunizationExplanationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Immunization.ImmunizationExplanationComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationExplanationComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonNotGiven())
      tgt.addReasonNotGiven(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Immunization.ImmunizationExplanationComponent convertImmunizationExplanationComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationExplanationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Immunization.ImmunizationExplanationComponent tgt = new org.hl7.fhir.dstu3.model.Immunization.ImmunizationExplanationComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonNotGiven())
      tgt.addReasonNotGiven(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Immunization.ImmunizationPractitionerComponent convertImmunizationPractitionerComponent(org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Immunization.ImmunizationPractitionerComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationPractitionerComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent convertImmunizationPractitionerComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationPractitionerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent tgt = new org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent convertImmunizationReactionComponent(org.hl7.fhir.dstu3.model.Immunization.ImmunizationReactionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent();
    copyElement(src, tgt);
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasDetail())
      tgt.setDetail(convertReference(src.getDetail()));
    if (src.hasReported())
      tgt.setReported(src.getReported());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Immunization.ImmunizationReactionComponent convertImmunizationReactionComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Immunization.ImmunizationReactionComponent tgt = new org.hl7.fhir.dstu3.model.Immunization.ImmunizationReactionComponent();
    copyElement(src, tgt);
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasDetail())
      tgt.setDetail(convertReference(src.getDetail()));
    if (src.hasReported())
      tgt.setReported(src.getReported());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImmunizationRecommendation convertImmunizationRecommendation(org.hl7.fhir.dstu3.model.ImmunizationRecommendation src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImmunizationRecommendation tgt = new org.hl7.fhir.r4.model.ImmunizationRecommendation();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    for (org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent t : src.getRecommendation())
      tgt.addRecommendation(convertImmunizationRecommendationRecommendationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImmunizationRecommendation convertImmunizationRecommendation(org.hl7.fhir.r4.model.ImmunizationRecommendation src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImmunizationRecommendation tgt = new org.hl7.fhir.dstu3.model.ImmunizationRecommendation();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    for (org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent t : src.getRecommendation())
      tgt.addRecommendation(convertImmunizationRecommendationRecommendationComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent convertImmunizationRecommendationRecommendationComponent(org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent tgt = new org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent();
    copyElement(src, tgt);
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasVaccineCode())
      tgt.setVaccineCode(convertCodeableConcept(src.getVaccineCode()));
    if (src.hasTargetDisease())
      tgt.setTargetDisease(convertCodeableConcept(src.getTargetDisease()));
    if (src.hasDoseNumber())
      tgt.setDoseNumber(src.getDoseNumber());
    if (src.hasForecastStatus())
      tgt.setForecastStatus(convertCodeableConcept(src.getForecastStatus()));
    for (org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent t : src.getDateCriterion())
      tgt.addDateCriterion(convertImmunizationRecommendationRecommendationDateCriterionComponent(t));
    if (src.hasProtocol())
      tgt.setProtocol(convertImmunizationRecommendationRecommendationProtocolComponent(src.getProtocol()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingImmunization())
      tgt.addSupportingImmunization(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingPatientInformation())
      tgt.addSupportingPatientInformation(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent convertImmunizationRecommendationRecommendationComponent(org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent tgt = new org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationComponent();
    copyElement(src, tgt);
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasVaccineCode())
      tgt.setVaccineCode(convertCodeableConcept(src.getVaccineCode()));
    if (src.hasTargetDisease())
      tgt.setTargetDisease(convertCodeableConcept(src.getTargetDisease()));
    if (src.hasDoseNumber())
      tgt.setDoseNumber(src.getDoseNumber());
    if (src.hasForecastStatus())
      tgt.setForecastStatus(convertCodeableConcept(src.getForecastStatus()));
    for (org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent t : src.getDateCriterion())
      tgt.addDateCriterion(convertImmunizationRecommendationRecommendationDateCriterionComponent(t));
    if (src.hasProtocol())
      tgt.setProtocol(convertImmunizationRecommendationRecommendationProtocolComponent(src.getProtocol()));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingImmunization())
      tgt.addSupportingImmunization(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingPatientInformation())
      tgt.addSupportingPatientInformation(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent convertImmunizationRecommendationRecommendationDateCriterionComponent(org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent tgt = new org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent convertImmunizationRecommendationRecommendationDateCriterionComponent(org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent tgt = new org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationDateCriterionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent convertImmunizationRecommendationRecommendationProtocolComponent(org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent tgt = new org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent();
    copyElement(src, tgt);
    if (src.hasDoseSequence())
      tgt.setDoseSequence(src.getDoseSequence());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAuthority())
      tgt.setAuthority(convertReference(src.getAuthority()));
    if (src.hasSeries())
      tgt.setSeries(src.getSeries());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent convertImmunizationRecommendationRecommendationProtocolComponent(org.hl7.fhir.r4.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent tgt = new org.hl7.fhir.dstu3.model.ImmunizationRecommendation.ImmunizationRecommendationRecommendationProtocolComponent();
    copyElement(src, tgt);
    if (src.hasDoseSequence())
      tgt.setDoseSequence(src.getDoseSequence());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAuthority())
      tgt.setAuthority(convertReference(src.getAuthority()));
    if (src.hasSeries())
      tgt.setSeries(src.getSeries());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Immunization.ImmunizationStatus convertImmunizationStatus(org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETED: return org.hl7.fhir.r4.model.Immunization.ImmunizationStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Immunization.ImmunizationStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Immunization.ImmunizationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus convertImmunizationStatus(org.hl7.fhir.r4.model.Immunization.ImmunizationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETED: return org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent convertImmunizationVaccinationProtocolComponent(org.hl7.fhir.dstu3.model.Immunization.ImmunizationVaccinationProtocolComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent();
    copyElement(src, tgt);
    if (src.hasDoseSequence())
      tgt.setDoseSequence(src.getDoseSequence());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAuthority())
      tgt.setAuthority(convertReference(src.getAuthority()));
    if (src.hasSeries())
      tgt.setSeries(src.getSeries());
    if (src.hasSeriesDoses())
      tgt.setSeriesDoses(src.getSeriesDoses());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getTargetDisease())
      tgt.addTargetDisease(convertCodeableConcept(t));
    if (src.hasDoseStatus())
      tgt.setDoseStatus(convertCodeableConcept(src.getDoseStatus()));
    if (src.hasDoseStatusReason())
      tgt.setDoseStatusReason(convertCodeableConcept(src.getDoseStatusReason()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Immunization.ImmunizationVaccinationProtocolComponent convertImmunizationVaccinationProtocolComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Immunization.ImmunizationVaccinationProtocolComponent tgt = new org.hl7.fhir.dstu3.model.Immunization.ImmunizationVaccinationProtocolComponent();
    copyElement(src, tgt);
    if (src.hasDoseSequence())
      tgt.setDoseSequence(src.getDoseSequence());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAuthority())
      tgt.setAuthority(convertReference(src.getAuthority()));
    if (src.hasSeries())
      tgt.setSeries(src.getSeries());
    if (src.hasSeriesDoses())
      tgt.setSeriesDoses(src.getSeriesDoses());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getTargetDisease())
      tgt.addTargetDisease(convertCodeableConcept(t));
    if (src.hasDoseStatus())
      tgt.setDoseStatus(convertCodeableConcept(src.getDoseStatus()));
    if (src.hasDoseStatusReason())
      tgt.setDoseStatusReason(convertCodeableConcept(src.getDoseStatusReason()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImplementationGuide convertImplementationGuide(org.hl7.fhir.dstu3.model.ImplementationGuide src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImplementationGuide tgt = new org.hl7.fhir.r4.model.ImplementationGuide();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasFhirVersion())
      tgt.setFhirVersion(src.getFhirVersion());
    for (org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideDependencyComponent t : src.getDependency())
      tgt.addDependency(convertImplementationGuideDependencyComponent(t));
    for (org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageComponent t : src.getPackage())
      tgt.addPackage(convertImplementationGuidePackageComponent(t));
    for (org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideGlobalComponent t : src.getGlobal())
      tgt.addGlobal(convertImplementationGuideGlobalComponent(t));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getBinary())
      tgt.addBinary(t.getValue());
    if (src.hasPage())
      tgt.setPage(convertImplementationGuidePageComponent(src.getPage()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImplementationGuide convertImplementationGuide(org.hl7.fhir.r4.model.ImplementationGuide src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImplementationGuide tgt = new org.hl7.fhir.dstu3.model.ImplementationGuide();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasFhirVersion())
      tgt.setFhirVersion(src.getFhirVersion());
    for (org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDependencyComponent t : src.getDependency())
      tgt.addDependency(convertImplementationGuideDependencyComponent(t));
    for (org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageComponent t : src.getPackage())
      tgt.addPackage(convertImplementationGuidePackageComponent(t));
    for (org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent t : src.getGlobal())
      tgt.addGlobal(convertImplementationGuideGlobalComponent(t));
    for (org.hl7.fhir.r4.model.UriType t : src.getBinary())
      tgt.addBinary(t.getValue());
    if (src.hasPage())
      tgt.setPage(convertImplementationGuidePageComponent(src.getPage()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDependencyComponent convertImplementationGuideDependencyComponent(org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideDependencyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDependencyComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDependencyComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertGuideDependencyType(src.getType()));
    if (src.hasUri())
      tgt.setUri(src.getUri());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideDependencyComponent convertImplementationGuideDependencyComponent(org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDependencyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideDependencyComponent tgt = new org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideDependencyComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertGuideDependencyType(src.getType()));
    if (src.hasUri())
      tgt.setUri(src.getUri());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent convertImplementationGuideGlobalComponent(org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideGlobalComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideGlobalComponent convertImplementationGuideGlobalComponent(org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideGlobalComponent tgt = new org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuideGlobalComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageComponent convertImplementationGuidePackageComponent(org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageResourceComponent t : src.getResource())
      tgt.addResource(convertImplementationGuidePackageResourceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageComponent convertImplementationGuidePackageComponent(org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageComponent tgt = new org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageResourceComponent t : src.getResource())
      tgt.addResource(convertImplementationGuidePackageResourceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageResourceComponent convertImplementationGuidePackageResourceComponent(org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageResourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageResourceComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageResourceComponent();
    copyElement(src, tgt);
    if (src.hasExample())
      tgt.setExample(src.getExample());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAcronym())
      tgt.setAcronym(src.getAcronym());
    if (src.hasSource())
      tgt.setSource(convertType(src.getSource()));
    if (src.hasExampleFor())
      tgt.setExampleFor(convertReference(src.getExampleFor()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageResourceComponent convertImplementationGuidePackageResourceComponent(org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageResourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageResourceComponent tgt = new org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePackageResourceComponent();
    copyElement(src, tgt);
    if (src.hasExample())
      tgt.setExample(src.getExample());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAcronym())
      tgt.setAcronym(src.getAcronym());
    if (src.hasSource())
      tgt.setSource(convertType(src.getSource()));
    if (src.hasExampleFor())
      tgt.setExampleFor(convertReference(src.getExampleFor()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePageComponent convertImplementationGuidePageComponent(org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePageComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePageComponent();
    copyElement(src, tgt);
    if (src.hasSource())
      tgt.setSource(src.getSource());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasKind())
      tgt.setKind(convertGuidePageKind(src.getKind()));
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getType())
      tgt.addType(t.getValue());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getPackage())
      tgt.addPackage(t.getValue());
    if (src.hasFormat())
      tgt.setFormat(src.getFormat());
    for (org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePageComponent t : src.getPage())
      tgt.addPage(convertImplementationGuidePageComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePageComponent convertImplementationGuidePageComponent(org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePageComponent tgt = new org.hl7.fhir.dstu3.model.ImplementationGuide.ImplementationGuidePageComponent();
    copyElement(src, tgt);
    if (src.hasSource())
      tgt.setSource(src.getSource());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasKind())
      tgt.setKind(convertGuidePageKind(src.getKind()));
    for (org.hl7.fhir.r4.model.CodeType t : src.getType())
      tgt.addType(t.getValue());
    for (org.hl7.fhir.r4.model.StringType t : src.getPackage())
      tgt.addPackage(t.getValue());
    if (src.hasFormat())
      tgt.setFormat(src.getFormat());
    for (org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePageComponent t : src.getPage())
      tgt.addPage(convertImplementationGuidePageComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability convertInstanceAvailability(org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ONLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.ONLINE;
    case OFFLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.OFFLINE;
    case NEARLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.NEARLINE;
    case UNAVAILABLE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.UNAVAILABLE;
    default: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability convertInstanceAvailability(org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ONLINE: return org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability.ONLINE;
    case OFFLINE: return org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability.OFFLINE;
    case NEARLINE: return org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability.NEARLINE;
    case UNAVAILABLE: return org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability.UNAVAILABLE;
    default: return org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ImagingManifest.InstanceComponent convertInstanceComponent(org.hl7.fhir.dstu3.model.ImagingManifest.InstanceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImagingManifest.InstanceComponent tgt = new org.hl7.fhir.r4.model.ImagingManifest.InstanceComponent();
    copyElement(src, tgt);
    if (src.hasSopClass())
      tgt.setSopClass(src.getSopClass());
    if (src.hasUid())
      tgt.setUid(src.getUid());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImagingManifest.InstanceComponent convertInstanceComponent(org.hl7.fhir.r4.model.ImagingManifest.InstanceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImagingManifest.InstanceComponent tgt = new org.hl7.fhir.dstu3.model.ImagingManifest.InstanceComponent();
    copyElement(src, tgt);
    if (src.hasSopClass())
      tgt.setSopClass(src.getSopClass());
    if (src.hasUid())
      tgt.setUid(src.getUid());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException {
    org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Claim.InsuranceComponent convertInsuranceComponent(org.hl7.fhir.dstu3.model.Claim.InsuranceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.InsuranceComponent tgt = new org.hl7.fhir.r4.model.Claim.InsuranceComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasFocal())
      tgt.setFocal(src.getFocal());
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasBusinessArrangement())
      tgt.setBusinessArrangement(src.getBusinessArrangement());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getPreAuthRef())
      tgt.addPreAuthRef(t.getValue());
    if (src.hasClaimResponse())
      tgt.setClaimResponse(convertReference(src.getClaimResponse()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.InsuranceComponent convertInsuranceComponent(org.hl7.fhir.r4.model.Claim.InsuranceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.InsuranceComponent tgt = new org.hl7.fhir.dstu3.model.Claim.InsuranceComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasFocal())
      tgt.setFocal(src.getFocal());
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasBusinessArrangement())
      tgt.setBusinessArrangement(src.getBusinessArrangement());
    for (org.hl7.fhir.r4.model.StringType t : src.getPreAuthRef())
      tgt.addPreAuthRef(t.getValue());
    if (src.hasClaimResponse())
      tgt.setClaimResponse(convertReference(src.getClaimResponse()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.EligibilityResponse.InsuranceComponent convertInsuranceComponent(org.hl7.fhir.dstu3.model.EligibilityResponse.InsuranceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.EligibilityResponse.InsuranceComponent tgt = new org.hl7.fhir.r4.model.EligibilityResponse.InsuranceComponent();
    copyElement(src, tgt);
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasContract())
      tgt.setContract(convertReference(src.getContract()));
    for (org.hl7.fhir.dstu3.model.EligibilityResponse.BenefitsComponent t : src.getBenefitBalance())
      tgt.addBenefitBalance(convertBenefitsComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.EligibilityResponse.InsuranceComponent convertInsuranceComponent(org.hl7.fhir.r4.model.EligibilityResponse.InsuranceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.EligibilityResponse.InsuranceComponent tgt = new org.hl7.fhir.dstu3.model.EligibilityResponse.InsuranceComponent();
    copyElement(src, tgt);
    if (src.hasCoverage())
      tgt.setCoverage(convertReference(src.getCoverage()));
    if (src.hasContract())
      tgt.setContract(convertReference(src.getContract()));
    for (org.hl7.fhir.r4.model.EligibilityResponse.BenefitsComponent t : src.getBenefitBalance())
      tgt.addBenefitBalance(convertBenefitsComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException {
    org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.IntegerType tgt = new org.hl7.fhir.dstu3.model.IntegerType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  private static org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity convertIssueSeverity(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FATAL: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.FATAL;
    case ERROR: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.ERROR;
    case WARNING: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.WARNING;
    case INFORMATION: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.INFORMATION;
    default: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity convertIssueSeverity(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FATAL: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.FATAL;
    case ERROR: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.ERROR;
    case WARNING: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.WARNING;
    case INFORMATION: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.INFORMATION;
    default: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.NULL;
  }
}

  private static org.hl7.fhir.r4.model.OperationOutcome.IssueType convertIssueType(org.hl7.fhir.dstu3.model.OperationOutcome.IssueType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INVALID: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVALID;
    case STRUCTURE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.STRUCTURE;
    case REQUIRED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.REQUIRED;
    case VALUE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.VALUE;
    case INVARIANT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVARIANT;
    case SECURITY: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.SECURITY;
    case LOGIN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOGIN;
    case UNKNOWN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.UNKNOWN;
    case EXPIRED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXPIRED;
    case FORBIDDEN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.FORBIDDEN;
    case SUPPRESSED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.SUPPRESSED;
    case PROCESSING: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.PROCESSING;
    case NOTSUPPORTED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTSUPPORTED;
    case DUPLICATE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.DUPLICATE;
    case NOTFOUND: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTFOUND;
    case TOOLONG: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOLONG;
    case CODEINVALID: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.CODEINVALID;
    case EXTENSION: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXTENSION;
    case TOOCOSTLY: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOCOSTLY;
    case BUSINESSRULE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.BUSINESSRULE;
    case CONFLICT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.CONFLICT;
    case INCOMPLETE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INCOMPLETE;
    case TRANSIENT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TRANSIENT;
    case LOCKERROR: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOCKERROR;
    case NOSTORE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOSTORE;
    case EXCEPTION: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXCEPTION;
    case TIMEOUT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TIMEOUT;
    case THROTTLED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.THROTTLED;
    case INFORMATIONAL: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INFORMATIONAL;
    default: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.OperationOutcome.IssueType convertIssueType(org.hl7.fhir.r4.model.OperationOutcome.IssueType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INVALID: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.INVALID;
    case STRUCTURE: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.STRUCTURE;
    case REQUIRED: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.REQUIRED;
    case VALUE: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.VALUE;
    case INVARIANT: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.INVARIANT;
    case SECURITY: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.SECURITY;
    case LOGIN: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.LOGIN;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.UNKNOWN;
    case EXPIRED: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.EXPIRED;
    case FORBIDDEN: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.FORBIDDEN;
    case SUPPRESSED: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.SUPPRESSED;
    case PROCESSING: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.PROCESSING;
    case NOTSUPPORTED: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.NOTSUPPORTED;
    case DUPLICATE: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.DUPLICATE;
    case NOTFOUND: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.NOTFOUND;
    case TOOLONG: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.TOOLONG;
    case CODEINVALID: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.CODEINVALID;
    case EXTENSION: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.EXTENSION;
    case TOOCOSTLY: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.TOOCOSTLY;
    case BUSINESSRULE: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.BUSINESSRULE;
    case CONFLICT: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.CONFLICT;
    case INCOMPLETE: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.INCOMPLETE;
    case TRANSIENT: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.TRANSIENT;
    case LOCKERROR: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.LOCKERROR;
    case NOSTORE: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.NOSTORE;
    case EXCEPTION: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.EXCEPTION;
    case TIMEOUT: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.TIMEOUT;
    case THROTTLED: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.THROTTLED;
    case INFORMATIONAL: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.INFORMATIONAL;
    default: return org.hl7.fhir.dstu3.model.OperationOutcome.IssueType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Claim.ItemComponent convertItemComponent(org.hl7.fhir.dstu3.model.Claim.ItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.ItemComponent tgt = new org.hl7.fhir.r4.model.Claim.ItemComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    for (org.hl7.fhir.dstu3.model.PositiveIntType t : src.getCareTeamLinkId())
      tgt.addCareTeamLinkId(t.getValue());
    for (org.hl7.fhir.dstu3.model.PositiveIntType t : src.getDiagnosisLinkId())
      tgt.addDiagnosisLinkId(t.getValue());
    for (org.hl7.fhir.dstu3.model.PositiveIntType t : src.getProcedureLinkId())
      tgt.addProcedureLinkId(t.getValue());
    for (org.hl7.fhir.dstu3.model.PositiveIntType t : src.getInformationLinkId())
      tgt.addInformationLinkId(t.getValue());
    if (src.hasRevenue())
      tgt.setRevenue(convertCodeableConcept(src.getRevenue()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasService())
      tgt.setService(convertCodeableConcept(src.getService()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getModifier())
      tgt.addModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getProgramCode())
      tgt.addProgramCode(convertCodeableConcept(t));
    if (src.hasServiced())
      tgt.setServiced(convertType(src.getServiced()));
    if (src.hasLocation())
      tgt.setLocation(convertType(src.getLocation()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getUdi())
      tgt.addUdi(convertReference(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSubSite())
      tgt.addSubSite(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEncounter())
      tgt.addEncounter(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Claim.DetailComponent t : src.getDetail())
      tgt.addDetail(convertDetailComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.ItemComponent convertItemComponent(org.hl7.fhir.r4.model.Claim.ItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.ItemComponent tgt = new org.hl7.fhir.dstu3.model.Claim.ItemComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    for (org.hl7.fhir.r4.model.PositiveIntType t : src.getCareTeamLinkId())
      tgt.addCareTeamLinkId(t.getValue());
    for (org.hl7.fhir.r4.model.PositiveIntType t : src.getDiagnosisLinkId())
      tgt.addDiagnosisLinkId(t.getValue());
    for (org.hl7.fhir.r4.model.PositiveIntType t : src.getProcedureLinkId())
      tgt.addProcedureLinkId(t.getValue());
    for (org.hl7.fhir.r4.model.PositiveIntType t : src.getInformationLinkId())
      tgt.addInformationLinkId(t.getValue());
    if (src.hasRevenue())
      tgt.setRevenue(convertCodeableConcept(src.getRevenue()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasService())
      tgt.setService(convertCodeableConcept(src.getService()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getModifier())
      tgt.addModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProgramCode())
      tgt.addProgramCode(convertCodeableConcept(t));
    if (src.hasServiced())
      tgt.setServiced(convertType(src.getServiced()));
    if (src.hasLocation())
      tgt.setLocation(convertType(src.getLocation()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    for (org.hl7.fhir.r4.model.Reference t : src.getUdi())
      tgt.addUdi(convertReference(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSubSite())
      tgt.addSubSite(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getEncounter())
      tgt.addEncounter(convertReference(t));
    for (org.hl7.fhir.r4.model.Claim.DetailComponent t : src.getDetail())
      tgt.addDetail(convertDetailComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent();
    copyElement(src, tgt);
    if (src.hasSequenceLinkId())
      tgt.setSequenceLinkId(src.getSequenceLinkId());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent();
    copyElement(src, tgt);
    if (src.hasSequenceLinkId())
      tgt.setSequenceLinkId(src.getSequenceLinkId());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Contract.LegalLanguageComponent convertLegalLanguageComponent(org.hl7.fhir.dstu3.model.Contract.LegalLanguageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.LegalLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.LegalLanguageComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.LegalLanguageComponent convertLegalLanguageComponent(org.hl7.fhir.r4.model.Contract.LegalLanguageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.LegalLanguageComponent tgt = new org.hl7.fhir.dstu3.model.Contract.LegalLanguageComponent();
    copyElement(src, tgt);
    if (src.hasContent())
      tgt.setContent(convertType(src.getContent()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Patient.LinkType convertLinkType(org.hl7.fhir.dstu3.model.Patient.LinkType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REPLACEDBY: return org.hl7.fhir.r4.model.Patient.LinkType.REPLACEDBY;
    case REPLACES: return org.hl7.fhir.r4.model.Patient.LinkType.REPLACES;
    case REFER: return org.hl7.fhir.r4.model.Patient.LinkType.REFER;
    case SEEALSO: return org.hl7.fhir.r4.model.Patient.LinkType.SEEALSO;
    default: return org.hl7.fhir.r4.model.Patient.LinkType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Patient.LinkType convertLinkType(org.hl7.fhir.r4.model.Patient.LinkType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REPLACEDBY: return org.hl7.fhir.dstu3.model.Patient.LinkType.REPLACEDBY;
    case REPLACES: return org.hl7.fhir.dstu3.model.Patient.LinkType.REPLACES;
    case REFER: return org.hl7.fhir.dstu3.model.Patient.LinkType.REFER;
    case SEEALSO: return org.hl7.fhir.dstu3.model.Patient.LinkType.SEEALSO;
    default: return org.hl7.fhir.dstu3.model.Patient.LinkType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Linkage convertLinkage(org.hl7.fhir.dstu3.model.Linkage src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Linkage tgt = new org.hl7.fhir.r4.model.Linkage();
    copyDomainResource(src, tgt);
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    for (org.hl7.fhir.dstu3.model.Linkage.LinkageItemComponent t : src.getItem())
      tgt.addItem(convertLinkageItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Linkage convertLinkage(org.hl7.fhir.r4.model.Linkage src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Linkage tgt = new org.hl7.fhir.dstu3.model.Linkage();
    copyDomainResource(src, tgt);
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    for (org.hl7.fhir.r4.model.Linkage.LinkageItemComponent t : src.getItem())
      tgt.addItem(convertLinkageItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Linkage.LinkageItemComponent convertLinkageItemComponent(org.hl7.fhir.dstu3.model.Linkage.LinkageItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Linkage.LinkageItemComponent tgt = new org.hl7.fhir.r4.model.Linkage.LinkageItemComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertLinkageType(src.getType()));
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Linkage.LinkageItemComponent convertLinkageItemComponent(org.hl7.fhir.r4.model.Linkage.LinkageItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Linkage.LinkageItemComponent tgt = new org.hl7.fhir.dstu3.model.Linkage.LinkageItemComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertLinkageType(src.getType()));
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Linkage.LinkageType convertLinkageType(org.hl7.fhir.dstu3.model.Linkage.LinkageType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SOURCE: return org.hl7.fhir.r4.model.Linkage.LinkageType.SOURCE;
    case ALTERNATE: return org.hl7.fhir.r4.model.Linkage.LinkageType.ALTERNATE;
    case HISTORICAL: return org.hl7.fhir.r4.model.Linkage.LinkageType.HISTORICAL;
    default: return org.hl7.fhir.r4.model.Linkage.LinkageType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Linkage.LinkageType convertLinkageType(org.hl7.fhir.r4.model.Linkage.LinkageType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SOURCE: return org.hl7.fhir.dstu3.model.Linkage.LinkageType.SOURCE;
    case ALTERNATE: return org.hl7.fhir.dstu3.model.Linkage.LinkageType.ALTERNATE;
    case HISTORICAL: return org.hl7.fhir.dstu3.model.Linkage.LinkageType.HISTORICAL;
    default: return org.hl7.fhir.dstu3.model.Linkage.LinkageType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ListResource convertList(org.hl7.fhir.dstu3.model.ListResource src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ListResource tgt = new org.hl7.fhir.r4.model.ListResource();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertListStatus(src.getStatus()));
    if (src.hasMode())
      tgt.setMode(convertListMode(src.getMode()));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasOrderedBy())
      tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy()));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent t : src.getEntry())
      tgt.addEntry(convertListEntryComponent(t));
    if (src.hasEmptyReason())
      tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ListResource convertList(org.hl7.fhir.r4.model.ListResource src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ListResource tgt = new org.hl7.fhir.dstu3.model.ListResource();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertListStatus(src.getStatus()));
    if (src.hasMode())
      tgt.setMode(convertListMode(src.getMode()));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    if (src.hasOrderedBy())
      tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy()));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.ListResource.ListEntryComponent t : src.getEntry())
      tgt.addEntry(convertListEntryComponent(t));
    if (src.hasEmptyReason())
      tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ListResource.ListEntryComponent convertListEntryComponent(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.r4.model.ListResource.ListEntryComponent();
    copyElement(src, tgt);
    if (src.hasFlag())
      tgt.setFlag(convertCodeableConcept(src.getFlag()));
    if (src.hasDeleted())
      tgt.setDeleted(src.getDeleted());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasItem())
      tgt.setItem(convertReference(src.getItem()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent convertListEntryComponent(org.hl7.fhir.r4.model.ListResource.ListEntryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent();
    copyElement(src, tgt);
    if (src.hasFlag())
      tgt.setFlag(convertCodeableConcept(src.getFlag()));
    if (src.hasDeleted())
      tgt.setDeleted(src.getDeleted());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasItem())
      tgt.setItem(convertReference(src.getItem()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ListResource.ListMode convertListMode(org.hl7.fhir.dstu3.model.ListResource.ListMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case WORKING: return org.hl7.fhir.r4.model.ListResource.ListMode.WORKING;
    case SNAPSHOT: return org.hl7.fhir.r4.model.ListResource.ListMode.SNAPSHOT;
    case CHANGES: return org.hl7.fhir.r4.model.ListResource.ListMode.CHANGES;
    default: return org.hl7.fhir.r4.model.ListResource.ListMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ListResource.ListMode convertListMode(org.hl7.fhir.r4.model.ListResource.ListMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case WORKING: return org.hl7.fhir.dstu3.model.ListResource.ListMode.WORKING;
    case SNAPSHOT: return org.hl7.fhir.dstu3.model.ListResource.ListMode.SNAPSHOT;
    case CHANGES: return org.hl7.fhir.dstu3.model.ListResource.ListMode.CHANGES;
    default: return org.hl7.fhir.dstu3.model.ListResource.ListMode.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ListResource.ListStatus convertListStatus(org.hl7.fhir.dstu3.model.ListResource.ListStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CURRENT: return org.hl7.fhir.r4.model.ListResource.ListStatus.CURRENT;
    case RETIRED: return org.hl7.fhir.r4.model.ListResource.ListStatus.RETIRED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.ListResource.ListStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.ListResource.ListStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ListResource.ListStatus convertListStatus(org.hl7.fhir.r4.model.ListResource.ListStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CURRENT: return org.hl7.fhir.dstu3.model.ListResource.ListStatus.CURRENT;
    case RETIRED: return org.hl7.fhir.dstu3.model.ListResource.ListStatus.RETIRED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.ListResource.ListStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.ListResource.ListStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Location convertLocation(org.hl7.fhir.dstu3.model.Location src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Location tgt = new org.hl7.fhir.r4.model.Location();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertLocationStatus(src.getStatus()));
    if (src.hasOperationalStatus())
      tgt.setOperationalStatus(convertCoding(src.getOperationalStatus()));
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias())
      tgt.addAlias(t.getValue());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasMode())
      tgt.setMode(convertLocationMode(src.getMode()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasAddress())
      tgt.setAddress(convertAddress(src.getAddress()));
    if (src.hasPhysicalType())
      tgt.setPhysicalType(convertCodeableConcept(src.getPhysicalType()));
    if (src.hasPosition())
      tgt.setPosition(convertLocationPositionComponent(src.getPosition()));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    if (src.hasPartOf())
      tgt.setPartOf(convertReference(src.getPartOf()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Location convertLocation(org.hl7.fhir.r4.model.Location src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Location tgt = new org.hl7.fhir.dstu3.model.Location();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertLocationStatus(src.getStatus()));
    if (src.hasOperationalStatus())
      tgt.setOperationalStatus(convertCoding(src.getOperationalStatus()));
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.r4.model.StringType t : src.getAlias())
      tgt.addAlias(t.getValue());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasMode())
      tgt.setMode(convertLocationMode(src.getMode()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasAddress())
      tgt.setAddress(convertAddress(src.getAddress()));
    if (src.hasPhysicalType())
      tgt.setPhysicalType(convertCodeableConcept(src.getPhysicalType()));
    if (src.hasPosition())
      tgt.setPosition(convertLocationPositionComponent(src.getPosition()));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    if (src.hasPartOf())
      tgt.setPartOf(convertReference(src.getPartOf()));
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Location.LocationMode convertLocationMode(org.hl7.fhir.dstu3.model.Location.LocationMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INSTANCE: return org.hl7.fhir.r4.model.Location.LocationMode.INSTANCE;
    case KIND: return org.hl7.fhir.r4.model.Location.LocationMode.KIND;
    default: return org.hl7.fhir.r4.model.Location.LocationMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Location.LocationMode convertLocationMode(org.hl7.fhir.r4.model.Location.LocationMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INSTANCE: return org.hl7.fhir.dstu3.model.Location.LocationMode.INSTANCE;
    case KIND: return org.hl7.fhir.dstu3.model.Location.LocationMode.KIND;
    default: return org.hl7.fhir.dstu3.model.Location.LocationMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.dstu3.model.Location.LocationPositionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.r4.model.Location.LocationPositionComponent();
    copyElement(src, tgt);
    if (src.hasLongitude())
      tgt.setLongitude(src.getLongitude());
    if (src.hasLatitude())
      tgt.setLatitude(src.getLatitude());
    if (src.hasAltitude())
      tgt.setAltitude(src.getAltitude());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.dstu3.model.Location.LocationPositionComponent();
    copyElement(src, tgt);
    if (src.hasLongitude())
      tgt.setLongitude(src.getLongitude());
    if (src.hasLatitude())
      tgt.setLatitude(src.getLatitude());
    if (src.hasAltitude())
      tgt.setAltitude(src.getAltitude());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Location.LocationStatus convertLocationStatus(org.hl7.fhir.dstu3.model.Location.LocationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Location.LocationStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.Location.LocationStatus.SUSPENDED;
    case INACTIVE: return org.hl7.fhir.r4.model.Location.LocationStatus.INACTIVE;
    default: return org.hl7.fhir.r4.model.Location.LocationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Location.LocationStatus convertLocationStatus(org.hl7.fhir.r4.model.Location.LocationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Location.LocationStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.Location.LocationStatus.SUSPENDED;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Location.LocationStatus.INACTIVE;
    default: return org.hl7.fhir.dstu3.model.Location.LocationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException {
    org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.MarkdownType tgt = new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  private static org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple convertMeasmntPrinciple(org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OTHER: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.OTHER;
    case CHEMICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.CHEMICAL;
    case ELECTRICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.ELECTRICAL;
    case IMPEDANCE: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.IMPEDANCE;
    case NUCLEAR: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.NUCLEAR;
    case OPTICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.OPTICAL;
    case THERMAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.THERMAL;
    case BIOLOGICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.BIOLOGICAL;
    case MECHANICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.MECHANICAL;
    case ACOUSTICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.ACOUSTICAL;
    case MANUAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.MANUAL;
    default: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple convertMeasmntPrinciple(org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OTHER: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.OTHER;
    case CHEMICAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.CHEMICAL;
    case ELECTRICAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.ELECTRICAL;
    case IMPEDANCE: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.IMPEDANCE;
    case NUCLEAR: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.NUCLEAR;
    case OPTICAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.OPTICAL;
    case THERMAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.THERMAL;
    case BIOLOGICAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.BIOLOGICAL;
    case MECHANICAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.MECHANICAL;
    case ACOUSTICAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.ACOUSTICAL;
    case MANUAL: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.MANUAL;
    default: return org.hl7.fhir.dstu3.model.DeviceComponent.MeasmntPrinciple.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Measure convertMeasure(org.hl7.fhir.dstu3.model.Measure src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Measure tgt = new org.hl7.fhir.r4.model.Measure();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasUsage())
      tgt.setUsage(src.getUsage());
    if (src.hasApprovalDate())
      tgt.setApprovalDate(src.getApprovalDate());
    if (src.hasLastReviewDate())
      tgt.setLastReviewDate(src.getLastReviewDate());
    if (src.hasEffectivePeriod())
      tgt.setEffectivePeriod(convertPeriod(src.getEffectivePeriod()));
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getTopic())
      tgt.addTopic(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Contributor t : src.getContributor())
      tgt.addContributor(convertContributor(t));
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.dstu3.model.RelatedArtifact t : src.getRelatedArtifact())
      tgt.addRelatedArtifact(convertRelatedArtifact(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getLibrary())
      tgt.addLibrary(convertReference(t));
    if (src.hasDisclaimer())
      tgt.setDisclaimer(src.getDisclaimer());
    if (src.hasScoring())
      tgt.setScoring(convertCodeableConcept(src.getScoring()));
    if (src.hasCompositeScoring())
      tgt.setCompositeScoring(convertCodeableConcept(src.getCompositeScoring()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasRiskAdjustment())
      tgt.setRiskAdjustment(src.getRiskAdjustment());
    if (src.hasRateAggregation())
      tgt.setRateAggregation(src.getRateAggregation());
    if (src.hasRationale())
      tgt.setRationale(src.getRationale());
    if (src.hasClinicalRecommendationStatement())
      tgt.setClinicalRecommendationStatement(src.getClinicalRecommendationStatement());
    if (src.hasImprovementNotation())
      tgt.setImprovementNotation(src.getImprovementNotation());
    for (org.hl7.fhir.dstu3.model.MarkdownType t : src.getDefinition())
      tgt.addDefinition(t.getValue());
    if (src.hasGuidance())
      tgt.setGuidance(src.getGuidance());
    if (src.hasSet())
      tgt.setSet(src.getSet());
    for (org.hl7.fhir.dstu3.model.Measure.MeasureGroupComponent t : src.getGroup())
      tgt.addGroup(convertMeasureGroupComponent(t));
    for (org.hl7.fhir.dstu3.model.Measure.MeasureSupplementalDataComponent t : src.getSupplementalData())
      tgt.addSupplementalData(convertMeasureSupplementalDataComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Measure convertMeasure(org.hl7.fhir.r4.model.Measure src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Measure tgt = new org.hl7.fhir.dstu3.model.Measure();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasUsage())
      tgt.setUsage(src.getUsage());
    if (src.hasApprovalDate())
      tgt.setApprovalDate(src.getApprovalDate());
    if (src.hasLastReviewDate())
      tgt.setLastReviewDate(src.getLastReviewDate());
    if (src.hasEffectivePeriod())
      tgt.setEffectivePeriod(convertPeriod(src.getEffectivePeriod()));
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getTopic())
      tgt.addTopic(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Contributor t : src.getContributor())
      tgt.addContributor(convertContributor(t));
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.r4.model.RelatedArtifact t : src.getRelatedArtifact())
      tgt.addRelatedArtifact(convertRelatedArtifact(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getLibrary())
      tgt.addLibrary(convertReference(t));
    if (src.hasDisclaimer())
      tgt.setDisclaimer(src.getDisclaimer());
    if (src.hasScoring())
      tgt.setScoring(convertCodeableConcept(src.getScoring()));
    if (src.hasCompositeScoring())
      tgt.setCompositeScoring(convertCodeableConcept(src.getCompositeScoring()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasRiskAdjustment())
      tgt.setRiskAdjustment(src.getRiskAdjustment());
    if (src.hasRateAggregation())
      tgt.setRateAggregation(src.getRateAggregation());
    if (src.hasRationale())
      tgt.setRationale(src.getRationale());
    if (src.hasClinicalRecommendationStatement())
      tgt.setClinicalRecommendationStatement(src.getClinicalRecommendationStatement());
    if (src.hasImprovementNotation())
      tgt.setImprovementNotation(src.getImprovementNotation());
    for (org.hl7.fhir.r4.model.MarkdownType t : src.getDefinition())
      tgt.addDefinition(t.getValue());
    if (src.hasGuidance())
      tgt.setGuidance(src.getGuidance());
    if (src.hasSet())
      tgt.setSet(src.getSet());
    for (org.hl7.fhir.r4.model.Measure.MeasureGroupComponent t : src.getGroup())
      tgt.addGroup(convertMeasureGroupComponent(t));
    for (org.hl7.fhir.r4.model.Measure.MeasureSupplementalDataComponent t : src.getSupplementalData())
      tgt.addSupplementalData(convertMeasureSupplementalDataComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Measure.MeasureGroupComponent convertMeasureGroupComponent(org.hl7.fhir.dstu3.model.Measure.MeasureGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Measure.MeasureGroupComponent tgt = new org.hl7.fhir.r4.model.Measure.MeasureGroupComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Measure.MeasureGroupPopulationComponent t : src.getPopulation())
      tgt.addPopulation(convertMeasureGroupPopulationComponent(t));
    for (org.hl7.fhir.dstu3.model.Measure.MeasureGroupStratifierComponent t : src.getStratifier())
      tgt.addStratifier(convertMeasureGroupStratifierComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Measure.MeasureGroupComponent convertMeasureGroupComponent(org.hl7.fhir.r4.model.Measure.MeasureGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Measure.MeasureGroupComponent tgt = new org.hl7.fhir.dstu3.model.Measure.MeasureGroupComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.Measure.MeasureGroupPopulationComponent t : src.getPopulation())
      tgt.addPopulation(convertMeasureGroupPopulationComponent(t));
    for (org.hl7.fhir.r4.model.Measure.MeasureGroupStratifierComponent t : src.getStratifier())
      tgt.addStratifier(convertMeasureGroupStratifierComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Measure.MeasureGroupPopulationComponent convertMeasureGroupPopulationComponent(org.hl7.fhir.dstu3.model.Measure.MeasureGroupPopulationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Measure.MeasureGroupPopulationComponent tgt = new org.hl7.fhir.r4.model.Measure.MeasureGroupPopulationComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Measure.MeasureGroupPopulationComponent convertMeasureGroupPopulationComponent(org.hl7.fhir.r4.model.Measure.MeasureGroupPopulationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Measure.MeasureGroupPopulationComponent tgt = new org.hl7.fhir.dstu3.model.Measure.MeasureGroupPopulationComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Measure.MeasureGroupStratifierComponent convertMeasureGroupStratifierComponent(org.hl7.fhir.dstu3.model.Measure.MeasureGroupStratifierComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Measure.MeasureGroupStratifierComponent tgt = new org.hl7.fhir.r4.model.Measure.MeasureGroupStratifierComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Measure.MeasureGroupStratifierComponent convertMeasureGroupStratifierComponent(org.hl7.fhir.r4.model.Measure.MeasureGroupStratifierComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Measure.MeasureGroupStratifierComponent tgt = new org.hl7.fhir.dstu3.model.Measure.MeasureGroupStratifierComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MeasureReport convertMeasureReport(org.hl7.fhir.dstu3.model.MeasureReport src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MeasureReport tgt = new org.hl7.fhir.r4.model.MeasureReport();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertMeasureReportStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertMeasureReportType(src.getType()));
    if (src.hasMeasure())
      tgt.setMeasure(convertReference(src.getMeasure()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasReportingOrganization())
      tgt.setReportingOrganization(convertReference(src.getReportingOrganization()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupComponent t : src.getGroup())
      tgt.addGroup(convertMeasureReportGroupComponent(t));
    if (src.hasEvaluatedResources())
      tgt.setEvaluatedResources(convertReference(src.getEvaluatedResources()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MeasureReport convertMeasureReport(org.hl7.fhir.r4.model.MeasureReport src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MeasureReport tgt = new org.hl7.fhir.dstu3.model.MeasureReport();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertMeasureReportStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertMeasureReportType(src.getType()));
    if (src.hasMeasure())
      tgt.setMeasure(convertReference(src.getMeasure()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasReportingOrganization())
      tgt.setReportingOrganization(convertReference(src.getReportingOrganization()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupComponent t : src.getGroup())
      tgt.addGroup(convertMeasureReportGroupComponent(t));
    if (src.hasEvaluatedResources())
      tgt.setEvaluatedResources(convertReference(src.getEvaluatedResources()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupComponent convertMeasureReportGroupComponent(org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupComponent tgt = new org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupPopulationComponent t : src.getPopulation())
      tgt.addPopulation(convertMeasureReportGroupPopulationComponent(t));
    if (src.hasMeasureScore())
      tgt.setMeasureScore(src.getMeasureScore());
    for (org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupStratifierComponent t : src.getStratifier())
      tgt.addStratifier(convertMeasureReportGroupStratifierComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupComponent convertMeasureReportGroupComponent(org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupComponent tgt = new org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupPopulationComponent t : src.getPopulation())
      tgt.addPopulation(convertMeasureReportGroupPopulationComponent(t));
    if (src.hasMeasureScore())
      tgt.setMeasureScore(src.getMeasureScore());
    for (org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupStratifierComponent t : src.getStratifier())
      tgt.addStratifier(convertMeasureReportGroupStratifierComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupPopulationComponent convertMeasureReportGroupPopulationComponent(org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupPopulationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupPopulationComponent tgt = new org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupPopulationComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    if (src.hasPatients())
      tgt.setPatients(convertReference(src.getPatients()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupPopulationComponent convertMeasureReportGroupPopulationComponent(org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupPopulationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupPopulationComponent tgt = new org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupPopulationComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    if (src.hasPatients())
      tgt.setPatients(convertReference(src.getPatients()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupStratifierComponent convertMeasureReportGroupStratifierComponent(org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupStratifierComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupStratifierComponent tgt = new org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupStratifierComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupComponent t : src.getStratum())
      tgt.addStratum(convertStratifierGroupComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupStratifierComponent convertMeasureReportGroupStratifierComponent(org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupStratifierComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupStratifierComponent tgt = new org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportGroupStratifierComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.r4.model.MeasureReport.StratifierGroupComponent t : src.getStratum())
      tgt.addStratum(convertStratifierGroupComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus convertMeasureReportStatus(org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETE: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus.COMPLETE;
    case PENDING: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus.PENDING;
    case ERROR: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus.ERROR;
    default: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportStatus convertMeasureReportStatus(org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETE: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportStatus.COMPLETE;
    case PENDING: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportStatus.PENDING;
    case ERROR: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportStatus.ERROR;
    default: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.MeasureReport.MeasureReportType convertMeasureReportType(org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INDIVIDUAL: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportType.INDIVIDUAL;
    case PATIENTLIST: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportType.PATIENTLIST;
    case SUMMARY: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportType.SUMMARY;
    default: return org.hl7.fhir.r4.model.MeasureReport.MeasureReportType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportType convertMeasureReportType(org.hl7.fhir.r4.model.MeasureReport.MeasureReportType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INDIVIDUAL: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportType.INDIVIDUAL;
    case PATIENTLIST: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportType.PATIENTLIST;
    case SUMMARY: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportType.SUMMARY;
    default: return org.hl7.fhir.dstu3.model.MeasureReport.MeasureReportType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Measure.MeasureSupplementalDataComponent convertMeasureSupplementalDataComponent(org.hl7.fhir.dstu3.model.Measure.MeasureSupplementalDataComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Measure.MeasureSupplementalDataComponent tgt = new org.hl7.fhir.r4.model.Measure.MeasureSupplementalDataComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getUsage())
      tgt.addUsage(convertCodeableConcept(t));
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Measure.MeasureSupplementalDataComponent convertMeasureSupplementalDataComponent(org.hl7.fhir.r4.model.Measure.MeasureSupplementalDataComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Measure.MeasureSupplementalDataComponent tgt = new org.hl7.fhir.dstu3.model.Measure.MeasureSupplementalDataComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getUsage())
      tgt.addUsage(convertCodeableConcept(t));
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Media convertMedia(org.hl7.fhir.dstu3.model.Media src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Media tgt = new org.hl7.fhir.r4.model.Media();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasType())
      tgt.setType(convertDigitalMediaType(src.getType()));
    if (src.hasSubtype())
      tgt.setSubtype(convertCodeableConcept(src.getSubtype()));
    if (src.hasView())
      tgt.setView(convertCodeableConcept(src.getView()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasOperator())
      tgt.setOperator(convertReference(src.getOperator()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    if (src.hasHeight())
      tgt.setHeight(src.getHeight());
    if (src.hasWidth())
      tgt.setWidth(src.getWidth());
    if (src.hasFrames())
      tgt.setFrames(src.getFrames());
    if (src.hasDuration())
      tgt.setDuration(src.getDuration());
    if (src.hasContent())
      tgt.setContent(convertAttachment(src.getContent()));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Media convertMedia(org.hl7.fhir.r4.model.Media src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Media tgt = new org.hl7.fhir.dstu3.model.Media();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasType())
      tgt.setType(convertDigitalMediaType(src.getType()));
    if (src.hasSubtype())
      tgt.setSubtype(convertCodeableConcept(src.getSubtype()));
    if (src.hasView())
      tgt.setView(convertCodeableConcept(src.getView()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasOperator())
      tgt.setOperator(convertReference(src.getOperator()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    if (src.hasHeight())
      tgt.setHeight(src.getHeight());
    if (src.hasWidth())
      tgt.setWidth(src.getWidth());
    if (src.hasFrames())
      tgt.setFrames(src.getFrames());
    if (src.hasDuration())
      tgt.setDuration(src.getDuration());
    if (src.hasContent())
      tgt.setContent(convertAttachment(src.getContent()));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Medication convertMedication(org.hl7.fhir.dstu3.model.Medication src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Medication tgt = new org.hl7.fhir.r4.model.Medication();
    copyDomainResource(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationStatus(src.getStatus()));
    if (src.hasIsBrand())
      tgt.setIsBrand(src.getIsBrand());
    if (src.hasIsOverTheCounter())
      tgt.setIsOverTheCounter(src.getIsOverTheCounter());
    if (src.hasManufacturer())
      tgt.setManufacturer(convertReference(src.getManufacturer()));
    if (src.hasForm())
      tgt.setForm(convertCodeableConcept(src.getForm()));
    for (org.hl7.fhir.dstu3.model.Medication.MedicationIngredientComponent t : src.getIngredient())
      tgt.addIngredient(convertMedicationIngredientComponent(t));
    if (src.hasPackage())
      tgt.setPackage(convertMedicationPackageComponent(src.getPackage()));
    for (org.hl7.fhir.dstu3.model.Attachment t : src.getImage())
      tgt.addImage(convertAttachment(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Medication convertMedication(org.hl7.fhir.r4.model.Medication src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Medication tgt = new org.hl7.fhir.dstu3.model.Medication();
    copyDomainResource(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationStatus(src.getStatus()));
    if (src.hasIsBrand())
      tgt.setIsBrand(src.getIsBrand());
    if (src.hasIsOverTheCounter())
      tgt.setIsOverTheCounter(src.getIsOverTheCounter());
    if (src.hasManufacturer())
      tgt.setManufacturer(convertReference(src.getManufacturer()));
    if (src.hasForm())
      tgt.setForm(convertCodeableConcept(src.getForm()));
    for (org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent t : src.getIngredient())
      tgt.addIngredient(convertMedicationIngredientComponent(t));
    if (src.hasPackage())
      tgt.setPackage(convertMedicationPackageComponent(src.getPackage()));
    for (org.hl7.fhir.r4.model.Attachment t : src.getImage())
      tgt.addImage(convertAttachment(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MedicationAdministration convertMedicationAdministration(org.hl7.fhir.dstu3.model.MedicationAdministration src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationAdministration tgt = new org.hl7.fhir.r4.model.MedicationAdministration();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationAdministrationStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    for (org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationPerformerComponent t : src.getPerformer())
      tgt.addPerformer(convertMedicationAdministrationPerformerComponent(t));
    if (src.hasNotGiven())
      tgt.setNotGiven(src.getNotGiven());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonNotGiven())
      tgt.addReasonNotGiven(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    if (src.hasPrescription())
      tgt.setRequest(convertReference(src.getPrescription()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDevice())
      tgt.addDevice(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    if (src.hasDosage())
      tgt.setDosage(convertMedicationAdministrationDosageComponent(src.getDosage()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEventHistory())
      tgt.addEventHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationAdministration convertMedicationAdministration(org.hl7.fhir.r4.model.MedicationAdministration src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationAdministration tgt = new org.hl7.fhir.dstu3.model.MedicationAdministration();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationAdministrationStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    for (org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationPerformerComponent t : src.getPerformer())
      tgt.addPerformer(convertMedicationAdministrationPerformerComponent(t));
    if (src.hasNotGiven())
      tgt.setNotGiven(src.getNotGiven());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonNotGiven())
      tgt.addReasonNotGiven(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    if (src.hasRequest())
      tgt.setPrescription(convertReference(src.getRequest()));
    for (org.hl7.fhir.r4.model.Reference t : src.getDevice())
      tgt.addDevice(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    if (src.hasDosage())
      tgt.setDosage(convertMedicationAdministrationDosageComponent(src.getDosage()));
    for (org.hl7.fhir.r4.model.Reference t : src.getEventHistory())
      tgt.addEventHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationDosageComponent convertMedicationAdministrationDosageComponent(org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationDosageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationDosageComponent tgt = new org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationDosageComponent();
    copyElement(src, tgt);
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasSite())
      tgt.setSite(convertCodeableConcept(src.getSite()));
    if (src.hasRoute())
      tgt.setRoute(convertCodeableConcept(src.getRoute()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasDose())
      tgt.setDose(convertSimpleQuantity(src.getDose()));
    if (src.hasRate())
      tgt.setRate(convertType(src.getRate()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationDosageComponent convertMedicationAdministrationDosageComponent(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationDosageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationDosageComponent tgt = new org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationDosageComponent();
    copyElement(src, tgt);
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasSite())
      tgt.setSite(convertCodeableConcept(src.getSite()));
    if (src.hasRoute())
      tgt.setRoute(convertCodeableConcept(src.getRoute()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasDose())
      tgt.setDose(convertSimpleQuantity(src.getDose()));
    if (src.hasRate())
      tgt.setRate(convertType(src.getRate()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationPerformerComponent convertMedicationAdministrationPerformerComponent(org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationPerformerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationPerformerComponent tgt = new org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationPerformerComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationPerformerComponent convertMedicationAdministrationPerformerComponent(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationPerformerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationPerformerComponent tgt = new org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationPerformerComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus convertMedicationAdministrationStatus(org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INPROGRESS: return org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.STOPPED;
    case UNKNOWN: return org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus convertMedicationAdministrationStatus(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INPROGRESS: return org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus.STOPPED;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.MedicationDispense convertMedicationDispense(org.hl7.fhir.dstu3.model.MedicationDispense src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationDispense tgt = new org.hl7.fhir.r4.model.MedicationDispense();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationDispenseStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    for (org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispensePerformerComponent t : src.getPerformer())
      tgt.addPerformer(convertMedicationDispensePerformerComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAuthorizingPrescription())
      tgt.addAuthorizingPrescription(convertReference(t));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasDaysSupply())
      tgt.setDaysSupply(convertSimpleQuantity(src.getDaysSupply()));
    if (src.hasWhenPrepared())
      tgt.setWhenPrepared(src.getWhenPrepared());
    if (src.hasWhenHandedOver())
      tgt.setWhenHandedOver(src.getWhenHandedOver());
    if (src.hasDestination())
      tgt.setDestination(convertReference(src.getDestination()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReceiver())
      tgt.addReceiver(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Dosage t : src.getDosageInstruction())
      tgt.addDosageInstruction(convertDosage(t));
    if (src.hasSubstitution())
      tgt.setSubstitution(convertMedicationDispenseSubstitutionComponent(src.getSubstitution()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDetectedIssue())
      tgt.addDetectedIssue(convertReference(t));
    if (src.hasNotDone())
      tgt.setNotDone(src.getNotDone());
    if (src.hasNotDoneReason())
      tgt.setNotDoneReason(convertType(src.getNotDoneReason()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEventHistory())
      tgt.addEventHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationDispense convertMedicationDispense(org.hl7.fhir.r4.model.MedicationDispense src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationDispense tgt = new org.hl7.fhir.dstu3.model.MedicationDispense();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationDispenseStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    for (org.hl7.fhir.r4.model.MedicationDispense.MedicationDispensePerformerComponent t : src.getPerformer())
      tgt.addPerformer(convertMedicationDispensePerformerComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getAuthorizingPrescription())
      tgt.addAuthorizingPrescription(convertReference(t));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasDaysSupply())
      tgt.setDaysSupply(convertSimpleQuantity(src.getDaysSupply()));
    if (src.hasWhenPrepared())
      tgt.setWhenPrepared(src.getWhenPrepared());
    if (src.hasWhenHandedOver())
      tgt.setWhenHandedOver(src.getWhenHandedOver());
    if (src.hasDestination())
      tgt.setDestination(convertReference(src.getDestination()));
    for (org.hl7.fhir.r4.model.Reference t : src.getReceiver())
      tgt.addReceiver(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Dosage t : src.getDosageInstruction())
      tgt.addDosageInstruction(convertDosage(t));
    if (src.hasSubstitution())
      tgt.setSubstitution(convertMedicationDispenseSubstitutionComponent(src.getSubstitution()));
    for (org.hl7.fhir.r4.model.Reference t : src.getDetectedIssue())
      tgt.addDetectedIssue(convertReference(t));
    if (src.hasNotDone())
      tgt.setNotDone(src.getNotDone());
    if (src.hasNotDoneReason())
      tgt.setNotDoneReason(convertType(src.getNotDoneReason()));
    for (org.hl7.fhir.r4.model.Reference t : src.getEventHistory())
      tgt.addEventHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MedicationDispense.MedicationDispensePerformerComponent convertMedicationDispensePerformerComponent(org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispensePerformerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationDispense.MedicationDispensePerformerComponent tgt = new org.hl7.fhir.r4.model.MedicationDispense.MedicationDispensePerformerComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispensePerformerComponent convertMedicationDispensePerformerComponent(org.hl7.fhir.r4.model.MedicationDispense.MedicationDispensePerformerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispensePerformerComponent tgt = new org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispensePerformerComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus convertMedicationDispenseStatus(org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PREPARATION: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.PREPARATION;
    case INPROGRESS: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.STOPPED;
    default: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus convertMedicationDispenseStatus(org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PREPARATION: return org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus.PREPARATION;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus.STOPPED;
    default: return org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent convertMedicationDispenseSubstitutionComponent(org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseSubstitutionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent tgt = new org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent();
    copyElement(src, tgt);
    if (src.hasWasSubstituted())
      tgt.setWasSubstituted(src.getWasSubstituted());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getResponsibleParty())
      tgt.addResponsibleParty(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseSubstitutionComponent convertMedicationDispenseSubstitutionComponent(org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseSubstitutionComponent tgt = new org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseSubstitutionComponent();
    copyElement(src, tgt);
    if (src.hasWasSubstituted())
      tgt.setWasSubstituted(src.getWasSubstituted());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason())
      tgt.addReason(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getResponsibleParty())
      tgt.addResponsibleParty(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent convertMedicationIngredientComponent(org.hl7.fhir.dstu3.model.Medication.MedicationIngredientComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent();
    copyElement(src, tgt);
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    if (src.hasIsActive())
      tgt.setIsActive(src.getIsActive());
    if (src.hasAmount())
      tgt.setAmount(convertRatio(src.getAmount()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Medication.MedicationIngredientComponent convertMedicationIngredientComponent(org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Medication.MedicationIngredientComponent tgt = new org.hl7.fhir.dstu3.model.Medication.MedicationIngredientComponent();
    copyElement(src, tgt);
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    if (src.hasIsActive())
      tgt.setIsActive(src.getIsActive());
    if (src.hasAmount())
      tgt.setAmount(convertRatio(src.getAmount()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Medication.MedicationPackageBatchComponent convertMedicationPackageBatchComponent(org.hl7.fhir.dstu3.model.Medication.MedicationPackageBatchComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Medication.MedicationPackageBatchComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationPackageBatchComponent();
    copyElement(src, tgt);
    if (src.hasLotNumber())
      tgt.setLotNumber(src.getLotNumber());
    if (src.hasExpirationDate())
      tgt.setExpirationDate(src.getExpirationDate());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Medication.MedicationPackageBatchComponent convertMedicationPackageBatchComponent(org.hl7.fhir.r4.model.Medication.MedicationPackageBatchComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Medication.MedicationPackageBatchComponent tgt = new org.hl7.fhir.dstu3.model.Medication.MedicationPackageBatchComponent();
    copyElement(src, tgt);
    if (src.hasLotNumber())
      tgt.setLotNumber(src.getLotNumber());
    if (src.hasExpirationDate())
      tgt.setExpirationDate(src.getExpirationDate());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationPackageComponent();
    copyElement(src, tgt);
    if (src.hasContainer())
      tgt.setContainer(convertCodeableConcept(src.getContainer()));
    for (org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent t : src.getContent())
      tgt.addContent(convertMedicationPackageContentComponent(t));
    for (org.hl7.fhir.dstu3.model.Medication.MedicationPackageBatchComponent t : src.getBatch())
      tgt.addBatch(convertMedicationPackageBatchComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.r4.model.Medication.MedicationPackageComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent();
    copyElement(src, tgt);
    if (src.hasContainer())
      tgt.setContainer(convertCodeableConcept(src.getContainer()));
    for (org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent t : src.getContent())
      tgt.addContent(convertMedicationPackageContentComponent(t));
    for (org.hl7.fhir.r4.model.Medication.MedicationPackageBatchComponent t : src.getBatch())
      tgt.addBatch(convertMedicationPackageBatchComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent();
    copyElement(src, tgt);
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    if (src.hasAmount())
      tgt.setAmount(convertSimpleQuantity(src.getAmount()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent();
    copyElement(src, tgt);
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    if (src.hasAmount())
      tgt.setAmount(convertSimpleQuantity(src.getAmount()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MedicationRequest convertMedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationRequest tgt = new org.hl7.fhir.r4.model.MedicationRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationRequestStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertMedicationRequestIntent(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertMedicationRequestPriority(src.getPriority()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertMedicationRequestRequesterComponent(src.getRequester()));
    if (src.hasRecorder())
      tgt.setRecorder(convertReference(src.getRecorder()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Dosage t : src.getDosageInstruction())
      tgt.addDosageInstruction(convertDosage(t));
    if (src.hasDispenseRequest())
      tgt.setDispenseRequest(convertMedicationRequestDispenseRequestComponent(src.getDispenseRequest()));
    if (src.hasSubstitution())
      tgt.setSubstitution(convertMedicationRequestSubstitutionComponent(src.getSubstitution()));
    if (src.hasPriorPrescription())
      tgt.setPriorPrescription(convertReference(src.getPriorPrescription()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDetectedIssue())
      tgt.addDetectedIssue(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEventHistory())
      tgt.addEventHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationRequest convertMedicationRequest(org.hl7.fhir.r4.model.MedicationRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationRequest tgt = new org.hl7.fhir.dstu3.model.MedicationRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationRequestStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertMedicationRequestIntent(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertMedicationRequestPriority(src.getPriority()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInformation())
      tgt.addSupportingInformation(convertReference(t));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertMedicationRequestRequesterComponent(src.getRequester()));
    if (src.hasRecorder())
      tgt.setRecorder(convertReference(src.getRecorder()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Dosage t : src.getDosageInstruction())
      tgt.addDosageInstruction(convertDosage(t));
    if (src.hasDispenseRequest())
      tgt.setDispenseRequest(convertMedicationRequestDispenseRequestComponent(src.getDispenseRequest()));
    if (src.hasSubstitution())
      tgt.setSubstitution(convertMedicationRequestSubstitutionComponent(src.getSubstitution()));
    if (src.hasPriorPrescription())
      tgt.setPriorPrescription(convertReference(src.getPriorPrescription()));
    for (org.hl7.fhir.r4.model.Reference t : src.getDetectedIssue())
      tgt.addDetectedIssue(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getEventHistory())
      tgt.addEventHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent convertMedicationRequestDispenseRequestComponent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent();
    copyElement(src, tgt);
    if (src.hasValidityPeriod())
      tgt.setValidityPeriod(convertPeriod(src.getValidityPeriod()));
    if (src.hasNumberOfRepeatsAllowed())
      tgt.setNumberOfRepeatsAllowed(src.getNumberOfRepeatsAllowed());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasExpectedSupplyDuration())
      tgt.setExpectedSupplyDuration(convertDuration(src.getExpectedSupplyDuration()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent convertMedicationRequestDispenseRequestComponent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent tgt = new org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent();
    copyElement(src, tgt);
    if (src.hasValidityPeriod())
      tgt.setValidityPeriod(convertPeriod(src.getValidityPeriod()));
    if (src.hasNumberOfRepeatsAllowed())
      tgt.setNumberOfRepeatsAllowed(src.getNumberOfRepeatsAllowed());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasExpectedSupplyDuration())
      tgt.setExpectedSupplyDuration(convertDuration(src.getExpectedSupplyDuration()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent convertMedicationRequestIntent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.PLAN;
    case ORDER: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.ORDER;
    case INSTANCEORDER: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.INSTANCEORDER;
    default: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent convertMedicationRequestIntent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent.PLAN;
    case ORDER: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent.ORDER;
    case INSTANCEORDER: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent.INSTANCEORDER;
    default: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent.NULL;
  }
}

  private static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority convertMedicationRequestPriority(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.URGENT;
    case STAT: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.STAT;
    case ASAP: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.ASAP;
    default: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestPriority convertMedicationRequestPriority(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestPriority.URGENT;
    case STAT: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestPriority.STAT;
    case ASAP: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestPriority.ASAP;
    default: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestPriority.NULL;
  }
}

  public static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestRequesterComponent convertMedicationRequestRequesterComponent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestRequesterComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestRequesterComponent convertMedicationRequestRequesterComponent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestRequesterComponent tgt = new org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus convertMedicationRequestStatus(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.ACTIVE;
    case ONHOLD: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.ONHOLD;
    case CANCELLED: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.STOPPED;
    case DRAFT: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.DRAFT;
    case UNKNOWN: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus convertMedicationRequestStatus(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.ACTIVE;
    case ONHOLD: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.ONHOLD;
    case CANCELLED: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.STOPPED;
    case DRAFT: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.DRAFT;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent convertMedicationRequestSubstitutionComponent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestSubstitutionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent();
    copyElement(src, tgt);
    if (src.hasAllowed())
      tgt.setAllowed(src.getAllowed());
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestSubstitutionComponent convertMedicationRequestSubstitutionComponent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestSubstitutionComponent tgt = new org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestSubstitutionComponent();
    copyElement(src, tgt);
    if (src.hasAllowed())
      tgt.setAllowed(src.getAllowed());
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.dstu3.model.MedicationStatement src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MedicationStatement tgt = new org.hl7.fhir.r4.model.MedicationStatement();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationStatementStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasDateAsserted())
      tgt.setDateAsserted(src.getDateAsserted());
    if (src.hasInformationSource())
      tgt.setInformationSource(convertReference(src.getInformationSource()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDerivedFrom())
      tgt.addDerivedFrom(convertReference(t));
    if (src.hasTaken())
      tgt.setTaken(convertMedicationStatementTaken(src.getTaken()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonNotTaken())
      tgt.addReasonNotTaken(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Dosage t : src.getDosage())
      tgt.addDosage(convertDosage(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.r4.model.MedicationStatement src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MedicationStatement tgt = new org.hl7.fhir.dstu3.model.MedicationStatement();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasStatus())
      tgt.setStatus(convertMedicationStatementStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasMedication())
      tgt.setMedication(convertType(src.getMedication()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasDateAsserted())
      tgt.setDateAsserted(src.getDateAsserted());
    if (src.hasInformationSource())
      tgt.setInformationSource(convertReference(src.getInformationSource()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.r4.model.Reference t : src.getDerivedFrom())
      tgt.addDerivedFrom(convertReference(t));
    if (src.hasTaken())
      tgt.setTaken(convertMedicationStatementTaken(src.getTaken()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonNotTaken())
      tgt.addReasonNotTaken(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Dosage t : src.getDosage())
      tgt.addDosage(convertDosage(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus convertMedicationStatementStatus(org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.ACTIVE;
    case COMPLETED: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR;
    case INTENDED: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.INTENDED;
    case STOPPED: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.STOPPED;
    case ONHOLD: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.ONHOLD;
    default: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus convertMedicationStatementStatus(org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.ACTIVE;
    case COMPLETED: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR;
    case INTENDED: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.INTENDED;
    case STOPPED: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.STOPPED;
    case ONHOLD: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.ONHOLD;
    default: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementTaken convertMedicationStatementTaken(org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case Y: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementTaken.Y;
    case N: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementTaken.N;
    case UNK: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementTaken.UNK;
    case NA: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementTaken.NA;
    default: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementTaken.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken convertMedicationStatementTaken(org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementTaken src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case Y: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken.Y;
    case N: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken.N;
    case UNK: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken.UNK;
    case NA: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken.NA;
    default: return org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Medication.MedicationStatus convertMedicationStatus(org.hl7.fhir.dstu3.model.Medication.MedicationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.Medication.MedicationStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.r4.model.Medication.MedicationStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Medication.MedicationStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Medication.MedicationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Medication.MedicationStatus convertMedicationStatus(org.hl7.fhir.r4.model.Medication.MedicationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.Medication.MedicationStatus.ACTIVE;
    case INACTIVE: return org.hl7.fhir.dstu3.model.Medication.MedicationStatus.INACTIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Medication.MedicationStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Medication.MedicationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.MessageDefinition convertMessageDefinition(org.hl7.fhir.dstu3.model.MessageDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MessageDefinition tgt = new org.hl7.fhir.r4.model.MessageDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasBase())
      tgt.setBase(convertReference(src.getBase()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getParent())
      tgt.addParent(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    if (src.hasCategory())
      tgt.setCategory(convertMessageSignificanceCategory(src.getCategory()));
    for (org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent t : src.getFocus())
      tgt.addFocus(convertMessageDefinitionFocusComponent(t));
    if (src.hasResponseRequired())
      tgt.setResponseRequired(src.getResponseRequired());
    for (org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent t : src.getAllowedResponse())
      tgt.addAllowedResponse(convertMessageDefinitionAllowedResponseComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MessageDefinition convertMessageDefinition(org.hl7.fhir.r4.model.MessageDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MessageDefinition tgt = new org.hl7.fhir.dstu3.model.MessageDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasBase())
      tgt.setBase(convertReference(src.getBase()));
    for (org.hl7.fhir.r4.model.Reference t : src.getParent())
      tgt.addParent(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    if (src.hasCategory())
      tgt.setCategory(convertMessageSignificanceCategory(src.getCategory()));
    for (org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent t : src.getFocus())
      tgt.addFocus(convertMessageDefinitionFocusComponent(t));
    if (src.hasResponseRequired())
      tgt.setResponseRequired(src.getResponseRequired());
    for (org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent t : src.getAllowedResponse())
      tgt.addAllowedResponse(convertMessageDefinitionAllowedResponseComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent convertMessageDefinitionAllowedResponseComponent(org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent tgt = new org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent();
    copyElement(src, tgt);
    if (src.hasMessage())
      tgt.setMessage(convertReference(src.getMessage()));
    if (src.hasSituation())
      tgt.setSituation(src.getSituation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent convertMessageDefinitionAllowedResponseComponent(org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent tgt = new org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent();
    copyElement(src, tgt);
    if (src.hasMessage())
      tgt.setMessage(convertReference(src.getMessage()));
    if (src.hasSituation())
      tgt.setSituation(src.getSituation());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent convertMessageDefinitionFocusComponent(org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent tgt = new org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent convertMessageDefinitionFocusComponent(org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent tgt = new org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.dstu3.model.MessageHeader.MessageDestinationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasEndpoint())
      tgt.setEndpoint(src.getEndpoint());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.dstu3.model.MessageHeader.MessageDestinationComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasEndpoint())
      tgt.setEndpoint(src.getEndpoint());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MessageHeader convertMessageHeader(org.hl7.fhir.dstu3.model.MessageHeader src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MessageHeader tgt = new org.hl7.fhir.r4.model.MessageHeader();
    copyDomainResource(src, tgt);
    if (src.hasEvent())
      tgt.setEvent(convertCoding(src.getEvent()));
    for (org.hl7.fhir.dstu3.model.MessageHeader.MessageDestinationComponent t : src.getDestination())
      tgt.addDestination(convertMessageDestinationComponent(t));
    if (src.hasSender())
      tgt.setSender(convertReference(src.getSender()));
    if (src.hasTimestamp())
      tgt.setTimestamp(src.getTimestamp());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    if (src.hasSource())
      tgt.setSource(convertMessageSourceComponent(src.getSource()));
    if (src.hasResponsible())
      tgt.setResponsible(convertReference(src.getResponsible()));
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    if (src.hasResponse())
      tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getFocus())
      tgt.addFocus(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MessageHeader convertMessageHeader(org.hl7.fhir.r4.model.MessageHeader src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MessageHeader tgt = new org.hl7.fhir.dstu3.model.MessageHeader();
    copyDomainResource(src, tgt);
    if (src.hasEvent())
      tgt.setEvent(convertCoding(src.getEvent()));
    for (org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent t : src.getDestination())
      tgt.addDestination(convertMessageDestinationComponent(t));
    if (src.hasSender())
      tgt.setSender(convertReference(src.getSender()));
    if (src.hasTimestamp())
      tgt.setTimestamp(src.getTimestamp());
    if (src.hasEnterer())
      tgt.setEnterer(convertReference(src.getEnterer()));
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    if (src.hasSource())
      tgt.setSource(convertMessageSourceComponent(src.getSource()));
    if (src.hasResponsible())
      tgt.setResponsible(convertReference(src.getResponsible()));
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    if (src.hasResponse())
      tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse()));
    for (org.hl7.fhir.r4.model.Reference t : src.getFocus())
      tgt.addFocus(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.dstu3.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(src.getIdentifier());
    if (src.hasCode())
      tgt.setCode(convertResponseType(src.getCode()));
    if (src.hasDetails())
      tgt.setDetails(convertReference(src.getDetails()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.dstu3.model.MessageHeader.MessageHeaderResponseComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(src.getIdentifier());
    if (src.hasCode())
      tgt.setCode(convertResponseType(src.getCode()));
    if (src.hasDetails())
      tgt.setDetails(convertReference(src.getDetails()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.dstu3.model.CapabilityStatement.MessageSignificanceCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CONSEQUENCE: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.CONSEQUENCE;
    case CURRENCY: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.CURRENCY;
    case NOTIFICATION: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.NOTIFICATION;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CONSEQUENCE: return org.hl7.fhir.dstu3.model.CapabilityStatement.MessageSignificanceCategory.CONSEQUENCE;
    case CURRENCY: return org.hl7.fhir.dstu3.model.CapabilityStatement.MessageSignificanceCategory.CURRENCY;
    case NOTIFICATION: return org.hl7.fhir.dstu3.model.CapabilityStatement.MessageSignificanceCategory.NOTIFICATION;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.MessageSignificanceCategory.NULL;
  }
}

  private static org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CONSEQUENCE: return org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.CONSEQUENCE;
    case CURRENCY: return org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.CURRENCY;
    case NOTIFICATION: return org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.NOTIFICATION;
    default: return org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CONSEQUENCE: return org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.CONSEQUENCE;
    case CURRENCY: return org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.CURRENCY;
    case NOTIFICATION: return org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.NOTIFICATION;
    default: return org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.NULL;
  }
}

  public static org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasSoftware())
      tgt.setSoftware(src.getSoftware());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasContact())
      tgt.setContact(convertContactPoint(src.getContact()));
    if (src.hasEndpoint())
      tgt.setEndpoint(src.getEndpoint());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasSoftware())
      tgt.setSoftware(src.getSoftware());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasContact())
      tgt.setContact(convertContactPoint(src.getContact()));
    if (src.hasEndpoint())
      tgt.setEndpoint(src.getEndpoint());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta();
    copyElement(src, tgt);
    if (src.hasVersionId())
      tgt.setVersionId(src.getVersionId());
    if (src.hasLastUpdated())
      tgt.setLastUpdated(src.getLastUpdated());
    for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile())
      tgt.addProfile(t.getValue());
    for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity())
      tgt.addSecurity(convertCoding(t));
    for (org.hl7.fhir.dstu3.model.Coding t : src.getTag())
      tgt.addTag(convertCoding(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta();
    copyElement(src, tgt);
    if (src.hasVersionId())
      tgt.setVersionId(src.getVersionId());
    if (src.hasLastUpdated())
      tgt.setLastUpdated(src.getLastUpdated());
    for (org.hl7.fhir.r4.model.UriType t : src.getProfile())
      tgt.addProfile(t.getValue());
    for (org.hl7.fhir.r4.model.Coding t : src.getSecurity())
      tgt.addSecurity(convertCoding(t));
    for (org.hl7.fhir.r4.model.Coding t : src.getTag())
      tgt.addTag(convertCoding(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money();
    copyQuantity(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money();
    copyQuantity(src, tgt);
    return tgt;
  }

  private static org.hl7.fhir.r4.model.HumanName.NameUse convertNameUse(org.hl7.fhir.dstu3.model.HumanName.NameUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case USUAL: return org.hl7.fhir.r4.model.HumanName.NameUse.USUAL;
    case OFFICIAL: return org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL;
    case TEMP: return org.hl7.fhir.r4.model.HumanName.NameUse.TEMP;
    case NICKNAME: return org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME;
    case ANONYMOUS: return org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS;
    case OLD: return org.hl7.fhir.r4.model.HumanName.NameUse.OLD;
    case MAIDEN: return org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN;
    default: return org.hl7.fhir.r4.model.HumanName.NameUse.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.HumanName.NameUse convertNameUse(org.hl7.fhir.r4.model.HumanName.NameUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case USUAL: return org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL;
    case OFFICIAL: return org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL;
    case TEMP: return org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP;
    case NICKNAME: return org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME;
    case ANONYMOUS: return org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS;
    case OLD: return org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD;
    case MAIDEN: return org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN;
    default: return org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL;
  }
}

  public static org.hl7.fhir.r4.model.NamingSystem convertNamingSystem(org.hl7.fhir.dstu3.model.NamingSystem src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NamingSystem tgt = new org.hl7.fhir.r4.model.NamingSystem();
    copyDomainResource(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasKind())
      tgt.setKind(convertNamingSystemType(src.getKind()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasResponsible())
      tgt.setResponsible(src.getResponsible());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasUsage())
      tgt.setUsage(src.getUsage());
    for (org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId())
      tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t));
    if (src.hasReplacedBy())
      tgt.setReplacedBy(convertReference(src.getReplacedBy()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NamingSystem convertNamingSystem(org.hl7.fhir.r4.model.NamingSystem src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NamingSystem tgt = new org.hl7.fhir.dstu3.model.NamingSystem();
    copyDomainResource(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasKind())
      tgt.setKind(convertNamingSystemType(src.getKind()));
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasResponsible())
      tgt.setResponsible(src.getResponsible());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasUsage())
      tgt.setUsage(src.getUsage());
    for (org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId())
      tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t));
    if (src.hasReplacedBy())
      tgt.setReplacedBy(convertReference(src.getReplacedBy()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType convertNamingSystemIdentifierType(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OID: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OID;
    case UUID: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.UUID;
    case URI: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.URI;
    case OTHER: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OTHER;
    default: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType convertNamingSystemIdentifierType(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OID: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.OID;
    case UUID: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.UUID;
    case URI: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.URI;
    case OTHER: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.OTHER;
    default: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.NamingSystem.NamingSystemType convertNamingSystemType(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CODESYSTEM: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.CODESYSTEM;
    case IDENTIFIER: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.IDENTIFIER;
    case ROOT: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.ROOT;
    default: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType convertNamingSystemType(org.hl7.fhir.r4.model.NamingSystem.NamingSystemType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CODESYSTEM: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.CODESYSTEM;
    case IDENTIFIER: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.IDENTIFIER;
    case ROOT: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.ROOT;
    default: return org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertNamingSystemIdentifierType(src.getType()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasPreferred())
      tgt.setPreferred(src.getPreferred());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertNamingSystemIdentifierType(src.getType()));
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasPreferred())
      tgt.setPreferred(src.getPreferred());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertNarrativeStatus(src.getStatus()));
    if (src.hasDiv())
      tgt.setDiv(src.getDiv());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertNarrativeStatus(src.getStatus()));
    if (src.hasDiv())
      tgt.setDiv(src.getDiv());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Narrative.NarrativeStatus convertNarrativeStatus(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GENERATED: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED;
    case EXTENSIONS: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS;
    case ADDITIONAL: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL;
    case EMPTY: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY;
    default: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus convertNarrativeStatus(org.hl7.fhir.r4.model.Narrative.NarrativeStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GENERATED: return org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED;
    case EXTENSIONS: return org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS;
    case ADDITIONAL: return org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL;
    case EMPTY: return org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY;
    default: return org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.NutritionOrder convertNutritionOrder(org.hl7.fhir.dstu3.model.NutritionOrder src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NutritionOrder tgt = new org.hl7.fhir.r4.model.NutritionOrder();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertNutritionOrderStatus(src.getStatus()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDateTime())
      tgt.setDateTime(src.getDateTime());
    if (src.hasOrderer())
      tgt.setOrderer(convertReference(src.getOrderer()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAllergyIntolerance())
      tgt.addAllergyIntolerance(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getFoodPreferenceModifier())
      tgt.addFoodPreferenceModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getExcludeFoodModifier())
      tgt.addExcludeFoodModifier(convertCodeableConcept(t));
    if (src.hasOralDiet())
      tgt.setOralDiet(convertNutritionOrderOralDietComponent(src.getOralDiet()));
    for (org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderSupplementComponent t : src.getSupplement())
      tgt.addSupplement(convertNutritionOrderSupplementComponent(t));
    if (src.hasEnteralFormula())
      tgt.setEnteralFormula(convertNutritionOrderEnteralFormulaComponent(src.getEnteralFormula()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NutritionOrder convertNutritionOrder(org.hl7.fhir.r4.model.NutritionOrder src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NutritionOrder tgt = new org.hl7.fhir.dstu3.model.NutritionOrder();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertNutritionOrderStatus(src.getStatus()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDateTime())
      tgt.setDateTime(src.getDateTime());
    if (src.hasOrderer())
      tgt.setOrderer(convertReference(src.getOrderer()));
    for (org.hl7.fhir.r4.model.Reference t : src.getAllergyIntolerance())
      tgt.addAllergyIntolerance(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getFoodPreferenceModifier())
      tgt.addFoodPreferenceModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getExcludeFoodModifier())
      tgt.addExcludeFoodModifier(convertCodeableConcept(t));
    if (src.hasOralDiet())
      tgt.setOralDiet(convertNutritionOrderOralDietComponent(src.getOralDiet()));
    for (org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderSupplementComponent t : src.getSupplement())
      tgt.addSupplement(convertNutritionOrderSupplementComponent(t));
    if (src.hasEnteralFormula())
      tgt.setEnteralFormula(convertNutritionOrderEnteralFormulaComponent(src.getEnteralFormula()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent convertNutritionOrderEnteralFormulaAdministrationComponent(org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent tgt = new org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent();
    copyElement(src, tgt);
    if (src.hasSchedule())
      tgt.setSchedule(convertTiming(src.getSchedule()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasRate())
      tgt.setRate(convertType(src.getRate()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent convertNutritionOrderEnteralFormulaAdministrationComponent(org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent tgt = new org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent();
    copyElement(src, tgt);
    if (src.hasSchedule())
      tgt.setSchedule(convertTiming(src.getSchedule()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasRate())
      tgt.setRate(convertType(src.getRate()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaComponent convertNutritionOrderEnteralFormulaComponent(org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaComponent tgt = new org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaComponent();
    copyElement(src, tgt);
    if (src.hasBaseFormulaType())
      tgt.setBaseFormulaType(convertCodeableConcept(src.getBaseFormulaType()));
    if (src.hasBaseFormulaProductName())
      tgt.setBaseFormulaProductName(src.getBaseFormulaProductName());
    if (src.hasAdditiveType())
      tgt.setAdditiveType(convertCodeableConcept(src.getAdditiveType()));
    if (src.hasAdditiveProductName())
      tgt.setAdditiveProductName(src.getAdditiveProductName());
    if (src.hasCaloricDensity())
      tgt.setCaloricDensity(convertSimpleQuantity(src.getCaloricDensity()));
    if (src.hasRouteofAdministration())
      tgt.setRouteofAdministration(convertCodeableConcept(src.getRouteofAdministration()));
    for (org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent t : src.getAdministration())
      tgt.addAdministration(convertNutritionOrderEnteralFormulaAdministrationComponent(t));
    if (src.hasMaxVolumeToDeliver())
      tgt.setMaxVolumeToDeliver(convertSimpleQuantity(src.getMaxVolumeToDeliver()));
    if (src.hasAdministrationInstruction())
      tgt.setAdministrationInstruction(src.getAdministrationInstruction());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaComponent convertNutritionOrderEnteralFormulaComponent(org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaComponent tgt = new org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderEnteralFormulaComponent();
    copyElement(src, tgt);
    if (src.hasBaseFormulaType())
      tgt.setBaseFormulaType(convertCodeableConcept(src.getBaseFormulaType()));
    if (src.hasBaseFormulaProductName())
      tgt.setBaseFormulaProductName(src.getBaseFormulaProductName());
    if (src.hasAdditiveType())
      tgt.setAdditiveType(convertCodeableConcept(src.getAdditiveType()));
    if (src.hasAdditiveProductName())
      tgt.setAdditiveProductName(src.getAdditiveProductName());
    if (src.hasCaloricDensity())
      tgt.setCaloricDensity(convertSimpleQuantity(src.getCaloricDensity()));
    if (src.hasRouteofAdministration())
      tgt.setRouteofAdministration(convertCodeableConcept(src.getRouteofAdministration()));
    for (org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderEnteralFormulaAdministrationComponent t : src.getAdministration())
      tgt.addAdministration(convertNutritionOrderEnteralFormulaAdministrationComponent(t));
    if (src.hasMaxVolumeToDeliver())
      tgt.setMaxVolumeToDeliver(convertSimpleQuantity(src.getMaxVolumeToDeliver()));
    if (src.hasAdministrationInstruction())
      tgt.setAdministrationInstruction(src.getAdministrationInstruction());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietComponent convertNutritionOrderOralDietComponent(org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietComponent tgt = new org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Timing t : src.getSchedule())
      tgt.addSchedule(convertTiming(t));
    for (org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietNutrientComponent t : src.getNutrient())
      tgt.addNutrient(convertNutritionOrderOralDietNutrientComponent(t));
    for (org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietTextureComponent t : src.getTexture())
      tgt.addTexture(convertNutritionOrderOralDietTextureComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getFluidConsistencyType())
      tgt.addFluidConsistencyType(convertCodeableConcept(t));
    if (src.hasInstruction())
      tgt.setInstruction(src.getInstruction());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietComponent convertNutritionOrderOralDietComponent(org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietComponent tgt = new org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Timing t : src.getSchedule())
      tgt.addSchedule(convertTiming(t));
    for (org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietNutrientComponent t : src.getNutrient())
      tgt.addNutrient(convertNutritionOrderOralDietNutrientComponent(t));
    for (org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietTextureComponent t : src.getTexture())
      tgt.addTexture(convertNutritionOrderOralDietTextureComponent(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getFluidConsistencyType())
      tgt.addFluidConsistencyType(convertCodeableConcept(t));
    if (src.hasInstruction())
      tgt.setInstruction(src.getInstruction());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietNutrientComponent convertNutritionOrderOralDietNutrientComponent(org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietNutrientComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietNutrientComponent tgt = new org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietNutrientComponent();
    copyElement(src, tgt);
    if (src.hasModifier())
      tgt.setModifier(convertCodeableConcept(src.getModifier()));
    if (src.hasAmount())
      tgt.setAmount(convertSimpleQuantity(src.getAmount()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietNutrientComponent convertNutritionOrderOralDietNutrientComponent(org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietNutrientComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietNutrientComponent tgt = new org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietNutrientComponent();
    copyElement(src, tgt);
    if (src.hasModifier())
      tgt.setModifier(convertCodeableConcept(src.getModifier()));
    if (src.hasAmount())
      tgt.setAmount(convertSimpleQuantity(src.getAmount()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietTextureComponent convertNutritionOrderOralDietTextureComponent(org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietTextureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietTextureComponent tgt = new org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietTextureComponent();
    copyElement(src, tgt);
    if (src.hasModifier())
      tgt.setModifier(convertCodeableConcept(src.getModifier()));
    if (src.hasFoodType())
      tgt.setFoodType(convertCodeableConcept(src.getFoodType()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietTextureComponent convertNutritionOrderOralDietTextureComponent(org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderOralDietTextureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietTextureComponent tgt = new org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderOralDietTextureComponent();
    copyElement(src, tgt);
    if (src.hasModifier())
      tgt.setModifier(convertCodeableConcept(src.getModifier()));
    if (src.hasFoodType())
      tgt.setFoodType(convertCodeableConcept(src.getFoodType()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus convertNutritionOrderStatus(org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.PROPOSED;
    case DRAFT: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.DRAFT;
    case PLANNED: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.PLANNED;
    case REQUESTED: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.REQUESTED;
    case ACTIVE: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.ACTIVE;
    case ONHOLD: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.COMPLETED;
    case CANCELLED: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus convertNutritionOrderStatus(org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSED: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.PROPOSED;
    case DRAFT: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.DRAFT;
    case PLANNED: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.PLANNED;
    case REQUESTED: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.REQUESTED;
    case ACTIVE: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.ACTIVE;
    case ONHOLD: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.ONHOLD;
    case COMPLETED: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.COMPLETED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderSupplementComponent convertNutritionOrderSupplementComponent(org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderSupplementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderSupplementComponent tgt = new org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderSupplementComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasProductName())
      tgt.setProductName(src.getProductName());
    for (org.hl7.fhir.dstu3.model.Timing t : src.getSchedule())
      tgt.addSchedule(convertTiming(t));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasInstruction())
      tgt.setInstruction(src.getInstruction());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderSupplementComponent convertNutritionOrderSupplementComponent(org.hl7.fhir.r4.model.NutritionOrder.NutritionOrderSupplementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderSupplementComponent tgt = new org.hl7.fhir.dstu3.model.NutritionOrder.NutritionOrderSupplementComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasProductName())
      tgt.setProductName(src.getProductName());
    for (org.hl7.fhir.r4.model.Timing t : src.getSchedule())
      tgt.addSchedule(convertTiming(t));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasInstruction())
      tgt.setInstruction(src.getInstruction());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Observation convertObservation(org.hl7.fhir.dstu3.model.Observation src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Observation tgt = new org.hl7.fhir.r4.model.Observation();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertObservationStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPerformer())
      tgt.addPerformer(convertReference(t));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasDataAbsentReason())
      tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason()));
    if (src.hasInterpretation())
      tgt.setInterpretation(convertCodeableConcept(src.getInterpretation()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasSpecimen())
      tgt.setSpecimen(convertReference(src.getSpecimen()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    for (org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange())
      tgt.addReferenceRange(convertObservationReferenceRangeComponent(t));
    for (org.hl7.fhir.dstu3.model.Observation.ObservationRelatedComponent t : src.getRelated())
      tgt.addRelated(convertObservationRelatedComponent(t));
    for (org.hl7.fhir.dstu3.model.Observation.ObservationComponentComponent t : src.getComponent())
      tgt.addComponent(convertObservationComponentComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Observation convertObservation(org.hl7.fhir.r4.model.Observation src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Observation tgt = new org.hl7.fhir.dstu3.model.Observation();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertObservationStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasEffective())
      tgt.setEffective(convertType(src.getEffective()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    for (org.hl7.fhir.r4.model.Reference t : src.getPerformer())
      tgt.addPerformer(convertReference(t));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasDataAbsentReason())
      tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason()));
    if (src.hasInterpretation())
      tgt.setInterpretation(convertCodeableConcept(src.getInterpretation()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasSpecimen())
      tgt.setSpecimen(convertReference(src.getSpecimen()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    for (org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange())
      tgt.addReferenceRange(convertObservationReferenceRangeComponent(t));
    for (org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent t : src.getRelated())
      tgt.addRelated(convertObservationRelatedComponent(t));
    for (org.hl7.fhir.r4.model.Observation.ObservationComponentComponent t : src.getComponent())
      tgt.addComponent(convertObservationComponentComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Observation.ObservationComponentComponent convertObservationComponentComponent(org.hl7.fhir.dstu3.model.Observation.ObservationComponentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Observation.ObservationComponentComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationComponentComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasDataAbsentReason())
      tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason()));
    if (src.hasInterpretation())
      tgt.setInterpretation(convertCodeableConcept(src.getInterpretation()));
    for (org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange())
      tgt.addReferenceRange(convertObservationReferenceRangeComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Observation.ObservationComponentComponent convertObservationComponentComponent(org.hl7.fhir.r4.model.Observation.ObservationComponentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Observation.ObservationComponentComponent tgt = new org.hl7.fhir.dstu3.model.Observation.ObservationComponentComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasDataAbsentReason())
      tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason()));
    if (src.hasInterpretation())
      tgt.setInterpretation(convertCodeableConcept(src.getInterpretation()));
    for (org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange())
      tgt.addReferenceRange(convertObservationReferenceRangeComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent convertObservationReferenceRangeComponent(org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent();
    copyElement(src, tgt);
    if (src.hasLow())
      tgt.setLow(convertSimpleQuantity(src.getLow()));
    if (src.hasHigh())
      tgt.setHigh(convertSimpleQuantity(src.getHigh()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAppliesTo())
      tgt.addAppliesTo(convertCodeableConcept(t));
    if (src.hasAge())
      tgt.setAge(convertRange(src.getAge()));
    if (src.hasText())
      tgt.setText(src.getText());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent convertObservationReferenceRangeComponent(org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent tgt = new org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent();
    copyElement(src, tgt);
    if (src.hasLow())
      tgt.setLow(convertSimpleQuantity(src.getLow()));
    if (src.hasHigh())
      tgt.setHigh(convertSimpleQuantity(src.getHigh()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAppliesTo())
      tgt.addAppliesTo(convertCodeableConcept(t));
    if (src.hasAge())
      tgt.setAge(convertRange(src.getAge()));
    if (src.hasText())
      tgt.setText(src.getText());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent convertObservationRelatedComponent(org.hl7.fhir.dstu3.model.Observation.ObservationRelatedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertObservationRelationshipType(src.getType()));
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Observation.ObservationRelatedComponent convertObservationRelatedComponent(org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Observation.ObservationRelatedComponent tgt = new org.hl7.fhir.dstu3.model.Observation.ObservationRelatedComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertObservationRelationshipType(src.getType()));
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Observation.ObservationRelationshipType convertObservationRelationshipType(org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HASMEMBER: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.HASMEMBER;
    case DERIVEDFROM: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.DERIVEDFROM;
    case SEQUELTO: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.SEQUELTO;
    case REPLACES: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.REPLACES;
    case QUALIFIEDBY: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.QUALIFIEDBY;
    case INTERFEREDBY: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.INTERFEREDBY;
    default: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType convertObservationRelationshipType(org.hl7.fhir.r4.model.Observation.ObservationRelationshipType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case HASMEMBER: return org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType.HASMEMBER;
    case DERIVEDFROM: return org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType.DERIVEDFROM;
    case SEQUELTO: return org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType.SEQUELTO;
    case REPLACES: return org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType.REPLACES;
    case QUALIFIEDBY: return org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType.QUALIFIEDBY;
    case INTERFEREDBY: return org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType.INTERFEREDBY;
    default: return org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Observation.ObservationStatus convertObservationStatus(org.hl7.fhir.dstu3.model.Observation.ObservationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.REGISTERED;
    case PRELIMINARY: return org.hl7.fhir.r4.model.Observation.ObservationStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL;
    case AMENDED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.CORRECTED;
    case CANCELLED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Observation.ObservationStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.Observation.ObservationStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Observation.ObservationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Observation.ObservationStatus convertObservationStatus(org.hl7.fhir.r4.model.Observation.ObservationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.REGISTERED;
    case PRELIMINARY: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.FINAL;
    case AMENDED: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.CORRECTED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Observation.ObservationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException {
    org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.OidType tgt = new org.hl7.fhir.dstu3.model.OidType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.dstu3.model.OperationDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.OperationDefinition tgt = new org.hl7.fhir.r4.model.OperationDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasKind())
      tgt.setKind(convertOperationKind(src.getKind()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasIdempotent())
      tgt.setIdempotent(src.getIdempotent());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasBase())
      tgt.setBase(convertReference(src.getBase()));
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getResource())
      tgt.addResource(t.getValue());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasInstance())
      tgt.setInstance(src.getInstance());
    for (org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter())
      tgt.addParameter(convertOperationDefinitionParameterComponent(t));
    for (org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionOverloadComponent t : src.getOverload())
      tgt.addOverload(convertOperationDefinitionOverloadComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.r4.model.OperationDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.OperationDefinition tgt = new org.hl7.fhir.dstu3.model.OperationDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasKind())
      tgt.setKind(convertOperationKind(src.getKind()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasIdempotent())
      tgt.setIdempotent(src.getIdempotent());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    if (src.hasBase())
      tgt.setBase(convertReference(src.getBase()));
    for (org.hl7.fhir.r4.model.CodeType t : src.getResource())
      tgt.addResource(t.getValue());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasInstance())
      tgt.setInstance(src.getInstance());
    for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter())
      tgt.addParameter(convertOperationDefinitionParameterComponent(t));
    for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionOverloadComponent t : src.getOverload())
      tgt.addOverload(convertOperationDefinitionOverloadComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionOverloadComponent convertOperationDefinitionOverloadComponent(org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionOverloadComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionOverloadComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionOverloadComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.StringType t : src.getParameterName())
      tgt.addParameterName(t.getValue());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionOverloadComponent convertOperationDefinitionOverloadComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionOverloadComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionOverloadComponent tgt = new org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionOverloadComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.StringType t : src.getParameterName())
      tgt.addParameterName(t.getValue());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent();
    copyElement(src, tgt);
    if (src.hasStrength())
      tgt.setStrength(convertBindingStrength(src.getStrength()));
    if (src.hasValueSet())
      tgt.setValueSet(convertType(src.getValueSet()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterBindingComponent();
    copyElement(src, tgt);
    if (src.hasStrength())
      tgt.setStrength(convertBindingStrength(src.getStrength()));
    if (src.hasValueSet())
      tgt.setValueSet(convertType(src.getValueSet()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasUse())
      tgt.setUse(convertOperationParameterUse(src.getUse()));
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasSearchType())
      tgt.setSearchType(convertSearchParamType(src.getSearchType()));
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    if (src.hasBinding())
      tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding()));
    for (org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart())
      tgt.addPart(convertOperationDefinitionParameterComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasUse())
      tgt.setUse(convertOperationParameterUse(src.getUse()));
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasSearchType())
      tgt.setSearchType(convertSearchParamType(src.getSearchType()));
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    if (src.hasBinding())
      tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding()));
    for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart())
      tgt.addPart(convertOperationDefinitionParameterComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.OperationDefinition.OperationKind convertOperationKind(org.hl7.fhir.dstu3.model.OperationDefinition.OperationKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OPERATION: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.OPERATION;
    case QUERY: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.QUERY;
    default: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.OperationDefinition.OperationKind convertOperationKind(org.hl7.fhir.r4.model.OperationDefinition.OperationKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OPERATION: return org.hl7.fhir.dstu3.model.OperationDefinition.OperationKind.OPERATION;
    case QUERY: return org.hl7.fhir.dstu3.model.OperationDefinition.OperationKind.QUERY;
    default: return org.hl7.fhir.dstu3.model.OperationDefinition.OperationKind.NULL;
  }
}

  public static org.hl7.fhir.r4.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.OperationOutcome tgt = new org.hl7.fhir.r4.model.OperationOutcome();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue())
      tgt.addIssue(convertOperationOutcomeIssueComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.r4.model.OperationOutcome src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.OperationOutcome tgt = new org.hl7.fhir.dstu3.model.OperationOutcome();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue())
      tgt.addIssue(convertOperationOutcomeIssueComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent();
    copyElement(src, tgt);
    if (src.hasSeverity())
      tgt.setSeverity(convertIssueSeverity(src.getSeverity()));
    if (src.hasCode())
      tgt.setCode(convertIssueType(src.getCode()));
    if (src.hasDetails())
      tgt.setDetails(convertCodeableConcept(src.getDetails()));
    if (src.hasDiagnostics())
      tgt.setDiagnostics(src.getDiagnostics());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getLocation())
      tgt.addLocation(t.getValue());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getExpression())
      tgt.addExpression(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent();
    copyElement(src, tgt);
    if (src.hasSeverity())
      tgt.setSeverity(convertIssueSeverity(src.getSeverity()));
    if (src.hasCode())
      tgt.setCode(convertIssueType(src.getCode()));
    if (src.hasDetails())
      tgt.setDetails(convertCodeableConcept(src.getDetails()));
    if (src.hasDiagnostics())
      tgt.setDiagnostics(src.getDiagnostics());
    for (org.hl7.fhir.r4.model.StringType t : src.getLocation())
      tgt.addLocation(t.getValue());
    for (org.hl7.fhir.r4.model.StringType t : src.getExpression())
      tgt.addExpression(t.getValue());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse convertOperationParameterUse(org.hl7.fhir.dstu3.model.OperationDefinition.OperationParameterUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case IN: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.IN;
    case OUT: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.OUT;
    default: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.OperationDefinition.OperationParameterUse convertOperationParameterUse(org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case IN: return org.hl7.fhir.dstu3.model.OperationDefinition.OperationParameterUse.IN;
    case OUT: return org.hl7.fhir.dstu3.model.OperationDefinition.OperationParameterUse.OUT;
    default: return org.hl7.fhir.dstu3.model.OperationDefinition.OperationParameterUse.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Organization convertOrganization(org.hl7.fhir.dstu3.model.Organization src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Organization tgt = new org.hl7.fhir.r4.model.Organization();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias())
      tgt.addAlias(t.getValue());
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasPartOf())
      tgt.setPartOf(convertReference(src.getPartOf()));
    for (org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent t : src.getContact())
      tgt.addContact(convertOrganizationContactComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Organization convertOrganization(org.hl7.fhir.r4.model.Organization src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Organization tgt = new org.hl7.fhir.dstu3.model.Organization();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
      tgt.addType(convertCodeableConcept(t));
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.r4.model.StringType t : src.getAlias())
      tgt.addAlias(t.getValue());
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.r4.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasPartOf())
      tgt.setPartOf(convertReference(src.getPartOf()));
    for (org.hl7.fhir.r4.model.Organization.OrganizationContactComponent t : src.getContact())
      tgt.addContact(convertOrganizationContactComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.r4.model.Organization.OrganizationContactComponent();
    copyElement(src, tgt);
    if (src.hasPurpose())
      tgt.setPurpose(convertCodeableConcept(src.getPurpose()));
    if (src.hasName())
      tgt.setName(convertHumanName(src.getName()));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasAddress())
      tgt.setAddress(convertAddress(src.getAddress()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.r4.model.Organization.OrganizationContactComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent();
    copyElement(src, tgt);
    if (src.hasPurpose())
      tgt.setPurpose(convertCodeableConcept(src.getPurpose()));
    if (src.hasName())
      tgt.setName(convertHumanName(src.getName()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasAddress())
      tgt.setAddress(convertAddress(src.getAddress()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent();
    copyElement(src, tgt);
    if (src.hasProperty())
      tgt.setProperty(src.getProperty());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent();
    copyElement(src, tgt);
    if (src.hasProperty())
      tgt.setProperty(src.getProperty());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Task.ParameterComponent convertParameterComponent(org.hl7.fhir.dstu3.model.Task.ParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Task.ParameterComponent tgt = new org.hl7.fhir.r4.model.Task.ParameterComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Task.ParameterComponent convertParameterComponent(org.hl7.fhir.r4.model.Task.ParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Task.ParameterComponent tgt = new org.hl7.fhir.dstu3.model.Task.ParameterComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.dstu3.model.ParameterDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ParameterDefinition tgt = new org.hl7.fhir.r4.model.ParameterDefinition();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasUse())
      tgt.setUse(convertParameterUse(src.getUse()));
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ParameterDefinition tgt = new org.hl7.fhir.dstu3.model.ParameterDefinition();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasUse())
      tgt.setUse(convertParameterUse(src.getUse()));
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasProfile())
      tgt.setProfile(convertReference(src.getProfile()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse convertParameterUse(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case IN: return org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.IN;
    case OUT: return org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.OUT;
    default: return org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse convertParameterUse(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case IN: return org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.IN;
    case OUT: return org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.OUT;
    default: return org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.dstu3.model.Parameters src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Parameters tgt = new org.hl7.fhir.r4.model.Parameters();
    copyResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent t : src.getParameter())
      tgt.addParameter(convertParametersParameterComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Parameters convertParameters(org.hl7.fhir.r4.model.Parameters src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Parameters tgt = new org.hl7.fhir.dstu3.model.Parameters();
    copyResource(src, tgt);
    for (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent t : src.getParameter())
      tgt.addParameter(convertParametersParameterComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent convertParametersParameterComponent(org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent tgt = new org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasResource())
      tgt.setResource(convertResource(src.getResource()));
    for (org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent t : src.getPart())
      tgt.addPart(convertParametersParameterComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent convertParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent tgt = new org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasResource())
      tgt.setResource(convertResource(src.getResource()));
    for (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent t : src.getPart())
      tgt.addPart(convertParametersParameterComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Appointment.ParticipantRequired convertParticipantRequired(org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REQUIRED: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.REQUIRED;
    case OPTIONAL: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.OPTIONAL;
    case INFORMATIONONLY: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.INFORMATIONONLY;
    default: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired convertParticipantRequired(org.hl7.fhir.r4.model.Appointment.ParticipantRequired src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REQUIRED: return org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired.REQUIRED;
    case OPTIONAL: return org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired.OPTIONAL;
    case INFORMATIONONLY: return org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired.INFORMATIONONLY;
    default: return org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired.NULL;
  }
}

  private static org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus convertParticipantStatus(org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACCEPTED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.ACCEPTED;
    case DECLINED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.DECLINED;
    case TENTATIVE: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.TENTATIVE;
    case NEEDSACTION: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.NEEDSACTION;
    default: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus convertParticipantStatus(org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACCEPTED: return org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus.ACCEPTED;
    case DECLINED: return org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus.DECLINED;
    case TENTATIVE: return org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus.TENTATIVE;
    case NEEDSACTION: return org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus.NEEDSACTION;
    default: return org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Appointment.ParticipationStatus convertParticipationStatus(org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACCEPTED: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.ACCEPTED;
    case DECLINED: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.DECLINED;
    case TENTATIVE: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.TENTATIVE;
    case NEEDSACTION: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NEEDSACTION;
    default: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus convertParticipationStatus(org.hl7.fhir.r4.model.Appointment.ParticipationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACCEPTED: return org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.ACCEPTED;
    case DECLINED: return org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.DECLINED;
    case TENTATIVE: return org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.TENTATIVE;
    case NEEDSACTION: return org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.NEEDSACTION;
    default: return org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Patient convertPatient(org.hl7.fhir.dstu3.model.Patient src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Patient tgt = new org.hl7.fhir.r4.model.Patient();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.dstu3.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    if (src.hasDeceased())
      tgt.setDeceased(convertType(src.getDeceased()));
    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasMaritalStatus())
      tgt.setMaritalStatus(convertCodeableConcept(src.getMaritalStatus()));
    if (src.hasMultipleBirth())
      tgt.setMultipleBirth(convertType(src.getMultipleBirth()));
    for (org.hl7.fhir.dstu3.model.Attachment t : src.getPhoto())
      tgt.addPhoto(convertAttachment(t));
    for (org.hl7.fhir.dstu3.model.Patient.ContactComponent t : src.getContact())
      tgt.addContact(convertContactComponent(t));
    if (src.hasAnimal())
      tgt.setAnimal(convertAnimalComponent(src.getAnimal()));
    for (org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent t : src.getCommunication())
      tgt.addCommunication(convertPatientCommunicationComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getGeneralPractitioner())
      tgt.addGeneralPractitioner(convertReference(t));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    for (org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent t : src.getLink())
      tgt.addLink(convertPatientLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Patient convertPatient(org.hl7.fhir.r4.model.Patient src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Patient tgt = new org.hl7.fhir.dstu3.model.Patient();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.r4.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    if (src.hasDeceased())
      tgt.setDeceased(convertType(src.getDeceased()));
    for (org.hl7.fhir.r4.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasMaritalStatus())
      tgt.setMaritalStatus(convertCodeableConcept(src.getMaritalStatus()));
    if (src.hasMultipleBirth())
      tgt.setMultipleBirth(convertType(src.getMultipleBirth()));
    for (org.hl7.fhir.r4.model.Attachment t : src.getPhoto())
      tgt.addPhoto(convertAttachment(t));
    for (org.hl7.fhir.r4.model.Patient.ContactComponent t : src.getContact())
      tgt.addContact(convertContactComponent(t));
    if (src.hasAnimal())
      tgt.setAnimal(convertAnimalComponent(src.getAnimal()));
    for (org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent t : src.getCommunication())
      tgt.addCommunication(convertPatientCommunicationComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getGeneralPractitioner())
      tgt.addGeneralPractitioner(convertReference(t));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    for (org.hl7.fhir.r4.model.Patient.PatientLinkComponent t : src.getLink())
      tgt.addLink(convertPatientLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent convertPatientCommunicationComponent(org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent tgt = new org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(convertCodeableConcept(src.getLanguage()));
    if (src.hasPreferred())
      tgt.setPreferred(src.getPreferred());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent convertPatientCommunicationComponent(org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent tgt = new org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent();
    copyElement(src, tgt);
    if (src.hasLanguage())
      tgt.setLanguage(convertCodeableConcept(src.getLanguage()));
    if (src.hasPreferred())
      tgt.setPreferred(src.getPreferred());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Patient.PatientLinkComponent convertPatientLinkComponent(org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Patient.PatientLinkComponent tgt = new org.hl7.fhir.r4.model.Patient.PatientLinkComponent();
    copyElement(src, tgt);
    if (src.hasOther())
      tgt.setOther(convertReference(src.getOther()));
    if (src.hasType())
      tgt.setType(convertLinkType(src.getType()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent convertPatientLinkComponent(org.hl7.fhir.r4.model.Patient.PatientLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent tgt = new org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent();
    copyElement(src, tgt);
    if (src.hasOther())
      tgt.setOther(convertReference(src.getOther()));
    if (src.hasType())
      tgt.setType(convertLinkType(src.getType()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Claim.PayeeComponent convertPayeeComponent(org.hl7.fhir.dstu3.model.Claim.PayeeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.PayeeComponent tgt = new org.hl7.fhir.r4.model.Claim.PayeeComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasResourceType())
      tgt.setResource(convertCoding(src.getResourceType()));
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.PayeeComponent convertPayeeComponent(org.hl7.fhir.r4.model.Claim.PayeeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.PayeeComponent tgt = new org.hl7.fhir.dstu3.model.Claim.PayeeComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasResource())
      tgt.setResourceType(convertCoding(src.getResource()));
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.PaymentNotice convertPaymentNotice(org.hl7.fhir.dstu3.model.PaymentNotice src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.PaymentNotice tgt = new org.hl7.fhir.r4.model.PaymentNotice();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertPaymentNoticeStatus(src.getStatus()));
    if (src.hasRequest())
      tgt.setRequest(convertReference(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertReference(src.getResponse()));
    if (src.hasStatusDate())
      tgt.setStatusDate(src.getStatusDate());
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasPaymentStatus())
      tgt.setPaymentStatus(convertCodeableConcept(src.getPaymentStatus()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.PaymentNotice convertPaymentNotice(org.hl7.fhir.r4.model.PaymentNotice src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.PaymentNotice tgt = new org.hl7.fhir.dstu3.model.PaymentNotice();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertPaymentNoticeStatus(src.getStatus()));
    if (src.hasRequest())
      tgt.setRequest(convertReference(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertReference(src.getResponse()));
    if (src.hasStatusDate())
      tgt.setStatusDate(src.getStatusDate());
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasPaymentStatus())
      tgt.setPaymentStatus(convertCodeableConcept(src.getPaymentStatus()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus convertPaymentNoticeStatus(org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus convertPaymentNoticeStatus(org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period();
    copyElement(src, tgt);
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period();
    copyElement(src, tgt);
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Person convertPerson(org.hl7.fhir.dstu3.model.Person src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Person tgt = new org.hl7.fhir.r4.model.Person();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasPhoto())
      tgt.setPhoto(convertAttachment(src.getPhoto()));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.dstu3.model.Person.PersonLinkComponent t : src.getLink())
      tgt.addLink(convertPersonLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Person convertPerson(org.hl7.fhir.r4.model.Person src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Person tgt = new org.hl7.fhir.dstu3.model.Person();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    for (org.hl7.fhir.r4.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasPhoto())
      tgt.setPhoto(convertAttachment(src.getPhoto()));
    if (src.hasManagingOrganization())
      tgt.setManagingOrganization(convertReference(src.getManagingOrganization()));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.r4.model.Person.PersonLinkComponent t : src.getLink())
      tgt.addLink(convertPersonLinkComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.dstu3.model.Person.PersonLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.r4.model.Person.PersonLinkComponent();
    copyElement(src, tgt);
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasAssurance())
      tgt.setAssurance(convertIdentityAssuranceLevel(src.getAssurance()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.r4.model.Person.PersonLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.dstu3.model.Person.PersonLinkComponent();
    copyElement(src, tgt);
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasAssurance())
      tgt.setAssurance(convertIdentityAssuranceLevel(src.getAssurance()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException {
    org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.PositiveIntType tgt = new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Practitioner convertPractitioner(org.hl7.fhir.dstu3.model.Practitioner src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Practitioner tgt = new org.hl7.fhir.r4.model.Practitioner();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.dstu3.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    for (org.hl7.fhir.dstu3.model.Attachment t : src.getPhoto())
      tgt.addPhoto(convertAttachment(t));
    for (org.hl7.fhir.dstu3.model.Practitioner.PractitionerQualificationComponent t : src.getQualification())
      tgt.addQualification(convertPractitionerQualificationComponent(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCommunication())
      tgt.addCommunication(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Practitioner convertPractitioner(org.hl7.fhir.r4.model.Practitioner src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Practitioner tgt = new org.hl7.fhir.dstu3.model.Practitioner();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    for (org.hl7.fhir.r4.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.r4.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    for (org.hl7.fhir.r4.model.Attachment t : src.getPhoto())
      tgt.addPhoto(convertAttachment(t));
    for (org.hl7.fhir.r4.model.Practitioner.PractitionerQualificationComponent t : src.getQualification())
      tgt.addQualification(convertPractitionerQualificationComponent(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCommunication())
      tgt.addCommunication(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Practitioner.PractitionerQualificationComponent convertPractitionerQualificationComponent(org.hl7.fhir.dstu3.model.Practitioner.PractitionerQualificationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Practitioner.PractitionerQualificationComponent tgt = new org.hl7.fhir.r4.model.Practitioner.PractitionerQualificationComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasIssuer())
      tgt.setIssuer(convertReference(src.getIssuer()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Practitioner.PractitionerQualificationComponent convertPractitionerQualificationComponent(org.hl7.fhir.r4.model.Practitioner.PractitionerQualificationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Practitioner.PractitionerQualificationComponent tgt = new org.hl7.fhir.dstu3.model.Practitioner.PractitionerQualificationComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasIssuer())
      tgt.setIssuer(convertReference(src.getIssuer()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.PractitionerRole convertPractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.PractitionerRole tgt = new org.hl7.fhir.r4.model.PractitionerRole();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasPractitioner())
      tgt.setPractitioner(convertReference(src.getPractitioner()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCode())
      tgt.addCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getLocation())
      tgt.addLocation(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getHealthcareService())
      tgt.addHealthcareService(convertReference(t));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleAvailableTimeComponent t : src.getAvailableTime())
      tgt.addAvailableTime(convertPractitionerRoleAvailableTimeComponent(t));
    for (org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleNotAvailableComponent t : src.getNotAvailable())
      tgt.addNotAvailable(convertPractitionerRoleNotAvailableComponent(t));
    if (src.hasAvailabilityExceptions())
      tgt.setAvailabilityExceptions(src.getAvailabilityExceptions());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.PractitionerRole convertPractitionerRole(org.hl7.fhir.r4.model.PractitionerRole src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.PractitionerRole tgt = new org.hl7.fhir.dstu3.model.PractitionerRole();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasPractitioner())
      tgt.setPractitioner(convertReference(src.getPractitioner()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCode())
      tgt.addCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getLocation())
      tgt.addLocation(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getHealthcareService())
      tgt.addHealthcareService(convertReference(t));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    for (org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleAvailableTimeComponent t : src.getAvailableTime())
      tgt.addAvailableTime(convertPractitionerRoleAvailableTimeComponent(t));
    for (org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleNotAvailableComponent t : src.getNotAvailable())
      tgt.addNotAvailable(convertPractitionerRoleNotAvailableComponent(t));
    if (src.hasAvailabilityExceptions())
      tgt.setAvailabilityExceptions(src.getAvailabilityExceptions());
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleAvailableTimeComponent convertPractitionerRoleAvailableTimeComponent(org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleAvailableTimeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleAvailableTimeComponent tgt = new org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleAvailableTimeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek> t : src.getDaysOfWeek())
      tgt.addDaysOfWeek(convertDaysOfWeek(t.getValue()));
    if (src.hasAllDay())
      tgt.setAllDay(src.getAllDay());
    if (src.hasAvailableStartTime())
      tgt.setAvailableStartTime(src.getAvailableStartTime());
    if (src.hasAvailableEndTime())
      tgt.setAvailableEndTime(src.getAvailableEndTime());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleAvailableTimeComponent convertPractitionerRoleAvailableTimeComponent(org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleAvailableTimeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleAvailableTimeComponent tgt = new org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleAvailableTimeComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek> t : src.getDaysOfWeek())
      tgt.addDaysOfWeek(convertDaysOfWeek(t.getValue()));
    if (src.hasAllDay())
      tgt.setAllDay(src.getAllDay());
    if (src.hasAvailableStartTime())
      tgt.setAvailableStartTime(src.getAvailableStartTime());
    if (src.hasAvailableEndTime())
      tgt.setAvailableEndTime(src.getAvailableEndTime());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleNotAvailableComponent convertPractitionerRoleNotAvailableComponent(org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleNotAvailableComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleNotAvailableComponent tgt = new org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleNotAvailableComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasDuring())
      tgt.setDuring(convertPeriod(src.getDuring()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleNotAvailableComponent convertPractitionerRoleNotAvailableComponent(org.hl7.fhir.r4.model.PractitionerRole.PractitionerRoleNotAvailableComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleNotAvailableComponent tgt = new org.hl7.fhir.dstu3.model.PractitionerRole.PractitionerRoleNotAvailableComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasDuring())
      tgt.setDuring(convertPeriod(src.getDuring()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Procedure convertProcedure(org.hl7.fhir.dstu3.model.Procedure src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Procedure tgt = new org.hl7.fhir.r4.model.Procedure();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertProcedureStatus(src.getStatus()));
    if (src.hasNotDone())
      tgt.setNotDone(src.getNotDone());
    if (src.hasNotDoneReason())
      tgt.setNotDoneReason(convertCodeableConcept(src.getNotDoneReason()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasPerformed())
      tgt.setPerformed(convertType(src.getPerformed()));
    for (org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent t : src.getPerformer())
      tgt.addPerformer(convertProcedurePerformerComponent(t));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    if (src.hasOutcome())
      tgt.setOutcome(convertCodeableConcept(src.getOutcome()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReport())
      tgt.addReport(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getComplication())
      tgt.addComplication(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getComplicationDetail())
      tgt.addComplicationDetail(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getFollowUp())
      tgt.addFollowUp(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice())
      tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getUsedReference())
      tgt.addUsedReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getUsedCode())
      tgt.addUsedCode(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Procedure convertProcedure(org.hl7.fhir.r4.model.Procedure src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Procedure tgt = new org.hl7.fhir.dstu3.model.Procedure();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertProcedureStatus(src.getStatus()));
    if (src.hasNotDone())
      tgt.setNotDone(src.getNotDone());
    if (src.hasNotDoneReason())
      tgt.setNotDoneReason(convertCodeableConcept(src.getNotDoneReason()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasPerformed())
      tgt.setPerformed(convertType(src.getPerformed()));
    for (org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent t : src.getPerformer())
      tgt.addPerformer(convertProcedurePerformerComponent(t));
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    if (src.hasOutcome())
      tgt.setOutcome(convertCodeableConcept(src.getOutcome()));
    for (org.hl7.fhir.r4.model.Reference t : src.getReport())
      tgt.addReport(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getComplication())
      tgt.addComplication(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getComplicationDetail())
      tgt.addComplicationDetail(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getFollowUp())
      tgt.addFollowUp(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice())
      tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getUsedReference())
      tgt.addUsedReference(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getUsedCode())
      tgt.addUsedCode(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Claim.ProcedureComponent convertProcedureComponent(org.hl7.fhir.dstu3.model.Claim.ProcedureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.ProcedureComponent tgt = new org.hl7.fhir.r4.model.Claim.ProcedureComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasProcedure())
      tgt.setProcedure(convertType(src.getProcedure()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.ProcedureComponent convertProcedureComponent(org.hl7.fhir.r4.model.Claim.ProcedureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.ProcedureComponent tgt = new org.hl7.fhir.dstu3.model.Claim.ProcedureComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasProcedure())
      tgt.setProcedure(convertType(src.getProcedure()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.dstu3.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent();
    copyElement(src, tgt);
    if (src.hasAction())
      tgt.setAction(convertCodeableConcept(src.getAction()));
    if (src.hasManipulated())
      tgt.setManipulated(convertReference(src.getManipulated()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.dstu3.model.Procedure.ProcedureFocalDeviceComponent();
    copyElement(src, tgt);
    if (src.hasAction())
      tgt.setAction(convertCodeableConcept(src.getAction()));
    if (src.hasManipulated())
      tgt.setManipulated(convertReference(src.getManipulated()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent convertProcedurePerformerComponent(org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent convertProcedurePerformerComponent(org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent tgt = new org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertCodeableConcept(src.getRole()));
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ProcedureRequest convertProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ProcedureRequest tgt = new org.hl7.fhir.r4.model.ProcedureRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    if (src.hasRequisition())
      tgt.setRequisition(convertIdentifier(src.getRequisition()));
    if (src.hasStatus())
      tgt.setStatus(convertProcedureRequestStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertProcedureRequestIntent(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertProcedureRequestPriority(src.getPriority()));
    if (src.hasDoNotPerform())
      tgt.setDoNotPerform(src.getDoNotPerform());
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAsNeeded())
      tgt.setAsNeeded(convertType(src.getAsNeeded()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertProcedureRequestRequesterComponent(src.getRequester()));
    if (src.hasPerformerType())
      tgt.setPerformerType(convertCodeableConcept(src.getPerformerType()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInfo())
      tgt.addSupportingInfo(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSpecimen())
      tgt.addSpecimen(convertReference(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRelevantHistory())
      tgt.addRelevantHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ProcedureRequest convertProcedureRequest(org.hl7.fhir.r4.model.ProcedureRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ProcedureRequest tgt = new org.hl7.fhir.dstu3.model.ProcedureRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    if (src.hasRequisition())
      tgt.setRequisition(convertIdentifier(src.getRequisition()));
    if (src.hasStatus())
      tgt.setStatus(convertProcedureRequestStatus(src.getStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertProcedureRequestIntent(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertProcedureRequestPriority(src.getPriority()));
    if (src.hasDoNotPerform())
      tgt.setDoNotPerform(src.getDoNotPerform());
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAsNeeded())
      tgt.setAsNeeded(convertType(src.getAsNeeded()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertProcedureRequestRequesterComponent(src.getRequester()));
    if (src.hasPerformerType())
      tgt.setPerformerType(convertCodeableConcept(src.getPerformerType()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInfo())
      tgt.addSupportingInfo(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getSpecimen())
      tgt.addSpecimen(convertReference(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodySite())
      tgt.addBodySite(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getRelevantHistory())
      tgt.addRelevantHistory(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent convertProcedureRequestIntent(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.PLAN;
    case ORDER: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.ORDER;
    case ORIGINALORDER: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.ORIGINALORDER;
    case REFLEXORDER: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.REFLEXORDER;
    case FILLERORDER: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.FILLERORDER;
    case INSTANCEORDER: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER;
    case OPTION: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.OPTION;
    default: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent convertProcedureRequestIntent(org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.PLAN;
    case ORDER: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.ORDER;
    case ORIGINALORDER: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.ORIGINALORDER;
    case REFLEXORDER: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.REFLEXORDER;
    case FILLERORDER: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.FILLERORDER;
    case INSTANCEORDER: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER;
    case OPTION: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.OPTION;
    default: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority convertProcedureRequestPriority(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.URGENT;
    case ASAP: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ASAP;
    case STAT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.STAT;
    default: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority convertProcedureRequestPriority(org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.URGENT;
    case ASAP: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.ASAP;
    case STAT: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.STAT;
    default: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestRequesterComponent convertProcedureRequestRequesterComponent(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestRequesterComponent tgt = new org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestRequesterComponent convertProcedureRequestRequesterComponent(org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestRequesterComponent tgt = new org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus convertProcedureRequestStatus(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus convertProcedureRequestStatus(org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PREPARATION: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.PREPARATION;
    case INPROGRESS: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.INPROGRESS;
    case SUSPENDED: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.SUSPENDED;
    case ABORTED: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ABORTED;
    case COMPLETED: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.r4.model.Procedure.ProcedureStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PREPARATION: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.PREPARATION;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.INPROGRESS;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.SUSPENDED;
    case ABORTED: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.ABORTED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ProcessRequest convertProcessRequest(org.hl7.fhir.dstu3.model.ProcessRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ProcessRequest tgt = new org.hl7.fhir.r4.model.ProcessRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertProcessRequestStatus(src.getStatus()));
    if (src.hasAction())
      tgt.setAction(convertActionList(src.getAction()));
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasRequest())
      tgt.setRequest(convertReference(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertReference(src.getResponse()));
    if (src.hasNullify())
      tgt.setNullify(src.getNullify());
    if (src.hasReference())
      tgt.setReference(src.getReference());
    for (org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent t : src.getItem())
      tgt.addItem(convertItemsComponent(t));
    for (org.hl7.fhir.dstu3.model.StringType t : src.getInclude())
      tgt.addInclude(t.getValue());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getExclude())
      tgt.addExclude(t.getValue());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ProcessRequest convertProcessRequest(org.hl7.fhir.r4.model.ProcessRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ProcessRequest tgt = new org.hl7.fhir.dstu3.model.ProcessRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertProcessRequestStatus(src.getStatus()));
    if (src.hasAction())
      tgt.setAction(convertActionList(src.getAction()));
    if (src.hasTarget())
      tgt.setTarget(convertReference(src.getTarget()));
    if (src.hasCreated())
      tgt.setCreated(src.getCreated());
    if (src.hasProvider())
      tgt.setProvider(convertReference(src.getProvider()));
    if (src.hasOrganization())
      tgt.setOrganization(convertReference(src.getOrganization()));
    if (src.hasRequest())
      tgt.setRequest(convertReference(src.getRequest()));
    if (src.hasResponse())
      tgt.setResponse(convertReference(src.getResponse()));
    if (src.hasNullify())
      tgt.setNullify(src.getNullify());
    if (src.hasReference())
      tgt.setReference(src.getReference());
    for (org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent t : src.getItem())
      tgt.addItem(convertItemsComponent(t));
    for (org.hl7.fhir.r4.model.StringType t : src.getInclude())
      tgt.addInclude(t.getValue());
    for (org.hl7.fhir.r4.model.StringType t : src.getExclude())
      tgt.addExclude(t.getValue());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ProcessRequest.ProcessRequestStatus convertProcessRequestStatus(org.hl7.fhir.dstu3.model.ProcessRequest.ProcessRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.ProcessRequest.ProcessRequestStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.r4.model.ProcessRequest.ProcessRequestStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.r4.model.ProcessRequest.ProcessRequestStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.ProcessRequest.ProcessRequestStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.ProcessRequest.ProcessRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ProcessRequest.ProcessRequestStatus convertProcessRequestStatus(org.hl7.fhir.r4.model.ProcessRequest.ProcessRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.ProcessRequest.ProcessRequestStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.dstu3.model.ProcessRequest.ProcessRequestStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.dstu3.model.ProcessRequest.ProcessRequestStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.ProcessRequest.ProcessRequestStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.ProcessRequest.ProcessRequestStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CodeSystem.PropertyComponent convertPropertyComponent(org.hl7.fhir.dstu3.model.CodeSystem.PropertyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CodeSystem.PropertyComponent tgt = new org.hl7.fhir.r4.model.CodeSystem.PropertyComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasUri())
      tgt.setUri(src.getUri());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasType())
      tgt.setType(convertPropertyType(src.getType()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CodeSystem.PropertyComponent convertPropertyComponent(org.hl7.fhir.r4.model.CodeSystem.PropertyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CodeSystem.PropertyComponent tgt = new org.hl7.fhir.dstu3.model.CodeSystem.PropertyComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasUri())
      tgt.setUri(src.getUri());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasType())
      tgt.setType(convertPropertyType(src.getType()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation convertPropertyRepresentation(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case XMLATTR: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR;
    case XMLTEXT: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT;
    case TYPEATTR: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR;
    case CDATEXT: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT;
    case XHTML: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XHTML;
    default: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation convertPropertyRepresentation(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case XMLATTR: return org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR;
    case XMLTEXT: return org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLTEXT;
    case TYPEATTR: return org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.TYPEATTR;
    case CDATEXT: return org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.CDATEXT;
    case XHTML: return org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XHTML;
    default: return org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL;
  }
}

  private static org.hl7.fhir.r4.model.CodeSystem.PropertyType convertPropertyType(org.hl7.fhir.dstu3.model.CodeSystem.PropertyType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CODE: return org.hl7.fhir.r4.model.CodeSystem.PropertyType.CODE;
    case CODING: return org.hl7.fhir.r4.model.CodeSystem.PropertyType.CODING;
    case STRING: return org.hl7.fhir.r4.model.CodeSystem.PropertyType.STRING;
    case INTEGER: return org.hl7.fhir.r4.model.CodeSystem.PropertyType.INTEGER;
    case BOOLEAN: return org.hl7.fhir.r4.model.CodeSystem.PropertyType.BOOLEAN;
    case DATETIME: return org.hl7.fhir.r4.model.CodeSystem.PropertyType.DATETIME;
    default: return org.hl7.fhir.r4.model.CodeSystem.PropertyType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CodeSystem.PropertyType convertPropertyType(org.hl7.fhir.r4.model.CodeSystem.PropertyType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CODE: return org.hl7.fhir.dstu3.model.CodeSystem.PropertyType.CODE;
    case CODING: return org.hl7.fhir.dstu3.model.CodeSystem.PropertyType.CODING;
    case STRING: return org.hl7.fhir.dstu3.model.CodeSystem.PropertyType.STRING;
    case INTEGER: return org.hl7.fhir.dstu3.model.CodeSystem.PropertyType.INTEGER;
    case BOOLEAN: return org.hl7.fhir.dstu3.model.CodeSystem.PropertyType.BOOLEAN;
    case DATETIME: return org.hl7.fhir.dstu3.model.CodeSystem.PropertyType.DATETIME;
    default: return org.hl7.fhir.dstu3.model.CodeSystem.PropertyType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Provenance convertProvenance(org.hl7.fhir.dstu3.model.Provenance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Provenance tgt = new org.hl7.fhir.r4.model.Provenance();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Reference t : src.getTarget())
      tgt.addTarget(convertReference(t));
    if (src.hasRecorded())
      tgt.setRecorded(src.getRecorded());
    for (org.hl7.fhir.dstu3.model.UriType t : src.getPolicy())
      tgt.addPolicy(t.getValue());
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent())
      tgt.addAgent(convertProvenanceAgentComponent(t));
    for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent t : src.getEntity())
      tgt.addEntity(convertProvenanceEntityComponent(t));
    for (org.hl7.fhir.dstu3.model.Signature t : src.getSignature())
      tgt.addSignature(convertSignature(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Provenance convertProvenance(org.hl7.fhir.r4.model.Provenance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Provenance tgt = new org.hl7.fhir.dstu3.model.Provenance();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Reference t : src.getTarget())
      tgt.addTarget(convertReference(t));
    if (src.hasRecorded())
      tgt.setRecorded(src.getRecorded());
    for (org.hl7.fhir.r4.model.UriType t : src.getPolicy())
      tgt.addPolicy(t.getValue());
    if (src.hasLocation())
      tgt.setLocation(convertReference(src.getLocation()));
    for (org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent t : src.getAgent())
      tgt.addAgent(convertProvenanceAgentComponent(t));
    for (org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent t : src.getEntity())
      tgt.addEntity(convertProvenanceEntityComponent(t));
    for (org.hl7.fhir.r4.model.Signature t : src.getSignature())
      tgt.addSignature(convertSignature(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    if (src.hasWho())
      tgt.setWho(convertType(src.getWho()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertType(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    if (src.hasWho())
      tgt.setWho(convertType(src.getWho()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertType(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertProvenanceEntityRole(src.getRole()));
    if (src.hasWhat())
      tgt.setWhat(convertType(src.getWhat()));
    for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent())
      tgt.addAgent(convertProvenanceAgentComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent();
    copyElement(src, tgt);
    if (src.hasRole())
      tgt.setRole(convertProvenanceEntityRole(src.getRole()));
    if (src.hasWhat())
      tgt.setWhat(convertType(src.getWhat()));
    for (org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent t : src.getAgent())
      tgt.addAgent(convertProvenanceAgentComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole convertProvenanceEntityRole(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DERIVATION: return org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.DERIVATION;
    case REVISION: return org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.REVISION;
    case QUOTATION: return org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.QUOTATION;
    case SOURCE: return org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.SOURCE;
    case REMOVAL: return org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.REMOVAL;
    default: return org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole convertProvenanceEntityRole(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DERIVATION: return org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.DERIVATION;
    case REVISION: return org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REVISION;
    case QUOTATION: return org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.QUOTATION;
    case SOURCE: return org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.SOURCE;
    case REMOVAL: return org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REMOVAL;
    default: return org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Enumerations.PublicationStatus convertPublicationStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE;
    case RETIRED: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED;
    case UNKNOWN: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus convertPublicationStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE;
    case RETIRED: return org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Sequence.QualityType convertQualityType(org.hl7.fhir.dstu3.model.Sequence.QualityType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INDEL: return org.hl7.fhir.r4.model.Sequence.QualityType.INDEL;
    case SNP: return org.hl7.fhir.r4.model.Sequence.QualityType.SNP;
    case UNKNOWN: return org.hl7.fhir.r4.model.Sequence.QualityType.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Sequence.QualityType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Sequence.QualityType convertQualityType(org.hl7.fhir.r4.model.Sequence.QualityType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INDEL: return org.hl7.fhir.dstu3.model.Sequence.QualityType.INDEL;
    case SNP: return org.hl7.fhir.dstu3.model.Sequence.QualityType.SNP;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Sequence.QualityType.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Sequence.QualityType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasComparator())
      tgt.setComparator(convertQuantityComparator(src.getComparator()));
    if (src.hasUnit())
      tgt.setUnit(src.getUnit());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasComparator())
      tgt.setComparator(convertQuantityComparator(src.getComparator()));
    if (src.hasUnit())
      tgt.setUnit(src.getUnit());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Quantity.QuantityComparator convertQuantityComparator(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LESS_THAN: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN;
    case LESS_OR_EQUAL: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL;
    case GREATER_OR_EQUAL: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL;
    case GREATER_THAN: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN;
    default: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator convertQuantityComparator(org.hl7.fhir.r4.model.Quantity.QuantityComparator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LESS_THAN: return org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN;
    case LESS_OR_EQUAL: return org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL;
    case GREATER_OR_EQUAL: return org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL;
    case GREATER_THAN: return org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN;
    default: return org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu3.model.Questionnaire src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Questionnaire tgt = new org.hl7.fhir.r4.model.Questionnaire();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasApprovalDate())
      tgt.setApprovalDate(src.getApprovalDate());
    if (src.hasLastReviewDate())
      tgt.setLastReviewDate(src.getLastReviewDate());
    if (src.hasEffectivePeriod())
      tgt.setEffectivePeriod(convertPeriod(src.getEffectivePeriod()));
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.dstu3.model.Coding t : src.getCode())
      tgt.addCode(convertCoding(t));
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getSubjectType())
      tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r4.model.Questionnaire src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Questionnaire tgt = new org.hl7.fhir.dstu3.model.Questionnaire();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasApprovalDate())
      tgt.setApprovalDate(src.getApprovalDate());
    if (src.hasLastReviewDate())
      tgt.setLastReviewDate(src.getLastReviewDate());
    if (src.hasEffectivePeriod())
      tgt.setEffectivePeriod(convertPeriod(src.getEffectivePeriod()));
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.r4.model.Coding t : src.getCode())
      tgt.addCode(convertCoding(t));
    for (org.hl7.fhir.r4.model.CodeType t : src.getSubjectType())
      tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireItemComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent();
    copyElement(src, tgt);
    if (src.hasLinkId())
      tgt.setLinkId(src.getLinkId());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    for (org.hl7.fhir.dstu3.model.Coding t : src.getCode())
      tgt.addCode(convertCoding(t));
    if (src.hasPrefix())
      tgt.setPrefix(src.getPrefix());
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasType())
      tgt.setType(convertQuestionnaireItemType(src.getType()));
    for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent t : src.getEnableWhen())
      tgt.addEnableWhen(convertQuestionnaireItemEnableWhenComponent(t));
    if (src.hasRequired())
      tgt.setRequired(src.getRequired());
    if (src.hasRepeats())
      tgt.setRepeats(src.getRepeats());
    if (src.hasReadOnly())
      tgt.setReadOnly(src.getReadOnly());
    if (src.hasMaxLength())
      tgt.setMaxLength(src.getMaxLength());
    if (src.hasOptions())
      tgt.setOptions(convertReference(src.getOptions()));
    for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent t : src.getOption())
      tgt.addOption(convertQuestionnaireItemOptionComponent(t));
    if (src.hasInitial())
      tgt.setInitial(convertType(src.getInitial()));
    for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireItemComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent();
    copyElement(src, tgt);
    if (src.hasLinkId())
      tgt.setLinkId(src.getLinkId());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    for (org.hl7.fhir.r4.model.Coding t : src.getCode())
      tgt.addCode(convertCoding(t));
    if (src.hasPrefix())
      tgt.setPrefix(src.getPrefix());
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasType())
      tgt.setType(convertQuestionnaireItemType(src.getType()));
    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent t : src.getEnableWhen())
      tgt.addEnableWhen(convertQuestionnaireItemEnableWhenComponent(t));
    if (src.hasRequired())
      tgt.setRequired(src.getRequired());
    if (src.hasRepeats())
      tgt.setRepeats(src.getRepeats());
    if (src.hasReadOnly())
      tgt.setReadOnly(src.getReadOnly());
    if (src.hasMaxLength())
      tgt.setMaxLength(src.getMaxLength());
    if (src.hasOptions())
      tgt.setOptions(convertReference(src.getOptions()));
    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOptionComponent t : src.getOption())
      tgt.addOption(convertQuestionnaireItemOptionComponent(t));
    if (src.hasInitial())
      tgt.setInitial(convertType(src.getInitial()));
    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent convertQuestionnaireItemEnableWhenComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent();
    copyElement(src, tgt);
    if (src.hasQuestion())
      tgt.setQuestion(src.getQuestion());
    if (src.hasHasAnswer())
      tgt.setHasAnswer(src.getHasAnswer());
    if (src.hasAnswer())
      tgt.setAnswer(convertType(src.getAnswer()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent convertQuestionnaireItemEnableWhenComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent tgt = new org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent();
    copyElement(src, tgt);
    if (src.hasQuestion())
      tgt.setQuestion(src.getQuestion());
    if (src.hasHasAnswer())
      tgt.setHasAnswer(src.getHasAnswer());
    if (src.hasAnswer())
      tgt.setAnswer(convertType(src.getAnswer()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOptionComponent convertQuestionnaireItemOptionComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOptionComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOptionComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent convertQuestionnaireItemOptionComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOptionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent tgt = new org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType convertQuestionnaireItemType(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GROUP: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP;
    case DISPLAY: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DISPLAY;
    case QUESTION: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.QUESTION;
    case BOOLEAN: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.BOOLEAN;
    case DECIMAL: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DECIMAL;
    case INTEGER: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.INTEGER;
    case DATE: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATE;
    case DATETIME: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATETIME;
    case TIME: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TIME;
    case STRING: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.STRING;
    case TEXT: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TEXT;
    case URL: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.URL;
    case CHOICE: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.CHOICE;
    case OPENCHOICE: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.OPENCHOICE;
    case ATTACHMENT: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.ATTACHMENT;
    case REFERENCE: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.REFERENCE;
    case QUANTITY: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.QUANTITY;
    default: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType convertQuestionnaireItemType(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case GROUP: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.GROUP;
    case DISPLAY: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.DISPLAY;
    case QUESTION: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.QUESTION;
    case BOOLEAN: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.BOOLEAN;
    case DECIMAL: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.DECIMAL;
    case INTEGER: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.INTEGER;
    case DATE: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.DATE;
    case DATETIME: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.DATETIME;
    case TIME: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.TIME;
    case STRING: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.STRING;
    case TEXT: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.TEXT;
    case URL: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.URL;
    case CHOICE: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.CHOICE;
    case OPENCHOICE: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.OPENCHOICE;
    case ATTACHMENT: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.ATTACHMENT;
    case REFERENCE: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.REFERENCE;
    case QUANTITY: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.QUANTITY;
    default: return org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.QuestionnaireResponse convertQuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.QuestionnaireResponse tgt = new org.hl7.fhir.r4.model.QuestionnaireResponse();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getParent())
      tgt.addParent(convertReference(t));
    if (src.hasQuestionnaire())
      tgt.setQuestionnaire(convertReference(src.getQuestionnaire()));
    if (src.hasStatus())
      tgt.setStatus(convertQuestionnaireResponseStatus(src.getStatus()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasAuthored())
      tgt.setAuthored(src.getAuthored());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.QuestionnaireResponse convertQuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.QuestionnaireResponse tgt = new org.hl7.fhir.dstu3.model.QuestionnaireResponse();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getParent())
      tgt.addParent(convertReference(t));
    if (src.hasQuestionnaire())
      tgt.setQuestionnaire(convertReference(src.getQuestionnaire()));
    if (src.hasStatus())
      tgt.setStatus(convertQuestionnaireResponseStatus(src.getStatus()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasAuthored())
      tgt.setAuthored(src.getAuthored());
    if (src.hasAuthor())
      tgt.setAuthor(convertReference(src.getAuthor()));
    if (src.hasSource())
      tgt.setSource(convertReference(src.getSource()));
    for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent convertQuestionnaireResponseItemAnswerComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent tgt = new org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent convertQuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent tgt = new org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent convertQuestionnaireResponseItemComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent tgt = new org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent();
    copyElement(src, tgt);
    if (src.hasLinkId())
      tgt.setLinkId(src.getLinkId());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent t : src.getAnswer())
      tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t));
    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent convertQuestionnaireResponseItemComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent tgt = new org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent();
    copyElement(src, tgt);
    if (src.hasLinkId())
      tgt.setLinkId(src.getLinkId());
    if (src.hasDefinition())
      tgt.setDefinition(src.getDefinition());
    if (src.hasText())
      tgt.setText(src.getText());
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent t : src.getAnswer())
      tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t));
    for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus convertQuestionnaireResponseStatus(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INPROGRESS: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS;
    case COMPLETED: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED;
    case AMENDED: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.STOPPED;
    default: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus convertQuestionnaireResponseStatus(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INPROGRESS: return org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS;
    case COMPLETED: return org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED;
    case AMENDED: return org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.ENTEREDINERROR;
    case STOPPED: return org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.STOPPED;
    default: return org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range();
    copyElement(src, tgt);
    if (src.hasLow())
      tgt.setLow(convertSimpleQuantity(src.getLow()));
    if (src.hasHigh())
      tgt.setHigh(convertSimpleQuantity(src.getHigh()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range();
    copyElement(src, tgt);
    if (src.hasLow())
      tgt.setLow(convertSimpleQuantity(src.getLow()));
    if (src.hasHigh())
      tgt.setHigh(convertSimpleQuantity(src.getHigh()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio();
    copyElement(src, tgt);
    if (src.hasNumerator())
      tgt.setNumerator(convertQuantity(src.getNumerator()));
    if (src.hasDenominator())
      tgt.setDenominator(convertQuantity(src.getDenominator()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio();
    copyElement(src, tgt);
    if (src.hasNumerator())
      tgt.setNumerator(convertQuantity(src.getNumerator()));
    if (src.hasDenominator())
      tgt.setDenominator(convertQuantity(src.getDenominator()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference();
    copyElement(src, tgt);
    if (src.hasReference())
      tgt.setReference(src.getReference());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference();
    copyElement(src, tgt);
    if (src.hasReference())
      tgt.setReference(src.getReference());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy convertReferenceHandlingPolicy(org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LITERAL: return org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy.LITERAL;
    case LOGICAL: return org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy.LOGICAL;
    case RESOLVES: return org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy.RESOLVES;
    case ENFORCED: return org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy.ENFORCED;
    case LOCAL: return org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy.LOCAL;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy convertReferenceHandlingPolicy(org.hl7.fhir.r4.model.CapabilityStatement.ReferenceHandlingPolicy src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case LITERAL: return org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy.LITERAL;
    case LOGICAL: return org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy.LOGICAL;
    case RESOLVES: return org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy.RESOLVES;
    case ENFORCED: return org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy.ENFORCED;
    case LOCAL: return org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy.LOCAL;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.ReferenceHandlingPolicy.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules convertReferenceVersionRules(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EITHER: return org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER;
    case INDEPENDENT: return org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT;
    case SPECIFIC: return org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC;
    default: return org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules convertReferenceVersionRules(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EITHER: return org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.EITHER;
    case INDEPENDENT: return org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT;
    case SPECIFIC: return org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.SPECIFIC;
    default: return org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority convertReferralPriority(org.hl7.fhir.dstu3.model.ReferralRequest.ReferralPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.URGENT;
    case ASAP: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ASAP;
    case STAT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.STAT;
    default: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ProcedureRequest convertReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ProcedureRequest tgt = new org.hl7.fhir.r4.model.ProcedureRequest();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition())
      tgt.addDefinition(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReplaces())
      tgt.addReplaces(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertReferralRequestStatus(src.getStatus()));
    if (src.hasType())
      tgt.setCode(convertCodeableConcept(src.getType()));
    if (src.hasPriority())
      tgt.setPriority(convertReferralPriority(src.getPriority()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertReferralRequestRequesterComponent(src.getRequester()));
    if (src.hasSpecialty())
      tgt.setPerformerType(convertCodeableConcept(src.getSpecialty()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
      tgt.addReasonCode(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
      tgt.addReasonReference(convertReference(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInfo())
      tgt.addSupportingInfo(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRelevantHistory())
      tgt.addRelevantHistory(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestRequesterComponent convertReferralRequestRequesterComponent(org.hl7.fhir.dstu3.model.ReferralRequest.ReferralRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestRequesterComponent tgt = new org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus convertReferralRequestStatus(org.hl7.fhir.dstu3.model.ReferralRequest.ReferralRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DocumentReference.ReferredDocumentStatus convertReferredDocumentStatus(org.hl7.fhir.dstu3.model.DocumentReference.ReferredDocumentStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRELIMINARY: return org.hl7.fhir.r4.model.DocumentReference.ReferredDocumentStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.r4.model.DocumentReference.ReferredDocumentStatus.FINAL;
    case AMENDED: return org.hl7.fhir.r4.model.DocumentReference.ReferredDocumentStatus.AMENDED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.DocumentReference.ReferredDocumentStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.DocumentReference.ReferredDocumentStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DocumentReference.ReferredDocumentStatus convertReferredDocumentStatus(org.hl7.fhir.r4.model.DocumentReference.ReferredDocumentStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRELIMINARY: return org.hl7.fhir.dstu3.model.DocumentReference.ReferredDocumentStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.dstu3.model.DocumentReference.ReferredDocumentStatus.FINAL;
    case AMENDED: return org.hl7.fhir.dstu3.model.DocumentReference.ReferredDocumentStatus.AMENDED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.DocumentReference.ReferredDocumentStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.DocumentReference.ReferredDocumentStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.RelatedArtifact tgt = new org.hl7.fhir.r4.model.RelatedArtifact();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertRelatedArtifactType(src.getType()));
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasCitation())
      tgt.setCitation(src.getCitation());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasDocument())
      tgt.setDocument(convertAttachment(src.getDocument()));
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.RelatedArtifact tgt = new org.hl7.fhir.dstu3.model.RelatedArtifact();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertRelatedArtifactType(src.getType()));
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasCitation())
      tgt.setCitation(src.getCitation());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasDocument())
      tgt.setDocument(convertAttachment(src.getDocument()));
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType convertRelatedArtifactType(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DOCUMENTATION: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION;
    case JUSTIFICATION: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION;
    case CITATION: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.CITATION;
    case PREDECESSOR: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR;
    case SUCCESSOR: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR;
    case DERIVEDFROM: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM;
    case DEPENDSON: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DEPENDSON;
    case COMPOSEDOF: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF;
    default: return org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType convertRelatedArtifactType(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DOCUMENTATION: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION;
    case JUSTIFICATION: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION;
    case CITATION: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.CITATION;
    case PREDECESSOR: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR;
    case SUCCESSOR: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR;
    case DERIVEDFROM: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM;
    case DEPENDSON: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DEPENDSON;
    case COMPOSEDOF: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF;
    default: return org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Claim.RelatedClaimComponent convertRelatedClaimComponent(org.hl7.fhir.dstu3.model.Claim.RelatedClaimComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.RelatedClaimComponent tgt = new org.hl7.fhir.r4.model.Claim.RelatedClaimComponent();
    copyElement(src, tgt);
    if (src.hasClaim())
      tgt.setClaim(convertReference(src.getClaim()));
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    if (src.hasReference())
      tgt.setReference(convertIdentifier(src.getReference()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.RelatedClaimComponent convertRelatedClaimComponent(org.hl7.fhir.r4.model.Claim.RelatedClaimComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.RelatedClaimComponent tgt = new org.hl7.fhir.dstu3.model.Claim.RelatedClaimComponent();
    copyElement(src, tgt);
    if (src.hasClaim())
      tgt.setClaim(convertReference(src.getClaim()));
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    if (src.hasReference())
      tgt.setReference(convertIdentifier(src.getReference()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.RelatedPerson convertRelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.RelatedPerson tgt = new org.hl7.fhir.r4.model.RelatedPerson();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    for (org.hl7.fhir.dstu3.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    for (org.hl7.fhir.dstu3.model.Attachment t : src.getPhoto())
      tgt.addPhoto(convertAttachment(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.RelatedPerson convertRelatedPerson(org.hl7.fhir.r4.model.RelatedPerson src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.RelatedPerson tgt = new org.hl7.fhir.dstu3.model.RelatedPerson();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasRelationship())
      tgt.setRelationship(convertCodeableConcept(src.getRelationship()));
    for (org.hl7.fhir.r4.model.HumanName t : src.getName())
      tgt.addName(convertHumanName(t));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
      tgt.addTelecom(convertContactPoint(t));
    if (src.hasGender())
      tgt.setGender(convertAdministrativeGender(src.getGender()));
    if (src.hasBirthDate())
      tgt.setBirthDate(src.getBirthDate());
    for (org.hl7.fhir.r4.model.Address t : src.getAddress())
      tgt.addAddress(convertAddress(t));
    for (org.hl7.fhir.r4.model.Attachment t : src.getPhoto())
      tgt.addPhoto(convertAttachment(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Sequence.RepositoryType convertRepositoryType(org.hl7.fhir.dstu3.model.Sequence.RepositoryType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DIRECTLINK: return org.hl7.fhir.r4.model.Sequence.RepositoryType.DIRECTLINK;
    case OPENAPI: return org.hl7.fhir.r4.model.Sequence.RepositoryType.OPENAPI;
    case LOGIN: return org.hl7.fhir.r4.model.Sequence.RepositoryType.LOGIN;
    case OAUTH: return org.hl7.fhir.r4.model.Sequence.RepositoryType.OAUTH;
    case OTHER: return org.hl7.fhir.r4.model.Sequence.RepositoryType.OTHER;
    default: return org.hl7.fhir.r4.model.Sequence.RepositoryType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Sequence.RepositoryType convertRepositoryType(org.hl7.fhir.r4.model.Sequence.RepositoryType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DIRECTLINK: return org.hl7.fhir.dstu3.model.Sequence.RepositoryType.DIRECTLINK;
    case OPENAPI: return org.hl7.fhir.dstu3.model.Sequence.RepositoryType.OPENAPI;
    case LOGIN: return org.hl7.fhir.dstu3.model.Sequence.RepositoryType.LOGIN;
    case OAUTH: return org.hl7.fhir.dstu3.model.Sequence.RepositoryType.OAUTH;
    case OTHER: return org.hl7.fhir.dstu3.model.Sequence.RepositoryType.OTHER;
    default: return org.hl7.fhir.dstu3.model.Sequence.RepositoryType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.DeviceRequest.RequestPriority convertRequestPriority(org.hl7.fhir.dstu3.model.DeviceRequest.RequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.r4.model.DeviceRequest.RequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.r4.model.DeviceRequest.RequestPriority.URGENT;
    case ASAP: return org.hl7.fhir.r4.model.DeviceRequest.RequestPriority.ASAP;
    case STAT: return org.hl7.fhir.r4.model.DeviceRequest.RequestPriority.STAT;
    default: return org.hl7.fhir.r4.model.DeviceRequest.RequestPriority.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.DeviceRequest.RequestPriority convertRequestPriority(org.hl7.fhir.r4.model.DeviceRequest.RequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.dstu3.model.DeviceRequest.RequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.dstu3.model.DeviceRequest.RequestPriority.URGENT;
    case ASAP: return org.hl7.fhir.dstu3.model.DeviceRequest.RequestPriority.ASAP;
    case STAT: return org.hl7.fhir.dstu3.model.DeviceRequest.RequestPriority.STAT;
    default: return org.hl7.fhir.dstu3.model.DeviceRequest.RequestPriority.NULL;
  }
}

  private static org.hl7.fhir.r4.model.SupplyRequest.RequestPriority convertRequestPriority(org.hl7.fhir.dstu3.model.SupplyRequest.RequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.URGENT;
    case ASAP: return org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.ASAP;
    case STAT: return org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.STAT;
    default: return org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.SupplyRequest.RequestPriority convertRequestPriority(org.hl7.fhir.r4.model.SupplyRequest.RequestPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.dstu3.model.SupplyRequest.RequestPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.dstu3.model.SupplyRequest.RequestPriority.URGENT;
    case ASAP: return org.hl7.fhir.dstu3.model.SupplyRequest.RequestPriority.ASAP;
    case STAT: return org.hl7.fhir.dstu3.model.SupplyRequest.RequestPriority.STAT;
    default: return org.hl7.fhir.dstu3.model.SupplyRequest.RequestPriority.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ResearchStudy convertResearchStudy(org.hl7.fhir.dstu3.model.ResearchStudy src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ResearchStudy tgt = new org.hl7.fhir.r4.model.ResearchStudy();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getProtocol())
      tgt.addProtocol(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertResearchStudyStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getFocus())
      tgt.addFocus(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    for (org.hl7.fhir.dstu3.model.RelatedArtifact t : src.getRelatedArtifact())
      tgt.addRelatedArtifact(convertRelatedArtifact(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getKeyword())
      tgt.addKeyword(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEnrollment())
      tgt.addEnrollment(convertReference(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasSponsor())
      tgt.setSponsor(convertReference(src.getSponsor()));
    if (src.hasPrincipalInvestigator())
      tgt.setPrincipalInvestigator(convertReference(src.getPrincipalInvestigator()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSite())
      tgt.addSite(convertReference(t));
    if (src.hasReasonStopped())
      tgt.setReasonStopped(convertCodeableConcept(src.getReasonStopped()));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyArmComponent t : src.getArm())
      tgt.addArm(convertResearchStudyArmComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ResearchStudy convertResearchStudy(org.hl7.fhir.r4.model.ResearchStudy src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ResearchStudy tgt = new org.hl7.fhir.dstu3.model.ResearchStudy();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    for (org.hl7.fhir.r4.model.Reference t : src.getProtocol())
      tgt.addProtocol(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertResearchStudyStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getFocus())
      tgt.addFocus(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    for (org.hl7.fhir.r4.model.RelatedArtifact t : src.getRelatedArtifact())
      tgt.addRelatedArtifact(convertRelatedArtifact(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getKeyword())
      tgt.addKeyword(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.Reference t : src.getEnrollment())
      tgt.addEnrollment(convertReference(t));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasSponsor())
      tgt.setSponsor(convertReference(src.getSponsor()));
    if (src.hasPrincipalInvestigator())
      tgt.setPrincipalInvestigator(convertReference(src.getPrincipalInvestigator()));
    for (org.hl7.fhir.r4.model.Reference t : src.getSite())
      tgt.addSite(convertReference(t));
    if (src.hasReasonStopped())
      tgt.setReasonStopped(convertCodeableConcept(src.getReasonStopped()));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyArmComponent t : src.getArm())
      tgt.addArm(convertResearchStudyArmComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyArmComponent convertResearchStudyArmComponent(org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyArmComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyArmComponent tgt = new org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyArmComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyArmComponent convertResearchStudyArmComponent(org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyArmComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyArmComponent tgt = new org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyArmComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus convertResearchStudyStatus(org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus.DRAFT;
    case INPROGRESS: return org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus.INPROGRESS;
    case SUSPENDED: return org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus.SUSPENDED;
    case STOPPED: return org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus.STOPPED;
    case COMPLETED: return org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus convertResearchStudyStatus(org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus.DRAFT;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus.INPROGRESS;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus.SUSPENDED;
    case STOPPED: return org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus.STOPPED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.ResearchStudy.ResearchStudyStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ResearchSubject convertResearchSubject(org.hl7.fhir.dstu3.model.ResearchSubject src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ResearchSubject tgt = new org.hl7.fhir.r4.model.ResearchSubject();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertResearchSubjectStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasStudy())
      tgt.setStudy(convertReference(src.getStudy()));
    if (src.hasIndividual())
      tgt.setIndividual(convertReference(src.getIndividual()));
    if (src.hasAssignedArm())
      tgt.setAssignedArm(src.getAssignedArm());
    if (src.hasActualArm())
      tgt.setActualArm(src.getActualArm());
    if (src.hasConsent())
      tgt.setConsent(convertReference(src.getConsent()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ResearchSubject convertResearchSubject(org.hl7.fhir.r4.model.ResearchSubject src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ResearchSubject tgt = new org.hl7.fhir.dstu3.model.ResearchSubject();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertResearchSubjectStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    if (src.hasStudy())
      tgt.setStudy(convertReference(src.getStudy()));
    if (src.hasIndividual())
      tgt.setIndividual(convertReference(src.getIndividual()));
    if (src.hasAssignedArm())
      tgt.setAssignedArm(src.getAssignedArm());
    if (src.hasActualArm())
      tgt.setActualArm(src.getActualArm());
    if (src.hasConsent())
      tgt.setConsent(convertReference(src.getConsent()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus convertResearchSubjectStatus(org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CANDIDATE: return org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus.CANDIDATE;
    case ENROLLED: return org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus.ENROLLED;
    case ACTIVE: return org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus.SUSPENDED;
    case WITHDRAWN: return org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus.WITHDRAWN;
    case COMPLETED: return org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus.COMPLETED;
    default: return org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus convertResearchSubjectStatus(org.hl7.fhir.r4.model.ResearchSubject.ResearchSubjectStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CANDIDATE: return org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus.CANDIDATE;
    case ENROLLED: return org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus.ENROLLED;
    case ACTIVE: return org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus.SUSPENDED;
    case WITHDRAWN: return org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus.WITHDRAWN;
    case COMPLETED: return org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus.COMPLETED;
    default: return org.hl7.fhir.dstu3.model.ResearchSubject.ResearchSubjectStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException {
    if (src == null)
      return null;
    if (src instanceof org.hl7.fhir.dstu3.model.Parameters)
      return convertParameters((org.hl7.fhir.dstu3.model.Parameters) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Account)
      return convertAccount((org.hl7.fhir.dstu3.model.Account) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ActivityDefinition)
      return convertActivityDefinition((org.hl7.fhir.dstu3.model.ActivityDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.AllergyIntolerance)
      return convertAllergyIntolerance((org.hl7.fhir.dstu3.model.AllergyIntolerance) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Appointment)
      return convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src);
    if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse)
      return convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src);
    if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent)
      return convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Basic)
      return convertBasic((org.hl7.fhir.dstu3.model.Basic) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Binary)
      return convertBinary((org.hl7.fhir.dstu3.model.Binary) src);
    if (src instanceof org.hl7.fhir.dstu3.model.BodySite)
      return convertBodySite((org.hl7.fhir.dstu3.model.BodySite) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Bundle)
      return convertBundle((org.hl7.fhir.dstu3.model.Bundle) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement)
      return convertCapabilityStatement((org.hl7.fhir.dstu3.model.CapabilityStatement) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CarePlan)
      return convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CareTeam)
      return convertCareTeam((org.hl7.fhir.dstu3.model.CareTeam) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ChargeItem)
      return convertChargeItem((org.hl7.fhir.dstu3.model.ChargeItem) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Claim)
      return convertClaim((org.hl7.fhir.dstu3.model.Claim) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression)
      return convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem)
      return convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Communication)
      return convertCommunication((org.hl7.fhir.dstu3.model.Communication) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CommunicationRequest)
      return convertCommunicationRequest((org.hl7.fhir.dstu3.model.CommunicationRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition)
      return convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Composition)
      return convertComposition((org.hl7.fhir.dstu3.model.Composition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap)
      return convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Condition)
      return convertCondition((org.hl7.fhir.dstu3.model.Condition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Consent)
      return convertConsent((org.hl7.fhir.dstu3.model.Consent) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Contract)
      return convertContract((org.hl7.fhir.dstu3.model.Contract) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Coverage)
      return convertCoverage((org.hl7.fhir.dstu3.model.Coverage) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DataElement)
      return convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue)
      return convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Device)
      return convertDevice((org.hl7.fhir.dstu3.model.Device) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DeviceComponent)
      return convertDeviceComponent((org.hl7.fhir.dstu3.model.DeviceComponent) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DeviceMetric)
      return convertDeviceMetric((org.hl7.fhir.dstu3.model.DeviceMetric) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DeviceRequest)
      return convertDeviceRequest((org.hl7.fhir.dstu3.model.DeviceRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement)
      return convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport)
      return convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DocumentManifest)
      return convertDocumentManifest((org.hl7.fhir.dstu3.model.DocumentManifest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference)
      return convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src);
    if (src instanceof org.hl7.fhir.dstu3.model.EligibilityRequest)
      return convertEligibilityRequest((org.hl7.fhir.dstu3.model.EligibilityRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Encounter)
      return convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Endpoint)
      return convertEndpoint((org.hl7.fhir.dstu3.model.Endpoint) src);
    if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare)
      return convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ExpansionProfile)
      return convertExpansionProfile((org.hl7.fhir.dstu3.model.ExpansionProfile) src);
    if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory)
      return convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Flag)
      return convertFlag((org.hl7.fhir.dstu3.model.Flag) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Goal)
      return convertGoal((org.hl7.fhir.dstu3.model.Goal) src);
    if (src instanceof org.hl7.fhir.dstu3.model.GraphDefinition)
      return convertGraphDefinition((org.hl7.fhir.dstu3.model.GraphDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Group)
      return convertGroup((org.hl7.fhir.dstu3.model.Group) src);
    if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService)
      return convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ImagingManifest)
      return convertImagingManifest((org.hl7.fhir.dstu3.model.ImagingManifest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy)
      return convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Immunization)
      return convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ImmunizationRecommendation)
      return convertImmunizationRecommendation((org.hl7.fhir.dstu3.model.ImmunizationRecommendation) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide)
      return convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Linkage)
      return convertLinkage((org.hl7.fhir.dstu3.model.Linkage) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ListResource)
      return convertList((org.hl7.fhir.dstu3.model.ListResource) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Location)
      return convertLocation((org.hl7.fhir.dstu3.model.Location) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Measure)
      return convertMeasure((org.hl7.fhir.dstu3.model.Measure) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MeasureReport)
      return convertMeasureReport((org.hl7.fhir.dstu3.model.MeasureReport) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Media)
      return convertMedia((org.hl7.fhir.dstu3.model.Media) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Medication)
      return convertMedication((org.hl7.fhir.dstu3.model.Medication) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MedicationAdministration)
      return convertMedicationAdministration((org.hl7.fhir.dstu3.model.MedicationAdministration) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense)
      return convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MedicationRequest)
      return convertMedicationRequest((org.hl7.fhir.dstu3.model.MedicationRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement)
      return convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MessageDefinition)
      return convertMessageDefinition((org.hl7.fhir.dstu3.model.MessageDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader)
      return convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src);
    if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem)
      return convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src);
    if (src instanceof org.hl7.fhir.dstu3.model.NutritionOrder)
      return convertNutritionOrder((org.hl7.fhir.dstu3.model.NutritionOrder) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Observation)
      return convertObservation((org.hl7.fhir.dstu3.model.Observation) src);
    if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition)
      return convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome)
      return convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Organization)
      return convertOrganization((org.hl7.fhir.dstu3.model.Organization) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Patient)
      return convertPatient((org.hl7.fhir.dstu3.model.Patient) src);
    if (src instanceof org.hl7.fhir.dstu3.model.PaymentNotice)
      return convertPaymentNotice((org.hl7.fhir.dstu3.model.PaymentNotice) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Person)
      return convertPerson((org.hl7.fhir.dstu3.model.Person) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Practitioner)
      return convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src);
    if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole)
      return convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Procedure)
      return convertProcedure((org.hl7.fhir.dstu3.model.Procedure) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ProcedureRequest)
      return convertProcedureRequest((org.hl7.fhir.dstu3.model.ProcedureRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ProcessRequest)
      return convertProcessRequest((org.hl7.fhir.dstu3.model.ProcessRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Provenance)
      return convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire)
      return convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src);
    if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse)
      return convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ReferralRequest)
      return convertReferralRequest((org.hl7.fhir.dstu3.model.ReferralRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson)
      return convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ResearchStudy)
      return convertResearchStudy((org.hl7.fhir.dstu3.model.ResearchStudy) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ResearchSubject)
      return convertResearchSubject((org.hl7.fhir.dstu3.model.ResearchSubject) src);
    if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment)
      return convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Schedule)
      return convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src);
    if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter)
      return convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Sequence)
      return convertSequence((org.hl7.fhir.dstu3.model.Sequence) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Slot)
      return convertSlot((org.hl7.fhir.dstu3.model.Slot) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Specimen)
      return convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src);
    if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition)
      return convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.StructureMap)
      return convertStructureMap((org.hl7.fhir.dstu3.model.StructureMap) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Subscription)
      return convertSubscription((org.hl7.fhir.dstu3.model.Subscription) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Substance)
      return convertSubstance((org.hl7.fhir.dstu3.model.Substance) src);
    if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery)
      return convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src);
    if (src instanceof org.hl7.fhir.dstu3.model.SupplyRequest)
      return convertSupplyRequest((org.hl7.fhir.dstu3.model.SupplyRequest) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Task)
      return convertTask((org.hl7.fhir.dstu3.model.Task) src);
    if (src instanceof org.hl7.fhir.dstu3.model.TestReport)
      return convertTestReport((org.hl7.fhir.dstu3.model.TestReport) src);
    if (src instanceof org.hl7.fhir.dstu3.model.TestScript)
      return convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ValueSet)
      return convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src);
    if (src instanceof org.hl7.fhir.dstu3.model.VisionPrescription)
      return convertVisionPrescription((org.hl7.fhir.dstu3.model.VisionPrescription) src);
    throw new Error("Unknown resource "+src.fhirType());
  }

  public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException {
    if (src == null)
      return null;
    if (src instanceof org.hl7.fhir.r4.model.Parameters)
      return convertParameters((org.hl7.fhir.r4.model.Parameters) src);
    if (src instanceof org.hl7.fhir.r4.model.Account)
      return convertAccount((org.hl7.fhir.r4.model.Account) src);
    if (src instanceof org.hl7.fhir.r4.model.ActivityDefinition)
      return convertActivityDefinition((org.hl7.fhir.r4.model.ActivityDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.AllergyIntolerance)
      return convertAllergyIntolerance((org.hl7.fhir.r4.model.AllergyIntolerance) src);
    if (src instanceof org.hl7.fhir.r4.model.Appointment)
      return convertAppointment((org.hl7.fhir.r4.model.Appointment) src);
    if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse)
      return convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src);
    if (src instanceof org.hl7.fhir.r4.model.AuditEvent)
      return convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src);
    if (src instanceof org.hl7.fhir.r4.model.Basic)
      return convertBasic((org.hl7.fhir.r4.model.Basic) src);
    if (src instanceof org.hl7.fhir.r4.model.Binary)
      return convertBinary((org.hl7.fhir.r4.model.Binary) src);
    if (src instanceof org.hl7.fhir.r4.model.BodyStructure)
      return convertBodySite((org.hl7.fhir.r4.model.BodyStructure) src);
    if (src instanceof org.hl7.fhir.r4.model.Bundle)
      return convertBundle((org.hl7.fhir.r4.model.Bundle) src);
    if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement)
      return convertCapabilityStatement((org.hl7.fhir.r4.model.CapabilityStatement) src);
    if (src instanceof org.hl7.fhir.r4.model.CarePlan)
      return convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src);
    if (src instanceof org.hl7.fhir.r4.model.CareTeam)
      return convertCareTeam((org.hl7.fhir.r4.model.CareTeam) src);
    if (src instanceof org.hl7.fhir.r4.model.ChargeItem)
      return convertChargeItem((org.hl7.fhir.r4.model.ChargeItem) src);
    if (src instanceof org.hl7.fhir.r4.model.Claim)
      return convertClaim((org.hl7.fhir.r4.model.Claim) src);
    if (src instanceof org.hl7.fhir.r4.model.ClinicalImpression)
      return convertClinicalImpression((org.hl7.fhir.r4.model.ClinicalImpression) src);
    if (src instanceof org.hl7.fhir.r4.model.CodeSystem)
      return convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src);
    if (src instanceof org.hl7.fhir.r4.model.Communication)
      return convertCommunication((org.hl7.fhir.r4.model.Communication) src);
    if (src instanceof org.hl7.fhir.r4.model.CommunicationRequest)
      return convertCommunicationRequest((org.hl7.fhir.r4.model.CommunicationRequest) src);
    if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition)
      return convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.Composition)
      return convertComposition((org.hl7.fhir.r4.model.Composition) src);
    if (src instanceof org.hl7.fhir.r4.model.ConceptMap)
      return convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src);
    if (src instanceof org.hl7.fhir.r4.model.Condition)
      return convertCondition((org.hl7.fhir.r4.model.Condition) src);
    if (src instanceof org.hl7.fhir.r4.model.Consent)
      return convertConsent((org.hl7.fhir.r4.model.Consent) src);
    if (src instanceof org.hl7.fhir.r4.model.Contract)
      return convertContract((org.hl7.fhir.r4.model.Contract) src);
    if (src instanceof org.hl7.fhir.r4.model.Coverage)
      return convertCoverage((org.hl7.fhir.r4.model.Coverage) src);
    if (src instanceof org.hl7.fhir.r4.model.DetectedIssue)
      return convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src);
    if (src instanceof org.hl7.fhir.r4.model.Device)
      return convertDevice((org.hl7.fhir.r4.model.Device) src);
    if (src instanceof org.hl7.fhir.r4.model.DeviceComponent)
      return convertDeviceComponent((org.hl7.fhir.r4.model.DeviceComponent) src);
    if (src instanceof org.hl7.fhir.r4.model.DeviceMetric)
      return convertDeviceMetric((org.hl7.fhir.r4.model.DeviceMetric) src);
    if (src instanceof org.hl7.fhir.r4.model.DeviceRequest)
      return convertDeviceRequest((org.hl7.fhir.r4.model.DeviceRequest) src);
    if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement)
      return convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src);
    if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport)
      return convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src);
    if (src instanceof org.hl7.fhir.r4.model.DocumentManifest)
      return convertDocumentManifest((org.hl7.fhir.r4.model.DocumentManifest) src);
    if (src instanceof org.hl7.fhir.r4.model.DocumentReference)
      return convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src);
    if (src instanceof org.hl7.fhir.r4.model.EligibilityRequest)
      return convertEligibilityRequest((org.hl7.fhir.r4.model.EligibilityRequest) src);
    if (src instanceof org.hl7.fhir.r4.model.Encounter)
      return convertEncounter((org.hl7.fhir.r4.model.Encounter) src);
    if (src instanceof org.hl7.fhir.r4.model.Endpoint)
      return convertEndpoint((org.hl7.fhir.r4.model.Endpoint) src);
    if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare)
      return convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src);
    if (src instanceof org.hl7.fhir.r4.model.ExpansionProfile)
      return convertExpansionProfile((org.hl7.fhir.r4.model.ExpansionProfile) src);
    if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory)
      return convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src);
    if (src instanceof org.hl7.fhir.r4.model.Flag)
      return convertFlag((org.hl7.fhir.r4.model.Flag) src);
    if (src instanceof org.hl7.fhir.r4.model.Goal)
      return convertGoal((org.hl7.fhir.r4.model.Goal) src);
    if (src instanceof org.hl7.fhir.r4.model.GraphDefinition)
      return convertGraphDefinition((org.hl7.fhir.r4.model.GraphDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.Group)
      return convertGroup((org.hl7.fhir.r4.model.Group) src);
    if (src instanceof org.hl7.fhir.r4.model.HealthcareService)
      return convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src);
    if (src instanceof org.hl7.fhir.r4.model.ImagingManifest)
      return convertImagingManifest((org.hl7.fhir.r4.model.ImagingManifest) src);
    if (src instanceof org.hl7.fhir.r4.model.ImagingStudy)
      return convertImagingStudy((org.hl7.fhir.r4.model.ImagingStudy) src);
    if (src instanceof org.hl7.fhir.r4.model.Immunization)
      return convertImmunization((org.hl7.fhir.r4.model.Immunization) src);
    if (src instanceof org.hl7.fhir.r4.model.ImmunizationRecommendation)
      return convertImmunizationRecommendation((org.hl7.fhir.r4.model.ImmunizationRecommendation) src);
    if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide)
      return convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src);
    if (src instanceof org.hl7.fhir.r4.model.Linkage)
      return convertLinkage((org.hl7.fhir.r4.model.Linkage) src);
    if (src instanceof org.hl7.fhir.r4.model.ListResource)
      return convertList((org.hl7.fhir.r4.model.ListResource) src);
    if (src instanceof org.hl7.fhir.r4.model.Location)
      return convertLocation((org.hl7.fhir.r4.model.Location) src);
    if (src instanceof org.hl7.fhir.r4.model.Measure)
      return convertMeasure((org.hl7.fhir.r4.model.Measure) src);
    if (src instanceof org.hl7.fhir.r4.model.MeasureReport)
      return convertMeasureReport((org.hl7.fhir.r4.model.MeasureReport) src);
    if (src instanceof org.hl7.fhir.r4.model.Media)
      return convertMedia((org.hl7.fhir.r4.model.Media) src);
    if (src instanceof org.hl7.fhir.r4.model.Medication)
      return convertMedication((org.hl7.fhir.r4.model.Medication) src);
    if (src instanceof org.hl7.fhir.r4.model.MedicationAdministration)
      return convertMedicationAdministration((org.hl7.fhir.r4.model.MedicationAdministration) src);
    if (src instanceof org.hl7.fhir.r4.model.MedicationDispense)
      return convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src);
    if (src instanceof org.hl7.fhir.r4.model.MedicationRequest)
      return convertMedicationRequest((org.hl7.fhir.r4.model.MedicationRequest) src);
    if (src instanceof org.hl7.fhir.r4.model.MedicationStatement)
      return convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src);
    if (src instanceof org.hl7.fhir.r4.model.MessageDefinition)
      return convertMessageDefinition((org.hl7.fhir.r4.model.MessageDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.MessageHeader)
      return convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src);
    if (src instanceof org.hl7.fhir.r4.model.NamingSystem)
      return convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src);
    if (src instanceof org.hl7.fhir.r4.model.NutritionOrder)
      return convertNutritionOrder((org.hl7.fhir.r4.model.NutritionOrder) src);
    if (src instanceof org.hl7.fhir.r4.model.Observation)
      return convertObservation((org.hl7.fhir.r4.model.Observation) src);
    if (src instanceof org.hl7.fhir.r4.model.OperationDefinition)
      return convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.OperationOutcome)
      return convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src);
    if (src instanceof org.hl7.fhir.r4.model.Organization)
      return convertOrganization((org.hl7.fhir.r4.model.Organization) src);
    if (src instanceof org.hl7.fhir.r4.model.Patient)
      return convertPatient((org.hl7.fhir.r4.model.Patient) src);
    if (src instanceof org.hl7.fhir.r4.model.PaymentNotice)
      return convertPaymentNotice((org.hl7.fhir.r4.model.PaymentNotice) src);
    if (src instanceof org.hl7.fhir.r4.model.Person)
      return convertPerson((org.hl7.fhir.r4.model.Person) src);
    if (src instanceof org.hl7.fhir.r4.model.Practitioner)
      return convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src);
    if (src instanceof org.hl7.fhir.r4.model.PractitionerRole)
      return convertPractitionerRole((org.hl7.fhir.r4.model.PractitionerRole) src);
    if (src instanceof org.hl7.fhir.r4.model.Procedure)
      return convertProcedure((org.hl7.fhir.r4.model.Procedure) src);
    if (src instanceof org.hl7.fhir.r4.model.ProcedureRequest)
      return convertProcedureRequest((org.hl7.fhir.r4.model.ProcedureRequest) src);
    if (src instanceof org.hl7.fhir.r4.model.ProcessRequest)
      return convertProcessRequest((org.hl7.fhir.r4.model.ProcessRequest) src);
    if (src instanceof org.hl7.fhir.r4.model.Provenance)
      return convertProvenance((org.hl7.fhir.r4.model.Provenance) src);
    if (src instanceof org.hl7.fhir.r4.model.Questionnaire)
      return convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src);
    if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse)
      return convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src);
    if (src instanceof org.hl7.fhir.r4.model.RelatedPerson)
      return convertRelatedPerson((org.hl7.fhir.r4.model.RelatedPerson) src);
    if (src instanceof org.hl7.fhir.r4.model.ResearchStudy)
      return convertResearchStudy((org.hl7.fhir.r4.model.ResearchStudy) src);
    if (src instanceof org.hl7.fhir.r4.model.ResearchSubject)
      return convertResearchSubject((org.hl7.fhir.r4.model.ResearchSubject) src);
    if (src instanceof org.hl7.fhir.r4.model.RiskAssessment)
      return convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src);
    if (src instanceof org.hl7.fhir.r4.model.Schedule)
      return convertSchedule((org.hl7.fhir.r4.model.Schedule) src);
    if (src instanceof org.hl7.fhir.r4.model.SearchParameter)
      return convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src);
    if (src instanceof org.hl7.fhir.r4.model.Sequence)
      return convertSequence((org.hl7.fhir.r4.model.Sequence) src);
    if (src instanceof org.hl7.fhir.r4.model.Slot)
      return convertSlot((org.hl7.fhir.r4.model.Slot) src);
    if (src instanceof org.hl7.fhir.r4.model.Specimen)
      return convertSpecimen((org.hl7.fhir.r4.model.Specimen) src);
    if (src instanceof org.hl7.fhir.r4.model.StructureDefinition)
      return convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.StructureMap)
      return convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src);
    if (src instanceof org.hl7.fhir.r4.model.Subscription)
      return convertSubscription((org.hl7.fhir.r4.model.Subscription) src);
    if (src instanceof org.hl7.fhir.r4.model.Substance)
      return convertSubstance((org.hl7.fhir.r4.model.Substance) src);
    if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery)
      return convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src);
    if (src instanceof org.hl7.fhir.r4.model.SupplyRequest)
      return convertSupplyRequest((org.hl7.fhir.r4.model.SupplyRequest) src);
    if (src instanceof org.hl7.fhir.r4.model.Task)
      return convertTask((org.hl7.fhir.r4.model.Task) src);
    if (src instanceof org.hl7.fhir.r4.model.TestReport)
      return convertTestReport((org.hl7.fhir.r4.model.TestReport) src);
    if (src instanceof org.hl7.fhir.r4.model.TestScript)
      return convertTestScript((org.hl7.fhir.r4.model.TestScript) src);
    if (src instanceof org.hl7.fhir.r4.model.ValueSet)
      return convertValueSet((org.hl7.fhir.r4.model.ValueSet) src);
    if (src instanceof org.hl7.fhir.r4.model.VisionPrescription)
      return convertVisionPrescription((org.hl7.fhir.r4.model.VisionPrescription) src);
    throw new Error("Unknown resource "+src.fhirType());
  }

  public static org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceInteractionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertTypeRestfulInteraction(src.getCode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceInteractionComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceInteractionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertTypeRestfulInteraction(src.getCode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy convertResourceVersionPolicy(org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceVersionPolicy src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOVERSION: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NOVERSION;
    case VERSIONED: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONED;
    case VERSIONEDUPDATE: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONEDUPDATE;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceVersionPolicy convertResourceVersionPolicy(org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NOVERSION: return org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceVersionPolicy.NOVERSION;
    case VERSIONED: return org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceVersionPolicy.VERSIONED;
    case VERSIONEDUPDATE: return org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceVersionPolicy.VERSIONEDUPDATE;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceVersionPolicy.NULL;
  }
}

  private static org.hl7.fhir.r4.model.MessageHeader.ResponseType convertResponseType(org.hl7.fhir.dstu3.model.MessageHeader.ResponseType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OK: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.OK;
    case TRANSIENTERROR: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.TRANSIENTERROR;
    case FATALERROR: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.FATALERROR;
    default: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.MessageHeader.ResponseType convertResponseType(org.hl7.fhir.r4.model.MessageHeader.ResponseType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case OK: return org.hl7.fhir.dstu3.model.MessageHeader.ResponseType.OK;
    case TRANSIENTERROR: return org.hl7.fhir.dstu3.model.MessageHeader.ResponseType.TRANSIENTERROR;
    case FATALERROR: return org.hl7.fhir.dstu3.model.MessageHeader.ResponseType.FATALERROR;
    default: return org.hl7.fhir.dstu3.model.MessageHeader.ResponseType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode convertRestfulCapabilityMode(org.hl7.fhir.dstu3.model.CapabilityStatement.RestfulCapabilityMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CLIENT: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.CLIENT;
    case SERVER: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.SERVER;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.RestfulCapabilityMode convertRestfulCapabilityMode(org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CLIENT: return org.hl7.fhir.dstu3.model.CapabilityStatement.RestfulCapabilityMode.CLIENT;
    case SERVER: return org.hl7.fhir.dstu3.model.CapabilityStatement.RestfulCapabilityMode.SERVER;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.RestfulCapabilityMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.RiskAssessment convertRiskAssessment(org.hl7.fhir.dstu3.model.RiskAssessment src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.RiskAssessment tgt = new org.hl7.fhir.r4.model.RiskAssessment();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasBasedOn())
      tgt.setBasedOn(convertReference(src.getBasedOn()));
    if (src.hasParent())
      tgt.setParent(convertReference(src.getParent()));
    if (src.hasStatus())
      tgt.setStatus(convertRiskAssessmentStatus(src.getStatus()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasCondition())
      tgt.setCondition(convertReference(src.getCondition()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    if (src.hasReason())
      tgt.setReason(convertType(src.getReason()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasis())
      tgt.addBasis(convertReference(t));
    for (org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentPredictionComponent t : src.getPrediction())
      tgt.addPrediction(convertRiskAssessmentPredictionComponent(t));
    if (src.hasMitigation())
      tgt.setMitigation(src.getMitigation());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.RiskAssessment convertRiskAssessment(org.hl7.fhir.r4.model.RiskAssessment src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.RiskAssessment tgt = new org.hl7.fhir.dstu3.model.RiskAssessment();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasBasedOn())
      tgt.setBasedOn(convertReference(src.getBasedOn()));
    if (src.hasParent())
      tgt.setParent(convertReference(src.getParent()));
    if (src.hasStatus())
      tgt.setStatus(convertRiskAssessmentStatus(src.getStatus()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasCondition())
      tgt.setCondition(convertReference(src.getCondition()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    if (src.hasReason())
      tgt.setReason(convertType(src.getReason()));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasis())
      tgt.addBasis(convertReference(t));
    for (org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent t : src.getPrediction())
      tgt.addPrediction(convertRiskAssessmentPredictionComponent(t));
    if (src.hasMitigation())
      tgt.setMitigation(src.getMitigation());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent convertRiskAssessmentPredictionComponent(org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentPredictionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent tgt = new org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent();
    copyElement(src, tgt);
    if (src.hasOutcome())
      tgt.setOutcome(convertCodeableConcept(src.getOutcome()));
    if (src.hasProbability())
      tgt.setProbability(convertType(src.getProbability()));
    if (src.hasQualitativeRisk())
      tgt.setQualitativeRisk(convertCodeableConcept(src.getQualitativeRisk()));
    if (src.hasRelativeRisk())
      tgt.setRelativeRisk(src.getRelativeRisk());
    if (src.hasWhen())
      tgt.setWhen(convertType(src.getWhen()));
    if (src.hasRationale())
      tgt.setRationale(src.getRationale());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentPredictionComponent convertRiskAssessmentPredictionComponent(org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentPredictionComponent tgt = new org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentPredictionComponent();
    copyElement(src, tgt);
    if (src.hasOutcome())
      tgt.setOutcome(convertCodeableConcept(src.getOutcome()));
    if (src.hasProbability())
      tgt.setProbability(convertType(src.getProbability()));
    if (src.hasQualitativeRisk())
      tgt.setQualitativeRisk(convertCodeableConcept(src.getQualitativeRisk()));
    if (src.hasRelativeRisk())
      tgt.setRelativeRisk(src.getRelativeRisk());
    if (src.hasWhen())
      tgt.setWhen(convertType(src.getWhen()));
    if (src.hasRationale())
      tgt.setRationale(src.getRationale());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus convertRiskAssessmentStatus(org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.REGISTERED;
    case PRELIMINARY: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.FINAL;
    case AMENDED: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.CORRECTED;
    case CANCELLED: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus convertRiskAssessmentStatus(org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REGISTERED: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.REGISTERED;
    case PRELIMINARY: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.PRELIMINARY;
    case FINAL: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.FINAL;
    case AMENDED: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.AMENDED;
    case CORRECTED: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.CORRECTED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.CANCELLED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.RiskAssessment.RiskAssessmentStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.TestScript.RuleParamComponent convertRuleParamComponent(org.hl7.fhir.dstu3.model.TestScript.RuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.RuleParamComponent tgt = new org.hl7.fhir.r4.model.TestScript.RuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.RuleParamComponent convertRuleParamComponent(org.hl7.fhir.r4.model.TestScript.RuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.RuleParamComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.RuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.RulesetRuleComponent convertRulesetRuleComponent(org.hl7.fhir.dstu3.model.TestScript.RulesetRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.RulesetRuleComponent tgt = new org.hl7.fhir.r4.model.TestScript.RulesetRuleComponent();
    copyElement(src, tgt);
    if (src.hasRuleId())
      tgt.setRuleId(src.getRuleId());
    for (org.hl7.fhir.dstu3.model.TestScript.RulesetRuleParamComponent t : src.getParam())
      tgt.addParam(convertRulesetRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.RulesetRuleComponent convertRulesetRuleComponent(org.hl7.fhir.r4.model.TestScript.RulesetRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.RulesetRuleComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.RulesetRuleComponent();
    copyElement(src, tgt);
    if (src.hasRuleId())
      tgt.setRuleId(src.getRuleId());
    for (org.hl7.fhir.r4.model.TestScript.RulesetRuleParamComponent t : src.getParam())
      tgt.addParam(convertRulesetRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.RulesetRuleParamComponent convertRulesetRuleParamComponent(org.hl7.fhir.dstu3.model.TestScript.RulesetRuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.RulesetRuleParamComponent tgt = new org.hl7.fhir.r4.model.TestScript.RulesetRuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.RulesetRuleParamComponent convertRulesetRuleParamComponent(org.hl7.fhir.r4.model.TestScript.RulesetRuleParamComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.RulesetRuleParamComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.RulesetRuleParamComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData();
    copyElement(src, tgt);
    if (src.hasOrigin())
      tgt.setOrigin(convertSimpleQuantity(src.getOrigin()));
    if (src.hasPeriod())
      tgt.setPeriod(src.getPeriod());
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasLowerLimit())
      tgt.setLowerLimit(src.getLowerLimit());
    if (src.hasUpperLimit())
      tgt.setUpperLimit(src.getUpperLimit());
    if (src.hasDimensions())
      tgt.setDimensions(src.getDimensions());
    if (src.hasData())
      tgt.setData(src.getData());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData();
    copyElement(src, tgt);
    if (src.hasOrigin())
      tgt.setOrigin(convertSimpleQuantity(src.getOrigin()));
    if (src.hasPeriod())
      tgt.setPeriod(src.getPeriod());
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasLowerLimit())
      tgt.setLowerLimit(src.getLowerLimit());
    if (src.hasUpperLimit())
      tgt.setUpperLimit(src.getUpperLimit());
    if (src.hasDimensions())
      tgt.setDimensions(src.getDimensions());
    if (src.hasData())
      tgt.setData(src.getData());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Schedule convertSchedule(org.hl7.fhir.dstu3.model.Schedule src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Schedule tgt = new org.hl7.fhir.r4.model.Schedule();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasServiceCategory())
      tgt.setServiceCategory(convertCodeableConcept(src.getServiceCategory()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getServiceType())
      tgt.addServiceType(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getActor())
      tgt.addActor(convertReference(t));
    if (src.hasPlanningHorizon())
      tgt.setPlanningHorizon(convertPeriod(src.getPlanningHorizon()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Schedule convertSchedule(org.hl7.fhir.r4.model.Schedule src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Schedule tgt = new org.hl7.fhir.dstu3.model.Schedule();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasActive())
      tgt.setActive(src.getActive());
    if (src.hasServiceCategory())
      tgt.setServiceCategory(convertCodeableConcept(src.getServiceCategory()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType())
      tgt.addServiceType(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getActor())
      tgt.addActor(convertReference(t));
    if (src.hasPlanningHorizon())
      tgt.setPlanningHorizon(convertPeriod(src.getPlanningHorizon()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.SearchParameter.SearchComparator convertSearchComparator(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQ: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.EQ;
    case NE: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.NE;
    case GT: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.GT;
    case LT: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.LT;
    case GE: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.GE;
    case LE: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.LE;
    case SA: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.SA;
    case EB: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.EB;
    case AP: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.AP;
    default: return org.hl7.fhir.r4.model.SearchParameter.SearchComparator.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator convertSearchComparator(org.hl7.fhir.r4.model.SearchParameter.SearchComparator src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case EQ: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.EQ;
    case NE: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.NE;
    case GT: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.GT;
    case LT: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.LT;
    case GE: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.GE;
    case LE: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.LE;
    case SA: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.SA;
    case EB: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.EB;
    case AP: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.AP;
    default: return org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Bundle.SearchEntryMode convertSearchEntryMode(org.hl7.fhir.dstu3.model.Bundle.SearchEntryMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MATCH: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.MATCH;
    case INCLUDE: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.INCLUDE;
    case OUTCOME: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.OUTCOME;
    default: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Bundle.SearchEntryMode convertSearchEntryMode(org.hl7.fhir.r4.model.Bundle.SearchEntryMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MATCH: return org.hl7.fhir.dstu3.model.Bundle.SearchEntryMode.MATCH;
    case INCLUDE: return org.hl7.fhir.dstu3.model.Bundle.SearchEntryMode.INCLUDE;
    case OUTCOME: return org.hl7.fhir.dstu3.model.Bundle.SearchEntryMode.OUTCOME;
    default: return org.hl7.fhir.dstu3.model.Bundle.SearchEntryMode.NULL;
  }
}

  private static org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode convertSearchModifierCode(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MISSING: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.MISSING;
    case EXACT: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.EXACT;
    case CONTAINS: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.CONTAINS;
    case NOT: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.NOT;
    case TEXT: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.TEXT;
    case IN: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.IN;
    case NOTIN: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.NOTIN;
    case BELOW: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.BELOW;
    case ABOVE: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.ABOVE;
    case TYPE: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.TYPE;
    default: return org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode convertSearchModifierCode(org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case MISSING: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.MISSING;
    case EXACT: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.EXACT;
    case CONTAINS: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.CONTAINS;
    case NOT: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NOT;
    case TEXT: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.TEXT;
    case IN: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.IN;
    case NOTIN: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NOTIN;
    case BELOW: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.BELOW;
    case ABOVE: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.ABOVE;
    case TYPE: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.TYPE;
    default: return org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NUMBER: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER;
    case DATE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE;
    case STRING: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING;
    case TOKEN: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN;
    case REFERENCE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE;
    case COMPOSITE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE;
    case QUANTITY: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY;
    case URI: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI;
    default: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.r4.model.Enumerations.SearchParamType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NUMBER: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER;
    case DATE: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE;
    case STRING: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING;
    case TOKEN: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN;
    case REFERENCE: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE;
    case COMPOSITE: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE;
    case QUANTITY: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY;
    case URI: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI;
    default: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu3.model.SearchParameter src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SearchParameter tgt = new org.hl7.fhir.r4.model.SearchParameter();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getBase())
      tgt.addBase(t.getValue());
    if (src.hasType())
      tgt.setType(convertSearchParamType(src.getType()));
    if (src.hasDerivedFrom())
      tgt.setDerivedFrom(src.getDerivedFrom());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasXpath())
      tgt.setXpath(src.getXpath());
    if (src.hasXpathUsage())
      tgt.setXpathUsage(convertXPathUsageType(src.getXpathUsage()));
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getTarget())
      tgt.addTarget(t.getValue());
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator> t : src.getComparator())
      tgt.addComparator(convertSearchComparator(t.getValue()));
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode> t : src.getModifier())
      tgt.addModifier(convertSearchModifierCode(t.getValue()));
    for (org.hl7.fhir.dstu3.model.StringType t : src.getChain())
      tgt.addChain(t.getValue());
    for (org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent t : src.getComponent())
      tgt.addComponent(convertSearchParameterComponentComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SearchParameter convertSearchParameter(org.hl7.fhir.r4.model.SearchParameter src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SearchParameter tgt = new org.hl7.fhir.dstu3.model.SearchParameter();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    for (org.hl7.fhir.r4.model.CodeType t : src.getBase())
      tgt.addBase(t.getValue());
    if (src.hasType())
      tgt.setType(convertSearchParamType(src.getType()));
    if (src.hasDerivedFrom())
      tgt.setDerivedFrom(src.getDerivedFrom());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasXpath())
      tgt.setXpath(src.getXpath());
    if (src.hasXpathUsage())
      tgt.setXpathUsage(convertXPathUsageType(src.getXpathUsage()));
    for (org.hl7.fhir.r4.model.CodeType t : src.getTarget())
      tgt.addTarget(t.getValue());
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.SearchComparator> t : src.getComparator())
      tgt.addComparator(convertSearchComparator(t.getValue()));
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode> t : src.getModifier())
      tgt.addModifier(convertSearchModifierCode(t.getValue()));
    for (org.hl7.fhir.r4.model.StringType t : src.getChain())
      tgt.addChain(t.getValue());
    for (org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent t : src.getComponent())
      tgt.addComponent(convertSearchParameterComponentComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent convertSearchParameterComponentComponent(org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent tgt = new org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent();
    copyElement(src, tgt);
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent convertSearchParameterComponentComponent(org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent tgt = new org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent();
    copyElement(src, tgt);
    if (src.hasDefinition())
      tgt.setDefinition(convertReference(src.getDefinition()));
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Composition.SectionComponent convertSectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Composition.SectionComponent tgt = new org.hl7.fhir.r4.model.Composition.SectionComponent();
    copyElement(src, tgt);
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasText())
      tgt.setText(convertNarrative(src.getText()));
    if (src.hasMode())
      tgt.setMode(convertSectionMode(src.getMode()));
    if (src.hasOrderedBy())
      tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEntry())
      tgt.addEntry(convertReference(t));
    if (src.hasEmptyReason())
      tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason()));
    for (org.hl7.fhir.dstu3.model.Composition.SectionComponent t : src.getSection())
      tgt.addSection(convertSectionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Composition.SectionComponent convertSectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Composition.SectionComponent tgt = new org.hl7.fhir.dstu3.model.Composition.SectionComponent();
    copyElement(src, tgt);
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasText())
      tgt.setText(convertNarrative(src.getText()));
    if (src.hasMode())
      tgt.setMode(convertSectionMode(src.getMode()));
    if (src.hasOrderedBy())
      tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy()));
    for (org.hl7.fhir.r4.model.Reference t : src.getEntry())
      tgt.addEntry(convertReference(t));
    if (src.hasEmptyReason())
      tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason()));
    for (org.hl7.fhir.r4.model.Composition.SectionComponent t : src.getSection())
      tgt.addSection(convertSectionComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Composition.SectionMode convertSectionMode(org.hl7.fhir.dstu3.model.Composition.SectionMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case WORKING: return org.hl7.fhir.r4.model.Composition.SectionMode.WORKING;
    case SNAPSHOT: return org.hl7.fhir.r4.model.Composition.SectionMode.SNAPSHOT;
    case CHANGES: return org.hl7.fhir.r4.model.Composition.SectionMode.CHANGES;
    default: return org.hl7.fhir.r4.model.Composition.SectionMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Composition.SectionMode convertSectionMode(org.hl7.fhir.r4.model.Composition.SectionMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case WORKING: return org.hl7.fhir.dstu3.model.Composition.SectionMode.WORKING;
    case SNAPSHOT: return org.hl7.fhir.dstu3.model.Composition.SectionMode.SNAPSHOT;
    case CHANGES: return org.hl7.fhir.dstu3.model.Composition.SectionMode.CHANGES;
    default: return org.hl7.fhir.dstu3.model.Composition.SectionMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Sequence convertSequence(org.hl7.fhir.dstu3.model.Sequence src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Sequence tgt = new org.hl7.fhir.r4.model.Sequence();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasType())
      tgt.setType(convertSequenceType(src.getType()));
    if (src.hasCoordinateSystem())
      tgt.setCoordinateSystem(src.getCoordinateSystem());
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasSpecimen())
      tgt.setSpecimen(convertReference(src.getSpecimen()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    if (src.hasQuantity())
      tgt.setQuantity(convertQuantity(src.getQuantity()));
    if (src.hasReferenceSeq())
      tgt.setReferenceSeq(convertSequenceReferenceSeqComponent(src.getReferenceSeq()));
    for (org.hl7.fhir.dstu3.model.Sequence.SequenceVariantComponent t : src.getVariant())
      tgt.addVariant(convertSequenceVariantComponent(t));
    if (src.hasObservedSeq())
      tgt.setObservedSeq(src.getObservedSeq());
    for (org.hl7.fhir.dstu3.model.Sequence.SequenceQualityComponent t : src.getQuality())
      tgt.addQuality(convertSequenceQualityComponent(t));
    if (src.hasReadCoverage())
      tgt.setReadCoverage(src.getReadCoverage());
    for (org.hl7.fhir.dstu3.model.Sequence.SequenceRepositoryComponent t : src.getRepository())
      tgt.addRepository(convertSequenceRepositoryComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPointer())
      tgt.addPointer(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Sequence convertSequence(org.hl7.fhir.r4.model.Sequence src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Sequence tgt = new org.hl7.fhir.dstu3.model.Sequence();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasType())
      tgt.setType(convertSequenceType(src.getType()));
    if (src.hasCoordinateSystem())
      tgt.setCoordinateSystem(src.getCoordinateSystem());
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasSpecimen())
      tgt.setSpecimen(convertReference(src.getSpecimen()));
    if (src.hasDevice())
      tgt.setDevice(convertReference(src.getDevice()));
    if (src.hasPerformer())
      tgt.setPerformer(convertReference(src.getPerformer()));
    if (src.hasQuantity())
      tgt.setQuantity(convertQuantity(src.getQuantity()));
    if (src.hasReferenceSeq())
      tgt.setReferenceSeq(convertSequenceReferenceSeqComponent(src.getReferenceSeq()));
    for (org.hl7.fhir.r4.model.Sequence.SequenceVariantComponent t : src.getVariant())
      tgt.addVariant(convertSequenceVariantComponent(t));
    if (src.hasObservedSeq())
      tgt.setObservedSeq(src.getObservedSeq());
    for (org.hl7.fhir.r4.model.Sequence.SequenceQualityComponent t : src.getQuality())
      tgt.addQuality(convertSequenceQualityComponent(t));
    if (src.hasReadCoverage())
      tgt.setReadCoverage(src.getReadCoverage());
    for (org.hl7.fhir.r4.model.Sequence.SequenceRepositoryComponent t : src.getRepository())
      tgt.addRepository(convertSequenceRepositoryComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPointer())
      tgt.addPointer(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Sequence.SequenceQualityComponent convertSequenceQualityComponent(org.hl7.fhir.dstu3.model.Sequence.SequenceQualityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Sequence.SequenceQualityComponent tgt = new org.hl7.fhir.r4.model.Sequence.SequenceQualityComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertQualityType(src.getType()));
    if (src.hasStandardSequence())
      tgt.setStandardSequence(convertCodeableConcept(src.getStandardSequence()));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasScore())
      tgt.setScore(convertQuantity(src.getScore()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasTruthTP())
      tgt.setTruthTP(src.getTruthTP());
    if (src.hasQueryTP())
      tgt.setQueryTP(src.getQueryTP());
    if (src.hasTruthFN())
      tgt.setTruthFN(src.getTruthFN());
    if (src.hasQueryFP())
      tgt.setQueryFP(src.getQueryFP());
    if (src.hasGtFP())
      tgt.setGtFP(src.getGtFP());
    if (src.hasPrecision())
      tgt.setPrecision(src.getPrecision());
    if (src.hasRecall())
      tgt.setRecall(src.getRecall());
    if (src.hasFScore())
      tgt.setFScore(src.getFScore());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Sequence.SequenceQualityComponent convertSequenceQualityComponent(org.hl7.fhir.r4.model.Sequence.SequenceQualityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Sequence.SequenceQualityComponent tgt = new org.hl7.fhir.dstu3.model.Sequence.SequenceQualityComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertQualityType(src.getType()));
    if (src.hasStandardSequence())
      tgt.setStandardSequence(convertCodeableConcept(src.getStandardSequence()));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasScore())
      tgt.setScore(convertQuantity(src.getScore()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasTruthTP())
      tgt.setTruthTP(src.getTruthTP());
    if (src.hasQueryTP())
      tgt.setQueryTP(src.getQueryTP());
    if (src.hasTruthFN())
      tgt.setTruthFN(src.getTruthFN());
    if (src.hasQueryFP())
      tgt.setQueryFP(src.getQueryFP());
    if (src.hasGtFP())
      tgt.setGtFP(src.getGtFP());
    if (src.hasPrecision())
      tgt.setPrecision(src.getPrecision());
    if (src.hasRecall())
      tgt.setRecall(src.getRecall());
    if (src.hasFScore())
      tgt.setFScore(src.getFScore());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Sequence.SequenceReferenceSeqComponent convertSequenceReferenceSeqComponent(org.hl7.fhir.dstu3.model.Sequence.SequenceReferenceSeqComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Sequence.SequenceReferenceSeqComponent tgt = new org.hl7.fhir.r4.model.Sequence.SequenceReferenceSeqComponent();
    copyElement(src, tgt);
    if (src.hasChromosome())
      tgt.setChromosome(convertCodeableConcept(src.getChromosome()));
    if (src.hasGenomeBuild())
      tgt.setGenomeBuild(src.getGenomeBuild());
    if (src.hasReferenceSeqId())
      tgt.setReferenceSeqId(convertCodeableConcept(src.getReferenceSeqId()));
    if (src.hasReferenceSeqPointer())
      tgt.setReferenceSeqPointer(convertReference(src.getReferenceSeqPointer()));
    if (src.hasReferenceSeqString())
      tgt.setReferenceSeqString(src.getReferenceSeqString());
    if (src.hasStrand())
      tgt.setStrand(src.getStrand());
    if (src.hasWindowStart())
      tgt.setWindowStart(src.getWindowStart());
    if (src.hasWindowEnd())
      tgt.setWindowEnd(src.getWindowEnd());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Sequence.SequenceReferenceSeqComponent convertSequenceReferenceSeqComponent(org.hl7.fhir.r4.model.Sequence.SequenceReferenceSeqComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Sequence.SequenceReferenceSeqComponent tgt = new org.hl7.fhir.dstu3.model.Sequence.SequenceReferenceSeqComponent();
    copyElement(src, tgt);
    if (src.hasChromosome())
      tgt.setChromosome(convertCodeableConcept(src.getChromosome()));
    if (src.hasGenomeBuild())
      tgt.setGenomeBuild(src.getGenomeBuild());
    if (src.hasReferenceSeqId())
      tgt.setReferenceSeqId(convertCodeableConcept(src.getReferenceSeqId()));
    if (src.hasReferenceSeqPointer())
      tgt.setReferenceSeqPointer(convertReference(src.getReferenceSeqPointer()));
    if (src.hasReferenceSeqString())
      tgt.setReferenceSeqString(src.getReferenceSeqString());
    if (src.hasStrand())
      tgt.setStrand(src.getStrand());
    if (src.hasWindowStart())
      tgt.setWindowStart(src.getWindowStart());
    if (src.hasWindowEnd())
      tgt.setWindowEnd(src.getWindowEnd());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Sequence.SequenceRepositoryComponent convertSequenceRepositoryComponent(org.hl7.fhir.dstu3.model.Sequence.SequenceRepositoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Sequence.SequenceRepositoryComponent tgt = new org.hl7.fhir.r4.model.Sequence.SequenceRepositoryComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertRepositoryType(src.getType()));
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDatasetId())
      tgt.setDatasetId(src.getDatasetId());
    if (src.hasVariantsetId())
      tgt.setVariantsetId(src.getVariantsetId());
    if (src.hasReadsetId())
      tgt.setReadsetId(src.getReadsetId());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Sequence.SequenceRepositoryComponent convertSequenceRepositoryComponent(org.hl7.fhir.r4.model.Sequence.SequenceRepositoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Sequence.SequenceRepositoryComponent tgt = new org.hl7.fhir.dstu3.model.Sequence.SequenceRepositoryComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertRepositoryType(src.getType()));
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDatasetId())
      tgt.setDatasetId(src.getDatasetId());
    if (src.hasVariantsetId())
      tgt.setVariantsetId(src.getVariantsetId());
    if (src.hasReadsetId())
      tgt.setReadsetId(src.getReadsetId());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Sequence.SequenceType convertSequenceType(org.hl7.fhir.dstu3.model.Sequence.SequenceType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AA: return org.hl7.fhir.r4.model.Sequence.SequenceType.AA;
    case DNA: return org.hl7.fhir.r4.model.Sequence.SequenceType.DNA;
    case RNA: return org.hl7.fhir.r4.model.Sequence.SequenceType.RNA;
    default: return org.hl7.fhir.r4.model.Sequence.SequenceType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Sequence.SequenceType convertSequenceType(org.hl7.fhir.r4.model.Sequence.SequenceType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AA: return org.hl7.fhir.dstu3.model.Sequence.SequenceType.AA;
    case DNA: return org.hl7.fhir.dstu3.model.Sequence.SequenceType.DNA;
    case RNA: return org.hl7.fhir.dstu3.model.Sequence.SequenceType.RNA;
    default: return org.hl7.fhir.dstu3.model.Sequence.SequenceType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Sequence.SequenceVariantComponent convertSequenceVariantComponent(org.hl7.fhir.dstu3.model.Sequence.SequenceVariantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Sequence.SequenceVariantComponent tgt = new org.hl7.fhir.r4.model.Sequence.SequenceVariantComponent();
    copyElement(src, tgt);
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasObservedAllele())
      tgt.setObservedAllele(src.getObservedAllele());
    if (src.hasReferenceAllele())
      tgt.setReferenceAllele(src.getReferenceAllele());
    if (src.hasCigar())
      tgt.setCigar(src.getCigar());
    if (src.hasVariantPointer())
      tgt.setVariantPointer(convertReference(src.getVariantPointer()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Sequence.SequenceVariantComponent convertSequenceVariantComponent(org.hl7.fhir.r4.model.Sequence.SequenceVariantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Sequence.SequenceVariantComponent tgt = new org.hl7.fhir.dstu3.model.Sequence.SequenceVariantComponent();
    copyElement(src, tgt);
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasObservedAllele())
      tgt.setObservedAllele(src.getObservedAllele());
    if (src.hasReferenceAllele())
      tgt.setReferenceAllele(src.getReferenceAllele());
    if (src.hasCigar())
      tgt.setCigar(src.getCigar());
    if (src.hasVariantPointer())
      tgt.setVariantPointer(convertReference(src.getVariantPointer()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ImagingManifest.SeriesComponent convertSeriesComponent(org.hl7.fhir.dstu3.model.ImagingManifest.SeriesComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImagingManifest.SeriesComponent tgt = new org.hl7.fhir.r4.model.ImagingManifest.SeriesComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    for (org.hl7.fhir.dstu3.model.ImagingManifest.InstanceComponent t : src.getInstance())
      tgt.addInstance(convertInstanceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImagingManifest.SeriesComponent convertSeriesComponent(org.hl7.fhir.r4.model.ImagingManifest.SeriesComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImagingManifest.SeriesComponent tgt = new org.hl7.fhir.dstu3.model.ImagingManifest.SeriesComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    for (org.hl7.fhir.r4.model.ImagingManifest.InstanceComponent t : src.getInstance())
      tgt.addInstance(convertInstanceComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent();
    copyElement(src, tgt);
    if (src.hasResult())
      tgt.setResult(convertTestReportActionResult(src.getResult()));
    if (src.hasMessage())
      tgt.setMessage(src.getMessage());
    if (src.hasDetail())
      tgt.setDetail(src.getDetail());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent();
    copyElement(src, tgt);
    if (src.hasResult())
      tgt.setResult(convertTestReportActionResult(src.getResult()));
    if (src.hasMessage())
      tgt.setMessage(src.getMessage());
    if (src.hasDetail())
      tgt.setDetail(src.getDetail());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent();
    copyElement(src, tgt);
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasDirection())
      tgt.setDirection(convertAssertionDirectionType(src.getDirection()));
    if (src.hasCompareToSourceId())
      tgt.setCompareToSourceId(src.getCompareToSourceId());
    if (src.hasCompareToSourceExpression())
      tgt.setCompareToSourceExpression(src.getCompareToSourceExpression());
    if (src.hasCompareToSourcePath())
      tgt.setCompareToSourcePath(src.getCompareToSourcePath());
    if (src.hasContentType())
      tgt.setContentType(convertContentType(src.getContentType()));
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasHeaderField())
      tgt.setHeaderField(src.getHeaderField());
    if (src.hasMinimumId())
      tgt.setMinimumId(src.getMinimumId());
    if (src.hasNavigationLinks())
      tgt.setNavigationLinks(src.getNavigationLinks());
    if (src.hasOperator())
      tgt.setOperator(convertAssertionOperatorType(src.getOperator()));
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasRequestMethod())
      tgt.setRequestMethod(convertTestScriptRequestMethodCode(src.getRequestMethod()));
    if (src.hasRequestURL())
      tgt.setRequestURL(src.getRequestURL());
    if (src.hasResource())
      tgt.setResource(src.getResource());
    if (src.hasResponse())
      tgt.setResponse(convertAssertionResponseTypes(src.getResponse()));
    if (src.hasResponseCode())
      tgt.setResponseCode(src.getResponseCode());
    if (src.hasRule())
      tgt.setRule(convertActionAssertRuleComponent(src.getRule()));
    if (src.hasRuleset())
      tgt.setRuleset(convertActionAssertRulesetComponent(src.getRuleset()));
    if (src.hasSourceId())
      tgt.setSourceId(src.getSourceId());
    if (src.hasValidateProfileId())
      tgt.setValidateProfileId(src.getValidateProfileId());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasWarningOnly())
      tgt.setWarningOnly(src.getWarningOnly());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent();
    copyElement(src, tgt);
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasDirection())
      tgt.setDirection(convertAssertionDirectionType(src.getDirection()));
    if (src.hasCompareToSourceId())
      tgt.setCompareToSourceId(src.getCompareToSourceId());
    if (src.hasCompareToSourceExpression())
      tgt.setCompareToSourceExpression(src.getCompareToSourceExpression());
    if (src.hasCompareToSourcePath())
      tgt.setCompareToSourcePath(src.getCompareToSourcePath());
    if (src.hasContentType())
      tgt.setContentType(convertContentType(src.getContentType()));
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasHeaderField())
      tgt.setHeaderField(src.getHeaderField());
    if (src.hasMinimumId())
      tgt.setMinimumId(src.getMinimumId());
    if (src.hasNavigationLinks())
      tgt.setNavigationLinks(src.getNavigationLinks());
    if (src.hasOperator())
      tgt.setOperator(convertAssertionOperatorType(src.getOperator()));
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasRequestMethod())
      tgt.setRequestMethod(convertTestScriptRequestMethodCode(src.getRequestMethod()));
    if (src.hasRequestURL())
      tgt.setRequestURL(src.getRequestURL());
    if (src.hasResource())
      tgt.setResource(src.getResource());
    if (src.hasResponse())
      tgt.setResponse(convertAssertionResponseTypes(src.getResponse()));
    if (src.hasResponseCode())
      tgt.setResponseCode(src.getResponseCode());
    if (src.hasRule())
      tgt.setRule(convertActionAssertRuleComponent(src.getRule()));
    if (src.hasRuleset())
      tgt.setRuleset(convertActionAssertRulesetComponent(src.getRuleset()));
    if (src.hasSourceId())
      tgt.setSourceId(src.getSourceId());
    if (src.hasValidateProfileId())
      tgt.setValidateProfileId(src.getValidateProfileId());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasWarningOnly())
      tgt.setWarningOnly(src.getWarningOnly());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestReport.SetupActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestScript.SetupActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent();
    copyElement(src, tgt);
    if (src.hasResult())
      tgt.setResult(convertTestReportActionResult(src.getResult()));
    if (src.hasMessage())
      tgt.setMessage(src.getMessage());
    if (src.hasDetail())
      tgt.setDetail(src.getDetail());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent();
    copyElement(src, tgt);
    if (src.hasResult())
      tgt.setResult(convertTestReportActionResult(src.getResult()));
    if (src.hasMessage())
      tgt.setMessage(src.getMessage());
    if (src.hasDetail())
      tgt.setDetail(src.getDetail());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    if (src.hasResource())
      tgt.setResource(src.getResource());
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAccept())
      tgt.setAccept(convertContentType(src.getAccept()));
    if (src.hasContentType())
      tgt.setContentType(convertContentType(src.getContentType()));
    if (src.hasDestination())
      tgt.setDestination(src.getDestination());
    if (src.hasEncodeRequestUrl())
      tgt.setEncodeRequestUrl(src.getEncodeRequestUrl());
    if (src.hasOrigin())
      tgt.setOrigin(src.getOrigin());
    if (src.hasParams())
      tgt.setParams(src.getParams());
    for (org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader())
      tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t));
    if (src.hasRequestId())
      tgt.setRequestId(src.getRequestId());
    if (src.hasResponseId())
      tgt.setResponseId(src.getResponseId());
    if (src.hasSourceId())
      tgt.setSourceId(src.getSourceId());
    if (src.hasTargetId())
      tgt.setTargetId(src.getTargetId());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    if (src.hasResource())
      tgt.setResource(src.getResource());
    if (src.hasLabel())
      tgt.setLabel(src.getLabel());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasAccept())
      tgt.setAccept(convertContentType(src.getAccept()));
    if (src.hasContentType())
      tgt.setContentType(convertContentType(src.getContentType()));
    if (src.hasDestination())
      tgt.setDestination(src.getDestination());
    if (src.hasEncodeRequestUrl())
      tgt.setEncodeRequestUrl(src.getEncodeRequestUrl());
    if (src.hasOrigin())
      tgt.setOrigin(src.getOrigin());
    if (src.hasParams())
      tgt.setParams(src.getParams());
    for (org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader())
      tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t));
    if (src.hasRequestId())
      tgt.setRequestId(src.getRequestId());
    if (src.hasResponseId())
      tgt.setResponseId(src.getResponseId());
    if (src.hasSourceId())
      tgt.setSourceId(src.getSourceId());
    if (src.hasTargetId())
      tgt.setTargetId(src.getTargetId());
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent();
    copyElement(src, tgt);
    if (src.hasField())
      tgt.setField(src.getField());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent();
    copyElement(src, tgt);
    if (src.hasField())
      tgt.setField(src.getField());
    if (src.hasValue())
      tgt.setValue(src.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Contract.SignatoryComponent convertSignatoryComponent(org.hl7.fhir.dstu3.model.Contract.SignatoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.SignatoryComponent tgt = new org.hl7.fhir.r4.model.Contract.SignatoryComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    for (org.hl7.fhir.dstu3.model.Signature t : src.getSignature())
      tgt.addSignature(convertSignature(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.SignatoryComponent convertSignatoryComponent(org.hl7.fhir.r4.model.Contract.SignatoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.SignatoryComponent tgt = new org.hl7.fhir.dstu3.model.Contract.SignatoryComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCoding(src.getType()));
    if (src.hasParty())
      tgt.setParty(convertReference(src.getParty()));
    for (org.hl7.fhir.r4.model.Signature t : src.getSignature())
      tgt.addSignature(convertSignature(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Coding t : src.getType())
      tgt.addType(convertCoding(t));
    if (src.hasWhen())
      tgt.setWhen(src.getWhen());
    if (src.hasWho())
      tgt.setWho(convertType(src.getWho()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertType(src.getOnBehalfOf()));
    if (src.hasContentType())
      tgt.setContentType(src.getContentType());
    if (src.hasBlob())
      tgt.setBlob(src.getBlob());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Coding t : src.getType())
      tgt.addType(convertCoding(t));
    if (src.hasWhen())
      tgt.setWhen(src.getWhen());
    if (src.hasWho())
      tgt.setWho(convertType(src.getWho()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertType(src.getOnBehalfOf()));
    if (src.hasContentType())
      tgt.setContentType(src.getContentType());
    if (src.hasBlob())
      tgt.setBlob(src.getBlob());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasComparator())
      tgt.setComparator(convertQuantityComparator(src.getComparator()));
    if (src.hasUnit())
      tgt.setUnit(src.getUnit());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasComparator())
      tgt.setComparator(convertQuantityComparator(src.getComparator()));
    if (src.hasUnit())
      tgt.setUnit(src.getUnit());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.ElementDefinition.SlicingRules convertSlicingRules(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CLOSED: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED;
    case OPEN: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN;
    case OPENATEND: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND;
    default: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules convertSlicingRules(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CLOSED: return org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED;
    case OPEN: return org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN;
    case OPENATEND: return org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND;
    default: return org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Slot convertSlot(org.hl7.fhir.dstu3.model.Slot src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Slot tgt = new org.hl7.fhir.r4.model.Slot();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasServiceCategory())
      tgt.setServiceCategory(convertCodeableConcept(src.getServiceCategory()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getServiceType())
      tgt.addServiceType(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    if (src.hasAppointmentType())
      tgt.setAppointmentType(convertCodeableConcept(src.getAppointmentType()));
    if (src.hasSchedule())
      tgt.setSchedule(convertReference(src.getSchedule()));
    if (src.hasStatus())
      tgt.setStatus(convertSlotStatus(src.getStatus()));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasOverbooked())
      tgt.setOverbooked(src.getOverbooked());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Slot convertSlot(org.hl7.fhir.r4.model.Slot src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Slot tgt = new org.hl7.fhir.dstu3.model.Slot();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasServiceCategory())
      tgt.setServiceCategory(convertCodeableConcept(src.getServiceCategory()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType())
      tgt.addServiceType(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty())
      tgt.addSpecialty(convertCodeableConcept(t));
    if (src.hasAppointmentType())
      tgt.setAppointmentType(convertCodeableConcept(src.getAppointmentType()));
    if (src.hasSchedule())
      tgt.setSchedule(convertReference(src.getSchedule()));
    if (src.hasStatus())
      tgt.setStatus(convertSlotStatus(src.getStatus()));
    if (src.hasStart())
      tgt.setStart(src.getStart());
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasOverbooked())
      tgt.setOverbooked(src.getOverbooked());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Slot.SlotStatus convertSlotStatus(org.hl7.fhir.dstu3.model.Slot.SlotStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case BUSY: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSY;
    case FREE: return org.hl7.fhir.r4.model.Slot.SlotStatus.FREE;
    case BUSYUNAVAILABLE: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYUNAVAILABLE;
    case BUSYTENTATIVE: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYTENTATIVE;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Slot.SlotStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Slot.SlotStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Slot.SlotStatus convertSlotStatus(org.hl7.fhir.r4.model.Slot.SlotStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case BUSY: return org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSY;
    case FREE: return org.hl7.fhir.dstu3.model.Slot.SlotStatus.FREE;
    case BUSYUNAVAILABLE: return org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYUNAVAILABLE;
    case BUSYTENTATIVE: return org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYTENTATIVE;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Slot.SlotStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Slot.SlotStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    for (org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent t : src.getTarget())
      tgt.addTarget(convertTargetElementComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    for (org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent t : src.getTarget())
      tgt.addTarget(convertTargetElementComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Claim.SpecialConditionComponent convertSpecialConditionComponent(org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.SpecialConditionComponent tgt = new org.hl7.fhir.r4.model.Claim.SpecialConditionComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasTiming())
      tgt.setTiming(convertType(src.getTiming()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent convertSpecialConditionComponent(org.hl7.fhir.r4.model.Claim.SpecialConditionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent tgt = new org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasTiming())
      tgt.setTiming(convertType(src.getTiming()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    if (src.hasReason())
      tgt.setReason(convertCodeableConcept(src.getReason()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Specimen convertSpecimen(org.hl7.fhir.dstu3.model.Specimen src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Specimen tgt = new org.hl7.fhir.r4.model.Specimen();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasAccessionIdentifier())
      tgt.setAccessionIdentifier(convertIdentifier(src.getAccessionIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertSpecimenStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasReceivedTime())
      tgt.setReceivedTime(src.getReceivedTime());
    for (org.hl7.fhir.dstu3.model.Reference t : src.getParent())
      tgt.addParent(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRequest())
      tgt.addRequest(convertReference(t));
    if (src.hasCollection())
      tgt.setCollection(convertSpecimenCollectionComponent(src.getCollection()));
    for (org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent t : src.getProcessing())
      tgt.addProcessing(convertSpecimenProcessingComponent(t));
    for (org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent t : src.getContainer())
      tgt.addContainer(convertSpecimenContainerComponent(t));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Specimen convertSpecimen(org.hl7.fhir.r4.model.Specimen src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Specimen tgt = new org.hl7.fhir.dstu3.model.Specimen();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasAccessionIdentifier())
      tgt.setAccessionIdentifier(convertIdentifier(src.getAccessionIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertSpecimenStatus(src.getStatus()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSubject())
      tgt.setSubject(convertReference(src.getSubject()));
    if (src.hasReceivedTime())
      tgt.setReceivedTime(src.getReceivedTime());
    for (org.hl7.fhir.r4.model.Reference t : src.getParent())
      tgt.addParent(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getRequest())
      tgt.addRequest(convertReference(t));
    if (src.hasCollection())
      tgt.setCollection(convertSpecimenCollectionComponent(src.getCollection()));
    for (org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent t : src.getProcessing())
      tgt.addProcessing(convertSpecimenProcessingComponent(t));
    for (org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent t : src.getContainer())
      tgt.addContainer(convertSpecimenContainerComponent(t));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent convertSpecimenCollectionComponent(org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent tgt = new org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent();
    copyElement(src, tgt);
    if (src.hasCollector())
      tgt.setCollector(convertReference(src.getCollector()));
    if (src.hasCollected())
      tgt.setCollected(convertType(src.getCollected()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent convertSpecimenCollectionComponent(org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent tgt = new org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent();
    copyElement(src, tgt);
    if (src.hasCollector())
      tgt.setCollector(convertReference(src.getCollector()));
    if (src.hasCollected())
      tgt.setCollected(convertType(src.getCollected()));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasMethod())
      tgt.setMethod(convertCodeableConcept(src.getMethod()));
    if (src.hasBodySite())
      tgt.setBodySite(convertCodeableConcept(src.getBodySite()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent convertSpecimenContainerComponent(org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent tgt = new org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasCapacity())
      tgt.setCapacity(convertSimpleQuantity(src.getCapacity()));
    if (src.hasSpecimenQuantity())
      tgt.setSpecimenQuantity(convertSimpleQuantity(src.getSpecimenQuantity()));
    if (src.hasAdditive())
      tgt.setAdditive(convertType(src.getAdditive()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent convertSpecimenContainerComponent(org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent tgt = new org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasCapacity())
      tgt.setCapacity(convertSimpleQuantity(src.getCapacity()));
    if (src.hasSpecimenQuantity())
      tgt.setSpecimenQuantity(convertSimpleQuantity(src.getSpecimenQuantity()));
    if (src.hasAdditive())
      tgt.setAdditive(convertType(src.getAdditive()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent convertSpecimenProcessingComponent(org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent tgt = new org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasProcedure())
      tgt.setProcedure(convertCodeableConcept(src.getProcedure()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getAdditive())
      tgt.addAdditive(convertReference(t));
    if (src.hasTime())
      tgt.setTime(convertType(src.getTime()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent convertSpecimenProcessingComponent(org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent tgt = new org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent();
    copyElement(src, tgt);
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasProcedure())
      tgt.setProcedure(convertCodeableConcept(src.getProcedure()));
    for (org.hl7.fhir.r4.model.Reference t : src.getAdditive())
      tgt.addAdditive(convertReference(t));
    if (src.hasTime())
      tgt.setTime(convertType(src.getTime()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Specimen.SpecimenStatus convertSpecimenStatus(org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AVAILABLE: return org.hl7.fhir.r4.model.Specimen.SpecimenStatus.AVAILABLE;
    case UNAVAILABLE: return org.hl7.fhir.r4.model.Specimen.SpecimenStatus.UNAVAILABLE;
    case UNSATISFACTORY: return org.hl7.fhir.r4.model.Specimen.SpecimenStatus.UNSATISFACTORY;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Specimen.SpecimenStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Specimen.SpecimenStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus convertSpecimenStatus(org.hl7.fhir.r4.model.Specimen.SpecimenStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case AVAILABLE: return org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.AVAILABLE;
    case UNAVAILABLE: return org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.UNAVAILABLE;
    case UNSATISFACTORY: return org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.UNSATISFACTORY;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent convertStatusHistoryComponent(org.hl7.fhir.dstu3.model.Encounter.StatusHistoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent tgt = new org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertEncounterStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Encounter.StatusHistoryComponent convertStatusHistoryComponent(org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Encounter.StatusHistoryComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.StatusHistoryComponent();
    copyElement(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertEncounterStatus(src.getStatus()));
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MeasureReport.StratifierGroupComponent convertStratifierGroupComponent(org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MeasureReport.StratifierGroupComponent tgt = new org.hl7.fhir.r4.model.MeasureReport.StratifierGroupComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    for (org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupPopulationComponent t : src.getPopulation())
      tgt.addPopulation(convertStratifierGroupPopulationComponent(t));
    if (src.hasMeasureScore())
      tgt.setMeasureScore(src.getMeasureScore());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupComponent convertStratifierGroupComponent(org.hl7.fhir.r4.model.MeasureReport.StratifierGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupComponent tgt = new org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    for (org.hl7.fhir.r4.model.MeasureReport.StratifierGroupPopulationComponent t : src.getPopulation())
      tgt.addPopulation(convertStratifierGroupPopulationComponent(t));
    if (src.hasMeasureScore())
      tgt.setMeasureScore(src.getMeasureScore());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.MeasureReport.StratifierGroupPopulationComponent convertStratifierGroupPopulationComponent(org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupPopulationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.MeasureReport.StratifierGroupPopulationComponent tgt = new org.hl7.fhir.r4.model.MeasureReport.StratifierGroupPopulationComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    if (src.hasPatients())
      tgt.setPatients(convertReference(src.getPatients()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupPopulationComponent convertStratifierGroupPopulationComponent(org.hl7.fhir.r4.model.MeasureReport.StratifierGroupPopulationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupPopulationComponent tgt = new org.hl7.fhir.dstu3.model.MeasureReport.StratifierGroupPopulationComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    if (src.hasPatients())
      tgt.setPatients(convertReference(src.getPatients()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException {
    org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureDefinition tgt = new org.hl7.fhir.r4.model.StructureDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.dstu3.model.Coding t : src.getKeyword())
      tgt.addKeyword(convertCoding(t));
    if (src.hasFhirVersion())
      tgt.setFhirVersion(src.getFhirVersion());
    for (org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
    if (src.hasKind())
      tgt.setKind(convertStructureDefinitionKind(src.getKind()));
    if (src.hasAbstract())
      tgt.setAbstract(src.getAbstract());
    if (src.hasContextType())
      tgt.setContextType(convertExtensionContext(src.getContextType()));
    for (org.hl7.fhir.dstu3.model.StringType t : src.getContext())
      tgt.addContext(t.getValue());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getContextInvariant())
      tgt.addContextInvariant(t.getValue());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasBaseDefinition())
      tgt.setBaseDefinition(src.getBaseDefinition());
    if (src.hasDerivation())
      tgt.setDerivation(convertTypeDerivationRule(src.getDerivation()));
    if (src.hasSnapshot())
      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
    if (src.hasDifferential())
      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r4.model.StructureDefinition src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureDefinition tgt = new org.hl7.fhir.dstu3.model.StructureDefinition();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.r4.model.Coding t : src.getKeyword())
      tgt.addKeyword(convertCoding(t));
    if (src.hasFhirVersion())
      tgt.setFhirVersion(src.getFhirVersion());
    for (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
    if (src.hasKind())
      tgt.setKind(convertStructureDefinitionKind(src.getKind()));
    if (src.hasAbstract())
      tgt.setAbstract(src.getAbstract());
    if (src.hasContextType())
      tgt.setContextType(convertExtensionContext(src.getContextType()));
    for (org.hl7.fhir.r4.model.StringType t : src.getContext())
      tgt.addContext(t.getValue());
    for (org.hl7.fhir.r4.model.StringType t : src.getContextInvariant())
      tgt.addContextInvariant(t.getValue());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasBaseDefinition())
      tgt.setBaseDefinition(src.getBaseDefinition());
    if (src.hasDerivation())
      tgt.setDerivation(convertTypeDerivationRule(src.getDerivation()));
    if (src.hasSnapshot())
      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
    if (src.hasDifferential())
      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement())
      tgt.addElement(convertElementDefinition(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement())
      tgt.addElement(convertElementDefinition(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind convertStructureDefinitionKind(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRIMITIVETYPE: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE;
    case COMPLEXTYPE: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE;
    case RESOURCE: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.RESOURCE;
    case LOGICAL: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.LOGICAL;
    default: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind convertStructureDefinitionKind(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PRIMITIVETYPE: return org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE;
    case COMPLEXTYPE: return org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE;
    case RESOURCE: return org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.RESOURCE;
    case LOGICAL: return org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.LOGICAL;
    default: return org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.NULL;
  }
}

  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent();
    copyElement(src, tgt);
    if (src.hasIdentity())
      tgt.setIdentity(src.getIdentity());
    if (src.hasUri())
      tgt.setUri(src.getUri());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent();
    copyElement(src, tgt);
    if (src.hasIdentity())
      tgt.setIdentity(src.getIdentity());
    if (src.hasUri())
      tgt.setUri(src.getUri());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasComment())
      tgt.setComment(src.getComment());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement())
      tgt.addElement(convertElementDefinition(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement())
      tgt.addElement(convertElementDefinition(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureMap convertStructureMap(org.hl7.fhir.dstu3.model.StructureMap src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap tgt = new org.hl7.fhir.r4.model.StructureMap();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent t : src.getStructure())
      tgt.addStructure(convertStructureMapStructureComponent(t));
    for (org.hl7.fhir.dstu3.model.UriType t : src.getImport())
      tgt.addImport(t.getValue());
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupComponent t : src.getGroup())
      tgt.addGroup(convertStructureMapGroupComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap convertStructureMap(org.hl7.fhir.r4.model.StructureMap src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap tgt = new org.hl7.fhir.dstu3.model.StructureMap();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent t : src.getStructure())
      tgt.addStructure(convertStructureMapStructureComponent(t));
    for (org.hl7.fhir.r4.model.UriType t : src.getImport())
      tgt.addImport(t.getValue());
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent t : src.getGroup())
      tgt.addGroup(convertStructureMapGroupComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.StructureMap.StructureMapContextType convertStructureMapContextType(org.hl7.fhir.dstu3.model.StructureMap.StructureMapContextType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case TYPE: return org.hl7.fhir.r4.model.StructureMap.StructureMapContextType.TYPE;
    case VARIABLE: return org.hl7.fhir.r4.model.StructureMap.StructureMapContextType.VARIABLE;
    default: return org.hl7.fhir.r4.model.StructureMap.StructureMapContextType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureMap.StructureMapContextType convertStructureMapContextType(org.hl7.fhir.r4.model.StructureMap.StructureMapContextType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case TYPE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapContextType.TYPE;
    case VARIABLE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapContextType.VARIABLE;
    default: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapContextType.NULL;
  }
}

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent convertStructureMapGroupComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasExtends())
      tgt.setExtends(src.getExtends());
    if (src.hasTypeMode())
      tgt.setTypeMode(convertStructureMapGroupTypeMode(src.getTypeMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupInputComponent t : src.getInput())
      tgt.addInput(convertStructureMapGroupInputComponent(t));
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
      tgt.addRule(convertStructureMapGroupRuleComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupComponent convertStructureMapGroupComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasExtends())
      tgt.setExtends(src.getExtends());
    if (src.hasTypeMode())
      tgt.setTypeMode(convertStructureMapGroupTypeMode(src.getTypeMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent t : src.getInput())
      tgt.addInput(convertStructureMapGroupInputComponent(t));
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
      tgt.addRule(convertStructureMapGroupRuleComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent convertStructureMapGroupInputComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupInputComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasMode())
      tgt.setMode(convertStructureMapInputMode(src.getMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupInputComponent convertStructureMapGroupInputComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupInputComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupInputComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasMode())
      tgt.setMode(convertStructureMapInputMode(src.getMode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent convertStructureMapGroupRuleComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleSourceComponent t : src.getSource())
      tgt.addSource(convertStructureMapGroupRuleSourceComponent(t));
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetComponent t : src.getTarget())
      tgt.addTarget(convertStructureMapGroupRuleTargetComponent(t));
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
      tgt.addRule(convertStructureMapGroupRuleComponent(t));
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleDependentComponent t : src.getDependent())
      tgt.addDependent(convertStructureMapGroupRuleDependentComponent(t));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleComponent convertStructureMapGroupRuleComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent t : src.getSource())
      tgt.addSource(convertStructureMapGroupRuleSourceComponent(t));
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent t : src.getTarget())
      tgt.addTarget(convertStructureMapGroupRuleTargetComponent(t));
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
      tgt.addRule(convertStructureMapGroupRuleComponent(t));
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent t : src.getDependent())
      tgt.addDependent(convertStructureMapGroupRuleDependentComponent(t));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getVariable())
      tgt.addVariable(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleDependentComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    for (org.hl7.fhir.r4.model.StringType t : src.getVariable())
      tgt.addVariable(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent convertStructureMapGroupRuleSourceComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleSourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent();
    copyElement(src, tgt);
    if (src.hasContext())
      tgt.setContext(src.getContext());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasDefaultValue())
      tgt.setDefaultValue(convertType(src.getDefaultValue()));
    if (src.hasElement())
      tgt.setElement(src.getElement());
    if (src.hasListMode())
      tgt.setListMode(convertStructureMapSourceListMode(src.getListMode()));
    if (src.hasVariable())
      tgt.setVariable(src.getVariable());
    if (src.hasCondition())
      tgt.setCondition(src.getCondition());
    if (src.hasCheck())
      tgt.setCheck(src.getCheck());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleSourceComponent convertStructureMapGroupRuleSourceComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleSourceComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleSourceComponent();
    copyElement(src, tgt);
    if (src.hasContext())
      tgt.setContext(src.getContext());
    if (src.hasMin())
      tgt.setMin(src.getMin());
    if (src.hasMax())
      tgt.setMax(src.getMax());
    if (src.hasType())
      tgt.setType(src.getType());
    if (src.hasDefaultValue())
      tgt.setDefaultValue(convertType(src.getDefaultValue()));
    if (src.hasElement())
      tgt.setElement(src.getElement());
    if (src.hasListMode())
      tgt.setListMode(convertStructureMapSourceListMode(src.getListMode()));
    if (src.hasVariable())
      tgt.setVariable(src.getVariable());
    if (src.hasCondition())
      tgt.setCondition(src.getCondition());
    if (src.hasCheck())
      tgt.setCheck(src.getCheck());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent convertStructureMapGroupRuleTargetComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent();
    copyElement(src, tgt);
    if (src.hasContext())
      tgt.setContext(src.getContext());
    if (src.hasContextType())
      tgt.setContextType(convertStructureMapContextType(src.getContextType()));
    if (src.hasElement())
      tgt.setElement(src.getElement());
    if (src.hasVariable())
      tgt.setVariable(src.getVariable());
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode> t : src.getListMode())
      tgt.addListMode(convertStructureMapTargetListMode(t.getValue()));
    if (src.hasListRuleId())
      tgt.setListRuleId(src.getListRuleId());
    if (src.hasTransform())
      tgt.setTransform(convertStructureMapTransform(src.getTransform()));
    for (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetParameterComponent t : src.getParameter())
      tgt.addParameter(convertStructureMapGroupRuleTargetParameterComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetComponent convertStructureMapGroupRuleTargetComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetComponent();
    copyElement(src, tgt);
    if (src.hasContext())
      tgt.setContext(src.getContext());
    if (src.hasContextType())
      tgt.setContextType(convertStructureMapContextType(src.getContextType()));
    if (src.hasElement())
      tgt.setElement(src.getElement());
    if (src.hasVariable())
      tgt.setVariable(src.getVariable());
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode> t : src.getListMode())
      tgt.addListMode(convertStructureMapTargetListMode(t.getValue()));
    if (src.hasListRuleId())
      tgt.setListRuleId(src.getListRuleId());
    if (src.hasTransform())
      tgt.setTransform(convertStructureMapTransform(src.getTransform()));
    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent t : src.getParameter())
      tgt.addParameter(convertStructureMapGroupRuleTargetParameterComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent convertStructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetParameterComponent convertStructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetParameterComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetParameterComponent();
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode convertStructureMapGroupTypeMode(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupTypeMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NONE: return org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.NONE;
    case TYPES: return org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.TYPES;
    case TYPEANDTYPES: return org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.TYPEANDTYPES;
    default: return org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupTypeMode convertStructureMapGroupTypeMode(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NONE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupTypeMode.NONE;
    case TYPES: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupTypeMode.TYPES;
    case TYPEANDTYPES: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupTypeMode.TYPEANDTYPES;
    default: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupTypeMode.NULL;
  }
}

  private static org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode convertStructureMapInputMode(org.hl7.fhir.dstu3.model.StructureMap.StructureMapInputMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SOURCE: return org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode.SOURCE;
    case TARGET: return org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode.TARGET;
    default: return org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureMap.StructureMapInputMode convertStructureMapInputMode(org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SOURCE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapInputMode.SOURCE;
    case TARGET: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapInputMode.TARGET;
    default: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapInputMode.NULL;
  }
}

  private static org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode convertStructureMapModelMode(org.hl7.fhir.dstu3.model.StructureMap.StructureMapModelMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SOURCE: return org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.SOURCE;
    case QUERIED: return org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.QUERIED;
    case TARGET: return org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.TARGET;
    case PRODUCED: return org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.PRODUCED;
    default: return org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureMap.StructureMapModelMode convertStructureMapModelMode(org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SOURCE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapModelMode.SOURCE;
    case QUERIED: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapModelMode.QUERIED;
    case TARGET: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapModelMode.TARGET;
    case PRODUCED: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapModelMode.PRODUCED;
    default: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapModelMode.NULL;
  }
}

  private static org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode convertStructureMapSourceListMode(org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FIRST: return org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.FIRST;
    case NOTFIRST: return org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.NOTFIRST;
    case LAST: return org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.LAST;
    case NOTLAST: return org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.NOTLAST;
    case ONLYONE: return org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.ONLYONE;
    default: return org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode convertStructureMapSourceListMode(org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FIRST: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode.FIRST;
    case NOTFIRST: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode.NOTFIRST;
    case LAST: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode.LAST;
    case NOTLAST: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode.NOTLAST;
    case ONLYONE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode.ONLYONE;
    default: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapSourceListMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent();
    copyElement(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasMode())
      tgt.setMode(convertStructureMapModelMode(src.getMode()));
    if (src.hasAlias())
      tgt.setAlias(src.getAlias());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent();
    copyElement(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasMode())
      tgt.setMode(convertStructureMapModelMode(src.getMode()));
    if (src.hasAlias())
      tgt.setAlias(src.getAlias());
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode convertStructureMapTargetListMode(org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FIRST: return org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.FIRST;
    case SHARE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.SHARE;
    case LAST: return org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.LAST;
    case COLLATE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.COLLATE;
    default: return org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode convertStructureMapTargetListMode(org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case FIRST: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode.FIRST;
    case SHARE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode.SHARE;
    case LAST: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode.LAST;
    case COLLATE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode.COLLATE;
    default: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode.NULL;
  }
}

  private static org.hl7.fhir.r4.model.StructureMap.StructureMapTransform convertStructureMapTransform(org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CREATE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CREATE;
    case COPY: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.COPY;
    case TRUNCATE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.TRUNCATE;
    case ESCAPE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.ESCAPE;
    case CAST: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CAST;
    case APPEND: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.APPEND;
    case TRANSLATE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.TRANSLATE;
    case REFERENCE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.REFERENCE;
    case DATEOP: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.DATEOP;
    case UUID: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.UUID;
    case POINTER: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.POINTER;
    case EVALUATE: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.EVALUATE;
    case CC: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CC;
    case C: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.C;
    case QTY: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.QTY;
    case ID: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.ID;
    case CP: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CP;
    default: return org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform convertStructureMapTransform(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case CREATE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.CREATE;
    case COPY: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.COPY;
    case TRUNCATE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.TRUNCATE;
    case ESCAPE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.ESCAPE;
    case CAST: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.CAST;
    case APPEND: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.APPEND;
    case TRANSLATE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.TRANSLATE;
    case REFERENCE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.REFERENCE;
    case DATEOP: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.DATEOP;
    case UUID: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.UUID;
    case POINTER: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.POINTER;
    case EVALUATE: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.EVALUATE;
    case CC: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.CC;
    case C: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.C;
    case QTY: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.QTY;
    case ID: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.ID;
    case CP: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.CP;
    default: return org.hl7.fhir.dstu3.model.StructureMap.StructureMapTransform.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ImagingManifest.StudyComponent convertStudyComponent(org.hl7.fhir.dstu3.model.ImagingManifest.StudyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ImagingManifest.StudyComponent tgt = new org.hl7.fhir.r4.model.ImagingManifest.StudyComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasImagingStudy())
      tgt.setImagingStudy(convertReference(src.getImagingStudy()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    for (org.hl7.fhir.dstu3.model.ImagingManifest.SeriesComponent t : src.getSeries())
      tgt.addSeries(convertSeriesComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ImagingManifest.StudyComponent convertStudyComponent(org.hl7.fhir.r4.model.ImagingManifest.StudyComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ImagingManifest.StudyComponent tgt = new org.hl7.fhir.dstu3.model.ImagingManifest.StudyComponent();
    copyElement(src, tgt);
    if (src.hasUid())
      tgt.setUid(src.getUid());
    if (src.hasImagingStudy())
      tgt.setImagingStudy(convertReference(src.getImagingStudy()));
    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint())
      tgt.addEndpoint(convertReference(t));
    for (org.hl7.fhir.r4.model.ImagingManifest.SeriesComponent t : src.getSeries())
      tgt.addSeries(convertSeriesComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Claim.SubDetailComponent convertSubDetailComponent(org.hl7.fhir.dstu3.model.Claim.SubDetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Claim.SubDetailComponent tgt = new org.hl7.fhir.r4.model.Claim.SubDetailComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasRevenue())
      tgt.setRevenue(convertCodeableConcept(src.getRevenue()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasService())
      tgt.setService(convertCodeableConcept(src.getService()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getModifier())
      tgt.addModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getProgramCode())
      tgt.addProgramCode(convertCodeableConcept(t));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getUdi())
      tgt.addUdi(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Claim.SubDetailComponent convertSubDetailComponent(org.hl7.fhir.r4.model.Claim.SubDetailComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Claim.SubDetailComponent tgt = new org.hl7.fhir.dstu3.model.Claim.SubDetailComponent();
    copyElement(src, tgt);
    if (src.hasSequence())
      tgt.setSequence(src.getSequence());
    if (src.hasRevenue())
      tgt.setRevenue(convertCodeableConcept(src.getRevenue()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasService())
      tgt.setService(convertCodeableConcept(src.getService()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getModifier())
      tgt.addModifier(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProgramCode())
      tgt.addProgramCode(convertCodeableConcept(t));
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    for (org.hl7.fhir.r4.model.Reference t : src.getUdi())
      tgt.addUdi(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Subscription convertSubscription(org.hl7.fhir.dstu3.model.Subscription src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Subscription tgt = new org.hl7.fhir.r4.model.Subscription();
    copyDomainResource(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertSubscriptionStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getContact())
      tgt.addContact(convertContactPoint(t));
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasReason())
      tgt.setReason(src.getReason());
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    if (src.hasError())
      tgt.setError(src.getError());
    if (src.hasChannel())
      tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel()));
    for (org.hl7.fhir.dstu3.model.Coding t : src.getTag())
      tgt.addTag(convertCoding(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Subscription convertSubscription(org.hl7.fhir.r4.model.Subscription src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Subscription tgt = new org.hl7.fhir.dstu3.model.Subscription();
    copyDomainResource(src, tgt);
    if (src.hasStatus())
      tgt.setStatus(convertSubscriptionStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact())
      tgt.addContact(convertContactPoint(t));
    if (src.hasEnd())
      tgt.setEnd(src.getEnd());
    if (src.hasReason())
      tgt.setReason(src.getReason());
    if (src.hasCriteria())
      tgt.setCriteria(src.getCriteria());
    if (src.hasError())
      tgt.setError(src.getError());
    if (src.hasChannel())
      tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel()));
    for (org.hl7.fhir.r4.model.Coding t : src.getTag())
      tgt.addTag(convertCoding(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertSubscriptionChannelType(src.getType()));
    if (src.hasEndpoint())
      tgt.setEndpoint(src.getEndpoint());
    if (src.hasPayload())
      tgt.setPayload(src.getPayload());
    for (org.hl7.fhir.dstu3.model.StringType t : src.getHeader())
      tgt.addHeader(t.getValue());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertSubscriptionChannelType(src.getType()));
    if (src.hasEndpoint())
      tgt.setEndpoint(src.getEndpoint());
    if (src.hasPayload())
      tgt.setPayload(src.getPayload());
    for (org.hl7.fhir.r4.model.StringType t : src.getHeader())
      tgt.addHeader(t.getValue());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType convertSubscriptionChannelType(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RESTHOOK: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.RESTHOOK;
    case WEBSOCKET: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.WEBSOCKET;
    case EMAIL: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.EMAIL;
    case SMS: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.SMS;
    case MESSAGE: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.MESSAGE;
    default: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType convertSubscriptionChannelType(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RESTHOOK: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.RESTHOOK;
    case WEBSOCKET: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.WEBSOCKET;
    case EMAIL: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.EMAIL;
    case SMS: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.SMS;
    case MESSAGE: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.MESSAGE;
    default: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Subscription.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REQUESTED: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.REQUESTED;
    case ACTIVE: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ACTIVE;
    case ERROR: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ERROR;
    case OFF: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.OFF;
    default: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case REQUESTED: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.REQUESTED;
    case ACTIVE: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.ACTIVE;
    case ERROR: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.ERROR;
    case OFF: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.OFF;
    default: return org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Substance convertSubstance(org.hl7.fhir.dstu3.model.Substance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Substance tgt = new org.hl7.fhir.r4.model.Substance();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertFHIRSubstanceStatus(src.getStatus()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.Substance.SubstanceInstanceComponent t : src.getInstance())
      tgt.addInstance(convertSubstanceInstanceComponent(t));
    for (org.hl7.fhir.dstu3.model.Substance.SubstanceIngredientComponent t : src.getIngredient())
      tgt.addIngredient(convertSubstanceIngredientComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Substance convertSubstance(org.hl7.fhir.r4.model.Substance src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Substance tgt = new org.hl7.fhir.dstu3.model.Substance();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertFHIRSubstanceStatus(src.getStatus()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
      tgt.addCategory(convertCodeableConcept(t));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent t : src.getInstance())
      tgt.addInstance(convertSubstanceInstanceComponent(t));
    for (org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent t : src.getIngredient())
      tgt.addIngredient(convertSubstanceIngredientComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent convertSubstanceIngredientComponent(org.hl7.fhir.dstu3.model.Substance.SubstanceIngredientComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent tgt = new org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent();
    copyElement(src, tgt);
    if (src.hasQuantity())
      tgt.setQuantity(convertRatio(src.getQuantity()));
    if (src.hasSubstance())
      tgt.setSubstance(convertType(src.getSubstance()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Substance.SubstanceIngredientComponent convertSubstanceIngredientComponent(org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Substance.SubstanceIngredientComponent tgt = new org.hl7.fhir.dstu3.model.Substance.SubstanceIngredientComponent();
    copyElement(src, tgt);
    if (src.hasQuantity())
      tgt.setQuantity(convertRatio(src.getQuantity()));
    if (src.hasSubstance())
      tgt.setSubstance(convertType(src.getSubstance()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent convertSubstanceInstanceComponent(org.hl7.fhir.dstu3.model.Substance.SubstanceInstanceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent tgt = new org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasExpiry())
      tgt.setExpiry(src.getExpiry());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Substance.SubstanceInstanceComponent convertSubstanceInstanceComponent(org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Substance.SubstanceInstanceComponent tgt = new org.hl7.fhir.dstu3.model.Substance.SubstanceInstanceComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasExpiry())
      tgt.setExpiry(src.getExpiry());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.dstu3.model.SupplyDelivery src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SupplyDelivery tgt = new org.hl7.fhir.r4.model.SupplyDelivery();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertSupplyDeliveryStatus(src.getStatus()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSuppliedItem())
      tgt.setSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItem()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasSupplier())
      tgt.setSupplier(convertReference(src.getSupplier()));
    if (src.hasDestination())
      tgt.setDestination(convertReference(src.getDestination()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getReceiver())
      tgt.addReceiver(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r4.model.SupplyDelivery src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SupplyDelivery tgt = new org.hl7.fhir.dstu3.model.SupplyDelivery();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertSupplyDeliveryStatus(src.getStatus()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSuppliedItem())
      tgt.setSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItem()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasSupplier())
      tgt.setSupplier(convertReference(src.getSupplier()));
    if (src.hasDestination())
      tgt.setDestination(convertReference(src.getDestination()));
    for (org.hl7.fhir.r4.model.Reference t : src.getReceiver())
      tgt.addReceiver(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus convertSupplyDeliveryStatus(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INPROGRESS: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS;
    case COMPLETED: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED;
    case ABANDONED: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus convertSupplyDeliveryStatus(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case INPROGRESS: return org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS;
    case COMPLETED: return org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED;
    case ABANDONED: return org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent();
    copyElement(src, tgt);
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent();
    copyElement(src, tgt);
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.dstu3.model.SupplyRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SupplyRequest tgt = new org.hl7.fhir.r4.model.SupplyRequest();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertSupplyRequestStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasPriority())
      tgt.setPriority(convertRequestPriority(src.getPriority()));
    if (src.hasOrderedItem())
      tgt.setOrderedItem(convertSupplyRequestOrderedItemComponent(src.getOrderedItem()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertSupplyRequestRequesterComponent(src.getRequester()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupplier())
      tgt.addSupplier(convertReference(t));
    if (src.hasReason())
      tgt.setReason(convertType(src.getReason()));
    if (src.hasDeliverFrom())
      tgt.setDeliverFrom(convertReference(src.getDeliverFrom()));
    if (src.hasDeliverTo())
      tgt.setDeliverTo(convertReference(src.getDeliverTo()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.r4.model.SupplyRequest src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SupplyRequest tgt = new org.hl7.fhir.dstu3.model.SupplyRequest();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasStatus())
      tgt.setStatus(convertSupplyRequestStatus(src.getStatus()));
    if (src.hasCategory())
      tgt.setCategory(convertCodeableConcept(src.getCategory()));
    if (src.hasPriority())
      tgt.setPriority(convertRequestPriority(src.getPriority()));
    if (src.hasOrderedItem())
      tgt.setOrderedItem(convertSupplyRequestOrderedItemComponent(src.getOrderedItem()));
    if (src.hasOccurrence())
      tgt.setOccurrence(convertType(src.getOccurrence()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasRequester())
      tgt.setRequester(convertSupplyRequestRequesterComponent(src.getRequester()));
    for (org.hl7.fhir.r4.model.Reference t : src.getSupplier())
      tgt.addSupplier(convertReference(t));
    if (src.hasReason())
      tgt.setReason(convertType(src.getReason()));
    if (src.hasDeliverFrom())
      tgt.setDeliverFrom(convertReference(src.getDeliverFrom()));
    if (src.hasDeliverTo())
      tgt.setDeliverTo(convertReference(src.getDeliverTo()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestOrderedItemComponent convertSupplyRequestOrderedItemComponent(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestOrderedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestOrderedItemComponent tgt = new org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestOrderedItemComponent();
    copyElement(src, tgt);
    if (src.hasQuantity())
      tgt.setQuantity(convertQuantity(src.getQuantity()));
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestOrderedItemComponent convertSupplyRequestOrderedItemComponent(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestOrderedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestOrderedItemComponent tgt = new org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestOrderedItemComponent();
    copyElement(src, tgt);
    if (src.hasQuantity())
      tgt.setQuantity(convertQuantity(src.getQuantity()));
    if (src.hasItem())
      tgt.setItem(convertType(src.getItem()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestRequesterComponent convertSupplyRequestRequesterComponent(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestRequesterComponent tgt = new org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestRequesterComponent convertSupplyRequestRequesterComponent(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestRequesterComponent tgt = new org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus convertSupplyRequestStatus(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus convertSupplyRequestStatus(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.DRAFT;
    case ACTIVE: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.ACTIVE;
    case SUSPENDED: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.SUSPENDED;
    case CANCELLED: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.ENTEREDINERROR;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.SystemInteractionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertSystemRestfulInteraction(src.getCode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.CapabilityStatement.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.CapabilityStatement.SystemInteractionComponent tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement.SystemInteractionComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertSystemRestfulInteraction(src.getCode()));
    if (src.hasDocumentation())
      tgt.setDocumentation(src.getDocumentation());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction convertSystemRestfulInteraction(org.hl7.fhir.dstu3.model.CapabilityStatement.SystemRestfulInteraction src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case TRANSACTION: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.TRANSACTION;
    case BATCH: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.BATCH;
    case SEARCHSYSTEM: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.SEARCHSYSTEM;
    case HISTORYSYSTEM: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.HISTORYSYSTEM;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.SystemRestfulInteraction convertSystemRestfulInteraction(org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case TRANSACTION: return org.hl7.fhir.dstu3.model.CapabilityStatement.SystemRestfulInteraction.TRANSACTION;
    case BATCH: return org.hl7.fhir.dstu3.model.CapabilityStatement.SystemRestfulInteraction.BATCH;
    case SEARCHSYSTEM: return org.hl7.fhir.dstu3.model.CapabilityStatement.SystemRestfulInteraction.SEARCHSYSTEM;
    case HISTORYSYSTEM: return org.hl7.fhir.dstu3.model.CapabilityStatement.SystemRestfulInteraction.HISTORYSYSTEM;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.SystemRestfulInteraction.NULL;
  }
}

  private static org.hl7.fhir.r4.model.ExpansionProfile.SystemVersionProcessingMode convertSystemVersionProcessingMode(org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DEFAULT: return org.hl7.fhir.r4.model.ExpansionProfile.SystemVersionProcessingMode.DEFAULT;
    case CHECK: return org.hl7.fhir.r4.model.ExpansionProfile.SystemVersionProcessingMode.CHECK;
    case OVERRIDE: return org.hl7.fhir.r4.model.ExpansionProfile.SystemVersionProcessingMode.OVERRIDE;
    default: return org.hl7.fhir.r4.model.ExpansionProfile.SystemVersionProcessingMode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode convertSystemVersionProcessingMode(org.hl7.fhir.r4.model.ExpansionProfile.SystemVersionProcessingMode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DEFAULT: return org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode.DEFAULT;
    case CHECK: return org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode.CHECK;
    case OVERRIDE: return org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode.OVERRIDE;
    default: return org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasEquivalence())
      tgt.setEquivalence(convertConceptMapEquivalence(src.getEquivalence()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    for (org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
      tgt.addDependsOn(convertOtherElementComponent(t));
    for (org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent t : src.getProduct())
      tgt.addProduct(convertOtherElementComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    if (src.hasEquivalence())
      tgt.setEquivalence(convertConceptMapEquivalence(src.getEquivalence()));
    if (src.hasComment())
      tgt.setComment(src.getComment());
    for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
      tgt.addDependsOn(convertOtherElementComponent(t));
    for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getProduct())
      tgt.addProduct(convertOtherElementComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Task convertTask(org.hl7.fhir.dstu3.model.Task src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Task tgt = new org.hl7.fhir.r4.model.Task();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasDefinition())
      tgt.setDefinition(convertType(src.getDefinition()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertTaskStatus(src.getStatus()));
    if (src.hasStatusReason())
      tgt.setStatusReason(convertCodeableConcept(src.getStatusReason()));
    if (src.hasBusinessStatus())
      tgt.setBusinessStatus(convertCodeableConcept(src.getBusinessStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertTaskIntent(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertTaskPriority(src.getPriority()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasFocus())
      tgt.setFocus(convertReference(src.getFocus()));
    if (src.hasFor())
      tgt.setFor(convertReference(src.getFor()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasExecutionPeriod())
      tgt.setExecutionPeriod(convertPeriod(src.getExecutionPeriod()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasLastModified())
      tgt.setLastModified(src.getLastModified());
    if (src.hasRequester())
      tgt.setRequester(convertTaskRequesterComponent(src.getRequester()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPerformerType())
      tgt.addPerformerType(convertCodeableConcept(t));
    if (src.hasOwner())
      tgt.setOwner(convertReference(src.getOwner()));
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRelevantHistory())
      tgt.addRelevantHistory(convertReference(t));
    if (src.hasRestriction())
      tgt.setRestriction(convertTaskRestrictionComponent(src.getRestriction()));
    for (org.hl7.fhir.dstu3.model.Task.ParameterComponent t : src.getInput())
      tgt.addInput(convertParameterComponent(t));
    for (org.hl7.fhir.dstu3.model.Task.TaskOutputComponent t : src.getOutput())
      tgt.addOutput(convertTaskOutputComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Task convertTask(org.hl7.fhir.r4.model.Task src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Task tgt = new org.hl7.fhir.dstu3.model.Task();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasDefinition())
      tgt.setDefinition(convertType(src.getDefinition()));
    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn())
      tgt.addBasedOn(convertReference(t));
    if (src.hasGroupIdentifier())
      tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier()));
    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf())
      tgt.addPartOf(convertReference(t));
    if (src.hasStatus())
      tgt.setStatus(convertTaskStatus(src.getStatus()));
    if (src.hasStatusReason())
      tgt.setStatusReason(convertCodeableConcept(src.getStatusReason()));
    if (src.hasBusinessStatus())
      tgt.setBusinessStatus(convertCodeableConcept(src.getBusinessStatus()));
    if (src.hasIntent())
      tgt.setIntent(convertTaskIntent(src.getIntent()));
    if (src.hasPriority())
      tgt.setPriority(convertTaskPriority(src.getPriority()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasFocus())
      tgt.setFocus(convertReference(src.getFocus()));
    if (src.hasFor())
      tgt.setFor(convertReference(src.getFor()));
    if (src.hasContext())
      tgt.setContext(convertReference(src.getContext()));
    if (src.hasExecutionPeriod())
      tgt.setExecutionPeriod(convertPeriod(src.getExecutionPeriod()));
    if (src.hasAuthoredOn())
      tgt.setAuthoredOn(src.getAuthoredOn());
    if (src.hasLastModified())
      tgt.setLastModified(src.getLastModified());
    if (src.hasRequester())
      tgt.setRequester(convertTaskRequesterComponent(src.getRequester()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPerformerType())
      tgt.addPerformerType(convertCodeableConcept(t));
    if (src.hasOwner())
      tgt.setOwner(convertReference(src.getOwner()));
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getRelevantHistory())
      tgt.addRelevantHistory(convertReference(t));
    if (src.hasRestriction())
      tgt.setRestriction(convertTaskRestrictionComponent(src.getRestriction()));
    for (org.hl7.fhir.r4.model.Task.ParameterComponent t : src.getInput())
      tgt.addInput(convertParameterComponent(t));
    for (org.hl7.fhir.r4.model.Task.TaskOutputComponent t : src.getOutput())
      tgt.addOutput(convertTaskOutputComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Task.TaskIntent convertTaskIntent(org.hl7.fhir.dstu3.model.Task.TaskIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.r4.model.Task.TaskIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.r4.model.Task.TaskIntent.PLAN;
    case ORDER: return org.hl7.fhir.r4.model.Task.TaskIntent.ORDER;
    case ORIGINALORDER: return org.hl7.fhir.r4.model.Task.TaskIntent.ORIGINALORDER;
    case REFLEXORDER: return org.hl7.fhir.r4.model.Task.TaskIntent.REFLEXORDER;
    case FILLERORDER: return org.hl7.fhir.r4.model.Task.TaskIntent.FILLERORDER;
    case INSTANCEORDER: return org.hl7.fhir.r4.model.Task.TaskIntent.INSTANCEORDER;
    case OPTION: return org.hl7.fhir.r4.model.Task.TaskIntent.OPTION;
    default: return org.hl7.fhir.r4.model.Task.TaskIntent.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Task.TaskIntent convertTaskIntent(org.hl7.fhir.r4.model.Task.TaskIntent src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PROPOSAL: return org.hl7.fhir.dstu3.model.Task.TaskIntent.PROPOSAL;
    case PLAN: return org.hl7.fhir.dstu3.model.Task.TaskIntent.PLAN;
    case ORDER: return org.hl7.fhir.dstu3.model.Task.TaskIntent.ORDER;
    case ORIGINALORDER: return org.hl7.fhir.dstu3.model.Task.TaskIntent.ORIGINALORDER;
    case REFLEXORDER: return org.hl7.fhir.dstu3.model.Task.TaskIntent.REFLEXORDER;
    case FILLERORDER: return org.hl7.fhir.dstu3.model.Task.TaskIntent.FILLERORDER;
    case INSTANCEORDER: return org.hl7.fhir.dstu3.model.Task.TaskIntent.INSTANCEORDER;
    case OPTION: return org.hl7.fhir.dstu3.model.Task.TaskIntent.OPTION;
    default: return org.hl7.fhir.dstu3.model.Task.TaskIntent.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Task.TaskOutputComponent convertTaskOutputComponent(org.hl7.fhir.dstu3.model.Task.TaskOutputComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Task.TaskOutputComponent tgt = new org.hl7.fhir.r4.model.Task.TaskOutputComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Task.TaskOutputComponent convertTaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Task.TaskOutputComponent tgt = new org.hl7.fhir.dstu3.model.Task.TaskOutputComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Task.TaskPriority convertTaskPriority(org.hl7.fhir.dstu3.model.Task.TaskPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.r4.model.Task.TaskPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.r4.model.Task.TaskPriority.URGENT;
    case ASAP: return org.hl7.fhir.r4.model.Task.TaskPriority.ASAP;
    case STAT: return org.hl7.fhir.r4.model.Task.TaskPriority.STAT;
    default: return org.hl7.fhir.r4.model.Task.TaskPriority.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Task.TaskPriority convertTaskPriority(org.hl7.fhir.r4.model.Task.TaskPriority src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ROUTINE: return org.hl7.fhir.dstu3.model.Task.TaskPriority.ROUTINE;
    case URGENT: return org.hl7.fhir.dstu3.model.Task.TaskPriority.URGENT;
    case ASAP: return org.hl7.fhir.dstu3.model.Task.TaskPriority.ASAP;
    case STAT: return org.hl7.fhir.dstu3.model.Task.TaskPriority.STAT;
    default: return org.hl7.fhir.dstu3.model.Task.TaskPriority.NULL;
  }
}

  public static org.hl7.fhir.r4.model.Task.TaskRequesterComponent convertTaskRequesterComponent(org.hl7.fhir.dstu3.model.Task.TaskRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Task.TaskRequesterComponent tgt = new org.hl7.fhir.r4.model.Task.TaskRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Task.TaskRequesterComponent convertTaskRequesterComponent(org.hl7.fhir.r4.model.Task.TaskRequesterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Task.TaskRequesterComponent tgt = new org.hl7.fhir.dstu3.model.Task.TaskRequesterComponent();
    copyElement(src, tgt);
    if (src.hasAgent())
      tgt.setAgent(convertReference(src.getAgent()));
    if (src.hasOnBehalfOf())
      tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Task.TaskRestrictionComponent convertTaskRestrictionComponent(org.hl7.fhir.dstu3.model.Task.TaskRestrictionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Task.TaskRestrictionComponent tgt = new org.hl7.fhir.r4.model.Task.TaskRestrictionComponent();
    copyElement(src, tgt);
    if (src.hasRepetitions())
      tgt.setRepetitions(src.getRepetitions());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Task.TaskRestrictionComponent convertTaskRestrictionComponent(org.hl7.fhir.r4.model.Task.TaskRestrictionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Task.TaskRestrictionComponent tgt = new org.hl7.fhir.dstu3.model.Task.TaskRestrictionComponent();
    copyElement(src, tgt);
    if (src.hasRepetitions())
      tgt.setRepetitions(src.getRepetitions());
    if (src.hasPeriod())
      tgt.setPeriod(convertPeriod(src.getPeriod()));
    for (org.hl7.fhir.r4.model.Reference t : src.getRecipient())
      tgt.addRecipient(convertReference(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Task.TaskStatus convertTaskStatus(org.hl7.fhir.dstu3.model.Task.TaskStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.r4.model.Task.TaskStatus.DRAFT;
    case REQUESTED: return org.hl7.fhir.r4.model.Task.TaskStatus.REQUESTED;
    case RECEIVED: return org.hl7.fhir.r4.model.Task.TaskStatus.RECEIVED;
    case ACCEPTED: return org.hl7.fhir.r4.model.Task.TaskStatus.ACCEPTED;
    case REJECTED: return org.hl7.fhir.r4.model.Task.TaskStatus.REJECTED;
    case READY: return org.hl7.fhir.r4.model.Task.TaskStatus.READY;
    case CANCELLED: return org.hl7.fhir.r4.model.Task.TaskStatus.CANCELLED;
    case INPROGRESS: return org.hl7.fhir.r4.model.Task.TaskStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.r4.model.Task.TaskStatus.ONHOLD;
    case FAILED: return org.hl7.fhir.r4.model.Task.TaskStatus.FAILED;
    case COMPLETED: return org.hl7.fhir.r4.model.Task.TaskStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.Task.TaskStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.Task.TaskStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Task.TaskStatus convertTaskStatus(org.hl7.fhir.r4.model.Task.TaskStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DRAFT: return org.hl7.fhir.dstu3.model.Task.TaskStatus.DRAFT;
    case REQUESTED: return org.hl7.fhir.dstu3.model.Task.TaskStatus.REQUESTED;
    case RECEIVED: return org.hl7.fhir.dstu3.model.Task.TaskStatus.RECEIVED;
    case ACCEPTED: return org.hl7.fhir.dstu3.model.Task.TaskStatus.ACCEPTED;
    case REJECTED: return org.hl7.fhir.dstu3.model.Task.TaskStatus.REJECTED;
    case READY: return org.hl7.fhir.dstu3.model.Task.TaskStatus.READY;
    case CANCELLED: return org.hl7.fhir.dstu3.model.Task.TaskStatus.CANCELLED;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.Task.TaskStatus.INPROGRESS;
    case ONHOLD: return org.hl7.fhir.dstu3.model.Task.TaskStatus.ONHOLD;
    case FAILED: return org.hl7.fhir.dstu3.model.Task.TaskStatus.FAILED;
    case COMPLETED: return org.hl7.fhir.dstu3.model.Task.TaskStatus.COMPLETED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.Task.TaskStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.Task.TaskStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.TeardownActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestReport.TeardownActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TeardownActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestScript.TeardownActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Contract.AgentComponent convertTermAgentComponent(org.hl7.fhir.dstu3.model.Contract.TermAgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.AgentComponent tgt = new org.hl7.fhir.r4.model.Contract.AgentComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.TermAgentComponent convertTermAgentComponent(org.hl7.fhir.r4.model.Contract.AgentComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.TermAgentComponent tgt = new org.hl7.fhir.dstu3.model.Contract.TermAgentComponent();
    copyElement(src, tgt);
    if (src.hasActor())
      tgt.setActor(convertReference(src.getActor()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole())
      tgt.addRole(convertCodeableConcept(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Contract.TermComponent convertTermComponent(org.hl7.fhir.dstu3.model.Contract.TermComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.TermComponent tgt = new org.hl7.fhir.r4.model.Contract.TermComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    if (src.hasApplies())
      tgt.setApplies(convertPeriod(src.getApplies()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSubType())
      tgt.setSubType(convertCodeableConcept(src.getSubType()));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAction())
      tgt.addAction(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getActionReason())
      tgt.addActionReason(convertCodeableConcept(t));
    for (org.hl7.fhir.dstu3.model.Contract.TermAgentComponent t : src.getAgent())
      tgt.addAgent(convertTermAgentComponent(t));
    for (org.hl7.fhir.dstu3.model.Contract.TermComponent t : src.getGroup())
      tgt.addGroup(convertTermComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.TermComponent convertTermComponent(org.hl7.fhir.r4.model.Contract.TermComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.TermComponent tgt = new org.hl7.fhir.dstu3.model.Contract.TermComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    if (src.hasApplies())
      tgt.setApplies(convertPeriod(src.getApplies()));
    if (src.hasType())
      tgt.setType(convertCodeableConcept(src.getType()));
    if (src.hasSubType())
      tgt.setSubType(convertCodeableConcept(src.getSubType()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAction())
      tgt.addAction(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getActionReason())
      tgt.addActionReason(convertCodeableConcept(t));
    for (org.hl7.fhir.r4.model.Contract.AgentComponent t : src.getAgent())
      tgt.addAgent(convertTermAgentComponent(t));
    for (org.hl7.fhir.r4.model.Contract.TermComponent t : src.getGroup())
      tgt.addGroup(convertTermComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Contract.ValuedItemComponent convertTermValuedItemComponent(org.hl7.fhir.dstu3.model.Contract.TermValuedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.r4.model.Contract.ValuedItemComponent();
    copyElement(src, tgt);
    if (src.hasEntity())
      tgt.setEntity(convertType(src.getEntity()));
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasEffectiveTime())
      tgt.setEffectiveTime(src.getEffectiveTime());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasPoints())
      tgt.setPoints(src.getPoints());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.TermValuedItemComponent convertTermValuedItemComponent(org.hl7.fhir.r4.model.Contract.ValuedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.TermValuedItemComponent tgt = new org.hl7.fhir.dstu3.model.Contract.TermValuedItemComponent();
    copyElement(src, tgt);
    if (src.hasEntity())
      tgt.setEntity(convertType(src.getEntity()));
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasEffectiveTime())
      tgt.setEffectiveTime(src.getEffectiveTime());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasPoints())
      tgt.setPoints(src.getPoints());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestReport.TestActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.TestActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestReport.TestActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestScript.TestActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestScript.TestActionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestActionComponent();
    copyElement(src, tgt);
    if (src.hasOperation())
      tgt.setOperation(convertSetupActionOperationComponent(src.getOperation()));
    if (src.hasAssert())
      tgt.setAssert(convertSetupActionAssertComponent(src.getAssert()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestReport convertTestReport(org.hl7.fhir.dstu3.model.TestReport src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport tgt = new org.hl7.fhir.r4.model.TestReport();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertTestReportStatus(src.getStatus()));
    if (src.hasTestScript())
      tgt.setTestScript(convertReference(src.getTestScript()));
    if (src.hasResult())
      tgt.setResult(convertTestReportResult(src.getResult()));
    if (src.hasScore())
      tgt.setScore(src.getScore());
    if (src.hasTester())
      tgt.setTester(src.getTester());
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    for (org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertTestReportParticipantComponent(t));
    if (src.hasSetup())
      tgt.setSetup(convertTestReportSetupComponent(src.getSetup()));
    for (org.hl7.fhir.dstu3.model.TestReport.TestReportTestComponent t : src.getTest())
      tgt.addTest(convertTestReportTestComponent(t));
    if (src.hasTeardown())
      tgt.setTeardown(convertTestReportTeardownComponent(src.getTeardown()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport convertTestReport(org.hl7.fhir.r4.model.TestReport src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport tgt = new org.hl7.fhir.dstu3.model.TestReport();
    copyDomainResource(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasStatus())
      tgt.setStatus(convertTestReportStatus(src.getStatus()));
    if (src.hasTestScript())
      tgt.setTestScript(convertReference(src.getTestScript()));
    if (src.hasResult())
      tgt.setResult(convertTestReportResult(src.getResult()));
    if (src.hasScore())
      tgt.setScore(src.getScore());
    if (src.hasTester())
      tgt.setTester(src.getTester());
    if (src.hasIssued())
      tgt.setIssued(src.getIssued());
    for (org.hl7.fhir.r4.model.TestReport.TestReportParticipantComponent t : src.getParticipant())
      tgt.addParticipant(convertTestReportParticipantComponent(t));
    if (src.hasSetup())
      tgt.setSetup(convertTestReportSetupComponent(src.getSetup()));
    for (org.hl7.fhir.r4.model.TestReport.TestReportTestComponent t : src.getTest())
      tgt.addTest(convertTestReportTestComponent(t));
    if (src.hasTeardown())
      tgt.setTeardown(convertTestReportTeardownComponent(src.getTeardown()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.TestReport.TestReportActionResult convertTestReportActionResult(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PASS: return org.hl7.fhir.r4.model.TestReport.TestReportActionResult.PASS;
    case SKIP: return org.hl7.fhir.r4.model.TestReport.TestReportActionResult.SKIP;
    case FAIL: return org.hl7.fhir.r4.model.TestReport.TestReportActionResult.FAIL;
    case WARNING: return org.hl7.fhir.r4.model.TestReport.TestReportActionResult.WARNING;
    case ERROR: return org.hl7.fhir.r4.model.TestReport.TestReportActionResult.ERROR;
    default: return org.hl7.fhir.r4.model.TestReport.TestReportActionResult.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult convertTestReportActionResult(org.hl7.fhir.r4.model.TestReport.TestReportActionResult src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PASS: return org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.PASS;
    case SKIP: return org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.SKIP;
    case FAIL: return org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.FAIL;
    case WARNING: return org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.WARNING;
    case ERROR: return org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.ERROR;
    default: return org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.NULL;
  }
}

  public static org.hl7.fhir.r4.model.TestReport.TestReportParticipantComponent convertTestReportParticipantComponent(org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.TestReportParticipantComponent tgt = new org.hl7.fhir.r4.model.TestReport.TestReportParticipantComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertTestReportParticipantType(src.getType()));
    if (src.hasUri())
      tgt.setUri(src.getUri());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantComponent convertTestReportParticipantComponent(org.hl7.fhir.r4.model.TestReport.TestReportParticipantComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantComponent();
    copyElement(src, tgt);
    if (src.hasType())
      tgt.setType(convertTestReportParticipantType(src.getType()));
    if (src.hasUri())
      tgt.setUri(src.getUri());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    return tgt;
  }

  private static org.hl7.fhir.r4.model.TestReport.TestReportParticipantType convertTestReportParticipantType(org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case TESTENGINE: return org.hl7.fhir.r4.model.TestReport.TestReportParticipantType.TESTENGINE;
    case CLIENT: return org.hl7.fhir.r4.model.TestReport.TestReportParticipantType.CLIENT;
    case SERVER: return org.hl7.fhir.r4.model.TestReport.TestReportParticipantType.SERVER;
    default: return org.hl7.fhir.r4.model.TestReport.TestReportParticipantType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantType convertTestReportParticipantType(org.hl7.fhir.r4.model.TestReport.TestReportParticipantType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case TESTENGINE: return org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantType.TESTENGINE;
    case CLIENT: return org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantType.CLIENT;
    case SERVER: return org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantType.SERVER;
    default: return org.hl7.fhir.dstu3.model.TestReport.TestReportParticipantType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.TestReport.TestReportResult convertTestReportResult(org.hl7.fhir.dstu3.model.TestReport.TestReportResult src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PASS: return org.hl7.fhir.r4.model.TestReport.TestReportResult.PASS;
    case FAIL: return org.hl7.fhir.r4.model.TestReport.TestReportResult.FAIL;
    case PENDING: return org.hl7.fhir.r4.model.TestReport.TestReportResult.PENDING;
    default: return org.hl7.fhir.r4.model.TestReport.TestReportResult.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestReport.TestReportResult convertTestReportResult(org.hl7.fhir.r4.model.TestReport.TestReportResult src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case PASS: return org.hl7.fhir.dstu3.model.TestReport.TestReportResult.PASS;
    case FAIL: return org.hl7.fhir.dstu3.model.TestReport.TestReportResult.FAIL;
    case PENDING: return org.hl7.fhir.dstu3.model.TestReport.TestReportResult.PENDING;
    default: return org.hl7.fhir.dstu3.model.TestReport.TestReportResult.NULL;
  }
}

  public static org.hl7.fhir.r4.model.TestReport.TestReportSetupComponent convertTestReportSetupComponent(org.hl7.fhir.dstu3.model.TestReport.TestReportSetupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.TestReportSetupComponent tgt = new org.hl7.fhir.r4.model.TestReport.TestReportSetupComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent t : src.getAction())
      tgt.addAction(convertSetupActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.TestReportSetupComponent convertTestReportSetupComponent(org.hl7.fhir.r4.model.TestReport.TestReportSetupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.TestReportSetupComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestReportSetupComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.TestReport.SetupActionComponent t : src.getAction())
      tgt.addAction(convertSetupActionComponent(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.TestReport.TestReportStatus convertTestReportStatus(org.hl7.fhir.dstu3.model.TestReport.TestReportStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETED: return org.hl7.fhir.r4.model.TestReport.TestReportStatus.COMPLETED;
    case INPROGRESS: return org.hl7.fhir.r4.model.TestReport.TestReportStatus.INPROGRESS;
    case WAITING: return org.hl7.fhir.r4.model.TestReport.TestReportStatus.WAITING;
    case STOPPED: return org.hl7.fhir.r4.model.TestReport.TestReportStatus.STOPPED;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.TestReport.TestReportStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.TestReport.TestReportStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestReport.TestReportStatus convertTestReportStatus(org.hl7.fhir.r4.model.TestReport.TestReportStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETED: return org.hl7.fhir.dstu3.model.TestReport.TestReportStatus.COMPLETED;
    case INPROGRESS: return org.hl7.fhir.dstu3.model.TestReport.TestReportStatus.INPROGRESS;
    case WAITING: return org.hl7.fhir.dstu3.model.TestReport.TestReportStatus.WAITING;
    case STOPPED: return org.hl7.fhir.dstu3.model.TestReport.TestReportStatus.STOPPED;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.TestReport.TestReportStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.TestReport.TestReportStatus.NULL;
  }
}

  public static org.hl7.fhir.r4.model.TestReport.TestReportTeardownComponent convertTestReportTeardownComponent(org.hl7.fhir.dstu3.model.TestReport.TestReportTeardownComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.TestReportTeardownComponent tgt = new org.hl7.fhir.r4.model.TestReport.TestReportTeardownComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent t : src.getAction())
      tgt.addAction(convertTeardownActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.TestReportTeardownComponent convertTestReportTeardownComponent(org.hl7.fhir.r4.model.TestReport.TestReportTeardownComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.TestReportTeardownComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestReportTeardownComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.TestReport.TeardownActionComponent t : src.getAction())
      tgt.addAction(convertTeardownActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestReport.TestReportTestComponent convertTestReportTestComponent(org.hl7.fhir.dstu3.model.TestReport.TestReportTestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestReport.TestReportTestComponent tgt = new org.hl7.fhir.r4.model.TestReport.TestReportTestComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.TestReport.TestActionComponent t : src.getAction())
      tgt.addAction(convertTestActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestReport.TestReportTestComponent convertTestReportTestComponent(org.hl7.fhir.r4.model.TestReport.TestReportTestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestReport.TestReportTestComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestReportTestComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.TestReport.TestActionComponent t : src.getAction())
      tgt.addAction(convertTestActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript convertTestScript(org.hl7.fhir.dstu3.model.TestScript src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript tgt = new org.hl7.fhir.r4.model.TestScript();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptOriginComponent t : src.getOrigin())
      tgt.addOrigin(convertTestScriptOriginComponent(t));
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptDestinationComponent t : src.getDestination())
      tgt.addDestination(convertTestScriptDestinationComponent(t));
    if (src.hasMetadata())
      tgt.setMetadata(convertTestScriptMetadataComponent(src.getMetadata()));
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptFixtureComponent t : src.getFixture())
      tgt.addFixture(convertTestScriptFixtureComponent(t));
    for (org.hl7.fhir.dstu3.model.Reference t : src.getProfile())
      tgt.addProfile(convertReference(t));
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptVariableComponent t : src.getVariable())
      tgt.addVariable(convertTestScriptVariableComponent(t));
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptRuleComponent t : src.getRule())
      tgt.addRule(convertTestScriptRuleComponent(t));
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptRulesetComponent t : src.getRuleset())
      tgt.addRuleset(convertTestScriptRulesetComponent(t));
    if (src.hasSetup())
      tgt.setSetup(convertTestScriptSetupComponent(src.getSetup()));
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptTestComponent t : src.getTest())
      tgt.addTest(convertTestScriptTestComponent(t));
    if (src.hasTeardown())
      tgt.setTeardown(convertTestScriptTeardownComponent(src.getTeardown()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript convertTestScript(org.hl7.fhir.r4.model.TestScript src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript tgt = new org.hl7.fhir.dstu3.model.TestScript();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.r4.model.TestScript.TestScriptOriginComponent t : src.getOrigin())
      tgt.addOrigin(convertTestScriptOriginComponent(t));
    for (org.hl7.fhir.r4.model.TestScript.TestScriptDestinationComponent t : src.getDestination())
      tgt.addDestination(convertTestScriptDestinationComponent(t));
    if (src.hasMetadata())
      tgt.setMetadata(convertTestScriptMetadataComponent(src.getMetadata()));
    for (org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent t : src.getFixture())
      tgt.addFixture(convertTestScriptFixtureComponent(t));
    for (org.hl7.fhir.r4.model.Reference t : src.getProfile())
      tgt.addProfile(convertReference(t));
    for (org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent t : src.getVariable())
      tgt.addVariable(convertTestScriptVariableComponent(t));
    for (org.hl7.fhir.r4.model.TestScript.TestScriptRuleComponent t : src.getRule())
      tgt.addRule(convertTestScriptRuleComponent(t));
    for (org.hl7.fhir.r4.model.TestScript.TestScriptRulesetComponent t : src.getRuleset())
      tgt.addRuleset(convertTestScriptRulesetComponent(t));
    if (src.hasSetup())
      tgt.setSetup(convertTestScriptSetupComponent(src.getSetup()));
    for (org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent t : src.getTest())
      tgt.addTest(convertTestScriptTestComponent(t));
    if (src.hasTeardown())
      tgt.setTeardown(convertTestScriptTeardownComponent(src.getTeardown()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptDestinationComponent convertTestScriptDestinationComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptDestinationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptDestinationComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptDestinationComponent();
    copyElement(src, tgt);
    if (src.hasIndex())
      tgt.setIndex(src.getIndex());
    if (src.hasProfile())
      tgt.setProfile(convertCoding(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptDestinationComponent convertTestScriptDestinationComponent(org.hl7.fhir.r4.model.TestScript.TestScriptDestinationComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptDestinationComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptDestinationComponent();
    copyElement(src, tgt);
    if (src.hasIndex())
      tgt.setIndex(src.getIndex());
    if (src.hasProfile())
      tgt.setProfile(convertCoding(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent convertTestScriptFixtureComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptFixtureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent();
    copyElement(src, tgt);
    if (src.hasAutocreate())
      tgt.setAutocreate(src.getAutocreate());
    if (src.hasAutodelete())
      tgt.setAutodelete(src.getAutodelete());
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptFixtureComponent convertTestScriptFixtureComponent(org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptFixtureComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptFixtureComponent();
    copyElement(src, tgt);
    if (src.hasAutocreate())
      tgt.setAutocreate(src.getAutocreate());
    if (src.hasAutodelete())
      tgt.setAutodelete(src.getAutodelete());
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent convertTestScriptMetadataCapabilityComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataCapabilityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent();
    copyElement(src, tgt);
    if (src.hasRequired())
      tgt.setRequired(src.getRequired());
    if (src.hasValidated())
      tgt.setValidated(src.getValidated());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.IntegerType t : src.getOrigin())
      tgt.addOrigin(t.getValue());
    if (src.hasDestination())
      tgt.setDestination(src.getDestination());
    for (org.hl7.fhir.dstu3.model.UriType t : src.getLink())
      tgt.addLink(t.getValue());
    if (src.hasCapabilities())
      tgt.setCapabilities(convertReference(src.getCapabilities()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataCapabilityComponent convertTestScriptMetadataCapabilityComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataCapabilityComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataCapabilityComponent();
    copyElement(src, tgt);
    if (src.hasRequired())
      tgt.setRequired(src.getRequired());
    if (src.hasValidated())
      tgt.setValidated(src.getValidated());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.IntegerType t : src.getOrigin())
      tgt.addOrigin(t.getValue());
    if (src.hasDestination())
      tgt.setDestination(src.getDestination());
    for (org.hl7.fhir.r4.model.UriType t : src.getLink())
      tgt.addLink(t.getValue());
    if (src.hasCapabilities())
      tgt.setCapabilities(convertReference(src.getCapabilities()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent convertTestScriptMetadataComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataLinkComponent t : src.getLink())
      tgt.addLink(convertTestScriptMetadataLinkComponent(t));
    for (org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataCapabilityComponent t : src.getCapability())
      tgt.addCapability(convertTestScriptMetadataCapabilityComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataComponent convertTestScriptMetadataComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent t : src.getLink())
      tgt.addLink(convertTestScriptMetadataLinkComponent(t));
    for (org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent t : src.getCapability())
      tgt.addCapability(convertTestScriptMetadataCapabilityComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent convertTestScriptMetadataLinkComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent();
    copyElement(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataLinkComponent convertTestScriptMetadataLinkComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataLinkComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptMetadataLinkComponent();
    copyElement(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptOriginComponent convertTestScriptOriginComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptOriginComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptOriginComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptOriginComponent();
    copyElement(src, tgt);
    if (src.hasIndex())
      tgt.setIndex(src.getIndex());
    if (src.hasProfile())
      tgt.setProfile(convertCoding(src.getProfile()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptOriginComponent convertTestScriptOriginComponent(org.hl7.fhir.r4.model.TestScript.TestScriptOriginComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptOriginComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptOriginComponent();
    copyElement(src, tgt);
    if (src.hasIndex())
      tgt.setIndex(src.getIndex());
    if (src.hasProfile())
      tgt.setProfile(convertCoding(src.getProfile()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode convertTestScriptRequestMethodCode(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DELETE: return org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.DELETE;
    case GET: return org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.GET;
    case OPTIONS: return org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.OPTIONS;
    case PATCH: return org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.PATCH;
    case POST: return org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.POST;
    case PUT: return org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.PUT;
    default: return org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode convertTestScriptRequestMethodCode(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case DELETE: return org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.DELETE;
    case GET: return org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.GET;
    case OPTIONS: return org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.OPTIONS;
    case PATCH: return org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PATCH;
    case POST: return org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.POST;
    case PUT: return org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PUT;
    default: return org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.TestScript.TestScriptRuleComponent convertTestScriptRuleComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptRuleComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptRuleComponent();
    copyElement(src, tgt);
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    for (org.hl7.fhir.dstu3.model.TestScript.RuleParamComponent t : src.getParam())
      tgt.addParam(convertRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptRuleComponent convertTestScriptRuleComponent(org.hl7.fhir.r4.model.TestScript.TestScriptRuleComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptRuleComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptRuleComponent();
    copyElement(src, tgt);
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    for (org.hl7.fhir.r4.model.TestScript.RuleParamComponent t : src.getParam())
      tgt.addParam(convertRuleParamComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptRulesetComponent convertTestScriptRulesetComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptRulesetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptRulesetComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptRulesetComponent();
    copyElement(src, tgt);
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    for (org.hl7.fhir.dstu3.model.TestScript.RulesetRuleComponent t : src.getRule())
      tgt.addRule(convertRulesetRuleComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptRulesetComponent convertTestScriptRulesetComponent(org.hl7.fhir.r4.model.TestScript.TestScriptRulesetComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptRulesetComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptRulesetComponent();
    copyElement(src, tgt);
    if (src.hasResource())
      tgt.setResource(convertReference(src.getResource()));
    for (org.hl7.fhir.r4.model.TestScript.RulesetRuleComponent t : src.getRule())
      tgt.addRule(convertRulesetRuleComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent convertTestScriptSetupComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptSetupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent t : src.getAction())
      tgt.addAction(convertSetupActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptSetupComponent convertTestScriptSetupComponent(org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptSetupComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptSetupComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.TestScript.SetupActionComponent t : src.getAction())
      tgt.addAction(convertSetupActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent convertTestScriptTeardownComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptTeardownComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent t : src.getAction())
      tgt.addAction(convertTeardownActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptTeardownComponent convertTestScriptTeardownComponent(org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptTeardownComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptTeardownComponent();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.TestScript.TeardownActionComponent t : src.getAction())
      tgt.addAction(convertTeardownActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent convertTestScriptTestComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptTestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.TestScript.TestActionComponent t : src.getAction())
      tgt.addAction(convertTestActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptTestComponent convertTestScriptTestComponent(org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptTestComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptTestComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.TestScript.TestActionComponent t : src.getAction())
      tgt.addAction(convertTestActionComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent convertTestScriptVariableComponent(org.hl7.fhir.dstu3.model.TestScript.TestScriptVariableComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDefaultValue())
      tgt.setDefaultValue(src.getDefaultValue());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasHeaderField())
      tgt.setHeaderField(src.getHeaderField());
    if (src.hasHint())
      tgt.setHint(src.getHint());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasSourceId())
      tgt.setSourceId(src.getSourceId());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TestScript.TestScriptVariableComponent convertTestScriptVariableComponent(org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.TestScript.TestScriptVariableComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestScriptVariableComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasDefaultValue())
      tgt.setDefaultValue(src.getDefaultValue());
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    if (src.hasExpression())
      tgt.setExpression(src.getExpression());
    if (src.hasHeaderField())
      tgt.setHeaderField(src.getHeaderField());
    if (src.hasHint())
      tgt.setHint(src.getHint());
    if (src.hasPath())
      tgt.setPath(src.getPath());
    if (src.hasSourceId())
      tgt.setSourceId(src.getSourceId());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException {
    org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.TimeType tgt = new org.hl7.fhir.dstu3.model.TimeType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing();
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent())
      tgt.addEvent(t.getValue());
    if (src.hasRepeat())
      tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing();
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent())
      tgt.addEvent(t.getValue());
    if (src.hasRepeat())
      tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat()));
    if (src.hasCode())
      tgt.setCode(convertCodeableConcept(src.getCode()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent();
    copyElement(src, tgt);
    if (src.hasBounds())
      tgt.setBounds(convertType(src.getBounds()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    if (src.hasCountMax())
      tgt.setCountMax(src.getCountMax());
    if (src.hasDuration())
      tgt.setDuration(src.getDuration());
    if (src.hasDurationMax())
      tgt.setDurationMax(src.getDurationMax());
    if (src.hasDurationUnit())
      tgt.setDurationUnit(convertUnitsOfTime(src.getDurationUnit()));
    if (src.hasFrequency())
      tgt.setFrequency(src.getFrequency());
    if (src.hasFrequencyMax())
      tgt.setFrequencyMax(src.getFrequencyMax());
    if (src.hasPeriod())
      tgt.setPeriod(src.getPeriod());
    if (src.hasPeriodMax())
      tgt.setPeriodMax(src.getPeriodMax());
    if (src.hasPeriodUnit())
      tgt.setPeriodUnit(convertUnitsOfTime(src.getPeriodUnit()));
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.DayOfWeek> t : src.getDayOfWeek())
      tgt.addDayOfWeek(convertDayOfWeek(t.getValue()));
    for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay())
      tgt.addTimeOfDay(t.getValue());
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.EventTiming> t : src.getWhen())
      tgt.addWhen(convertEventTiming(t.getValue()));
    if (src.hasOffset())
      tgt.setOffset(src.getOffset());
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent();
    copyElement(src, tgt);
    if (src.hasBounds())
      tgt.setBounds(convertType(src.getBounds()));
    if (src.hasCount())
      tgt.setCount(src.getCount());
    if (src.hasCountMax())
      tgt.setCountMax(src.getCountMax());
    if (src.hasDuration())
      tgt.setDuration(src.getDuration());
    if (src.hasDurationMax())
      tgt.setDurationMax(src.getDurationMax());
    if (src.hasDurationUnit())
      tgt.setDurationUnit(convertUnitsOfTime(src.getDurationUnit()));
    if (src.hasFrequency())
      tgt.setFrequency(src.getFrequency());
    if (src.hasFrequencyMax())
      tgt.setFrequencyMax(src.getFrequencyMax());
    if (src.hasPeriod())
      tgt.setPeriod(src.getPeriod());
    if (src.hasPeriodMax())
      tgt.setPeriodMax(src.getPeriodMax());
    if (src.hasPeriodUnit())
      tgt.setPeriodUnit(convertUnitsOfTime(src.getPeriodUnit()));
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Timing.DayOfWeek> t : src.getDayOfWeek())
      tgt.addDayOfWeek(convertDayOfWeek(t.getValue()));
    for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay())
      tgt.addTimeOfDay(t.getValue());
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Timing.EventTiming> t : src.getWhen())
      tgt.addWhen(convertEventTiming(t.getValue()));
    if (src.hasOffset())
      tgt.setOffset(src.getOffset());
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException {
    if (src == null)
      return null;
    if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType)
      return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.BooleanType)
      return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CodeType)
      return convertCode((org.hl7.fhir.dstu3.model.CodeType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DateType)
      return convertDate((org.hl7.fhir.dstu3.model.DateType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType)
      return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.DecimalType)
      return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.IdType)
      return convertId((org.hl7.fhir.dstu3.model.IdType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.InstantType)
      return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.IntegerType)
      return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType)
      return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.OidType)
      return convertOid((org.hl7.fhir.dstu3.model.OidType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType)
      return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.StringType)
      return convertString((org.hl7.fhir.dstu3.model.StringType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.TimeType)
      return convertTime((org.hl7.fhir.dstu3.model.TimeType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType)
      return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.UriType)
      return convertUri((org.hl7.fhir.dstu3.model.UriType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.UuidType)
      return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Extension)
      return convertExtension((org.hl7.fhir.dstu3.model.Extension) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Narrative)
      return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Age)
      return convertAge((org.hl7.fhir.dstu3.model.Age) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Annotation)
      return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Attachment)
      return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src);
    if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept)
      return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Coding)
      return convertCoding((org.hl7.fhir.dstu3.model.Coding) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Count)
      return convertCount((org.hl7.fhir.dstu3.model.Count) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Distance)
      return convertDistance((org.hl7.fhir.dstu3.model.Distance) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Duration)
      return convertDuration((org.hl7.fhir.dstu3.model.Duration) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Identifier)
      return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Money)
      return convertMoney((org.hl7.fhir.dstu3.model.Money) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Period)
      return convertPeriod((org.hl7.fhir.dstu3.model.Period) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Quantity)
      return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Range)
      return convertRange((org.hl7.fhir.dstu3.model.Range) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Ratio)
      return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Reference)
      return convertReference((org.hl7.fhir.dstu3.model.Reference) src);
    if (src instanceof org.hl7.fhir.dstu3.model.SampledData)
      return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Signature)
      return convertSignature((org.hl7.fhir.dstu3.model.Signature) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Address)
      return convertAddress((org.hl7.fhir.dstu3.model.Address) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ContactDetail)
      return convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint)
      return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Contributor)
      return convertContributor((org.hl7.fhir.dstu3.model.Contributor) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Dosage)
      return convertDosage((org.hl7.fhir.dstu3.model.Dosage) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition)
      return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.HumanName)
      return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Meta)
      return convertMeta((org.hl7.fhir.dstu3.model.Meta) src);
    if (src instanceof org.hl7.fhir.dstu3.model.ParameterDefinition)
      return convertParameterDefinition((org.hl7.fhir.dstu3.model.ParameterDefinition) src);
    if (src instanceof org.hl7.fhir.dstu3.model.RelatedArtifact)
      return convertRelatedArtifact((org.hl7.fhir.dstu3.model.RelatedArtifact) src);
    if (src instanceof org.hl7.fhir.dstu3.model.Timing)
      return convertTiming((org.hl7.fhir.dstu3.model.Timing) src);
    if (src instanceof org.hl7.fhir.dstu3.model.UsageContext)
      return convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) src);
    if (src instanceof org.hl7.fhir.dstu3.model.SimpleQuantity)
      return convertSimpleQuantity((org.hl7.fhir.dstu3.model.SimpleQuantity) src);
    throw new Error("Unknown type "+src.fhirType());
  }

  public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException {
    if (src == null)
      return null;
    if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType)
      return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src);
    if (src instanceof org.hl7.fhir.r4.model.BooleanType)
      return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src);
    if (src instanceof org.hl7.fhir.r4.model.CodeType)
      return convertCode((org.hl7.fhir.r4.model.CodeType) src);
    if (src instanceof org.hl7.fhir.r4.model.DateType)
      return convertDate((org.hl7.fhir.r4.model.DateType) src);
    if (src instanceof org.hl7.fhir.r4.model.DateTimeType)
      return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src);
    if (src instanceof org.hl7.fhir.r4.model.DecimalType)
      return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src);
    if (src instanceof org.hl7.fhir.r4.model.IdType)
      return convertId((org.hl7.fhir.r4.model.IdType) src);
    if (src instanceof org.hl7.fhir.r4.model.InstantType)
      return convertInstant((org.hl7.fhir.r4.model.InstantType) src);
    if (src instanceof org.hl7.fhir.r4.model.IntegerType)
      return convertInteger((org.hl7.fhir.r4.model.IntegerType) src);
    if (src instanceof org.hl7.fhir.r4.model.MarkdownType)
      return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src);
    if (src instanceof org.hl7.fhir.r4.model.OidType)
      return convertOid((org.hl7.fhir.r4.model.OidType) src);
    if (src instanceof org.hl7.fhir.r4.model.PositiveIntType)
      return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src);
    if (src instanceof org.hl7.fhir.r4.model.StringType)
      return convertString((org.hl7.fhir.r4.model.StringType) src);
    if (src instanceof org.hl7.fhir.r4.model.TimeType)
      return convertTime((org.hl7.fhir.r4.model.TimeType) src);
    if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType)
      return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src);
    if (src instanceof org.hl7.fhir.r4.model.UriType)
      return convertUri((org.hl7.fhir.r4.model.UriType) src);
    if (src instanceof org.hl7.fhir.r4.model.UuidType)
      return convertUuid((org.hl7.fhir.r4.model.UuidType) src);
    if (src instanceof org.hl7.fhir.r4.model.Extension)
      return convertExtension((org.hl7.fhir.r4.model.Extension) src);
    if (src instanceof org.hl7.fhir.r4.model.Narrative)
      return convertNarrative((org.hl7.fhir.r4.model.Narrative) src);
    if (src instanceof org.hl7.fhir.r4.model.Age)
      return convertAge((org.hl7.fhir.r4.model.Age) src);
    if (src instanceof org.hl7.fhir.r4.model.Annotation)
      return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src);
    if (src instanceof org.hl7.fhir.r4.model.Attachment)
      return convertAttachment((org.hl7.fhir.r4.model.Attachment) src);
    if (src instanceof org.hl7.fhir.r4.model.CodeableConcept)
      return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src);
    if (src instanceof org.hl7.fhir.r4.model.Coding)
      return convertCoding((org.hl7.fhir.r4.model.Coding) src);
    if (src instanceof org.hl7.fhir.r4.model.Count)
      return convertCount((org.hl7.fhir.r4.model.Count) src);
    if (src instanceof org.hl7.fhir.r4.model.Distance)
      return convertDistance((org.hl7.fhir.r4.model.Distance) src);
    if (src instanceof org.hl7.fhir.r4.model.Duration)
      return convertDuration((org.hl7.fhir.r4.model.Duration) src);
    if (src instanceof org.hl7.fhir.r4.model.Identifier)
      return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src);
    if (src instanceof org.hl7.fhir.r4.model.Money)
      return convertMoney((org.hl7.fhir.r4.model.Money) src);
    if (src instanceof org.hl7.fhir.r4.model.Period)
      return convertPeriod((org.hl7.fhir.r4.model.Period) src);
    if (src instanceof org.hl7.fhir.r4.model.Quantity)
      return convertQuantity((org.hl7.fhir.r4.model.Quantity) src);
    if (src instanceof org.hl7.fhir.r4.model.Range)
      return convertRange((org.hl7.fhir.r4.model.Range) src);
    if (src instanceof org.hl7.fhir.r4.model.Ratio)
      return convertRatio((org.hl7.fhir.r4.model.Ratio) src);
    if (src instanceof org.hl7.fhir.r4.model.Reference)
      return convertReference((org.hl7.fhir.r4.model.Reference) src);
    if (src instanceof org.hl7.fhir.r4.model.SampledData)
      return convertSampledData((org.hl7.fhir.r4.model.SampledData) src);
    if (src instanceof org.hl7.fhir.r4.model.Signature)
      return convertSignature((org.hl7.fhir.r4.model.Signature) src);
    if (src instanceof org.hl7.fhir.r4.model.Address)
      return convertAddress((org.hl7.fhir.r4.model.Address) src);
    if (src instanceof org.hl7.fhir.r4.model.ContactDetail)
      return convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) src);
    if (src instanceof org.hl7.fhir.r4.model.ContactPoint)
      return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src);
    if (src instanceof org.hl7.fhir.r4.model.Contributor)
      return convertContributor((org.hl7.fhir.r4.model.Contributor) src);
    if (src instanceof org.hl7.fhir.r4.model.Dosage)
      return convertDosage((org.hl7.fhir.r4.model.Dosage) src);
    if (src instanceof org.hl7.fhir.r4.model.ElementDefinition)
      return convertElementDefinition((org.hl7.fhir.r4.model.ElementDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.HumanName)
      return convertHumanName((org.hl7.fhir.r4.model.HumanName) src);
    if (src instanceof org.hl7.fhir.r4.model.Meta)
      return convertMeta((org.hl7.fhir.r4.model.Meta) src);
    if (src instanceof org.hl7.fhir.r4.model.ParameterDefinition)
      return convertParameterDefinition((org.hl7.fhir.r4.model.ParameterDefinition) src);
    if (src instanceof org.hl7.fhir.r4.model.RelatedArtifact)
      return convertRelatedArtifact((org.hl7.fhir.r4.model.RelatedArtifact) src);
    if (src instanceof org.hl7.fhir.r4.model.Timing)
      return convertTiming((org.hl7.fhir.r4.model.Timing) src);
    if (src instanceof org.hl7.fhir.r4.model.UsageContext)
      return convertUsageContext((org.hl7.fhir.r4.model.UsageContext) src);
    if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity)
      return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src);
    throw new Error("Unknown type "+src.fhirType());
  }

  private static org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule convertTypeDerivationRule(org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SPECIALIZATION: return org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION;
    case CONSTRAINT: return org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.CONSTRAINT;
    default: return org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule convertTypeDerivationRule(org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case SPECIALIZATION: return org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION;
    case CONSTRAINT: return org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.CONSTRAINT;
    default: return org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.NULL;
  }
}

  public static org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasProfile())
      tgt.setProfile(src.getProfile());
    if (src.hasTargetProfile())
      tgt.setTargetProfile(src.getTargetProfile());
    for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode> t : src.getAggregation())
      tgt.addAggregation(convertAggregationMode(t.getValue()));
    if (src.hasVersioning())
      tgt.setVersioning(convertReferenceVersionRules(src.getVersioning()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasProfile())
      tgt.setProfile(src.getProfile());
    if (src.hasTargetProfile())
      tgt.setTargetProfile(src.getTargetProfile());
    for (org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.AggregationMode> t : src.getAggregation())
      tgt.addAggregation(convertAggregationMode(t.getValue()));
    if (src.hasVersioning())
      tgt.setVersioning(convertReferenceVersionRules(src.getVersioning()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction convertTypeRestfulInteraction(org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case READ: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.READ;
    case VREAD: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.VREAD;
    case UPDATE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.UPDATE;
    case PATCH: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.PATCH;
    case DELETE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.DELETE;
    case HISTORYINSTANCE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYINSTANCE;
    case HISTORYTYPE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYTYPE;
    case CREATE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.CREATE;
    case SEARCHTYPE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.SEARCHTYPE;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction convertTypeRestfulInteraction(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case READ: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.READ;
    case VREAD: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.VREAD;
    case UPDATE: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.UPDATE;
    case PATCH: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.PATCH;
    case DELETE: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.DELETE;
    case HISTORYINSTANCE: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.HISTORYINSTANCE;
    case HISTORYTYPE: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.HISTORYTYPE;
    case CREATE: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.CREATE;
    case SEARCHTYPE: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.SEARCHTYPE;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.TypeRestfulInteraction.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Device.UDIEntryType convertUDIEntryType(org.hl7.fhir.dstu3.model.Device.UDIEntryType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case BARCODE: return org.hl7.fhir.r4.model.Device.UDIEntryType.BARCODE;
    case RFID: return org.hl7.fhir.r4.model.Device.UDIEntryType.RFID;
    case MANUAL: return org.hl7.fhir.r4.model.Device.UDIEntryType.MANUAL;
    case CARD: return org.hl7.fhir.r4.model.Device.UDIEntryType.CARD;
    case SELFREPORTED: return org.hl7.fhir.r4.model.Device.UDIEntryType.SELFREPORTED;
    case UNKNOWN: return org.hl7.fhir.r4.model.Device.UDIEntryType.UNKNOWN;
    default: return org.hl7.fhir.r4.model.Device.UDIEntryType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Device.UDIEntryType convertUDIEntryType(org.hl7.fhir.r4.model.Device.UDIEntryType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case BARCODE: return org.hl7.fhir.dstu3.model.Device.UDIEntryType.BARCODE;
    case RFID: return org.hl7.fhir.dstu3.model.Device.UDIEntryType.RFID;
    case MANUAL: return org.hl7.fhir.dstu3.model.Device.UDIEntryType.MANUAL;
    case CARD: return org.hl7.fhir.dstu3.model.Device.UDIEntryType.CARD;
    case SELFREPORTED: return org.hl7.fhir.dstu3.model.Device.UDIEntryType.SELFREPORTED;
    case UNKNOWN: return org.hl7.fhir.dstu3.model.Device.UDIEntryType.UNKNOWN;
    default: return org.hl7.fhir.dstu3.model.Device.UDIEntryType.NULL;
  }
}

  private static org.hl7.fhir.r4.model.Timing.UnitsOfTime convertUnitsOfTime(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case S: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.S;
    case MIN: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN;
    case H: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.H;
    case D: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.D;
    case WK: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK;
    case MO: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO;
    case A: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.A;
    default: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Timing.UnitsOfTime convertUnitsOfTime(org.hl7.fhir.r4.model.Timing.UnitsOfTime src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case S: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S;
    case MIN: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN;
    case H: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H;
    case D: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D;
    case WK: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK;
    case MO: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO;
    case A: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A;
    default: return org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL;
  }
}

  private static org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode convertUnknownContentCode(org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NO: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.NO;
    case EXTENSIONS: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.EXTENSIONS;
    case ELEMENTS: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.ELEMENTS;
    case BOTH: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.BOTH;
    default: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode convertUnknownContentCode(org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NO: return org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.NO;
    case EXTENSIONS: return org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.EXTENSIONS;
    case ELEMENTS: return org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.ELEMENTS;
    case BOTH: return org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.BOTH;
    default: return org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.NULL;
  }
}

  public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException {
    org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.UnsignedIntType tgt = new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException {
    org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.UsageContext convertUsageContext(org.hl7.fhir.dstu3.model.UsageContext src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.UsageContext tgt = new org.hl7.fhir.r4.model.UsageContext();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCoding(src.getCode()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.UsageContext convertUsageContext(org.hl7.fhir.r4.model.UsageContext src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.UsageContext tgt = new org.hl7.fhir.dstu3.model.UsageContext();
    copyElement(src, tgt);
    if (src.hasCode())
      tgt.setCode(convertCoding(src.getCode()));
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.Claim.Use convertUse(org.hl7.fhir.dstu3.model.Claim.Use src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETE: return org.hl7.fhir.r4.model.Claim.Use.COMPLETE;
    case PROPOSED: return org.hl7.fhir.r4.model.Claim.Use.PROPOSED;
    case EXPLORATORY: return org.hl7.fhir.r4.model.Claim.Use.EXPLORATORY;
    case OTHER: return org.hl7.fhir.r4.model.Claim.Use.OTHER;
    default: return org.hl7.fhir.r4.model.Claim.Use.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.Claim.Use convertUse(org.hl7.fhir.r4.model.Claim.Use src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case COMPLETE: return org.hl7.fhir.dstu3.model.Claim.Use.COMPLETE;
    case PROPOSED: return org.hl7.fhir.dstu3.model.Claim.Use.PROPOSED;
    case EXPLORATORY: return org.hl7.fhir.dstu3.model.Claim.Use.EXPLORATORY;
    case OTHER: return org.hl7.fhir.dstu3.model.Claim.Use.OTHER;
    default: return org.hl7.fhir.dstu3.model.Claim.Use.NULL;
  }
}

  public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException {
    org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException {
    org.hl7.fhir.dstu3.model.UuidType tgt = new org.hl7.fhir.dstu3.model.UuidType(src.getValue());
    copyElement(src, tgt);
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.dstu3.model.ValueSet src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasImmutable())
      tgt.setImmutable(src.getImmutable());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasExtensible())
      tgt.setExtensible(src.getExtensible());
    if (src.hasCompose())
      tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
    if (src.hasExpansion())
      tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet();
    copyDomainResource(src, tgt);
    if (src.hasUrl())
      tgt.setUrl(src.getUrl());
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasTitle())
      tgt.setTitle(src.getTitle());
    if (src.hasStatus())
      tgt.setStatus(convertPublicationStatus(src.getStatus()));
    if (src.hasExperimental())
      tgt.setExperimental(src.getExperimental());
    if (src.hasDate())
      tgt.setDate(src.getDate());
    if (src.hasPublisher())
      tgt.setPublisher(src.getPublisher());
    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
      tgt.addContact(convertContactDetail(t));
    if (src.hasDescription())
      tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
      tgt.addUseContext(convertUsageContext(t));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
      tgt.addJurisdiction(convertCodeableConcept(t));
    if (src.hasImmutable())
      tgt.setImmutable(src.getImmutable());
    if (src.hasPurpose())
      tgt.setPurpose(src.getPurpose());
    if (src.hasCopyright())
      tgt.setCopyright(src.getCopyright());
    if (src.hasExtensible())
      tgt.setExtensible(src.getExtensible());
    if (src.hasCompose())
      tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
    if (src.hasExpansion())
      tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent();
    copyElement(src, tgt);
    if (src.hasLockedDate())
      tgt.setLockedDate(src.getLockedDate());
    if (src.hasInactive())
      tgt.setInactive(src.getInactive());
    for (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent t : src.getInclude())
      tgt.addInclude(convertConceptSetComponent(t));
    for (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent t : src.getExclude())
      tgt.addExclude(convertConceptSetComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent();
    copyElement(src, tgt);
    if (src.hasLockedDate())
      tgt.setLockedDate(src.getLockedDate());
    if (src.hasInactive())
      tgt.setInactive(src.getInactive());
    for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getInclude())
      tgt.addInclude(convertConceptSetComponent(t));
    for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getExclude())
      tgt.addExclude(convertConceptSetComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(src.getIdentifier());
    if (src.hasTimestamp())
      tgt.setTimestamp(src.getTimestamp());
    if (src.hasTotal())
      tgt.setTotal(src.getTotal());
    if (src.hasOffset())
      tgt.setOffset(src.getOffset());
    for (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter())
      tgt.addParameter(convertValueSetExpansionParameterComponent(t));
    for (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
      tgt.addContains(convertValueSetExpansionContainsComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent();
    copyElement(src, tgt);
    if (src.hasIdentifier())
      tgt.setIdentifier(src.getIdentifier());
    if (src.hasTimestamp())
      tgt.setTimestamp(src.getTimestamp());
    if (src.hasTotal())
      tgt.setTotal(src.getTotal());
    if (src.hasOffset())
      tgt.setOffset(src.getOffset());
    for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter())
      tgt.addParameter(convertValueSetExpansionParameterComponent(t));
    for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
      tgt.addContains(convertValueSetExpansionContainsComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasAbstract())
      tgt.setAbstract(src.getAbstract());
    if (src.hasInactive())
      tgt.setInactive(src.getInactive());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    for (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
    for (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
      tgt.addContains(convertValueSetExpansionContainsComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent();
    copyElement(src, tgt);
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasAbstract())
      tgt.setAbstract(src.getAbstract());
    if (src.hasInactive())
      tgt.setInactive(src.getInactive());
    if (src.hasVersion())
      tgt.setVersion(src.getVersion());
    if (src.hasCode())
      tgt.setCode(src.getCode());
    if (src.hasDisplay())
      tgt.setDisplay(src.getDisplay());
    for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
    for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
      tgt.addContains(convertValueSetExpansionContainsComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent();
    copyElement(src, tgt);
    if (src.hasName())
      tgt.setName(src.getName());
    if (src.hasValue())
      tgt.setValue(convertType(src.getValue()));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.Contract.ValuedItemComponent convertValuedItemComponent(org.hl7.fhir.dstu3.model.Contract.ValuedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.r4.model.Contract.ValuedItemComponent();
    copyElement(src, tgt);
    if (src.hasEntity())
      tgt.setEntity(convertType(src.getEntity()));
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasEffectiveTime())
      tgt.setEffectiveTime(src.getEffectiveTime());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasPoints())
      tgt.setPoints(src.getPoints());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.Contract.ValuedItemComponent convertValuedItemComponent(org.hl7.fhir.r4.model.Contract.ValuedItemComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.dstu3.model.Contract.ValuedItemComponent();
    copyElement(src, tgt);
    if (src.hasEntity())
      tgt.setEntity(convertType(src.getEntity()));
    if (src.hasIdentifier())
      tgt.setIdentifier(convertIdentifier(src.getIdentifier()));
    if (src.hasEffectiveTime())
      tgt.setEffectiveTime(src.getEffectiveTime());
    if (src.hasQuantity())
      tgt.setQuantity(convertSimpleQuantity(src.getQuantity()));
    if (src.hasUnitPrice())
      tgt.setUnitPrice(convertMoney(src.getUnitPrice()));
    if (src.hasFactor())
      tgt.setFactor(src.getFactor());
    if (src.hasPoints())
      tgt.setPoints(src.getPoints());
    if (src.hasNet())
      tgt.setNet(convertMoney(src.getNet()));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.VisionPrescription.VisionBase convertVisionBase(org.hl7.fhir.dstu3.model.VisionPrescription.VisionBase src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case UP: return org.hl7.fhir.r4.model.VisionPrescription.VisionBase.UP;
    case DOWN: return org.hl7.fhir.r4.model.VisionPrescription.VisionBase.DOWN;
    case IN: return org.hl7.fhir.r4.model.VisionPrescription.VisionBase.IN;
    case OUT: return org.hl7.fhir.r4.model.VisionPrescription.VisionBase.OUT;
    default: return org.hl7.fhir.r4.model.VisionPrescription.VisionBase.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.VisionPrescription.VisionBase convertVisionBase(org.hl7.fhir.r4.model.VisionPrescription.VisionBase src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case UP: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionBase.UP;
    case DOWN: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionBase.DOWN;
    case IN: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionBase.IN;
    case OUT: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionBase.OUT;
    default: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionBase.NULL;
  }
}

  private static org.hl7.fhir.r4.model.VisionPrescription.VisionEyes convertVisionEyes(org.hl7.fhir.dstu3.model.VisionPrescription.VisionEyes src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RIGHT: return org.hl7.fhir.r4.model.VisionPrescription.VisionEyes.RIGHT;
    case LEFT: return org.hl7.fhir.r4.model.VisionPrescription.VisionEyes.LEFT;
    default: return org.hl7.fhir.r4.model.VisionPrescription.VisionEyes.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.VisionPrescription.VisionEyes convertVisionEyes(org.hl7.fhir.r4.model.VisionPrescription.VisionEyes src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case RIGHT: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionEyes.RIGHT;
    case LEFT: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionEyes.LEFT;
    default: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionEyes.NULL;
  }
}

  public static org.hl7.fhir.r4.model.VisionPrescription convertVisionPrescription(org.hl7.fhir.dstu3.model.VisionPrescription src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.VisionPrescription tgt = new org.hl7.fhir.r4.model.VisionPrescription();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertVisionStatus(src.getStatus()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDateWritten())
      tgt.setDateWritten(src.getDateWritten());
    if (src.hasPrescriber())
      tgt.setPrescriber(convertReference(src.getPrescriber()));
    if (src.hasReason())
      tgt.setReason(convertType(src.getReason()));
    for (org.hl7.fhir.dstu3.model.VisionPrescription.VisionPrescriptionDispenseComponent t : src.getDispense())
      tgt.addDispense(convertVisionPrescriptionDispenseComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.VisionPrescription convertVisionPrescription(org.hl7.fhir.r4.model.VisionPrescription src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.VisionPrescription tgt = new org.hl7.fhir.dstu3.model.VisionPrescription();
    copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
      tgt.addIdentifier(convertIdentifier(t));
    if (src.hasStatus())
      tgt.setStatus(convertVisionStatus(src.getStatus()));
    if (src.hasPatient())
      tgt.setPatient(convertReference(src.getPatient()));
    if (src.hasEncounter())
      tgt.setEncounter(convertReference(src.getEncounter()));
    if (src.hasDateWritten())
      tgt.setDateWritten(src.getDateWritten());
    if (src.hasPrescriber())
      tgt.setPrescriber(convertReference(src.getPrescriber()));
    if (src.hasReason())
      tgt.setReason(convertType(src.getReason()));
    for (org.hl7.fhir.r4.model.VisionPrescription.VisionPrescriptionDispenseComponent t : src.getDispense())
      tgt.addDispense(convertVisionPrescriptionDispenseComponent(t));
    return tgt;
  }

  public static org.hl7.fhir.r4.model.VisionPrescription.VisionPrescriptionDispenseComponent convertVisionPrescriptionDispenseComponent(org.hl7.fhir.dstu3.model.VisionPrescription.VisionPrescriptionDispenseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.r4.model.VisionPrescription.VisionPrescriptionDispenseComponent tgt = new org.hl7.fhir.r4.model.VisionPrescription.VisionPrescriptionDispenseComponent();
    copyElement(src, tgt);
    if (src.hasProduct())
      tgt.setProduct(convertCodeableConcept(src.getProduct()));
    if (src.hasEye())
      tgt.setEye(convertVisionEyes(src.getEye()));
    if (src.hasSphere())
      tgt.setSphere(src.getSphere());
    if (src.hasCylinder())
      tgt.setCylinder(src.getCylinder());
    if (src.hasAxis())
      tgt.setAxis(src.getAxis());
    if (src.hasPrism())
      tgt.setPrism(src.getPrism());
    if (src.hasBase())
      tgt.setBase(convertVisionBase(src.getBase()));
    if (src.hasAdd())
      tgt.setAdd(src.getAdd());
    if (src.hasPower())
      tgt.setPower(src.getPower());
    if (src.hasBackCurve())
      tgt.setBackCurve(src.getBackCurve());
    if (src.hasDiameter())
      tgt.setDiameter(src.getDiameter());
    if (src.hasDuration())
      tgt.setDuration(convertSimpleQuantity(src.getDuration()));
    if (src.hasColor())
      tgt.setColor(src.getColor());
    if (src.hasBrand())
      tgt.setBrand(src.getBrand());
    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  public static org.hl7.fhir.dstu3.model.VisionPrescription.VisionPrescriptionDispenseComponent convertVisionPrescriptionDispenseComponent(org.hl7.fhir.r4.model.VisionPrescription.VisionPrescriptionDispenseComponent src) throws FHIRException {
    if (src == null)
      return null;
    org.hl7.fhir.dstu3.model.VisionPrescription.VisionPrescriptionDispenseComponent tgt = new org.hl7.fhir.dstu3.model.VisionPrescription.VisionPrescriptionDispenseComponent();
    copyElement(src, tgt);
    if (src.hasProduct())
      tgt.setProduct(convertCodeableConcept(src.getProduct()));
    if (src.hasEye())
      tgt.setEye(convertVisionEyes(src.getEye()));
    if (src.hasSphere())
      tgt.setSphere(src.getSphere());
    if (src.hasCylinder())
      tgt.setCylinder(src.getCylinder());
    if (src.hasAxis())
      tgt.setAxis(src.getAxis());
    if (src.hasPrism())
      tgt.setPrism(src.getPrism());
    if (src.hasBase())
      tgt.setBase(convertVisionBase(src.getBase()));
    if (src.hasAdd())
      tgt.setAdd(src.getAdd());
    if (src.hasPower())
      tgt.setPower(src.getPower());
    if (src.hasBackCurve())
      tgt.setBackCurve(src.getBackCurve());
    if (src.hasDiameter())
      tgt.setDiameter(src.getDiameter());
    if (src.hasDuration())
      tgt.setDuration(convertSimpleQuantity(src.getDuration()));
    if (src.hasColor())
      tgt.setColor(src.getColor());
    if (src.hasBrand())
      tgt.setBrand(src.getBrand());
    for (org.hl7.fhir.r4.model.Annotation t : src.getNote())
      tgt.addNote(convertAnnotation(t));
    return tgt;
  }

  private static org.hl7.fhir.r4.model.VisionPrescription.VisionStatus convertVisionStatus(org.hl7.fhir.dstu3.model.VisionPrescription.VisionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.r4.model.VisionPrescription.VisionStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.r4.model.VisionPrescription.VisionStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.r4.model.VisionPrescription.VisionStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.r4.model.VisionPrescription.VisionStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.r4.model.VisionPrescription.VisionStatus.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.VisionPrescription.VisionStatus convertVisionStatus(org.hl7.fhir.r4.model.VisionPrescription.VisionStatus src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case ACTIVE: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionStatus.ACTIVE;
    case CANCELLED: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionStatus.CANCELLED;
    case DRAFT: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionStatus.DRAFT;
    case ENTEREDINERROR: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionStatus.ENTEREDINERROR;
    default: return org.hl7.fhir.dstu3.model.VisionPrescription.VisionStatus.NULL;
  }
}

  private static org.hl7.fhir.r4.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NORMAL: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL;
    case PHONETIC: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.PHONETIC;
    case NEARBY: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NEARBY;
    case DISTANCE: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.DISTANCE;
    case OTHER: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.OTHER;
    default: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NULL;
  }
}

  private static org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType src) throws FHIRException {
    if (src == null)
      return null;
    switch (src) {
    case NORMAL: return org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL;
    case PHONETIC: return org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.PHONETIC;
    case NEARBY: return org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NEARBY;
    case DISTANCE: return org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.DISTANCE;
    case OTHER: return org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.OTHER;
    default: return org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NULL;
  }
}

  private static void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException {
    copyElement(src, tgt);
    for (org.hl7.fhir.dstu3.model.Extension  e : src.getModifierExtension()) {
      tgt.addModifierExtension(convertExtension(e));
    }
  }

  private static void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException {
    copyElement(src, tgt);
    for (org.hl7.fhir.r4.model.Extension  e : src.getModifierExtension()) {
      tgt.addModifierExtension(convertExtension(e));
    }
  }

  private static void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException {
    copyResource(src, tgt);
    if (src.hasText())
      tgt.setText(convertNarrative(src.getText()));
    for (org.hl7.fhir.dstu3.model.Resource t : src.getContained())
      tgt.addContained(convertResource(t));
    for (org.hl7.fhir.dstu3.model.Extension t : src.getExtension())
      tgt.addExtension(convertExtension(t));
    for (org.hl7.fhir.dstu3.model.Extension t : src.getModifierExtension())
      tgt.addModifierExtension(convertExtension(t));
  }

  private static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException {
    copyResource(src, tgt);
    if (src.hasText())
      tgt.setText(convertNarrative(src.getText()));
    for (org.hl7.fhir.r4.model.Resource t : src.getContained())
      tgt.addContained(convertResource(t));
    for (org.hl7.fhir.r4.model.Extension t : src.getExtension())
      tgt.addExtension(convertExtension(t));
    for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension())
      tgt.addModifierExtension(convertExtension(t));
  }

  private static void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r4.model.Element tgt) throws FHIRException {
    if (src.hasId())
      tgt.setId(src.getId());
    for (org.hl7.fhir.dstu3.model.Extension  e : src.getExtension()) {
      tgt.addExtension(convertExtension(e));
    }
  }

  private static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu3.model.Element tgt) throws FHIRException {
    if (src.hasId())
      tgt.setId(src.getId());
    for (org.hl7.fhir.r4.model.Extension  e : src.getExtension()) {
      tgt.addExtension(convertExtension(e));
    }
  }

   public static void copyQuantity(org.hl7.fhir.dstu3.model.Quantity src, org.hl7.fhir.r4.model.Quantity tgt) throws FHIRException {
    if (src == null || tgt == null)
      return;
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasComparator())
      tgt.setComparator(convertQuantityComparator(src.getComparator()));
    if (src.hasUnit())
      tgt.setUnit(src.getUnit());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
      tgt.setCode(src.getCode());
  }

  public static void copyQuantity(org.hl7.fhir.r4.model.Quantity src, org.hl7.fhir.dstu3.model.Quantity tgt) throws FHIRException {
    if (src == null || tgt == null)
      return;
    copyElement(src, tgt);
    if (src.hasValue())
      tgt.setValue(src.getValue());
    if (src.hasComparator())
      tgt.setComparator(convertQuantityComparator(src.getComparator()));
    if (src.hasUnit())
      tgt.setUnit(src.getUnit());
    if (src.hasSystem())
      tgt.setSystem(src.getSystem());
    if (src.hasCode())
     tgt.setCode(src.getCode());
}

  private static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException {
    if (src.hasId())
      tgt.setId(src.getId());
    if (src.hasMeta())
      tgt.setMeta(convertMeta(src.getMeta()));
    if (src.hasImplicitRules())
      tgt.setImplicitRules(src.getImplicitRules());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
  }

  private static void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException {
    if (src.hasId())
      tgt.setId(src.getId());
    if (src.hasMeta())
      tgt.setMeta(convertMeta(src.getMeta()));
    if (src.hasImplicitRules())
      tgt.setImplicitRules(src.getImplicitRules());
    if (src.hasLanguage())
      tgt.setLanguage(src.getLanguage());
  }


}
