001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
006import org.hl7.fhir.exceptions.FHIRException;
007
008/*
009  Copyright (c) 2011+, HL7, Inc.
010  All rights reserved.
011  
012  Redistribution and use in source and binary forms, with or without modification, 
013  are permitted provided that the following conditions are met:
014  
015   * Redistributions of source code must retain the above copyright notice, this 
016     list of conditions and the following disclaimer.
017   * Redistributions in binary form must reproduce the above copyright notice, 
018     this list of conditions and the following disclaimer in the documentation 
019     and/or other materials provided with the distribution.
020   * Neither the name of HL7 nor the names of its contributors may be used to 
021     endorse or promote products derived from this software without specific 
022     prior written permission.
023  
024  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
025  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
026  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
027  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
028  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
029  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
030  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
031  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
032  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
033  POSSIBILITY OF SUCH DAMAGE.
034  
035*/
036// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
037public class OperationOutcome40_50 {
038
039  public static org.hl7.fhir.r5.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.r4.model.OperationOutcome src) throws FHIRException {
040    if (src == null)
041      return null;
042    org.hl7.fhir.r5.model.OperationOutcome tgt = new org.hl7.fhir.r5.model.OperationOutcome();
043    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
044    for (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue())
045      tgt.addIssue(convertOperationOutcomeIssueComponent(t));
046    return tgt;
047  }
048
049  public static org.hl7.fhir.r4.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.r5.model.OperationOutcome src) throws FHIRException {
050    if (src == null)
051      return null;
052    org.hl7.fhir.r4.model.OperationOutcome tgt = new org.hl7.fhir.r4.model.OperationOutcome();
053    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
054    for (org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue())
055      tgt.addIssue(convertOperationOutcomeIssueComponent(t));
056    return tgt;
057  }
058
059  public static org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException {
060    if (src == null)
061      return null;
062    org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent();
063    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
064    if (src.hasSeverity())
065      tgt.setSeverityElement(convertIssueSeverity(src.getSeverityElement()));
066    if (src.hasCode())
067      tgt.setCodeElement(convertIssueType(src.getCodeElement()));
068    if (src.hasDetails())
069      tgt.setDetails(CodeableConcept40_50.convertCodeableConcept(src.getDetails()));
070    if (src.hasDiagnostics())
071      tgt.setDiagnosticsElement(String40_50.convertString(src.getDiagnosticsElement()));
072    for (org.hl7.fhir.r4.model.StringType t : src.getLocation()) tgt.getLocation().add(String40_50.convertString(t));
073    for (org.hl7.fhir.r4.model.StringType t : src.getExpression())
074      tgt.getExpression().add(String40_50.convertString(t));
075    return tgt;
076  }
077
078  public static org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException {
079    if (src == null)
080      return null;
081    org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent();
082    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
083    if (src.hasSeverity())
084      tgt.setSeverityElement(convertIssueSeverity(src.getSeverityElement()));
085    if (src.hasCode())
086      tgt.setCodeElement(convertIssueType(src.getCodeElement()));
087    if (src.hasDetails())
088      tgt.setDetails(CodeableConcept40_50.convertCodeableConcept(src.getDetails()));
089    if (src.hasDiagnostics())
090      tgt.setDiagnosticsElement(String40_50.convertString(src.getDiagnosticsElement()));
091    for (org.hl7.fhir.r5.model.StringType t : src.getLocation()) tgt.getLocation().add(String40_50.convertString(t));
092    for (org.hl7.fhir.r5.model.StringType t : src.getExpression())
093      tgt.getExpression().add(String40_50.convertString(t));
094    return tgt;
095  }
096
097  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity> convertIssueSeverity(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity> src) throws FHIRException {
098    if (src == null || src.isEmpty())
099      return null;
100    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.OperationOutcome.IssueSeverityEnumFactory());
101    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
102    switch (src.getValue()) {
103      case FATAL:
104        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.FATAL);
105        break;
106      case ERROR:
107        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR);
108        break;
109      case WARNING:
110        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING);
111        break;
112      case INFORMATION:
113        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.INFORMATION);
114        break;
115      default:
116        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.NULL);
117        break;
118    }
119    return tgt;
120  }
121
122  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity> convertIssueSeverity(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity> src) throws FHIRException {
123    if (src == null || src.isEmpty())
124      return null;
125    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.OperationOutcome.IssueSeverityEnumFactory());
126    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
127    switch (src.getValue()) {
128      case FATAL:
129        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.FATAL);
130        break;
131      case ERROR:
132        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.ERROR);
133        break;
134      case WARNING:
135        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.WARNING);
136        break;
137      case INFORMATION:
138        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.INFORMATION);
139        break;
140      default:
141        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.NULL);
142        break;
143    }
144    return tgt;
145  }
146
147  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueType> convertIssueType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationOutcome.IssueType> src) throws FHIRException {
148    if (src == null || src.isEmpty())
149      return null;
150    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.OperationOutcome.IssueTypeEnumFactory());
151    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
152    switch (src.getValue()) {
153      case INVALID:
154        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INVALID);
155        break;
156      case STRUCTURE:
157        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.STRUCTURE);
158        break;
159      case REQUIRED:
160        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.REQUIRED);
161        break;
162      case VALUE:
163        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.VALUE);
164        break;
165      case INVARIANT:
166        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INVARIANT);
167        break;
168      case SECURITY:
169        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.SECURITY);
170        break;
171      case LOGIN:
172        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.LOGIN);
173        break;
174      case UNKNOWN:
175        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.UNKNOWN);
176        break;
177      case EXPIRED:
178        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.EXPIRED);
179        break;
180      case FORBIDDEN:
181        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.FORBIDDEN);
182        break;
183      case SUPPRESSED:
184        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.SUPPRESSED);
185        break;
186      case PROCESSING:
187        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.PROCESSING);
188        break;
189      case NOTSUPPORTED:
190        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NOTSUPPORTED);
191        break;
192      case DUPLICATE:
193        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.DUPLICATE);
194        break;
195      case MULTIPLEMATCHES:
196        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.MULTIPLEMATCHES);
197        break;
198      case NOTFOUND:
199        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NOTFOUND);
200        break;
201      case DELETED:
202        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.DELETED);
203        break;
204      case TOOLONG:
205        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TOOLONG);
206        break;
207      case CODEINVALID:
208        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.CODEINVALID);
209        break;
210      case EXTENSION:
211        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.EXTENSION);
212        break;
213      case TOOCOSTLY:
214        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TOOCOSTLY);
215        break;
216      case BUSINESSRULE:
217        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.BUSINESSRULE);
218        break;
219      case CONFLICT:
220        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.CONFLICT);
221        break;
222      case TRANSIENT:
223        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TRANSIENT);
224        break;
225      case LOCKERROR:
226        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.LOCKERROR);
227        break;
228      case NOSTORE:
229        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NOSTORE);
230        break;
231      case EXCEPTION:
232        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.EXCEPTION);
233        break;
234      case TIMEOUT:
235        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TIMEOUT);
236        break;
237      case INCOMPLETE:
238        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INCOMPLETE);
239        break;
240      case THROTTLED:
241        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.THROTTLED);
242        break;
243      case INFORMATIONAL:
244        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INFORMATIONAL);
245        break;
246      default:
247        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NULL);
248        break;
249    }
250    return tgt;
251  }
252
253  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationOutcome.IssueType> convertIssueType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueType> src) throws FHIRException {
254    if (src == null || src.isEmpty())
255      return null;
256    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationOutcome.IssueType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.OperationOutcome.IssueTypeEnumFactory());
257    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
258    switch (src.getValue()) {
259      case INVALID:
260        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVALID);
261        break;
262      case STRUCTURE:
263        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.STRUCTURE);
264        break;
265      case REQUIRED:
266        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.REQUIRED);
267        break;
268      case VALUE:
269        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.VALUE);
270        break;
271      case INVARIANT:
272        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVARIANT);
273        break;
274      case SECURITY:
275        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.SECURITY);
276        break;
277      case LOGIN:
278        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOGIN);
279        break;
280      case UNKNOWN:
281        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.UNKNOWN);
282        break;
283      case EXPIRED:
284        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXPIRED);
285        break;
286      case FORBIDDEN:
287        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.FORBIDDEN);
288        break;
289      case SUPPRESSED:
290        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.SUPPRESSED);
291        break;
292      case PROCESSING:
293        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.PROCESSING);
294        break;
295      case NOTSUPPORTED:
296        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTSUPPORTED);
297        break;
298      case DUPLICATE:
299        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.DUPLICATE);
300        break;
301      case MULTIPLEMATCHES:
302        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.MULTIPLEMATCHES);
303        break;
304      case NOTFOUND:
305        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTFOUND);
306        break;
307      case DELETED:
308        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.DELETED);
309        break;
310      case TOOLONG:
311        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOLONG);
312        break;
313      case CODEINVALID:
314        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.CODEINVALID);
315        break;
316      case EXTENSION:
317        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXTENSION);
318        break;
319      case TOOCOSTLY:
320        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOCOSTLY);
321        break;
322      case BUSINESSRULE:
323        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.BUSINESSRULE);
324        break;
325      case CONFLICT:
326        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.CONFLICT);
327        break;
328      case TRANSIENT:
329        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.TRANSIENT);
330        break;
331      case LOCKERROR:
332        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOCKERROR);
333        break;
334      case NOSTORE:
335        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOSTORE);
336        break;
337      case EXCEPTION:
338        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXCEPTION);
339        break;
340      case TIMEOUT:
341        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.TIMEOUT);
342        break;
343      case INCOMPLETE:
344        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.INCOMPLETE);
345        break;
346      case THROTTLED:
347        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.THROTTLED);
348        break;
349      case INFORMATIONAL:
350        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.INFORMATIONAL);
351        break;
352      default:
353        tgt.setValue(org.hl7.fhir.r4.model.OperationOutcome.IssueType.NULL);
354        break;
355    }
356    return tgt;
357  }
358}