Beispiel #1
0
        /// <summary> Creates a version-specific MSH object and returns it as a version-independent
        /// MSH interface.
        /// throws HL7Exception if there is a problem, e.g. invalid version, code not available
        /// for given version.
        /// </summary>
        public static Segment makeControlMSH(System.String version, ModelClassFactory factory)
        {
            Segment msh = null;

            try
            {
                Message dummy = (Message)GenericMessage.getGenericMessageClass(version).GetConstructor(new System.Type[] { typeof(ModelClassFactory) }).Invoke(new System.Object[] { factory });

                System.Type[]   constructorParamTypes = new System.Type[] { typeof(Group), typeof(ModelClassFactory) };
                System.Object[] constructorParamArgs  = new System.Object[] { dummy, factory };
                System.Type     c = factory.getSegmentClass("MSH", version);
                System.Reflection.ConstructorInfo constructor = c.GetConstructor(constructorParamTypes);
                msh = (Segment)constructor.Invoke(constructorParamArgs);
            }
            catch (System.Exception e)
            {
                throw new HL7Exception("Couldn't create MSH for version " + version + " (does your classpath include this version?) ... ", HL7Exception.APPLICATION_INTERNAL_ERROR, e);
            }
            return(msh);
        }
Beispiel #2
0
        /// <summary> Creates a version-specific MSH object and returns it as a version-independent 
        /// MSH interface. 
        /// throws HL7Exception if there is a problem, e.g. invalid version, code not available 
        /// for given version. 
        /// </summary>
        public static Segment makeControlMSH(System.String version, ModelClassFactory factory)
        {
            Segment msh = null;

            try
            {
                Message dummy = (Message) GenericMessage.getGenericMessageClass(version).GetConstructor(new System.Type[]{typeof(ModelClassFactory)}).Invoke(new System.Object[]{factory});

                System.Type[] constructorParamTypes = new System.Type[]{typeof(Group), typeof(ModelClassFactory)};
                System.Object[] constructorParamArgs = new System.Object[]{dummy, factory};
                System.Type c = factory.getSegmentClass("MSH", version);
                System.Reflection.ConstructorInfo constructor = c.GetConstructor(constructorParamTypes);
                msh = (Segment) constructor.Invoke(constructorParamArgs);
            }
            catch (System.Exception e)
            {
                throw new HL7Exception("Couldn't create MSH for version " + version + " (does your classpath include this version?) ... ", HL7Exception.APPLICATION_INTERNAL_ERROR, e);
            }
            return msh;
        }