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.ElementDefinition14_50;
005import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.CodeableConcept14_50;
006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.String14_50;
007import org.hl7.fhir.exceptions.FHIRException;
008
009public class OperationOutcome14_50 {
010
011  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity> convertIssueSeverity(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity> src) throws FHIRException {
012    if (src == null || src.isEmpty())
013      return null;
014    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverityEnumFactory());
015    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
016    switch (src.getValue()) {
017      case FATAL:
018        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity.FATAL);
019        break;
020      case ERROR:
021        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity.ERROR);
022        break;
023      case WARNING:
024        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity.WARNING);
025        break;
026      case INFORMATION:
027        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity.INFORMATION);
028        break;
029      default:
030        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity.NULL);
031        break;
032    }
033    return tgt;
034  }
035
036  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity> convertIssueSeverity(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueSeverity> src) throws FHIRException {
037    if (src == null || src.isEmpty())
038      return null;
039    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());
040    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
041    switch (src.getValue()) {
042      case FATAL:
043        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.FATAL);
044        break;
045      case ERROR:
046        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR);
047        break;
048      case WARNING:
049        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING);
050        break;
051      case INFORMATION:
052        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.INFORMATION);
053        break;
054      default:
055        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.NULL);
056        break;
057    }
058    return tgt;
059  }
060
061  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType> convertIssueType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueType> src) throws FHIRException {
062    if (src == null || src.isEmpty())
063      return null;
064    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueTypeEnumFactory());
065    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
066    switch (src.getValue()) {
067      case INVALID:
068        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.INVALID);
069        break;
070      case STRUCTURE:
071        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.STRUCTURE);
072        break;
073      case REQUIRED:
074        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.REQUIRED);
075        break;
076      case VALUE:
077        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.VALUE);
078        break;
079      case INVARIANT:
080        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.INVARIANT);
081        break;
082      case SECURITY:
083        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.SECURITY);
084        break;
085      case LOGIN:
086        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.LOGIN);
087        break;
088      case UNKNOWN:
089        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.UNKNOWN);
090        break;
091      case EXPIRED:
092        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.EXPIRED);
093        break;
094      case FORBIDDEN:
095        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.FORBIDDEN);
096        break;
097      case SUPPRESSED:
098        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.SUPPRESSED);
099        break;
100      case PROCESSING:
101        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.PROCESSING);
102        break;
103      case NOTSUPPORTED:
104        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.NOTSUPPORTED);
105        break;
106      case DUPLICATE:
107        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.DUPLICATE);
108        break;
109      case NOTFOUND:
110        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.NOTFOUND);
111        break;
112      case TOOLONG:
113        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.TOOLONG);
114        break;
115      case CODEINVALID:
116        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.CODEINVALID);
117        break;
118      case EXTENSION:
119        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.EXTENSION);
120        break;
121      case TOOCOSTLY:
122        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.TOOCOSTLY);
123        break;
124      case BUSINESSRULE:
125        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.BUSINESSRULE);
126        break;
127      case CONFLICT:
128        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.CONFLICT);
129        break;
130      case INCOMPLETE:
131        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.INCOMPLETE);
132        break;
133      case TRANSIENT:
134        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.TRANSIENT);
135        break;
136      case LOCKERROR:
137        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.LOCKERROR);
138        break;
139      case NOSTORE:
140        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.NOSTORE);
141        break;
142      case EXCEPTION:
143        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.EXCEPTION);
144        break;
145      case TIMEOUT:
146        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.TIMEOUT);
147        break;
148      case THROTTLED:
149        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.THROTTLED);
150        break;
151      case INFORMATIONAL:
152        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.INFORMATIONAL);
153        break;
154      default:
155        tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType.NULL);
156        break;
157    }
158    return tgt;
159  }
160
161  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.OperationOutcome.IssueType> convertIssueType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationOutcome.IssueType> src) throws FHIRException {
162    if (src == null || src.isEmpty())
163      return null;
164    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());
165    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
166    switch (src.getValue()) {
167      case INVALID:
168        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INVALID);
169        break;
170      case STRUCTURE:
171        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.STRUCTURE);
172        break;
173      case REQUIRED:
174        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.REQUIRED);
175        break;
176      case VALUE:
177        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.VALUE);
178        break;
179      case INVARIANT:
180        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INVARIANT);
181        break;
182      case SECURITY:
183        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.SECURITY);
184        break;
185      case LOGIN:
186        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.LOGIN);
187        break;
188      case UNKNOWN:
189        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.UNKNOWN);
190        break;
191      case EXPIRED:
192        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.EXPIRED);
193        break;
194      case FORBIDDEN:
195        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.FORBIDDEN);
196        break;
197      case SUPPRESSED:
198        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.SUPPRESSED);
199        break;
200      case PROCESSING:
201        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.PROCESSING);
202        break;
203      case NOTSUPPORTED:
204        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NOTSUPPORTED);
205        break;
206      case DUPLICATE:
207        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.DUPLICATE);
208        break;
209      case NOTFOUND:
210        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NOTFOUND);
211        break;
212      case TOOLONG:
213        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TOOLONG);
214        break;
215      case CODEINVALID:
216        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.CODEINVALID);
217        break;
218      case EXTENSION:
219        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.EXTENSION);
220        break;
221      case TOOCOSTLY:
222        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TOOCOSTLY);
223        break;
224      case BUSINESSRULE:
225        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.BUSINESSRULE);
226        break;
227      case CONFLICT:
228        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.CONFLICT);
229        break;
230      case INCOMPLETE:
231        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INCOMPLETE);
232        break;
233      case TRANSIENT:
234        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TRANSIENT);
235        break;
236      case LOCKERROR:
237        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.LOCKERROR);
238        break;
239      case NOSTORE:
240        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NOSTORE);
241        break;
242      case EXCEPTION:
243        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.EXCEPTION);
244        break;
245      case TIMEOUT:
246        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.TIMEOUT);
247        break;
248      case THROTTLED:
249        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.THROTTLED);
250        break;
251      case INFORMATIONAL:
252        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.INFORMATIONAL);
253        break;
254      default:
255        tgt.setValue(org.hl7.fhir.r5.model.OperationOutcome.IssueType.NULL);
256        break;
257    }
258    return tgt;
259  }
260
261  public static org.hl7.fhir.dstu2016may.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.r5.model.OperationOutcome src) throws FHIRException {
262    if (src == null || src.isEmpty())
263      return null;
264    org.hl7.fhir.dstu2016may.model.OperationOutcome tgt = new org.hl7.fhir.dstu2016may.model.OperationOutcome();
265    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
266    for (org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue())
267      tgt.addIssue(convertOperationOutcomeIssueComponent(t));
268    return tgt;
269  }
270
271  public static org.hl7.fhir.r5.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.dstu2016may.model.OperationOutcome src) throws FHIRException {
272    if (src == null || src.isEmpty())
273      return null;
274    org.hl7.fhir.r5.model.OperationOutcome tgt = new org.hl7.fhir.r5.model.OperationOutcome();
275    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
276    for (org.hl7.fhir.dstu2016may.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue())
277      tgt.addIssue(convertOperationOutcomeIssueComponent(t));
278    return tgt;
279  }
280
281  public static org.hl7.fhir.dstu2016may.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException {
282    if (src == null || src.isEmpty())
283      return null;
284    org.hl7.fhir.dstu2016may.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.dstu2016may.model.OperationOutcome.OperationOutcomeIssueComponent();
285    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
286    if (src.hasSeverity())
287      tgt.setSeverityElement(convertIssueSeverity(src.getSeverityElement()));
288    if (src.hasCode())
289      tgt.setCodeElement(convertIssueType(src.getCodeElement()));
290    if (src.hasDetails())
291      tgt.setDetails(CodeableConcept14_50.convertCodeableConcept(src.getDetails()));
292    if (src.hasDiagnostics())
293      tgt.setDiagnosticsElement(String14_50.convertString(src.getDiagnosticsElement()));
294    for (org.hl7.fhir.r5.model.StringType t : src.getLocation()) tgt.addLocation(t.getValue());
295    for (org.hl7.fhir.r5.model.StringType t : src.getExpression())
296      tgt.addExpression(ElementDefinition14_50.convertTo2016MayExpression(t.getValue()));
297    return tgt;
298  }
299
300  public static org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.dstu2016may.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException {
301    if (src == null || src.isEmpty())
302      return null;
303    org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent();
304    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
305    if (src.hasSeverity())
306      tgt.setSeverityElement(convertIssueSeverity(src.getSeverityElement()));
307    if (src.hasCode())
308      tgt.setCodeElement(convertIssueType(src.getCodeElement()));
309    if (src.hasDetails())
310      tgt.setDetails(CodeableConcept14_50.convertCodeableConcept(src.getDetails()));
311    if (src.hasDiagnostics())
312      tgt.setDiagnosticsElement(String14_50.convertString(src.getDiagnosticsElement()));
313    for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLocation()) tgt.addLocation(t.getValue());
314    for (org.hl7.fhir.dstu2016may.model.StringType t : src.getExpression())
315      tgt.addExpression(ElementDefinition14_50.convertToR4Expression(t.getValue()));
316    return tgt;
317  }
318}