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