using System;
using NHapi.Base;
using NHapi.Base.Parser;
using NHapi.Base.Model;
using NHapi.Model.V251.Datatype;
using NHapi.Base.Log;
namespace NHapi.Model.V251.Segment{
///<summary>
/// Represents an HL7 EVN message segment.
/// This segment has the following fields:<ol>
///<li>EVN-1: Event Type Code (ID)</li>
///<li>EVN-2: Recorded Date/Time (TS)</li>
///<li>EVN-3: Date/Time Planned Event (TS)</li>
///<li>EVN-4: Event Reason Code (IS)</li>
///<li>EVN-5: Operator ID (XCN)</li>
///<li>EVN-6: Event Occurred (TS)</li>
///<li>EVN-7: Event Facility (HD)</li>
///</ol>
/// The get...() methods return data from individual fields. These methods
/// do not throw exceptions and may therefore have to handle exceptions internally.
/// If an exception is handled internally, it is logged and null is returned.
/// This is not expected to happen - if it does happen this indicates not so much
/// an exceptional circumstance as a bug in the code for this class.
///</summary>
[Serializable]
public class EVN : AbstractSegment {
/**
* Creates a EVN (Event Type) segment object that belongs to the given
* message.
*/
public EVN(IGroup parent, IModelClassFactory factory) : base(parent,factory) {
IMessage message = Message;
try {
this.add(typeof(ID), false, 1, 3, new System.Object[]{message, 3}, "Event Type Code");
this.add(typeof(TS), true, 1, 26, new System.Object[]{message}, "Recorded Date/Time");
this.add(typeof(TS), false, 1, 26, new System.Object[]{message}, "Date/Time Planned Event");
this.add(typeof(IS), false, 1, 3, new System.Object[]{message, 62}, "Event Reason Code");
this.add(typeof(XCN), false, 0, 250, new System.Object[]{message}, "Operator ID");
this.add(typeof(TS), false, 1, 26, new System.Object[]{message}, "Event Occurred");
this.add(typeof(HD), false, 1, 241, new System.Object[]{message}, "Event Facility");
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Can't instantiate " + GetType().Name, he);
}
}
///<summary>
/// Returns Event Type Code(EVN-1).
///</summary>
public ID EventTypeCode
{
get{
ID ret = null;
try
{
IType t = this.GetField(1, 0);
ret = (ID)t;
}
catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception ex) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex);
throw new System.Exception("An unexpected error ocurred", ex);
}
return ret;
}
}
///<summary>
/// Returns Recorded Date/Time(EVN-2).
///</summary>
public TS RecordedDateTime
{
get{
TS ret = null;
try
{
IType t = this.GetField(2, 0);
ret = (TS)t;
}
catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception ex) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex);
throw new System.Exception("An unexpected error ocurred", ex);
}
return ret;
}
}
///<summary>
/// Returns Date/Time Planned Event(EVN-3).
///</summary>
public TS DateTimePlannedEvent
{
get{
TS ret = null;
try
{
IType t = this.GetField(3, 0);
ret = (TS)t;
}
catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception ex) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex);
throw new System.Exception("An unexpected error ocurred", ex);
}
return ret;
}
}
///<summary>
/// Returns Event Reason Code(EVN-4).
///</summary>
public IS EventReasonCode
{
get{
IS ret = null;
try
{
IType t = this.GetField(4, 0);
ret = (IS)t;
}
catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception ex) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex);
throw new System.Exception("An unexpected error ocurred", ex);
}
return ret;
}
}
///<summary>
/// Returns a single repetition of Operator ID(EVN-5).
/// throws HL7Exception if the repetition number is invalid.
/// <param name="rep">The repetition number (this is a repeating field)</param>
///</summary>
public XCN GetOperatorID(int rep)
{
XCN ret = null;
try
{
IType t = this.GetField(5, rep);
ret = (XCN)t;
} catch (System.Exception ex) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex);
throw new System.Exception("An unexpected error ocurred", ex);
}
return ret;
}
///<summary>
/// Returns all repetitions of Operator ID (EVN-5).
///</summary>
public XCN[] GetOperatorID() {
XCN[] ret = null;
try {
IType[] t = this.GetField(5);
ret = new XCN[t.Length];
for (int i = 0; i < ret.Length; i++) {
ret[i] = (XCN)t[i];
}
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception cce) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new System.Exception("An unexpected error ocurred", cce);
}
return ret;
}
///<summary>
/// Returns the total repetitions of Operator ID (EVN-5).
///</summary>
public int OperatorIDRepetitionsUsed
{
get{
try {
return GetTotalFieldRepetitionsUsed(5);
}
catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception cce) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new System.Exception("An unexpected error ocurred", cce);
}
}
}
///<summary>
/// Returns Event Occurred(EVN-6).
///</summary>
public TS EventOccurred
{
get{
TS ret = null;
try
{
IType t = this.GetField(6, 0);
ret = (TS)t;
}
catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception ex) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex);
throw new System.Exception("An unexpected error ocurred", ex);
}
return ret;
}
}
///<summary>
/// Returns Event Facility(EVN-7).
///</summary>
public HD EventFacility
{
get{
HD ret = null;
try
{
IType t = this.GetField(7, 0);
ret = (HD)t;
}
catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new System.Exception("An unexpected error ocurred", he);
} catch (System.Exception ex) {
HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex);
throw new System.Exception("An unexpected error ocurred", ex);
}
return ret;
}
}
}}
|