001package org.hl7.fhir.convertors.conv10_30.datatypes10_30; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_30; 004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Coding10_30; 005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.*; 006import org.hl7.fhir.dstu2.utils.ToolingExtensions; 007import org.hl7.fhir.dstu3.conformance.ProfileUtilities; 008import org.hl7.fhir.dstu3.model.ElementDefinition; 009import org.hl7.fhir.exceptions.FHIRException; 010 011import java.util.List; 012import java.util.stream.Collectors; 013 014public class ElementDefinition10_30 { 015 public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List<String> slicePaths) throws FHIRException { 016 if (src == null || src.isEmpty()) return null; 017 org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); 018 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 019 if (src.hasPathElement()) tgt.setPathElement(String10_30.convertString(src.getPathElement())); 020 tgt.setRepresentation(src.getRepresentation().stream().map(ElementDefinition10_30::convertPropertyRepresentation).collect(Collectors.toList())); 021 if (src.hasName()) { 022 if (slicePaths.contains(src.getPath())) tgt.setSliceNameElement(String10_30.convertString(src.getNameElement())); 023 if (src.hasNameElement()) tgt.setIdElement(String10_30.convertString(src.getNameElement())); 024 } 025 if (src.hasLabel()) tgt.setLabelElement(String10_30.convertString(src.getLabelElement())); 026 for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(Coding10_30.convertCoding(t)); 027 if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); 028 if (src.hasShort()) tgt.setShortElement(String10_30.convertString(src.getShortElement())); 029 if (src.hasDefinition()) tgt.setDefinitionElement(MarkDown10_30.convertMarkdown(src.getDefinitionElement())); 030 if (src.hasComments()) tgt.setCommentElement(MarkDown10_30.convertMarkdown(src.getCommentsElement())); 031 if (src.hasRequirements()) tgt.setRequirementsElement(MarkDown10_30.convertMarkdown(src.getRequirementsElement())); 032 for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); 033 if (src.hasMin()) tgt.setMin(src.getMin()); 034 if (src.hasMax()) tgt.setMaxElement(String10_30.convertString(src.getMaxElement())); 035 if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); 036 if (src.hasNameReference()) tgt.setContentReference("#" + src.getNameReference()); 037 for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) 038 tgt.addType(convertElementDefinitionTypeComponent(t)); 039 if (src.hasDefaultValue()) 040 tgt.setDefaultValue(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getDefaultValue())); 041 if (src.hasMeaningWhenMissing()) 042 tgt.setMeaningWhenMissingElement(MarkDown10_30.convertMarkdown(src.getMeaningWhenMissingElement())); 043 if (src.hasFixed()) 044 tgt.setFixed(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getFixed())); 045 if (src.hasPattern()) 046 tgt.setPattern(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getPattern())); 047 if (src.hasExample()) 048 tgt.addExample().setLabel("General").setValue(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getExample())); 049 if (src.hasMinValue()) 050 tgt.setMinValue(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getMinValue())); 051 if (src.hasMaxValue()) 052 tgt.setMaxValue(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getMaxValue())); 053 if (src.hasMaxLength()) tgt.setMaxLengthElement(Integer10_30.convertInteger(src.getMaxLengthElement())); 054 for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); 055 for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) 056 tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); 057 if (src.hasMustSupport()) tgt.setMustSupportElement(Boolean10_30.convertBoolean(src.getMustSupportElement())); 058 if (src.hasIsModifier()) tgt.setIsModifierElement(Boolean10_30.convertBoolean(src.getIsModifierElement())); 059 if (src.hasIsSummary()) tgt.setIsSummaryElement(Boolean10_30.convertBoolean(src.getIsSummaryElement())); 060 if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); 061 for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) 062 tgt.addMapping(convertElementDefinitionMappingComponent(t)); 063 return tgt; 064 } 065 066 public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { 067 if (src == null || src.isEmpty()) return null; 068 org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); 069 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 070 if (src.hasPathElement()) tgt.setPathElement(String10_30.convertString(src.getPathElement())); 071 tgt.setRepresentation(src.getRepresentation().stream().map(ElementDefinition10_30::convertPropertyRepresentation).collect(Collectors.toList())); 072 if (src.hasSliceName()) tgt.setNameElement(String10_30.convertString(src.getSliceNameElement())); 073 else tgt.setNameElement(String10_30.convertString(src.getIdElement())); 074 if (src.hasLabelElement()) tgt.setLabelElement(String10_30.convertString(src.getLabelElement())); 075 for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(Coding10_30.convertCoding(t)); 076 if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); 077 if (src.hasShortElement()) tgt.setShortElement(String10_30.convertString(src.getShortElement())); 078 if (src.hasDefinitionElement()) tgt.setDefinitionElement(MarkDown10_30.convertMarkdown(src.getDefinitionElement())); 079 if (src.hasCommentElement()) tgt.setCommentsElement(MarkDown10_30.convertMarkdown(src.getCommentElement())); 080 if (src.hasRequirementsElement()) 081 tgt.setRequirementsElement(MarkDown10_30.convertMarkdown(src.getRequirementsElement())); 082 for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); 083 tgt.setMin(src.getMin()); 084 if (src.hasMaxElement()) tgt.setMaxElement(String10_30.convertString(src.getMaxElement())); 085 if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); 086 if (src.hasContentReference()) tgt.setNameReference(src.getContentReference().substring(1)); 087 for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) 088 tgt.addType(convertElementDefinitionTypeComponent(t)); 089 if (src.hasDefaultValue()) 090 tgt.setDefaultValue(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getDefaultValue())); 091 if (src.hasMeaningWhenMissingElement()) 092 tgt.setMeaningWhenMissingElement(MarkDown10_30.convertMarkdown(src.getMeaningWhenMissingElement())); 093 if (src.hasFixed()) 094 tgt.setFixed(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getFixed())); 095 if (src.hasPattern()) 096 tgt.setPattern(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getPattern())); 097 if (src.hasExample()) 098 tgt.setExample(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getExampleFirstRep().getValue())); 099 if (src.hasMinValue()) 100 tgt.setMinValue(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getMinValue())); 101 if (src.hasMaxValue()) 102 tgt.setMaxValue(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getMaxValue())); 103 if (src.hasMaxLengthElement()) tgt.setMaxLengthElement(Integer10_30.convertInteger(src.getMaxLengthElement())); 104 for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); 105 for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) 106 tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); 107 if (src.hasMustSupportElement()) 108 tgt.setMustSupportElement(Boolean10_30.convertBoolean(src.getMustSupportElement())); 109 if (src.hasIsModifierElement()) tgt.setIsModifierElement(Boolean10_30.convertBoolean(src.getIsModifierElement())); 110 if (src.hasIsSummaryElement()) tgt.setIsSummaryElement(Boolean10_30.convertBoolean(src.getIsSummaryElement())); 111 if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); 112 for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) 113 tgt.addMapping(convertElementDefinitionMappingComponent(t)); 114 return tgt; 115 } 116 117 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation> convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation> src) throws FHIRException { 118 if (src == null || src.isEmpty()) return null; 119 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()); 120 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 121 if (src.getValue() == null) { 122 tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); 123 } else { 124 switch (src.getValue()) { 125 case XMLATTR: 126 tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); 127 break; 128 default: 129 tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); 130 break; 131 } 132 } 133 return tgt; 134 } 135 136 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation> convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation> src) throws FHIRException { 137 if (src == null || src.isEmpty()) return null; 138 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); 139 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 140 if (src.getValue() == null) { 141 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); 142 } else { 143 switch (src.getValue()) { 144 case XMLATTR: 145 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); 146 break; 147 default: 148 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); 149 break; 150 } 151 } 152 return tgt; 153 } 154 155 public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { 156 if (src == null || src.isEmpty()) return null; 157 org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); 158 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 159 for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) 160 tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); 161 if (src.hasDescriptionElement()) tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 162 if (src.hasOrderedElement()) tgt.setOrderedElement(Boolean10_30.convertBoolean(src.getOrderedElement())); 163 if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); 164 return tgt; 165 } 166 167 public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { 168 if (src == null || src.isEmpty()) return null; 169 org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); 170 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 171 for (ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) 172 tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); 173 if (src.hasDescriptionElement()) tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 174 if (src.hasOrderedElement()) tgt.setOrderedElement(Boolean10_30.convertBoolean(src.getOrderedElement())); 175 if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); 176 return tgt; 177 } 178 179 static public org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.SlicingRules> convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules> src) throws FHIRException { 180 if (src == null || src.isEmpty()) return null; 181 org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.SlicingRules> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new ElementDefinition.SlicingRulesEnumFactory()); 182 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 183 if (src.getValue() == null) { 184 tgt.setValue(ElementDefinition.SlicingRules.NULL); 185 } else { 186 switch (src.getValue()) { 187 case CLOSED: 188 tgt.setValue(ElementDefinition.SlicingRules.CLOSED); 189 break; 190 case OPEN: 191 tgt.setValue(ElementDefinition.SlicingRules.OPEN); 192 break; 193 case OPENATEND: 194 tgt.setValue(ElementDefinition.SlicingRules.OPENATEND); 195 break; 196 default: 197 tgt.setValue(ElementDefinition.SlicingRules.NULL); 198 break; 199 } 200 } 201 return tgt; 202 } 203 204 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules> convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.SlicingRules> src) throws FHIRException { 205 if (src == null || src.isEmpty()) return null; 206 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); 207 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 208 if (src.getValue() == null) { 209 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); 210 } else { 211 switch (src.getValue()) { 212 case CLOSED: 213 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); 214 break; 215 case OPEN: 216 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); 217 break; 218 case OPENATEND: 219 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); 220 break; 221 default: 222 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); 223 break; 224 } 225 } 226 return tgt; 227 } 228 229 public static ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { 230 if (src == null || src.isEmpty()) return null; 231 ElementDefinition.ElementDefinitionBaseComponent tgt = new ElementDefinition.ElementDefinitionBaseComponent(); 232 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 233 if (src.hasPathElement()) tgt.setPathElement(String10_30.convertString(src.getPathElement())); 234 if (src.hasMin()) tgt.setMin(src.getMin()); 235 if (src.hasMaxElement()) tgt.setMaxElement(String10_30.convertString(src.getMaxElement())); 236 return tgt; 237 } 238 239 public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { 240 if (src == null || src.isEmpty()) return null; 241 org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); 242 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 243 if (src.hasPathElement()) tgt.setPathElement(String10_30.convertString(src.getPathElement())); 244 if (src.hasMin()) tgt.setMin(src.getMin()); 245 if (src.hasMaxElement()) tgt.setMaxElement(String10_30.convertString(src.getMaxElement())); 246 return tgt; 247 } 248 249 public static ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src) throws FHIRException { 250 if (src == null || src.isEmpty()) return null; 251 ElementDefinition.TypeRefComponent tgt = new ElementDefinition.TypeRefComponent(); 252 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 253 if (src.hasCodeElement()) tgt.setCodeElement(Code10_30.convertCodeToUri(src.getCodeElement())); 254 for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) 255 if (src.hasTarget()) tgt.setTargetProfile(t.getValueAsString()); 256 else tgt.setProfile(t.getValue()); 257 tgt.setAggregation(src.getAggregation().stream().map(ElementDefinition10_30::convertAggregationMode).collect(Collectors.toList())); 258 return tgt; 259 } 260 261 public static org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(ElementDefinition.TypeRefComponent src) throws FHIRException { 262 if (src == null || src.isEmpty()) return null; 263 org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); 264 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 265 if (src.hasCodeElement()) tgt.setCodeElement(Code10_30.convertUriToCode(src.getCodeElement())); 266 if (src.hasTarget()) { 267 if (src.hasTargetProfile()) tgt.addProfile(src.getTargetProfile()); 268 } else if (src.hasProfile()) tgt.addProfile(src.getProfile()); 269 tgt.setAggregation(src.getAggregation().stream().map(ElementDefinition10_30::convertAggregationMode).collect(Collectors.toList())); 270 return tgt; 271 } 272 273 static public org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.AggregationMode> convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode> src) throws FHIRException { 274 if (src == null || src.isEmpty()) return null; 275 org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.AggregationMode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new ElementDefinition.AggregationModeEnumFactory()); 276 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 277 if (src.getValue() == null) { 278 tgt.setValue(ElementDefinition.AggregationMode.NULL); 279 } else { 280 switch (src.getValue()) { 281 case CONTAINED: 282 tgt.setValue(ElementDefinition.AggregationMode.CONTAINED); 283 break; 284 case REFERENCED: 285 tgt.setValue(ElementDefinition.AggregationMode.REFERENCED); 286 break; 287 case BUNDLED: 288 tgt.setValue(ElementDefinition.AggregationMode.BUNDLED); 289 break; 290 default: 291 tgt.setValue(ElementDefinition.AggregationMode.NULL); 292 break; 293 } 294 } 295 return tgt; 296 } 297 298 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode> convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.AggregationMode> src) throws FHIRException { 299 if (src == null || src.isEmpty()) return null; 300 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); 301 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 302 if (src.getValue() == null) { 303 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); 304 } else { 305 switch (src.getValue()) { 306 case CONTAINED: 307 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); 308 break; 309 case REFERENCED: 310 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); 311 break; 312 case BUNDLED: 313 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); 314 break; 315 default: 316 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); 317 break; 318 } 319 } 320 return tgt; 321 } 322 323 public static ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { 324 if (src == null || src.isEmpty()) return null; 325 ElementDefinition.ElementDefinitionConstraintComponent tgt = new ElementDefinition.ElementDefinitionConstraintComponent(); 326 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 327 if (src.hasKeyElement()) tgt.setKeyElement(Id10_30.convertId(src.getKeyElement())); 328 if (src.hasRequirementsElement()) 329 tgt.setRequirementsElement(String10_30.convertString(src.getRequirementsElement())); 330 if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); 331 if (src.hasHumanElement()) tgt.setHumanElement(String10_30.convertString(src.getHumanElement())); 332 tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); 333 if (src.hasXpathElement()) tgt.setXpathElement(String10_30.convertString(src.getXpathElement())); 334 return tgt; 335 } 336 337 public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { 338 if (src == null || src.isEmpty()) return null; 339 org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); 340 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 341 if (src.hasKeyElement()) tgt.setKeyElement(Id10_30.convertId(src.getKeyElement())); 342 if (src.hasRequirementsElement()) 343 tgt.setRequirementsElement(String10_30.convertString(src.getRequirementsElement())); 344 if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); 345 if (src.hasHumanElement()) tgt.setHumanElement(String10_30.convertString(src.getHumanElement())); 346 if (src.hasExpression()) 347 ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); 348 if (src.hasXpathElement()) tgt.setXpathElement(String10_30.convertString(src.getXpathElement())); 349 return tgt; 350 } 351 352 static public org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.ConstraintSeverity> convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity> src) throws FHIRException { 353 if (src == null || src.isEmpty()) return null; 354 org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.ConstraintSeverity> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new ElementDefinition.ConstraintSeverityEnumFactory()); 355 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 356 if (src.getValue() == null) { 357 tgt.setValue(ElementDefinition.ConstraintSeverity.NULL); 358 } else { 359 switch (src.getValue()) { 360 case ERROR: 361 tgt.setValue(ElementDefinition.ConstraintSeverity.ERROR); 362 break; 363 case WARNING: 364 tgt.setValue(ElementDefinition.ConstraintSeverity.WARNING); 365 break; 366 default: 367 tgt.setValue(ElementDefinition.ConstraintSeverity.NULL); 368 break; 369 } 370 } 371 return tgt; 372 } 373 374 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity> convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration<ElementDefinition.ConstraintSeverity> src) throws FHIRException { 375 if (src == null || src.isEmpty()) return null; 376 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); 377 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 378 if (src.getValue() == null) { 379 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); 380 } else { 381 switch (src.getValue()) { 382 case ERROR: 383 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); 384 break; 385 case WARNING: 386 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); 387 break; 388 default: 389 tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); 390 break; 391 } 392 } 393 return tgt; 394 } 395 396 public static ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { 397 if (src == null || src.isEmpty()) return null; 398 ElementDefinition.ElementDefinitionBindingComponent tgt = new ElementDefinition.ElementDefinitionBindingComponent(); 399 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 400 if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); 401 if (src.hasDescriptionElement()) tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 402 if (src.hasValueSet()) 403 tgt.setValueSet(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getValueSet())); 404 return tgt; 405 } 406 407 public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { 408 if (src == null || src.isEmpty()) return null; 409 org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); 410 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 411 if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); 412 if (src.hasDescriptionElement()) tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 413 if (src.hasValueSet()) 414 tgt.setValueSet(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getValueSet())); 415 return tgt; 416 } 417 418 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Enumerations.BindingStrength> convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Enumerations.BindingStrength> src) throws FHIRException { 419 if (src == null || src.isEmpty()) return null; 420 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Enumerations.BindingStrength> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); 421 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 422 if (src.getValue() == null) { 423 tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); 424 } else { 425 switch (src.getValue()) { 426 case REQUIRED: 427 tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); 428 break; 429 case EXTENSIBLE: 430 tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); 431 break; 432 case PREFERRED: 433 tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); 434 break; 435 case EXAMPLE: 436 tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); 437 break; 438 default: 439 tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); 440 break; 441 } 442 } 443 return tgt; 444 } 445 446 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Enumerations.BindingStrength> convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Enumerations.BindingStrength> src) throws FHIRException { 447 if (src == null || src.isEmpty()) return null; 448 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Enumerations.BindingStrength> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); 449 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 450 if (src.getValue() == null) { 451 tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); 452 } else { 453 switch (src.getValue()) { 454 case REQUIRED: 455 tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); 456 break; 457 case EXTENSIBLE: 458 tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); 459 break; 460 case PREFERRED: 461 tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); 462 break; 463 case EXAMPLE: 464 tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); 465 break; 466 default: 467 tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); 468 break; 469 } 470 } 471 return tgt; 472 } 473 474 public static ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { 475 if (src == null || src.isEmpty()) return null; 476 ElementDefinition.ElementDefinitionMappingComponent tgt = new ElementDefinition.ElementDefinitionMappingComponent(); 477 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 478 if (src.hasIdentityElement()) tgt.setIdentityElement(Id10_30.convertId(src.getIdentityElement())); 479 if (src.hasLanguageElement()) tgt.setLanguageElement(Code10_30.convertCode(src.getLanguageElement())); 480 if (src.hasMapElement()) tgt.setMapElement(String10_30.convertString(src.getMapElement())); 481 return tgt; 482 } 483 484 public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { 485 if (src == null || src.isEmpty()) return null; 486 org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); 487 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 488 if (src.hasIdentityElement()) tgt.setIdentityElement(Id10_30.convertId(src.getIdentityElement())); 489 if (src.hasLanguageElement()) tgt.setLanguageElement(Code10_30.convertCode(src.getLanguageElement())); 490 if (src.hasMapElement()) tgt.setMapElement(String10_30.convertString(src.getMapElement())); 491 return tgt; 492 } 493}