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