将 HL7 段转换为 XML [英] Converting and HL7 segment to XML

查看:104
本文介绍了将 HL7 段转换为 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 XML,我们能够使用 HAPI 库生成它并使用 XSL 来更改 XML 的格式.我正在使用以下模板.当前模板查看 OBX.5 段的数字值,然后解释 OBX6(度量单位).但是,当 OBX6 来自某个客户端的样式时,我也尝试将它们解释为重复,中间带有插入符号 ^(例如:%^% 或 <代码>mL^mL).我当前的模板忽略了这一点,但我希望能够在 ^ 之前或之后获取段子字符串的值.

i have an XML that we were able to generate using HAPI libraries and use XSL to change the format of the 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). 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). My current template ignores this but I would like to be able to get the value of the segment substring before or after the ^.

<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>

结果应该产生

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

来自

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

提前致谢!

推荐答案

使用:

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

这是一个简单的基于 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>

当此转换应用于以下 XML 文档时(派生自提供的 XML 片段并使其格式正确):

when this transformation is applied on the following XML document (derived from the provided XML fragment and made well-formed):

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

产生了想要的、正确的结果:

%

这篇关于将 HL7 段转换为 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆