
001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003import java.util.stream.Collectors; 004 005import org.hl7.fhir.convertors.context.ConversionContext30_40; 006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.ContactDetail30_40; 007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40; 008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40; 009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Timing30_40; 010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Boolean30_40; 011import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Code30_40; 012import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40; 013import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.MarkDown30_40; 014import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40; 015import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Uri30_40; 016import org.hl7.fhir.exceptions.FHIRException; 017import org.hl7.fhir.r4.model.Enumeration; 018import org.hl7.fhir.r4.model.SearchParameter; 019 020public class SearchParameter30_40 { 021 022 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.SearchComparator> convertSearchComparator(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator> src) throws FHIRException { 023 if (src == null || src.isEmpty()) 024 return null; 025 Enumeration<SearchParameter.SearchComparator> tgt = new Enumeration<>(new SearchParameter.SearchComparatorEnumFactory()); 026 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 027 if (src.getValue() == null) { 028 tgt.setValue(null); 029 } else { 030 switch (src.getValue()) { 031 case EQ: 032 tgt.setValue(SearchParameter.SearchComparator.EQ); 033 break; 034 case NE: 035 tgt.setValue(SearchParameter.SearchComparator.NE); 036 break; 037 case GT: 038 tgt.setValue(SearchParameter.SearchComparator.GT); 039 break; 040 case LT: 041 tgt.setValue(SearchParameter.SearchComparator.LT); 042 break; 043 case GE: 044 tgt.setValue(SearchParameter.SearchComparator.GE); 045 break; 046 case LE: 047 tgt.setValue(SearchParameter.SearchComparator.LE); 048 break; 049 case SA: 050 tgt.setValue(SearchParameter.SearchComparator.SA); 051 break; 052 case EB: 053 tgt.setValue(SearchParameter.SearchComparator.EB); 054 break; 055 case AP: 056 tgt.setValue(SearchParameter.SearchComparator.AP); 057 break; 058 default: 059 tgt.setValue(SearchParameter.SearchComparator.NULL); 060 break; 061 } 062 } 063 return tgt; 064 } 065 066 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator> convertSearchComparator(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.SearchComparator> src) throws FHIRException { 067 if (src == null || src.isEmpty()) 068 return null; 069 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SearchParameter.SearchComparatorEnumFactory()); 070 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 071 if (src.getValue() == null) { 072 tgt.setValue(null); 073 } else { 074 switch (src.getValue()) { 075 case EQ: 076 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.EQ); 077 break; 078 case NE: 079 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.NE); 080 break; 081 case GT: 082 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.GT); 083 break; 084 case LT: 085 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.LT); 086 break; 087 case GE: 088 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.GE); 089 break; 090 case LE: 091 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.LE); 092 break; 093 case SA: 094 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.SA); 095 break; 096 case EB: 097 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.EB); 098 break; 099 case AP: 100 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.AP); 101 break; 102 default: 103 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.NULL); 104 break; 105 } 106 } 107 return tgt; 108 } 109 110 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode> convertSearchModifierCode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode> src) throws FHIRException { 111 if (src == null || src.isEmpty()) 112 return null; 113 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCodeEnumFactory()); 114 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 115 if (src.getValue() == null) { 116 tgt.setValue(null); 117 } else { 118 switch (src.getValue()) { 119 case MISSING: 120 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.MISSING); 121 break; 122 case EXACT: 123 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.EXACT); 124 break; 125 case CONTAINS: 126 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.CONTAINS); 127 break; 128 case NOT: 129 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NOT); 130 break; 131 case TEXT: 132 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.TEXT); 133 break; 134 case IN: 135 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.IN); 136 break; 137 case NOTIN: 138 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NOTIN); 139 break; 140 case BELOW: 141 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.BELOW); 142 break; 143 case ABOVE: 144 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.ABOVE); 145 break; 146 case TYPE: 147 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.TYPE); 148 break; 149 default: 150 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NULL); 151 break; 152 } 153 } 154 return tgt; 155 } 156 157 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.SearchModifierCode> convertSearchModifierCode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode> src) throws FHIRException { 158 if (src == null || src.isEmpty()) 159 return null; 160 Enumeration<SearchParameter.SearchModifierCode> tgt = new Enumeration<>(new SearchParameter.SearchModifierCodeEnumFactory()); 161 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 162 if (src.getValue() == null) { 163 tgt.setValue(null); 164 } else { 165 switch (src.getValue()) { 166 case MISSING: 167 tgt.setValue(SearchParameter.SearchModifierCode.MISSING); 168 break; 169 case EXACT: 170 tgt.setValue(SearchParameter.SearchModifierCode.EXACT); 171 break; 172 case CONTAINS: 173 tgt.setValue(SearchParameter.SearchModifierCode.CONTAINS); 174 break; 175 case NOT: 176 tgt.setValue(SearchParameter.SearchModifierCode.NOT); 177 break; 178 case TEXT: 179 tgt.setValue(SearchParameter.SearchModifierCode.TEXT); 180 break; 181 case IN: 182 tgt.setValue(SearchParameter.SearchModifierCode.IN); 183 break; 184 case NOTIN: 185 tgt.setValue(SearchParameter.SearchModifierCode.NOTIN); 186 break; 187 case BELOW: 188 tgt.setValue(SearchParameter.SearchModifierCode.BELOW); 189 break; 190 case ABOVE: 191 tgt.setValue(SearchParameter.SearchModifierCode.ABOVE); 192 break; 193 case TYPE: 194 tgt.setValue(SearchParameter.SearchModifierCode.TYPE); 195 break; 196 default: 197 tgt.setValue(SearchParameter.SearchModifierCode.NULL); 198 break; 199 } 200 } 201 return tgt; 202 } 203 204 public static org.hl7.fhir.dstu3.model.SearchParameter convertSearchParameter(org.hl7.fhir.r4.model.SearchParameter src) throws FHIRException { 205 if (src == null) 206 return null; 207 org.hl7.fhir.dstu3.model.SearchParameter tgt = new org.hl7.fhir.dstu3.model.SearchParameter(); 208 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 209 if (src.hasUrl()) 210 tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement())); 211 if (src.hasVersion()) 212 tgt.setVersionElement(String30_40.convertString(src.getVersionElement())); 213 if (src.hasName()) 214 tgt.setNameElement(String30_40.convertString(src.getNameElement())); 215 if (src.hasStatus()) 216 tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement())); 217 if (src.hasExperimental()) 218 tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement())); 219 if (src.hasDateElement()) 220 tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement())); 221 if (src.hasPublisher()) 222 tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement())); 223 for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) 224 tgt.addContact(ContactDetail30_40.convertContactDetail(t)); 225 for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) 226 tgt.addUseContext(Timing30_40.convertUsageContext(t)); 227 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) 228 tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t)); 229 if (src.hasPurpose()) 230 tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement())); 231 if (src.hasCode()) 232 tgt.setCodeElement(Code30_40.convertCode(src.getCodeElement())); 233 for (org.hl7.fhir.r4.model.CodeType t : src.getBase()) tgt.addBase(t.getValue()); 234 if (src.hasType()) 235 tgt.setTypeElement(Enumerations30_40.convertSearchParamType(src.getTypeElement())); 236 if (src.hasDerivedFrom()) 237 tgt.setDerivedFrom(src.getDerivedFrom()); 238 if (src.hasDescription()) 239 tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement())); 240 if (src.hasExpression()) 241 tgt.setExpressionElement(String30_40.convertString(src.getExpressionElement())); 242 if (src.hasXpath()) 243 tgt.setXpathElement(String30_40.convertString(src.getXpathElement())); 244 if (src.hasXpathUsage()) 245 tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement())); 246 for (org.hl7.fhir.r4.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue()); 247 tgt.setComparator(src.getComparator().stream() 248 .map(SearchParameter30_40::convertSearchComparator) 249 .collect(Collectors.toList())); 250 tgt.setModifier(src.getModifier().stream() 251 .map(SearchParameter30_40::convertSearchModifierCode) 252 .collect(Collectors.toList())); 253 for (org.hl7.fhir.r4.model.StringType t : src.getChain()) tgt.addChain(t.getValue()); 254 for (org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent t : src.getComponent()) 255 tgt.addComponent(convertSearchParameterComponentComponent(t)); 256 return tgt; 257 } 258 259 public static org.hl7.fhir.r4.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu3.model.SearchParameter src) throws FHIRException { 260 if (src == null) 261 return null; 262 org.hl7.fhir.r4.model.SearchParameter tgt = new org.hl7.fhir.r4.model.SearchParameter(); 263 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 264 if (src.hasUrl()) 265 tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement())); 266 if (src.hasVersion()) 267 tgt.setVersionElement(String30_40.convertString(src.getVersionElement())); 268 if (src.hasName()) 269 tgt.setNameElement(String30_40.convertString(src.getNameElement())); 270 if (src.hasStatus()) 271 tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement())); 272 if (src.hasExperimental()) 273 tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement())); 274 if (src.hasDateElement()) 275 tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement())); 276 if (src.hasPublisher()) 277 tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement())); 278 for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) 279 tgt.addContact(ContactDetail30_40.convertContactDetail(t)); 280 for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext()) 281 tgt.addUseContext(Timing30_40.convertUsageContext(t)); 282 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction()) 283 tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t)); 284 if (src.hasPurpose()) 285 tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement())); 286 if (src.hasCode()) 287 tgt.setCodeElement(Code30_40.convertCode(src.getCodeElement())); 288 for (org.hl7.fhir.dstu3.model.CodeType t : src.getBase()) tgt.addBase(t.getValue()); 289 if (src.hasType()) 290 tgt.setTypeElement(Enumerations30_40.convertSearchParamType(src.getTypeElement())); 291 if (src.hasDerivedFrom()) 292 tgt.setDerivedFrom(src.getDerivedFrom()); 293 if (src.hasDescription()) 294 tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement())); 295 if (src.hasExpression()) 296 tgt.setExpressionElement(String30_40.convertString(src.getExpressionElement())); 297 if (src.hasXpath()) 298 tgt.setXpathElement(String30_40.convertString(src.getXpathElement())); 299 if (src.hasXpathUsage()) 300 tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement())); 301 for (org.hl7.fhir.dstu3.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue()); 302 tgt.setComparator(src.getComparator().stream() 303 .map(SearchParameter30_40::convertSearchComparator) 304 .collect(Collectors.toList())); 305 tgt.setModifier(src.getModifier().stream() 306 .map(SearchParameter30_40::convertSearchModifierCode) 307 .collect(Collectors.toList())); 308 for (org.hl7.fhir.dstu3.model.StringType t : src.getChain()) tgt.addChain(t.getValue()); 309 for (org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent t : src.getComponent()) 310 tgt.addComponent(convertSearchParameterComponentComponent(t)); 311 return tgt; 312 } 313 314 public static org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent convertSearchParameterComponentComponent(org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent src) throws FHIRException { 315 if (src == null) 316 return null; 317 org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent tgt = new org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent(); 318 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 319 if (src.hasDefinition()) 320 tgt.setDefinition(Reference30_40.convertCanonicalToReference(src.getDefinitionElement())); 321 if (src.hasExpression()) 322 tgt.setExpressionElement(String30_40.convertString(src.getExpressionElement())); 323 return tgt; 324 } 325 326 public static org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent convertSearchParameterComponentComponent(org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent src) throws FHIRException { 327 if (src == null) 328 return null; 329 org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent tgt = new org.hl7.fhir.r4.model.SearchParameter.SearchParameterComponentComponent(); 330 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 331 if (src.hasDefinition()) 332 tgt.setDefinitionElement(Reference30_40.convertReferenceToCanonical(src.getDefinition())); 333 if (src.hasExpression()) 334 tgt.setExpressionElement(String30_40.convertString(src.getExpressionElement())); 335 return tgt; 336 } 337 338 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> src) throws FHIRException { 339 if (src == null || src.isEmpty()) 340 return null; 341 Enumeration<SearchParameter.XPathUsageType> tgt = new Enumeration<>(new SearchParameter.XPathUsageTypeEnumFactory()); 342 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 343 if (src.getValue() == null) { 344 tgt.setValue(null); 345 } else { 346 switch (src.getValue()) { 347 case NORMAL: 348 tgt.setValue(SearchParameter.XPathUsageType.NORMAL); 349 break; 350 case PHONETIC: 351 tgt.setValue(SearchParameter.XPathUsageType.PHONETIC); 352 break; 353 case NEARBY: 354 tgt.setValue(SearchParameter.XPathUsageType.NEARBY); 355 break; 356 case DISTANCE: 357 tgt.setValue(SearchParameter.XPathUsageType.DISTANCE); 358 break; 359 case OTHER: 360 tgt.setValue(SearchParameter.XPathUsageType.OTHER); 361 break; 362 default: 363 tgt.setValue(SearchParameter.XPathUsageType.NULL); 364 break; 365 } 366 } 367 return tgt; 368 } 369 370 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> src) throws FHIRException { 371 if (src == null || src.isEmpty()) 372 return null; 373 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageTypeEnumFactory()); 374 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 375 if (src.getValue() == null) { 376 tgt.setValue(null); 377 } else { 378 switch (src.getValue()) { 379 case NORMAL: 380 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL); 381 break; 382 case PHONETIC: 383 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.PHONETIC); 384 break; 385 case NEARBY: 386 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NEARBY); 387 break; 388 case DISTANCE: 389 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.DISTANCE); 390 break; 391 case OTHER: 392 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.OTHER); 393 break; 394 default: 395 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NULL); 396 break; 397 } 398 } 399 return tgt; 400 } 401}