当前位置: 首页>>代码示例>>C#>>正文


C# ISegment.GetStructureName方法代码示例

本文整理汇总了C#中ISegment.GetStructureName方法的典型用法代码示例。如果您正苦于以下问题:C# ISegment.GetStructureName方法的具体用法?C# ISegment.GetStructureName怎么用?C# ISegment.GetStructureName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISegment的用法示例。


在下文中一共展示了ISegment.GetStructureName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeACK

        public static IMessage MakeACK(ISegment inboundHeader, string ackCode)
        {
            if (!inboundHeader.GetStructureName().Equals("MSH"))
                throw new NHapi.Base.HL7Exception(
                    "Need an MSH segment to create a response ACK (got " + inboundHeader.GetStructureName() + ")");

            // Find the HL7 version of the inbound message:
            //
            string version = null;
            try
            {
                version = Terser.Get(inboundHeader, 12, 0, 1, 1);
            }
            catch (NHapi.Base.HL7Exception)
            {
                // I'm not happy to proceed if we can't identify the inbound
                // message version.
                throw new NHapi.Base.HL7Exception("Failed to get valid HL7 version from inbound MSH-12-1");
            }

            IMessage ackMessage = new ACK();
            // Create a Terser instance for the outbound message (the ACK).
            Terser terser = new Terser(ackMessage);

            // Populate outbound MSH fields using data from inbound message
            ISegment outHeader = (ISegment)terser.getSegment("MSH");
            DeepCopy.copy(inboundHeader, outHeader);

            // Now set the message type, HL7 version number, acknowledgement code
            // and message control ID fields:
            string sendingApp = terser.Get("/MSH-3");
            string sendingEnv = terser.Get("/MSH-4");
            terser.Set("/MSH-3", CommunicationName);
            terser.Set("/MSH-4", EnvironmentIdentifier);
            terser.Set("/MSH-5", sendingApp);
            terser.Set("/MSH-6", sendingEnv);
            terser.Set("/MSH-7", DateTime.Now.ToString("yyyyMMddmmhh"));
            terser.Set("/MSH-9", "ACK");
            terser.Set("/MSH-12", version);
            terser.Set("/MSA-1", ackCode == null ? "AA" : ackCode);
            terser.Set("/MSA-2", Terser.Get(inboundHeader, 10, 0, 1, 1));

            return ackMessage;
        }
开发者ID:JohnBloom,项目名称:NHapiSampleApplication,代码行数:44,代码来源:HL7Acknowlege.cs

示例2: Encode

		public static String Encode(ISegment source, EncodingCharacters encodingChars)
		{
			StringBuilder result = new StringBuilder();
			result.Append(source.GetStructureName());
			result.Append(encodingChars.FieldSeparator);

			//start at field 2 for MSH segment because field 1 is the field delimiter
			int startAt = 1;
			if (IsDelimDefSegment(source.GetStructureName()))
				startAt = 2;

			//loop through fields; for every field delimit any repetitions and add field delimiter after ...
			int numFields = source.NumFields();
			for (int i = startAt; i <= numFields; i++)
			{
				try
				{
					IType[] reps = source.GetField(i);
					for (int j = 0; j < reps.Length; j++)
					{
						String fieldText = Encode(reps[j], encodingChars);
						//if this is MSH-2, then it shouldn't be escaped, so unescape it again
						if (IsDelimDefSegment(source.GetStructureName()) && i == 2)
							fieldText = Escape.unescape(fieldText, encodingChars);
						result.Append(fieldText);
						if (j < reps.Length - 1)
							result.Append(encodingChars.RepetitionSeparator);
					}
				}
				catch (HL7Exception e)
				{
					log.Error("Error while encoding segment: ", e);
				}
				result.Append(encodingChars.FieldSeparator);
			}

			//strip trailing delimiters ...
			return StripExtraDelimiters(result.ToString(), encodingChars.FieldSeparator);
		}
开发者ID:RickIsWright,项目名称:nHapi,代码行数:39,代码来源:PipeParser.cs

示例3: Parse

		/// <summary> Parses a segment string and populates the given Segment object.  Unexpected fields are
		/// added as Varies' at the end of the segment.  
		/// 
		/// </summary>
		/// <throws>  HL7Exception if the given string does not contain the </throws>
		/// <summary>      given segment or if the string is not encoded properly
		/// </summary>
		public virtual void Parse(ISegment destination, String segment, EncodingCharacters encodingChars)
		{
			int fieldOffset = 0;
			if (IsDelimDefSegment(destination.GetStructureName()))
			{
				fieldOffset = 1;
				//set field 1 to fourth character of string
				Terser.Set(destination, 1, 0, 1, 1, Convert.ToString(encodingChars.FieldSeparator));
			}

			String[] fields = Split(segment, Convert.ToString(encodingChars.FieldSeparator));

			for (int i = 1; i < fields.Length; i++)
			{
				String[] reps = Split(fields[i], Convert.ToString(encodingChars.RepetitionSeparator));
				if (log.DebugEnabled)
				{
					log.Debug(reps.Length + "reps delimited by: " + encodingChars.RepetitionSeparator);
				}

				//MSH-2 will get split incorrectly so we have to fudge it ...
				bool isMSH2 = IsDelimDefSegment(destination.GetStructureName()) && i + fieldOffset == 2;
				if (isMSH2)
				{
					reps = new String[1];
					reps[0] = fields[i];
				}

				for (int j = 0; j < reps.Length; j++)
				{
					try
					{
						StringBuilder statusMessage = new StringBuilder("Parsing field ");
						statusMessage.Append(i + fieldOffset);
						statusMessage.Append(" repetition ");
						statusMessage.Append(j);
						log.Debug(statusMessage.ToString());

						IType field = destination.GetField(i + fieldOffset, j);
						if (isMSH2)
						{
							Terser.getPrimitive(field, 1, 1).Value = reps[j];
						}
						else
						{
							Parse(field, reps[j], encodingChars);
						}
					}
					catch (HL7Exception e)
					{
						//set the field location and throw again ...
						e.FieldPosition = i + fieldOffset;
						e.SegmentRepetition = MessageIterator.getIndex(destination.ParentStructure, destination).rep;
						e.SegmentName = destination.GetStructureName();
						throw;
					}
				}
			}

			//set data type of OBX-5
			if (destination.GetType().FullName.IndexOf("OBX") >= 0)
			{
				Varies.fixOBX5(destination, Factory);
			}
		}
开发者ID:RickIsWright,项目名称:nHapi,代码行数:72,代码来源:PipeParser.cs

示例4: populate

        /// <summary> Populates the given error segment with information from this Exception.</summary>
        public virtual void populate(ISegment errorSegment)
        {
            //make sure it's an ERR
            if (!errorSegment.GetStructureName().Equals("ERR"))
                throw new HL7Exception("Can only populate an ERR segment with an exception -- got: " + errorSegment.GetType().FullName);

            int rep = errorSegment.GetField(1).Length; //append after existing reps

            if (this.SegmentName != null)
                Terser.Set(errorSegment, 1, rep, 1, 1, this.SegmentName);

            if (this.SegmentRepetition >= 0)
                Terser.Set(errorSegment, 1, rep, 2, 1, System.Convert.ToString(this.SegmentRepetition));

            if (this.FieldPosition >= 0)
                Terser.Set(errorSegment, 1, rep, 3, 1, System.Convert.ToString(this.FieldPosition));

            Terser.Set(errorSegment, 1, rep, 4, 1, System.Convert.ToString(this.errCode));
            Terser.Set(errorSegment, 1, rep, 4, 3, "hl70357");
            Terser.Set(errorSegment, 1, rep, 4, 5, this.Message);

            //try to get error condition text
            try
            {
                System.String desc = TableRepository.Instance.getDescription(357, System.Convert.ToString(this.errCode));
                Terser.Set(errorSegment, 1, rep, 4, 2, desc);
            }
            catch (LookupException e)
            {
                ourLog.Debug("Warning: LookupException getting error condition text (are we connected to a TableRepository?)", e);
            }
        }
开发者ID:snosrap,项目名称:nhapi,代码行数:33,代码来源:HL7Exception.cs

示例5: MakeElementName

		/// <summary> Returns the expected XML element name for the given child of a message constituent 
		/// of the given class (the class should be a Composite or Segment class). 
		/// </summary>
		/*private String makeElementName(Class c, int child) {
        String longClassName = c.getName();
        String shortClassName = longClassName.substring(longClassName.lastIndexOf('.') + 1, longClassName.length());
        if (shortClassName.startsWith("Valid")) {
        shortClassName = shortClassName.substring(5, shortClassName.length());
        }
        return shortClassName + "." + child;
        }*/
		/// <summary>Returns the expected XML element name for the given child of the given Segment </summary>
		private String MakeElementName(ISegment s, int child)
		{
			return s.GetStructureName() + "." + child;
		}
开发者ID:liddictm,项目名称:nHapi,代码行数:16,代码来源:XMLParser.cs

示例6: Parse

		/// <summary> Populates the given Segment object with data from the given XML Element.</summary>
		/// <throws>  HL7Exception if the XML Element does not have the correct name and structure </throws>
		/// <summary>      for the given Segment, or if there is an error while setting individual field values.
		/// </summary>
		public virtual void Parse(ISegment segmentObject, XmlElement segmentElement)
		{
			SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

			//        for (int i = 1; i <= segmentObject.NumFields(); i++) {
			//            String elementName = makeElementName(segmentObject, i);
			//            done.add(elementName);
			//            parseReps(segmentObject, segmentElement, elementName, i);
			//        }

			XmlNodeList all = segmentElement.ChildNodes;
			for (int i = 0; i < all.Count; i++)
			{
				String elementName = all.Item(i).Name;
				if (Convert.ToInt16(all.Item(i).NodeType) == (short) XmlNodeType.Element && !done.Contains(elementName))
				{
					done.Add(elementName);

					int index = elementName.IndexOf('.');
					if (index >= 0 && elementName.Length > index)
					{
						//properly formatted element
						String fieldNumString = elementName.Substring(index + 1);
						int fieldNum = Int32.Parse(fieldNumString);
						ParseReps(segmentObject, segmentElement, elementName, fieldNum);
					}
					else
					{
						log.Debug("Child of segment " + segmentObject.GetStructureName() + " doesn't look like a field: " + elementName);
					}
				}
			}

			//set data type of OBX-5        
			if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
			{
				Varies.fixOBX5(segmentObject, Factory);
			}
		}
开发者ID:liddictm,项目名称:nHapi,代码行数:43,代码来源:XMLParser.cs


注:本文中的ISegment.GetStructureName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。