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