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