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 * 031 */ 032public enum ErrorCode { 033 MESSAGE_ACCEPTED(0, "Message accepted"), 034 SEGMENT_SEQUENCE_ERROR(100, "Segment sequence error"), 035 REQUIRED_FIELD_MISSING(101, "Required field missing"), 036 DATA_TYPE_ERROR(102, "Data type error"), 037 TABLE_VALUE_NOT_FOUND(103, "Table value not found"), 038 UNSUPPORTED_MESSAGE_TYPE(200, "Unsupported message type"), 039 UNSUPPORTED_EVENT_CODE(201, "Unsupported event code"), 040 UNSUPPORTED_PROCESSING_ID(202, "Unsupported processing id"), 041 UNSUPPORTED_VERSION_ID(203, "Unsupported version id"), 042 UNKNOWN_KEY_IDENTIFIER(204, "Unknown key identifier"), 043 DUPLICATE_KEY_IDENTIFIER(205, "Duplicate key identifier"), 044 APPLICATION_RECORD_LOCKED(206, "Application record locked"), 045 APPLICATION_INTERNAL_ERROR(207, "Application internal error"); 046 047 private static final String HL70357 = "HL70357"; 048 private final int code; 049 private final String message; 050 051 ErrorCode(int errCode, String message) { 052 this.code = errCode; 053 this.message = message; 054 } 055 056 /** 057 * @return the integer error code 058 */ 059 public int getCode() { 060 return code; 061 } 062 063 /** 064 * @return the error code message 065 */ 066 public String getMessage() { 067 return message; 068 } 069 070 /** 071 * Returns the ErrorCode for the given integer 072 * @param errCode integer error code 073 * @return ErrorCode 074 */ 075 public static ErrorCode errorCodeFor(int errCode) { 076 for (ErrorCode err : ErrorCode.values()) { 077 if (err.code == errCode) { 078 return err; 079 } 080 } 081 return null; 082 } 083 084 /** 085 * @return the HL7 table number 086 */ 087 public static String codeTable() { 088 return HL70357; 089 } 090}