001package org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50;
002
003import java.util.stream.Collectors;
004
005import org.hl7.fhir.convertors.context.ConversionContext40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.BackboneElement40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Code40_50;
012import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Id40_50;
013import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Integer40_50;
014import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50;
015import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
016import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.UnsignedInt40_50;
017import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
018import org.hl7.fhir.convertors.conv40_50.resources40_50.Enumerations40_50;
019import org.hl7.fhir.exceptions.FHIRException;
020import org.hl7.fhir.r4.model.BooleanType;
021import org.hl7.fhir.r4.model.CanonicalType;
022import org.hl7.fhir.r4.model.Extension;
023import org.hl7.fhir.r4.model.MarkdownType;
024import org.hl7.fhir.r4.model.StringType;
025import org.hl7.fhir.r5.model.CodeType;
026import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingAdditionalComponent;
027import org.hl7.fhir.r5.model.UsageContext;
028
029public class ElementDefinition40_50 {
030  public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException {
031    if (src == null) return null;
032    org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition();
033    BackboneElement40_50.copyBackboneElement(src, tgt, 
034        "http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.mustHaveValue", 
035        "http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.valueAlternatives");
036    if (src.hasPath()) tgt.setPathElement(String40_50.convertString(src.getPathElement()));
037    tgt.setRepresentation(src.getRepresentation().stream().map(ElementDefinition40_50::convertPropertyRepresentation).collect(Collectors.toList()));
038    if (src.hasSliceName()) tgt.setSliceNameElement(String40_50.convertString(src.getSliceNameElement()));
039    if (src.hasSliceIsConstraining())
040      tgt.setSliceIsConstrainingElement(Boolean40_50.convertBoolean(src.getSliceIsConstrainingElement()));
041    if (src.hasLabel()) tgt.setLabelElement(String40_50.convertString(src.getLabelElement()));
042    for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(Coding40_50.convertCoding(t));
043    if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing()));
044    if (src.hasShort()) tgt.setShortElement(String40_50.convertString(src.getShortElement()));
045    if (src.hasDefinition()) tgt.setDefinitionElement(MarkDown40_50.convertMarkdown(src.getDefinitionElement()));
046    if (src.hasComment()) tgt.setCommentElement(MarkDown40_50.convertMarkdown(src.getCommentElement()));
047    if (src.hasRequirements()) tgt.setRequirementsElement(MarkDown40_50.convertMarkdown(src.getRequirementsElement()));
048    for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.getAlias().add(String40_50.convertString(t));
049    if (src.hasMin()) tgt.setMinElement(UnsignedInt40_50.convertUnsignedInt(src.getMinElement()));
050    if (src.hasMax()) tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
051    if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
052    if (src.hasContentReference())
053      tgt.setContentReferenceElement(Uri40_50.convertUri(src.getContentReferenceElement()));
054    for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType())
055      tgt.addType(convertTypeRefComponent(t));
056    if (src.hasDefaultValue())
057      tgt.setDefaultValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDefaultValue()));
058    if (src.hasMeaningWhenMissing())
059      tgt.setMeaningWhenMissingElement(MarkDown40_50.convertMarkdown(src.getMeaningWhenMissingElement()));
060    if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(String40_50.convertString(src.getOrderMeaningElement()));
061    if (src.hasFixed())
062      tgt.setFixed(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getFixed()));
063    if (src.hasPattern())
064      tgt.setPattern(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getPattern()));
065    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample())
066      tgt.addExample(convertElementDefinitionExampleComponent(t));
067    if (src.hasMinValue())
068      tgt.setMinValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getMinValue()));
069    if (src.hasMaxValue())
070      tgt.setMaxValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getMaxValue()));
071    if (src.hasMaxLength()) tgt.setMaxLengthElement(Integer40_50.convertInteger(src.getMaxLengthElement()));
072    for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.getCondition().add(Id40_50.convertId(t));
073    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint())
074      tgt.addConstraint(convertElementDefinitionConstraintComponent(t));
075    if (src.hasMustSupport()) tgt.setMustSupportElement(Boolean40_50.convertBoolean(src.getMustSupportElement()));
076    if (src.hasIsModifier()) tgt.setIsModifierElement(Boolean40_50.convertBoolean(src.getIsModifierElement()));
077    if (src.hasIsModifierReason())
078      tgt.setIsModifierReasonElement(String40_50.convertString(src.getIsModifierReasonElement()));
079    if (src.hasIsSummary()) tgt.setIsSummaryElement(Boolean40_50.convertBoolean(src.getIsSummaryElement()));
080    if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding()));
081    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping())
082      tgt.addMapping(convertElementDefinitionMappingComponent(t));
083
084    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.mustHaveValue")) {
085      tgt.setMustHaveValueElement(Boolean40_50.convertBoolean((org.hl7.fhir.r4.model.BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.mustHaveValue").getValueAsPrimitive()));
086    }
087    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.valueAlternatives")) {
088      tgt.addValueAlternative(Canonical40_50.convertCanonical((org.hl7.fhir.r4.model.CanonicalType)ext.getValue()));
089    }
090
091    return tgt;
092  }
093
094  public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException {
095    if (src == null) return null;
096    org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition();
097    BackboneElement40_50.copyBackboneElement(src, tgt);
098    if (src.hasPath()) tgt.setPathElement(String40_50.convertString(src.getPathElement()));
099    tgt.setRepresentation(src.getRepresentation().stream().map(ElementDefinition40_50::convertPropertyRepresentation).collect(Collectors.toList()));
100    if (src.hasSliceName()) tgt.setSliceNameElement(String40_50.convertString(src.getSliceNameElement()));
101    if (src.hasSliceIsConstraining())
102      tgt.setSliceIsConstrainingElement(Boolean40_50.convertBoolean(src.getSliceIsConstrainingElement()));
103    if (src.hasLabel()) tgt.setLabelElement(String40_50.convertString(src.getLabelElement()));
104    for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(Coding40_50.convertCoding(t));
105    if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing()));
106    if (src.hasShort()) tgt.setShortElement(String40_50.convertString(src.getShortElement()));
107    if (src.hasDefinition()) tgt.setDefinitionElement(MarkDown40_50.convertMarkdown(src.getDefinitionElement()));
108    if (src.hasComment()) tgt.setCommentElement(MarkDown40_50.convertMarkdown(src.getCommentElement()));
109    if (src.hasRequirements()) tgt.setRequirementsElement(MarkDown40_50.convertMarkdown(src.getRequirementsElement()));
110    for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.getAlias().add(String40_50.convertString(t));
111    if (src.hasMin()) tgt.setMinElement(UnsignedInt40_50.convertUnsignedInt(src.getMinElement()));
112    if (src.hasMax()) tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
113    if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
114    if (src.hasContentReference())
115      tgt.setContentReferenceElement(Uri40_50.convertUri(src.getContentReferenceElement()));
116    for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType())
117      tgt.addType(convertTypeRefComponent(t));
118    if (src.hasDefaultValue())
119      tgt.setDefaultValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDefaultValue()));
120    if (src.hasMeaningWhenMissing())
121      tgt.setMeaningWhenMissingElement(MarkDown40_50.convertMarkdown(src.getMeaningWhenMissingElement()));
122    if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(String40_50.convertString(src.getOrderMeaningElement()));
123    if (src.hasFixed())
124      tgt.setFixed(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getFixed()));
125    if (src.hasPattern())
126      tgt.setPattern(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getPattern()));
127    for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample())
128      tgt.addExample(convertElementDefinitionExampleComponent(t));
129    if (src.hasMinValue())
130      tgt.setMinValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getMinValue()));
131    if (src.hasMaxValue())
132      tgt.setMaxValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getMaxValue()));
133    if (src.hasMaxLength()) tgt.setMaxLengthElement(Integer40_50.convertInteger(src.getMaxLengthElement()));
134    for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.getCondition().add(Id40_50.convertId(t));
135    for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint())
136      tgt.addConstraint(convertElementDefinitionConstraintComponent(t));
137    if (src.hasMustSupport()) tgt.setMustSupportElement(Boolean40_50.convertBoolean(src.getMustSupportElement()));
138    if (src.hasIsModifier()) tgt.setIsModifierElement(Boolean40_50.convertBoolean(src.getIsModifierElement()));
139    if (src.hasIsModifierReason())
140      tgt.setIsModifierReasonElement(String40_50.convertString(src.getIsModifierReasonElement()));
141    if (src.hasIsSummary()) tgt.setIsSummaryElement(Boolean40_50.convertBoolean(src.getIsSummaryElement()));
142    if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding()));
143    for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping())
144      tgt.addMapping(convertElementDefinitionMappingComponent(t));
145    if (src.hasMustHaveValue()) {
146      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.mustHaveValue", Boolean40_50.convertBoolean(src.getMustHaveValueElement()));
147    }
148    for (org.hl7.fhir.r5.model.CanonicalType ct : src.getValueAlternatives()) {
149      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.valueAlternatives", Canonical40_50.convertCanonical(ct));      
150    }
151
152    return tgt;
153  }
154
155  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation> convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation> src) throws FHIRException {
156    if (src == null || src.isEmpty()) return null;
157    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory());
158    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
159    if (src.getValue() == null) {
160      tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL);
161    } else {
162      switch (src.getValue()) {
163        case XMLATTR:
164          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR);
165          break;
166        case XMLTEXT:
167          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLTEXT);
168          break;
169        case TYPEATTR:
170          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.TYPEATTR);
171          break;
172        case CDATEXT:
173          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.CDATEXT);
174          break;
175        case XHTML:
176          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XHTML);
177          break;
178        default:
179          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL);
180          break;
181      }
182    }
183    return tgt;
184  }
185
186  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation> convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation> src) throws FHIRException {
187    if (src == null || src.isEmpty()) return null;
188    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory());
189    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
190    if (src.getValue() == null) {
191      tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL);
192    } else {
193      switch (src.getValue()) {
194        case XMLATTR:
195          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR);
196          break;
197        case XMLTEXT:
198          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT);
199          break;
200        case TYPEATTR:
201          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR);
202          break;
203        case CDATEXT:
204          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT);
205          break;
206        case XHTML:
207          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XHTML);
208          break;
209        default:
210          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL);
211          break;
212      }
213    }
214    return tgt;
215  }
216
217  public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException {
218    if (src == null) return null;
219    org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent();
220    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
221    for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator())
222      tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t));
223    if (src.hasDescription()) tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
224    if (src.hasOrdered()) tgt.setOrderedElement(Boolean40_50.convertBoolean(src.getOrderedElement()));
225    if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement()));
226    return tgt;
227  }
228
229  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException {
230    if (src == null) return null;
231    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent();
232    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
233    for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator())
234      tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t));
235    if (src.hasDescription()) tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
236    if (src.hasOrdered()) tgt.setOrderedElement(Boolean40_50.convertBoolean(src.getOrderedElement()));
237    if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement()));
238    return tgt;
239  }
240
241  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.SlicingRules> convertSlicingRules(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.SlicingRules> src) throws FHIRException {
242    if (src == null || src.isEmpty()) return null;
243    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.SlicingRules> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory());
244    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
245    if (src.getValue() == null) {
246      tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL);
247    } else {
248      switch (src.getValue()) {
249        case CLOSED:
250          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED);
251          break;
252        case OPEN:
253          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN);
254          break;
255        case OPENATEND:
256          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND);
257          break;
258        default:
259          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL);
260          break;
261      }
262    }
263    return tgt;
264  }
265
266  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.SlicingRules> convertSlicingRules(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.SlicingRules> src) throws FHIRException {
267    if (src == null || src.isEmpty()) return null;
268    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.SlicingRules> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory());
269    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
270    if (src.getValue() == null) {
271      tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL);
272    } else {
273      switch (src.getValue()) {
274        case CLOSED:
275          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED);
276          break;
277        case OPEN:
278          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN);
279          break;
280        case OPENATEND:
281          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND);
282          break;
283        default:
284          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL);
285          break;
286      }
287    }
288    return tgt;
289  }
290
291  public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException {
292    if (src == null) return null;
293    org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent();
294    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
295    if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement()));
296    if (src.hasPath()) tgt.setPathElement(String40_50.convertString(src.getPathElement()));
297    return tgt;
298  }
299
300  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException {
301    if (src == null) return null;
302    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent();
303    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
304    if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement()));
305    if (src.hasPath()) tgt.setPathElement(String40_50.convertString(src.getPathElement()));
306    return tgt;
307  }
308
309  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType> convertDiscriminatorType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType> src) throws FHIRException {
310    if (src == null || src.isEmpty()) return null;
311    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorTypeEnumFactory());
312    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
313    if (src.getValue() == null) {
314      tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL);
315    } else {
316      switch (src.getValue()) {
317        case VALUE:
318          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.VALUE);
319          break;
320        case EXISTS:
321          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.EXISTS);
322          break;
323        case PATTERN:
324          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PATTERN);
325          break;
326        case TYPE:
327          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.TYPE);
328          break;
329        case PROFILE:
330          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PROFILE);
331          break;
332        default:
333          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL);
334          break;
335      }
336    }
337    return tgt;
338  }
339
340  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType> convertDiscriminatorType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType> src) throws FHIRException {
341    if (src == null || src.isEmpty()) return null;
342    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorTypeEnumFactory());
343    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
344    if (src.getValue() == null) {
345      tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL);
346    } else {
347      switch (src.getValue()) {
348        case VALUE:
349          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.VALUE);
350          break;
351        case EXISTS:
352          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.EXISTS);
353          break;
354        case PATTERN:
355          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PATTERN);
356          break;
357        case TYPE:
358          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.TYPE);
359          break;
360        case PROFILE:
361          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PROFILE);
362          break;
363        default:
364          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL);
365          break;
366      }
367    }
368    return tgt;
369  }
370
371  public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException {
372    if (src == null) return null;
373    org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent();
374    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
375    if (src.hasPath()) tgt.setPathElement(String40_50.convertString(src.getPathElement()));
376    if (src.hasMin()) tgt.setMinElement(UnsignedInt40_50.convertUnsignedInt(src.getMinElement()));
377    if (src.hasMax()) tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
378    return tgt;
379  }
380
381  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException {
382    if (src == null) return null;
383    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent();
384    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
385    if (src.hasPath()) tgt.setPathElement(String40_50.convertString(src.getPathElement()));
386    if (src.hasMin()) tgt.setMinElement(UnsignedInt40_50.convertUnsignedInt(src.getMinElement()));
387    if (src.hasMax()) tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
388    return tgt;
389  }
390
391  public static org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src) throws FHIRException {
392    if (src == null) return null;
393    org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent();
394    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
395    if (src.hasCode()) tgt.setCodeElement(Uri40_50.convertUri(src.getCodeElement()));
396    for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile())
397      tgt.getProfile().add(Canonical40_50.convertCanonical(t));
398    for (org.hl7.fhir.r4.model.CanonicalType t : src.getTargetProfile())
399      tgt.getTargetProfile().add(Canonical40_50.convertCanonical(t));
400    tgt.setAggregation(src.getAggregation().stream().map(ElementDefinition40_50::convertAggregationMode).collect(Collectors.toList()));
401    if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement()));
402    return tgt;
403  }
404
405  public static org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src) throws FHIRException {
406    if (src == null) return null;
407    org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent();
408    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
409    if (src.hasCode()) tgt.setCodeElement(Uri40_50.convertUri(src.getCodeElement()));
410    for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile())
411      tgt.getProfile().add(Canonical40_50.convertCanonical(t));
412    for (org.hl7.fhir.r5.model.CanonicalType t : src.getTargetProfile())
413      tgt.getTargetProfile().add(Canonical40_50.convertCanonical(t));
414    tgt.setAggregation(src.getAggregation().stream().map(ElementDefinition40_50::convertAggregationMode).collect(Collectors.toList()));
415    if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement()));
416    return tgt;
417  }
418
419  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.AggregationMode> convertAggregationMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.AggregationMode> src) throws FHIRException {
420    if (src == null || src.isEmpty()) return null;
421    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.AggregationMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory());
422    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
423    if (src.getValue() == null) {
424      tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL);
425    } else {
426      switch (src.getValue()) {
427        case CONTAINED:
428          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED);
429          break;
430        case REFERENCED:
431          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED);
432          break;
433        case BUNDLED:
434          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED);
435          break;
436        default:
437          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL);
438          break;
439      }
440    }
441    return tgt;
442  }
443
444  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.AggregationMode> convertAggregationMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.AggregationMode> src) throws FHIRException {
445    if (src == null || src.isEmpty()) return null;
446    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.AggregationMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory());
447    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
448    if (src.getValue() == null) {
449      tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL);
450    } else {
451      switch (src.getValue()) {
452        case CONTAINED:
453          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED);
454          break;
455        case REFERENCED:
456          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED);
457          break;
458        case BUNDLED:
459          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED);
460          break;
461        default:
462          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL);
463          break;
464      }
465    }
466    return tgt;
467  }
468
469  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules> convertReferenceVersionRules(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules> src) throws FHIRException {
470    if (src == null || src.isEmpty()) return null;
471    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRulesEnumFactory());
472    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
473    if (src.getValue() == null) {
474      tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL);
475    } else {
476      switch (src.getValue()) {
477        case EITHER:
478          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.EITHER);
479          break;
480        case INDEPENDENT:
481          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT);
482          break;
483        case SPECIFIC:
484          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.SPECIFIC);
485          break;
486        default:
487          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL);
488          break;
489      }
490    }
491    return tgt;
492  }
493
494  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules> convertReferenceVersionRules(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules> src) throws FHIRException {
495    if (src == null || src.isEmpty()) return null;
496    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRulesEnumFactory());
497    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
498    if (src.getValue() == null) {
499      tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL);
500    } else {
501      switch (src.getValue()) {
502        case EITHER:
503          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER);
504          break;
505        case INDEPENDENT:
506          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT);
507          break;
508        case SPECIFIC:
509          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC);
510          break;
511        default:
512          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL);
513          break;
514      }
515    }
516    return tgt;
517  }
518
519  public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException {
520    if (src == null) return null;
521    org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent();
522    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
523    if (src.hasLabel()) tgt.setLabelElement(String40_50.convertString(src.getLabelElement()));
524    if (src.hasValue())
525      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
526    return tgt;
527  }
528
529  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException {
530    if (src == null) return null;
531    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent();
532    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
533    if (src.hasLabel()) tgt.setLabelElement(String40_50.convertString(src.getLabelElement()));
534    if (src.hasValue())
535      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
536    return tgt;
537  }
538
539  public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException {
540    if (src == null) return null;
541    org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent();
542    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
543    if (src.hasKey()) tgt.setKeyElement(Id40_50.convertId(src.getKeyElement()));
544    if (src.hasRequirements()) tgt.setRequirementsElement(String40_50.convertStringToMarkdown(src.getRequirementsElement()));
545    if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement()));
546    if (src.hasHuman()) tgt.setHumanElement(String40_50.convertString(src.getHumanElement()));
547    if (src.hasExpression()) tgt.setExpressionElement(String40_50.convertString(src.getExpressionElement()));
548    if (src.hasXpath()) {
549      tgt.addExtension(new org.hl7.fhir.r5.model.Extension(org.hl7.fhir.r5.utils.ToolingExtensions.EXT_XPATH_CONSTRAINT, new org.hl7.fhir.r5.model.StringType(src.getXpath())));
550    }
551    if (src.hasSource()) tgt.setSourceElement(Canonical40_50.convertCanonical(src.getSourceElement()));
552    return tgt;
553  }
554
555  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException {
556    if (src == null) return null;
557    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent();
558    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, org.hl7.fhir.r5.utils.ToolingExtensions.EXT_XPATH_CONSTRAINT);
559    if (src.hasKey()) tgt.setKeyElement(Id40_50.convertId(src.getKeyElement()));
560    if (src.hasRequirements()) tgt.setRequirementsElement(String40_50.convertString(src.getRequirementsElement()));
561    if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement()));
562    if (src.hasHuman()) tgt.setHumanElement(String40_50.convertString(src.getHumanElement()));
563    if (src.hasExpression()) tgt.setExpressionElement(String40_50.convertString(src.getExpressionElement()));
564    if (org.hl7.fhir.r5.utils.ToolingExtensions.hasExtension(src, org.hl7.fhir.r5.utils.ToolingExtensions.EXT_XPATH_CONSTRAINT)) {
565      tgt.setXpath(org.hl7.fhir.r5.utils.ToolingExtensions.readStringExtension(src, org.hl7.fhir.r5.utils.ToolingExtensions.EXT_XPATH_CONSTRAINT));
566    }
567    if (src.hasSource()) tgt.setSourceElement(Canonical40_50.convertCanonical(src.getSourceElement()));
568    return tgt;
569  }
570
571  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity> convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity> src) throws FHIRException {
572    if (src == null || src.isEmpty()) return null;
573    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory());
574    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
575    if (src.getValue() == null) {
576      tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL);
577    } else {
578      switch (src.getValue()) {
579        case ERROR:
580          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR);
581          break;
582        case WARNING:
583          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING);
584          break;
585        default:
586          tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL);
587          break;
588      }
589    }
590    return tgt;
591  }
592
593  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity> convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity> src) throws FHIRException {
594    if (src == null || src.isEmpty()) return null;
595    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory());
596    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
597    if (src.getValue() == null) {
598      tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL);
599    } else {
600      switch (src.getValue()) {
601        case ERROR:
602          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR);
603          break;
604        case WARNING:
605          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING);
606          break;
607        default:
608          tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL);
609          break;
610      }
611    }
612    return tgt;
613  }
614
615  public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException {
616    if (src == null) return null;
617    org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent();
618    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
619        "http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.binding.additional");
620    if (src.hasStrength()) tgt.setStrengthElement(Enumerations40_50.convertBindingStrength(src.getStrengthElement()));
621    if (src.hasDescription()) tgt.setDescriptionElement(String40_50.convertStringToMarkdown(src.getDescriptionElement()));
622    if (src.hasValueSet()) tgt.setValueSetElement(Canonical40_50.convertCanonical(src.getValueSetElement()));
623
624    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ElementDefinition.binding.additional")) {
625      tgt.addAdditional(convertAdditional(ext));
626    }
627    return tgt;
628  }
629
630  private static ElementDefinitionBindingAdditionalComponent convertAdditional(Extension src) {
631    if (src == null) return null;
632    ElementDefinitionBindingAdditionalComponent tgt = new ElementDefinitionBindingAdditionalComponent();
633    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, "valueSet", "purpose", "documentation", "shortDoco", "usage", "any");
634    if (src.hasExtension("purpose")) {
635      tgt.getPurposeElement().setValueAsString(src.getExtensionByUrl("purpose").getValue().primitiveValue());
636    }
637    if (src.hasExtension("valueSet")) {
638      tgt.setValueSetElement(Canonical40_50.convertCanonical((CanonicalType) src.getExtensionByUrl("valueSet").getValue()));
639    }
640    if (src.hasExtension("documentation")) {
641      tgt.setDocumentationElement(MarkDown40_50.convertMarkdown((MarkdownType) src.getExtensionByUrl("documentation").getValue()));
642    }
643    if (src.hasExtension("shortDoco")) {
644      tgt.setShortDocoElement(String40_50.convertString((StringType) src.getExtensionByUrl("shortDoco").getValue()));
645    }
646    for (Extension t : src.getExtensionsByUrl("usage")) {
647      tgt.addUsage(UsageContext40_50.convertUsageContext((org.hl7.fhir.r4.model.UsageContext) t.getValue()));
648    }
649    if (src.hasExtension("any")) {
650      tgt.setAnyElement(Boolean40_50.convertBoolean((BooleanType) src.getExtensionByUrl("any").getValue()));
651    }
652    return tgt;
653  }
654
655  private static Extension convertAdditional(ElementDefinitionBindingAdditionalComponent src) {
656    if (src == null) return null;
657    Extension tgt = new Extension();
658    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
659    if (src.hasPurpose()) {
660      tgt.addExtension(new Extension("purpose", new CodeType(src.getPurposeElement().primitiveValue())));
661    }
662    if (src.hasValueSet()) {
663      tgt.addExtension(new Extension("valueSet", Canonical40_50.convertCanonical(src.getValueSetElement())));
664    }
665    if (src.hasDocumentation()) {
666      tgt.addExtension(new Extension("documentation", MarkDown40_50.convertMarkdown(src.getDocumentationElement())));
667    }
668    if (src.hasShortDoco()) {
669      tgt.addExtension(new Extension("shortDoco", String40_50.convertString(src.getShortDocoElement())));
670    }
671    for (UsageContext t : src.getUsage()) {
672      tgt.addExtension(new Extension("usage", UsageContext40_50.convertUsageContext(t)));
673    }
674    if (src.hasAny()) {
675      tgt.addExtension(new Extension("any", Boolean40_50.convertBoolean(src.getAnyElement())));
676    }
677    
678    return tgt;
679  }
680
681  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException {
682    if (src == null) return null;
683    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent();
684    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
685    if (src.hasStrength()) tgt.setStrengthElement(Enumerations40_50.convertBindingStrength(src.getStrengthElement()));
686    if (src.hasDescription()) tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
687    if (src.hasValueSet()) tgt.setValueSetElement(Canonical40_50.convertCanonical(src.getValueSetElement()));
688    for (ElementDefinitionBindingAdditionalComponent ab : src.getAdditional()) {
689      tgt.addExtension(convertAdditional(ab));
690    }
691    return tgt;
692  }
693
694  public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException {
695    if (src == null) return null;
696    org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent();
697    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
698    if (src.hasIdentity()) tgt.setIdentityElement(Id40_50.convertId(src.getIdentityElement()));
699    if (src.hasLanguage()) tgt.setLanguageElement(Code40_50.convertCode(src.getLanguageElement()));
700    if (src.hasMap()) tgt.setMapElement(String40_50.convertString(src.getMapElement()));
701    if (src.hasComment()) tgt.setCommentElement(String40_50.convertStringToMarkdown(src.getCommentElement()));
702    return tgt;
703  }
704
705  public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException {
706    if (src == null) return null;
707    org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent();
708    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
709    if (src.hasIdentity()) tgt.setIdentityElement(Id40_50.convertId(src.getIdentityElement()));
710    if (src.hasLanguage()) tgt.setLanguageElement(Code40_50.convertCode(src.getLanguageElement()));
711    if (src.hasMap()) tgt.setMapElement(String40_50.convertString(src.getMapElement()));
712    if (src.hasComment()) tgt.setCommentElement(String40_50.convertString(src.getCommentElement()));
713    return tgt;
714  }
715}