
001package org.hl7.fhir.convertors.conv10_50.resources10_50; 002 003import java.util.ArrayList; 004import java.util.List; 005 006import org.hl7.fhir.convertors.context.ConversionContext10_50; 007import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50; 008import org.hl7.fhir.convertors.conv10_50.datatypes10_50.ElementDefinition10_50; 009import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.CodeableConcept10_50; 010import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Coding10_50; 011import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.ContactPoint10_50; 012import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Identifier10_50; 013import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Boolean10_50; 014import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.DateTime10_50; 015import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Id10_50; 016import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.String10_50; 017import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Uri10_50; 018import org.hl7.fhir.exceptions.FHIRException; 019import org.hl7.fhir.r5.model.ElementDefinition; 020import org.hl7.fhir.r5.model.Enumeration; 021import org.hl7.fhir.r5.model.StructureDefinition; 022import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; 023import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; 024import org.hl7.fhir.utilities.Utilities; 025 026public class StructureDefinition10_50 { 027 028 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType> convertExtensionContext(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> src) throws FHIRException { 029 if (src == null || src.isEmpty()) 030 return null; 031 Enumeration<StructureDefinition.ExtensionContextType> tgt = new Enumeration<>(new StructureDefinition.ExtensionContextTypeEnumFactory()); 032 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 033 if (src.getValue() == null) { 034 tgt.setValue(null); 035 } else { 036 switch (src.getValue()) { 037 case RESOURCE: 038 tgt.setValue(StructureDefinition.ExtensionContextType.ELEMENT); 039 break; 040 case DATATYPE: 041 tgt.setValue(StructureDefinition.ExtensionContextType.ELEMENT); 042 break; 043 case EXTENSION: 044 tgt.setValue(StructureDefinition.ExtensionContextType.EXTENSION); 045 break; 046 default: 047 tgt.setValue(StructureDefinition.ExtensionContextType.NULL); 048 break; 049 } 050 } 051 return tgt; 052 } 053 054 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> convertExtensionContext(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType> src, String expression) throws FHIRException { 055 if (src == null || src.isEmpty()) 056 return null; 057 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()); 058 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 059 if (src.getValue() == null) { 060 tgt.setValue(null); 061 } else { 062 switch (src.getValue()) { 063 case FHIRPATH: 064 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.RESOURCE); 065 break; 066 case ELEMENT: 067 String tn = expression.contains(".") ? expression.substring(0, expression.indexOf(".")) : expression; 068 if (isResource102(tn)) { 069 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.RESOURCE); 070 } else { 071 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.DATATYPE); 072 } 073 break; 074 case EXTENSION: 075 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.EXTENSION); 076 break; 077 default: 078 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.NULL); 079 break; 080 } 081 } 082 return tgt; 083 } 084 085 public static org.hl7.fhir.dstu2.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r5.model.StructureDefinition src) throws FHIRException { 086 if (src == null || src.isEmpty()) 087 return null; 088 org.hl7.fhir.dstu2.model.StructureDefinition tgt = new org.hl7.fhir.dstu2.model.StructureDefinition(); 089 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt); 090 if (src.hasUrlElement()) 091 tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement())); 092 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 093 tgt.addIdentifier(Identifier10_50.convertIdentifier(t)); 094 if (src.hasVersionElement()) 095 tgt.setVersionElement(String10_50.convertString(src.getVersionElement())); 096 if (src.hasNameElement()) 097 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 098 if (src.hasTitleElement()) 099 tgt.setDisplayElement(String10_50.convertString(src.getTitleElement())); 100 if (src.hasStatus()) 101 tgt.setStatusElement(Enumerations10_50.convertConformanceResourceStatus(src.getStatusElement())); 102 if (src.hasExperimental()) 103 tgt.setExperimentalElement(Boolean10_50.convertBoolean(src.getExperimentalElement())); 104 if (src.hasPublisherElement()) 105 tgt.setPublisherElement(String10_50.convertString(src.getPublisherElement())); 106 for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) 107 tgt.addContact(convertStructureDefinitionContactComponent(t)); 108 if (src.hasDate()) 109 tgt.setDateElement(DateTime10_50.convertDateTime(src.getDateElement())); 110 if (src.hasDescription()) 111 tgt.setDescription(src.getDescription()); 112 for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext()) 113 if (t.hasValueCodeableConcept()) 114 tgt.addUseContext(CodeableConcept10_50.convertCodeableConcept(t.getValueCodeableConcept())); 115 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction()) 116 tgt.addUseContext(CodeableConcept10_50.convertCodeableConcept(t)); 117 if (src.hasPurpose()) 118 tgt.setRequirements(src.getPurpose()); 119 if (src.hasCopyright()) 120 tgt.setCopyright(src.getCopyright()); 121 for (org.hl7.fhir.r5.model.Coding t : src.getKeyword()) tgt.addCode(Coding10_50.convertCoding(t)); 122 if (src.hasFhirVersion()) 123 tgt.setFhirVersion(src.getFhirVersion().toCode()); 124 for (org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) 125 tgt.addMapping(convertStructureDefinitionMappingComponent(t)); 126 if (src.hasKind()) 127 tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement())); 128 if (src.hasAbstractElement()) 129 tgt.setAbstractElement(Boolean10_50.convertBoolean(src.getAbstractElement())); 130 for (org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent t : src.getContext()) { 131 if (!tgt.hasContextType()) 132 tgt.setContextTypeElement(convertExtensionContext(t.getTypeElement(), t.getExpression())); 133 tgt.addContext("Element".equals(t.getExpression()) ? "*" : t.getExpression()); 134 } 135 if (src.hasType()) 136 tgt.setConstrainedType(src.getType()); 137 if (src.hasBaseDefinition()) 138 tgt.setBase(src.getBaseDefinition()); 139 if (src.hasSnapshot()) 140 tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); 141 if (src.hasDifferential()) 142 tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); 143 if (tgt.hasBase()) { 144 if (tgt.hasDifferential()) 145 tgt.getDifferential().getElement().get(0).addType().setCode(tail(tgt.getBase())); 146 if (tgt.hasSnapshot()) 147 tgt.getSnapshot().getElement().get(0).addType().setCode(tail(tgt.getBase())); 148 } 149 return tgt; 150 } 151 152 public static org.hl7.fhir.r5.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition src) throws FHIRException { 153 if (src == null || src.isEmpty()) 154 return null; 155 org.hl7.fhir.r5.model.StructureDefinition tgt = new org.hl7.fhir.r5.model.StructureDefinition(); 156 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt); 157 if (src.hasUrlElement()) 158 tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement())); 159 for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) 160 tgt.addIdentifier(Identifier10_50.convertIdentifier(t)); 161 if (src.hasVersionElement()) 162 tgt.setVersionElement(String10_50.convertString(src.getVersionElement())); 163 if (src.hasNameElement()) 164 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 165 if (src.hasDisplayElement()) 166 tgt.setTitleElement(String10_50.convertString(src.getDisplayElement())); 167 if (src.hasStatus()) 168 tgt.setStatusElement(Enumerations10_50.convertConformanceResourceStatus(src.getStatusElement())); 169 if (src.hasExperimental()) 170 tgt.setExperimentalElement(Boolean10_50.convertBoolean(src.getExperimentalElement())); 171 if (src.hasPublisherElement()) 172 tgt.setPublisherElement(String10_50.convertString(src.getPublisherElement())); 173 for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact()) 174 tgt.addContact(convertStructureDefinitionContactComponent(t)); 175 if (src.hasDate()) 176 tgt.setDateElement(DateTime10_50.convertDateTime(src.getDateElement())); 177 if (src.hasDescription()) 178 tgt.setDescription(src.getDescription()); 179 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) 180 if (VersionConvertor_10_50.isJurisdiction(t)) 181 tgt.addJurisdiction(CodeableConcept10_50.convertCodeableConcept(t)); 182 else 183 tgt.addUseContext(CodeableConcept10_50.convertCodeableConceptToUsageContext(t)); 184 if (src.hasRequirements()) 185 tgt.setPurpose(src.getRequirements()); 186 if (src.hasCopyright()) 187 tgt.setCopyright(src.getCopyright()); 188 for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addKeyword(Coding10_50.convertCoding(t)); 189 if (src.hasFhirVersion()) 190 tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); 191 for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) 192 tgt.addMapping(convertStructureDefinitionMappingComponent(t)); 193 if (src.hasKind()) 194 tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement(), tgt.getIdElement().getIdPart())); 195 if (src.hasAbstractElement()) 196 tgt.setAbstractElement(Boolean10_50.convertBoolean(src.getAbstractElement())); 197 for (org.hl7.fhir.dstu2.model.StringType t : src.getContext()) { 198 org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent ec = tgt.addContext(); 199 ec.setTypeElement(convertExtensionContext(src.getContextTypeElement())); 200 ec.setExpression("*".equals(t.getValue()) ? "Element" : t.getValue()); 201 } 202 if (src.hasConstrainedType()) 203 tgt.setType(src.getConstrainedType()); 204 else if (src.getSnapshot().hasElement()) 205 tgt.setType(src.getSnapshot().getElement().get(0).getPath()); 206 else if (src.getDifferential().hasElement() && !src.getDifferential().getElement().get(0).getPath().contains(".")) 207 tgt.setType(src.getDifferential().getElement().get(0).getPath()); 208 else 209 tgt.setType(src.getDifferential().getElement().get(0).getPath().substring(0, src.getDifferential().getElement().get(0).getPath().indexOf("."))); 210 if (src.hasBase()) 211 tgt.setBaseDefinition(src.getBase()); 212 tgt.setDerivation(src.hasConstrainedType() ? org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.CONSTRAINT : org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION); 213 if (src.hasSnapshot()) 214 tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); 215 if (src.hasDifferential()) 216 tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); 217 if (tgt.hasSnapshot()) 218 tgt.getSnapshot().getElementFirstRep().getType().clear(); 219 if (tgt.hasDifferential()) 220 tgt.getDifferential().getElementFirstRep().getType().clear(); 221 if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getIdElement().getIdPart())) { 222 tgt.setDerivation(TypeDerivationRule.SPECIALIZATION); 223 tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + tgt.getType()); 224 tgt.setType(tgt.getIdElement().getIdPart()); 225 } 226 if (tgt.getDerivation() == TypeDerivationRule.SPECIALIZATION) { 227 for (ElementDefinition ed : tgt.getSnapshot().getElement()) { 228 if (!ed.hasBase()) { 229 ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); 230 } 231 } 232 } 233 return tgt; 234 } 235 236 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent convertStructureDefinitionContactComponent(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException { 237 if (src == null || src.isEmpty()) 238 return null; 239 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent(); 240 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 241 if (src.hasNameElement()) 242 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 243 for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) 244 tgt.addTelecom(ContactPoint10_50.convertContactPoint(t)); 245 return tgt; 246 } 247 248 public static org.hl7.fhir.r5.model.ContactDetail convertStructureDefinitionContactComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent src) throws FHIRException { 249 if (src == null || src.isEmpty()) 250 return null; 251 org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail(); 252 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 253 if (src.hasNameElement()) 254 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 255 for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) 256 tgt.addTelecom(ContactPoint10_50.convertContactPoint(t)); 257 return tgt; 258 } 259 260 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { 261 if (src == null || src.isEmpty()) 262 return null; 263 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent(); 264 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 265 for (org.hl7.fhir.r5.model.ElementDefinition t : src.getElement()) 266 tgt.addElement(ElementDefinition10_50.convertElementDefinition(t)); 267 return tgt; 268 } 269 270 public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { 271 if (src == null || src.isEmpty()) 272 return null; 273 org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent(); 274 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 275 List<String> slicePaths = new ArrayList<String>(); 276 for (org.hl7.fhir.dstu2.model.ElementDefinition t : src.getElement()) { 277 if (t.hasSlicing()) 278 slicePaths.add(t.getPath()); 279 tgt.addElement(ElementDefinition10_50.convertElementDefinition(t, slicePaths, src.getElement(), src.getElement().indexOf(t))); 280 } 281 return tgt; 282 } 283 284 public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> src, String dtName) throws FHIRException { 285 if (src == null || src.isEmpty()) 286 return null; 287 Enumeration<StructureDefinitionKind> tgt = new Enumeration<>(new StructureDefinition.StructureDefinitionKindEnumFactory()); 288 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 289 if (src.getValue() == null) { 290 tgt.setValue(null); 291 } else { 292 switch (src.getValue()) { 293 case DATATYPE: 294 if (Utilities.existsInList(dtName, "boolean", "integer", "integer64", "decimal", "base64Binary", 295 "instant", "string", "uri", "date", "dateTime", "time", "code", "oid", "uuid", "id", 296 "unsignedInt", "positiveInt", "markdown", "xhtml", "url", "canonical")) { 297 tgt.setValue(StructureDefinitionKind.PRIMITIVETYPE); 298 } else { 299 tgt.setValue(StructureDefinitionKind.COMPLEXTYPE); 300 } 301 break; 302 case RESOURCE: 303 tgt.setValue(StructureDefinitionKind.RESOURCE); 304 break; 305 case LOGICAL: 306 tgt.setValue(StructureDefinitionKind.LOGICAL); 307 break; 308 default: 309 tgt.setValue(StructureDefinitionKind.NULL); 310 break; 311 } 312 } 313 return tgt; 314 } 315 316 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind> src) throws FHIRException { 317 if (src == null || src.isEmpty()) 318 return null; 319 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()); 320 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 321 if (src.getValue() == null) { 322 tgt.setValue(null); 323 } else { 324 switch (src.getValue()) { 325 case PRIMITIVETYPE: 326 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.DATATYPE); 327 break; 328 case COMPLEXTYPE: 329 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.DATATYPE); 330 break; 331 case RESOURCE: 332 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.RESOURCE); 333 break; 334 case LOGICAL: 335 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.LOGICAL); 336 break; 337 default: 338 tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.NULL); 339 break; 340 } 341 } 342 return tgt; 343 } 344 345 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { 346 if (src == null || src.isEmpty()) 347 return null; 348 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent(); 349 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 350 if (src.hasIdentityElement()) 351 tgt.setIdentityElement(Id10_50.convertId(src.getIdentityElement())); 352 if (src.hasUriElement()) 353 tgt.setUriElement(Uri10_50.convertUri(src.getUriElement())); 354 if (src.hasNameElement()) 355 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 356 if (src.hasCommentElement()) 357 tgt.setCommentsElement(String10_50.convertString(src.getCommentElement())); 358 return tgt; 359 } 360 361 public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { 362 if (src == null || src.isEmpty()) 363 return null; 364 org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent(); 365 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 366 if (src.hasIdentityElement()) 367 tgt.setIdentityElement(Id10_50.convertId(src.getIdentityElement())); 368 if (src.hasUriElement()) 369 tgt.setUriElement(Uri10_50.convertUri(src.getUriElement())); 370 if (src.hasNameElement()) 371 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 372 if (src.hasCommentsElement()) 373 tgt.setCommentElement(String10_50.convertString(src.getCommentsElement())); 374 return tgt; 375 } 376 377 public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { 378 if (src == null || src.isEmpty()) 379 return null; 380 org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent(); 381 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 382 List<String> slicePaths = new ArrayList<String>(); 383 for (org.hl7.fhir.dstu2.model.ElementDefinition t : src.getElement()) { 384 if (t.hasSlicing()) 385 slicePaths.add(t.getPath()); 386 tgt.addElement(ElementDefinition10_50.convertElementDefinition(t, slicePaths, src.getElement(), src.getElement().indexOf(t))); 387 } 388 return tgt; 389 } 390 391 public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { 392 if (src == null || src.isEmpty()) 393 return null; 394 org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent(); 395 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 396 for (org.hl7.fhir.r5.model.ElementDefinition t : src.getElement()) 397 tgt.addElement(ElementDefinition10_50.convertElementDefinition(t)); 398 return tgt; 399 } 400 401 static public boolean isResource102(String tn) { 402 return Utilities.existsInList(tn, "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodySite", "Bundle", "CarePlan", "Claim", "ClaimResponse", "ClinicalImpression", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "Conformance", "Contract", "DetectedIssue", "Coverage", "DataElement", "Device", "DeviceComponent", "DeviceMetric", "DeviceUseRequest", "DeviceUseStatement", "DiagnosticOrder", "DiagnosticReport", "DocumentManifest", "DocumentReference", "EligibilityRequest", "EligibilityResponse", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "ExplanationOfBenefit", "FamilyMemberHistory", "Flag", "Goal", "Group", "HealthcareService", "ImagingObjectSelection", "ImagingStudy", "Immunization", "ImmunizationRecommendation", "ImplementationGuide", "List", "Location", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationOrder", "MedicationStatement", "MessageHeader", "NamingSystem", "NutritionOrder", "Observation", "OperationDefinition", "OperationOutcome", "Order", "OrderResponse", "Organization", "Parameters", "Patient", "PaymentNotice", "PaymentReconciliation", "Person", "Practitioner", "Procedure", "ProcessRequest", "ProcessResponse", "ProcedureRequest", "Provenance", "Questionnaire", "QuestionnaireResponse", "ReferralRequest", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "Specimen", "StructureDefinition", "Subscription", "Substance", "SupplyRequest", "SupplyDelivery", "TestScript", "ValueSet", "VisionPrescription"); 403 } 404 405 static public String tail(String base) { 406 return base.substring(base.lastIndexOf("/") + 1); 407 } 408}