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