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