相关文章推荐
温文尔雅的大白菜  ·  c# - ICommand MVVM ...·  1 年前    · 
不拘小节的水煮鱼  ·  css - Why does ...·  1 年前    · 
英勇无比的大蒜  ·  C++ ...·  1 年前    · 

<dependency>
<groupId>org.openehealth.ipf.boot</groupId>
<artifactId>ipf-hl7v3-spring-boot-starter</artifactId>
<version>3.3.0</version>
</dependency>

HL7 2.6解析转XML(C#版)

项目中需要解析HL7,所以在网上找到解析代码,但错误很多,所以我修改了一下,测试好用。

XmlElement subComponentRepEl = _xmlDoc.CreateElement(sFields[0] + "." + a.ToString() + "." + b.ToString() + "." + c.ToString() + "." + d.ToString()); subComponentRepEl.InnerText = subComponentRepetitions[d]; componentEl.AppendChild(subComponentRepEl); XmlElement subComponentEl = _xmlDoc.CreateElement(sFields[0] + "." + a.ToString() + "." + b.ToString() + "." + c.ToString()); subComponentEl.InnerText = subComponents[c]; componentEl.AppendChild(subComponentEl); fieldEl.AppendChild(componentEl); else //2.如果没有字组了,大部分是没有 string [] sRepetitions = HL7ToXmlConverter.GetSubComponents(sComponents[b]); if (sRepetitions.Length > 1) XmlElement repetitionEl = null ; for ( int c = 0; c < sRepetitions.Length; c++) repetitionEl = _xmlDoc.CreateElement(sFields[0] + "." + a.ToString() + "." + b.ToString() + "." + c.ToString()); repetitionEl.InnerText = sRepetitions[c]; componentEl.AppendChild(repetitionEl); fieldEl.AppendChild(componentEl); el.AppendChild(fieldEl); componentEl.InnerText = sComponents[b]; fieldEl.AppendChild(componentEl); el.AppendChild(fieldEl); el.AppendChild(fieldEl); //0:如果不可以分隔,可以直接写节点值了。 fieldEl.InnerText = sFields[a]; el.AppendChild(fieldEl); String chuang1 = PT.Common.HL7ToXmlConverter.GetText(xmlObject, "PV1/PV1.6/PV1.6.0/PV1.6.0.2" , 0); String chuang2 = PT.Common.HL7ToXmlConverter.GetText(xmlObject, "PV1/PV1.3/PV1.3.0/PV1.3.0.2" , 0); ThreadUPtextBoxMsg(textBoxMsgAppendText, "\r\n[解析HL7消息为XML]" + name + "从" + chuang1 + "床换到" + chuang2 + "床" );