如何解决XSLT 3.0封装式来源PROV
<?xml version="1.0" encoding="utf-8"?>
<ClinicalDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hl7-org:v3 ../../C-CDA%20rules/infrastructure/cda/CDA_SDTC.xsd"
xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc">
<realmCode code="US"/>
<typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
<templateId root="2.16.840.1.113883.10.20.22.1.1"/>
……………
<translation code="J45" codeSystem="2.16.840.1.113883.6.90"
displayName="Asthma" codeSystemName="ICD-10-CM"/>
<translation code="493.92" codeSystem="2.16.840.1.113883.6.103"
displayName="Asthma,unspecified type,with (acute) exacerbation" codeSystemName="ICD-9-CM"/>
……………..
<translation code="J45" codeSystem="2.16.840.1.113883.6.90"
displayName="Asthma" codeSystemName="ICD-10-CM"/>
<translation code="493.92" codeSystem="2.16.840.1.113883.6.103"
displayName="Asthma,with (acute) exacerbation" codeSystemName="ICD-9-CM"/>
…………..
<translation code="G0121" codeSystem="2.16.840.1.113883.6.13"
displayName="Colon ca scrn not hi rsk ind" codeSystemName="HCPCS"/>
<translation code="Z12.11" codeSystem="2.16.840.1.113883.6.90"
displayName="Encounter for screening for malignant neoplasm of colon" codeSystemName="ICD-10-CM"/>
<translation code="45.23" codeSystem="2.16.840.1.113883.6.103"
displayName="Colonoscopy" codeSystemName="ICD-9-CM"/>
<translation code="174184006" codeSystem="2.16.840.1.113883.6.96"
displayName="Diagnostic endoscopic examination on colon" codeSystemName="SNOMED-CT"/>
...........
我希望信封
Provenance
之间的元素
<?xml version="1.0" encoding="utf-8"?>
AND
<ClinicalDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hl7-org:v3 ../../C-CDA%20rules/infrastructure/cda/CDA_SDTC.xsd"
xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc">
Provenance
的构造是
<Provenance xmlns="http://hl7.org/fhir">
<id value="Patient/codeSystem_history/v1"/>
<derivation value="Transformation: ICD-10-CM,ICD-10-PCS,SNOMED-CT,HCPCS"/>
<lastTransformed value="2020-09-09"/>
<translation>
<coding>
<system value="http://hl7.org/fhir/sid/icd-10"/>
<code value="H40.11X0"/>
<display value="Primary open-angle glaucoma,stage unspecified"/>
</coding>
<coding>
<system value="http://hl7.org/fhir/sid/icd-10"/>
<code value="I25.1"/>
<display value="Atherosclerotic heart disease of native coronary artery"/>
</coding>
<coding>
<system value="HCPCS"/>
<code value="G0121"/>
<display value="Colon ca scrn not hi rsk ind"/>
</coding>
<coding>
<!-- Procedure Outcome(SNOMED CT): http://snomed.info/sct-->
<system value="SNOMED-CT"/>
<code value="176259004"/>
<display value="Radical prostatectomy - unspecified excision of pelvic nodes"/>
</coding>
</translation>
<coding>
…………………………
</coding>
…………………………
</Provenance>
Provenance
的逻辑是
-
标识所有 unique
codeSystemName
属性,其值分别为ICD-10-CM
,ICD-10-PCS
,HCPCS
和{{1 }}中的SNOMED-CT
元素。 -
转换并创建属性|
translation
@translation
中的元素:
-
Provenance
是codeSystemName
:ICD-10-***
-
<system value="http://hl7.org/fhir/sid/icd-10"/>
是codeSystemName
:HCPCS
-
<system value="HCPCS"/>
是codeSystemName
:SNOMED-CT
在<system value=" SNOMED-CT "/>
之后是相应的system
(code
)和/translation/@code
(display
)元素。
我的代码:
/translation/@displayName
但是渲染效果不是我期望的
- 首先,会产生重复项,并且所有
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n1="urn:hl7-org:v3" exclude-result-prefixes="#all"> <xsl:output indent="yes" method="xml" encoding="utf-8"/> <xsl:param name="date" select="current-dateTime()"/> <xsl:param name="ICD-10" select="'http://hl7.org/fhir/sid/icd-10'"/> <xsl:param name="SNOMED-CT" select="'SNOMED-CT'"/> <xsl:param name="HCPCS" select="'HCPCS'"/> <!-- <xsl:key name="code-system-name" match="n1:translation" use="translate(normalize-space(@codeSystemName),' 	

.;','')"/>--> <!-- <xsl:key name="code-system-name" match="n1:translation" use="@codeSystemName"/>--> <xsl:template match="/"> <Provenance xmlns="http://hl7.org/fhir"> <id value="Patient/codeSystem_history/v1"/> <derivation value="Transformation: ICD-10-CM,HCPCS"/> <lastTransformed> <xsl:attribute name="value" select="$date"/> </lastTransformed> <translation> <xsl:call-template name="coding-template" /> </translation> </Provenance> </xsl:template> <xsl:template name="coding-template" > <xsl:for-each select="//n1:translation"> <!-- <xsl:for-each-group select="//n1:translation" group-by="@codeSystemName">--> <!-- group-adjacent="if (self::p[@codeSystemName='ICD-10-CM']) then $ICD-10 else if (self::p[@codeSystemName ='SNOMED-CT']) then $SNOMED-CT else $HCPCS ">--> <coding xmlns="http://hl7.org/fhir"> <xsl:element name="system"> <xsl:attribute name="value"> <xsl:choose> <!-- <xsl:when test="key('code-system-name','ICD-10-CM')">--> <xsl:when test="contains(@codeSystemName,'ICD-10')"> <xsl:value-of select="$ICD-10"/> </xsl:when> <xsl:when test="contains(@codeSystemName,'SNOMED-CT')"> <xsl:value-of select="$SNOMED-CT"/> </xsl:when> <xsl:when test="contains(@codeSystemName,'HCPCS')"> <xsl:value-of select="$HCPCS"/> </xsl:when> </xsl:choose> </xsl:attribute> </xsl:element> <xsl:element name="code"> <xsl:attribute name="value"><xsl:value-of select="@code"/></xsl:attribute> </xsl:element> <xsl:element name="display"> <xsl:attribute name="value"><xsl:value-of select="@displayName"/></xsl:attribute> </xsl:element> </coding> </xsl:for-each> <!--</xsl:for-each-group>--> </xsl:template>
都会被无意中提取(ICD-9-CM
)。
<system value=""/>
- 第二,原始文档未保留。
解决方法
听起来好像您想执行以下操作:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xpath-default-namespace="urn:hl7-org:v3"
exclude-result-prefixes="#all"
xmlns="http://hl7.org/fhir"
version="3.0">
<xsl:param name="needed-codes" as="xs:string*"
select="'ICD-10-CM','ICD-10-PCS','HCPCS','SNOMED-CT'"/>
<xsl:mode on-no-match="shallow-skip"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<Provenance>
<id value="Patient/codeSystem_history/v1"/>
<derivation value="Transformation: {$needed-codes}"/>
<translatation>
<xsl:for-each-group select="//translation[@codeSystemName = $needed-codes]"
composite="yes" group-by="@code,@codeSystem">
<coding>
<xsl:apply-templates select="@codeSystemName,@code,@displayName"/>
</coding>
</xsl:for-each-group>
</translatation>
</Provenance>
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="translation[starts-with(@codeSystemName,'ICD-10-')]/@codeSystemName">
<system value="http://hl7.org/fhir/sid/icd-10"/>
</xsl:template>
<xsl:template match="translation[@codeSystemName = 'HCPCS']/@codeSystemName">
<system value="HCPCS"/>
</xsl:template>
<xsl:template match="translation[@codeSystemName = 'SNOMED-CT']/@codeSystemName">
<system value="SNOMED-CT"/>
</xsl:template>
<xsl:template match="@code">
<code value="{.}"/>
</xsl:template>
<xsl:template match="@displayName">
<display value="{.}"/>
</xsl:template>
</xsl:stylesheet>
我不太确定自己是否使用了正确的选择和正确的分组键(因为我不知道输入格式,而且这个问题不能清楚地描述输入/输出片段是否匹配),但至少可以输入数据的一些分组和转换。
我不明白“未保留原始文档”指的是什么,不清楚在所需的输出样本中您在何处进行描述。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。