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