Example #1
0
        /// <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);
            }
        }
Example #2
0
File: OBX.cs Project: snosrap/nhapi
 /**
    * Returns all repetitions of Observation Value (OBX-5).
    */
 public Varies[] getObservationValue()
 {
     Varies[] ret = null;
     try {
     Type[] t = this.getField(5);
     ret = new Varies[t.Length];
     for (int i = 0; i < ret.Length; i++) {
     ret[i] = (Varies)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;
 }