package ch.elexis.core.model.issue;

import java.util.ResourceBundle;

import ch.elexis.core.interfaces.ILocalizedEnum;
import ch.elexis.core.interfaces.INumericEnum;

public enum Type implements INumericEnum, ILocalizedEnum {

	// @formatter:off
	COMMON(0), 
	PRINT(1), 
	PRINT_DRUG_STICKER(2), 
	SEND_DOCUMENT(3), 
	READ_DOCUMENT(4), 
	CHECK_LAB_RESULT(5), 
	MAKE_APPOINTMENT(6), 
	DISPENSE_MEDICATION(7), 
	PROCESS_SERVICE_RECORDING(8);
	// @formatter:on

	private final int numeric;

	private Type(int numeric) {
		this.numeric = numeric;
	}

	public int numericValue() {
		return numeric;
	}

	public String getLocaleText() {
		try {
			return ResourceBundle.getBundle(ch.elexis.core.l10n.Messages.BUNDLE_NAME)
					.getString(Type.class.getSimpleName() + "_" + this.name());
		} catch (Exception e) {
			return this.name();
		}
	}

	public static Type byNumericSafe(String actionTypeIn) {
		int numeric = Integer.parseInt(actionTypeIn);
		for (Type actionType : Type.values()) {
			if (actionType.numericValue() == numeric) {
				return actionType;
			}
		}
		return Type.COMMON;
	}
}

@@ -60,24 +60,70 @@
 rceBundle;%0A%0A
+import org.apache.commons.lang3.StringUtils;%0A%0A
 import ch.el
@@ -934,16 +934,73 @@
 peIn) %7B%0A
+%09%09if (StringUtils.isNotBlank(actionTypeIn)) %7B%0A%09%09%09try %7B%0A%09%09
 %09%09int nu
@@ -1039,16 +1039,18 @@
 ypeIn);%0A
+%09%09
 %09%09for (T
@@ -1086,16 +1086,18 @@
 )) %7B%0A%09%09%09
+%09%09
 if (acti
@@ -1128,24 +1128,26 @@
  numeric) %7B%0A
+%09%09
 %09%09%09%09return a
@@ -1157,16 +1157,97 @@
 onType;%0A
+%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D catch (NumberFormatException ne) %7B%0A%09%09%09%09// ignore return common%0A
 %09%09%09%7D%0A%09%09%7D

add empty check bevore getting numeric value for Type