コード例 #1
0
ファイル: ParserBase.cs プロジェクト: ppatole/ReportServer0.1
        /// <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 ISegment MakeControlMSH(String version, IModelClassFactory factory)
        {
            ISegment msh = null;

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

                Type[]          constructorParamTypes = new Type[] { typeof(IGroup), typeof(IModelClassFactory) };
                Object[]        constructorParamArgs  = new Object[] { dummy, factory };
                Type            c           = factory.GetSegmentClass("MSH", version);
                ConstructorInfo constructor = c.GetConstructor(constructorParamTypes);
                msh = (ISegment)constructor.Invoke(constructorParamArgs);
            }
            catch (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);
        }
コード例 #2
0
        /// <summary>
        /// <p>Attempts to return the message class corresponding to the given name, by searching through
        /// default and user-defined (as per PackageList()) packages. Returns GenericMessage if the class
        /// is not found.</p>
        /// <p>It is important to note that there can only be one implementation of a particular message
        /// structure (i.e. one class with the message structure name, regardless of its package) among
        /// the packages defined as per the <code>PackageList()</code> method.  If there are duplicates
        /// (e.g. two ADT_A01 classes) the first one in the search order will always be used.  However,
        /// this restriction only applies to message classes, not (normally) segment classes, etc.  This
        /// is because classes representing parts of a message are referenced explicitly in the code for
        /// the message class, rather than being looked up (using findMessageClass() ) based on the
        /// String value of MSH-9. The exception is that Segments may have to be looked up by name when
        /// they appear in unexpected locations (e.g. by local extension) -- see findSegmentClass().</p>
        /// <p>Note: the current implementation will be slow if there are multiple user- defined packages,
        /// because the JVM will try to load a number of non-existent classes every parse.  This should
        /// be changed so that specific classes, rather than packages, are registered by name.</p>
        /// </summary>
        ///
        /// <param name="theName">      name of the desired structure in the form XXX_YYY. </param>
        /// <param name="theVersion">   HL7 version (e.g. "2.3")  </param>
        /// <param name="isExplicit">   true if the structure was specified explicitly in MSH-9-3, false
        ///                             if it was inferred from MSH-9-1 and MSH-9-2.  If false, a lookup
        ///                             may be performed to find an alternate structure corresponding to
        ///                             that message type and event. </param>
        ///
        /// <returns>   corresponding message subclass if found; GenericMessage otherwise. </returns>

        public virtual System.Type GetMessageClass(System.String theName, System.String theVersion, bool isExplicit)
        {
            System.Type mc = null;
            if (!isExplicit)
            {
                theName = ParserBase.GetMessageStructureForEvent(theName, theVersion);
            }
            mc = findClass(theName, theVersion, ClassType.Message);
            if (mc == null)
            {
                mc = GenericMessage.getGenericMessageClass(theVersion);
            }
            return(mc);
        }