001/** 002The contents of this file are subject to the Mozilla Public License Version 1.1 003(the "License"); you may not use this file except in compliance with the License. 004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005Software distributed under the License is distributed on an "AS IS" basis, 006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007specific language governing rights and limitations under the License. 008 009The Original Code is "ErrorCode.java". Description: 010"Error code enumeration." 011 012The Initial Developer of the Original Code is University Health Network. Copyright (C) 0132012. All Rights Reserved. 014 015Contributor(s): ______________________________________. 016 017Alternatively, the contents of this file may be used under the terms of the 018GNU General Public License (the "GPL"), in which case the provisions of the GPL are 019applicable instead of those above. If you wish to allow use of your version of this 020file only under the terms of the GPL and not to allow others to use your version 021of this file under the MPL, indicate your decision by deleting the provisions above 022and replace them with the notice and other provisions required by the GPL License. 023If you do not delete the provisions above, a recipient may use your version of 024this file under either the MPL or the GPL. 025 */ 026package ca.uhn.hl7v2; 027 028/** 029 * Error code table 030 */ 031public enum ErrorCode { 032 MESSAGE_ACCEPTED(0, "Message accepted"), 033 SEGMENT_SEQUENCE_ERROR(100, "Segment sequence error"), 034 REQUIRED_FIELD_MISSING(101, "Required field missing"), 035 DATA_TYPE_ERROR(102, "Data type error"), 036 TABLE_VALUE_NOT_FOUND(103, "Table value not found"), 037 UNSUPPORTED_MESSAGE_TYPE(200, "Unsupported message type"), 038 UNSUPPORTED_EVENT_CODE(201, "Unsupported event code"), 039 UNSUPPORTED_PROCESSING_ID(202, "Unsupported processing id"), 040 UNSUPPORTED_VERSION_ID(203, "Unsupported version id"), 041 UNKNOWN_KEY_IDENTIFIER(204, "Unknown key identifier"), 042 DUPLICATE_KEY_IDENTIFIER(205, "Duplicate key identifier"), 043 APPLICATION_RECORD_LOCKED(206, "Application record locked"), 044 APPLICATION_INTERNAL_ERROR(207, "Application internal error"); 045 046 private static final String HL70357 = "HL70357"; 047 private final int code; 048 private final String message; 049 050 ErrorCode(int errCode, String message) { 051 this.code = errCode; 052 this.message = message; 053 } 054 055 /** 056 * @return the integer error code 057 */ 058 public int getCode() { 059 return code; 060 } 061 062 /** 063 * @return the error code message 064 */ 065 public String getMessage() { 066 return message; 067 } 068 069 /** 070 * Returns the ErrorCode for the given integer 071 * @param errCode integer error code 072 * @return ErrorCode 073 */ 074 public static ErrorCode errorCodeFor(int errCode) { 075 for (ErrorCode err : ErrorCode.values()) { 076 if (err.code == errCode) { 077 return err; 078 } 079 } 080 return null; 081 } 082 083 /** 084 * @return the HL7 table number 085 */ 086 public static String codeTable() { 087 return HL70357; 088 } 089}