简体   繁体   English

将HL7段转换为XML

[英]Converting and HL7 segment to XML

i have an XML that we were able to generate using HAPI libraries and use XSL to change the format of the XML. 我有一个XML,我们可以使用HAPI库生成,并使用XSL来更改XML的格式。 I am using the following template. 我使用以下模板。 The current template looks at the OBX.5 segment for a digital value and then interprets the OBX6 (units of measure). 当前模板查看OBX.5段以获取数字值,然后解释OBX6(度量单位)。 However I am trying to also interpret the OBX6 when they come from one of the clients in a style as duplicates with the caret ^ in between (ex: %^% or mL^mL ). 不过我想也解释OBX6时,他们的风格来自客户之一,与插入符号重复^之间(例如: %^%mL^mL )。 My current template ignores this but I would like to be able to get the value of the segment substring before or after the ^ . 我当前的模板忽略了这一点,但我希望能够在^之前或之后获得segment substring的值。

<xsl:template match="hl7:OBX.6[matches(./../hl7:OBX.5, '^\d+(\.\d+)?$') and index-of($percentList, .) or index-of($mgdlList, .) or index-of($mlList, .) or index-of($mmList, .) or index-of($mgList, .))]">
    <result><xsl:value-of select="./../hl7:OBX.5" /></result>
        <xsl:when test="index-of($percentList, .)">
            <units>%</units>
        </xsl:when>
...
        <xsl:when test="index-of($mlList, .)">
            <units>ml</units>
        </xsl:when>

        <xsl:otherwise>
            <units><xsl:value-of select="./hl7:CE.1" /></units>
        </xsl:otherwise>
...

</xsl:template>

The result should produce 结果应该产生

            <result>38.0</result>
            <units>%</units>

from

                <OBX.5>38.0</OBX.5>
                <OBX.6>
                    <CE.1>%^%</CE.1>
                </OBX.6>

Thanks in advance! 提前致谢!

Use : 用途

tokenize(hl7:CE.1, '\^')[1]

Here is a simple XSLT 2.0 - based verification: 这是一个简单的基于XSLT 2.0的验证:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="OBX.6">
  <xsl:sequence select="tokenize(CE.1, '\^')[1]"/>
 </xsl:template>

 <xsl:template match="text()"/>
</xsl:stylesheet>

when this transformation is applied on the following XML document (derived from the provided XML fragment and made well-formed): 当此转换应用于以下XML文档时 (从提供的XML片段派生并且格式正确):

<t>
    <OBX.5>38.0</OBX.5>
    <OBX.6>
        <CE.1>%^%</CE.1>
    </OBX.6>
</t>

the wanted, correct result is produced: 产生了想要的正确结果:

%

I also found that HAPI can be tweaked to delimit within the segments by line terminator, | 我还发现,高致病性禽流感可以调整,以通过行终止,段内划定| for segment terminator and ^ for field terminator. 用于段终止符和^用于字段终止符。 This helped immensely 这极大地帮助了我

The corresponding xsl looks like: 相应的xsl看起来像:

<xsl:template match="hl7:OBX.6[matches(./../hl7:OBX.5, '^\d+(\.\d+)?$') ]">

    <xsl:if test="hl7:CE.1[  index-of($percentList, .) or index-of($mgdlList, .) or index-of($mlList, .) or index-of($mmList, .) or index-of($mgList, .))]">
        <result><xsl:value-of select="./../hl7:OBX.5" /></result>

        <xsl:choose>
            <xsl:when test="index-of($percentList, hl7:CE.1)">
                <units>%</units>
            </xsl:when>
...

            <xsl:when test="index-of($mlList, hl7:CE.1)">
                <units>mL</units>
            </xsl:when>
...

            <xsl:otherwise>
                <units><xsl:value-of select="hl7:CE.1" /></units>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:if>
</xsl:template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM