
001package org.hl7.fhir.convertors.conv14_40; 002 003import org.hl7.fhir.convertors.VersionConvertor_14_40; 004import org.hl7.fhir.exceptions.FHIRException; 005 006public class Bundle14_40 { 007 008 public static org.hl7.fhir.r4.model.Bundle convertBundle(org.hl7.fhir.dstu2016may.model.Bundle src) throws FHIRException { 009 if (src == null || src.isEmpty()) 010 return null; 011 org.hl7.fhir.r4.model.Bundle tgt = new org.hl7.fhir.r4.model.Bundle(); 012 VersionConvertor_14_40.copyResource(src, tgt); 013 if (src.hasType()) 014 tgt.setTypeElement(convertBundleType(src.getTypeElement())); 015 if (src.hasTotal()) 016 tgt.setTotalElement(VersionConvertor_14_40.convertUnsignedInt(src.getTotalElement())); 017 for (org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); 018 for (org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent t : src.getEntry()) tgt.addEntry(convertBundleEntryComponent(t)); 019 if (src.hasSignature()) 020 tgt.setSignature(VersionConvertor_14_40.convertSignature(src.getSignature())); 021 return tgt; 022 } 023 024 public static org.hl7.fhir.dstu2016may.model.Bundle convertBundle(org.hl7.fhir.r4.model.Bundle src) throws FHIRException { 025 if (src == null || src.isEmpty()) 026 return null; 027 org.hl7.fhir.dstu2016may.model.Bundle tgt = new org.hl7.fhir.dstu2016may.model.Bundle(); 028 VersionConvertor_14_40.copyResource(src, tgt); 029 if (src.hasType()) 030 tgt.setTypeElement(convertBundleType(src.getTypeElement())); 031 if (src.hasTotal()) 032 tgt.setTotalElement(VersionConvertor_14_40.convertUnsignedInt(src.getTotalElement())); 033 for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); 034 for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent t : src.getEntry()) tgt.addEntry(convertBundleEntryComponent(t)); 035 if (src.hasSignature()) 036 tgt.setSignature(VersionConvertor_14_40.convertSignature(src.getSignature())); 037 return tgt; 038 } 039 040 public static org.hl7.fhir.r4.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent src) throws FHIRException { 041 if (src == null || src.isEmpty()) 042 return null; 043 org.hl7.fhir.r4.model.Bundle.BundleEntryComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntryComponent(); 044 VersionConvertor_14_40.copyElement(src, tgt); 045 for (org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); 046 if (src.hasFullUrl()) 047 tgt.setFullUrlElement(VersionConvertor_14_40.convertUri(src.getFullUrlElement())); 048 if (src.hasResource()) 049 tgt.setResource(VersionConvertor_14_40.convertResource(src.getResource())); 050 if (src.hasSearch()) 051 tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch())); 052 if (src.hasRequest()) 053 tgt.setRequest(convertBundleEntryRequestComponent(src.getRequest())); 054 if (src.hasResponse()) 055 tgt.setResponse(convertBundleEntryResponseComponent(src.getResponse())); 056 return tgt; 057 } 058 059 public static org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent src) throws FHIRException { 060 if (src == null || src.isEmpty()) 061 return null; 062 org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent tgt = new org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent(); 063 VersionConvertor_14_40.copyElement(src, tgt); 064 for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); 065 if (src.hasFullUrl()) 066 tgt.setFullUrlElement(VersionConvertor_14_40.convertUri(src.getFullUrlElement())); 067 if (src.hasResource()) 068 tgt.setResource(VersionConvertor_14_40.convertResource(src.getResource())); 069 if (src.hasSearch()) 070 tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch())); 071 if (src.hasRequest()) 072 tgt.setRequest(convertBundleEntryRequestComponent(src.getRequest())); 073 if (src.hasResponse()) 074 tgt.setResponse(convertBundleEntryResponseComponent(src.getResponse())); 075 return tgt; 076 } 077 078 public static org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent convertBundleEntryRequestComponent(org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryRequestComponent src) throws FHIRException { 079 if (src == null || src.isEmpty()) 080 return null; 081 org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent(); 082 VersionConvertor_14_40.copyElement(src, tgt); 083 if (src.hasMethod()) 084 tgt.setMethodElement(convertHTTPVerb(src.getMethodElement())); 085 if (src.hasUrlElement()) 086 tgt.setUrlElement(VersionConvertor_14_40.convertUri(src.getUrlElement())); 087 if (src.hasIfNoneMatch()) 088 tgt.setIfNoneMatchElement(VersionConvertor_14_40.convertString(src.getIfNoneMatchElement())); 089 if (src.hasIfModifiedSince()) 090 tgt.setIfModifiedSinceElement(VersionConvertor_14_40.convertInstant(src.getIfModifiedSinceElement())); 091 if (src.hasIfMatch()) 092 tgt.setIfMatchElement(VersionConvertor_14_40.convertString(src.getIfMatchElement())); 093 if (src.hasIfNoneExist()) 094 tgt.setIfNoneExistElement(VersionConvertor_14_40.convertString(src.getIfNoneExistElement())); 095 return tgt; 096 } 097 098 public static org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryRequestComponent convertBundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent src) throws FHIRException { 099 if (src == null || src.isEmpty()) 100 return null; 101 org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryRequestComponent tgt = new org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryRequestComponent(); 102 VersionConvertor_14_40.copyElement(src, tgt); 103 if (src.hasMethod()) 104 tgt.setMethodElement(convertHTTPVerb(src.getMethodElement())); 105 if (src.hasUrlElement()) 106 tgt.setUrlElement(VersionConvertor_14_40.convertUri(src.getUrlElement())); 107 if (src.hasIfNoneMatch()) 108 tgt.setIfNoneMatchElement(VersionConvertor_14_40.convertString(src.getIfNoneMatchElement())); 109 if (src.hasIfModifiedSince()) 110 tgt.setIfModifiedSinceElement(VersionConvertor_14_40.convertInstant(src.getIfModifiedSinceElement())); 111 if (src.hasIfMatch()) 112 tgt.setIfMatchElement(VersionConvertor_14_40.convertString(src.getIfMatchElement())); 113 if (src.hasIfNoneExist()) 114 tgt.setIfNoneExistElement(VersionConvertor_14_40.convertString(src.getIfNoneExistElement())); 115 return tgt; 116 } 117 118 public static org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent convertBundleEntryResponseComponent(org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryResponseComponent src) throws FHIRException { 119 if (src == null || src.isEmpty()) 120 return null; 121 org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent(); 122 VersionConvertor_14_40.copyElement(src, tgt); 123 if (src.hasStatusElement()) 124 tgt.setStatusElement(VersionConvertor_14_40.convertString(src.getStatusElement())); 125 if (src.hasLocation()) 126 tgt.setLocationElement(VersionConvertor_14_40.convertUri(src.getLocationElement())); 127 if (src.hasEtag()) 128 tgt.setEtagElement(VersionConvertor_14_40.convertString(src.getEtagElement())); 129 if (src.hasLastModified()) 130 tgt.setLastModifiedElement(VersionConvertor_14_40.convertInstant(src.getLastModifiedElement())); 131 return tgt; 132 } 133 134 public static org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryResponseComponent convertBundleEntryResponseComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent src) throws FHIRException { 135 if (src == null || src.isEmpty()) 136 return null; 137 org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryResponseComponent tgt = new org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryResponseComponent(); 138 VersionConvertor_14_40.copyElement(src, tgt); 139 if (src.hasStatusElement()) 140 tgt.setStatusElement(VersionConvertor_14_40.convertString(src.getStatusElement())); 141 if (src.hasLocation()) 142 tgt.setLocationElement(VersionConvertor_14_40.convertUri(src.getLocationElement())); 143 if (src.hasEtag()) 144 tgt.setEtagElement(VersionConvertor_14_40.convertString(src.getEtagElement())); 145 if (src.hasLastModified()) 146 tgt.setLastModifiedElement(VersionConvertor_14_40.convertInstant(src.getLastModifiedElement())); 147 return tgt; 148 } 149 150 public static org.hl7.fhir.dstu2016may.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent src) throws FHIRException { 151 if (src == null || src.isEmpty()) 152 return null; 153 org.hl7.fhir.dstu2016may.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.dstu2016may.model.Bundle.BundleEntrySearchComponent(); 154 VersionConvertor_14_40.copyElement(src, tgt); 155 if (src.hasMode()) 156 tgt.setModeElement(convertSearchEntryMode(src.getModeElement())); 157 if (src.hasScore()) 158 tgt.setScoreElement(VersionConvertor_14_40.convertDecimal(src.getScoreElement())); 159 return tgt; 160 } 161 162 public static org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.dstu2016may.model.Bundle.BundleEntrySearchComponent src) throws FHIRException { 163 if (src == null || src.isEmpty()) 164 return null; 165 org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent(); 166 VersionConvertor_14_40.copyElement(src, tgt); 167 if (src.hasMode()) 168 tgt.setModeElement(convertSearchEntryMode(src.getModeElement())); 169 if (src.hasScore()) 170 tgt.setScoreElement(VersionConvertor_14_40.convertDecimal(src.getScoreElement())); 171 return tgt; 172 } 173 174 public static org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.r4.model.Bundle.BundleLinkComponent src) throws FHIRException { 175 if (src == null || src.isEmpty()) 176 return null; 177 org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent(); 178 VersionConvertor_14_40.copyElement(src, tgt); 179 if (src.hasRelationElement()) 180 tgt.setRelationElement(VersionConvertor_14_40.convertString(src.getRelationElement())); 181 if (src.hasUrlElement()) 182 tgt.setUrlElement(VersionConvertor_14_40.convertUri(src.getUrlElement())); 183 return tgt; 184 } 185 186 public static org.hl7.fhir.r4.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent src) throws FHIRException { 187 if (src == null || src.isEmpty()) 188 return null; 189 org.hl7.fhir.r4.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleLinkComponent(); 190 VersionConvertor_14_40.copyElement(src, tgt); 191 if (src.hasRelationElement()) 192 tgt.setRelationElement(VersionConvertor_14_40.convertString(src.getRelationElement())); 193 if (src.hasUrlElement()) 194 tgt.setUrlElement(VersionConvertor_14_40.convertUri(src.getUrlElement())); 195 return tgt; 196 } 197 198 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.BundleType> convertBundleType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.BundleType> src) throws FHIRException { 199 if (src == null || src.isEmpty()) 200 return null; 201 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.BundleType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Bundle.BundleTypeEnumFactory()); 202 VersionConvertor_14_40.copyElement(src, tgt); 203 switch(src.getValue()) { 204 case DOCUMENT: 205 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT); 206 break; 207 case MESSAGE: 208 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.MESSAGE); 209 break; 210 case TRANSACTION: 211 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTION); 212 break; 213 case TRANSACTIONRESPONSE: 214 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTIONRESPONSE); 215 break; 216 case BATCH: 217 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.BATCH); 218 break; 219 case BATCHRESPONSE: 220 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.BATCHRESPONSE); 221 break; 222 case HISTORY: 223 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.HISTORY); 224 break; 225 case SEARCHSET: 226 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET); 227 break; 228 case COLLECTION: 229 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.COLLECTION); 230 break; 231 default: 232 tgt.setValue(org.hl7.fhir.r4.model.Bundle.BundleType.NULL); 233 break; 234 } 235 return tgt; 236 } 237 238 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.BundleType> convertBundleType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.BundleType> src) throws FHIRException { 239 if (src == null || src.isEmpty()) 240 return null; 241 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.BundleType> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Bundle.BundleTypeEnumFactory()); 242 VersionConvertor_14_40.copyElement(src, tgt); 243 switch(src.getValue()) { 244 case DOCUMENT: 245 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.DOCUMENT); 246 break; 247 case MESSAGE: 248 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.MESSAGE); 249 break; 250 case TRANSACTION: 251 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.TRANSACTION); 252 break; 253 case TRANSACTIONRESPONSE: 254 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.TRANSACTIONRESPONSE); 255 break; 256 case BATCH: 257 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.BATCH); 258 break; 259 case BATCHRESPONSE: 260 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.BATCHRESPONSE); 261 break; 262 case HISTORY: 263 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.HISTORY); 264 break; 265 case SEARCHSET: 266 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.SEARCHSET); 267 break; 268 case COLLECTION: 269 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.COLLECTION); 270 break; 271 default: 272 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.BundleType.NULL); 273 break; 274 } 275 return tgt; 276 } 277 278 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.HTTPVerb> convertHTTPVerb(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb> src) throws FHIRException { 279 if (src == null || src.isEmpty()) 280 return null; 281 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.HTTPVerb> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Bundle.HTTPVerbEnumFactory()); 282 VersionConvertor_14_40.copyElement(src, tgt); 283 switch(src.getValue()) { 284 case GET: 285 tgt.setValue(org.hl7.fhir.r4.model.Bundle.HTTPVerb.GET); 286 break; 287 case POST: 288 tgt.setValue(org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST); 289 break; 290 case PUT: 291 tgt.setValue(org.hl7.fhir.r4.model.Bundle.HTTPVerb.PUT); 292 break; 293 case DELETE: 294 tgt.setValue(org.hl7.fhir.r4.model.Bundle.HTTPVerb.DELETE); 295 break; 296 default: 297 tgt.setValue(org.hl7.fhir.r4.model.Bundle.HTTPVerb.NULL); 298 break; 299 } 300 return tgt; 301 } 302 303 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb> convertHTTPVerb(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.HTTPVerb> src) throws FHIRException { 304 if (src == null || src.isEmpty()) 305 return null; 306 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerbEnumFactory()); 307 VersionConvertor_14_40.copyElement(src, tgt); 308 switch(src.getValue()) { 309 case GET: 310 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb.GET); 311 break; 312 case POST: 313 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb.POST); 314 break; 315 case PUT: 316 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb.PUT); 317 break; 318 case DELETE: 319 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb.DELETE); 320 break; 321 default: 322 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb.NULL); 323 break; 324 } 325 return tgt; 326 } 327 328 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.SearchEntryMode> convertSearchEntryMode(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode> src) throws FHIRException { 329 if (src == null || src.isEmpty()) 330 return null; 331 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.SearchEntryMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Bundle.SearchEntryModeEnumFactory()); 332 VersionConvertor_14_40.copyElement(src, tgt); 333 switch(src.getValue()) { 334 case MATCH: 335 tgt.setValue(org.hl7.fhir.r4.model.Bundle.SearchEntryMode.MATCH); 336 break; 337 case INCLUDE: 338 tgt.setValue(org.hl7.fhir.r4.model.Bundle.SearchEntryMode.INCLUDE); 339 break; 340 case OUTCOME: 341 tgt.setValue(org.hl7.fhir.r4.model.Bundle.SearchEntryMode.OUTCOME); 342 break; 343 default: 344 tgt.setValue(org.hl7.fhir.r4.model.Bundle.SearchEntryMode.NULL); 345 break; 346 } 347 return tgt; 348 } 349 350 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode> convertSearchEntryMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Bundle.SearchEntryMode> src) throws FHIRException { 351 if (src == null || src.isEmpty()) 352 return null; 353 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryModeEnumFactory()); 354 VersionConvertor_14_40.copyElement(src, tgt); 355 switch(src.getValue()) { 356 case MATCH: 357 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode.MATCH); 358 break; 359 case INCLUDE: 360 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode.INCLUDE); 361 break; 362 case OUTCOME: 363 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode.OUTCOME); 364 break; 365 default: 366 tgt.setValue(org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode.NULL); 367 break; 368 } 369 return tgt; 370 } 371}