source: ccr2ccd-xslt/trunk/templates/ccddatetime.xsl@ 759

Last change on this file since 759 was 759, checked in by Richard Braman, 14 years ago

add files from Ken Miller

File size: 7.8 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="urn:hl7-org:v3" xmlns:a="urn:astm-org:CCR" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="a date">
3 <!-- Converts the CCR DateTime to CCD effectiveTime. Only ExactDateTime is supported (both alone and in DateTimeRange). -->
4 <xsl:import href="../lib/date.format-date.template.xsl"/>
5 <xsl:template name="ccdDateTime">
6 <xsl:param name="dt"/>
7 <xsl:param name="type"/>
8 <xsl:if test="$dt">
9 <xsl:if test="$dt[1]/a:ExactDateTime">
10 <effectiveTime>
11 <xsl:if test="$type">
12 <xsl:attribute name="xsi:type">
13 <xsl:value-of select="$type"></xsl:value-of>
14 </xsl:attribute>
15 </xsl:if>
16 <low>
17 <xsl:attribute name="value">
18 <xsl:call-template name="date:format-date">
19 <xsl:with-param name="date-time">
20 <xsl:value-of select="$dt[1]/a:ExactDateTime"/>
21 </xsl:with-param>
22 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
23 </xsl:call-template>
24 </xsl:attribute>
25 </low>
26 <high nullFlavor="UNK"/>
27 </effectiveTime>
28 </xsl:if>
29 <xsl:if test="$dt[1]/a:DateTimeRange">
30 <effectiveTime>
31 <low>
32 <xsl:attribute name="value">
33 <xsl:call-template name="date:format-date">
34 <xsl:with-param name="date-time">
35 <xsl:value-of select="$dt[1]/a:DateTimeRange/a:BeginRange/a:ExactDateTime"/>
36 </xsl:with-param>
37 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
38 </xsl:call-template>
39 </xsl:attribute>
40 </low>
41 <high>
42 <xsl:attribute name="value">
43 <xsl:call-template name="date:format-date">
44 <xsl:with-param name="date-time">
45 <xsl:value-of select="$dt[1]/a:DateTimeRange/a:EndRange/a:ExactDateTime"/>
46 </xsl:with-param>
47 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
48 </xsl:call-template>
49 </xsl:attribute>
50 </high>
51 </effectiveTime>
52 </xsl:if>
53 </xsl:if>
54 </xsl:template>
55
56 <xsl:template name="dateTime" match="a:DateTime">
57 <xsl:param name="dt" select="."/>
58 <xsl:param name="fmt">MMM dd, yyyy</xsl:param>
59 <xsl:for-each select="$dt">
60 <tr>
61 <xsl:if test="$dt/a:Type/a:Text">
62 <td>
63 <xsl:value-of select="a:Type/a:Text"/>:
64 </td>
65 </xsl:if>
66 <xsl:choose>
67 <xsl:when test="a:ExactDateTime">
68 <td>
69 <xsl:call-template name="date:format-date">
70 <xsl:with-param name="date-time">
71 <xsl:value-of select="a:ExactDateTime"/>
72 </xsl:with-param>
73 <xsl:with-param name="pattern" select="$fmt"/>
74 </xsl:call-template>
75 </td>
76 </xsl:when>
77 <xsl:when test="$dt/a:Age">
78 <td>
79 <xsl:value-of select="$dt/a:Age/a:Value"/>
80 <xsl:text xml:space="preserve"> </xsl:text>
81 <xsl:value-of select="$dt/a:Age/a:Units/a:Unit"/>
82 </td>
83 </xsl:when>
84 <xsl:when test="$dt/a:ApproximateDateTime">
85 <td>
86 <xsl:value-of select="$dt/a:ApproximateDateTime/a:Text"/>
87 </td>
88 </xsl:when>
89 <xsl:when test="$dt/a:DateTimeRange">
90 <td>
91 <xsl:for-each select="$dt/a:DateTimeRange/a:BeginRange">
92 <xsl:choose>
93 <xsl:when test="$dt/a:ExactDateTime">
94 <xsl:call-template name="date:format-date">
95 <xsl:with-param name="date-time">
96 <xsl:value-of select="$dt/a:ExactDateTime"/>
97 </xsl:with-param>
98 <xsl:with-param name="pattern" select="$fmt"/>
99 </xsl:call-template>
100 </xsl:when>
101 <xsl:when test="$dt/a:Age">
102 <xsl:value-of select="$dt/a:Age/a:Value"/>
103 <xsl:text xml:space="preserve"> </xsl:text>
104 <xsl:value-of select="$dt/a:Age/a:Units/a:Unit"/>
105 </xsl:when>
106 <xsl:when test="$dt/a:ApproximateDateTime">
107 <xsl:value-of select="$dt/a:ApproximateDateTime/a:Text"/>
108 </xsl:when>
109 <xsl:otherwise/>
110 </xsl:choose>
111 </xsl:for-each><xsl:text xml:space="preserve"> </xsl:text>
112 -<xsl:text xml:space="preserve"> </xsl:text>
113 <xsl:for-each select="$dt/a:DateTimeRange/a:EndRange">
114 <xsl:choose>
115 <xsl:when test="$dt/a:ExactDateTime">
116 <xsl:call-template name="date:format-date">
117 <xsl:with-param name="date-time">
118 <xsl:value-of select="$dt/a:ExactDateTime"/>
119 </xsl:with-param>
120 <xsl:with-param name="pattern" select="$fmt"/>
121 </xsl:call-template>
122 </xsl:when>
123 <xsl:when test="$dt/a:Age">
124 <xsl:value-of select="$dt/a:Age/a:Value"/>
125 <xsl:text xml:space="preserve"> </xsl:text>
126 <xsl:value-of select="$dt/a:Age/a:Units/a:Unit"/>
127 </xsl:when>
128 <xsl:when test="$dt/a:ApproximateDateTime">
129 <xsl:value-of select="$dt/a:ApproximateDateTime/a:Text"/>
130 </xsl:when>
131 <xsl:otherwise/>
132 </xsl:choose>
133 </xsl:for-each>
134 </td>
135 </xsl:when>
136 <xsl:otherwise/>
137 </xsl:choose>
138 </tr>
139 </xsl:for-each>
140 </xsl:template>
141</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.