本文整理汇总了C#中Segment.getField方法的典型用法代码示例。如果您正苦于以下问题:C# Segment.getField方法的具体用法?C# Segment.getField怎么用?C# Segment.getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment.getField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fixOBX5
/// <summary> Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument
/// is a Segment as opposed to a particular OBX because it is meant to work with any version.
/// </summary>
public static void fixOBX5(Segment segment, ModelClassFactory factory)
{
try
{
//get unqualified class name
Primitive obx2 = (Primitive) segment.getField(2, 0);
Type[] reps = segment.getField(5);
for (int i = 0; i < reps.Length; i++)
{
Varies v = (Varies) reps[i];
if (obx2.Value == null)
{
if (v.Data != null)
{
if (!(v.Data is Primitive) || ((Primitive) v.Data).Value != null)
{
throw new NuGenHL7Exception("OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2.", NuGenHL7Exception.REQUIRED_FIELD_MISSING);
}
}
}
else
{
//set class
System.Type c = factory.getTypeClass(obx2.Value, segment.Message.Version);
// Class c = Genetibase.NuGenHL7.parser.Parser.findClass(obx2.getValue(),
// segment.getMessage().getVersion(),
// "datatype");
v.Data = (Type) c.GetConstructor(new System.Type[]{typeof(Message)}).Invoke(new System.Object[]{v.Message});
}
} // for reps
}
catch (NuGenHL7Exception e)
{
throw e;
}
catch (System.Exception e)
{
throw new NuGenHL7Exception(e.GetType().FullName + " trying to set data type of OBX-5", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR, e);
}
}
示例2: copy
/* if (from instanceof Varies) {
from = ((Varies) from).getData();
}
if (to instanceof Varies) {
to = ((Varies) to).getData();
}
if (from instanceof Primitive) {
if (to instanceof Primitive) {
copy((Primitive) from, (Primitive) to);
} else {
copy((Primitive) from, (Composite) to);
}
} else {
if (to instanceof Primitive) {
copy((Composite) from, (Primitive) to);
} else {
copy((Composite) from, (Composite) to);
}
}
}*/
/// <summary>Copies a primitive to a primitive </summary>
/*private static void copy(Primitive from, Primitive to) throws DataTypeException {
to.setValue(from.getValue());
}*/
/// <summary>Copies composite to composite - could be different # of components (extras either way are ignored) </summary>
/*private static void copy(Composite from, Composite to) throws DataTypeException {
Type[] froms = from.getComponents();
Type[] tos = to.getComponents();
int limit = Math.min(froms.length, tos.length);
for (int i = 0; i < limit; i++) {
copy(froms[i], tos[i]);
}
}*/
/// <summary>Copies primitive to first component of composite. </summary>
/*private static void copy(Primitive from, Composite to) throws DataTypeException {
Type firstComponent = to.getComponent(0);
copy(from, firstComponent);
}*/
/// <summary>Copies first component of composite to a primitive </summary>
/*private static void copy(Composite from, Primitive to) throws DataTypeException {
Type firstComponent = from.getComponent(0);
copy(firstComponent, to);
}*/
/// <summary> Copies contents from the source segment to the destination segment. This
/// method calls copy(Type, Type) on each repetition of each field (see additional
/// behavioural description there). An attempt is made to copy each repetition of
/// each field in the source segment, regardless of whether the corresponding
/// destination field is repeating or even exists.
/// </summary>
/// <param name="from">the segment from which data are copied
/// </param>
/// <param name="to">the segment into which data are copied
/// </param>
public static void copy(Segment from, Segment to)
{
int n = from.numFields();
for (int i = 1; i <= n; i++)
{
Genetibase.NuGenHL7.model.Type[] reps = from.getField(i);
for (int j = 0; j < reps.Length; j++)
{
copy(reps[j], to.getField(i, j));
}
}
}
示例3: fixOBX5
/// <summary> Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument
/// is a Segment as opposed to a particular OBX because it is meant to work with any version.
/// </summary>
public static void fixOBX5(Segment segment, ModelClassFactory factory)
{
try
{
//get unqualified class name
Primitive obx2 = (Primitive) segment.getField(2, 0);
Varies v = (Varies) segment.getField(5, 0);
if (obx2.Value == null)
{
if (v.Data != null)
{
if (!(v.Data is Primitive) || ((Primitive) v.Data).Value != null)
{
throw new HL7Exception("OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2.", HL7Exception.REQUIRED_FIELD_MISSING);
}
}
}
else
{
//set class
System.Type c = factory.getTypeClass(obx2.Value, segment.Message.Version);
// Class c = ca.uhn.hl7v2.parser.Parser.findClass(obx2.getValue(),
// segment.getMessage().getVersion(),
// "datatype");
v.Data = (Type) c.GetConstructor(new System.Type[]{typeof(Message)}).Invoke(new System.Object[]{v.Message});
}
}
catch (HL7Exception e)
{
throw e;
}
catch (System.Exception e)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
throw new HL7Exception(e.GetType().FullName + " trying to set data type of OBX-5", HL7Exception.APPLICATION_INTERNAL_ERROR, e);
}
}
示例4: checkForExtraFields
/// <summary> Checks a segment against a list of allowed fields
/// (ie those mentioned in the profile with usage other than X). Returns
/// a list of exceptions representing field that appear
/// but are not supposed to.
/// </summary>
/// <param name="allowedFields">an array of Integers containing field #s of allowed fields
/// </param>
private NuGenHL7Exception[] checkForExtraFields(Segment segment, System.Collections.ArrayList allowedFields)
{
System.Collections.ArrayList exList = new System.Collections.ArrayList();
for (int i = 1; i <= segment.numFields(); i++)
{
if (!allowedFields.Contains((System.Int32) i))
{
try
{
Genetibase.NuGenHL7.model.Type[] reps = segment.getField(i);
for (int j = 0; j < reps.Length; j++)
{
if (hasContent(reps[j]))
{
NuGenHL7Exception e = new NuGenXElementPresentException("Field " + i + " in " + segment.getName() + " appears in the message but not in the profile");
exList.Add(e);
}
}
}
catch (NuGenHL7Exception he)
{
throw new NuGenProfileException("Problem testing against profile", he);
}
}
}
return this.toArray(exList);
}
示例5: getPrimitive
/// <summary> Returns the Primitive object at the given location.</summary>
private static Primitive getPrimitive(Segment segment, int field, int rep, int component, int subcomponent)
{
model.Type type = segment.getField(field, rep);
return getPrimitive(type, component, subcomponent);
}