/*
* This code is made available under the terms of the Eclipse Public License v1.0
* in the github project https://github.com/project-husky/husky there you also
* find a list of the contributors and the license information.
*
* This project has been developed further and modified by the joined working group Husky
* on the basis of the eHealth Connector opensource project from June 28, 2021,
* whereas medshare GmbH is the initial and main contributor/author of the eHealth Connector.
*
*/
package org.projecthusky.common.enums;
import org.projecthusky.common.hl7cdar2.CS;
import org.projecthusky.common.model.Code;
/*
*Die Codes beschreiben die möglichen Zustände einer Aktion
*
*/
public enum StatusCode {
/**
* nicht mehr gewollt
*
*/
ABORTED(EnumConstants.ABORTED_CODE, EnumConstants.ABORTED_CODE),
/**
* aktiv
*
*/
ACTIVE(EnumConstants.ACTIVE_CODE, EnumConstants.ACTIVE_CODE),
/**
* abgebrochen
*
*/
CANCELLED(EnumConstants.CANCELLED_CODE, EnumConstants.CANCELLED_CODE),
/**
* erledigt
*
*/
COMPLETED(EnumConstants.COMPLETED_CODE, EnumConstants.COMPLETED_CODE),
/**
* abwartend
*
*/
HELD("held", "held"),
/**
* aktuell
*
*/
NEW("new", "new"),
/**
* ausgesetzt
*
*/
SUSPENDED(EnumConstants.SUSPENDED_CODE, EnumConstants.SUSPENDED_CODE);
public static final String ABORTED_CODE = EnumConstants.ABORTED_CODE;
public static final String ACTIVE_CODE = EnumConstants.ACTIVE_CODE;
public static final String CANCELLED_CODE = EnumConstants.CANCELLED_CODE;
/**
* Name of the Code System
Name des
* Codes Systems
*/
public static final String CODE_SYSTEM_NAME = "ActStatus";
/**
* Identifier of the Code System
* Identifikator für das Code System
*/
public static final String CODE_SYSTEM_OID = "2.16.840.1.113883.5.14";
public static final String COMPLETED_CODE = EnumConstants.COMPLETED_CODE;
public static final String HELD_CODE = "held";
public static final String NEW_CODE = "new";
public static final String SUSPENDED_CODE = EnumConstants.SUSPENDED_CODE;
/**
* Gets the Enum with a given code
* Liefert den Enum anhand eines gegebenen codes
*
* @param code
*
* code
* @return the enum
*/
public static StatusCode getEnum(String code) {
for (final StatusCode x : values()) {
if (x.getCodeValue().equals(code)) {
return x;
}
}
return null;
}
/**
* Checks if a given enum is part of this value set.
* Prüft, ob der gegebene enum Teil dieses Value Sets
* ist.
*
*
* @param enumName
*
* enumName
* @return true, if enum is in this value set
*/
public static boolean isEnumOfValueSet(String enumName) {
if (enumName == null) {
return false;
}
try {
Enum.valueOf(StatusCode.class, enumName);
return true;
} catch (final IllegalArgumentException ex) {
return false;
}
}
/**
* Checks if a given code value is in this value set.
* Prüft, ob der gegebene code in diesem Value Set vorhanden
* ist.
*
* @param codeValue
*
* code
* @return true, if is in value set
*/
public static boolean isInValueSet(String codeValue) {
for (final StatusCode x : values()) {
if (x.getCodeValue().equals(codeValue)) {
return true;
}
}
return false;
}
/**
* Machine interpretable and (inside this class) unique
* code
Maschinen interpretierbarer und (innerhalb
* dieser Klasse) eindeutiger Code
*/
private String code;
/**
* Human readable name
* Menschenlesbarer Name
*/
private String displayName;
/**
* Instantiates this Enum Object with a given Code and
* Display Name
Instantiiert dieses Enum Object
* mittels eines Codes und einem Display Name
*
* @param code
*
* code
* @param displayName
*
* display name
*/
private StatusCode(String code, String displayName) {
this.code = code;
this.displayName = displayName;
}
/**
* Gets the husky Code Object
* Liefert das husky Code Objekt
*
* @return the code
*/
public Code getCode() {
return new Code(code, CODE_SYSTEM_OID, displayName);
}
/**
* Gets the code system name.
Liefert
* code system name.
*
* @return the code system name
*/
public String getCodeSystemName() {
return CODE_SYSTEM_NAME;
}
/**
* Gets the code system id.
Liefert
* die code system id.
*
* @return the code system id
*/
public String getCodeSystemOid() {
return CODE_SYSTEM_OID;
}
/**
* Gets the actual Code as string
* Liefert den eigentlichen Code als String
*
* @return the code
*/
public String getCodeValue() {
return this.code;
}
/**
* Gets the Code of this Enum as MDHT Object.
* Liefert den Code dieses Enum als MDHT Objekt.
*
* @return The MDHT Code
*/
public CS getCS() {
final CS cs = new CS();
cs.setCode(code);
return cs;
}
/**
* Gets the display name.
Liefert
* display name.
*
* @return the display name
*/
public String getDisplayName() {
return this.displayName;
}
}