Last active
August 29, 2015 14:03
-
-
Save vaibhavb/0cae48afaf6fd91aac10 to your computer and use it in GitHub Desktop.
HealthVault XSLT for CCD/A documents. Created using the documentation available [here](http://blogs.msdn.com/b/familyhealthguy/archive/2011/07/10/healthvault-data-type-awesomeness.aspx)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="" xmlns:cda="urn:hl7-org:v3" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mif="urn:hl7-org:v3/mif" | |
xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:h="urn:com.microsoft.wc.thing" | |
xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0"> | |
<xsl:output method="xml" indent="no" encoding="utf-8"/> | |
<xsl:param name="g_debug"/> | |
<xsl:template name="Write_LF"> | |
<xsl:value-of select="h:lf()"/> | |
</xsl:template> | |
<xsl:template name="Write_Line"> | |
<xsl:param name="value"/> | |
<xsl:if test="$value != ''"> | |
<xsl:value-of select="$value"/> | |
<xsl:call-template name="Write_LF"/> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Write_Divider"> | |
<xsl:call-template name="Write_Line"> | |
<xsl:with-param name="value">----------</xsl:with-param> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="Concat"> | |
<xsl:param name="separator"/> | |
<xsl:param name="nodes"/> | |
<xsl:variable name="concatResult"> | |
<xsl:for-each select="$nodes"> | |
<xsl:variable name="value" select="string(.)"/> | |
<xsl:if test="$value != ''"> | |
<xsl:value-of select="$separator"/> | |
<xsl:value-of select="$value"/> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:variable> | |
<xsl:value-of select="substring-after(string($concatResult), $separator)"/> | |
</xsl:template> | |
<xsl:template name="ConcatPhrases"> | |
<xsl:param name="nodes"/> | |
<xsl:call-template name="Concat"> | |
<xsl:with-param name="nodes" select="$nodes"/> | |
<xsl:with-param name="separator"/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="Write_Concatenated"> | |
<xsl:param name="separator"/> | |
<xsl:param name="nodes"/> | |
<xsl:param name="tag"/> | |
<xsl:variable name="concatResult"> | |
<xsl:for-each select="$nodes"> | |
<xsl:variable name="value" select="string(.)"/> | |
<xsl:if test="$value != ''"> | |
<xsl:value-of select="$separator"/> | |
<xsl:value-of select="$value"/> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:variable> | |
<xsl:variable name="value" select="substring-after(string($concatResult), $separator)"/> | |
<xsl:if test="$value != ''"> | |
<xsl:element name="{$tag}"> | |
<xsl:value-of select="$value"/> | |
</xsl:element> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="NodeToString"> | |
<xsl:param name="node"/> | |
<xsl:param name="indent"/> | |
<xsl:param name="fRecursive"/> | |
<xsl:variable name="value" select="normalize-space(string($node/text()))"/> | |
<xsl:variable name="attributes" select="$node/attribute::node()"/> | |
<xsl:variable name="children" select="$node/child::node()"/> | |
<xsl:variable name="localName" select="local-name($node)"/> | |
<xsl:if test="$localName != ''"> | |
<xsl:value-of select="h:lf()"/> | |
<xsl:value-of select="$indent"/> | |
<xsl:value-of select="$localName"/> | |
</xsl:if> | |
<xsl:if test="$value != ''"> | |
<xsl:if test="$localName != ''"> | |
<xsl:text>: </xsl:text> | |
<xsl:value-of select="$value"/> | |
</xsl:if> | |
</xsl:if> | |
<xsl:if test="$attributes or $children"> | |
<xsl:for-each select="$attributes"> | |
<xsl:text> [</xsl:text> | |
<xsl:value-of select="local-name(.)"/> | |
<xsl:text>=</xsl:text> | |
<xsl:value-of select="."/> | |
<xsl:text> ]</xsl:text> | |
</xsl:for-each> | |
<xsl:if test="$fRecursive and $children"> | |
<xsl:variable name="childIndent" select="concat($indent, ' ')"/> | |
<xsl:variable name="hasChildElements" | |
select="count($node/child::text()) != count($children)"/> | |
<xsl:if test="$hasChildElements"> | |
<xsl:value-of select="h:lf()"/> | |
<xsl:value-of select="$indent"/> | |
<xsl:text>{</xsl:text> | |
</xsl:if> | |
<xsl:call-template name="NodesetToString"> | |
<xsl:with-param name="nodeset" select="$children"/> | |
<xsl:with-param name="indent" select="$childIndent"/> | |
<xsl:with-param name="fRecursive" select="$fRecursive"/> | |
</xsl:call-template> | |
<xsl:if test="$hasChildElements"> | |
<xsl:value-of select="h:lf()"/> | |
<xsl:value-of select="$indent"/> | |
<xsl:text>}</xsl:text> | |
</xsl:if> | |
</xsl:if> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="NodesetToString"> | |
<xsl:param name="nodeset"/> | |
<xsl:param name="indent"/> | |
<xsl:param name="fRecursive"/> | |
<xsl:if test="$nodeset"> | |
<xsl:for-each select="$nodeset"> | |
<xsl:call-template name="NodeToString"> | |
<xsl:with-param name="node" select="."/> | |
<xsl:with-param name="indent" select="$indent"/> | |
<xsl:with-param name="fRecursive" select="$fRecursive"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="CopyNodeset"> | |
<xsl:param name="node"/> | |
<xsl:param name="filter"/> | |
<xsl:choose> | |
<xsl:when test="$filter"> | |
<xsl:for-each select="$node"> | |
<xsl:variable name="nodeName" select="local-name()"/> | |
<xsl:if test="not($nodeName = $filter)"> | |
<xsl:copy> | |
<xsl:copy-of select="attribute::node()"/> | |
<xsl:variable name="children" select="child::node()"/> | |
<xsl:if test="$children"> | |
<xsl:call-template name="CopyNodeset"> | |
<xsl:with-param name="node" select="$children"/> | |
<xsl:with-param name="filter" select="$filter"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:copy> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:copy-of select="$node"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="Throw"> | |
<h:EXCEPTION/> | |
</xsl:template> | |
<xsl:template name="Finally"> | |
<xsl:param name="fragment"/> | |
<xsl:variable name="node" select="msxsl:node-set($fragment)"/> | |
<xsl:choose> | |
<xsl:when test="not($node) or $node//h:EXCEPTION"> | |
<xsl:if test="$g_debug"> | |
<xsl:call-template name="Log_Exception"> | |
<xsl:with-param name="node" select="$node"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:copy-of select="$node"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="CommitSuccessful"> | |
<xsl:param name="nodeset"/> | |
<xsl:variable name="successful" select="$nodeset[not(descendant-or-self::h:EXCEPTION)]"/> | |
<xsl:if test="$successful"> | |
<xsl:copy-of select="$successful"/> | |
</xsl:if> | |
<xsl:if test="$g_debug and count($successful) != count($nodeset)"> | |
<xsl:call-template name="Log_Exception"> | |
<xsl:with-param name="node" select="$nodeset[descendant-or-self::h:EXCEPTION]"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Log_Exception"> | |
<xsl:param name="node"/> | |
<xsl:variable name="exceptionString"> | |
<xsl:text>******EXCEPTION*******</xsl:text> | |
<xsl:value-of select="h:lf()"/> | |
<xsl:call-template name="NodesetToString"> | |
<xsl:with-param name="nodeset" select="$node"/> | |
<xsl:with-param name="fRecursive" select="true()"/> | |
</xsl:call-template> | |
<xsl:text>**********************</xsl:text> | |
</xsl:variable> | |
<xsl:message> | |
<xsl:value-of select="$exceptionString"/> | |
</xsl:message> | |
<xsl:comment><xsl:value-of select="$exceptionString"/></xsl:comment> | |
</xsl:template> | |
<xsl:template name="ToInteger"> | |
<xsl:param name="value"/> | |
<xsl:choose> | |
<xsl:when test="$value"> | |
<xsl:variable name="numValue" select="number($value)"/> | |
<xsl:variable name="numString" select="string($numValue)"/> | |
<xsl:choose> | |
<xsl:when test="$numString != 'NaN'"> | |
<xsl:variable name="intValue" select="round($numValue)"/> | |
<xsl:choose> | |
<xsl:when test="$intValue = $numValue"> | |
<xsl:value-of select="$numString"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="ToUnsignedInteger"> | |
<xsl:param name="value"/> | |
<xsl:choose> | |
<xsl:when test="$value"> | |
<xsl:variable name="numValue" select="number($value)"/> | |
<xsl:variable name="numString" select="string($numValue)"/> | |
<xsl:choose> | |
<xsl:when test="$numString != 'NaN'"> | |
<xsl:variable name="intValue" select="round($numValue)"/> | |
<xsl:choose> | |
<xsl:when test="$intValue = $numValue and $intValue >= 1"> | |
<xsl:value-of select="$numString"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="Write_ISODate"> | |
<xsl:param name="year"/> | |
<xsl:param name="month"/> | |
<xsl:param name="day"/> | |
<xsl:if test="$year != ''"> | |
<xsl:value-of select="format-number($year, '0000')"/> | |
<xsl:if test="$month != ''"> | |
<xsl:text>-</xsl:text> | |
<xsl:value-of select="format-number($month, '00')"/> | |
<xsl:if test="$day != ''"> | |
<xsl:text>-</xsl:text> | |
<xsl:value-of select="format-number($day, '00')"/> | |
</xsl:if> | |
</xsl:if> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Write_ISOTime"> | |
<xsl:param name="hour"/> | |
<xsl:param name="min"/> | |
<xsl:param name="sec"/> | |
<xsl:if test="$hour != ''"> | |
<xsl:text>T</xsl:text> | |
<xsl:value-of select="format-number($hour, '00')"/> | |
<xsl:if test="$min != ''"> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="format-number($min, '00')"/> | |
<xsl:if test="$sec != ''"> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="format-number($sec, '00')"/> | |
</xsl:if> | |
</xsl:if> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Write_ISOTimeZone"> | |
<xsl:param name="tz"/> | |
<xsl:if test="$tz != ''"> | |
<xsl:choose> | |
<xsl:when test="$tz = 'Z' or $tz = 'GMT'"> | |
<xsl:text>Z</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:variable name="offset"> | |
<xsl:choose> | |
<xsl:when test="starts-with($tz, 'GMT')"> | |
<xsl:value-of select="substring-after($tz, 'GMT')"/> | |
</xsl:when> | |
<xsl:when test="starts-with($tz, 'Z')"> | |
<xsl:value-of select="substring-after($tz, 'Z')"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$tz"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="starts-with($offset, '+') or starts-with($offset, '-')"> | |
<xsl:variable name="normalized-offset" | |
select="translate(substring($offset, 2), ':', '')"/> | |
<xsl:if | |
test="(string-length($normalized-offset) = 2 or string-length($normalized-offset) = 4)
 and string(number($normalized-offset)) != 'NaN'"> | |
<xsl:value-of select="$offset"/> | |
</xsl:if> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Write_ISODateTime"> | |
<xsl:param name="year"/> | |
<xsl:param name="month"/> | |
<xsl:param name="day"/> | |
<xsl:param name="hour"/> | |
<xsl:param name="min"/> | |
<xsl:param name="sec"/> | |
<xsl:param name="tz"/> | |
<xsl:call-template name="Write_ISODate"> | |
<xsl:with-param name="year" select="$year"/> | |
<xsl:with-param name="month" select="$month"/> | |
<xsl:with-param name="day" select="$day"/> | |
</xsl:call-template> | |
<xsl:call-template name="Write_ISOTime"> | |
<xsl:with-param name="hour" select="$hour"/> | |
<xsl:with-param name="min" select="$min"/> | |
<xsl:with-param name="sec" select="$sec"/> | |
</xsl:call-template> | |
<xsl:call-template name="Write_ISOTimeZone"> | |
<xsl:with-param name="tz" select="$tz"/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:variable name="g_ccrVocabData"> | |
<ccrVocab> | |
<general> | |
<healthcare-system> | |
<export>Healthcare Information System</export> | |
<import>healthcare information system</import> | |
</healthcare-system> | |
<patient> | |
<export>Patient</export> | |
<import>patient</import> | |
</patient> | |
<priority-primary> | |
<export>Primary</export> | |
<import>primary</import> | |
<import>preferred</import> | |
<import>primary-preferred</import> | |
<import>1</import> | |
</priority-primary> | |
<priority-secondary> | |
<export>Secondary</export> | |
<import>secondary</import> | |
<import>2</import> | |
</priority-secondary> | |
</general> | |
<measurements> | |
<inches> | |
<export>in</export> | |
<import>in</import> | |
<import>inch</import> | |
<import>inches</import> | |
<ucum>[in_us]</ucum> | |
</inches> | |
<feet> | |
<export>ft</export> | |
<import>ft</import> | |
<import>feet</import> | |
<ucum>[ft_us]</ucum> | |
</feet> | |
<kilometers> | |
<export>km</export> | |
<import>k</import> | |
<import>km</import> | |
<import>kilometers</import> | |
<import>kilometer</import> | |
<ucum>km</ucum> | |
</kilometers> | |
<meters> | |
<export>m</export> | |
<import>m</import> | |
<import>meter</import> | |
<import>meters</import> | |
<ucum>m</ucum> | |
</meters> | |
<centimeters> | |
<export>cm</export> | |
<import>cm</import> | |
<import>centimeters</import> | |
<import>centimetres</import> | |
<ucum>cm</ucum> | |
</centimeters> | |
<miles> | |
<export>mi</export> | |
<import>mi</import> | |
<import>mile</import> | |
<import>miles</import> | |
<ucum>[mi_us]</ucum> | |
</miles> | |
<pounds> | |
<export>lbs</export> | |
<import>lb</import> | |
<import>lbs</import> | |
<import>pounds</import> | |
<ucum>[lb_av]</ucum> | |
</pounds> | |
<ounces> | |
<export>oz</export> | |
<import>oz</import> | |
<import>ounce</import> | |
<import>ounces</import> | |
<ucum>[oz_av]</ucum> | |
</ounces> | |
<kilos> | |
<export>kg</export> | |
<import>kg</import> | |
<import>kgs</import> | |
<import>kilos</import> | |
<import>kilogram</import> | |
<import>kilograms</import> | |
<ucum>kg</ucum> | |
</kilos> | |
<grams> | |
<export>gm</export> | |
<import>gm</import> | |
<import>gram</import> | |
<import>grams</import> | |
<ucum>g</ucum> | |
</grams> | |
<molarity> | |
<export>mmol/L</export> | |
<import>mmol/l</import> | |
</molarity> | |
<concentration> | |
<export>mg/dL</export> | |
<import>mg/dl</import> | |
</concentration> | |
<liters-per-second> | |
<export>l/s</export> | |
<import>l/s</import> | |
<import>liters/second</import> | |
<import>litres/second</import> | |
<ucum>L/s</ucum> | |
</liters-per-second> | |
<liters> | |
<export>liters</export> | |
<import>l</import> | |
<import>liter</import> | |
<import>liters</import> | |
<import>litres</import> | |
<ucum>L</ucum> | |
</liters> | |
<minutes> | |
<export>min</export> | |
<import>minutes</import> | |
<import>minute</import> | |
<import>min</import> | |
<import>m</import> | |
</minutes> | |
<hour> | |
<export>hours</export> | |
<import>h</import> | |
<import>hr</import> | |
<import>hour</import> | |
<import>hours</import> | |
</hour> | |
<second> | |
<export>seconds</export> | |
<import>s</import> | |
<import>sec</import> | |
<import>second</import> | |
<import>seconds</import> | |
</second> | |
<millimeters-mercury> | |
<export>mmHg</export> | |
<import>mmhg</import> | |
<import>mm[Hg]</import> | |
<ucum>mm[Hg]</ucum> | |
</millimeters-mercury> | |
<per-minute> | |
<export>per min</export> | |
<import>per min</import> | |
<import>per minute</import> | |
<import>per-min</import> | |
<import>per-minute</import> | |
<ucum>/min</ucum> | |
</per-minute> | |
<milligrams-per-deciliter> | |
<export>mg/DL</export> | |
<import>mg/DL</import> | |
<import>mg/dL</import> | |
<ucum>mg/dL</ucum> | |
</milligrams-per-deciliter> | |
<millimoles-per-liter> | |
<export>mmol/L</export> | |
<import>mmol/L</import> | |
<ucum>mmol/L</ucum> | |
</millimoles-per-liter> | |
<percent> | |
<export>%</export> | |
<import>%</import> | |
<ucum>%</ucum> | |
</percent> | |
</measurements> | |
<payer> | |
<payer-benefit-start-date> | |
<export>Benefit Start date</export> | |
<import>benefit start date</import> | |
<import>start date</import> | |
<import>effective date</import> | |
</payer-benefit-start-date> | |
<payer-benefit-stop-date> | |
<export>Benefit Stop date</export> | |
<import>termination date</import> | |
<import>benefit stop date</import> | |
<import>expiration date</import> | |
<import>stop date</import> | |
<import>end date</import> | |
</payer-benefit-stop-date> | |
<payer-primary-health-insurance> | |
<export>Primary Health Insurance</export> | |
<import>primary health insurance</import> | |
</payer-primary-health-insurance> | |
<payer-plan-code> | |
<export>Plan code</export> | |
<import>plan code</import> | |
<import>plan id</import> | |
<import>plan number</import> | |
</payer-plan-code> | |
<payer-group-number> | |
<export>Group number</export> | |
<import>group number</import> | |
<import>group id</import> | |
<import>group code</import> | |
</payer-group-number> | |
<payer-subscriber-number> | |
<export>Subscriber number</export> | |
<import>subscriber number</import> | |
<import>subscriber id</import> | |
<import>subscriber code</import> | |
</payer-subscriber-number> | |
<payer-carrier-id> | |
<export>Carrier ID</export> | |
<import>carrier id</import> | |
<import>carrier number</import> | |
<import>carrier code</import> | |
</payer-carrier-id> | |
</payer> | |
<advance-directives> | |
<directive-start-date> | |
<export>Start date</export> | |
<import>start date</import> | |
</directive-start-date> | |
<directive-stop-date> | |
<export>End date</export> | |
<import>end date</import> | |
</directive-stop-date> | |
<directive-treating-physician> | |
<export>Treating physician</export> | |
<import>treating clinician</import> | |
<import>treating physician</import> | |
<import>treatment provider</import> | |
<import>attending</import> | |
<import>attending provider</import> | |
<import>attending physician</import> | |
<import>attending clinician</import> | |
</directive-treating-physician> | |
<directive-verified-treating-physician> | |
<export>Verified With Treating Physician</export> | |
<import>verified with treating physician</import> | |
</directive-verified-treating-physician> | |
</advance-directives> | |
<problem> | |
<problem-onset-date> | |
<export>Onset date</export> | |
<import>onset date</import> | |
<import>start date</import> | |
<import>begin date</import> | |
<import>date of onset</import> | |
<import>since age</import> | |
<import>from age</import> | |
<import>onset</import> | |
<import>from date</import> | |
<import>started</import> | |
<import>diagnosis date</import> | |
</problem-onset-date> | |
<problem-end-date> | |
<export>End date</export> | |
<import>end date</import> | |
<import>stop date</import> | |
<import>ended</import> | |
<import>to date</import> | |
</problem-end-date> | |
<problem-status> | |
<export-code> | |
<code>55561003</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>active</displayName> | |
</export-code> | |
<export-code> | |
<code>73425007</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>inactive</displayName> | |
</export-code> | |
<export-code> | |
<code>90734009</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>chronic</displayName> | |
</export-code> | |
<export-code> | |
<code>7087005</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>intermittent</displayName> | |
</export-code> | |
<export-code> | |
<code>255227004</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>recurrent</displayName> | |
</export-code> | |
<export-code> | |
<code>415684004</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>rule out</displayName> | |
</export-code> | |
<export-code> | |
<code>410516002</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>ruled out</displayName> | |
</export-code> | |
<export-code> | |
<code>413322009</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.13</codeSystem> | |
<codeSystemName>SNOMED CT</codeSystemName> | |
<displayName>resolved</displayName> | |
</export-code> | |
</problem-status> | |
</problem> | |
<alerts> | |
<allergy> | |
<export>Allergy</export> | |
<import>allergy</import> | |
<import>adverse reaction</import> | |
</allergy> | |
<allergy-start-date> | |
<export>Start date</export> | |
<import>start date</import> | |
<import>onset date</import> | |
<import>date of onset</import> | |
<import>since age</import> | |
<import>from date</import> | |
<import>onset</import> | |
<import>initial occurrence</import> | |
</allergy-start-date> | |
</alerts> | |
<medication> | |
<medication-date-range> | |
<export>range</export> | |
<import>range</import> | |
<import>range </import> | |
</medication-date-range> | |
<medication-start-date> | |
<export>Start date</export> | |
<import>start date</import> | |
<import>administration date</import> | |
<import>since age</import> | |
<import>from age</import> | |
<import>from date</import> | |
<import>begin date</import> | |
<import>started</import> | |
</medication-start-date> | |
<medication-stop-date> | |
<export>Stop date</export> | |
<import>stop date</import> | |
<import>end date</import> | |
<import>to date</import> | |
<import>stopped</import> | |
</medication-stop-date> | |
<medication-prescription-date> | |
<export>Prescription date</export> | |
<import>prescription date</import> | |
<import>prescribed date</import> | |
<import>date prescribed</import> | |
<import>prescribed</import> | |
</medication-prescription-date> | |
<medication-prescribing-provider> | |
<export>Prescribing provider</export> | |
<import>prescribing provider</import> | |
<import>prescribing physician</import> | |
<import>prescribing clinician</import> | |
<import>prescriber</import> | |
</medication-prescribing-provider> | |
</medication> | |
<immunization> | |
<immunization-date> | |
<export>Immunization date</export> | |
<import>immunization date</import> | |
<import>administration date</import> | |
<import>administered</import> | |
<import>start date</import> | |
</immunization-date> | |
<immunization-lot-number> | |
<export>Immunization lot number</export> | |
<import>immunization lot number</import> | |
<import>lot number</import> | |
<import>lot</import> | |
</immunization-lot-number> | |
</immunization> | |
<vital-signs> | |
<blood-glucose> | |
<export>Blood glucose</export> | |
<export-code> | |
<code>434912009</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Blood glucose</displayName> | |
</export-code> | |
<import>glucose, plasma</import> | |
<import>glucose, serum</import> | |
<import>plasma</import> | |
<import>whole blood</import> | |
<import>blood glucose</import> | |
<import>blood glucose (before breakfast)</import> | |
<import>blood glucose (before lunch)</import> | |
<import>blood glucose (before supper)</import> | |
<import>blood glucose (before dinner)</import> | |
<import>blood glucose (bedtime)</import> | |
<import>blood glucose (night)</import> | |
<import-code> | |
<code>434912009</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
</import-code> | |
</blood-glucose> | |
<blood-oxygen-saturation> | |
<export>Blood oxygen saturation</export> | |
<export-code> | |
<code>103228002</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Blood oxygen saturation</displayName> | |
</export-code> | |
<import>blood oxygen saturation</import> | |
</blood-oxygen-saturation> | |
<blood-pressure> | |
<export>Blood Pressure</export> | |
<export-code> | |
<code>75367002</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Blood pressure</displayName> | |
</export-code> | |
<import>blood pressure</import> | |
</blood-pressure> | |
<blood-pressure-systolic> | |
<export>Systolic Blood Pressure</export> | |
<export-code> | |
<code>271649006</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Systolic blood pressure</displayName> | |
</export-code> | |
<import>systolic blood pressure</import> | |
<import>systolic</import> | |
<import>bp (systolic)</import> | |
<import>systolic bp-sitting</import> | |
<import>systolic bp</import> | |
<import>bp sys</import> | |
<import>systolic bp sitting</import> | |
</blood-pressure-systolic> | |
<blood-pressure-diastolic> | |
<export>Diastolic Blood Pressure</export> | |
<export-code> | |
<code>271650006</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Diastolic blood pressure</displayName> | |
</export-code> | |
<import>diastolic blood pressure</import> | |
<import>diastolic</import> | |
<import>bp (diastolic)</import> | |
<import>diastolic bp-sitting</import> | |
<import>diastolic bp</import> | |
<import>bp dias</import> | |
<import>diastolic bp sitting</import> | |
</blood-pressure-diastolic> | |
<blood-pressure-pulse> | |
<export>Pulse Rate</export> | |
<export-code> | |
<code>364075005</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Heart rate</displayName> | |
</export-code> | |
<import>pulse rate</import> | |
<import>pulse</import> | |
<import>pul rate</import> | |
<import>pulse-rate</import> | |
<import>heart beat</import> | |
<import>heart rate</import> | |
</blood-pressure-pulse> | |
<cholesterol> | |
<export>Cholesterol</export> | |
<import>cholesterol</import> | |
</cholesterol> | |
<cholesterol-ldl> | |
<export>LDL Cholesterol</export> | |
<export-code> | |
<code>102739008</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Low density lipoprotein (LDL) cholesterol</displayName> | |
</export-code> | |
<import>ldl cholesterol</import> | |
<import>ldl</import> | |
<import>cholesterol ldl</import> | |
<import>ldl cholesterol calc</import> | |
<import>ldl-cholesterol</import> | |
<import>low density lipoprotein (LDL) cholesterol</import> | |
<import-code> | |
<code>55440-2</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>2089-1</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>13457-7</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>18262-6</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>49132-4</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>18261-8</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>102739008</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
</import-code> | |
</cholesterol-ldl> | |
<cholesterol-hdl> | |
<export>HDL Cholesterol</export> | |
<export-code> | |
<code>102737005</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>High density lipoprotein (HDL) cholesterol</displayName> | |
</export-code> | |
<import>hdl cholesterol</import> | |
<import>hdl</import> | |
<import>cholesterol hdl</import> | |
<import>hdl cholesterol calc</import> | |
<import>hdl-cholesterol</import> | |
<import>high density lipoprotein (HDL) cholesterol</import> | |
<import-code> | |
<code>54372-8</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>2085-9</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>49130-8</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>18263-4</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>102737005</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
</import-code> | |
</cholesterol-hdl> | |
<cholesterol-total> | |
<export>Total Cholesterol</export> | |
<export-code> | |
<code>301860006</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Total cholesterol</displayName> | |
</export-code> | |
<import>total cholesterol</import> | |
<import>total</import> | |
<import>cholesterol total</import> | |
<import>cholesterol, total</import> | |
</cholesterol-total> | |
<cholesterol-triglycerides> | |
<export>Triglycerides</export> | |
<export-code> | |
<code>85600001</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Triglycerides</displayName> | |
</export-code> | |
<import>triglycerides</import> | |
<import>triglyceride</import> | |
<import>trig</import> | |
<import>triglycerides, blood</import> | |
</cholesterol-triglycerides> | |
<exercise-distance> | |
<export>Exercise distance</export> | |
<import>exercise distance</import> | |
</exercise-distance> | |
<exercise-duration> | |
<export>Exercise duration</export> | |
<import>exercise duration</import> | |
</exercise-duration> | |
<exercise-details> | |
<export>Exercise details</export> | |
<import>exercise details</import> | |
</exercise-details> | |
<height> | |
<export>Height</export> | |
<export-code> | |
<code>50373000</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Body height</displayName> | |
</export-code> | |
<import>height</import> | |
<import>hgt</import> | |
<import>body height</import> | |
<import-code> | |
<code>3137-7</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>3138-5</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8301-4</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8302-2</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8303-0</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8304-8</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8305-5</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8306-3</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8307-1</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8308-9</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>50373000</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
</import-code> | |
</height> | |
<peak-flow> | |
<export>Peak Flow</export> | |
<import>peak flow</import> | |
</peak-flow> | |
<peak-flow-fev1> | |
<export>Forced Expiratory Volume in One Second (FEV1)</export> | |
<export-code> | |
<code>59328004</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Forced expiratory volume in 1 second</displayName> | |
</export-code> | |
<import>fev1</import> | |
<import>forced expiratory volume in one second (fev1)</import> | |
<import>forced expiratory volume in 1 second</import> | |
<import-code> | |
<code>59328004</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
</import-code> | |
</peak-flow-fev1> | |
<peak-flow-fev6> | |
<export>Forced Expiratory Volume in Six Seconds (FEV6)</export> | |
<export-code> | |
<displayName>Forced expiratory volume in 6 seconds</displayName> | |
</export-code> | |
<import>fev6</import> | |
<import>forced expiratory volume in six seconds (fev6)</import> | |
<import>forced expiratory volume in 6 seconds</import> | |
</peak-flow-fev6> | |
<peak-flow-pef> | |
<export>Peak Expiratory Flow Rate (PEFR)</export> | |
<export-code> | |
<code>18491006</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Peak expiratory flow rate</displayName> | |
</export-code> | |
<import>pef</import> | |
<import>pefr</import> | |
<import>peak expiratory flow rate (pef)</import> | |
<import>peak expiratory flow rate (pefr)</import> | |
<import-code> | |
<code>18491006</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
</import-code> | |
</peak-flow-pef> | |
<radiology-lab-results> | |
<export>radiology results</export> | |
<import>imaging - x-ray</import> | |
<import>ultrasound</import> | |
<import>ct</import> | |
<import>mri</import> | |
<import>angiography</import> | |
<import>cardiac echo</import> | |
<import>nuclear medicine</import> | |
<import>radiology results</import> | |
</radiology-lab-results> | |
<weight> | |
<export>Weight</export> | |
<export-code> | |
<code>27113001</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
<displayName>Body weight</displayName> | |
</export-code> | |
<import>weight</import> | |
<import>wgt</import> | |
<import>body weight</import> | |
<import-code> | |
<code>18833-4</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>29463-7</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>3141-9</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>3142-7</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>50064-5</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8335-2</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8338-6</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8339-4</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8340-2</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8341-0</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8342-8</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8343-6</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8344-4</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8345-1</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8346-9</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8347-7</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8348-5</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8349-3</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8350-1</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>8351-9</code> | |
<codeSystem>2.16.840.1.113883.6.1</codeSystem> | |
</import-code> | |
<import-code> | |
<code>27113001</code> | |
<codeSystem>2.16.840.1.113883.6.96</codeSystem> | |
</import-code> | |
</weight> | |
</vital-signs> | |
<results> | |
<result-collection-date> | |
<export>Collection start date</export> | |
<import>collection start date</import> | |
<import>collection date time</import> | |
<import>collection time</import> | |
<import>measurement start date</import> | |
<import>measurement time</import> | |
<import>assessment time</import> | |
<import>performed</import> | |
</result-collection-date> | |
<result-ordering-provider> | |
<export>Ordering provider</export> | |
<import>ordering provider</import> | |
<import>ordering physician</import> | |
<import>ordering clinician</import> | |
<import>ordered by</import> | |
</result-ordering-provider> | |
<result-discharge-summary> | |
<export>Discharge summary</export> | |
<import>discharge summary</import> | |
</result-discharge-summary> | |
<discharge-summary-create-date> | |
<export>Created</export> | |
<import>clinical report creation date</import> | |
<import>transcribed</import> | |
<import>created</import> | |
<import>creation date</import> | |
</discharge-summary-create-date> | |
<discharge-summary-comment> | |
<export>Discharge summary</export> | |
<import>discharge summary</import> | |
<import>clinical report</import> | |
</discharge-summary-comment> | |
<discharge-summary-primary-provider> | |
<export>Primary provider</export> | |
<import>primary provider</import> | |
</discharge-summary-primary-provider> | |
<discharge-summary-secondary-provider> | |
<export>Secondary provider</export> | |
<import>secondary provider</import> | |
</discharge-summary-secondary-provider> | |
<discharge-summary-principal-procedure-physician> | |
<export>Principal procedure physician</export> | |
<import>principal procedure physician</import> | |
</discharge-summary-principal-procedure-physician> | |
<discharge-summary-primary-endorsement> | |
<export>Primary provider endorsement</export> | |
<import>primary provider endorsement</import> | |
</discharge-summary-primary-endorsement> | |
<discharge-summary-secondary-endorsement> | |
<export>Secondary provider endorsement</export> | |
<import>secondary provider endorsement</import> | |
</discharge-summary-secondary-endorsement> | |
<discharge-summary-discharge-date> | |
<export>Discharge date</export> | |
<import>discharge date</import> | |
</discharge-summary-discharge-date> | |
</results> | |
<procedures> | |
<procedure-date> | |
<export>Performed</export> | |
<import>performed</import> | |
<import>start date</import> | |
<import>procedure date</import> | |
<import>occurred</import> | |
<import>service date</import> | |
</procedure-date> | |
<procedure-primary-provider> | |
<export>Treating clinician</export> | |
<import>treating clinician</import> | |
<import>treating physician</import> | |
<import>treatment provider</import> | |
<import>primary care provider</import> | |
<import>primary care physician</import> | |
<import>primary care clinician</import> | |
<import>administered by</import> | |
<import>performed by</import> | |
</procedure-primary-provider> | |
<procedure-secondary-provider> | |
<export>Secondary care provider</export> | |
<import>secondary care provider</import> | |
<import>secondary care physician</import> | |
<import>secondary care clinician</import> | |
</procedure-secondary-provider> | |
</procedures> | |
<encounter> | |
<encounter-date> | |
<export>Encounter date</export> | |
<import>encounter date</import> | |
<import>occurred</import> | |
</encounter-date> | |
<encounter-pending> | |
<export>Pending</export> | |
<import>pending</import> | |
<import>scheduled</import> | |
</encounter-pending> | |
<appointment-date> | |
<export>Appointment date</export> | |
<import>appointment date</import> | |
<import>encounter date</import> | |
<import>scheduled date</import> | |
</appointment-date> | |
</encounter> | |
</ccrVocab> | |
</xsl:variable> | |
<xsl:variable name="g_ccrVocab" select="msxsl:node-set($g_ccrVocabData)/ccrVocab"/> | |
<xsl:variable name="g_ccdVocabData"> | |
<ccdVocab> | |
<results> | |
<observation-status> | |
<valid-export>normal</valid-export> | |
<valid-export>aborted</valid-export> | |
<valid-export>active</valid-export> | |
<valid-export>cancelled</valid-export> | |
<valid-export>completed</valid-export> | |
<valid-export>held</valid-export> | |
<valid-export>new</valid-export> | |
<valid-export>suspended</valid-export> | |
<valid-export>nullified</valid-export> | |
<valid-export>obsolete</valid-export> | |
</observation-status> | |
<radiology> | |
<export>Imaging</export> | |
<export-code> | |
<code>363679005</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
<displayName>Imaging</displayName> | |
</export-code> | |
<import>Imaging</import> | |
<import>X-ray</import> | |
<import>CT</import> | |
<import>MRI</import> | |
<import>Nuclear Medicine</import> | |
<import>Angiography</import> | |
<import>Cardiac Echo</import> | |
<import>Ultrasound</import> | |
<import-code> | |
<code>363679005</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
<import-code> | |
<code>363680008</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
<import-code> | |
<code>16310003</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
<import-code> | |
<code>77477000</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
<import-code> | |
<code>113091000</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
<import-code> | |
<code>371572003</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
<import-code> | |
<code>77343006</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
<import-code> | |
<code>40701008</code> | |
<codeSystem>2.16.840.1.113883.1.11.20.16</codeSystem> | |
</import-code> | |
</radiology> | |
</results> | |
</ccdVocab> | |
</xsl:variable> | |
<xsl:variable name="g_ccdVocab" select="msxsl:node-set($g_ccdVocabData)/ccdVocab"/> | |
<xsl:output method="xml"/> | |
<xsl:variable name="thingid" select="/thing/thing-id"/> | |
<xsl:variable name="version" select="/thing/thing-id/@version-stamp"/> | |
<xsl:variable name="v_vitals" select="$g_ccrVocab/vital-signs"/> | |
<xsl:variable name="v_measure" select="$g_ccrVocab/measurements"/> | |
<xsl:variable name="v_results" select="$g_ccdVocab/results"/> | |
<xsl:template match="/"> | |
<xsl:choose> | |
<xsl:when test="cda:ClinicalDocument"> | |
<xsl:apply-templates select="cda:ClinicalDocument"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:apply-templates select="/thing/data-xml/*"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template match="cda:ClinicalDocument"> | |
<xsl:variable name="payer_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.9</id> | |
<id>2.16.840.1.113883.10.20.22.2.18</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="payer_templates" select="msxsl:node-set($payer_template_ids)"/> | |
<xsl:variable name="payer_activity_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.20</id> | |
<id>2.16.840.1.113883.10.20.22.4.60</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="payer_activity" select="msxsl:node-set($payer_activity_ids)"/> | |
<xsl:variable name="policy_activity_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.26</id> | |
<id>2.16.840.1.113883.10.20.22.4.61</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="policy_activity" select="msxsl:node-set($policy_activity_ids)"/> | |
<xsl:call-template name="Payers"> | |
<xsl:with-param name="payers" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$payer_templates/ids/id]/cda:entry/cda:act[not(./@nullFlavor or ./@negationInd = 'true') and ./cda:templateId/@root=$payer_activity/ids/id]/cda:entryRelationship[./cda:act/cda:templateId/@root=$policy_activity/ids/id]"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$payer_templates/ids/id and ./cda:entry/cda:act[not(./@nullFlavor or ./@negationInd = 'true') and ./cda:templateId/@root=$payer_activity/ids/id]/cda:entryRelationship/cda:act[./cda:templateId/@root=$policy_activity/ids/id]]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="ad_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.1</id> | |
<id>2.16.840.1.113883.10.20.22.2.21</id> | |
<id>2.16.840.1.113883.10.20.22.2.21.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="advanced_directives_templates" select="msxsl:node-set($ad_template_ids)"/> | |
<xsl:variable name="advanced_directives_observation_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.17</id> | |
<id>2.16.840.1.113883.10.20.22.4.48</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="advanced_directives_observation" | |
select="msxsl:node-set($advanced_directives_observation_ids)"/> | |
<xsl:call-template name="AdvanceDirectives"> | |
<xsl:with-param name="directives" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$advanced_directives_templates/ids/id]/cda:entry/cda:observation[not(./@nullFlavor or ./@negationInd = 'true') and ./cda:templateId/@root=$advanced_directives_observation/ids/id]"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$advanced_directives_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="fh_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.4</id> | |
<id>2.16.840.1.113883.10.20.22.2.15</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="family_history_templates" select="msxsl:node-set($fh_template_ids)"/> | |
<xsl:call-template name="FamilyHistory"> | |
<xsl:with-param name="histories" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$family_history_templates/ids/id]/cda:entry"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$family_history_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="med_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.8</id> | |
<id>2.16.840.1.113883.10.20.22.2.1</id> | |
<id>2.16.840.1.113883.10.20.22.2.1.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="medication_templates" select="msxsl:node-set($med_template_ids)"/> | |
<xsl:call-template name="Medications"> | |
<xsl:with-param name="medications" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$medication_templates/ids/id]/cda:entry/cda:substanceAdministration[not(./@nullFlavor or ./@negationInd = 'true')]"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$medication_templates/ids/id and ./cda:entry/cda:substanceAdministration[not(./@nullFlavor or ./@negationInd = 'true')]]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="immunization_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.6</id> | |
<id>2.16.840.1.113883.10.20.22.2.2</id> | |
<id>2.16.840.1.113883.10.20.22.2.2.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="immunization_templates" | |
select="msxsl:node-set($immunization_template_ids)"/> | |
<xsl:variable name="immunization_administration_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.24</id> | |
<id>2.16.840.1.113883.10.20.22.4.52</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="immunization_administration" | |
select="msxsl:node-set($immunization_administration_ids)"/> | |
<xsl:call-template name="Immunizations"> | |
<xsl:with-param name="immunizations" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$immunization_templates/ids/id]/cda:entry/cda:substanceAdministration[not(./@nullFlavor or ./@negationInd = 'true') and ./cda:templateId/@root = $immunization_administration/ids/id]"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$immunization_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="vs_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.16</id> | |
<id>2.16.840.1.113883.10.20.22.2.4</id> | |
<id>2.16.840.1.113883.10.20.22.2.4.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="vital_signs_templates" select="msxsl:node-set($vs_template_ids)"/> | |
<xsl:call-template name="VitalSigns"> | |
<xsl:with-param name="vital-signs" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$vital_signs_templates/ids/id]/cda:entry"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$vital_signs_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="lr_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.14</id> | |
<id>2.16.840.1.113883.3.88.11.83.122</id> | |
<id>1.3.6.1.4.1.19376.1.5.3.1.3.28</id> | |
<id>2.16.840.1.113883.10.20.22.2.3</id> | |
<id>2.16.840.1.113883.10.20.22.2.3.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="lab_result_templates" select="msxsl:node-set($lr_template_ids)"/> | |
<xsl:call-template name="LabResults"> | |
<xsl:with-param name="lab-results" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$lab_result_templates/ids/id]/cda:entry"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$lab_result_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="procedure_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.12</id> | |
<id>2.16.840.1.113883.10.20.22.2.7</id> | |
<id>2.16.840.1.113883.10.20.22.2.7.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="procedure_templates" select="msxsl:node-set($procedure_template_ids)"/> | |
<xsl:call-template name="Procedures"> | |
<xsl:with-param name="procedures" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$procedure_templates/ids/id]/cda:entry"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$procedure_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="encounter_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.3</id> | |
<id>2.16.840.1.113883.10.20.22.2.22</id> | |
<id>2.16.840.1.113883.10.20.22.2.22.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="encounter_templates" select="msxsl:node-set($encounter_template_ids)"/> | |
<xsl:call-template name="Encounters"> | |
<xsl:with-param name="encounters" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$encounter_templates/ids/id]/cda:entry/cda:encounter"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$encounter_templates/ids/id and ./cda:entry/cda:encounter]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="allergies_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.2</id> | |
<id>2.16.840.1.113883.10.20.22.2.6</id> | |
<id>2.16.840.1.113883.10.20.22.2.6.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="allergies_templates" select="msxsl:node-set($allergies_template_ids)"/> | |
<xsl:variable name="allergy_activity_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.27</id> | |
<id>2.16.840.1.113883.10.20.22.4.30</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="allergy_activities" select="msxsl:node-set($allergy_activity_ids)"/> | |
<xsl:variable name="allergy_observation_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.18</id> | |
<id>2.16.840.1.113883.10.20.22.4.7</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="allergy_observations" select="msxsl:node-set($allergy_observation_ids)"/> | |
<xsl:call-template name="Allergies"> | |
<xsl:with-param name="allergies" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$allergies_templates/ids/id]/cda:entry/cda:act[not(./@nullFlavor or ./@negationInd = 'true') and ./cda:templateId/@root = $allergy_activities/ids/id]/cda:entryRelationship/cda:observation[./cda:templateId/@root = $allergy_observations/ids/id and ((./cda:value/@code and ./cda:value/@code != '160244002') or not(./cda:value/@code))]"/> | |
<xsl:with-param name="effectiveTime" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$allergies_templates/ids/id]/cda:entry/cda:act[not(./@nullFlavor or ./@negationInd = 'true') and ./cda:templateId/@root = $allergy_activities/ids/id]/cda:entryRelationship/cda:effectiveTime"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$allergies_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="conditions_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.11</id> | |
<id>2.16.840.1.113883.10.20.22.2.5</id> | |
<id>2.16.840.1.113883.10.20.22.2.5.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="conditions_templates" select="msxsl:node-set($conditions_template_ids)"/> | |
<xsl:variable name="condition_activity_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.27</id> | |
<id>2.16.840.1.113883.10.20.22.4.3</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="condition_activity" select="msxsl:node-set($condition_activity_ids)"/> | |
<xsl:variable name="condition_observation_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.28</id> | |
<id>2.16.840.1.113883.10.20.22.4.4</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="condition_observation" | |
select="msxsl:node-set($condition_observation_ids)"/> | |
<xsl:call-template name="Conditions"> | |
<xsl:with-param name="conditions" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$conditions_templates/ids/id]/cda:entry/cda:act[not(./@nullFlavor or ./@negationInd = 'true') and ./cda:templateId/@root=$condition_activity/ids/id]/cda:entryRelationship/cda:observation[./cda:templateId/@root=$condition_observation/ids/id]"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$conditions_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
<xsl:variable name="appointment_template_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.10</id> | |
<id>2.16.840.1.113883.10.20.22.2.10</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="appointment_templates" | |
select="msxsl:node-set($appointment_template_ids)"/> | |
<xsl:variable name="appointment_encounter_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.25</id> | |
<id>2.16.840.1.113883.10.20.22.4.40</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="appointment_encounter" | |
select="msxsl:node-set($appointment_encounter_ids)"/> | |
<xsl:call-template name="Appointments"> | |
<xsl:with-param name="appointments" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$appointment_templates/ids/id]/cda:entry/cda:encounter[./cda:templateId/@root= $appointment_encounter/ids/id]"/> | |
<xsl:with-param name="narrative-block" | |
select="cda:component/cda:structuredBody/cda:component/cda:section[./cda:templateId/@root=$appointment_templates/ids/id]/cda:text" | |
/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="Payers"> | |
<xsl:param name="payers"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$payers"> | |
<xsl:variable name="payer" select="cda:act"/> | |
<xsl:variable name="sequence-number" select="cda:sequenceNumber/@value"/> | |
<xsl:if test="$payer"> | |
<thing> | |
<type-id>9366440c-ec81-4b89-b231-308a4c4d70ed</type-id> | |
<data-xml> | |
<payer> | |
<plan-name> | |
<xsl:choose> | |
<xsl:when | |
test="$payer/cda:performer/cda:assignedEntity/cda:representedOrganization/cda:name and
 $payer/cda:performer/cda:assignedEntity/cda:representedOrganization/cda:name != ''"> | |
<xsl:value-of | |
select="$payer/cda:performer/cda:assignedEntity/cda:representedOrganization/cda:name" | |
/> | |
</xsl:when> | |
<xsl:otherwise>Unknown</xsl:otherwise> | |
</xsl:choose> | |
</plan-name> | |
<xsl:if test="$payer/cda:code"> | |
<coverage-type> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$payer/cda:code"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</coverage-type> | |
</xsl:if> | |
<xsl:call-template name="OptionalIdElement"> | |
<xsl:with-param name="element-name" select="'carrier-id'"/> | |
<xsl:with-param name="id" | |
select="$payer/cda:performer[@typeCode='PRF']/cda:assignedEntity/cda:id" | |
/> | |
</xsl:call-template> | |
<xsl:call-template name="OptionalIdElement"> | |
<xsl:with-param name="element-name" select="'group-num'"/> | |
<xsl:with-param name="id" select="$payer/cda:id"/> | |
</xsl:call-template> | |
<xsl:variable name="payer_performer_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.19</id> | |
<id>2.16.840.1.113883.10.20.22.4.87</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="payer_performer" | |
select="msxsl:node-set($payer_performer_ids)"/> | |
<xsl:choose> | |
<xsl:when | |
test="$payer/cda:entryRelationship[@typeCode='REFR']/cda:act[./cda:templateId/@root = $payer_performer/ids/id]/cda:id"> | |
<xsl:call-template name="OptionalIdElement"> | |
<xsl:with-param name="element-name" select="'plan-code'"/> | |
<xsl:with-param name="id" | |
select="$payer/cda:entryRelationship[@typeCode='REFR']/cda:act[./cda:templateId/@root = $payer_performer/ids/id]/cda:id" | |
/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when | |
test="$payer/cda:entryRelationship[@typeCode='REFR']/cda:act[@classCode='ACT' and @moodCode='DEF']"> | |
<xsl:call-template name="OptionalIdElement"> | |
<xsl:with-param name="element-name" select="'plan-code'"/> | |
<xsl:with-param name="id" | |
select="$payer/cda:entryRelationship[@typeCode='REFR']/cda:act[@classCode='ACT' and @moodCode='DEF']/cda:id" | |
/> | |
</xsl:call-template> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:call-template name="OptionalIdElement"> | |
<xsl:with-param name="element-name" select="'subscriber-id'"/> | |
<xsl:with-param name="id" | |
select="$payer/cda:participant[@typeCode='HLD']/cda:participantRole/cda:id" | |
/> | |
</xsl:call-template> | |
<xsl:if | |
test="$payer/cda:participant[@typeCode='COV']/cda:participantRole/cda:code/@code"> | |
<person-code> | |
<xsl:value-of | |
select="$payer/cda:participant[@typeCode='COV']/cda:participantRole/cda:code/@code" | |
/> | |
</person-code> | |
</xsl:if> | |
<xsl:variable name="name"> | |
<xsl:call-template name="PN_To_String"> | |
<xsl:with-param name="pn" | |
select="$payer/cda:participant[@typeCode='HLD']/cda:participantRole/cda:playingEntity/cda:name" | |
/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:if test="$name != ''"> | |
<subscriber-name> | |
<xsl:value-of select="$name"/> | |
</subscriber-name> | |
</xsl:if> | |
<xsl:if test="$sequence-number and $sequence-number = '1'"> | |
<is-primary>true</is-primary> | |
</xsl:if> | |
<xsl:if | |
test="$payer/cda:participant[@typeCode='COV']/cda:time/cda:high[not(@nullFlavor)]"> | |
<expiration-date> | |
<xsl:call-template name="DateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="$payer/cda:participant[@typeCode='COV']/cda:time/cda:high/@value" | |
/> | |
</xsl:call-template> | |
</expiration-date> | |
</xsl:if> | |
<xsl:if | |
test="$payer/cda:performer[@typeCode='PRF']/cda:assignedEntity and
 $payer/cda:performer[@typeCode='PRF']/cda:assignedEntity != ''"> | |
<contact> | |
<xsl:call-template name="ContactFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="$payer/cda:performer[@typeCode='PRF']/cda:assignedEntity" | |
/> | |
</xsl:call-template> | |
</contact> | |
</xsl:if> | |
</payer> | |
<xsl:for-each select="$payer/../.."> | |
<xsl:call-template name="AddCommonSection"/> | |
</xsl:for-each> | |
</data-xml> | |
</thing> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="OptionalIdElement"> | |
<xsl:param name="element-name"/> | |
<xsl:param name="id"/> | |
<xsl:choose> | |
<xsl:when test="$id/@extension"> | |
<xsl:element name="{$element-name}"> | |
<xsl:value-of select="$id/@extension"/> | |
</xsl:element> | |
</xsl:when> | |
<xsl:when test="$id/@root"> | |
<xsl:element name="{$element-name}"> | |
<xsl:value-of select="$id/@root"/> | |
</xsl:element> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="AdvanceDirectives"> | |
<xsl:param name="directives"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$directives"> | |
<thing> | |
<type-id>822a5e5a-14f1-4d06-b92f-8f3f1b05218f</type-id> | |
<data-xml> | |
<directive> | |
<start-date> | |
<xsl:choose> | |
<xsl:when test="cda:effectiveTime/cda:low/@value"> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="cda:effectiveTime/@value"> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<descriptive>Unknown</descriptive> | |
</xsl:otherwise> | |
</xsl:choose> | |
</start-date> | |
<xsl:choose> | |
<xsl:when test="cda:effectiveTime/cda:high/@value"> | |
<stop-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</stop-date> | |
</xsl:when> | |
<xsl:otherwise> | |
<stop-date> | |
<descriptive>Unknown</descriptive> | |
</stop-date> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:variable name="descriptionValue"> | |
<xsl:call-template name="StringFromAny"> | |
<xsl:with-param name="value" select="cda:value"/> | |
<xsl:with-param name="reference-text" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="descriptionTranslation"> | |
<xsl:call-template name="StringFromAny"> | |
<xsl:with-param name="value" select="cda:value/cda:translation"/> | |
<xsl:with-param name="reference-text" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="descriptionText"> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="cda:text"/> | |
<xsl:with-param name="reference-text" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="$descriptionValue != ''"> | |
<description> | |
<xsl:value-of select="$descriptionValue"/> | |
</description> | |
</xsl:when> | |
<xsl:when test="$descriptionTranslation != ''"> | |
<description> | |
<xsl:value-of select="$descriptionTranslation"/> | |
</description> | |
</xsl:when> | |
<xsl:when test="$descriptionText != ''"> | |
<description> | |
<xsl:value-of select="$descriptionText"/> | |
</description> | |
</xsl:when> | |
</xsl:choose> | |
</directive> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:variable name="fh_observation_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.22</id> | |
<id>2.16.840.1.113883.10.20.22.4.46</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="family_history_observation" select="msxsl:node-set($fh_observation_ids)"/> | |
<xsl:template name="FamilyHistory"> | |
<xsl:param name="histories"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:variable name="fh_organizer_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.23</id> | |
<id>2.16.840.1.113883.10.20.22.4.45</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="family_history_organizer" select="msxsl:node-set($fh_organizer_ids)"/> | |
<xsl:for-each select="$histories"> | |
<xsl:call-template name="Organizer-familyhistory_To_family-history"> | |
<xsl:with-param name="history" | |
select="cda:organizer[./cda:templateId/@root = $family_history_organizer/ids/id]"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
<xsl:if | |
test="cda:observation[./cda:templateId/@root = $family_history_observation/ids/id]"> | |
<thing> | |
<type-id>4a04fcc8-19c1-4d59-a8c7-2031a03f21de</type-id> | |
<data-xml> | |
<family-history> | |
<xsl:call-template name="Observation-familyhistory_To_family-history"> | |
<xsl:with-param name="history" | |
select="cda:observation[./cda:templateId/@root = $family_history_observation/ids/id]"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</family-history> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Organizer-familyhistory_To_family-history"> | |
<xsl:param name="history"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$history"> | |
<thing> | |
<type-id>4a04fcc8-19c1-4d59-a8c7-2031a03f21de</type-id> | |
<data-xml> | |
<family-history> | |
<xsl:variable name="subject" select="cda:subject/cda:relatedSubject"/> | |
<xsl:variable name="conditions" | |
select="cda:component/cda:observation[./cda:templateId/@root = $family_history_observation/ids/id]"/> | |
<xsl:variable name="fm_cause_of_death_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.42</id> | |
<id>2.16.840.1.113883.10.20.22.4.47</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="fm_cause_of_death" | |
select="msxsl:node-set($fm_cause_of_death_ids)"/> | |
<xsl:variable name="cause-of-death" | |
select="cda:component/cda:observation[./cda:templateId/@root = $fm_cause_of_death/ids/id]"/> | |
<xsl:call-template name="Observation-familyhistory_To_family-history"> | |
<xsl:with-param name="history" select="$conditions"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
<xsl:if test="$cause-of-death"> | |
<xsl:call-template name="Observation-familyhistory_To_family-history"> | |
<xsl:with-param name="history" select="$cause-of-death"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="resolution" select="'Cause of death'"/> | |
</xsl:call-template> | |
</xsl:if> | |
<xsl:if test="$subject"> | |
<relative> | |
<xsl:choose> | |
<xsl:when test="$subject/cda:code"> | |
<relationship> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="$subject/cda:code"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</relationship> | |
</xsl:when> | |
<xsl:otherwise> | |
<relationship> | |
<text>Unknown</text> | |
</relationship> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:if test="$subject/cda:subject/cda:birthTime/@value"> | |
<date-of-birth> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="$subject/cda:subject/cda:birthTime/@value"/> | |
</xsl:call-template> | |
</date-of-birth> | |
</xsl:if> | |
<xsl:if xmlns:sdtc="urn:hl7-org:sdtc" | |
test="$subject/cda:subject/sdtc:deceasedTime/@value"> | |
<date-of-death> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="$subject/cda:subject/sdtc:deceasedTime/@value" | |
/> | |
</xsl:call-template> | |
</date-of-death> | |
</xsl:if> | |
</relative> | |
</xsl:if> | |
</family-history> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Observation-familyhistory_To_family-history"> | |
<xsl:param name="history"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:param name="resolution"/> | |
<xsl:for-each select="$history"> | |
<condition> | |
<name><xsl:choose><xsl:when | |
test="(cda:value/@displayName or cda:value/cda:originalText or cda:value/@code) and not(cda:value/@nullFlavor)" | |
><xsl:call-template name="CodableValueFromAny"><xsl:with-param | |
name="value" select="cda:value"/><xsl:with-param | |
name="reference-text" select="$narrative-block" | |
/></xsl:call-template></xsl:when><xsl:when test="cda:text" | |
><text><xsl:call-template name="StringFromED"><xsl:with-param | |
name="value" select="cda:text"/><xsl:with-param | |
name="reference-text" select="$narrative-block" | |
/></xsl:call-template></text></xsl:when><xsl:when | |
test="cda:value/cda:translation"><xsl:call-template | |
name="CodableValueFromAny"><xsl:with-param name="value" | |
select="cda:value/cda:translation"/><xsl:with-param | |
name="reference-text" select="$narrative-block"/><xsl:with-param | |
name="type" select="cda:value/@xsi:type" | |
/></xsl:call-template></xsl:when><xsl:otherwise><text>Unknown</text></xsl:otherwise></xsl:choose></name> | |
<xsl:choose> | |
<xsl:when test="cda:effectiveTime/cda:low/@value"> | |
<onset-date> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</onset-date> | |
</xsl:when> | |
<xsl:when test="cda:effectiveTime/@value"> | |
<onset-date> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="cda:effectiveTime/@value" | |
/> | |
</xsl:call-template> | |
</onset-date> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:if test="cda:effectiveTime/cda:high/@value"> | |
<resolution-date> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</resolution-date> | |
</xsl:if> | |
<xsl:if test="$resolution and $resolution != ''"> | |
<resolution> | |
<xsl:value-of select="$resolution"/> | |
</resolution> | |
</xsl:if> | |
</condition> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Medications"> | |
<xsl:param name="medications"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$medications"> | |
<xsl:variable name="try"> | |
<xsl:variable name="medication-code" | |
select="cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"/> | |
<xsl:variable name="brand-name" | |
select="cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:name"/> | |
<thing> | |
<type-id>30cafccc-047d-4288-94ef-643571f7919d</type-id> | |
<data-xml> | |
<medication> | |
<xsl:choose> | |
<xsl:when | |
test="$brand-name and $brand-name != '' and not($medication-code/@displayName)"> | |
<name><text><xsl:value-of select="$brand-name" | |
/></text><xsl:call-template name="CodedValueFromCCDCode" | |
><xsl:with-param name="code-value" | |
select="$medication-code" | |
/></xsl:call-template></name> | |
<xsl:if | |
test="$medication-code and (
 ($medication-code/cda:originalText/cda:reference/@value and $narrative-block) or
 $medication-code/cda:originalText/text() != '' or
 translate(normalize-space($medication-code/text()), ' ', '') != '')"> | |
<generic-name> | |
<text> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" | |
select="$medication-code/cda:originalText"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</text> | |
</generic-name> | |
</xsl:if> | |
</xsl:when> | |
<xsl:when test="$medication-code"> | |
<name><xsl:call-template name="CodableValueFromCCDCode" | |
><xsl:with-param name="code-value" | |
select="$medication-code"/><xsl:with-param | |
name="reference-text" select="$narrative-block" | |
/></xsl:call-template></name> | |
<xsl:if | |
test="$medication-code and (
 ($medication-code/cda:originalText/cda:reference/@value and $narrative-block) or
 $medication-code/cda:originalText/text() != '' or
 translate(normalize-space($medication-code/text()), ' ', '') != '')"> | |
<generic-name> | |
<text> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" | |
select="$medication-code/cda:originalText"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</text> | |
</generic-name> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:if test="cda:doseQuantity/@value or cda:maxDoseQuantity/@value"> | |
<dose> | |
<xsl:choose> | |
<xsl:when test="cda:doseQuantity/@value"> | |
<xsl:call-template name="PQValueToGeneralMeasurement"> | |
<xsl:with-param name="value" | |
select="cda:doseQuantity"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="cda:maxDoseQuantity/@value"> | |
<xsl:call-template name="PQValueToGeneralMeasurement"> | |
<xsl:with-param name="value" | |
select="cda:maxDoseQuantity"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:when> | |
</xsl:choose> | |
</dose> | |
</xsl:if> | |
<xsl:if test="cda:effectiveTime[./@xsi:type = 'PIVL_TS']"> | |
<frequency> | |
<xsl:call-template name="PIVL_TS-to-general-measurement"> | |
<xsl:with-param name="effectiveTime" | |
select="cda:effectiveTime[./@xsi:type = 'PIVL_TS'][1]"/> | |
</xsl:call-template> | |
</frequency> | |
</xsl:if> | |
<xsl:if test="cda:routeCode"> | |
<route> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:routeCode"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</route> | |
</xsl:if> | |
<xsl:variable name="medication_indication_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.28</id> | |
<id>2.16.840.1.113883.10.20.22.4.19</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="medication_indication" | |
select="msxsl:node-set($medication_indication_ids)"/> | |
<xsl:if | |
test="cda:entryRelationship[./@typeCode='RSON']/cda:observation[./cda:templateId/@root = $medication_indication/ids/id]"> | |
<indication> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="cda:entryRelationship[./@typeCode='RSON']/cda:observation[./cda:templateId/@root = $medication_indication/ids/id]/cda:value"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</indication> | |
</xsl:if> | |
<xsl:if test="cda:effectiveTime/cda:low/@value"> | |
<date-started> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</date-started> | |
</xsl:if> | |
<xsl:if test="cda:statusCode/@code = 'completed'"> | |
<xsl:if test="cda:effectiveTime/cda:high/@value"> | |
<date-discontinued> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</date-discontinued> | |
</xsl:if> | |
</xsl:if> | |
<xsl:variable name="medication_instruction_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.49</id> | |
<id>2.16.840.1.113883.10.20.22.4.20</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="medication_instruction" | |
select="msxsl:node-set($medication_instruction_ids)"/> | |
<xsl:variable name="instructions" | |
select="cda:entryRelationship[./@typeCode = 'SUBJ']/cda:act[./cda:templateId/@root = $medication_instruction/ids/id]"/> | |
<xsl:variable name="medication_supply_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.34</id> | |
<id>2.16.840.1.113883.10.20.22.4.17</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="medication_supply" | |
select="msxsl:node-set($medication_supply_ids)"/> | |
<xsl:variable name="supply" | |
select="cda:entryRelationshp[./@typeCode = 'REFR']/cda:supply[./@moodCode = 'INT' and ./cda:templateId/@root = $medication_supply/ids/id]"/> | |
<xsl:if test="$supply or $instructions"> | |
<prescription> | |
<prescribed-by> | |
<xsl:choose> | |
<xsl:when test="$supply/cda:author"> | |
<xsl:call-template | |
name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="$supply/cda:author"/> | |
</xsl:call-template> | |
<date-prescribed> | |
<xsl:call-template | |
name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$supply/cda:author/cda:time"/> | |
</xsl:call-template> | |
</date-prescribed> | |
</xsl:when> | |
<xsl:otherwise> | |
<name><full>Unknown</full></name> | |
</xsl:otherwise> | |
</xsl:choose> | |
</prescribed-by> | |
<xsl:if test="$supply/cda:quantity"> | |
<amount-prescribed> | |
<xsl:call-template name="PQValueToGeneralMeasurement"> | |
<xsl:with-param name="value" | |
select="$supply/cda:quantity"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</amount-prescribed> | |
</xsl:if> | |
<xsl:choose> | |
<xsl:when test="$instructions/cda:text"> | |
<instructions> | |
<text> | |
<xsl:value-of select="$instructions/cda:text"/> | |
</text> | |
</instructions> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:variable name="instructionId" | |
select="substring($instructions/cda:text/cda:reference/@value, 2)"/> | |
<xsl:if test="$instructionId"> | |
<xsl:if | |
test="$narrative-block//cda:td/@ID = $instructionId or
 ($narrative-block//cda:content/@ID = $instructionId and
 $narrative-block//cda:content/@revised != 'delete')"> | |
<instructions> | |
<text> | |
<xsl:call-template name="GetFromTextById"> | |
<xsl:with-param name="text" | |
select="$narrative-block"/> | |
<xsl:with-param name="id" select="$instructionId" | |
/> | |
</xsl:call-template> | |
</text> | |
</instructions> | |
</xsl:if> | |
</xsl:if> | |
</xsl:otherwise> | |
</xsl:choose> | |
</prescription> | |
</xsl:if> | |
</medication> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Immunizations"> | |
<xsl:param name="immunizations"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$immunizations"> | |
<thing> | |
<type-id>cd3587b5-b6e1-4565-ab3b-1c3ad45eb04f</type-id> | |
<data-xml> | |
<immunization> | |
<xsl:if | |
test="cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"> | |
<name><xsl:call-template name="CodableValueFromCCDCode"><xsl:with-param | |
name="code-value" | |
select="cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code" | |
/><xsl:with-param name="reference-text" | |
select="$narrative-block"/></xsl:call-template></name> | |
</xsl:if> | |
<xsl:if test="cda:effectiveTime"> | |
<administration-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="cda:effectiveTime" | |
/> | |
</xsl:call-template> | |
</administration-date> | |
</xsl:if> | |
<xsl:if test="cda:performer/cda:assignedEntity"> | |
<administrator> | |
<xsl:call-template name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="cda:performer/cda:assignedEntity"/> | |
</xsl:call-template> | |
</administrator> | |
</xsl:if> | |
<xsl:if | |
test="cda:consumable/cda:manufacturedProduct/cda:manufacturerOrganization/cda:name"> | |
<manufacturer> | |
<text> | |
<xsl:value-of | |
select="cda:consumable/cda:manufacturedProduct/cda:manufacturerOrganization/cda:name" | |
/> | |
</text> | |
</manufacturer> | |
</xsl:if> | |
<xsl:if | |
test="cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:lotNumberText"> | |
<lot> | |
<xsl:value-of | |
select="cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:lotNumberText" | |
/> | |
</lot> | |
</xsl:if> | |
<xsl:if test="cda:routeCode"> | |
<route> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:routeCode"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</route> | |
</xsl:if> | |
<xsl:choose> | |
<xsl:when test="@moodCode = 'EVN' and cda:repeatNumber"> | |
<sequence> | |
<xsl:value-of select="cda:repeatNumber"/> | |
</sequence> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:variable name="sequence" | |
select="cda:entryRelationship[./@typeCode = 'SUBJ']/cda:observation[./cda:templateId/@root = '2.16.840.1.113883.10.20.1.46']/cda:value/@value"/> | |
<xsl:if test="$sequence and $sequence != ''"> | |
<sequence> | |
<xsl:value-of select="$sequence"/> | |
</sequence> | |
</xsl:if> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:if test="cda:approachSiteCode"> | |
<anatomic-surface> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:approachSiteCode"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</anatomic-surface> | |
</xsl:if> | |
<xsl:variable name="immunization_adverse_event_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.54</id> | |
<id>2.16.840.1.113883.10.20.22.4.9</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="immunization_adverse_event" | |
select="msxsl:node-set($immunization_adverse_event_ids)"/> | |
<xsl:variable name="adverse-event" | |
select="cda:entryRelationship[./cda:typeCode = 'CAUS']/cda:observation[./cda:templateId/@root = $immunization_adverse_event/ids/id]/cda:value"/> | |
<xsl:if test="$adverse-event"> | |
<adverse-event> | |
<xsl:call-template name="StringFromAny"> | |
<xsl:with-param name="value" select="$adverse-event"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</adverse-event> | |
</xsl:if> | |
</immunization> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:variable name="vital_signs_observation_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.31</id> | |
<id>2.16.840.1.113883.10.20.22.4.27</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="vital_signs_observation" | |
select="msxsl:node-set($vital_signs_observation_ids)"/> | |
<xsl:template name="VitalSigns"> | |
<xsl:param name="vital-signs"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:variable name="vs_organizer_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.35</id> | |
<id>2.16.840.1.113883.10.20.22.4.26</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="vital_signs_organizer" select="msxsl:node-set($vs_organizer_ids)"/> | |
<xsl:for-each select="$vital-signs"> | |
<xsl:variable name="organizers" | |
select="cda:organizer[./cda:templateId/@root = $vital_signs_organizer/ids/id]"/> | |
<xsl:call-template name="Organizers_to_Things"> | |
<xsl:with-param name="organizers" select="$organizers"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowVitalSignFallback" select="true()"/> | |
<xsl:with-param name="allowed-observation-ids" | |
select="$vital_signs_observation/ids/id"/> | |
</xsl:call-template> | |
<xsl:if test="cda:observation[./cda:templateId/@root = $vital_signs_observation/ids/id]"> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:observation[./cda:templateId/@root = $vital_signs_observation/ids/id]"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowVitalSignFallback" select="true()"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Organizers_to_Things"> | |
<xsl:param name="organizers"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:param name="allowVitalSignFallback" select="false()"/> | |
<xsl:param name="allowed-observation-ids"/> | |
<xsl:for-each select="$organizers"> | |
<xsl:variable name="defaultEffectiveTime" select="cda:effectiveTime"/> | |
<xsl:variable name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:variable name="bp-systolic-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-pressure-systolic"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bp-systolic" | |
select="msxsl:node-set($bp-systolic-nodes)[1]/cda:observation"/> | |
<xsl:variable name="bp-diastolic-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-pressure-diastolic"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bp-diastolic" | |
select="msxsl:node-set($bp-diastolic-nodes)[1]/cda:observation"/> | |
<xsl:variable name="bp-pulse-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-pressure-pulse"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bp-pulse" | |
select="msxsl:node-set($bp-pulse-nodes)[1]/cda:observation"/> | |
<xsl:variable name="ldl"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/cholesterol-ldl"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="cholesterol-ldl" select="msxsl:node-set($ldl)[1]/cda:observation"/> | |
<xsl:variable name="hdl"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/cholesterol-hdl"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="cholesterol-hdl" select="msxsl:node-set($hdl)[1]/cda:observation"/> | |
<xsl:variable name="total"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/cholesterol-total"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="cholesterol-total" | |
select="msxsl:node-set($total)[1]/cda:observation"/> | |
<xsl:variable name="pef-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/peak-flow-pef"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="pef" select="msxsl:node-set($pef-nodes)[1]/cda:observation"/> | |
<xsl:variable name="fev1-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/peak-flow-fev1"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="fev1" select="msxsl:node-set($fev1-nodes)[1]/cda:observation"/> | |
<xsl:variable name="fev6-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/peak-flow-fev6"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="fev6" select="msxsl:node-set($fev6-nodes)[1]/cda:observation"/> | |
<xsl:choose> | |
<xsl:when test="$defaultEffectiveTime and $bp-systolic and $bp-diastolic"> | |
<xsl:variable name="thingXml"> | |
<xsl:call-template name="Organizer_To_blood-pressure"> | |
<xsl:with-param name="organizer" select="."/> | |
<xsl:with-param name="effectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowed-observation-ids" | |
select="$allowed-observation-ids"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="things" select="msxsl:node-set($thingXml)"/> | |
<xsl:choose> | |
<xsl:when test="$things"> | |
<xsl:copy-of select="$things"/> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:with-param name="defaultEffectiveTime" | |
select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="ignore-items" | |
select="$bp-systolic | $bp-diastolic | $bp-pulse"/> | |
<xsl:with-param name="allowVitalSignFallback" | |
select="$allowVitalSignFallback"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:with-param name="defaultEffectiveTime" | |
select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowVitalSignFallback" | |
select="$allowVitalSignFallback"/> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:when | |
test="$defaultEffectiveTime and ($cholesterol-ldl or $cholesterol-hdl or $cholesterol-total)"> | |
<xsl:variable name="thingXml"> | |
<xsl:call-template name="Organizer_To_cholesterol-profile"> | |
<xsl:with-param name="organizer" select="."/> | |
<xsl:with-param name="effectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowed-observation-ids" | |
select="$allowed-observation-ids"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="things" select="msxsl:node-set($thingXml)"/> | |
<xsl:choose> | |
<xsl:when test="$things"> | |
<xsl:copy-of select="$things"/> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:with-param name="defaultEffectiveTime" | |
select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="ignore-items" | |
select="$cholesterol-ldl | $cholesterol-hdl | $cholesterol-total"/> | |
<xsl:with-param name="allowVitalSignFallback" | |
select="$allowVitalSignFallback"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:with-param name="defaultEffectiveTime" | |
select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowVitalSignFallback" | |
select="$allowVitalSignFallback"/> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:when test="$defaultEffectiveTime and ($pef or $fev1 or $fev6)"> | |
<xsl:variable name="thingXml"> | |
<xsl:call-template name="Organizer_To_peak-flow"> | |
<xsl:with-param name="organizer" select="."/> | |
<xsl:with-param name="effectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowed-observation-ids" | |
select="$allowed-observation-ids"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="things" select="msxsl:node-set($thingXml)"/> | |
<xsl:choose> | |
<xsl:when test="$things"> | |
<xsl:copy-of select="$things"/> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:with-param name="defaultEffectiveTime" | |
select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="ignore-items" select="$pef | $fev1 | $fev6"/> | |
<xsl:with-param name="allowVitalSignFallback" | |
select="$allowVitalSignFallback"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:with-param name="defaultEffectiveTime" | |
select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowVitalSignFallback" | |
select="$allowVitalSignFallback"/> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowVitalSignFallback" | |
select="$allowVitalSignFallback"/> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Organizer_To_blood-pressure"> | |
<xsl:param name="organizer"/> | |
<xsl:param name="effectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:param name="allowed-observation-ids"/> | |
<xsl:variable name="observations" | |
select="$organizer/cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:variable name="bp-systolic-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-pressure-systolic"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bp-systolic" | |
select="msxsl:node-set($bp-systolic-nodes)[1]/cda:observation"/> | |
<xsl:variable name="bp-diastolic-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-pressure-diastolic"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bp-diastolic" | |
select="msxsl:node-set($bp-diastolic-nodes)[1]/cda:observation"/> | |
<xsl:variable name="bp-pulse-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-pressure-pulse"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bp-pulse" select="msxsl:node-set($bp-pulse-nodes)[1]/cda:observation"/> | |
<xsl:variable name="try"> | |
<thing> | |
<type-id>ca3c57f4-f4c1-4e15-be67-0a3caf5414ed</type-id> | |
<data-xml> | |
<blood-pressure> | |
<when> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="$effectiveTime"/> | |
</xsl:call-template> | |
</when> | |
<xsl:choose> | |
<xsl:when | |
test="$bp-systolic/cda:value/@xsi:type = 'PQ' and
 number($bp-systolic/cda:value/@value) > 0 and
 h:lc($bp-systolic/cda:value/@unit) = h:lc($v_measure/millimeters-mercury/import) or h:lc($bp-systolic/cda:value/@unit) = h:lc($v_measure/millimeters-mercury/ucum)"> | |
<systolic> | |
<xsl:call-template name="ToInteger"> | |
<xsl:with-param name="value" | |
select="$bp-systolic/cda:value/@value"/> | |
</xsl:call-template> | |
</systolic> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:choose> | |
<xsl:when | |
test="$bp-diastolic/cda:value/@xsi:type = 'PQ' and
 number($bp-diastolic/cda:value/@value) > 0 and
 h:lc($bp-diastolic/cda:value/@unit) = h:lc($v_measure/millimeters-mercury/import) or h:lc($bp-diastolic/cda:value/@unit) = h:lc($v_measure/millimeters-mercury/ucum)"> | |
<diastolic> | |
<xsl:call-template name="ToInteger"> | |
<xsl:with-param name="value" | |
select="$bp-diastolic/cda:value/@value"/> | |
</xsl:call-template> | |
</diastolic> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:if | |
test="$bp-pulse/cda:value/@xsi:type = 'PQ' and
 number($bp-pulse/cda:value/@value) > 0 and
 h:lc($bp-pulse/cda:value/@unit) = h:lc($v_measure/per-minute/import) or h:lc($bp-pulse/cda:value/@unit) = h:lc($v_measure/per-minute/ucum)"> | |
<pulse> | |
<xsl:value-of select="$bp-pulse/cda:value/@value"/> | |
</pulse> | |
</xsl:if> | |
</blood-pressure> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="Organizer_To_cholesterol-profile"> | |
<xsl:param name="organizer"/> | |
<xsl:param name="effectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:param name="allowed-observation-ids"/> | |
<xsl:variable name="observations" | |
select="$organizer/cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:variable name="ldl"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/cholesterol-ldl"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="cholesterol-ldl" select="msxsl:node-set($ldl)[1]/cda:observation"/> | |
<xsl:variable name="hdl"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/cholesterol-hdl"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="cholesterol-hdl" select="msxsl:node-set($hdl)[1]/cda:observation"/> | |
<xsl:variable name="total"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/cholesterol-total"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="cholesterol-total" select="msxsl:node-set($total)[1]/cda:observation"/> | |
<xsl:variable name="triglycerides"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/cholesterol-triglycerides"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="cholesterol-triglycerides" | |
select="msxsl:node-set($triglycerides)[1]/cda:observation"/> | |
<xsl:variable name="try"> | |
<thing> | |
<type-id>98F76958-E34F-459B-A760-83C1699ADD38</type-id> | |
<data-xml> | |
<cholesterol-profile> | |
<when> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="$effectiveTime"/> | |
</xsl:call-template> | |
</when> | |
<xsl:if | |
test="$cholesterol-ldl/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-ldl/cda:value/@value) > 0 and
 h:lc($cholesterol-ldl/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/import) or h:lc($cholesterol-ldl/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/ucum)"> | |
<ldl> | |
<xsl:call-template name="CholesterolFromMgDL"> | |
<xsl:with-param name="value" | |
select="$cholesterol-ldl/cda:value/@value"/> | |
<xsl:with-param name="constant" select="38.66976"/> | |
</xsl:call-template> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$cholesterol-ldl/cda:value"/> | |
</xsl:call-template> | |
</ldl> | |
</xsl:if> | |
<xsl:if | |
test="$cholesterol-hdl/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-hdl/cda:value/@value) > 0 and
 h:lc($cholesterol-hdl/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/import) or h:lc($cholesterol-hdl/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/ucum)"> | |
<hdl> | |
<xsl:call-template name="CholesterolFromMgDL"> | |
<xsl:with-param name="value" | |
select="$cholesterol-hdl/cda:value/@value"/> | |
<xsl:with-param name="constant" select="38.66976"/> | |
</xsl:call-template> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$cholesterol-hdl/cda:value"/> | |
</xsl:call-template> | |
</hdl> | |
</xsl:if> | |
<xsl:if | |
test="$cholesterol-total/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-total/cda:value/@value) > 0 and
 h:lc($cholesterol-total/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/import) or h:lc($cholesterol-total/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/ucum)"> | |
<total-cholesterol> | |
<xsl:call-template name="CholesterolFromMgDL"> | |
<xsl:with-param name="value" | |
select="$cholesterol-total/cda:value/@value"/> | |
<xsl:with-param name="constant" select="38.66976"/> | |
</xsl:call-template> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$cholesterol-total/cda:value" | |
/> | |
</xsl:call-template> | |
</total-cholesterol> | |
</xsl:if> | |
<xsl:if | |
test="$cholesterol-triglycerides/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-triglycerides/cda:value/@value) > 0 and
 h:lc($cholesterol-triglycerides/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/import) or h:lc($cholesterol-triglycerides/cda:value/@unit) = h:lc($v_measure/milligrams-per-deciliter/ucum)"> | |
<triglyceride> | |
<xsl:call-template name="CholesterolFromMgDL"> | |
<xsl:with-param name="value" | |
select="$cholesterol-triglycerides/cda:value/@value"/> | |
<xsl:with-param name="constant" select="88.57396"/> | |
</xsl:call-template> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" | |
select="$cholesterol-triglycerides/cda:value"/> | |
</xsl:call-template> | |
</triglyceride> | |
</xsl:if> | |
<xsl:if | |
test="$cholesterol-ldl/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-ldl/cda:value/@value) > 0 and
 h:lc($cholesterol-ldl/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/import) or h:lc($cholesterol-ldl/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/ucum)"> | |
<ldl> | |
<xsl:element name="mmolPerL"> | |
<xsl:value-of select="$cholesterol-ldl/cda:value/@value"/> | |
</xsl:element> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$cholesterol-ldl/cda:value"/> | |
</xsl:call-template> | |
</ldl> | |
</xsl:if> | |
<xsl:if | |
test="$cholesterol-hdl/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-hdl/cda:value/@value) > 0 and
 h:lc($cholesterol-hdl/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/import) or h:lc($cholesterol-hdl/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/ucum)"> | |
<hdl> | |
<xsl:element name="mmolPerL"> | |
<xsl:value-of select="$cholesterol-hdl/cda:value/@value"/> | |
</xsl:element> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$cholesterol-hdl/cda:value"/> | |
</xsl:call-template> | |
</hdl> | |
</xsl:if> | |
<xsl:if | |
test="$cholesterol-total/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-total/cda:value/@value) > 0 and
 h:lc($cholesterol-total/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/import) or h:lc($cholesterol-total/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/ucum)"> | |
<total-cholesterol> | |
<xsl:element name="mmolPerL"> | |
<xsl:value-of select="$cholesterol-total/cda:value/@value"/> | |
</xsl:element> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$cholesterol-total/cda:value" | |
/> | |
</xsl:call-template> | |
</total-cholesterol> | |
</xsl:if> | |
<xsl:if | |
test="$cholesterol-triglycerides/cda:value/@xsi:type = 'PQ' and
 number($cholesterol-triglycerides/cda:value/@value) > 0 and
 h:lc($cholesterol-triglycerides/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/import) or h:lc($cholesterol-triglycerides/cda:value/@unit) = h:lc($v_measure/millimoles-per-liter/ucum)"> | |
<triglyceride> | |
<xsl:element name="mmolPerL"> | |
<xsl:value-of | |
select="$cholesterol-triglycerides/cda:value/@value"/> | |
</xsl:element> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" | |
select="$cholesterol-triglycerides/cda:value"/> | |
</xsl:call-template> | |
</triglyceride> | |
</xsl:if> | |
</cholesterol-profile> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="CholesterolFromMgDL"> | |
<xsl:param name="value"/> | |
<xsl:param name="constant"/> | |
<xsl:element name="mmolPerL"> | |
<xsl:value-of select="round(($value div $constant) * 1000) div 1000"/> | |
</xsl:element> | |
</xsl:template> | |
<xsl:template name="Organizer_To_peak-flow"> | |
<xsl:param name="organizer"/> | |
<xsl:param name="effectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:param name="allowed-observation-ids"/> | |
<xsl:variable name="observations" | |
select="$organizer/cda:component/cda:observation[./cda:templateId/@root = $allowed-observation-ids]"/> | |
<xsl:variable name="pef-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/peak-flow-pef"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="pef" select="msxsl:node-set($pef-nodes)[1]/cda:observation"/> | |
<xsl:variable name="fev1-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/peak-flow-fev1"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="fev1" select="msxsl:node-set($fev1-nodes)[1]/cda:observation"/> | |
<xsl:variable name="fev6-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/peak-flow-fev6"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="fev6" select="msxsl:node-set($fev6-nodes)[1]/cda:observation"/> | |
<xsl:variable name="try"> | |
<thing> | |
<type-id>5d8419af-90f0-4875-a370-0f881c18f6b3</type-id> | |
<data-xml> | |
<peak-flow> | |
<when> | |
<xsl:call-template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="$effectiveTime"/> | |
</xsl:call-template> | |
</when> | |
<xsl:if | |
test="$pef/cda:value/@xsi:type = 'PQ' and
 number($pef/cda:value/@value) > 0 and
 h:lc($pef/cda:value/@unit) = h:lc($v_measure/liters-per-second/import) or h:lc($pef/cda:value/@unit) = h:lc($v_measure/liters-per-second/ucum)"> | |
<pef> | |
<liters-per-second> | |
<xsl:value-of select="$pef/cda:value/@value"/> | |
</liters-per-second> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$pef/cda:value"/> | |
</xsl:call-template> | |
</pef> | |
</xsl:if> | |
<xsl:if | |
test="$fev1/cda:value/@xsi:type = 'PQ' and
 number($fev1/cda:value/@value) > 0 and
 h:lc($fev1/cda:value/@unit) = h:lc($v_measure/liters/import) or h:lc($fev1/cda:value/@unit) = h:lc($v_measure/liters/ucum)"> | |
<fev1> | |
<liters> | |
<xsl:value-of select="$fev1/cda:value/@value"/> | |
</liters> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$fev1/cda:value"/> | |
</xsl:call-template> | |
</fev1> | |
</xsl:if> | |
<xsl:if | |
test="$fev6/cda:value/@xsi:type = 'PQ' and
 number($fev6/cda:value/@value) > 0 and
 h:lc($fev6/cda:value/@unit) = h:lc($v_measure/liters/import) or h:lc($fev6/cda:value/@unit) = h:lc($v_measure/liters/ucum)"> | |
<fev6> | |
<liters> | |
<xsl:value-of select="$fev6/cda:value/@value"/> | |
</liters> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$fev6/cda:value"/> | |
</xsl:call-template> | |
</fev6> | |
</xsl:if> | |
</peak-flow> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="ObservationResults_To_Things"> | |
<xsl:param name="observations"/> | |
<xsl:param name="defaultEffectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:param name="ignore-items"/> | |
<xsl:param name="allowVitalSignFallback"/> | |
<xsl:variable name="thingXml"> | |
<xsl:call-template name="ObservationResults_To_typed-things"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="things" select="msxsl:node-set($thingXml)"/> | |
<xsl:call-template name="CopyNodeset"> | |
<xsl:with-param name="node" select="$things"/> | |
<xsl:with-param name="filter">done</xsl:with-param> | |
</xsl:call-template> | |
<xsl:choose> | |
<xsl:when test="count($things/done) = 0 and $allowVitalSignFallback = true()"> | |
<xsl:call-template name="ObservationResults_To_vital-signs"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="ignore-items" select="$ignore-items"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:variable name="doneList" select="$things/done/text()"/> | |
<xsl:variable name="remainingList" | |
select="$observations[not(cda:id/@root = $doneList)]"/> | |
<xsl:if test="$remainingList and $allowVitalSignFallback = true()"> | |
<xsl:call-template name="ObservationResults_To_vital-signs"> | |
<xsl:with-param name="observations" select="$remainingList"/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="ignore-items" select="$ignore-items"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="ObservationResults_To_typed-things"> | |
<xsl:param name="observations"/> | |
<xsl:param name="defaultEffectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:variable name="weight-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/weight"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="weight-observations" | |
select="msxsl:node-set($weight-nodes)[1]/cda:observation"/> | |
<xsl:for-each select="$weight-observations"> | |
<xsl:call-template name="Observation_To_Weight"> | |
<xsl:with-param name="weight" select="."/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
<xsl:variable name="height-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/height"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="height-observations" | |
select="msxsl:node-set($height-nodes)[1]/cda:observation"/> | |
<xsl:for-each select="$height-observations"> | |
<xsl:call-template name="Observation_To_Height"> | |
<xsl:with-param name="height" select="."/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
<xsl:variable name="bloodglucose-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-glucose"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bloodglucose-observations" | |
select="msxsl:node-set($bloodglucose-nodes)[1]/cda:observation"/> | |
<xsl:for-each select="$bloodglucose-observations"> | |
<xsl:call-template name="Observation_To_BloodGlucose"> | |
<xsl:with-param name="bloodglucose" select="."/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
<xsl:variable name="bloodoxygensaturation-nodes"> | |
<xsl:call-template name="GetMatchingObservation"> | |
<xsl:with-param name="observations" select="$observations"/> | |
<xsl:with-param name="concept" select="$v_vitals/blood-oxygen-saturation"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="bloodoxygensaturation-observations" | |
select="msxsl:node-set($bloodoxygensaturation-nodes)[1]/cda:observation"/> | |
<xsl:for-each select="$bloodoxygensaturation-observations"> | |
<xsl:call-template name="Observation_To_BloodOxygenSaturation"> | |
<xsl:with-param name="bloodoxygensaturation" select="."/> | |
<xsl:with-param name="defaultEffectiveTime" select="$defaultEffectiveTime"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Observation_To_Weight"> | |
<xsl:param name="weight"/> | |
<xsl:param name="defaultEffectiveTime"/> | |
<xsl:if test="$weight and ($weight/cda:effectiveTime or $defaultEffectiveTime)"> | |
<xsl:variable name="try"> | |
<thing> | |
<type-id>3d34d87e-7fc1-4153-800f-f56592cb0d17</type-id> | |
<data-xml> | |
<weight> | |
<when> | |
<xsl:choose> | |
<xsl:when test="$weight/cda:effectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$weight/cda:effectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$defaultEffectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$defaultEffectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</when> | |
<xsl:choose> | |
<xsl:when test="$weight/cda:value/@xsi:type = 'PQ'"> | |
<value> | |
<kg> | |
<xsl:call-template name="Value_To_weight"> | |
<xsl:with-param name="value" | |
select="$weight/cda:value"/> | |
</xsl:call-template> | |
</kg> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$weight/cda:value"/> | |
</xsl:call-template> | |
</value> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</weight> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
<done> | |
<xsl:value-of select="$weight/cda:id/@root"/> | |
</done> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Observation_To_Height"> | |
<xsl:param name="height"/> | |
<xsl:param name="defaultEffectiveTime"/> | |
<xsl:if test="$height and ($height/cda:effectiveTime or $defaultEffectiveTime)"> | |
<xsl:variable name="try"> | |
<thing> | |
<type-id>40750a6a-89b2-455c-bd8d-b420a4cb500b</type-id> | |
<data-xml> | |
<height> | |
<when> | |
<xsl:choose> | |
<xsl:when test="$height/cda:effectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$height/cda:effectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$defaultEffectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$defaultEffectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</when> | |
<xsl:choose> | |
<xsl:when test="$height/cda:value/@xsi:type = 'PQ'"> | |
<value> | |
<m> | |
<xsl:call-template name="Value_To_height"> | |
<xsl:with-param name="value" | |
select="$height/cda:value"/> | |
</xsl:call-template> | |
</m> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" select="$height/cda:value"/> | |
</xsl:call-template> | |
</value> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</height> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
<done> | |
<xsl:value-of select="$height/cda:id/@root"/> | |
</done> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Observation_To_BloodGlucose"> | |
<xsl:param name="bloodglucose"/> | |
<xsl:param name="defaultEffectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:if test="$bloodglucose and ($bloodglucose/cda:effectiveTime or $defaultEffectiveTime)"> | |
<xsl:variable name="try"> | |
<thing> | |
<type-id>879e7c04-4e8a-4707-9ad3-b054df467ce4</type-id> | |
<data-xml> | |
<blood-glucose> | |
<when> | |
<xsl:choose> | |
<xsl:when test="$bloodglucose/cda:effectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$bloodglucose/cda:effectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$defaultEffectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$defaultEffectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</when> | |
<xsl:choose> | |
<xsl:when test="$bloodglucose/cda:value/@xsi:type = 'PQ'"> | |
<value> | |
<mmolPerL> | |
<xsl:call-template name="Value_To_mmolPerL"> | |
<xsl:with-param name="value" | |
select="$bloodglucose/cda:value"/> | |
</xsl:call-template> | |
</mmolPerL> | |
<xsl:call-template name="PQ_To_display-value"> | |
<xsl:with-param name="pq" | |
select="$bloodglucose/cda:value"/> | |
</xsl:call-template> | |
</value> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:if test="cda:code"> | |
<glucose-measurement-type> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:code"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</glucose-measurement-type> | |
</xsl:if> | |
</blood-glucose> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
<done> | |
<xsl:value-of select="$bloodglucose/cda:id/@root"/> | |
</done> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="Observation_To_BloodOxygenSaturation"> | |
<xsl:param name="bloodoxygensaturation"/> | |
<xsl:param name="defaultEffectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:if | |
test="$bloodoxygensaturation and ($bloodoxygensaturation/cda:effectiveTime or $defaultEffectiveTime)"> | |
<xsl:variable name="try"> | |
<thing> | |
<type-id>3a54f95f-03d8-4f62-815f-f691fc94a500</type-id> | |
<data-xml> | |
<blood-oxygen-saturation> | |
<when> | |
<xsl:choose> | |
<xsl:when test="$bloodoxygensaturation/cda:effectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$bloodoxygensaturation/cda:effectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$defaultEffectiveTime"> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$defaultEffectiveTime"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</when> | |
<xsl:choose> | |
<xsl:when | |
test="$bloodoxygensaturation/cda:value/@xsi:type = 'PQ' and
 h:lc($bloodoxygensaturation/cda:value/@unit) = h:lc($v_measure/percent/import) or h:lc($bloodoxygensaturation/cda:value/@unit) = h:lc($v_measure/percent/ucum) and
 number($bloodoxygensaturation/cda:value/@value) <= 100 and 
 number($bloodoxygensaturation/cda:value/@value) >= 0"> | |
<value> | |
<xsl:value-of | |
select="$bloodoxygensaturation/cda:value/@value div 100" | |
/> | |
</value> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:if test="cda:methodCode"> | |
<measurement-method> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:methodCode"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</measurement-method> | |
</xsl:if> | |
<xsl:if test="cda:interpretationCode"> | |
<measurement-flags> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="cda:interpretationCode"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</measurement-flags> | |
</xsl:if> | |
</blood-oxygen-saturation> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
<done> | |
<xsl:value-of select="$bloodoxygensaturation/cda:id/@root"/> | |
</done> | |
</xsl:variable> | |
<xsl:call-template name="Finally"> | |
<xsl:with-param name="fragment" select="$try"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="ObservationResults_To_vital-signs"> | |
<xsl:param name="observations"/> | |
<xsl:param name="defaultEffectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:param name="ignore-items"/> | |
<xsl:for-each select="$observations[. != $ignore-items]"> | |
<thing> | |
<type-id>73822612-C15F-4B49-9E65-6AF369E55C65</type-id> | |
<data-xml> | |
<vital-signs> | |
<when> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="cda:effectiveTime"/> | |
</xsl:call-template> | |
</when> | |
<vital-signs-results> | |
<title><xsl:call-template name="CodableValueFromCCDCode"><xsl:with-param | |
name="code-value" select="cda:code"/><xsl:with-param | |
name="reference-text" select="$narrative-block" | |
/></xsl:call-template></title> | |
<xsl:if test="cda:value/@xsi:type = 'PQ'"> | |
<xsl:if test="cda:value/@value"> | |
<value> | |
<xsl:value-of select="cda:value/@value"/> | |
</value> | |
</xsl:if> | |
<xsl:if test="cda:value/@unit"> | |
<unit> | |
<text> | |
<xsl:value-of select="cda:value/@unit"/> | |
</text> | |
</unit> | |
</xsl:if> | |
</xsl:if> | |
<xsl:if test="cda:referenceRange/cda:observationRange"> | |
<xsl:if | |
test="cda:referenceRange/cda:observationRange/cda:value/cda:low/@value"> | |
<reference-minimum> | |
<xsl:value-of | |
select="cda:referenceRange/cda:observationRange/cda:value/cda:low/@value" | |
/> | |
</reference-minimum> | |
</xsl:if> | |
<xsl:if | |
test="cda:referenceRange/cda:observationRange/cda:value/cda:high/@value"> | |
<reference-maximum> | |
<xsl:value-of | |
select="cda:referenceRange/cda:observationRange/cda:value/cda:high/@value" | |
/> | |
</reference-maximum> | |
</xsl:if> | |
</xsl:if> | |
<xsl:if test="cda:value/@xsi:type != 'PQ'"> | |
<text-value> | |
<xsl:call-template name="StringFromAny"> | |
<xsl:with-param name="value" select="cda:value"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</text-value> | |
</xsl:if> | |
<xsl:if test="cda:interpretationCode"> | |
<flag> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="cda:interpretationCode"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</flag> | |
</xsl:if> | |
</vital-signs-results> | |
</vital-signs> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:variable name="result_observation_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.31</id> | |
<id>2.16.840.1.113883.10.20.22.4.2</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="result_observation" select="msxsl:node-set($result_observation_ids)"/> | |
<xsl:template name="LabResults"> | |
<xsl:param name="lab-results"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:variable name="result_organizer_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.32</id> | |
<id>2.16.840.1.113883.10.20.22.4.1</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="result_organizer" select="msxsl:node-set($result_organizer_ids)"/> | |
<xsl:for-each select="$lab-results"> | |
<xsl:choose> | |
<xsl:when | |
test="cda:organizer[not(./@nullFlavor) and ./cda:templateId/@root = $result_organizer/ids/id]"> | |
<xsl:for-each | |
select="cda:organizer[not(./@nullFlavor) and ./cda:templateId/@root = $result_organizer/ids/id]"> | |
<xsl:variable name="default-effective-time" select="cda:effectiveTime"/> | |
<xsl:variable name="radiology-nodes"> | |
<xsl:call-template name="GetMatchingObservationsFromOrganizer"> | |
<xsl:with-param name="organizer" select="current()"/> | |
<xsl:with-param name="concept" select="$v_results/radiology"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="radiology-observations" | |
select="msxsl:node-set($radiology-nodes)[1]/cda:observation"/> | |
<xsl:for-each select="$radiology-observations"> | |
<xsl:call-template name="RadiologyLabResultFromCCDObservation"> | |
<xsl:with-param name="observation" select="current()"/> | |
<xsl:with-param name="default-effective-time" | |
select="$default-effective-time"/> | |
<xsl:with-param name="result_organizer" select="$result_organizer"/> | |
<xsl:with-param name="reference-text" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
<xsl:call-template name="LabResultFromOrganizer"> | |
<xsl:with-param name="organizer" select="current()"/> | |
<xsl:with-param name="result_organizer" select="$result_organizer"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:when test="cda:observation"> | |
<thing> | |
<type-id>5800eab5-a8c2-482a-a4d6-f1db25ae08c3</type-id> | |
<data-xml> | |
<lab-test-results> | |
<xsl:if test="cda:observation[1]/cda:effectiveTime"> | |
<when> | |
<xsl:call-template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="cda:observation[1]/cda:effectiveTime"/> | |
</xsl:call-template> | |
</when> | |
</xsl:if> | |
<xsl:for-each select="cda:observation"> | |
<xsl:call-template name="LabGroupFromCCDObservation"> | |
<xsl:with-param name="observation" select="current()"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</lab-test-results> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:variable name="organizers" | |
select="cda:organizer[not(./@nullFlavor) and ./cda:templateId/@root = $result_organizer/ids/id]"/> | |
<xsl:call-template name="Organizers_to_Things"> | |
<xsl:with-param name="organizers" select="$organizers"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
<xsl:with-param name="allowed-observation-ids" select="$result_observation/ids/id"/> | |
</xsl:call-template> | |
<xsl:if test="cda:observation[./cda:templateId/@root = $result_observation/ids/id]"> | |
<xsl:call-template name="ObservationResults_To_Things"> | |
<xsl:with-param name="observations" | |
select="cda:observation[./cda:templateId/@root = $result_observation/ids/id]"/> | |
<xsl:with-param name="narrative-block" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="RadiologyLabResultFromCCDObservation"> | |
<xsl:param name="observation"/> | |
<xsl:param name="default-effective-time"/> | |
<xsl:param name="result_organizer"/> | |
<xsl:param name="reference-text"/> | |
<thing> | |
<type-id>E4911BD3-61BF-4E10-AE78-9C574B888B8F</type-id> | |
<data-xml> | |
<radiology-lab-results> | |
<xsl:choose> | |
<xsl:when test="$observation/cda:effectiveTime"> | |
<when> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$observation/cda:effectiveTime"/> | |
</xsl:call-template> | |
</when> | |
</xsl:when> | |
<xsl:otherwise> | |
<when> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$default-effective-time"/> | |
</xsl:call-template> | |
</when> | |
</xsl:otherwise> | |
</xsl:choose> | |
<title><xsl:call-template name="StringFromCD"><xsl:with-param name="value" | |
select="cda:code"/><xsl:with-param name="reference-text" | |
select="$reference-text"/></xsl:call-template></title> | |
<xsl:choose> | |
<xsl:when test="cda:value/@xsi:type = 'PQ'"> | |
<result-text> | |
<xsl:value-of select="cda:value/@value"/> | |
<xsl:text xml:space="preserve"> </xsl:text> | |
<xsl:value-of select="cda:value/@unit"/> | |
</result-text> | |
</xsl:when> | |
<xsl:otherwise> | |
<result-text> | |
<xsl:call-template name="StringFromAny"> | |
<xsl:with-param name="value" select="cda:value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</result-text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</radiology-lab-results> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:template> | |
<xsl:template name="LabResultFromOrganizer"> | |
<xsl:param name="organizer"/> | |
<xsl:param name="result_organizer"/> | |
<xsl:param name="narrative-block"/> | |
<thing> | |
<type-id>5800eab5-a8c2-482a-a4d6-f1db25ae08c3</type-id> | |
<data-xml> | |
<lab-test-results> | |
<xsl:if | |
test="$organizer[not(./@nullFlavor) and ./cda:templateId/@root = $result_organizer/ids/id][1]/cda:effectiveTime"> | |
<when> | |
<xsl:call-template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" | |
select="$organizer[not(./@nullFlavor) and ./cda:templateId/@root = $result_organizer/ids/id][1]/cda:effectiveTime" | |
/> | |
</xsl:call-template> | |
</when> | |
</xsl:if> | |
<xsl:for-each | |
select="$organizer[not(./@nullFlavor) and ./cda:templateId/@root = $result_organizer/ids/id]"> | |
<xsl:call-template name="LabGroupFromCCDOrganizer"> | |
<xsl:with-param name="organizer" select="current()"/> | |
<xsl:with-param name="reference-text" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</lab-test-results> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:template> | |
<xsl:template name="Procedures"> | |
<xsl:param name="procedures"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:variable name="procedure_activity_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.29</id> | |
<id>2.16.840.1.113883.10.20.22.4.12</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="procedure_activity" select="msxsl:node-set($procedure_activity_ids)"/> | |
<xsl:variable name="procedure_observation_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.29</id> | |
<id>2.16.840.1.113883.10.20.22.4.13</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="procedure_observation" | |
select="msxsl:node-set($procedure_observation_ids)"/> | |
<xsl:variable name="procedure_procedure_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.29</id> | |
<id>2.16.840.1.113883.10.20.22.4.14</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="procedure_procedure" select="msxsl:node-set($procedure_procedure_ids)"/> | |
<xsl:for-each | |
select="$procedures/cda:act[./cda:templateId/@root = $procedure_activity/ids/id] |
 $procedures/cda:observation[./cda:templateId/@root = $procedure_observation/ids/id] |
 $procedures/cda:procedure[./cda:templateId/@root = $procedure_procedure/ids/id]"> | |
<thing> | |
<type-id>df4db479-a1ba-42a2-8714-2b083b88150f</type-id> | |
<data-xml> | |
<procedure> | |
<xsl:if test="cda:effectiveTime"> | |
<when> | |
<xsl:call-template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="cda:effectiveTime" | |
/> | |
</xsl:call-template> | |
</when> | |
</xsl:if> | |
<xsl:if test="cda:code"> | |
<name><xsl:call-template name="CodableValueFromCCDCode"><xsl:with-param | |
name="code-value" select="cda:code"/><xsl:with-param | |
name="reference-text" select="$narrative-block" | |
/></xsl:call-template></name> | |
</xsl:if> | |
<xsl:if test="cda:targetSiteCode"> | |
<anatomic-location> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:targetSiteCode"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</anatomic-location> | |
</xsl:if> | |
<xsl:if | |
test="cda:performer[1]/cda:assignedEntity/cda:assignedPerson/cda:name"> | |
<primary-provider> | |
<xsl:call-template name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="cda:performer[1]/cda:assignedEntity"/> | |
</xsl:call-template> | |
</primary-provider> | |
</xsl:if> | |
<xsl:if | |
test="cda:performer[2]/cda:assignedEntity/cda:assignedPerson/cda:name"> | |
<secondary-provider> | |
<xsl:call-template name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="cda:performer[2]/cda:assignedEntity"/> | |
</xsl:call-template> | |
</secondary-provider> | |
</xsl:if> | |
</procedure> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Encounters"> | |
<xsl:param name="encounters"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$encounters"> | |
<thing> | |
<type-id>464083cc-13de-4f3e-a189-da8e47d5651b</type-id> | |
<data-xml> | |
<encounter> | |
<xsl:if test="cda:effectiveTime"> | |
<when> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="cda:effectiveTime" | |
/> | |
</xsl:call-template> | |
</when> | |
</xsl:if> | |
<xsl:if test="cda:code"> | |
<type> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:code"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</type> | |
</xsl:if> | |
<xsl:variable name="encounter_indication_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.28</id> | |
<id>2.16.840.1.113883.10.20.22.4.19</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="encounter_indication" | |
select="msxsl:node-set($encounter_indication_ids)"/> | |
<xsl:variable name="indication" | |
select="cda:entryRelationship[./@typeCode = 'RSON']/cda:observation[./cda:templateId/@root = $encounter_indication/ids/id]"/> | |
<xsl:choose> | |
<xsl:when test="$indication/cda:value"> | |
<reason> | |
<xsl:call-template name="StringFromAny"> | |
<xsl:with-param name="value" select="$indication/cda:value"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</reason> | |
</xsl:when> | |
<xsl:when test="cda:text"> | |
<reason> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="cda:text"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</reason> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:if test="cda:effectiveTime/cda:low/@value"> | |
<duration> | |
<start-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</start-date> | |
<xsl:if test="cda:effectiveTime/cda:high/@value"> | |
<end-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</end-date> | |
</xsl:if> | |
</duration> | |
</xsl:if> | |
<xsl:variable name="encounter_facility_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.45</id> | |
<id>2.16.840.1.113883.10.20.22.4.32</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="encounter_facility" | |
select="msxsl:node-set($encounter_facility_ids)"/> | |
<xsl:variable name="location" | |
select="cda:participant[./@typeCode = 'LOC' and ./cda:templateId/@root = $encounter_facility]/cda:participantRole"/> | |
<xsl:if test="$location/cda:playingEntity/cda:name"> | |
<facility> | |
<xsl:call-template name="OrganizationFromCCDParticipantRole"> | |
<xsl:with-param name="entity" select="$location"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</facility> | |
</xsl:if> | |
</encounter> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Allergies"> | |
<xsl:param name="allergies"/> | |
<xsl:param name="effectiveTime"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$allergies"> | |
<xsl:variable name="allergen-code" | |
select="cda:participant[./@typeCode = 'CSM']/cda:participantRole[./@classCode = 'MANU']/cda:playingEntity[./@classCode = 'MMAT']/cda:code"/> | |
<xsl:variable name="allergy_reaction_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.54</id> | |
<id>2.16.840.1.113883.10.20.22.4.7</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="allergy_reaction" select="msxsl:node-set($allergy_reaction_ids)"/> | |
<xsl:variable name="reaction" | |
select="cda:entryRelationship/cda:observation[./cda:templateId/@root = $allergy_reaction/ids/id][1]"/> | |
<thing> | |
<type-id>52bf9104-2c5e-4f1f-a66d-552ebcc53df7</type-id> | |
<data-xml> | |
<allergy> | |
<name><xsl:choose><xsl:when test="$allergen-code"><xsl:call-template | |
name="CodableValueFromCCDCode"><xsl:with-param | |
name="code-value" select="$allergen-code" | |
/><xsl:with-param name="reference-text" | |
select="$narrative-block" | |
/></xsl:call-template></xsl:when><xsl:when test="cda:value" | |
><xsl:call-template name="CodableValueFromCCDCode" | |
><xsl:with-param name="code-value" select="cda:value" | |
/><xsl:with-param name="reference-text" | |
select="$narrative-block" | |
/></xsl:call-template></xsl:when><xsl:otherwise><text>Unknown</text></xsl:otherwise></xsl:choose></name> | |
<xsl:if test="$reaction/cda:value"> | |
<reaction> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$reaction/cda:value"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</reaction> | |
</xsl:if> | |
<xsl:if | |
test="cda:effectiveTime/@value or cda:effectiveTime/cda:low/@value or cda:effectiveTime/cda:center/@value or cda:effectiveTime/cda:high/@value"> | |
<first-observed> | |
<xsl:call-template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="cda:effectiveTime" | |
/> | |
</xsl:call-template> | |
</first-observed> | |
</xsl:if> | |
<xsl:if | |
test="cda:participant[./@typeCode = 'CSM']/cda:participantRole[./@classCode = 'MANU']/cda:code"> | |
<allergen-type> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="cda:participant[./@typeCode = 'CSM']/cda:participantRole[./@classCode = 'MANU']/cda:code"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</allergen-type> | |
</xsl:if> | |
<xsl:if test="$allergen-code"> | |
<allergen-code> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$allergen-code"/> | |
<xsl:with-param name="reference-text" select="$narrative-block" | |
/> | |
</xsl:call-template> | |
</allergen-code> | |
</xsl:if> | |
<xsl:variable name="allergy_procedure_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.29</id> | |
<id>2.16.840.1.113883.10.20.22.4.12</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="allergy_procedure" | |
select="msxsl:node-set($allergy_procedure_ids)"/> | |
<xsl:variable name="procedure" | |
select="$reaction/cda:entryRelationship[./@typeCode = 'RSON']/cda:act[./cda:templateId/@root = $allergy_procedure/ids/id][1]"/> | |
<xsl:variable name="allergy_medication_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.24</id> | |
<id>2.16.840.1.113883.10.20.22.4.16</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="allergy_medication" | |
select="msxsl:node-set($allergy_medication_ids)"/> | |
<xsl:variable name="medication" | |
select="$reaction/cda:entryRelationship[./@typeCode = 'RSON']/cda:substanceAdministration[./cda:templateId/@root = $allergy_medication/ids/id][1]"/> | |
<xsl:choose> | |
<xsl:when | |
test="$procedure and ($procedure/cda:performer/cda:assignedEntity or $procedure/cda:code)"> | |
<xsl:if test="$procedure/cda:performer/cda:assignedEntity"> | |
<treatment-provider> | |
<xsl:call-template name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="$procedure/cda:performer/cda:assignedEntity" | |
/> | |
</xsl:call-template> | |
</treatment-provider> | |
</xsl:if> | |
<xsl:if test="$procedure/cda:code"> | |
<treatment> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="$procedure/cda:code"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</treatment> | |
</xsl:if> | |
</xsl:when> | |
<xsl:when | |
test="$medication and ($medication/cda:performer/cda:assignedEntity or $medication/cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code)"> | |
<xsl:if test="$medication/cda:performer/cda:assignedEntity"> | |
<treatment-provider> | |
<xsl:call-template name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="$medication/cda:performer/cda:assignedEntity" | |
/> | |
</xsl:call-template> | |
</treatment-provider> | |
</xsl:if> | |
<xsl:if | |
test="$medication/cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"> | |
<treatment> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="$medication/cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</treatment> | |
</xsl:if> | |
</xsl:when> | |
</xsl:choose> | |
</allergy> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Conditions"> | |
<xsl:param name="conditions"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$conditions"> | |
<thing> | |
<type-id>7ea7a1f9-880b-4bd4-b593-f5660f20eda8</type-id> | |
<data-xml> | |
<condition> | |
<xsl:choose> | |
<xsl:when | |
test="(cda:value/@displayName != '' or cda:value/cda:originalText != '' or cda:value/@code != '') and not(cda:value/@nullFlavor)"> | |
<name><xsl:call-template name="CodableValueFromCCDCode" | |
><xsl:with-param name="code-value" select="cda:value" | |
/><xsl:with-param name="reference-text" | |
select="$narrative-block"/></xsl:call-template></name> | |
</xsl:when> | |
<xsl:when test="cda:text != ''"> | |
<name><text><xsl:call-template name="StringFromED"><xsl:with-param | |
name="value" select="cda:text"/><xsl:with-param | |
name="reference-text" select="$narrative-block" | |
/></xsl:call-template></text></name> | |
</xsl:when> | |
<xsl:when test="cda:value/cda:translation"> | |
<name><xsl:call-template name="CodableValueFromCCDCode" | |
><xsl:with-param name="code-value" | |
select="cda:value/cda:translation"/><xsl:with-param | |
name="reference-text" select="$narrative-block" | |
/></xsl:call-template></name> | |
</xsl:when> | |
<xsl:otherwise> | |
<name><text>Unknown</text></name> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:choose> | |
<xsl:when test="cda:effectiveTime/@nullFlavor"/> | |
<xsl:when test="cda:effectiveTime/cda:low/@value != ''"> | |
<onset-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</onset-date> | |
</xsl:when> | |
<xsl:when test="cda:effectiveTime/@value"> | |
<onset-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/@value"/> | |
</xsl:call-template> | |
</onset-date> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:variable name="problem_observation_status_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.50</id> | |
<id>2.16.840.1.113883.10.20.22.4.6</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="problem_observation_status" | |
select="msxsl:node-set($problem_observation_status_ids)"/> | |
<xsl:variable name="status-value" | |
select="cda:entryRelationship[./@typeCode='REFR']/cda:observation[./cda:templateId/@root=$problem_observation_status/ids/id]/cda:value"/> | |
<xsl:if test="$status-value"> | |
<status> | |
<xsl:choose> | |
<xsl:when | |
test="$status-value/@code='55561003' or h:lc($status-value/@displayName)='active'"> | |
<text>Current: Currently has this</text> | |
<code><value>active</value><family>wc</family><type>condition-occurrence</type><version>1</version></code> | |
</xsl:when> | |
<xsl:when | |
test="$status-value/@code='73425007' or h:lc($status-value/@displayName)='inactive'"> | |
<text>Past: No longer has this</text> | |
<code><value>inactive</value><family>wc</family><type>condition-occurrence</type><version>1</version></code> | |
</xsl:when> | |
<xsl:when | |
test="$status-value/@code='7087005' or h:lc($status-value/@displayName)='intermittent'"> | |
<text>Intermittent: Comes and goes</text> | |
<code><value>intermittent</value><family>wc</family><type>condition-occurrence</type><version>1</version></code> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$status-value"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</status> | |
</xsl:if> | |
<xsl:if test="cda:effectiveTime/cda:high/@value"> | |
<stop-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</stop-date> | |
</xsl:if> | |
</condition> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="Appointments"> | |
<xsl:param name="appointments"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$appointments"> | |
<xsl:if test="cda:effectiveTime"> | |
<thing> | |
<type-id>4b18aeb6-5f01-444c-8c70-dbf13a2f510b</type-id> | |
<data-xml> | |
<appointment> | |
<when> | |
<xsl:call-template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="cda:effectiveTime" | |
/> | |
</xsl:call-template> | |
</when> | |
<xsl:if test="cda:effectiveTime/cda:low/@value"> | |
<duration> | |
<start-date> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</start-date> | |
<xsl:if test="cda:effectiveTime/cda:high/@value"> | |
<end-date> | |
<xsl:call-template | |
name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" | |
select="cda:effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</end-date> | |
</xsl:if> | |
</duration> | |
</xsl:if> | |
<xsl:if test="cda:code"> | |
<service> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:code"/> | |
<xsl:with-param name="reference-text" | |
select="$narrative-block"/> | |
</xsl:call-template> | |
</service> | |
</xsl:if> | |
<xsl:variable name="encounter_facility_ids"> | |
<ids> | |
<id>2.16.840.1.113883.10.20.1.45</id> | |
<id>2.16.840.1.113883.10.20.22.4.32</id> | |
</ids> | |
</xsl:variable> | |
<xsl:variable name="encounter_facility" | |
select="msxsl:node-set($encounter_facility_ids)"/> | |
<xsl:variable name="location" | |
select="cda:participant[./@typeCode = 'LOC' and ./cda:templateId/@root = $encounter_facility]/cda:participantRole"/> | |
<xsl:choose> | |
<xsl:when | |
test="cda:performer/cda:assignedEntity/cda:assignedPerson/cda:name"> | |
<clinic> | |
<xsl:call-template name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" | |
select="cda:performer/cda:assignedEntity"/> | |
</xsl:call-template> | |
<xsl:if test="$location/cda:playingEntity/cda:name"> | |
<organization> | |
<xsl:call-template name="PN_To_String"> | |
<xsl:with-param name="pn" | |
select="$location/cda:playingEntity/cda:name"/> | |
</xsl:call-template> | |
</organization> | |
</xsl:if> | |
</clinic> | |
</xsl:when> | |
<xsl:when test="$location/cda:playingEntity/cda:name"> | |
<clinic> | |
<name><full><xsl:call-template name="PN_To_String" | |
><xsl:with-param name="pn" | |
select="$location/cda:playingEntity/cda:name" | |
/></xsl:call-template></full></name> | |
</clinic> | |
</xsl:when> | |
</xsl:choose> | |
</appointment> | |
<xsl:call-template name="AddCommonSection"/> | |
</data-xml> | |
</thing> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="GetFromTextById"> | |
<xsl:param name="text"/> | |
<xsl:param name="id"/> | |
<xsl:variable name="content-id"> | |
<xsl:choose> | |
<xsl:when test="substring($id, 1, 1) = '#'"> | |
<xsl:value-of select="substring($id, 2)"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$id"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="$text//cda:td[./@ID=$content-id]/cda:content"> | |
<xsl:value-of select="$text//cda:td[./@ID=$content-id]/cda:content"/> | |
</xsl:when> | |
<xsl:when test="$text//cda:content[./@ID=$content-id]"> | |
<xsl:value-of select="$text//cda:content[./@ID=$content-id]"/> | |
</xsl:when> | |
<xsl:when test="$text//cda:td[./@ID=$content-id]"> | |
<xsl:value-of select="$text//cda:td[./@ID=$content-id]"/> | |
</xsl:when> | |
<xsl:when test="$text//cda:item[./@ID=$content-id]"> | |
<xsl:value-of select="$text//cda:item[./@ID=$content-id]"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$text//cda:td[./@ID=$id]"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="CodableValueTextFromCCDCode"> | |
<xsl:param name="code-value"/> | |
<xsl:param name="reference-text"/> | |
<xsl:if test="$code-value"> | |
<xsl:choose> | |
<xsl:when test="$code-value/@displayName"> | |
<xsl:value-of select="$code-value/@displayName"/> | |
</xsl:when> | |
<xsl:when test="$code-value/cda:originalText"> | |
<xsl:choose> | |
<xsl:when | |
test="$code-value/cda:originalText/cda:reference/@value and $reference-text"> | |
<xsl:call-template name="GetFromTextById"> | |
<xsl:with-param name="text" select="$reference-text"/> | |
<xsl:with-param name="id" | |
select="$code-value/cda:originalText/cda:reference/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$code-value/cda:originalText"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:when test="$code-value/@code"> | |
<xsl:value-of select="$code-value/@code"/> | |
</xsl:when> | |
<xsl:when test="$code-value/cda:translation"> | |
<xsl:call-template name="StringFromCD"> | |
<xsl:with-param name="value" select="$code-value/cda:translation"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:text>Unknown</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="CodableValueFromCCDCode"> | |
<xsl:param name="code-value"/> | |
<xsl:param name="reference-text"/> | |
<xsl:if test="$code-value"> | |
<text> | |
<xsl:call-template name="CodableValueTextFromCCDCode"> | |
<xsl:with-param name="code-value" select="$code-value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</text> | |
<xsl:call-template name="CodedValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$code-value"/> | |
</xsl:call-template> | |
<xsl:for-each select="$code-value/cda:translation"> | |
<xsl:call-template name="CodedValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="."/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="CodedValueFromCCDCode"> | |
<xsl:param name="code-value"/> | |
<xsl:if | |
test="$code-value/@code and ($code-value/@codeSystemName or $code-value/@codeSystem)"> | |
<code><value><xsl:value-of select="$code-value/@code"/></value><xsl:variable | |
name="codeSystemName"><xsl:choose><xsl:when test="$code-value/@codeSystemName" | |
><xsl:value-of select="$code-value/@codeSystemName" | |
/></xsl:when><xsl:otherwise><xsl:call-template name="codeSystemName" | |
><xsl:with-param name="codeSystemCode" | |
select="$code-value/@codeSystem" | |
/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:variable><xsl:choose><xsl:when | |
test="$codeSystemName and $codeSystemName != ''"><type><xsl:value-of | |
select="$codeSystemName" | |
/></type></xsl:when><xsl:otherwise><type><xsl:value-of | |
select="$code-value/@codeSystem" | |
/></type></xsl:otherwise></xsl:choose><xsl:if | |
test="$code-value/@codeSystemVersion"><version><xsl:value-of | |
select="$code-value/@codeSystemVersion"/></version></xsl:if></code> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="CodableValueFromAny"> | |
<xsl:param name="value"/> | |
<xsl:param name="reference-text"/> | |
<xsl:param name="type" select="$value/@xsi:type"/> | |
<xsl:choose> | |
<xsl:when test="$value/@xsi:type = 'CD' or $type = 'CD'"> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'CE' or $type = 'CE'"> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'CS' or $type = 'CS'"> | |
<text> | |
<xsl:value-of select="$value/@code"/> | |
</text> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'ST' or $type = 'ST'"> | |
<text> | |
<xsl:value-of select="$value"/> | |
</text> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'ED' or $type = 'ED'"> | |
<text> | |
<xsl:choose> | |
<xsl:when test="$value/cda:reference/@value"> | |
<xsl:call-template name="GetFromTextById"> | |
<xsl:with-param name="text" select="$reference-text"/> | |
<xsl:with-param name="id" select="$value/cda:reference/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$value"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</text> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:variable name="numbers" select="'1234567890'"/> | |
<xsl:template name="codeSystemName"> | |
<xsl:param name="codeSystemCode"/> | |
<xsl:choose> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.96'">snomed-ct</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.103'">icd-9 cm (diagnosis | |
codes)</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.26'">medcin</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.1'">loinc</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.69'">ndc</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.88'">rxnorm</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.65'">mddx</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.63'">fddx</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.104'">icd-9cm (procedure | |
codes)</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.12'">cpt-4</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.2'">icd-9 cm</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.4'">icd10pcs</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.90'">icd10cm</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.86'">umls</xsl:when> | |
<xsl:when test="$codeSystemCode='2.16.840.1.113883.6.59'">cvx</xsl:when> | |
<xsl:when test="translate(translate($codeSystemCode, $numbers, ''), '.', '') = ''"> | |
<xsl:value-of select="$codeSystemCode"/> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:variable name="telecom-use"> | |
<telecommunication-address-use> | |
<use code="h">Home address</use> | |
<use code="hp">Primary home</use> | |
<use code="hv">Vacation home</use> | |
<use code="wp">Work place</use> | |
<use code="dir">Direct</use> | |
<use code="pub">Public</use> | |
<use code="tmp">Temporary address</use> | |
<use code="as">Answering service</use> | |
<use code="ec">Emergency contact</use> | |
<use code="mc">Mobile contact</use> | |
<use code="pg">Pager</use> | |
</telecommunication-address-use> | |
</xsl:variable> | |
<xsl:template name="ContactFromCCDAssignedEntity"> | |
<xsl:param name="entity"/> | |
<xsl:choose> | |
<xsl:when test="$entity/cda:addr or $entity/cda:telecom"> | |
<xsl:for-each select="$entity/cda:addr"> | |
<xsl:call-template name="AddressFromCCDAddress"> | |
<xsl:with-param name="address" select="current()"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
<xsl:for-each | |
select="$entity/cda:telecom[starts-with(./@value, 'tel:') and (not(./@use) or ./@use != 'BAD')]"> | |
<xsl:variable name="use" select="./@use"/> | |
<phone> | |
<xsl:if | |
test="msxsl:node-set($telecom-use)/telecommunication-address-use/use[./@code = h:lc($use)]"> | |
<description> | |
<xsl:value-of | |
select="msxsl:node-set($telecom-use)/telecommunication-address-use/use[@code = h:lc($use)]" | |
/> | |
</description> | |
</xsl:if> | |
<number> | |
<xsl:value-of select="substring(@value, string-length('tel:') + 1)"/> | |
</number> | |
</phone> | |
</xsl:for-each> | |
<xsl:for-each select="$entity/cda:telecom[starts-with(./@value, 'mailto:')]"> | |
<xsl:variable name="use" select="./@use"/> | |
<email><xsl:if | |
test="msxsl:node-set($telecom-use)/telecommunication-address-use/use[./@code = h:lc($use)]" | |
><description><xsl:value-of | |
select="msxsl:node-set($telecom-use)/telecommunication-address-use/use[./@code = h:lc($use)]" | |
/></description></xsl:if><address><xsl:value-of select="substring(@value, string-length('mailto:') + 1)"/></address></email> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:when test="$entity/cda:representedOrganization"> | |
<xsl:call-template name="ContactFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" select="$entity/cda:representedOrganization"/> | |
</xsl:call-template> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="PersonFromCCDAssignedEntity"> | |
<xsl:param name="entity"/> | |
<xsl:if test="$entity"> | |
<xsl:call-template name="NameFromCCDName"> | |
<xsl:with-param name="name" select="$entity/cda:assignedPerson/cda:name"/> | |
</xsl:call-template> | |
<xsl:if test="$entity/cda:representedOrganization/cda:name"> | |
<organization> | |
<xsl:value-of select="$entity/cda:representedOrganization/cda:name"/> | |
</organization> | |
</xsl:if> | |
<xsl:if test="$entity/cda:addr or $entity/cda:telecom"> | |
<contact> | |
<xsl:call-template name="ContactFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" select="$entity"/> | |
</xsl:call-template> | |
</contact> | |
</xsl:if> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="NameFromCCDName"> | |
<xsl:param name="name"/> | |
<xsl:variable name="full-name" | |
select="$name[not(./cda:family) and not(./cda:given) and not(./cda:prefix) and not(./cda:suffix)]"/> | |
<xsl:variable name="name-parts" | |
select="$name[./cda:family or ./cda:given or ./cda:prefix or ./cda:suffix]"/> | |
<xsl:choose> | |
<xsl:when test="$name-parts"> | |
<name><full><xsl:if test="$name-parts/cda:prefix"><xsl:value-of | |
select="$name-parts/cda:prefix"/></xsl:if><xsl:if | |
test="$name-parts/cda:given"><xsl:if test="$name-parts/cda:prefix" | |
><xsl:text xml:space="preserve"> </xsl:text></xsl:if><xsl:value-of | |
select="$name-parts/cda:given[1]"/></xsl:if><xsl:if | |
test="count($name-parts/cda:given) > 1" | |
><xsl:text xml:space="preserve"> </xsl:text><xsl:value-of | |
select="$name-parts/cda:given[2]"/></xsl:if><xsl:if | |
test="$name-parts/cda:family"><xsl:if | |
test="$name-parts/cda:prefix or $name-parts/cda:given" | |
><xsl:text xml:space="preserve"> </xsl:text></xsl:if><xsl:value-of | |
select="$name-parts/cda:family"/></xsl:if><xsl:if | |
test="$name-parts/cda:suffix"><xsl:if | |
test="$name-parts/cda:prefix or $name-parts/cda:given or $name-parts/cda:family" | |
><xsl:text xml:space="preserve"> </xsl:text></xsl:if><xsl:value-of | |
select="$name-parts/cda:suffix"/></xsl:if></full><xsl:if | |
test="$name-parts/cda:prefix"><title><text><xsl:value-of | |
select="$name-parts/cda:prefix"/></text></title></xsl:if><xsl:if | |
test="$name-parts/cda:given"><first><xsl:value-of | |
select="$name-parts/cda:given[1]"/></first></xsl:if><xsl:if | |
test="count($name-parts/cda:given) > 1"><middle><xsl:value-of | |
select="$name-parts/cda:given[2]"/></middle></xsl:if><xsl:if | |
test="$name/cda:family"><last><xsl:value-of select="$name/cda:family" | |
/></last></xsl:if><xsl:if test="$name/cda:suffix" | |
><suffix><text><xsl:value-of select="$name/cda:suffix" | |
/></text></suffix></xsl:if></name> | |
</xsl:when> | |
<xsl:when test="$full-name"> | |
<name><full><xsl:value-of select="$full-name"/></full></name> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="DateTimeFromCCDEffectiveTime"> | |
<xsl:param name="effectiveTime"/> | |
<xsl:choose> | |
<xsl:when test="$effectiveTime/@value"> | |
<xsl:call-template name="DateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:center/@value"> | |
<xsl:call-template name="DateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:center/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:low/@value"> | |
<xsl:call-template name="DateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:high/@value"> | |
<xsl:call-template name="DateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<date><y>1900</y><m>1</m><d>1</d></date> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="DateFromCCDEffectiveTime"> | |
<xsl:param name="effectiveTime"/> | |
<xsl:choose> | |
<xsl:when test="$effectiveTime/@value"> | |
<xsl:call-template name="DateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:center/@value"> | |
<xsl:call-template name="DateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:center/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:low/@value"> | |
<xsl:call-template name="DateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:high/@value"> | |
<xsl:call-template name="DateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<date><y>1900</y><m>1</m><d>1</d></date> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="ApproxDateFromCCDNumericDate"> | |
<xsl:param name="numericDate"/> | |
<xsl:if test="number(substring($numericDate, 1, 4))"> | |
<y> | |
<xsl:choose> | |
<xsl:when test="number(substring($numericDate, 1, 4)) < 1000"> | |
<xsl:text>1000</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="number(substring($numericDate, 1, 4))"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</y> | |
<xsl:choose> | |
<xsl:when test="number(substring($numericDate, 5, 2))"> | |
<m> | |
<xsl:value-of select="number(substring($numericDate, 5, 2))"/> | |
</m> | |
<xsl:choose> | |
<xsl:when test="number(substring($numericDate, 7, 2))"> | |
<d> | |
<xsl:value-of select="number(substring($numericDate, 7, 2))"/> | |
</d> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="DateTimeFromCCDNumericDate"> | |
<xsl:param name="numericDate"/> | |
<xsl:param name="approximate"/> | |
<date><xsl:if test="number(substring($numericDate, 1, 4))"><y><xsl:choose><xsl:when | |
test="number(substring($numericDate, 1, 4)) < 1000" | |
><xsl:text>1000</xsl:text></xsl:when><xsl:otherwise><xsl:value-of | |
select="number(substring($numericDate, 1, 4))" | |
/></xsl:otherwise></xsl:choose></y><xsl:choose><xsl:when | |
test="string(number(substring($numericDate, 5, 2))) != 'NaN' and
 number(substring($numericDate, 5, 2)) < 13 and
 number(substring($numericDate, 5, 2)) > 0" | |
><m><xsl:value-of select="number(substring($numericDate, 5, 2))" | |
/></m><xsl:choose><xsl:when | |
test="string(number(substring($numericDate, 7, 2))) != 'NaN' and
 number(substring($numericDate, 7, 2)) < 32 and
 number(substring($numericDate, 7, 2)) > 0" | |
><d><xsl:value-of | |
select="number(substring($numericDate, 7, 2))" | |
/></d></xsl:when><xsl:otherwise><d>1</d></xsl:otherwise></xsl:choose></xsl:when><xsl:when | |
test="not($approximate)" | |
><m>1</m><d>1</d></xsl:when></xsl:choose></xsl:if></date> | |
<xsl:if | |
test="number(substring($numericDate, 9, 2)) < 24 and
 number(substring($numericDate, 9, 2)) >= 0"> | |
<time> | |
<h> | |
<xsl:value-of select="number(substring($numericDate, 9, 2))"/> | |
</h> | |
<m> | |
<xsl:choose> | |
<xsl:when | |
test="string(number(substring($numericDate, 11, 2))) != 'NaN' and
 number(substring($numericDate, 11, 2)) < 60 and
 number(substring($numericDate, 11, 2)) >= 0"> | |
<xsl:value-of select="number(substring($numericDate, 11, 2))"/> | |
</xsl:when> | |
<xsl:otherwise>0</xsl:otherwise> | |
</xsl:choose> | |
</m> | |
<xsl:if | |
test="string(number(substring($numericDate, 13, 2))) != 'NaN' and
 number(substring($numericDate, 13, 2)) < 60 and
 number(substring($numericDate, 13, 2)) >= 0"> | |
<s> | |
<xsl:value-of select="number(substring($numericDate, 13, 2))"/> | |
</s> | |
<xsl:if | |
test="substring($numericDate, 15, 1) = '.' and
 number(substring($numericDate, 16, 3)) != 'NaN'"> | |
<f> | |
<xsl:value-of select="number(substring($numericDate, 16, 3))"/> | |
</f> | |
</xsl:if> | |
</xsl:if> | |
</time> | |
<xsl:choose> | |
<xsl:when | |
test="substring($numericDate, 15) != '' and
 substring($numericDate, 15, 1) != '.'"> | |
<tz> | |
<text> | |
<xsl:value-of select="substring($numericDate, 15)"/> | |
</text> | |
</tz> | |
</xsl:when> | |
<xsl:when | |
test="substring($numericDate, 15, 1) = '.' and
 substring($numericDate, 19) != ''"> | |
<tz> | |
<text> | |
<xsl:value-of select="substring($numericDate, 19)"/> | |
</text> | |
</tz> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="DateFromCCDNumericDate"> | |
<xsl:param name="numericDate"/> | |
<xsl:param name="approximate"/> | |
<xsl:if test="number(substring($numericDate, 1, 4))"> | |
<y> | |
<xsl:choose> | |
<xsl:when test="number(substring($numericDate, 1, 4)) < 1000"> | |
<xsl:text>1000</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="number(substring($numericDate, 1, 4))"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</y> | |
<xsl:choose> | |
<xsl:when | |
test="string(number(substring($numericDate, 5, 2))) != 'NaN' and
 number(substring($numericDate, 5, 2)) < 13 and
 number(substring($numericDate, 5, 2)) > 0"> | |
<m> | |
<xsl:value-of select="number(substring($numericDate, 5, 2))"/> | |
</m> | |
<xsl:choose> | |
<xsl:when | |
test="string(number(substring($numericDate, 7, 2))) != 'NaN' and
 number(substring($numericDate, 7, 2)) < 32 and
 number(substring($numericDate, 7, 2)) > 0"> | |
<d> | |
<xsl:value-of select="number(substring($numericDate, 7, 2))"/> | |
</d> | |
</xsl:when> | |
<xsl:otherwise> | |
<d>1</d> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:when test="not($approximate)"> | |
<m>1</m> | |
<d>1</d> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="ApproxDateFromCCDEffectiveTime"> | |
<xsl:param name="effectiveTime"/> | |
<xsl:choose> | |
<xsl:when test="$effectiveTime/@value"> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:center/@value"> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:center/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:low/@value"> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:high/@value"> | |
<xsl:call-template name="ApproxDateFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:param name="effectiveTime"/> | |
<xsl:choose> | |
<xsl:when test="$effectiveTime/@value"> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:low/@value"> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:low/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:center/@value"> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:center/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$effectiveTime/cda:high/@value"> | |
<xsl:call-template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$effectiveTime/cda:high/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<descriptive> </descriptive> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="ApproxDateTimeFromCCDNumericDate"> | |
<xsl:param name="numericDate"/> | |
<xsl:variable name="numericRoot"> | |
<xsl:choose> | |
<xsl:when test="string-length($numericDate) < 15"> | |
<xsl:value-of select="$numericDate"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="substring($numericDate, 1, 14)"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="not($numericDate)"> | |
<descriptive>Unknown</descriptive> | |
</xsl:when> | |
<xsl:when test="string(number($numericRoot)) = 'NaN'"> | |
<descriptive> | |
<xsl:value-of select="$numericDate"/> | |
</descriptive> | |
</xsl:when> | |
<xsl:otherwise> | |
<structured> | |
<xsl:call-template name="DateTimeFromCCDNumericDate"> | |
<xsl:with-param name="numericDate" select="$numericDate"/> | |
<xsl:with-param name="approximate" select="true()"/> | |
</xsl:call-template> | |
</structured> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="OrganizationFromCCDEntity"> | |
<xsl:param name="entity"/> | |
<xsl:if test="$entity/cda:representedOrganization/cda:name"> | |
<name><xsl:value-of select="$entity/cda:representedOrganization/cda:name"/></name> | |
<xsl:if test="$entity/cda:addr or $entity/cda:telecom"> | |
<contact> | |
<xsl:call-template name="ContactFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" select="$entity"/> | |
</xsl:call-template> | |
</contact> | |
</xsl:if> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="OrganizationFromCCDParticipantRole"> | |
<xsl:param name="entity"/> | |
<xsl:param name="reference-text"/> | |
<xsl:if test="$entity/cda:playingEntity/cda:name"> | |
<name><xsl:value-of select="$entity/cda:playingEntity/cda:name"/></name> | |
</xsl:if> | |
<xsl:if | |
test="$entity/cda:addr or $entity/cda:telecom or
 $entity/cda:representedOrganization/cda:addr or $entity/cda:representedOrganization/cda:telecom"> | |
<contact> | |
<xsl:call-template name="ContactFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" select="$entity"/> | |
</xsl:call-template> | |
</contact> | |
</xsl:if> | |
<xsl:if test="$entity/cda:code"> | |
<type> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$entity/cda:code"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</type> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="AddressFromCCDAddress"> | |
<xsl:param name="address"/> | |
<xsl:if | |
test="$address/cda:streetAddressLine and $address/cda:city and $address/cda:postalCode"> | |
<address><xsl:for-each select="$address/cda:streetAddressLine"><street><xsl:value-of select="current()"/></street></xsl:for-each><city><xsl:value-of select="$address/cda:city"/></city><xsl:if test="$address/cda:state"><state><xsl:value-of select="$address/cda:state"/></state></xsl:if><postcode><xsl:value-of select="$address/cda:postalCode"/></postcode><country><xsl:choose><xsl:when test="$address/cda:country"><xsl:value-of select="$address/cda:country"/></xsl:when><xsl:otherwise><xsl:text>USA</xsl:text></xsl:otherwise></xsl:choose></country><xsl:if test="$address/cda:county"><county><xsl:value-of select="$address/cda:county"/></county></xsl:if></address> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="LabGroupFromCCDOrganizer"> | |
<xsl:param name="organizer"/> | |
<xsl:param name="reference-text"/> | |
<xsl:if test="$organizer"> | |
<lab-group> | |
<group-name> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$organizer/cda:code"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</group-name> | |
<xsl:choose> | |
<xsl:when | |
test="$organizer/cda:performer/cda:assignedEntity/cda:representedOrganization/cda:name"> | |
<laboratory-name> | |
<xsl:call-template name="OrganizationFromCCDEntity"> | |
<xsl:with-param name="entity" | |
select="$organizer/cda:performer/cda:assignedEntity"/> | |
</xsl:call-template> | |
</laboratory-name> | |
</xsl:when> | |
<xsl:when | |
test="$organizer/cda:informant/cda:assignedEntity/cda:representedOrganization/cda:name"> | |
<laboratory-name> | |
<xsl:call-template name="OrganizationFromCCDEntity"> | |
<xsl:with-param name="entity" | |
select="$organizer/cda:informant/cda:assignedEntity"/> | |
</xsl:call-template> | |
</laboratory-name> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:if test="$organizer/cda:statusCode"> | |
<status> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$organizer/cda:statusCode"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</status> | |
</xsl:if> | |
<xsl:for-each | |
select="$organizer/cda:component/cda:observation[./cda:templateId/@root = $result_observation/ids/id]"> | |
<xsl:call-template name="ObservationResults_to_lab-test-result-type"> | |
<xsl:with-param name="observation" select="."/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:for-each> | |
</lab-group> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="LabGroupFromCCDObservation"> | |
<xsl:param name="observation"/> | |
<xsl:param name="reference-text"/> | |
<xsl:if test="$observation"> | |
<lab-group> | |
<group-name> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$observation/cda:code"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</group-name> | |
<xsl:choose> | |
<xsl:when | |
test="$observation/cda:performer/cda:assignedEntity/cda:representedOrganization/cda:name"> | |
<laboratory-name> | |
<xsl:call-template name="OrganizationFromCCDEntity"> | |
<xsl:with-param name="entity" | |
select="$observation/cda:performer/cda:assignedEntity"/> | |
</xsl:call-template> | |
</laboratory-name> | |
</xsl:when> | |
<xsl:when | |
test="$observation/cda:informant/cda:assignedEntity/cda:representedOrganization/cda:name"> | |
<laboratory-name> | |
<xsl:call-template name="OrganizationFromCCDEntity"> | |
<xsl:with-param name="entity" | |
select="$observation/cda:informant/cda:assignedEntity"/> | |
</xsl:call-template> | |
</laboratory-name> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:if test="$observation/cda:statusCode"> | |
<status> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$observation/cda:statusCode"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</status> | |
</xsl:if> | |
<xsl:call-template name="ObservationResults_to_lab-test-result-type"> | |
<xsl:with-param name="observation" select="$observation"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</lab-group> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="ObservationResults_to_lab-test-result-type"> | |
<xsl:param name="observation"/> | |
<xsl:param name="reference-text"/> | |
<results> | |
<xsl:if test="$observation/cda:effectiveTime"> | |
<when> | |
<xsl:call-template name="ApproxDateTimeFromCCDEffectiveTime"> | |
<xsl:with-param name="effectiveTime" select="$observation/cda:effectiveTime" | |
/> | |
</xsl:call-template> | |
</when> | |
</xsl:if> | |
<xsl:variable name="test-name"> | |
<xsl:call-template name="CodableValueTextFromCCDCode"> | |
<xsl:with-param name="code-value" select="$observation/cda:code"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:if test="$test-name"> | |
<name><xsl:value-of select="$test-name"/></name> | |
</xsl:if> | |
<xsl:if | |
test="$observation/../../cda:specimen/cda:specimenRole/cda:specimenPlayingEntity/cda:code"> | |
<substance> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="$observation/../../cda:specimen/cda:specimenRole/cda:specimenPlayingEntity/cda:code"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</substance> | |
</xsl:if> | |
<xsl:if test="$observation/cda:methodCode"> | |
<collection-method> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$observation/cda:methodCode"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</collection-method> | |
</xsl:if> | |
<xsl:if test="$observation/cda:code"> | |
<clinical-code> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="$observation/cda:code"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</clinical-code> | |
</xsl:if> | |
<value> | |
<measurement> | |
<xsl:call-template name="ValueToGeneralMeasurement"> | |
<xsl:with-param name="value" select="$observation/cda:value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</measurement> | |
<xsl:for-each select="$observation/cda:referenceRange/cda:observationRange"> | |
<ranges> | |
<type> | |
<xsl:choose> | |
<xsl:when test="cda:code"> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" select="cda:code"/> | |
<xsl:with-param name="reference-text" | |
select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="cda:value/@xsi:type = 'IVL_PQ'"> | |
<text> | |
<xsl:value-of select="cda:value/cda:low/@unit"/> | |
</text> | |
</xsl:when> | |
<xsl:when test="cda:value/@xsi:type = 'PQ'"> | |
<text> | |
<xsl:value-of select="cda:value/@unit"/> | |
</text> | |
</xsl:when> | |
<xsl:otherwise> | |
<text>Unknown</text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</type> | |
<xsl:choose> | |
<xsl:when test="cda:text"> | |
<text> | |
<text> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="cda:text"/> | |
<xsl:with-param name="reference-text" | |
select="$reference-text"/> | |
</xsl:call-template> | |
</text> | |
</text> | |
</xsl:when> | |
<xsl:when test="cda:value"> | |
<text> | |
<text> | |
<xsl:call-template name="StringFromAny"> | |
<xsl:with-param name="value" select="cda:value"/> | |
<xsl:with-param name="reference-text" | |
select="$reference-text"/> | |
</xsl:call-template> | |
</text> | |
</text> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:if | |
test="cda:value/@xsi:type = 'IVL_PQ' and cda:value/cda:low and cda:value/cda:high"> | |
<value> | |
<minimum-range> | |
<xsl:value-of select="cda:value/cda:low/@value"/> | |
</minimum-range> | |
<maximum-range> | |
<xsl:value-of select="cda:value/cda:high/@value"/> | |
</maximum-range> | |
</value> | |
</xsl:if> | |
</ranges> | |
</xsl:for-each> | |
<xsl:if test="$observation/cda:interpretationCode"> | |
<flag> | |
<xsl:call-template name="CodableValueFromCCDCode"> | |
<xsl:with-param name="code-value" | |
select="$observation/cda:interpretationCode"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</flag> | |
</xsl:if> | |
</value> | |
</results> | |
</xsl:template> | |
<xsl:template name="AddCommonSection"> | |
<common> | |
<xsl:variable name="source" | |
select="./cda:entryRelationship[./@typeCode = 'REFR']/cda:observation[./cda:code/@codeSystem = '2.16.840.1.113883.6.1' and ./cda:code/@code = '48766-0']"/> | |
<xsl:choose> | |
<xsl:when test="$source"> | |
<source><xsl:value-of select="$source/cda:value"/></source> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:variable name="nearest-informant-node"> | |
<xsl:call-template name="FindNearestInformant"> | |
<xsl:with-param name="node" select="."/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="nearest-informant" | |
select="msxsl:node-set($nearest-informant-node)/node()"/> | |
<xsl:if test="$nearest-informant"> | |
<xsl:choose> | |
<xsl:when test="$nearest-informant/cda:assignedEntity"> | |
<xsl:call-template name="AssignedEntity_To_String"> | |
<xsl:with-param name="entity" | |
select="$nearest-informant/cda:assignedEntity"/> | |
<xsl:with-param name="element-name" select="'source'"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$nearest-informant/cda:relatedEntity"> | |
<xsl:call-template name="RelatedEntity_To_String"> | |
<xsl:with-param name="entity" | |
select="$nearest-informant/cda:relatedEntity"/> | |
<xsl:with-param name="element-name" select="'source'"/> | |
</xsl:call-template> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:call-template name="AddRelatedItemReference"/> | |
<xsl:if test="./cda:id/@root != ''"> | |
<client-thing-id> | |
<xsl:value-of select="./cda:id/@root"/> | |
</client-thing-id> | |
</xsl:if> | |
</common> | |
</xsl:template> | |
<xsl:template name="FindNearestInformant"> | |
<xsl:param name="node"/> | |
<xsl:choose> | |
<xsl:when test="$node/cda:informant"> | |
<xsl:copy-of select="$node/cda:informant"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:if test="$node and local-name($node) != 'ClinicalDocument'"> | |
<xsl:call-template name="FindNearestInformant"> | |
<xsl:with-param name="node" select="$node/.."/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="AddRelatedItemReference"> | |
<xsl:if test="$thingid"> | |
<related-thing> | |
<thing-id> | |
<xsl:value-of select="$thingid"/> | |
</thing-id> | |
<xsl:if test="$version"> | |
<version-stamp> | |
<xsl:value-of select="$version"/> | |
</version-stamp> | |
</xsl:if> | |
<relationship-type>Extracted from CCD</relationship-type> | |
</related-thing> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="AssignedEntity_To_String"> | |
<xsl:param name="entity"/> | |
<xsl:param name="element-name"/> | |
<xsl:variable name="person-nodes"> | |
<xsl:call-template name="PersonFromCCDAssignedEntity"> | |
<xsl:with-param name="entity" select="$entity"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="person" select="msxsl:node-set($person-nodes)"/> | |
<xsl:if test="$person/name/full or $person/organization"> | |
<xsl:element name="{$element-name}"> | |
<xsl:if test="$person/name/full"> | |
<xsl:value-of select="$person/name/full"/> | |
</xsl:if> | |
<xsl:if test="$person/organization"> | |
<xsl:if test="$person/name/full"> | |
<xsl:text xml:space="preserve">, </xsl:text> | |
</xsl:if> | |
<xsl:value-of select="$person/organization"/> | |
</xsl:if> | |
</xsl:element> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="RelatedEntity_To_String"> | |
<xsl:param name="entity"/> | |
<xsl:param name="element-name"/> | |
<xsl:if test="$entity/cda:relatedPerson/cda:name"> | |
<xsl:variable name="name-nodes"> | |
<xsl:call-template name="NameFromCCDName"> | |
<xsl:with-param name="name" select="$entity/cda:relatedPerson/cda:name"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="name" select="msxsl:node-set($name-nodes)"/> | |
<xsl:element name="{$element-name}"> | |
<xsl:value-of select="$name/name/full"/> | |
</xsl:element> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="PN_To_String"> | |
<xsl:param name="pn"/> | |
<xsl:if test="$pn"> | |
<xsl:variable name="name-nodes"> | |
<xsl:call-template name="NameFromCCDName"> | |
<xsl:with-param name="name" select="$pn"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="name" select="msxsl:node-set($name-nodes)"/> | |
<xsl:value-of select="$name/name/full"/> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="ValueToGeneralMeasurement"> | |
<xsl:param name="value"/> | |
<xsl:param name="reference-text"/> | |
<xsl:choose> | |
<xsl:when test="$value/@xsi:type = 'PQ'"> | |
<xsl:call-template name="PQValueToGeneralMeasurement"> | |
<xsl:with-param name="value" select="$value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'ED'"> | |
<display> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="$value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</display> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'ST'"> | |
<display> | |
<xsl:value-of select="$value"/> | |
</display> | |
</xsl:when> | |
<xsl:when test="$value/@value"> | |
<display> | |
<xsl:value-of select="$value/@value"/> | |
</display> | |
</xsl:when> | |
<xsl:otherwise> | |
<display> | |
<xsl:text>Unknown</xsl:text> | |
</display> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="PQValueToGeneralMeasurement"> | |
<xsl:param name="value"/> | |
<xsl:param name="reference-text"/> | |
<display> | |
<xsl:choose> | |
<xsl:when test="$value/@value"> | |
<xsl:value-of select="$value/@value"/> | |
<xsl:if test="$value/@unit"> | |
<xsl:text xml:space="preserve"> </xsl:text> | |
<xsl:value-of select="$value/@unit"/> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:if test="$value/text()"> | |
<xsl:value-of select="$value"/> | |
</xsl:if> | |
</xsl:otherwise> | |
</xsl:choose> | |
</display> | |
<xsl:if test="$value/@value and $value/@unit"> | |
<structured> | |
<value> | |
<xsl:value-of select="$value/@value"/> | |
</value> | |
<units> | |
<text> | |
<xsl:value-of select="$value/@unit"/> | |
</text> | |
</units> | |
</structured> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="PQ_To_display-value"> | |
<xsl:param name="pq"/> | |
<xsl:variable name="unitXml" select="$v_measure/*[h:lc(./ucum) = h:lc($pq/@unit)]"/> | |
<xsl:variable name="unit" select="msxsl:node-set($unitXml)"/> | |
<xsl:choose> | |
<xsl:when test="$unit"> | |
<display> | |
<xsl:attribute name="units"> | |
<xsl:value-of select="$unit/export"/> | |
</xsl:attribute> | |
<xsl:attribute name="text"> | |
<xsl:value-of select="$pq/@value"/> | |
<xsl:text xml:space="preserve"> </xsl:text> | |
<xsl:value-of select="$unit/export"/> | |
</xsl:attribute> | |
<xsl:value-of select="$pq/@value"/> | |
</display> | |
</xsl:when> | |
<xsl:otherwise> | |
<display> | |
<xsl:attribute name="units"> | |
<xsl:value-of select="$pq/@unit"/> | |
</xsl:attribute> | |
<xsl:attribute name="text"> | |
<xsl:value-of select="$pq/@value"/> | |
<xsl:text xml:space="preserve"> </xsl:text> | |
<xsl:value-of select="$pq/@unit"/> | |
</xsl:attribute> | |
<xsl:value-of select="$pq/@value"/> | |
</display> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="PIVL_TS-to-general-measurement"> | |
<xsl:param name="effectiveTime"/> | |
<xsl:choose> | |
<xsl:when test="$effectiveTime/cda:period"> | |
<display> | |
<xsl:value-of select="$effectiveTime/cda:period/@value"/> | |
<xsl:if test="$effectiveTime/cda:period/@unit"> | |
<xsl:text xml:space="preserve"> </xsl:text> | |
<xsl:value-of select="$effectiveTime/cda:period/@unit"/> | |
</xsl:if> | |
</display> | |
<xsl:if test="$effectiveTime/cda:period/@value and $effectiveTime/cda:period/@unit"> | |
<structured> | |
<value> | |
<xsl:value-of select="$effectiveTime/cda:period/@value"/> | |
</value> | |
<units> | |
<text> | |
<xsl:value-of select="$effectiveTime/cda:period/@unit"/> | |
</text> | |
</units> | |
</structured> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<display>Unknown</display> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="StringFromAny"> | |
<xsl:param name="value"/> | |
<xsl:param name="reference-text"/> | |
<xsl:choose> | |
<xsl:when test="$value/@xsi:type = 'IVL_PQ'"> | |
<xsl:value-of select="$value/cda:low/@value"/> | |
<xsl:if test="$value/cda:low/@unit"> | |
<xsl:text xml:space="preserve"> </xsl:text> | |
<xsl:value-of select="$value/cda:low/@unit"/> | |
</xsl:if> | |
<xsl:text xml:space="preserve">-</xsl:text> | |
<xsl:value-of select="$value/cda:high/@value"/> | |
<xsl:if test="$value/cda:high/@unit"> | |
<xsl:text xml:space="preserve"> </xsl:text> | |
<xsl:value-of select="$value/cda:high/@unit"/> | |
</xsl:if> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'ED'"> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="$value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'ST'"> | |
<xsl:value-of select="$value"/> | |
</xsl:when> | |
<xsl:when test="$value/@xsi:type = 'CD' or $value/@xsi:type = 'CE'"> | |
<xsl:call-template name="StringFromCD"> | |
<xsl:with-param name="value" select="$value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$value/@value"> | |
<xsl:value-of select="$value/@value"/> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="StringFromED"> | |
<xsl:param name="value"/> | |
<xsl:param name="reference-text"/> | |
<xsl:choose> | |
<xsl:when test="$value/cda:reference/@value and $reference-text"> | |
<xsl:call-template name="GetFromTextById"> | |
<xsl:with-param name="text" select="$reference-text"/> | |
<xsl:with-param name="id" select="$value/cda:reference/@value"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$value"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="StringFromCD"> | |
<xsl:param name="value"/> | |
<xsl:param name="reference-text"/> | |
<xsl:choose> | |
<xsl:when test="$value/@displayName"> | |
<xsl:value-of select="$value/@displayName"/> | |
</xsl:when> | |
<xsl:when test="$value/cda:originalText"> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="$value"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:when test="$value/@code"> | |
<xsl:value-of select="$value/@code"/> | |
</xsl:when> | |
<xsl:when test="$value/cda:translation"> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="$value/cda:translation"/> | |
<xsl:with-param name="reference-text" select="$reference-text"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:text>Unknown</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="Value_To_weight"> | |
<xsl:param name="value"/> | |
<xsl:variable name="units" select="h:lc(string($value/@unit))"/> | |
<xsl:variable name="numValue" select="number($value/@value)"/> | |
<xsl:choose> | |
<xsl:when test="$units != '' and string($numValue) != 'NaN' and $numValue > 0"> | |
<xsl:choose> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/pounds/import) or h:lc($units) = h:lc($v_measure/pounds/ucum)"> | |
<xsl:value-of select="round(($numValue div 2.2046226) * 1000) div 1000"/> | |
</xsl:when> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/ounces/import) or h:lc($units) = h:lc($v_measure/ounces/ucum)"> | |
<xsl:value-of select="round(($numValue div (16 * 2.2) * 1000)) div 1000"/> | |
</xsl:when> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/kilos/import) or h:lc($units) = h:lc($v_measure/kilos/ucum)"> | |
<xsl:value-of select="$numValue"/> | |
</xsl:when> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/grams/import) or h:lc($units) = h:lc($v_measure/grams/ucum)"> | |
<xsl:value-of select="$numValue div 1000"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="Value_To_height"> | |
<xsl:param name="value"/> | |
<xsl:variable name="units" select="h:lc(string($value/@unit))"/> | |
<xsl:variable name="numValue" select="number($value/@value)"/> | |
<xsl:choose> | |
<xsl:when test="$units != '' and $numValue != 'NaN'"> | |
<xsl:choose> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/inches/import) or h:lc($units) = h:lc($v_measure/inches/ucum)"> | |
<xsl:value-of select="$numValue * 0.0254"/> | |
</xsl:when> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/feet/import) or h:lc($units) = h:lc($v_measure/feet/ucum)"> | |
<xsl:value-of select="$numValue * 12 * 0.0254"/> | |
</xsl:when> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/meters/import) or h:lc($units) = h:lc($v_measure/meters/ucum)"> | |
<xsl:value-of select="$numValue"/> | |
</xsl:when> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/centimeters/import) or h:lc($units) = h:lc($v_measure/centimeters/ucum)"> | |
<xsl:value-of select="$numValue div 100"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="Value_To_mmolPerL"> | |
<xsl:param name="value"/> | |
<xsl:variable name="units" select="h:lc(string($value/@unit))"/> | |
<xsl:variable name="numValue" select="number($value/@value)"/> | |
<xsl:choose> | |
<xsl:when test="$units != '' and string($numValue) != 'NaN'"> | |
<xsl:choose> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/millimoles-per-liter/import) or h:lc($units) = h:lc($v_measure/millimoles-per-liter/ucum)"> | |
<xsl:value-of select="$numValue"/> | |
</xsl:when> | |
<xsl:when | |
test="h:lc($units) = h:lc($v_measure/milligrams-per-deciliter/import) or h:lc($units) = h:lc($v_measure/milligrams-per-deciliter/ucum)"> | |
<xsl:value-of select="$numValue div 18"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:call-template name="Throw"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="GetMatchingObservation"> | |
<xsl:param name="observations"/> | |
<xsl:param name="concept"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$observations"> | |
<xsl:variable name="codeText"> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="cda:code/cda:originalText"/> | |
<xsl:with-param name="reference-text" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:if | |
test="
 (h:lc(./cda:code/@code) = $concept/import-code/code and 
 h:lc(./cda:code/@codeSystem) = $concept/import-code/codeSystem) or
 h:lc(./cda:code/@displayName) = $concept/import or
 h:lc($codeText) = $concept/import"> | |
<xsl:copy-of select="."/> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="GetMatchingObservationsFromOrganizer"> | |
<xsl:param name="organizer"/> | |
<xsl:param name="concept"/> | |
<xsl:param name="narrative-block"/> | |
<xsl:for-each select="$organizer"> | |
<xsl:variable name="codeText"> | |
<xsl:call-template name="StringFromED"> | |
<xsl:with-param name="value" select="$organizer/cda:code"/> | |
<xsl:with-param name="reference-text" select="$narrative-block"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:if | |
test="
 (h:lc(./cda:code/@code) = h:lc($concept/import-code/code) and 
 h:lc(./cda:code/@codeSystem) = h:lc($concept/import-code/codeSystem)) or
 h:lc(./cda:code/@displayName) = h:lc($concept/import) or
 h:lc($codeText) = h:lc($concept/import)"> | |
<xsl:copy-of select="cda:component/cda:observation"/> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<msxsl:script implements-prefix="h" language="C#"><![CDATA[ | |
public string lc(string value) | |
{ | |
return value.ToLower(); | |
} | |
public string lf() | |
{ | |
return "\n"; | |
} | |
public string uniqueID() | |
{ | |
return Guid.NewGuid().ToString("N"); | |
} | |
]]> | |
</msxsl:script> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment