
001package org.hl7.fhir.convertors.conv10_40.resources10_40; 002 003import java.util.List; 004 005import org.hl7.fhir.convertors.VersionConvertorConstants; 006import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40; 007import org.hl7.fhir.convertors.context.ConversionContext10_40; 008import org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40; 009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40; 010import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Coding10_40; 011import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.ContactPoint10_40; 012import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40; 013import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Boolean10_40; 014import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Code10_40; 015import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.DateTime10_40; 016import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Integer10_40; 017import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40; 018import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Uri10_40; 019import org.hl7.fhir.dstu2.model.ValueSet; 020import org.hl7.fhir.exceptions.FHIRException; 021import org.hl7.fhir.r4.model.BooleanType; 022import org.hl7.fhir.r4.model.CodeSystem; 023import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode; 024import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent; 025import org.hl7.fhir.r4.model.Enumeration; 026import org.hl7.fhir.r4.terminologies.CodeSystemUtilities; 027 028public class ValueSet10_40 { 029 030 public static org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent src) throws FHIRException { 031 if (src == null || src.isEmpty()) 032 return null; 033 org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent(); 034 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 035 if (src.hasCodeElement()) 036 tgt.setCodeElement(Code10_40.convertCode(src.getCodeElement())); 037 if (src.hasDisplayElement()) 038 tgt.setDisplayElement(String10_40.convertString(src.getDisplayElement())); 039 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent t : src.getDesignation()) 040 tgt.addDesignation(convertConceptReferenceDesignationComponent(t)); 041 return tgt; 042 } 043 044 public static org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent src) throws FHIRException { 045 if (src == null || src.isEmpty()) 046 return null; 047 org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent(); 048 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 049 if (src.hasCodeElement()) 050 tgt.setCodeElement(Code10_40.convertCode(src.getCodeElement())); 051 if (src.hasDisplayElement()) 052 tgt.setDisplayElement(String10_40.convertString(src.getDisplayElement())); 053 for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation()) 054 tgt.addDesignation(convertConceptReferenceDesignationComponent(t)); 055 return tgt; 056 } 057 058 public static org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent src) throws FHIRException { 059 if (src == null || src.isEmpty()) 060 return null; 061 org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent(); 062 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 063 if (src.hasLanguageElement()) 064 tgt.setLanguageElement(Code10_40.convertCode(src.getLanguageElement())); 065 if (src.hasUse()) 066 tgt.setUse(Coding10_40.convertCoding(src.getUse())); 067 if (src.hasValueElement()) 068 tgt.setValueElement(String10_40.convertString(src.getValueElement())); 069 return tgt; 070 } 071 072 public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException { 073 if (src == null || src.isEmpty()) 074 return null; 075 org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); 076 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 077 if (src.hasLanguageElement()) 078 tgt.setLanguageElement(Code10_40.convertCode(src.getLanguageElement())); 079 if (src.hasUse()) 080 tgt.setUse(Coding10_40.convertCoding(src.getUse())); 081 if (src.hasValueElement()) 082 tgt.setValueElement(String10_40.convertString(src.getValueElement())); 083 return tgt; 084 } 085 086 public static org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent src) throws FHIRException { 087 if (src == null || src.isEmpty()) 088 return null; 089 org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent(); 090 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 091 if (src.hasSystemElement()) 092 tgt.setSystemElement(Uri10_40.convertUri(src.getSystemElement())); 093 if (src.hasVersionElement()) 094 tgt.setVersionElement(String10_40.convertString(src.getVersionElement())); 095 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) 096 tgt.addConcept(convertConceptReferenceComponent(t)); 097 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) 098 tgt.addFilter(convertConceptSetFilterComponent(t)); 099 return tgt; 100 } 101 102 public static org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent src) throws FHIRException { 103 if (src == null || src.isEmpty()) 104 return null; 105 org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent(); 106 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 107 if (src.hasSystemElement()) 108 tgt.setSystemElement(Uri10_40.convertUri(src.getSystemElement())); 109 if (src.hasVersionElement()) 110 tgt.setVersionElement(String10_40.convertString(src.getVersionElement())); 111 for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) 112 tgt.addConcept(convertConceptReferenceComponent(t)); 113 for (org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) 114 tgt.addFilter(convertConceptSetFilterComponent(t)); 115 return tgt; 116 } 117 118 public static org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException { 119 if (src == null || src.isEmpty()) 120 return null; 121 org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent(); 122 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 123 if (src.hasPropertyElement()) 124 tgt.setPropertyElement(Code10_40.convertCode(src.getPropertyElement())); 125 if (src.hasOp()) 126 tgt.setOpElement(convertFilterOperator(src.getOpElement())); 127 if (src.hasValue()) 128 tgt.setValue(src.getValue()); 129 return tgt; 130 } 131 132 public static org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException { 133 if (src == null || src.isEmpty()) 134 return null; 135 org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent(); 136 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 137 if (src.hasPropertyElement()) 138 tgt.setPropertyElement(Code10_40.convertCode(src.getPropertyElement())); 139 if (src.hasOp()) 140 tgt.setOpElement(convertFilterOperator(src.getOpElement())); 141 if (src.hasValue()) 142 tgt.setValue(src.getValue()); 143 return tgt; 144 } 145 146 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ValueSet.FilterOperator> convertFilterOperator(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ValueSet.FilterOperator> src) throws FHIRException { 147 if (src == null || src.isEmpty()) 148 return null; 149 Enumeration<org.hl7.fhir.r4.model.ValueSet.FilterOperator> tgt = new Enumeration<>(new org.hl7.fhir.r4.model.ValueSet.FilterOperatorEnumFactory()); 150 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 151 if (src.getValue() == null) { 152 tgt.setValue(null); 153 } else { 154 switch (src.getValue()) { 155 case EQUAL: 156 tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.EQUAL); 157 break; 158 case ISA: 159 tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISA); 160 break; 161 case ISNOTA: 162 tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISNOTA); 163 break; 164 case REGEX: 165 tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.REGEX); 166 break; 167 case IN: 168 tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.IN); 169 break; 170 case NOTIN: 171 tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NOTIN); 172 break; 173 default: 174 tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL); 175 break; 176 } 177 } 178 return tgt; 179 } 180 181 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ValueSet.FilterOperator> convertFilterOperator(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ValueSet.FilterOperator> src) throws FHIRException { 182 if (src == null || src.isEmpty()) 183 return null; 184 org.hl7.fhir.dstu2.model.Enumeration<ValueSet.FilterOperator> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new ValueSet.FilterOperatorEnumFactory()); 185 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 186 if (src.getValue() == null) { 187 tgt.setValue(null); 188 } else { 189 switch (src.getValue()) { 190 case EQUAL: 191 tgt.setValue(ValueSet.FilterOperator.EQUAL); 192 break; 193 case ISA: 194 tgt.setValue(ValueSet.FilterOperator.ISA); 195 break; 196 case ISNOTA: 197 tgt.setValue(ValueSet.FilterOperator.ISNOTA); 198 break; 199 case REGEX: 200 tgt.setValue(ValueSet.FilterOperator.REGEX); 201 break; 202 case IN: 203 tgt.setValue(ValueSet.FilterOperator.IN); 204 break; 205 case NOTIN: 206 tgt.setValue(ValueSet.FilterOperator.NOTIN); 207 break; 208 default: 209 tgt.setValue(ValueSet.FilterOperator.NULL); 210 break; 211 } 212 } 213 return tgt; 214 } 215 216 public static org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src) throws FHIRException { 217 return convertValueSet(src, null); 218 } 219 220 public static org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, BaseAdvisor_10_40 advisor) throws FHIRException { 221 if (src == null || src.isEmpty()) 222 return null; 223 org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet(); 224 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 225 if (src.hasUrlElement()) 226 tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement())); 227 if (src.hasIdentifier()) 228 tgt.addIdentifier(Identifier10_40.convertIdentifier(src.getIdentifier())); 229 if (src.hasVersionElement()) 230 tgt.setVersionElement(String10_40.convertString(src.getVersionElement())); 231 if (src.hasNameElement()) 232 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 233 if (src.hasStatus()) 234 tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement())); 235 if (src.hasExperimental()) 236 tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement())); 237 if (src.hasPublisherElement()) 238 tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement())); 239 for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent t : src.getContact()) 240 tgt.addContact(convertValueSetContactComponent(t)); 241 if (src.hasDate()) 242 tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement())); 243 if (src.hasDescription()) 244 tgt.setDescription(src.getDescription()); 245 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) 246 if (VersionConvertor_10_40.isJurisdiction(t)) 247 tgt.addJurisdiction(CodeableConcept10_40.convertCodeableConcept(t)); 248 else 249 tgt.addUseContext(CodeableConcept10_40.convertCodeableConceptToUsageContext(t)); 250 if (src.hasImmutableElement()) 251 tgt.setImmutableElement(Boolean10_40.convertBoolean(src.getImmutableElement())); 252 if (src.hasRequirements()) 253 tgt.setPurpose(src.getRequirements()); 254 if (src.hasCopyright()) 255 tgt.setCopyright(src.getCopyright()); 256 if (src.hasExtensible()) 257 tgt.addExtension(VersionConvertorConstants.EXT_VS_EXTENSIBLE, new BooleanType(src.getExtensible())); 258 if (src.hasCompose()) { 259 if (src.hasCompose()) 260 tgt.setCompose(convertValueSetComposeComponent(src.getCompose())); 261 tgt.getCompose().setLockedDate(src.getLockedDate()); 262 } 263 if (src.hasCodeSystem() && advisor != null) { 264 org.hl7.fhir.r4.model.CodeSystem tgtcs = new org.hl7.fhir.r4.model.CodeSystem(); 265 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgtcs); 266 tgtcs.setUrl(src.getCodeSystem().getSystem()); 267 tgtcs.addIdentifier(Identifier10_40.convertIdentifier(src.getIdentifier())); 268 tgtcs.setVersion(src.getCodeSystem().getVersion()); 269 tgtcs.setName(src.getName() + " Code System"); 270 tgtcs.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement())); 271 if (src.hasExperimental()) 272 tgtcs.setExperimental(src.getExperimental()); 273 tgtcs.setPublisher(src.getPublisher()); 274 for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent t : src.getContact()) 275 tgtcs.addContact(convertValueSetContactComponent(t)); 276 if (src.hasDate()) 277 tgtcs.setDate(src.getDate()); 278 tgtcs.setDescription(src.getDescription()); 279 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) 280 if (VersionConvertor_10_40.isJurisdiction(t)) 281 tgtcs.addJurisdiction(CodeableConcept10_40.convertCodeableConcept(t)); 282 else 283 tgtcs.addUseContext(CodeableConcept10_40.convertCodeableConceptToUsageContext(t)); 284 tgtcs.setPurpose(src.getRequirements()); 285 tgtcs.setCopyright(src.getCopyright()); 286 tgtcs.setContent(CodeSystemContentMode.COMPLETE); 287 tgtcs.setCaseSensitive(src.getCodeSystem().getCaseSensitive()); 288 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent cs : src.getCodeSystem().getConcept()) 289 processConcept(tgtcs.getConcept(), cs, tgtcs); 290 advisor.handleCodeSystem(tgtcs, tgt); 291 tgt.setUserData("r2-cs", tgtcs); 292 tgt.getCompose().addInclude().setSystem(tgtcs.getUrl()); 293 } 294 if (src.hasExpansion()) 295 tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion())); 296 return tgt; 297 } 298 299 public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src, BaseAdvisor_10_40 advisor) throws FHIRException { 300 if (src == null || src.isEmpty()) 301 return null; 302 org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet(); 303 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 304 if (src.hasUrlElement()) 305 tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement())); 306 for (org.hl7.fhir.r4.model.Identifier i : src.getIdentifier()) 307 tgt.setIdentifier(Identifier10_40.convertIdentifier(i)); 308 if (src.hasVersionElement()) 309 tgt.setVersionElement(String10_40.convertString(src.getVersionElement())); 310 if (src.hasNameElement()) 311 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 312 if (src.hasStatus()) 313 tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement())); 314 if (src.hasExperimental()) 315 tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement())); 316 if (src.hasPublisherElement()) 317 tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement())); 318 for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) tgt.addContact(convertValueSetContactComponent(t)); 319 if (src.hasDate()) 320 tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement())); 321 tgt.setLockedDate(src.getCompose().getLockedDate()); 322 if (src.hasDescription()) 323 tgt.setDescription(src.getDescription()); 324 for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) 325 if (t.hasValueCodeableConcept()) 326 tgt.addUseContext(CodeableConcept10_40.convertCodeableConcept(t.getValueCodeableConcept())); 327 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) 328 tgt.addUseContext(CodeableConcept10_40.convertCodeableConcept(t)); 329 if (src.hasImmutableElement()) 330 tgt.setImmutableElement(Boolean10_40.convertBoolean(src.getImmutableElement())); 331 if (src.hasPurpose()) 332 tgt.setRequirements(src.getPurpose()); 333 if (src.hasCopyright()) 334 tgt.setCopyright(src.getCopyright()); 335 if (src.hasExtension(VersionConvertorConstants.EXT_VS_EXTENSIBLE)) 336 tgt.setExtensible(((BooleanType) src.getExtensionByUrl(VersionConvertorConstants.EXT_VS_EXTENSIBLE).getValue()).booleanValue()); 337 org.hl7.fhir.r4.model.CodeSystem srcCS = (CodeSystem) src.getUserData("r2-cs"); 338 if (srcCS == null) 339 srcCS = advisor.getCodeSystem(src); 340 if (srcCS != null) { 341 tgt.getCodeSystem().setSystem(srcCS.getUrl()); 342 tgt.getCodeSystem().setVersion(srcCS.getVersion()); 343 tgt.getCodeSystem().setCaseSensitive(srcCS.getCaseSensitive()); 344 for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent cs : srcCS.getConcept()) 345 processConcept(tgt.getCodeSystem().getConcept(), cs, srcCS); 346 } 347 if (src.hasCompose()) 348 tgt.setCompose(convertValueSetComposeComponent(src.getCompose(), srcCS == null ? null : srcCS.getUrl())); 349 if (src.hasExpansion()) 350 tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion())); 351 return tgt; 352 } 353 354 public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src) throws FHIRException { 355 return convertValueSet(src, null); 356 } 357 358 public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent src, String noSystem) throws FHIRException { 359 if (src == null || src.isEmpty()) 360 return null; 361 org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent(); 362 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 363 for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getInclude()) { 364 for (org.hl7.fhir.r4.model.UriType ti : t.getValueSet()) tgt.addImport(ti.getValue()); 365 if (noSystem == null || !t.getSystem().equals(noSystem)) 366 tgt.addInclude(convertConceptSetComponent(t)); 367 } 368 for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getExclude()) 369 tgt.addExclude(convertConceptSetComponent(t)); 370 return tgt; 371 } 372 373 public static org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent src) throws FHIRException { 374 if (src == null || src.isEmpty()) 375 return null; 376 org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent(); 377 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 378 for (org.hl7.fhir.dstu2.model.UriType t : src.getImport()) tgt.addInclude().addValueSet(t.getValue()); 379 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent t : src.getInclude()) 380 tgt.addInclude(convertConceptSetComponent(t)); 381 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent t : src.getExclude()) 382 tgt.addExclude(convertConceptSetComponent(t)); 383 return tgt; 384 } 385 386 public static org.hl7.fhir.r4.model.ContactDetail convertValueSetContactComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent src) throws FHIRException { 387 if (src == null || src.isEmpty()) 388 return null; 389 org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); 390 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 391 if (src.hasNameElement()) 392 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 393 for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) 394 tgt.addTelecom(ContactPoint10_40.convertContactPoint(t)); 395 return tgt; 396 } 397 398 public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent convertValueSetContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { 399 if (src == null || src.isEmpty()) 400 return null; 401 org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent(); 402 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 403 if (src.hasNameElement()) 404 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 405 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 406 tgt.addTelecom(ContactPoint10_40.convertContactPoint(t)); 407 return tgt; 408 } 409 410 public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException { 411 if (src == null || src.isEmpty()) 412 return null; 413 org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent(); 414 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 415 if (src.hasIdentifierElement()) 416 tgt.setIdentifierElement(Uri10_40.convertUri(src.getIdentifierElement())); 417 if (src.hasTimestampElement()) 418 tgt.setTimestampElement(DateTime10_40.convertDateTime(src.getTimestampElement())); 419 if (src.hasTotalElement()) 420 tgt.setTotalElement(Integer10_40.convertInteger(src.getTotalElement())); 421 if (src.hasOffsetElement()) 422 tgt.setOffsetElement(Integer10_40.convertInteger(src.getOffsetElement())); 423 for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) 424 tgt.addParameter(convertValueSetExpansionParameterComponent(t)); 425 for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) 426 tgt.addContains(convertValueSetExpansionContainsComponent(t)); 427 return tgt; 428 } 429 430 public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException { 431 if (src == null || src.isEmpty()) 432 return null; 433 org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent(); 434 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 435 if (src.hasIdentifierElement()) 436 tgt.setIdentifierElement(Uri10_40.convertUri(src.getIdentifierElement())); 437 if (src.hasTimestampElement()) 438 tgt.setTimestampElement(DateTime10_40.convertDateTime(src.getTimestampElement())); 439 if (src.hasTotalElement()) 440 tgt.setTotalElement(Integer10_40.convertInteger(src.getTotalElement())); 441 if (src.hasOffsetElement()) 442 tgt.setOffsetElement(Integer10_40.convertInteger(src.getOffsetElement())); 443 for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) 444 tgt.addParameter(convertValueSetExpansionParameterComponent(t)); 445 for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) 446 tgt.addContains(convertValueSetExpansionContainsComponent(t)); 447 return tgt; 448 } 449 450 public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException { 451 if (src == null || src.isEmpty()) 452 return null; 453 org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent(); 454 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 455 if (src.hasSystemElement()) 456 tgt.setSystemElement(Uri10_40.convertUri(src.getSystemElement())); 457 if (src.hasAbstractElement()) 458 tgt.setAbstractElement(Boolean10_40.convertBoolean(src.getAbstractElement())); 459 if (src.hasVersionElement()) 460 tgt.setVersionElement(String10_40.convertString(src.getVersionElement())); 461 if (src.hasCodeElement()) 462 tgt.setCodeElement(Code10_40.convertCode(src.getCodeElement())); 463 if (src.hasDisplayElement()) 464 tgt.setDisplayElement(String10_40.convertString(src.getDisplayElement())); 465 for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) 466 tgt.addContains(convertValueSetExpansionContainsComponent(t)); 467 return tgt; 468 } 469 470 public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException { 471 if (src == null || src.isEmpty()) 472 return null; 473 org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent(); 474 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 475 if (src.hasSystemElement()) 476 tgt.setSystemElement(Uri10_40.convertUri(src.getSystemElement())); 477 if (src.hasAbstractElement()) 478 tgt.setAbstractElement(Boolean10_40.convertBoolean(src.getAbstractElement())); 479 if (src.hasVersionElement()) 480 tgt.setVersionElement(String10_40.convertString(src.getVersionElement())); 481 if (src.hasCodeElement()) 482 tgt.setCodeElement(Code10_40.convertCode(src.getCodeElement())); 483 if (src.hasDisplayElement()) 484 tgt.setDisplayElement(String10_40.convertString(src.getDisplayElement())); 485 for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) 486 tgt.addContains(convertValueSetExpansionContainsComponent(t)); 487 return tgt; 488 } 489 490 public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException { 491 if (src == null || src.isEmpty()) 492 return null; 493 org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent(); 494 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 495 if (src.hasNameElement()) 496 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 497 if (src.hasValue()) 498 tgt.setValue(ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().convertType(src.getValue())); 499 return tgt; 500 } 501 502 public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException { 503 if (src == null || src.isEmpty()) 504 return null; 505 org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent(); 506 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 507 if (src.hasNameElement()) 508 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 509 if (src.hasValue()) 510 tgt.setValue(ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().convertType(src.getValue())); 511 return tgt; 512 } 513 514 static public void processConcept(List<ConceptDefinitionComponent> concepts, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException { 515 org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent(); 516 concepts.add(ct); 517 ct.setCode(cs.getCode()); 518 ct.setDisplay(cs.getDisplay()); 519 ct.setDefinition(cs.getDefinition()); 520 if (cs.getAbstract()) 521 CodeSystemUtilities.setNotSelectable(tgtcs, ct); 522 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { 523 org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent(); 524 cst.setLanguage(csd.getLanguage()); 525 cst.setUse(Coding10_40.convertCoding(csd.getUse())); 526 cst.setValue(csd.getValue()); 527 } 528 for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) 529 processConcept(ct.getConcept(), csc, tgtcs); 530 } 531 532 static public void processConcept(List<ValueSet.ConceptDefinitionComponent> concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException { 533 org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent(); 534 concepts.add(ct); 535 ct.setCode(cs.getCode()); 536 ct.setDisplay(cs.getDisplay()); 537 ct.setDefinition(cs.getDefinition()); 538 if (CodeSystemUtilities.isNotSelectable(srcCS, cs)) 539 ct.setAbstract(true); 540 for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { 541 org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); 542 cst.setLanguage(csd.getLanguage()); 543 cst.setUse(Coding10_40.convertCoding(csd.getUse())); 544 cst.setValue(csd.getValue()); 545 } 546 for (ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, srcCS); 547 } 548 549 public static ValueSet.ValueSetCodeSystemComponent convertCodeSystem(CodeSystem src) throws FHIRException { 550 if (src == null || src.isEmpty()) return null; 551 ValueSet.ValueSetCodeSystemComponent tgt = new ValueSet.ValueSetCodeSystemComponent(); 552 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 553 if (src.hasUrlElement()) tgt.setSystemElement(Uri10_40.convertUri(src.getUrlElement())); 554 if (src.hasVersionElement()) tgt.setVersionElement(String10_40.convertString(src.getVersionElement())); 555 if (src.hasCaseSensitiveElement()) 556 tgt.setCaseSensitiveElement(Boolean10_40.convertBoolean(src.getCaseSensitiveElement())); 557 for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); 558 return tgt; 559 } 560 561 public static ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { 562 if (src == null || src.isEmpty()) return null; 563 ValueSet.ConceptDefinitionComponent tgt = new ValueSet.ConceptDefinitionComponent(); 564 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 565 tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); 566 tgt.setCode(src.getCode()); 567 tgt.setDefinition(src.getDefinition()); 568 tgt.setDisplay(src.getDisplay()); 569 for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(cs, cc)); 570 for (CodeSystem.ConceptDefinitionDesignationComponent cc : src.getDesignation()) 571 tgt.addDesignation(convertCodeSystemDesignation(cc)); 572 return tgt; 573 } 574 575 public static ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(CodeSystem.ConceptDefinitionDesignationComponent src) throws FHIRException { 576 if (src == null || src.isEmpty()) return null; 577 ValueSet.ConceptDefinitionDesignationComponent tgt = new ValueSet.ConceptDefinitionDesignationComponent(); 578 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 579 tgt.setUse(Coding10_40.convertCoding(src.getUse())); 580 tgt.setLanguage(src.getLanguage()); 581 tgt.setValue(src.getValue()); 582 return tgt; 583 } 584}