001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
039import org.hl7.fhir.utilities.Utilities;
040
041import ca.uhn.fhir.model.api.annotation.Block;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.Description;
044import ca.uhn.fhir.model.api.annotation.ResourceDef;
045
046/**
047 * A collection of error, warning, or information messages that result from a
048 * system action.
049 */
050@ResourceDef(name = "OperationOutcome", profile = "http://hl7.org/fhir/StructureDefinition/OperationOutcome")
051public class OperationOutcome extends DomainResource implements IBaseOperationOutcome {
052
053  public enum IssueSeverity {
054    /**
055     * The issue caused the action to fail and no further checking could be
056     * performed.
057     */
058    FATAL,
059    /**
060     * The issue is sufficiently important to cause the action to fail.
061     */
062    ERROR,
063    /**
064     * The issue is not important enough to cause the action to fail but may cause
065     * it to be performed suboptimally or in a way that is not as desired.
066     */
067    WARNING,
068    /**
069     * The issue has no relation to the degree of success of the action.
070     */
071    INFORMATION,
072    /**
073     * added to help the parsers with the generic types
074     */
075    NULL;
076
077    public static IssueSeverity fromCode(String codeString) throws FHIRException {
078      if (codeString == null || "".equals(codeString))
079        return null;
080      if ("fatal".equals(codeString))
081        return FATAL;
082      if ("error".equals(codeString))
083        return ERROR;
084      if ("warning".equals(codeString))
085        return WARNING;
086      if ("information".equals(codeString))
087        return INFORMATION;
088      if (Configuration.isAcceptInvalidEnums())
089        return null;
090      else
091        throw new FHIRException("Unknown IssueSeverity code '" + codeString + "'");
092    }
093
094    public String toCode() {
095      switch (this) {
096      case FATAL:
097        return "fatal";
098      case ERROR:
099        return "error";
100      case WARNING:
101        return "warning";
102      case INFORMATION:
103        return "information";
104      case NULL:
105        return null;
106      default:
107        return "?";
108      }
109    }
110
111    public String getSystem() {
112      switch (this) {
113      case FATAL:
114        return "http://hl7.org/fhir/issue-severity";
115      case ERROR:
116        return "http://hl7.org/fhir/issue-severity";
117      case WARNING:
118        return "http://hl7.org/fhir/issue-severity";
119      case INFORMATION:
120        return "http://hl7.org/fhir/issue-severity";
121      case NULL:
122        return null;
123      default:
124        return "?";
125      }
126    }
127
128    public String getDefinition() {
129      switch (this) {
130      case FATAL:
131        return "The issue caused the action to fail and no further checking could be performed.";
132      case ERROR:
133        return "The issue is sufficiently important to cause the action to fail.";
134      case WARNING:
135        return "The issue is not important enough to cause the action to fail but may cause it to be performed suboptimally or in a way that is not as desired.";
136      case INFORMATION:
137        return "The issue has no relation to the degree of success of the action.";
138      case NULL:
139        return null;
140      default:
141        return "?";
142      }
143    }
144
145    public String getDisplay() {
146      switch (this) {
147      case FATAL:
148        return "Fatal";
149      case ERROR:
150        return "Error";
151      case WARNING:
152        return "Warning";
153      case INFORMATION:
154        return "Information";
155      case NULL:
156        return null;
157      default:
158        return "?";
159      }
160    }
161  }
162
163  public static class IssueSeverityEnumFactory implements EnumFactory<IssueSeverity> {
164    public IssueSeverity fromCode(String codeString) throws IllegalArgumentException {
165      if (codeString == null || "".equals(codeString))
166        if (codeString == null || "".equals(codeString))
167          return null;
168      if ("fatal".equals(codeString))
169        return IssueSeverity.FATAL;
170      if ("error".equals(codeString))
171        return IssueSeverity.ERROR;
172      if ("warning".equals(codeString))
173        return IssueSeverity.WARNING;
174      if ("information".equals(codeString))
175        return IssueSeverity.INFORMATION;
176      throw new IllegalArgumentException("Unknown IssueSeverity code '" + codeString + "'");
177    }
178
179    public Enumeration<IssueSeverity> fromType(PrimitiveType<?> code) throws FHIRException {
180      if (code == null)
181        return null;
182      if (code.isEmpty())
183        return new Enumeration<IssueSeverity>(this, IssueSeverity.NULL, code);
184      String codeString = code.asStringValue();
185      if (codeString == null || "".equals(codeString))
186        return new Enumeration<IssueSeverity>(this, IssueSeverity.NULL, code);
187      if ("fatal".equals(codeString))
188        return new Enumeration<IssueSeverity>(this, IssueSeverity.FATAL, code);
189      if ("error".equals(codeString))
190        return new Enumeration<IssueSeverity>(this, IssueSeverity.ERROR, code);
191      if ("warning".equals(codeString))
192        return new Enumeration<IssueSeverity>(this, IssueSeverity.WARNING, code);
193      if ("information".equals(codeString))
194        return new Enumeration<IssueSeverity>(this, IssueSeverity.INFORMATION, code);
195      throw new FHIRException("Unknown IssueSeverity code '" + codeString + "'");
196    }
197
198    public String toCode(IssueSeverity code) {
199      if (code == IssueSeverity.FATAL)
200        return "fatal";
201      if (code == IssueSeverity.ERROR)
202        return "error";
203      if (code == IssueSeverity.WARNING)
204        return "warning";
205      if (code == IssueSeverity.INFORMATION)
206        return "information";
207      return "?";
208    }
209
210    public String toSystem(IssueSeverity code) {
211      return code.getSystem();
212    }
213  }
214
215  public enum IssueType {
216    /**
217     * Content invalid against the specification or a profile.
218     */
219    INVALID,
220    /**
221     * A structural issue in the content such as wrong namespace, unable to parse
222     * the content completely, invalid syntax, etc.
223     */
224    STRUCTURE,
225    /**
226     * A required element is missing.
227     */
228    REQUIRED,
229    /**
230     * An element or header value is invalid.
231     */
232    VALUE,
233    /**
234     * A content validation rule failed - e.g. a schematron rule.
235     */
236    INVARIANT,
237    /**
238     * An authentication/authorization/permissions issue of some kind.
239     */
240    SECURITY,
241    /**
242     * The client needs to initiate an authentication process.
243     */
244    LOGIN,
245    /**
246     * The user or system was not able to be authenticated (either there is no
247     * process, or the proferred token is unacceptable).
248     */
249    UNKNOWN,
250    /**
251     * User session expired; a login may be required.
252     */
253    EXPIRED,
254    /**
255     * The user does not have the rights to perform this action.
256     */
257    FORBIDDEN,
258    /**
259     * Some information was not or might not have been returned due to business
260     * rules, consent or privacy rules, or access permission constraints. This
261     * information may be accessible through alternate processes.
262     */
263    SUPPRESSED,
264    /**
265     * Processing issues. These are expected to be final e.g. there is no point
266     * resubmitting the same content unchanged.
267     */
268    PROCESSING,
269    /**
270     * The interaction, operation, resource or profile is not supported.
271     */
272    NOTSUPPORTED,
273    /**
274     * An attempt was made to create a duplicate record.
275     */
276    DUPLICATE,
277    /**
278     * Multiple matching records were found when the operation required only one
279     * match.
280     */
281    MULTIPLEMATCHES,
282    /**
283     * The reference provided was not found. In a pure RESTful environment, this
284     * would be an HTTP 404 error, but this code may be used where the content is
285     * not found further into the application architecture.
286     */
287    NOTFOUND,
288    /**
289     * The reference pointed to content (usually a resource) that has been deleted.
290     */
291    DELETED,
292    /**
293     * Provided content is too long (typically, this is a denial of service
294     * protection type of error).
295     */
296    TOOLONG,
297    /**
298     * The code or system could not be understood, or it was not valid in the
299     * context of a particular ValueSet.code.
300     */
301    CODEINVALID,
302    /**
303     * An extension was found that was not acceptable, could not be resolved, or a
304     * modifierExtension was not recognized.
305     */
306    EXTENSION,
307    /**
308     * The operation was stopped to protect server resources; e.g. a request for a
309     * value set expansion on all of SNOMED CT.
310     */
311    TOOCOSTLY,
312    /**
313     * The content/operation failed to pass some business rule and so could not
314     * proceed.
315     */
316    BUSINESSRULE,
317    /**
318     * Content could not be accepted because of an edit conflict (i.e. version aware
319     * updates). (In a pure RESTful environment, this would be an HTTP 409 error,
320     * but this code may be used where the conflict is discovered further into the
321     * application architecture.).
322     */
323    CONFLICT,
324    /**
325     * Transient processing issues. The system receiving the message may be able to
326     * resubmit the same content once an underlying issue is resolved.
327     */
328    TRANSIENT,
329    /**
330     * A resource/record locking failure (usually in an underlying database).
331     */
332    LOCKERROR,
333    /**
334     * The persistent store is unavailable; e.g. the database is down for
335     * maintenance or similar action, and the interaction or operation cannot be
336     * processed.
337     */
338    NOSTORE,
339    /**
340     * An unexpected internal error has occurred.
341     */
342    EXCEPTION,
343    /**
344     * An internal timeout has occurred.
345     */
346    TIMEOUT,
347    /**
348     * Not all data sources typically accessed could be reached or responded in
349     * time, so the returned information might not be complete (applies to search
350     * interactions and some operations).
351     */
352    INCOMPLETE,
353    /**
354     * The system is not prepared to handle this request due to load management.
355     */
356    THROTTLED,
357    /**
358     * A message unrelated to the processing success of the completed operation
359     * (examples of the latter include things like reminders of password expiry,
360     * system maintenance times, etc.).
361     */
362    INFORMATIONAL,
363    /**
364     * added to help the parsers with the generic types
365     */
366    NULL;
367
368    public static IssueType fromCode(String codeString) throws FHIRException {
369      if (codeString == null || "".equals(codeString))
370        return null;
371      if ("invalid".equals(codeString))
372        return INVALID;
373      if ("structure".equals(codeString))
374        return STRUCTURE;
375      if ("required".equals(codeString))
376        return REQUIRED;
377      if ("value".equals(codeString))
378        return VALUE;
379      if ("invariant".equals(codeString))
380        return INVARIANT;
381      if ("security".equals(codeString))
382        return SECURITY;
383      if ("login".equals(codeString))
384        return LOGIN;
385      if ("unknown".equals(codeString))
386        return UNKNOWN;
387      if ("expired".equals(codeString))
388        return EXPIRED;
389      if ("forbidden".equals(codeString))
390        return FORBIDDEN;
391      if ("suppressed".equals(codeString))
392        return SUPPRESSED;
393      if ("processing".equals(codeString))
394        return PROCESSING;
395      if ("not-supported".equals(codeString))
396        return NOTSUPPORTED;
397      if ("duplicate".equals(codeString))
398        return DUPLICATE;
399      if ("multiple-matches".equals(codeString))
400        return MULTIPLEMATCHES;
401      if ("not-found".equals(codeString))
402        return NOTFOUND;
403      if ("deleted".equals(codeString))
404        return DELETED;
405      if ("too-long".equals(codeString))
406        return TOOLONG;
407      if ("code-invalid".equals(codeString))
408        return CODEINVALID;
409      if ("extension".equals(codeString))
410        return EXTENSION;
411      if ("too-costly".equals(codeString))
412        return TOOCOSTLY;
413      if ("business-rule".equals(codeString))
414        return BUSINESSRULE;
415      if ("conflict".equals(codeString))
416        return CONFLICT;
417      if ("transient".equals(codeString))
418        return TRANSIENT;
419      if ("lock-error".equals(codeString))
420        return LOCKERROR;
421      if ("no-store".equals(codeString))
422        return NOSTORE;
423      if ("exception".equals(codeString))
424        return EXCEPTION;
425      if ("timeout".equals(codeString))
426        return TIMEOUT;
427      if ("incomplete".equals(codeString))
428        return INCOMPLETE;
429      if ("throttled".equals(codeString))
430        return THROTTLED;
431      if ("informational".equals(codeString))
432        return INFORMATIONAL;
433      if (Configuration.isAcceptInvalidEnums())
434        return null;
435      else
436        throw new FHIRException("Unknown IssueType code '" + codeString + "'");
437    }
438
439    public String toCode() {
440      switch (this) {
441      case INVALID:
442        return "invalid";
443      case STRUCTURE:
444        return "structure";
445      case REQUIRED:
446        return "required";
447      case VALUE:
448        return "value";
449      case INVARIANT:
450        return "invariant";
451      case SECURITY:
452        return "security";
453      case LOGIN:
454        return "login";
455      case UNKNOWN:
456        return "unknown";
457      case EXPIRED:
458        return "expired";
459      case FORBIDDEN:
460        return "forbidden";
461      case SUPPRESSED:
462        return "suppressed";
463      case PROCESSING:
464        return "processing";
465      case NOTSUPPORTED:
466        return "not-supported";
467      case DUPLICATE:
468        return "duplicate";
469      case MULTIPLEMATCHES:
470        return "multiple-matches";
471      case NOTFOUND:
472        return "not-found";
473      case DELETED:
474        return "deleted";
475      case TOOLONG:
476        return "too-long";
477      case CODEINVALID:
478        return "code-invalid";
479      case EXTENSION:
480        return "extension";
481      case TOOCOSTLY:
482        return "too-costly";
483      case BUSINESSRULE:
484        return "business-rule";
485      case CONFLICT:
486        return "conflict";
487      case TRANSIENT:
488        return "transient";
489      case LOCKERROR:
490        return "lock-error";
491      case NOSTORE:
492        return "no-store";
493      case EXCEPTION:
494        return "exception";
495      case TIMEOUT:
496        return "timeout";
497      case INCOMPLETE:
498        return "incomplete";
499      case THROTTLED:
500        return "throttled";
501      case INFORMATIONAL:
502        return "informational";
503      case NULL:
504        return null;
505      default:
506        return "?";
507      }
508    }
509
510    public String getSystem() {
511      switch (this) {
512      case INVALID:
513        return "http://hl7.org/fhir/issue-type";
514      case STRUCTURE:
515        return "http://hl7.org/fhir/issue-type";
516      case REQUIRED:
517        return "http://hl7.org/fhir/issue-type";
518      case VALUE:
519        return "http://hl7.org/fhir/issue-type";
520      case INVARIANT:
521        return "http://hl7.org/fhir/issue-type";
522      case SECURITY:
523        return "http://hl7.org/fhir/issue-type";
524      case LOGIN:
525        return "http://hl7.org/fhir/issue-type";
526      case UNKNOWN:
527        return "http://hl7.org/fhir/issue-type";
528      case EXPIRED:
529        return "http://hl7.org/fhir/issue-type";
530      case FORBIDDEN:
531        return "http://hl7.org/fhir/issue-type";
532      case SUPPRESSED:
533        return "http://hl7.org/fhir/issue-type";
534      case PROCESSING:
535        return "http://hl7.org/fhir/issue-type";
536      case NOTSUPPORTED:
537        return "http://hl7.org/fhir/issue-type";
538      case DUPLICATE:
539        return "http://hl7.org/fhir/issue-type";
540      case MULTIPLEMATCHES:
541        return "http://hl7.org/fhir/issue-type";
542      case NOTFOUND:
543        return "http://hl7.org/fhir/issue-type";
544      case DELETED:
545        return "http://hl7.org/fhir/issue-type";
546      case TOOLONG:
547        return "http://hl7.org/fhir/issue-type";
548      case CODEINVALID:
549        return "http://hl7.org/fhir/issue-type";
550      case EXTENSION:
551        return "http://hl7.org/fhir/issue-type";
552      case TOOCOSTLY:
553        return "http://hl7.org/fhir/issue-type";
554      case BUSINESSRULE:
555        return "http://hl7.org/fhir/issue-type";
556      case CONFLICT:
557        return "http://hl7.org/fhir/issue-type";
558      case TRANSIENT:
559        return "http://hl7.org/fhir/issue-type";
560      case LOCKERROR:
561        return "http://hl7.org/fhir/issue-type";
562      case NOSTORE:
563        return "http://hl7.org/fhir/issue-type";
564      case EXCEPTION:
565        return "http://hl7.org/fhir/issue-type";
566      case TIMEOUT:
567        return "http://hl7.org/fhir/issue-type";
568      case INCOMPLETE:
569        return "http://hl7.org/fhir/issue-type";
570      case THROTTLED:
571        return "http://hl7.org/fhir/issue-type";
572      case INFORMATIONAL:
573        return "http://hl7.org/fhir/issue-type";
574      case NULL:
575        return null;
576      default:
577        return "?";
578      }
579    }
580
581    public String getDefinition() {
582      switch (this) {
583      case INVALID:
584        return "Content invalid against the specification or a profile.";
585      case STRUCTURE:
586        return "A structural issue in the content such as wrong namespace, unable to parse the content completely, invalid syntax, etc.";
587      case REQUIRED:
588        return "A required element is missing.";
589      case VALUE:
590        return "An element or header value is invalid.";
591      case INVARIANT:
592        return "A content validation rule failed - e.g. a schematron rule.";
593      case SECURITY:
594        return "An authentication/authorization/permissions issue of some kind.";
595      case LOGIN:
596        return "The client needs to initiate an authentication process.";
597      case UNKNOWN:
598        return "The user or system was not able to be authenticated (either there is no process, or the proferred token is unacceptable).";
599      case EXPIRED:
600        return "User session expired; a login may be required.";
601      case FORBIDDEN:
602        return "The user does not have the rights to perform this action.";
603      case SUPPRESSED:
604        return "Some information was not or might not have been returned due to business rules, consent or privacy rules, or access permission constraints.  This information may be accessible through alternate processes.";
605      case PROCESSING:
606        return "Processing issues. These are expected to be final e.g. there is no point resubmitting the same content unchanged.";
607      case NOTSUPPORTED:
608        return "The interaction, operation, resource or profile is not supported.";
609      case DUPLICATE:
610        return "An attempt was made to create a duplicate record.";
611      case MULTIPLEMATCHES:
612        return "Multiple matching records were found when the operation required only one match.";
613      case NOTFOUND:
614        return "The reference provided was not found. In a pure RESTful environment, this would be an HTTP 404 error, but this code may be used where the content is not found further into the application architecture.";
615      case DELETED:
616        return "The reference pointed to content (usually a resource) that has been deleted.";
617      case TOOLONG:
618        return "Provided content is too long (typically, this is a denial of service protection type of error).";
619      case CODEINVALID:
620        return "The code or system could not be understood, or it was not valid in the context of a particular ValueSet.code.";
621      case EXTENSION:
622        return "An extension was found that was not acceptable, could not be resolved, or a modifierExtension was not recognized.";
623      case TOOCOSTLY:
624        return "The operation was stopped to protect server resources; e.g. a request for a value set expansion on all of SNOMED CT.";
625      case BUSINESSRULE:
626        return "The content/operation failed to pass some business rule and so could not proceed.";
627      case CONFLICT:
628        return "Content could not be accepted because of an edit conflict (i.e. version aware updates). (In a pure RESTful environment, this would be an HTTP 409 error, but this code may be used where the conflict is discovered further into the application architecture.).";
629      case TRANSIENT:
630        return "Transient processing issues. The system receiving the message may be able to resubmit the same content once an underlying issue is resolved.";
631      case LOCKERROR:
632        return "A resource/record locking failure (usually in an underlying database).";
633      case NOSTORE:
634        return "The persistent store is unavailable; e.g. the database is down for maintenance or similar action, and the interaction or operation cannot be processed.";
635      case EXCEPTION:
636        return "An unexpected internal error has occurred.";
637      case TIMEOUT:
638        return "An internal timeout has occurred.";
639      case INCOMPLETE:
640        return "Not all data sources typically accessed could be reached or responded in time, so the returned information might not be complete (applies to search interactions and some operations).";
641      case THROTTLED:
642        return "The system is not prepared to handle this request due to load management.";
643      case INFORMATIONAL:
644        return "A message unrelated to the processing success of the completed operation (examples of the latter include things like reminders of password expiry, system maintenance times, etc.).";
645      case NULL:
646        return null;
647      default:
648        return "?";
649      }
650    }
651
652    public String getDisplay() {
653      switch (this) {
654      case INVALID:
655        return "Invalid Content";
656      case STRUCTURE:
657        return "Structural Issue";
658      case REQUIRED:
659        return "Required element missing";
660      case VALUE:
661        return "Element value invalid";
662      case INVARIANT:
663        return "Validation rule failed";
664      case SECURITY:
665        return "Security Problem";
666      case LOGIN:
667        return "Login Required";
668      case UNKNOWN:
669        return "Unknown User";
670      case EXPIRED:
671        return "Session Expired";
672      case FORBIDDEN:
673        return "Forbidden";
674      case SUPPRESSED:
675        return "Information  Suppressed";
676      case PROCESSING:
677        return "Processing Failure";
678      case NOTSUPPORTED:
679        return "Content not supported";
680      case DUPLICATE:
681        return "Duplicate";
682      case MULTIPLEMATCHES:
683        return "Multiple Matches";
684      case NOTFOUND:
685        return "Not Found";
686      case DELETED:
687        return "Deleted";
688      case TOOLONG:
689        return "Content Too Long";
690      case CODEINVALID:
691        return "Invalid Code";
692      case EXTENSION:
693        return "Unacceptable Extension";
694      case TOOCOSTLY:
695        return "Operation Too Costly";
696      case BUSINESSRULE:
697        return "Business Rule Violation";
698      case CONFLICT:
699        return "Edit Version Conflict";
700      case TRANSIENT:
701        return "Transient Issue";
702      case LOCKERROR:
703        return "Lock Error";
704      case NOSTORE:
705        return "No Store Available";
706      case EXCEPTION:
707        return "Exception";
708      case TIMEOUT:
709        return "Timeout";
710      case INCOMPLETE:
711        return "Incomplete Results";
712      case THROTTLED:
713        return "Throttled";
714      case INFORMATIONAL:
715        return "Informational Note";
716      case NULL:
717        return null;
718      default:
719        return "?";
720      }
721    }
722  }
723
724  public static class IssueTypeEnumFactory implements EnumFactory<IssueType> {
725    public IssueType fromCode(String codeString) throws IllegalArgumentException {
726      if (codeString == null || "".equals(codeString))
727        if (codeString == null || "".equals(codeString))
728          return null;
729      if ("invalid".equals(codeString))
730        return IssueType.INVALID;
731      if ("structure".equals(codeString))
732        return IssueType.STRUCTURE;
733      if ("required".equals(codeString))
734        return IssueType.REQUIRED;
735      if ("value".equals(codeString))
736        return IssueType.VALUE;
737      if ("invariant".equals(codeString))
738        return IssueType.INVARIANT;
739      if ("security".equals(codeString))
740        return IssueType.SECURITY;
741      if ("login".equals(codeString))
742        return IssueType.LOGIN;
743      if ("unknown".equals(codeString))
744        return IssueType.UNKNOWN;
745      if ("expired".equals(codeString))
746        return IssueType.EXPIRED;
747      if ("forbidden".equals(codeString))
748        return IssueType.FORBIDDEN;
749      if ("suppressed".equals(codeString))
750        return IssueType.SUPPRESSED;
751      if ("processing".equals(codeString))
752        return IssueType.PROCESSING;
753      if ("not-supported".equals(codeString))
754        return IssueType.NOTSUPPORTED;
755      if ("duplicate".equals(codeString))
756        return IssueType.DUPLICATE;
757      if ("multiple-matches".equals(codeString))
758        return IssueType.MULTIPLEMATCHES;
759      if ("not-found".equals(codeString))
760        return IssueType.NOTFOUND;
761      if ("deleted".equals(codeString))
762        return IssueType.DELETED;
763      if ("too-long".equals(codeString))
764        return IssueType.TOOLONG;
765      if ("code-invalid".equals(codeString))
766        return IssueType.CODEINVALID;
767      if ("extension".equals(codeString))
768        return IssueType.EXTENSION;
769      if ("too-costly".equals(codeString))
770        return IssueType.TOOCOSTLY;
771      if ("business-rule".equals(codeString))
772        return IssueType.BUSINESSRULE;
773      if ("conflict".equals(codeString))
774        return IssueType.CONFLICT;
775      if ("transient".equals(codeString))
776        return IssueType.TRANSIENT;
777      if ("lock-error".equals(codeString))
778        return IssueType.LOCKERROR;
779      if ("no-store".equals(codeString))
780        return IssueType.NOSTORE;
781      if ("exception".equals(codeString))
782        return IssueType.EXCEPTION;
783      if ("timeout".equals(codeString))
784        return IssueType.TIMEOUT;
785      if ("incomplete".equals(codeString))
786        return IssueType.INCOMPLETE;
787      if ("throttled".equals(codeString))
788        return IssueType.THROTTLED;
789      if ("informational".equals(codeString))
790        return IssueType.INFORMATIONAL;
791      throw new IllegalArgumentException("Unknown IssueType code '" + codeString + "'");
792    }
793
794    public Enumeration<IssueType> fromType(PrimitiveType<?> code) throws FHIRException {
795      if (code == null)
796        return null;
797      if (code.isEmpty())
798        return new Enumeration<IssueType>(this, IssueType.NULL, code);
799      String codeString = code.asStringValue();
800      if (codeString == null || "".equals(codeString))
801        return new Enumeration<IssueType>(this, IssueType.NULL, code);
802      if ("invalid".equals(codeString))
803        return new Enumeration<IssueType>(this, IssueType.INVALID, code);
804      if ("structure".equals(codeString))
805        return new Enumeration<IssueType>(this, IssueType.STRUCTURE, code);
806      if ("required".equals(codeString))
807        return new Enumeration<IssueType>(this, IssueType.REQUIRED, code);
808      if ("value".equals(codeString))
809        return new Enumeration<IssueType>(this, IssueType.VALUE, code);
810      if ("invariant".equals(codeString))
811        return new Enumeration<IssueType>(this, IssueType.INVARIANT, code);
812      if ("security".equals(codeString))
813        return new Enumeration<IssueType>(this, IssueType.SECURITY, code);
814      if ("login".equals(codeString))
815        return new Enumeration<IssueType>(this, IssueType.LOGIN, code);
816      if ("unknown".equals(codeString))
817        return new Enumeration<IssueType>(this, IssueType.UNKNOWN, code);
818      if ("expired".equals(codeString))
819        return new Enumeration<IssueType>(this, IssueType.EXPIRED, code);
820      if ("forbidden".equals(codeString))
821        return new Enumeration<IssueType>(this, IssueType.FORBIDDEN, code);
822      if ("suppressed".equals(codeString))
823        return new Enumeration<IssueType>(this, IssueType.SUPPRESSED, code);
824      if ("processing".equals(codeString))
825        return new Enumeration<IssueType>(this, IssueType.PROCESSING, code);
826      if ("not-supported".equals(codeString))
827        return new Enumeration<IssueType>(this, IssueType.NOTSUPPORTED, code);
828      if ("duplicate".equals(codeString))
829        return new Enumeration<IssueType>(this, IssueType.DUPLICATE, code);
830      if ("multiple-matches".equals(codeString))
831        return new Enumeration<IssueType>(this, IssueType.MULTIPLEMATCHES, code);
832      if ("not-found".equals(codeString))
833        return new Enumeration<IssueType>(this, IssueType.NOTFOUND, code);
834      if ("deleted".equals(codeString))
835        return new Enumeration<IssueType>(this, IssueType.DELETED, code);
836      if ("too-long".equals(codeString))
837        return new Enumeration<IssueType>(this, IssueType.TOOLONG, code);
838      if ("code-invalid".equals(codeString))
839        return new Enumeration<IssueType>(this, IssueType.CODEINVALID, code);
840      if ("extension".equals(codeString))
841        return new Enumeration<IssueType>(this, IssueType.EXTENSION, code);
842      if ("too-costly".equals(codeString))
843        return new Enumeration<IssueType>(this, IssueType.TOOCOSTLY, code);
844      if ("business-rule".equals(codeString))
845        return new Enumeration<IssueType>(this, IssueType.BUSINESSRULE, code);
846      if ("conflict".equals(codeString))
847        return new Enumeration<IssueType>(this, IssueType.CONFLICT, code);
848      if ("transient".equals(codeString))
849        return new Enumeration<IssueType>(this, IssueType.TRANSIENT, code);
850      if ("lock-error".equals(codeString))
851        return new Enumeration<IssueType>(this, IssueType.LOCKERROR, code);
852      if ("no-store".equals(codeString))
853        return new Enumeration<IssueType>(this, IssueType.NOSTORE, code);
854      if ("exception".equals(codeString))
855        return new Enumeration<IssueType>(this, IssueType.EXCEPTION, code);
856      if ("timeout".equals(codeString))
857        return new Enumeration<IssueType>(this, IssueType.TIMEOUT, code);
858      if ("incomplete".equals(codeString))
859        return new Enumeration<IssueType>(this, IssueType.INCOMPLETE, code);
860      if ("throttled".equals(codeString))
861        return new Enumeration<IssueType>(this, IssueType.THROTTLED, code);
862      if ("informational".equals(codeString))
863        return new Enumeration<IssueType>(this, IssueType.INFORMATIONAL, code);
864      throw new FHIRException("Unknown IssueType code '" + codeString + "'");
865    }
866
867    public String toCode(IssueType code) {
868      if (code == IssueType.INVALID)
869        return "invalid";
870      if (code == IssueType.STRUCTURE)
871        return "structure";
872      if (code == IssueType.REQUIRED)
873        return "required";
874      if (code == IssueType.VALUE)
875        return "value";
876      if (code == IssueType.INVARIANT)
877        return "invariant";
878      if (code == IssueType.SECURITY)
879        return "security";
880      if (code == IssueType.LOGIN)
881        return "login";
882      if (code == IssueType.UNKNOWN)
883        return "unknown";
884      if (code == IssueType.EXPIRED)
885        return "expired";
886      if (code == IssueType.FORBIDDEN)
887        return "forbidden";
888      if (code == IssueType.SUPPRESSED)
889        return "suppressed";
890      if (code == IssueType.PROCESSING)
891        return "processing";
892      if (code == IssueType.NOTSUPPORTED)
893        return "not-supported";
894      if (code == IssueType.DUPLICATE)
895        return "duplicate";
896      if (code == IssueType.MULTIPLEMATCHES)
897        return "multiple-matches";
898      if (code == IssueType.NOTFOUND)
899        return "not-found";
900      if (code == IssueType.DELETED)
901        return "deleted";
902      if (code == IssueType.TOOLONG)
903        return "too-long";
904      if (code == IssueType.CODEINVALID)
905        return "code-invalid";
906      if (code == IssueType.EXTENSION)
907        return "extension";
908      if (code == IssueType.TOOCOSTLY)
909        return "too-costly";
910      if (code == IssueType.BUSINESSRULE)
911        return "business-rule";
912      if (code == IssueType.CONFLICT)
913        return "conflict";
914      if (code == IssueType.TRANSIENT)
915        return "transient";
916      if (code == IssueType.LOCKERROR)
917        return "lock-error";
918      if (code == IssueType.NOSTORE)
919        return "no-store";
920      if (code == IssueType.EXCEPTION)
921        return "exception";
922      if (code == IssueType.TIMEOUT)
923        return "timeout";
924      if (code == IssueType.INCOMPLETE)
925        return "incomplete";
926      if (code == IssueType.THROTTLED)
927        return "throttled";
928      if (code == IssueType.INFORMATIONAL)
929        return "informational";
930      return "?";
931    }
932
933    public String toSystem(IssueType code) {
934      return code.getSystem();
935    }
936  }
937
938  @Block()
939  public static class OperationOutcomeIssueComponent extends BackboneElement implements IBaseBackboneElement {
940    /**
941     * Indicates whether the issue indicates a variation from successful processing.
942     */
943    @Child(name = "severity", type = { CodeType.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
944    @Description(shortDefinition = "fatal | error | warning | information", formalDefinition = "Indicates whether the issue indicates a variation from successful processing.")
945    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/issue-severity")
946    protected Enumeration<IssueSeverity> severity;
947
948    /**
949     * Describes the type of the issue. The system that creates an OperationOutcome
950     * SHALL choose the most applicable code from the IssueType value set, and may
951     * additional provide its own code for the error in the details element.
952     */
953    @Child(name = "code", type = { CodeType.class }, order = 2, min = 1, max = 1, modifier = false, summary = true)
954    @Description(shortDefinition = "Error or warning code", formalDefinition = "Describes the type of the issue. The system that creates an OperationOutcome SHALL choose the most applicable code from the IssueType value set, and may additional provide its own code for the error in the details element.")
955    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/issue-type")
956    protected Enumeration<IssueType> code;
957
958    /**
959     * Additional details about the error. This may be a text description of the
960     * error or a system code that identifies the error.
961     */
962    @Child(name = "details", type = {
963        CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
964    @Description(shortDefinition = "Additional details about the error", formalDefinition = "Additional details about the error. This may be a text description of the error or a system code that identifies the error.")
965    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/operation-outcome")
966    protected CodeableConcept details;
967
968    /**
969     * Additional diagnostic information about the issue.
970     */
971    @Child(name = "diagnostics", type = {
972        StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
973    @Description(shortDefinition = "Additional diagnostic information about the issue", formalDefinition = "Additional diagnostic information about the issue.")
974    protected StringType diagnostics;
975
976    /**
977     * This element is deprecated because it is XML specific. It is replaced by
978     * issue.expression, which is format independent, and simpler to parse.
979     * 
980     * For resource issues, this will be a simple XPath limited to element names,
981     * repetition indicators and the default child accessor that identifies one of
982     * the elements in the resource that caused this issue to be raised. For HTTP
983     * errors, will be "http." + the parameter name.
984     */
985    @Child(name = "location", type = {
986        StringType.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
987    @Description(shortDefinition = "Deprecated: Path of element(s) related to issue", formalDefinition = "This element is deprecated because it is XML specific. It is replaced by issue.expression, which is format independent, and simpler to parse. \n\nFor resource issues, this will be a simple XPath limited to element names, repetition indicators and the default child accessor that identifies one of the elements in the resource that caused this issue to be raised.  For HTTP errors, will be \"http.\" + the parameter name.")
988    protected List<StringType> location;
989
990    /**
991     * A [simple subset of FHIRPath](fhirpath.html#simple) limited to element names,
992     * repetition indicators and the default child accessor that identifies one of
993     * the elements in the resource that caused this issue to be raised.
994     */
995    @Child(name = "expression", type = {
996        StringType.class }, order = 6, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
997    @Description(shortDefinition = "FHIRPath of element(s) related to issue", formalDefinition = "A [simple subset of FHIRPath](fhirpath.html#simple) limited to element names, repetition indicators and the default child accessor that identifies one of the elements in the resource that caused this issue to be raised.")
998    protected List<StringType> expression;
999
1000    private static final long serialVersionUID = -1681095438L;
1001
1002    /**
1003     * Constructor
1004     */
1005    public OperationOutcomeIssueComponent() {
1006      super();
1007    }
1008
1009    /**
1010     * Constructor
1011     */
1012    public OperationOutcomeIssueComponent(Enumeration<IssueSeverity> severity, Enumeration<IssueType> code) {
1013      super();
1014      this.severity = severity;
1015      this.code = code;
1016    }
1017
1018    /**
1019     * @return {@link #severity} (Indicates whether the issue indicates a variation
1020     *         from successful processing.). This is the underlying object with id,
1021     *         value and extensions. The accessor "getSeverity" gives direct access
1022     *         to the value
1023     */
1024    public Enumeration<IssueSeverity> getSeverityElement() {
1025      if (this.severity == null)
1026        if (Configuration.errorOnAutoCreate())
1027          throw new Error("Attempt to auto-create OperationOutcomeIssueComponent.severity");
1028        else if (Configuration.doAutoCreate())
1029          this.severity = new Enumeration<IssueSeverity>(new IssueSeverityEnumFactory()); // bb
1030      return this.severity;
1031    }
1032
1033    public boolean hasSeverityElement() {
1034      return this.severity != null && !this.severity.isEmpty();
1035    }
1036
1037    public boolean hasSeverity() {
1038      return this.severity != null && !this.severity.isEmpty();
1039    }
1040
1041    /**
1042     * @param value {@link #severity} (Indicates whether the issue indicates a
1043     *              variation from successful processing.). This is the underlying
1044     *              object with id, value and extensions. The accessor "getSeverity"
1045     *              gives direct access to the value
1046     */
1047    public OperationOutcomeIssueComponent setSeverityElement(Enumeration<IssueSeverity> value) {
1048      this.severity = value;
1049      return this;
1050    }
1051
1052    /**
1053     * @return Indicates whether the issue indicates a variation from successful
1054     *         processing.
1055     */
1056    public IssueSeverity getSeverity() {
1057      return this.severity == null ? null : this.severity.getValue();
1058    }
1059
1060    /**
1061     * @param value Indicates whether the issue indicates a variation from
1062     *              successful processing.
1063     */
1064    public OperationOutcomeIssueComponent setSeverity(IssueSeverity value) {
1065      if (this.severity == null)
1066        this.severity = new Enumeration<IssueSeverity>(new IssueSeverityEnumFactory());
1067      this.severity.setValue(value);
1068      return this;
1069    }
1070
1071    /**
1072     * @return {@link #code} (Describes the type of the issue. The system that
1073     *         creates an OperationOutcome SHALL choose the most applicable code
1074     *         from the IssueType value set, and may additional provide its own code
1075     *         for the error in the details element.). This is the underlying object
1076     *         with id, value and extensions. The accessor "getCode" gives direct
1077     *         access to the value
1078     */
1079    public Enumeration<IssueType> getCodeElement() {
1080      if (this.code == null)
1081        if (Configuration.errorOnAutoCreate())
1082          throw new Error("Attempt to auto-create OperationOutcomeIssueComponent.code");
1083        else if (Configuration.doAutoCreate())
1084          this.code = new Enumeration<IssueType>(new IssueTypeEnumFactory()); // bb
1085      return this.code;
1086    }
1087
1088    public boolean hasCodeElement() {
1089      return this.code != null && !this.code.isEmpty();
1090    }
1091
1092    public boolean hasCode() {
1093      return this.code != null && !this.code.isEmpty();
1094    }
1095
1096    /**
1097     * @param value {@link #code} (Describes the type of the issue. The system that
1098     *              creates an OperationOutcome SHALL choose the most applicable
1099     *              code from the IssueType value set, and may additional provide
1100     *              its own code for the error in the details element.). This is the
1101     *              underlying object with id, value and extensions. The accessor
1102     *              "getCode" gives direct access to the value
1103     */
1104    public OperationOutcomeIssueComponent setCodeElement(Enumeration<IssueType> value) {
1105      this.code = value;
1106      return this;
1107    }
1108
1109    /**
1110     * @return Describes the type of the issue. The system that creates an
1111     *         OperationOutcome SHALL choose the most applicable code from the
1112     *         IssueType value set, and may additional provide its own code for the
1113     *         error in the details element.
1114     */
1115    public IssueType getCode() {
1116      return this.code == null ? null : this.code.getValue();
1117    }
1118
1119    /**
1120     * @param value Describes the type of the issue. The system that creates an
1121     *              OperationOutcome SHALL choose the most applicable code from the
1122     *              IssueType value set, and may additional provide its own code for
1123     *              the error in the details element.
1124     */
1125    public OperationOutcomeIssueComponent setCode(IssueType value) {
1126      if (this.code == null)
1127        this.code = new Enumeration<IssueType>(new IssueTypeEnumFactory());
1128      this.code.setValue(value);
1129      return this;
1130    }
1131
1132    /**
1133     * @return {@link #details} (Additional details about the error. This may be a
1134     *         text description of the error or a system code that identifies the
1135     *         error.)
1136     */
1137    public CodeableConcept getDetails() {
1138      if (this.details == null)
1139        if (Configuration.errorOnAutoCreate())
1140          throw new Error("Attempt to auto-create OperationOutcomeIssueComponent.details");
1141        else if (Configuration.doAutoCreate())
1142          this.details = new CodeableConcept(); // cc
1143      return this.details;
1144    }
1145
1146    public boolean hasDetails() {
1147      return this.details != null && !this.details.isEmpty();
1148    }
1149
1150    /**
1151     * @param value {@link #details} (Additional details about the error. This may
1152     *              be a text description of the error or a system code that
1153     *              identifies the error.)
1154     */
1155    public OperationOutcomeIssueComponent setDetails(CodeableConcept value) {
1156      this.details = value;
1157      return this;
1158    }
1159
1160    /**
1161     * @return {@link #diagnostics} (Additional diagnostic information about the
1162     *         issue.). This is the underlying object with id, value and extensions.
1163     *         The accessor "getDiagnostics" gives direct access to the value
1164     */
1165    public StringType getDiagnosticsElement() {
1166      if (this.diagnostics == null)
1167        if (Configuration.errorOnAutoCreate())
1168          throw new Error("Attempt to auto-create OperationOutcomeIssueComponent.diagnostics");
1169        else if (Configuration.doAutoCreate())
1170          this.diagnostics = new StringType(); // bb
1171      return this.diagnostics;
1172    }
1173
1174    public boolean hasDiagnosticsElement() {
1175      return this.diagnostics != null && !this.diagnostics.isEmpty();
1176    }
1177
1178    public boolean hasDiagnostics() {
1179      return this.diagnostics != null && !this.diagnostics.isEmpty();
1180    }
1181
1182    /**
1183     * @param value {@link #diagnostics} (Additional diagnostic information about
1184     *              the issue.). This is the underlying object with id, value and
1185     *              extensions. The accessor "getDiagnostics" gives direct access to
1186     *              the value
1187     */
1188    public OperationOutcomeIssueComponent setDiagnosticsElement(StringType value) {
1189      this.diagnostics = value;
1190      return this;
1191    }
1192
1193    /**
1194     * @return Additional diagnostic information about the issue.
1195     */
1196    public String getDiagnostics() {
1197      return this.diagnostics == null ? null : this.diagnostics.getValue();
1198    }
1199
1200    /**
1201     * @param value Additional diagnostic information about the issue.
1202     */
1203    public OperationOutcomeIssueComponent setDiagnostics(String value) {
1204      if (Utilities.noString(value))
1205        this.diagnostics = null;
1206      else {
1207        if (this.diagnostics == null)
1208          this.diagnostics = new StringType();
1209        this.diagnostics.setValue(value);
1210      }
1211      return this;
1212    }
1213
1214    /**
1215     * @return {@link #location} (This element is deprecated because it is XML
1216     *         specific. It is replaced by issue.expression, which is format
1217     *         independent, and simpler to parse.
1218     * 
1219     *         For resource issues, this will be a simple XPath limited to element
1220     *         names, repetition indicators and the default child accessor that
1221     *         identifies one of the elements in the resource that caused this issue
1222     *         to be raised. For HTTP errors, will be "http." + the parameter name.)
1223     */
1224    public List<StringType> getLocation() {
1225      if (this.location == null)
1226        this.location = new ArrayList<StringType>();
1227      return this.location;
1228    }
1229
1230    /**
1231     * @return Returns a reference to <code>this</code> for easy method chaining
1232     */
1233    public OperationOutcomeIssueComponent setLocation(List<StringType> theLocation) {
1234      this.location = theLocation;
1235      return this;
1236    }
1237
1238    public boolean hasLocation() {
1239      if (this.location == null)
1240        return false;
1241      for (StringType item : this.location)
1242        if (!item.isEmpty())
1243          return true;
1244      return false;
1245    }
1246
1247    /**
1248     * @return {@link #location} (This element is deprecated because it is XML
1249     *         specific. It is replaced by issue.expression, which is format
1250     *         independent, and simpler to parse.
1251     * 
1252     *         For resource issues, this will be a simple XPath limited to element
1253     *         names, repetition indicators and the default child accessor that
1254     *         identifies one of the elements in the resource that caused this issue
1255     *         to be raised. For HTTP errors, will be "http." + the parameter name.)
1256     */
1257    public StringType addLocationElement() {// 2
1258      StringType t = new StringType();
1259      if (this.location == null)
1260        this.location = new ArrayList<StringType>();
1261      this.location.add(t);
1262      return t;
1263    }
1264
1265    /**
1266     * @param value {@link #location} (This element is deprecated because it is XML
1267     *              specific. It is replaced by issue.expression, which is format
1268     *              independent, and simpler to parse.
1269     * 
1270     *              For resource issues, this will be a simple XPath limited to
1271     *              element names, repetition indicators and the default child
1272     *              accessor that identifies one of the elements in the resource
1273     *              that caused this issue to be raised. For HTTP errors, will be
1274     *              "http." + the parameter name.)
1275     */
1276    public OperationOutcomeIssueComponent addLocation(String value) { // 1
1277      StringType t = new StringType();
1278      t.setValue(value);
1279      if (this.location == null)
1280        this.location = new ArrayList<StringType>();
1281      this.location.add(t);
1282      return this;
1283    }
1284
1285    /**
1286     * @param value {@link #location} (This element is deprecated because it is XML
1287     *              specific. It is replaced by issue.expression, which is format
1288     *              independent, and simpler to parse.
1289     * 
1290     *              For resource issues, this will be a simple XPath limited to
1291     *              element names, repetition indicators and the default child
1292     *              accessor that identifies one of the elements in the resource
1293     *              that caused this issue to be raised. For HTTP errors, will be
1294     *              "http." + the parameter name.)
1295     */
1296    public boolean hasLocation(String value) {
1297      if (this.location == null)
1298        return false;
1299      for (StringType v : this.location)
1300        if (v.getValue().equals(value)) // string
1301          return true;
1302      return false;
1303    }
1304
1305    /**
1306     * @return {@link #expression} (A [simple subset of
1307     *         FHIRPath](fhirpath.html#simple) limited to element names, repetition
1308     *         indicators and the default child accessor that identifies one of the
1309     *         elements in the resource that caused this issue to be raised.)
1310     */
1311    public List<StringType> getExpression() {
1312      if (this.expression == null)
1313        this.expression = new ArrayList<StringType>();
1314      return this.expression;
1315    }
1316
1317    /**
1318     * @return Returns a reference to <code>this</code> for easy method chaining
1319     */
1320    public OperationOutcomeIssueComponent setExpression(List<StringType> theExpression) {
1321      this.expression = theExpression;
1322      return this;
1323    }
1324
1325    public boolean hasExpression() {
1326      if (this.expression == null)
1327        return false;
1328      for (StringType item : this.expression)
1329        if (!item.isEmpty())
1330          return true;
1331      return false;
1332    }
1333
1334    /**
1335     * @return {@link #expression} (A [simple subset of
1336     *         FHIRPath](fhirpath.html#simple) limited to element names, repetition
1337     *         indicators and the default child accessor that identifies one of the
1338     *         elements in the resource that caused this issue to be raised.)
1339     */
1340    public StringType addExpressionElement() {// 2
1341      StringType t = new StringType();
1342      if (this.expression == null)
1343        this.expression = new ArrayList<StringType>();
1344      this.expression.add(t);
1345      return t;
1346    }
1347
1348    /**
1349     * @param value {@link #expression} (A [simple subset of
1350     *              FHIRPath](fhirpath.html#simple) limited to element names,
1351     *              repetition indicators and the default child accessor that
1352     *              identifies one of the elements in the resource that caused this
1353     *              issue to be raised.)
1354     */
1355    public OperationOutcomeIssueComponent addExpression(String value) { // 1
1356      StringType t = new StringType();
1357      t.setValue(value);
1358      if (this.expression == null)
1359        this.expression = new ArrayList<StringType>();
1360      this.expression.add(t);
1361      return this;
1362    }
1363
1364    /**
1365     * @param value {@link #expression} (A [simple subset of
1366     *              FHIRPath](fhirpath.html#simple) limited to element names,
1367     *              repetition indicators and the default child accessor that
1368     *              identifies one of the elements in the resource that caused this
1369     *              issue to be raised.)
1370     */
1371    public boolean hasExpression(String value) {
1372      if (this.expression == null)
1373        return false;
1374      for (StringType v : this.expression)
1375        if (v.getValue().equals(value)) // string
1376          return true;
1377      return false;
1378    }
1379
1380    protected void listChildren(List<Property> children) {
1381      super.listChildren(children);
1382      children.add(new Property("severity", "code",
1383          "Indicates whether the issue indicates a variation from successful processing.", 0, 1, severity));
1384      children.add(new Property("code", "code",
1385          "Describes the type of the issue. The system that creates an OperationOutcome SHALL choose the most applicable code from the IssueType value set, and may additional provide its own code for the error in the details element.",
1386          0, 1, code));
1387      children.add(new Property("details", "CodeableConcept",
1388          "Additional details about the error. This may be a text description of the error or a system code that identifies the error.",
1389          0, 1, details));
1390      children.add(new Property("diagnostics", "string", "Additional diagnostic information about the issue.", 0, 1,
1391          diagnostics));
1392      children.add(new Property("location", "string",
1393          "This element is deprecated because it is XML specific. It is replaced by issue.expression, which is format independent, and simpler to parse. \n\nFor resource issues, this will be a simple XPath limited to element names, repetition indicators and the default child accessor that identifies one of the elements in the resource that caused this issue to be raised.  For HTTP errors, will be \"http.\" + the parameter name.",
1394          0, java.lang.Integer.MAX_VALUE, location));
1395      children.add(new Property("expression", "string",
1396          "A [simple subset of FHIRPath](fhirpath.html#simple) limited to element names, repetition indicators and the default child accessor that identifies one of the elements in the resource that caused this issue to be raised.",
1397          0, java.lang.Integer.MAX_VALUE, expression));
1398    }
1399
1400    @Override
1401    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1402      switch (_hash) {
1403      case 1478300413:
1404        /* severity */ return new Property("severity", "code",
1405            "Indicates whether the issue indicates a variation from successful processing.", 0, 1, severity);
1406      case 3059181:
1407        /* code */ return new Property("code", "code",
1408            "Describes the type of the issue. The system that creates an OperationOutcome SHALL choose the most applicable code from the IssueType value set, and may additional provide its own code for the error in the details element.",
1409            0, 1, code);
1410      case 1557721666:
1411        /* details */ return new Property("details", "CodeableConcept",
1412            "Additional details about the error. This may be a text description of the error or a system code that identifies the error.",
1413            0, 1, details);
1414      case -740386388:
1415        /* diagnostics */ return new Property("diagnostics", "string",
1416            "Additional diagnostic information about the issue.", 0, 1, diagnostics);
1417      case 1901043637:
1418        /* location */ return new Property("location", "string",
1419            "This element is deprecated because it is XML specific. It is replaced by issue.expression, which is format independent, and simpler to parse. \n\nFor resource issues, this will be a simple XPath limited to element names, repetition indicators and the default child accessor that identifies one of the elements in the resource that caused this issue to be raised.  For HTTP errors, will be \"http.\" + the parameter name.",
1420            0, java.lang.Integer.MAX_VALUE, location);
1421      case -1795452264:
1422        /* expression */ return new Property("expression", "string",
1423            "A [simple subset of FHIRPath](fhirpath.html#simple) limited to element names, repetition indicators and the default child accessor that identifies one of the elements in the resource that caused this issue to be raised.",
1424            0, java.lang.Integer.MAX_VALUE, expression);
1425      default:
1426        return super.getNamedProperty(_hash, _name, _checkValid);
1427      }
1428
1429    }
1430
1431    @Override
1432    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1433      switch (hash) {
1434      case 1478300413:
1435        /* severity */ return this.severity == null ? new Base[0] : new Base[] { this.severity }; // Enumeration<IssueSeverity>
1436      case 3059181:
1437        /* code */ return this.code == null ? new Base[0] : new Base[] { this.code }; // Enumeration<IssueType>
1438      case 1557721666:
1439        /* details */ return this.details == null ? new Base[0] : new Base[] { this.details }; // CodeableConcept
1440      case -740386388:
1441        /* diagnostics */ return this.diagnostics == null ? new Base[0] : new Base[] { this.diagnostics }; // StringType
1442      case 1901043637:
1443        /* location */ return this.location == null ? new Base[0]
1444            : this.location.toArray(new Base[this.location.size()]); // StringType
1445      case -1795452264:
1446        /* expression */ return this.expression == null ? new Base[0]
1447            : this.expression.toArray(new Base[this.expression.size()]); // StringType
1448      default:
1449        return super.getProperty(hash, name, checkValid);
1450      }
1451
1452    }
1453
1454    @Override
1455    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1456      switch (hash) {
1457      case 1478300413: // severity
1458        value = new IssueSeverityEnumFactory().fromType(castToCode(value));
1459        this.severity = (Enumeration) value; // Enumeration<IssueSeverity>
1460        return value;
1461      case 3059181: // code
1462        value = new IssueTypeEnumFactory().fromType(castToCode(value));
1463        this.code = (Enumeration) value; // Enumeration<IssueType>
1464        return value;
1465      case 1557721666: // details
1466        this.details = castToCodeableConcept(value); // CodeableConcept
1467        return value;
1468      case -740386388: // diagnostics
1469        this.diagnostics = castToString(value); // StringType
1470        return value;
1471      case 1901043637: // location
1472        this.getLocation().add(castToString(value)); // StringType
1473        return value;
1474      case -1795452264: // expression
1475        this.getExpression().add(castToString(value)); // StringType
1476        return value;
1477      default:
1478        return super.setProperty(hash, name, value);
1479      }
1480
1481    }
1482
1483    @Override
1484    public Base setProperty(String name, Base value) throws FHIRException {
1485      if (name.equals("severity")) {
1486        value = new IssueSeverityEnumFactory().fromType(castToCode(value));
1487        this.severity = (Enumeration) value; // Enumeration<IssueSeverity>
1488      } else if (name.equals("code")) {
1489        value = new IssueTypeEnumFactory().fromType(castToCode(value));
1490        this.code = (Enumeration) value; // Enumeration<IssueType>
1491      } else if (name.equals("details")) {
1492        this.details = castToCodeableConcept(value); // CodeableConcept
1493      } else if (name.equals("diagnostics")) {
1494        this.diagnostics = castToString(value); // StringType
1495      } else if (name.equals("location")) {
1496        this.getLocation().add(castToString(value));
1497      } else if (name.equals("expression")) {
1498        this.getExpression().add(castToString(value));
1499      } else
1500        return super.setProperty(name, value);
1501      return value;
1502    }
1503
1504    @Override
1505    public Base makeProperty(int hash, String name) throws FHIRException {
1506      switch (hash) {
1507      case 1478300413:
1508        return getSeverityElement();
1509      case 3059181:
1510        return getCodeElement();
1511      case 1557721666:
1512        return getDetails();
1513      case -740386388:
1514        return getDiagnosticsElement();
1515      case 1901043637:
1516        return addLocationElement();
1517      case -1795452264:
1518        return addExpressionElement();
1519      default:
1520        return super.makeProperty(hash, name);
1521      }
1522
1523    }
1524
1525    @Override
1526    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1527      switch (hash) {
1528      case 1478300413:
1529        /* severity */ return new String[] { "code" };
1530      case 3059181:
1531        /* code */ return new String[] { "code" };
1532      case 1557721666:
1533        /* details */ return new String[] { "CodeableConcept" };
1534      case -740386388:
1535        /* diagnostics */ return new String[] { "string" };
1536      case 1901043637:
1537        /* location */ return new String[] { "string" };
1538      case -1795452264:
1539        /* expression */ return new String[] { "string" };
1540      default:
1541        return super.getTypesForProperty(hash, name);
1542      }
1543
1544    }
1545
1546    @Override
1547    public Base addChild(String name) throws FHIRException {
1548      if (name.equals("severity")) {
1549        throw new FHIRException("Cannot call addChild on a singleton property OperationOutcome.severity");
1550      } else if (name.equals("code")) {
1551        throw new FHIRException("Cannot call addChild on a singleton property OperationOutcome.code");
1552      } else if (name.equals("details")) {
1553        this.details = new CodeableConcept();
1554        return this.details;
1555      } else if (name.equals("diagnostics")) {
1556        throw new FHIRException("Cannot call addChild on a singleton property OperationOutcome.diagnostics");
1557      } else if (name.equals("location")) {
1558        throw new FHIRException("Cannot call addChild on a singleton property OperationOutcome.location");
1559      } else if (name.equals("expression")) {
1560        throw new FHIRException("Cannot call addChild on a singleton property OperationOutcome.expression");
1561      } else
1562        return super.addChild(name);
1563    }
1564
1565    public OperationOutcomeIssueComponent copy() {
1566      OperationOutcomeIssueComponent dst = new OperationOutcomeIssueComponent();
1567      copyValues(dst);
1568      return dst;
1569    }
1570
1571    public void copyValues(OperationOutcomeIssueComponent dst) {
1572      super.copyValues(dst);
1573      dst.severity = severity == null ? null : severity.copy();
1574      dst.code = code == null ? null : code.copy();
1575      dst.details = details == null ? null : details.copy();
1576      dst.diagnostics = diagnostics == null ? null : diagnostics.copy();
1577      if (location != null) {
1578        dst.location = new ArrayList<StringType>();
1579        for (StringType i : location)
1580          dst.location.add(i.copy());
1581      }
1582      ;
1583      if (expression != null) {
1584        dst.expression = new ArrayList<StringType>();
1585        for (StringType i : expression)
1586          dst.expression.add(i.copy());
1587      }
1588      ;
1589    }
1590
1591    @Override
1592    public boolean equalsDeep(Base other_) {
1593      if (!super.equalsDeep(other_))
1594        return false;
1595      if (!(other_ instanceof OperationOutcomeIssueComponent))
1596        return false;
1597      OperationOutcomeIssueComponent o = (OperationOutcomeIssueComponent) other_;
1598      return compareDeep(severity, o.severity, true) && compareDeep(code, o.code, true)
1599          && compareDeep(details, o.details, true) && compareDeep(diagnostics, o.diagnostics, true)
1600          && compareDeep(location, o.location, true) && compareDeep(expression, o.expression, true);
1601    }
1602
1603    @Override
1604    public boolean equalsShallow(Base other_) {
1605      if (!super.equalsShallow(other_))
1606        return false;
1607      if (!(other_ instanceof OperationOutcomeIssueComponent))
1608        return false;
1609      OperationOutcomeIssueComponent o = (OperationOutcomeIssueComponent) other_;
1610      return compareValues(severity, o.severity, true) && compareValues(code, o.code, true)
1611          && compareValues(diagnostics, o.diagnostics, true) && compareValues(location, o.location, true)
1612          && compareValues(expression, o.expression, true);
1613    }
1614
1615    public boolean isEmpty() {
1616      return super.isEmpty()
1617          && ca.uhn.fhir.util.ElementUtil.isEmpty(severity, code, details, diagnostics, location, expression);
1618    }
1619
1620    public String fhirType() {
1621      return "OperationOutcome.issue";
1622
1623    }
1624
1625  }
1626
1627  /**
1628   * An error, warning, or information message that results from a system action.
1629   */
1630  @Child(name = "issue", type = {}, order = 0, min = 1, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1631  @Description(shortDefinition = "A single issue associated with the action", formalDefinition = "An error, warning, or information message that results from a system action.")
1632  protected List<OperationOutcomeIssueComponent> issue;
1633
1634  private static final long serialVersionUID = -152150052L;
1635
1636  /**
1637   * Constructor
1638   */
1639  public OperationOutcome() {
1640    super();
1641  }
1642
1643  /**
1644   * @return {@link #issue} (An error, warning, or information message that
1645   *         results from a system action.)
1646   */
1647  public List<OperationOutcomeIssueComponent> getIssue() {
1648    if (this.issue == null)
1649      this.issue = new ArrayList<OperationOutcomeIssueComponent>();
1650    return this.issue;
1651  }
1652
1653  /**
1654   * @return Returns a reference to <code>this</code> for easy method chaining
1655   */
1656  public OperationOutcome setIssue(List<OperationOutcomeIssueComponent> theIssue) {
1657    this.issue = theIssue;
1658    return this;
1659  }
1660
1661  public boolean hasIssue() {
1662    if (this.issue == null)
1663      return false;
1664    for (OperationOutcomeIssueComponent item : this.issue)
1665      if (!item.isEmpty())
1666        return true;
1667    return false;
1668  }
1669
1670  public OperationOutcomeIssueComponent addIssue() { // 3
1671    OperationOutcomeIssueComponent t = new OperationOutcomeIssueComponent();
1672    if (this.issue == null)
1673      this.issue = new ArrayList<OperationOutcomeIssueComponent>();
1674    this.issue.add(t);
1675    return t;
1676  }
1677
1678  public OperationOutcome addIssue(OperationOutcomeIssueComponent t) { // 3
1679    if (t == null)
1680      return this;
1681    if (this.issue == null)
1682      this.issue = new ArrayList<OperationOutcomeIssueComponent>();
1683    this.issue.add(t);
1684    return this;
1685  }
1686
1687  /**
1688   * @return The first repetition of repeating field {@link #issue}, creating it
1689   *         if it does not already exist
1690   */
1691  public OperationOutcomeIssueComponent getIssueFirstRep() {
1692    if (getIssue().isEmpty()) {
1693      addIssue();
1694    }
1695    return getIssue().get(0);
1696  }
1697
1698  protected void listChildren(List<Property> children) {
1699    super.listChildren(children);
1700    children
1701        .add(new Property("issue", "", "An error, warning, or information message that results from a system action.",
1702            0, java.lang.Integer.MAX_VALUE, issue));
1703  }
1704
1705  @Override
1706  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1707    switch (_hash) {
1708    case 100509913:
1709      /* issue */ return new Property("issue", "",
1710          "An error, warning, or information message that results from a system action.", 0,
1711          java.lang.Integer.MAX_VALUE, issue);
1712    default:
1713      return super.getNamedProperty(_hash, _name, _checkValid);
1714    }
1715
1716  }
1717
1718  @Override
1719  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1720    switch (hash) {
1721    case 100509913:
1722      /* issue */ return this.issue == null ? new Base[0] : this.issue.toArray(new Base[this.issue.size()]); // OperationOutcomeIssueComponent
1723    default:
1724      return super.getProperty(hash, name, checkValid);
1725    }
1726
1727  }
1728
1729  @Override
1730  public Base setProperty(int hash, String name, Base value) throws FHIRException {
1731    switch (hash) {
1732    case 100509913: // issue
1733      this.getIssue().add((OperationOutcomeIssueComponent) value); // OperationOutcomeIssueComponent
1734      return value;
1735    default:
1736      return super.setProperty(hash, name, value);
1737    }
1738
1739  }
1740
1741  @Override
1742  public Base setProperty(String name, Base value) throws FHIRException {
1743    if (name.equals("issue")) {
1744      this.getIssue().add((OperationOutcomeIssueComponent) value);
1745    } else
1746      return super.setProperty(name, value);
1747    return value;
1748  }
1749
1750  @Override
1751  public Base makeProperty(int hash, String name) throws FHIRException {
1752    switch (hash) {
1753    case 100509913:
1754      return addIssue();
1755    default:
1756      return super.makeProperty(hash, name);
1757    }
1758
1759  }
1760
1761  @Override
1762  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1763    switch (hash) {
1764    case 100509913:
1765      /* issue */ return new String[] {};
1766    default:
1767      return super.getTypesForProperty(hash, name);
1768    }
1769
1770  }
1771
1772  @Override
1773  public Base addChild(String name) throws FHIRException {
1774    if (name.equals("issue")) {
1775      return addIssue();
1776    } else
1777      return super.addChild(name);
1778  }
1779
1780  public String fhirType() {
1781    return "OperationOutcome";
1782
1783  }
1784
1785  public OperationOutcome copy() {
1786    OperationOutcome dst = new OperationOutcome();
1787    copyValues(dst);
1788    return dst;
1789  }
1790
1791  public void copyValues(OperationOutcome dst) {
1792    super.copyValues(dst);
1793    if (issue != null) {
1794      dst.issue = new ArrayList<OperationOutcomeIssueComponent>();
1795      for (OperationOutcomeIssueComponent i : issue)
1796        dst.issue.add(i.copy());
1797    }
1798    ;
1799  }
1800
1801  protected OperationOutcome typedCopy() {
1802    return copy();
1803  }
1804
1805  @Override
1806  public boolean equalsDeep(Base other_) {
1807    if (!super.equalsDeep(other_))
1808      return false;
1809    if (!(other_ instanceof OperationOutcome))
1810      return false;
1811    OperationOutcome o = (OperationOutcome) other_;
1812    return compareDeep(issue, o.issue, true);
1813  }
1814
1815  @Override
1816  public boolean equalsShallow(Base other_) {
1817    if (!super.equalsShallow(other_))
1818      return false;
1819    if (!(other_ instanceof OperationOutcome))
1820      return false;
1821    OperationOutcome o = (OperationOutcome) other_;
1822    return true;
1823  }
1824
1825  public boolean isEmpty() {
1826    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(issue);
1827  }
1828
1829  @Override
1830  public ResourceType getResourceType() {
1831    return ResourceType.OperationOutcome;
1832  }
1833
1834}