001package org.hl7.fhir.convertors.conv10_30.resources10_30; 002 003import java.util.ArrayList; 004import java.util.List; 005 006import org.hl7.fhir.convertors.context.ConversionContext10_30; 007import org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30; 008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.ElementDefinition10_30; 009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.CodeableConcept10_30; 010import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Coding10_30; 011import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.ContactPoint10_30; 012import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Identifier10_30; 013import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Boolean10_30; 014import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Code10_30; 015import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.DateTime10_30; 016import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Id10_30; 017import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30; 018import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Uri10_30; 019import org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind; 020import org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule; 021import org.hl7.fhir.exceptions.FHIRException; 022import org.hl7.fhir.utilities.Utilities; 023 024public class StructureDefinition10_30 { 025 026 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext> convertExtensionContext(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> src) throws FHIRException { 027 if (src == null || src.isEmpty()) 028 return null; 029 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContextEnumFactory()); 030 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 031 switch (src.getValue()) { 032 case RESOURCE: 033 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.RESOURCE); 034 break; 035 case DATATYPE: 036 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.DATATYPE); 037 break; 038 case EXTENSION: 039 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.EXTENSION); 040 break; 041 default: 042 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.NULL); 043 break; 044 } 045 return tgt; 046 } 047 048 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> convertExtensionContext(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext> src) throws FHIRException { 049 if (src == null || src.isEmpty()) 050 return null; 051 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContextEnumFactory()); 052 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 053 switch (src.getValue()) { 054 case RESOURCE: 055 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.RESOURCE); 056 break; 057 case DATATYPE: 058 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.DATATYPE); 059 break; 060 case EXTENSION: 061 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.EXTENSION); 062 break; 063 default: 064 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.NULL); 065 break; 066 } 067 return tgt; 068 } 069 070 public static org.hl7.fhir.dstu2.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition src) throws FHIRException { 071 if (src == null || src.isEmpty()) 072 return null; 073 org.hl7.fhir.dstu2.model.StructureDefinition tgt = new org.hl7.fhir.dstu2.model.StructureDefinition(); 074 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 075 if (src.hasUrlElement()) 076 tgt.setUrlElement(Uri10_30.convertUri(src.getUrlElement())); 077 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 078 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 079 if (src.hasVersionElement()) 080 tgt.setVersionElement(String10_30.convertString(src.getVersionElement())); 081 if (src.hasNameElement()) 082 tgt.setNameElement(String10_30.convertString(src.getNameElement())); 083 if (src.hasTitleElement()) 084 tgt.setDisplayElement(String10_30.convertString(src.getTitleElement())); 085 if (src.hasStatus()) 086 tgt.setStatusElement(Enumerations10_30.convertConformanceResourceStatus(src.getStatusElement())); 087 if (src.hasExperimental()) 088 tgt.setExperimentalElement(Boolean10_30.convertBoolean(src.getExperimentalElement())); 089 if (src.hasPublisherElement()) 090 tgt.setPublisherElement(String10_30.convertString(src.getPublisherElement())); 091 for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) 092 tgt.addContact(convertStructureDefinitionContactComponent(t)); 093 if (src.hasDate()) 094 tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement())); 095 if (src.hasDescription()) 096 tgt.setDescription(src.getDescription()); 097 for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext()) 098 if (t.hasValueCodeableConcept()) 099 tgt.addUseContext(CodeableConcept10_30.convertCodeableConcept(t.getValueCodeableConcept())); 100 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction()) 101 tgt.addUseContext(CodeableConcept10_30.convertCodeableConcept(t)); 102 if (src.hasPurpose()) 103 tgt.setRequirements(src.getPurpose()); 104 if (src.hasCopyright()) 105 tgt.setCopyright(src.getCopyright()); 106 for (org.hl7.fhir.dstu3.model.Coding t : src.getKeyword()) tgt.addCode(Coding10_30.convertCoding(t)); 107 if (src.hasFhirVersionElement()) 108 tgt.setFhirVersionElement(Id10_30.convertId(src.getFhirVersionElement())); 109 for (org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) 110 tgt.addMapping(convertStructureDefinitionMappingComponent(t)); 111 if (src.hasKind()) 112 tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement())); 113 if (src.hasAbstractElement()) 114 tgt.setAbstractElement(Boolean10_30.convertBoolean(src.getAbstractElement())); 115 if (src.hasContextType()) 116 tgt.setContextTypeElement(convertExtensionContext(src.getContextTypeElement())); 117 for (org.hl7.fhir.dstu3.model.StringType t : src.getContext()) tgt.addContext(t.getValue()); 118 if (src.hasTypeElement()) 119 tgt.setConstrainedTypeElement(Code10_30.convertCode(src.getTypeElement())); 120 if (src.hasBaseDefinitionElement()) 121 tgt.setBaseElement(Uri10_30.convertUri(src.getBaseDefinitionElement())); 122 if (src.hasSnapshot()) 123 tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); 124 if (src.hasDifferential()) 125 tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); 126 if (tgt.hasBase()) { 127 if (tgt.hasDifferential()) 128 tgt.getDifferential().getElement().get(0).addType().setCode(tail(tgt.getBase())); 129 if (tgt.hasSnapshot()) 130 tgt.getSnapshot().getElement().get(0).addType().setCode(tail(tgt.getBase())); 131 } 132 return tgt; 133 } 134 135 public static org.hl7.fhir.dstu3.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition src) throws FHIRException { 136 if (src == null || src.isEmpty()) 137 return null; 138 org.hl7.fhir.dstu3.model.StructureDefinition tgt = new org.hl7.fhir.dstu3.model.StructureDefinition(); 139 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 140 if (src.hasUrlElement()) 141 tgt.setUrlElement(Uri10_30.convertUri(src.getUrlElement())); 142 for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) 143 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 144 if (src.hasVersionElement()) 145 tgt.setVersionElement(String10_30.convertString(src.getVersionElement())); 146 if (src.hasNameElement()) 147 tgt.setNameElement(String10_30.convertString(src.getNameElement())); 148 if (src.hasDisplayElement()) 149 tgt.setTitleElement(String10_30.convertString(src.getDisplayElement())); 150 if (src.hasStatus()) 151 tgt.setStatusElement(Enumerations10_30.convertConformanceResourceStatus(src.getStatusElement())); 152 if (src.hasExperimental()) 153 tgt.setExperimentalElement(Boolean10_30.convertBoolean(src.getExperimentalElement())); 154 if (src.hasPublisherElement()) 155 tgt.setPublisherElement(String10_30.convertString(src.getPublisherElement())); 156 for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact()) 157 tgt.addContact(convertStructureDefinitionContactComponent(t)); 158 if (src.hasDate()) 159 tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement())); 160 if (src.hasDescription()) 161 tgt.setDescription(src.getDescription()); 162 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) 163 if (VersionConvertor_10_30.isJurisdiction(t)) 164 tgt.addJurisdiction(CodeableConcept10_30.convertCodeableConcept(t)); 165 else 166 tgt.addUseContext(CodeableConcept10_30.convertCodeableConceptToUsageContext(t)); 167 if (src.hasRequirements()) 168 tgt.setPurpose(src.getRequirements()); 169 if (src.hasCopyright()) 170 tgt.setCopyright(src.getCopyright()); 171 for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addKeyword(Coding10_30.convertCoding(t)); 172 if (src.hasFhirVersionElement()) 173 tgt.setFhirVersionElement(Id10_30.convertId(src.getFhirVersionElement())); 174 for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) 175 tgt.addMapping(convertStructureDefinitionMappingComponent(t)); 176 if (src.hasKind()) 177 tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement(), tgt.getId())); 178 if (src.hasAbstractElement()) 179 tgt.setAbstractElement(Boolean10_30.convertBoolean(src.getAbstractElement())); 180 if (src.hasContextType()) 181 tgt.setContextTypeElement(convertExtensionContext(src.getContextTypeElement())); 182 for (org.hl7.fhir.dstu2.model.StringType t : src.getContext()) tgt.addContext(t.getValue()); 183 if (src.hasConstrainedType()) 184 tgt.setTypeElement(Code10_30.convertCode(src.getConstrainedTypeElement())); 185 else if (src.getSnapshot().hasElement()) 186 tgt.setType(src.getSnapshot().getElement().get(0).getPath()); 187 else if (src.getDifferential().hasElement() && !src.getDifferential().getElement().get(0).getPath().contains(".")) 188 tgt.setType(src.getDifferential().getElement().get(0).getPath()); 189 else 190 tgt.setType(src.getDifferential().getElement().get(0).getPath().substring(0, src.getDifferential().getElement().get(0).getPath().indexOf("."))); 191 if (src.hasBaseElement()) 192 tgt.setBaseDefinitionElement(Uri10_30.convertUri(src.getBaseElement())); 193 tgt.setDerivation(src.hasConstrainedType() ? org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.CONSTRAINT : org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION); 194 if (src.hasSnapshot()) 195 tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); 196 if (src.hasDifferential()) 197 tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); 198 if (tgt.hasSnapshot()) 199 tgt.getSnapshot().getElementFirstRep().getType().clear(); 200 if (tgt.hasDifferential()) 201 tgt.getDifferential().getElementFirstRep().getType().clear(); 202 if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getId())) { 203 tgt.setDerivation(TypeDerivationRule.SPECIALIZATION); 204 tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + tgt.getType()); 205 tgt.setType(tgt.getId()); 206 } 207 return tgt; 208 } 209 210 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent convertStructureDefinitionContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { 211 if (src == null || src.isEmpty()) 212 return null; 213 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent(); 214 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 215 if (src.hasNameElement()) 216 tgt.setNameElement(String10_30.convertString(src.getNameElement())); 217 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) 218 tgt.addTelecom(ContactPoint10_30.convertContactPoint(t)); 219 return tgt; 220 } 221 222 public static org.hl7.fhir.dstu3.model.ContactDetail convertStructureDefinitionContactComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent src) throws FHIRException { 223 if (src == null || src.isEmpty()) 224 return null; 225 org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); 226 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 227 if (src.hasNameElement()) 228 tgt.setNameElement(String10_30.convertString(src.getNameElement())); 229 for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) 230 tgt.addTelecom(ContactPoint10_30.convertContactPoint(t)); 231 return tgt; 232 } 233 234 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { 235 if (src == null || src.isEmpty()) 236 return null; 237 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent(); 238 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 239 for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement()) 240 tgt.addElement(ElementDefinition10_30.convertElementDefinition(t)); 241 return tgt; 242 } 243 244 public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { 245 if (src == null || src.isEmpty()) 246 return null; 247 org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent(); 248 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 249 List<String> slicePaths = new ArrayList<String>(); 250 for (org.hl7.fhir.dstu2.model.ElementDefinition t : src.getElement()) { 251 if (t.hasSlicing()) 252 slicePaths.add(t.getPath()); 253 tgt.addElement(ElementDefinition10_30.convertElementDefinition(t, slicePaths)); 254 } 255 return tgt; 256 } 257 258 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind> src) throws FHIRException { 259 if (src == null || src.isEmpty()) 260 return null; 261 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKindEnumFactory()); 262 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 263 switch (src.getValue()) { 264 case PRIMITIVETYPE: 265 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.DATATYPE); 266 break; 267 case COMPLEXTYPE: 268 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.DATATYPE); 269 break; 270 case RESOURCE: 271 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.RESOURCE); 272 break; 273 case LOGICAL: 274 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.LOGICAL); 275 break; 276 default: 277 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.NULL); 278 break; 279 } 280 return tgt; 281 } 282 283 public static org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> src, String dtName) throws FHIRException { 284 if (src == null || src.isEmpty()) 285 return null; 286 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKindEnumFactory()); 287 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 288 switch (src.getValue()) { 289 case DATATYPE: 290 if (Utilities.existsInList(dtName, "boolean", "integer", "decimal", "base64Binary", "instant", 291 "string", "uri", "date", "dateTime", "time", "code", "oid", "uuid", "id", "unsignedInt", 292 "positiveInt", "markdown", "xhtml", "url", "canonical")) 293 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE); 294 else 295 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE); 296 break; 297 case RESOURCE: 298 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.RESOURCE); 299 break; 300 case LOGICAL: 301 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.LOGICAL); 302 break; 303 default: 304 tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.NULL); 305 break; 306 } 307 return tgt; 308 } 309 310 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { 311 if (src == null || src.isEmpty()) 312 return null; 313 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent(); 314 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 315 if (src.hasIdentityElement()) 316 tgt.setIdentityElement(Id10_30.convertId(src.getIdentityElement())); 317 if (src.hasUriElement()) 318 tgt.setUriElement(Uri10_30.convertUri(src.getUriElement())); 319 if (src.hasNameElement()) 320 tgt.setNameElement(String10_30.convertString(src.getNameElement())); 321 if (src.hasCommentElement()) 322 tgt.setCommentsElement(String10_30.convertString(src.getCommentElement())); 323 return tgt; 324 } 325 326 public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { 327 if (src == null || src.isEmpty()) 328 return null; 329 org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent(); 330 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 331 if (src.hasIdentityElement()) 332 tgt.setIdentityElement(Id10_30.convertId(src.getIdentityElement())); 333 if (src.hasUriElement()) 334 tgt.setUriElement(Uri10_30.convertUri(src.getUriElement())); 335 if (src.hasNameElement()) 336 tgt.setNameElement(String10_30.convertString(src.getNameElement())); 337 if (src.hasCommentsElement()) 338 tgt.setCommentElement(String10_30.convertString(src.getCommentsElement())); 339 return tgt; 340 } 341 342 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { 343 if (src == null || src.isEmpty()) 344 return null; 345 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent(); 346 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 347 for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement()) 348 tgt.addElement(ElementDefinition10_30.convertElementDefinition(t)); 349 return tgt; 350 } 351 352 public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { 353 if (src == null || src.isEmpty()) 354 return null; 355 org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent(); 356 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 357 List<String> slicePaths = new ArrayList<String>(); 358 for (org.hl7.fhir.dstu2.model.ElementDefinition t : src.getElement()) { 359 if (t.hasSlicing()) 360 slicePaths.add(t.getPath()); 361 tgt.addElement(ElementDefinition10_30.convertElementDefinition(t, slicePaths)); 362 } 363 return tgt; 364 } 365 366 static public String tail(String base) { 367 return base.substring(base.lastIndexOf("/") + 1); 368 } 369}