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 CTD message segment.
/// This segment has the following fields:<ol>
///<li>CTD-1: Contact Role (CE)</li>
///<li>CTD-2: Contact Name (XPN)</li>
///<li>CTD-3: Contact Address (XAD)</li>
///<li>CTD-4: Contact Location (PL)</li>
///<li>CTD-5: Contact Communication Information (XTN)</li>
///<li>CTD-6: Preferred Method of Contact (CE)</li>
///<li>CTD-7: Contact Identifiers (PLN)</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 CTD : AbstractSegment {
/**
* Creates a CTD (Contact Data) segment object that belongs to the given
* message.
*/
public CTD(IGroup parent, IModelClassFactory factory) : base(parent,factory) {
IMessage message = Message;
try {
this.add(typeof(CE), true, 0, 250, new System.Object[]{message}, "Contact Role");
this.add(typeof(XPN), false, 0, 250, new System.Object[]{message}, "Contact Name");
this.add(typeof(XAD), false, 0, 250, new System.Object[]{message}, "Contact Address");
this.add(typeof(PL), false, 1, 60, new System.Object[]{message}, "Contact Location");
this.add(typeof(XTN), false, 0, 250, new System.Object[]{message}, "Contact Communication Information");
this.add(typeof(CE), false, 1, 250, new System.Object[]{message}, "Preferred Method of Contact");
this.add(typeof(PLN), false, 0, 100, new System.Object[]{message}, "Contact Identifiers");
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(GetType()).error("Can't instantiate " + GetType().Name, he);
}
}
///<summary>
/// Returns a single repetition of Contact Role(CTD-1).
/// throws HL7Exception if the repetition number is invalid.
/// <param name="rep">The repetition number (this is a repeating field)</param>
///</summary>
public CE GetContactRole(int rep)
{
CE ret = null;
try
{
IType t = this.GetField(1, rep);
ret = (CE)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 Contact Role (CTD-1).
///</summary>
public CE[] GetContactRole() {
CE[] ret = null;
try {
IType[] t = this.GetField(1);
ret = new CE[t.Length];
for (int i = 0; i < ret.Length; i++) {
ret[i] = (CE)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 Contact Role (CTD-1).
///</summary>
public int ContactRoleRepetitionsUsed
{
get{
try {
return GetTotalFieldRepetitionsUsed(1);
}
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 a single repetition of Contact Name(CTD-2).
/// throws HL7Exception if the repetition number is invalid.
/// <param name="rep">The repetition number (this is a repeating field)</param>
///</summary>
public XPN GetContactName(int rep)
{
XPN ret = null;
try
{
IType t = this.GetField(2, rep);
ret = (XPN)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 Contact Name (CTD-2).
///</summary>
public XPN[] GetContactName() {
XPN[] ret = null;
try {
IType[] t = this.GetField(2);
ret = new XPN[t.Length];
for (int i = 0; i < ret.Length; i++) {
ret[i] = (XPN)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 Contact Name (CTD-2).
///</summary>
public int ContactNameRepetitionsUsed
{
get{
try {
return GetTotalFieldRepetitionsUsed(2);
}
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 a single repetition of Contact Address(CTD-3).
/// throws HL7Exception if the repetition number is invalid.
/// <param name="rep">The repetition number (this is a repeating field)</param>
///</summary>
public XAD GetContactAddress(int rep)
{
XAD ret = null;
try
{
IType t = this.GetField(3, rep);
ret = (XAD)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 Contact Address (CTD-3).
///</summary>
public XAD[] GetContactAddress() {
XAD[] ret = null;
try {
IType[] t = this.GetField(3);
ret = new XAD[t.Length];
for (int i = 0; i < ret.Length; i++) {
ret[i] = (XAD)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 Contact Address (CTD-3).
///</summary>
public int ContactAddressRepetitionsUsed
{
get{
try {
return GetTotalFieldRepetitionsUsed(3);
}
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 Contact Location(CTD-4).
///</summary>
public PL ContactLocation
{
get{
PL ret = null;
try
{
IType t = this.GetField(4, 0);
ret = (PL)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 Contact Communication Information(CTD-5).
/// throws HL7Exception if the repetition number is invalid.
/// <param name="rep">The repetition number (this is a repeating field)</param>
///</summary>
public XTN GetContactCommunicationInformation(int rep)
{
XTN ret = null;
try
{
IType t = this.GetField(5, rep);
ret = (XTN)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 Contact Communication Information (CTD-5).
///</summary>
public XTN[] GetContactCommunicationInformation() {
XTN[] ret = null;
try {
IType[] t = this.GetField(5);
ret = new XTN[t.Length];
for (int i = 0; i < ret.Length; i++) {
ret[i] = (XTN)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 Contact Communication Information (CTD-5).
///</summary>
public int ContactCommunicationInformationRepetitionsUsed
{
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 Preferred Method of Contact(CTD-6).
///</summary>
public CE PreferredMethodOfContact
{
get{
CE ret = null;
try
{
IType t = this.GetField(6, 0);
ret = (CE)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 Contact Identifiers(CTD-7).
/// throws HL7Exception if the repetition number is invalid.
/// <param name="rep">The repetition number (this is a repeating field)</param>
///</summary>
public PLN GetContactIdentifiers(int rep)
{
PLN ret = null;
try
{
IType t = this.GetField(7, rep);
ret = (PLN)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 Contact Identifiers (CTD-7).
///</summary>
public PLN[] GetContactIdentifiers() {
PLN[] ret = null;
try {
IType[] t = this.GetField(7);
ret = new PLN[t.Length];
for (int i = 0; i < ret.Length; i++) {
ret[i] = (PLN)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 Contact Identifiers (CTD-7).
///</summary>
public int ContactIdentifiersRepetitionsUsed
{
get{
try {
return GetTotalFieldRepetitionsUsed(7);
}
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);
}
}
}
}}
|