source: ccr2ccd-xslt/trunk/ccr_ccd.xsl@ 798

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

fixed a few bugs related to title, and some formatting issues. Need to review with Ken Miller to ensure changes meet spec.

File size: 159.1 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3Conversion of CCR to Level 3 CCD
4
5Orginal Author: Ken Miller
6Solventus LLC
7ken.miller@solventus.coms
8
9Contributors:
10Richard Braman, EHR Doctors, Inc rbraman@ehrdoctors.com
11George Lilly (WorldVistA glilly@glilly.net)
12xxxx - Oroville Hospital
13
14Date: 2010-05-5
15Version: 0.1
16
17License :
18
19 This program is free software: you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation, either version 3 of the License, or
22 (at your option) any later version.
23
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
28
29 You should have received a copy of the GNU General Public License
30 along with this program. If not, see http://www.gnu.org/licenses.
31
32-->
33<xsl:stylesheet version="1.0" xmlns="urn:hl7-org:v3" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:astm-org:CCR" xmlns:date="http://exslt.org/dates-and-times"
34xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="a date">
35 <xsl:import href="./templates/cdavocablookup.xsl"/>
36 <xsl:import href="./templates/hl7oidlookup.xsl"/>
37 <xsl:import href="./templates/code.xsl"/>
38 <xsl:import href="./templates/actor.xsl"/>
39 <xsl:import href="./templates/datetime.xsl"/>
40 <xsl:import href="./templates/problemDescription.xsl"/>
41
42 <xsl:output method="xml" encoding="utf-8" version="1.0" indent="yes"/>
43 <xsl:template match="/">
44 <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:sdtc="urn:hl7-org:sdtc" xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd" classCode="DOCCLIN" moodCode="EVN">
45 <realmCode code="US"/>
46 <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
47 <templateId root="2.16.840.1.113883.10.20.1"/>
48 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.1.1"/>
49 <templateId root="2.16.840.1.113883.10.20.3"/>
50 <templateId root="2.16.840.1.113883.3.88.11.32.1"/>
51
52 <id>
53 <xsl:attribute name="root">
54 <xsl:value-of select="/a:ContinuityOfCareRecord/a:CCRDocumentObjectID"></xsl:value-of>
55 </xsl:attribute>
56 </id>
57 <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Summarization of episode note"/>
58 <xsl:variable name="fromID" select="/a:ContinuityOfCareRecord/a:From/a:ActorLink[1]/a:ActorID"/>
59 <xsl:variable name="ccrFromActorObjectID" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$fromID]/a:InternalCCRLink[a:LinkRelationship='representedOrganization']/a:LinkID"/>
60 <title>Continuity of Care Document from <xsl:value-of select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrFromActorObjectID]/a:Organization/a:Name"/></title>
61 <effectiveTime>
62 <xsl:attribute name="value">
63 <xsl:call-template name="date:format-date">
64 <xsl:with-param name="date-time" select="/a:ContinuityOfCareRecord/a:DateTime/a:ExactDateTime"/>
65 <xsl:with-param name="pattern">yyyyMMddhhmmss+0000</xsl:with-param>
66 </xsl:call-template>
67 </xsl:attribute>
68 </effectiveTime>
69 <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/>
70 <languageCode code="en-US"/>
71
72 <recordTarget typeCode="RCT" contextControlCode="OP">
73 <xsl:call-template name="ccdPatientRole">
74 <xsl:with-param name="ccrActorObjectID" select="/a:ContinuityOfCareRecord/a:Patient[1]/a:ActorID"/>
75 </xsl:call-template>
76 </recordTarget>
77
78
79 <author>
80 <time>
81 <xsl:attribute name="value">
82 <xsl:call-template name="date:format-date">
83 <xsl:with-param name="date-time" select="/a:ContinuityOfCareRecord/a:DateTime/a:ExactDateTime"/>
84 <xsl:with-param name="pattern">yyyyMMddhhmmss</xsl:with-param>
85 </xsl:call-template>
86 </xsl:attribute>
87 </time>
88 <xsl:call-template name="ccdAssignedAuthor">
89 <xsl:with-param name="ccrActorObjectID" select="$fromID"/>
90 </xsl:call-template>
91 </author>
92
93 <xsl:if test="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$fromID]/a:InternalCCRLink[a:LinkRelationship='representedOrganization']">
94 <custodian>
95 <assignedCustodian>
96 <xsl:call-template name="ccdOrganization">
97 <xsl:with-param name="ccrActorObjectID" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$fromID]/a:InternalCCRLink[a:LinkRelationship='representedOrganization']/a:LinkID"/>
98 <xsl:with-param name="organizationNodeName" select="'representedCustodianOrganization'"/>
99 </xsl:call-template>
100 </assignedCustodian>
101 </custodian>
102 </xsl:if>
103
104 <documentationOf>
105 <serviceEvent classCode="PCPR">
106 <effectiveTime>
107 <low>
108 <xsl:attribute name="value">
109 <xsl:call-template name="date:format-date">
110 <xsl:with-param name="date-time">
111 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body//a:DateTime//a:ExactDateTime">
112 <xsl:sort order="ascending"/>
113 <xsl:if test="position()=1">
114 <xsl:value-of select="."/>
115 </xsl:if>
116 </xsl:for-each>
117 </xsl:with-param>
118 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
119 </xsl:call-template>
120 </xsl:attribute>
121 </low>
122 <high>
123 <xsl:attribute name="value">
124 <xsl:call-template name="date:format-date">
125 <xsl:with-param name="date-time">
126 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body//a:DateTime//a:ExactDateTime">
127 <xsl:sort order="descending"/>
128 <xsl:if test="position()=1">
129 <xsl:value-of select="."/>
130 </xsl:if>
131 </xsl:for-each>
132 </xsl:with-param>
133 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
134 </xsl:call-template>
135 </xsl:attribute>
136 </high>
137 </effectiveTime>
138 </serviceEvent>
139
140 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders/a:Provider">
141 <xsl:call-template name="ccdAssignedEntity">
142 <xsl:with-param name="ccrActorObjectID" select="a:ActorID"/>
143 </xsl:call-template>
144 </xsl:for-each>
145
146 </documentationOf>
147
148 <component>
149 <structuredBody>
150 <component>
151 <section>
152 <templateId root="2.16.840.1.113883.10.20.1.13"/>
153 <code code="48764-5" codeSystem="2.16.840.1.113883.6.1" />
154 <title>Purpose</title>
155 <text>
156 <xsl:value-of select="/a:ContinuityOfCareRecord/a:Purpose/a:Description/a:Text"></xsl:value-of>
157 </text>
158 </section>
159 </component>
160 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Alerts">
161 <component>
162 <section>
163 <templateId root="2.16.840.1.113883.10.20.1.2"/>
164 <code code="46240-8" codeSystem="2.16.840.1.113883.6.1"/>
165 <title>Alerts</title>
166 <text>
167 <table>
168 <tbody>
169 <tr>
170 <th>Type</th>
171 <th>Date</th>
172 <th>Code</th>
173 <th>Description</th>
174 <th>Reaction</th>
175 <th>Source</th>
176 </tr>
177 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Alerts/a:Alert">
178 <tr>
179 <xsl:attribute name="id">
180 <xsl:value-of select="a:CCRDataObjectID"/>
181 </xsl:attribute>
182
183 <td>
184 <xsl:value-of select="a:Type/a:Text"/>
185 </td>
186 <td>
187 <xsl:call-template name="date:format-date">
188 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
189 </xsl:call-template>
190 </td>
191 <td>
192 <xsl:apply-templates select="a:Description/a:Code"/>
193 </td>
194 <td>
195 <xsl:value-of select="a:Description/a:Text"/>
196 </td>
197 <td>
198 <xsl:value-of select="a:Reaction/a:Description/a:Text"/>
199 <xsl:if test="a:Reaction/a:Severity/a:Text">
200 -<xsl:value-of select="a:Reaction/a:Severity/a:Text"/>
201 </xsl:if>
202 </td>
203 <td>
204 <xsl:call-template name="actorName">
205 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
206 </xsl:call-template>
207 </td>
208 </tr>
209 </xsl:for-each>
210 </tbody>
211 </table>
212 </text>
213 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Alerts/a:Alert">
214 <entry typeCode="DRIV">
215 <act classCode="ACT" moodCode="EVN">
216 <templateId root="2.16.840.1.113883.10.20.1.27"/>
217 <!--Allergy act template -->
218
219 <!-- <id> -->
220 <xsl:call-template name="ccdID">
221 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
222 </xsl:call-template>
223
224 <code nullFlavor="NA"/>
225 <entryRelationship typeCode="SUBJ">
226 <observation classCode="OBS" moodCode="EVN">
227 <templateId root="2.16.840.1.113883.10.20.1.18"/>
228
229 <!-- <id> -->
230 <xsl:call-template name="ccdID">
231 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
232 <xsl:with-param name="suffix">.1</xsl:with-param>
233 </xsl:call-template>
234
235 <code code="416098002" codeSystem="2.16.840.1.113883.6.96" displayName="drug allergy" codeSystemName="SNOMED CT"/>
236
237 <text>
238 <reference>
239 <xsl:attribute name="value">
240 <xsl:text>#</xsl:text>
241 <xsl:value-of select="a:CCRDataObjectID"/>
242 </xsl:attribute>
243 </reference>
244 </text>
245
246 <statusCode code="completed"/>
247
248 <participant typeCode="CSM">
249 <xsl:choose>
250 <xsl:when test="a:Product/a:Description">
251 <xsl:call-template name="ccdParticipantRoleCodedDescription">
252 <xsl:with-param name="ccrCodedDescription" select="a:Product/a:Description"/>
253 </xsl:call-template>
254 </xsl:when>
255 <xsl:otherwise>
256 <xsl:call-template name="ccdParticipantRoleCodedDescription">
257 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
258 </xsl:call-template>
259 </xsl:otherwise>
260 </xsl:choose>
261 </participant>
262
263 <xsl:if test="a:Reaction">
264 <entryRelationship typeCode="MFST" inversionInd="true">
265 <observation classCode="OBS" moodCode="EVN">
266 <templateId root="2.16.840.1.113883.10.20.1.54"/>
267 <!--Reaction observation template -->
268 <code code="ASSERTION" codeSystem="2.16.840.1.113883.5.4"/>
269 <statusCode code="completed"/>
270 <xsl:call-template name="ccdCodedValue">
271 <xsl:with-param name="ccrCodedDescription" select="a:Reaction/a:Description"/>
272 </xsl:call-template>
273 </observation>
274 </entryRelationship>
275 </xsl:if>
276
277 <xsl:call-template name="ccdStatus">
278 <xsl:with-param name="ccrStatus" select="a:Status"/>
279 </xsl:call-template>
280
281 </observation>
282 </entryRelationship>
283 </act>
284 </entry>
285 </xsl:for-each>
286 </section>
287 </component>
288 </xsl:if>
289 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:AdvanceDirectives">
290 <component>
291 <section>
292 <templateId root="2.16.840.1.113883.10.20.1.1"/>
293 <code code="42348-3" codeSystem="2.16.840.1.113883.6.1"/>
294 <title>Advance Directives</title>
295 <text>
296 <table>
297 <tbody>
298 <tr>
299 <th>Type</th>
300 <th>Date</th>
301 <th>Description</th>
302 <th>Status</th>
303 <th>Source</th>
304 </tr>
305 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:AdvanceDirectives/a:AdvanceDirective">
306 <tr>
307 <td>
308 <xsl:value-of select="a:Type/a:Text"/>
309 </td>
310 <td>
311 <xsl:call-template name="date:format-date">
312 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
313 </xsl:call-template>
314 </td>
315 <td>
316 <xsl:value-of select="a:Description/a:Text"/>
317 </td>
318 <td>
319 <xsl:value-of select="a:Status/a:Text"/>
320 </td>
321 <td>
322 <xsl:call-template name="actorName">
323 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
324 </xsl:call-template>
325 </td>
326 </tr>
327 </xsl:for-each>
328 </tbody>
329 </table>
330
331 </text>
332 </section>
333 </component>
334 </xsl:if>
335 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:FunctionalStatus">
336 <component>
337 <section>
338 <templateId root="2.16.840.1.113883.10.20.1.5"/>
339 <code code="47420-5" codeSystem="2.16.840.1.113883.6.1"/>
340 <title>Functional Status</title>
341 <text>
342 <table>
343 <tbody>
344 <tr>
345 <th>Type</th>
346 <th>Date</th>
347 <th>Code</th>
348 <th>Description</th>
349 <th>Status</th>
350 <th>Source</th>
351 </tr>
352 <tr>
353 <td>
354 <xsl:value-of select="a:Type/a:Text"/>
355 </td>
356 <td>
357 <xsl:call-template name="date:format-date">
358 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
359 </xsl:call-template>
360 </td>
361 <td>
362 <xsl:apply-templates select="a:Description/a:Code"/>
363 </td>
364 <td>
365 <xsl:value-of select="a:Description/a:Text"/>
366 </td>
367 <td>
368 <xsl:value-of select="a:Status/a:Text"/>
369 </td>
370 <td>
371 <xsl:call-template name="actorName">
372 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
373 </xsl:call-template>
374 </td>
375 </tr>
376 </tbody>
377 </table>
378 </text>
379 </section>
380 </component>
381 </xsl:if>
382 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Problems">
383 <component>
384 <section>
385 <templateId root="2.16.840.1.113883.3.88.11.83.103" assigningAuthorityName="HITSP/C83"/>
386 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.6" assigningAuthorityName="IHE PCC"/>
387 <templateId root="2.16.840.1.113883.10.20.1.11" assigningAuthorityName="HL7 CCD"/>
388 <code code="11450-4" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Problem list"/>
389 <title>Problems</title>
390 <text>
391 <table>
392 <tbody>
393 <tr>
394 <th>Type</th>
395 <th>Date</th>
396 <th>Code</th>
397 <th>Description</th>
398 <th>Status</th>
399 <th>Source</th>
400 </tr>
401 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
402 <tr>
403 <td>
404 <xsl:value-of select="a:Type/a:Text"/>
405 </td>
406 <xsl:apply-templates select="a:DateTime"/>
407 <td>
408 <xsl:apply-templates select="a:Description/a:Code"/>
409 </td>
410 <td>
411 <xsl:attribute name="ID">
412 <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
413 </xsl:attribute>
414 <xsl:value-of select="a:Description/a:Text"/>
415 </td>
416 <td>
417 <xsl:value-of select="a:Status/a:Text"/>
418 </td>
419 <td>
420 <xsl:call-template name="actorName">
421 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
422 </xsl:call-template>
423 </td>
424 </tr>
425 </xsl:for-each>
426 </tbody>
427 </table>
428 </text>
429 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
430 <entry typeCode="DRIV">
431 <act classCode="ACT" moodCode="EVN">
432 <templateId root="2.16.840.1.113883.10.20.1.27"/>
433 <!-- Problem act template -->
434
435 <!-- <id> -->
436 <xsl:call-template name="ccdID">
437 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
438 </xsl:call-template>
439
440 <code nullFlavor="NA"/>
441
442 <xsl:call-template name="ccdPerformer">
443 <xsl:with-param name="ccrActorReference" select="a:Source/a:Actor"/>
444 </xsl:call-template>
445
446 <entryRelationship typeCode="SUBJ">
447 <observation classCode="OBS" moodCode="EVN">
448 <templateId root="2.16.840.1.113883.10.20.1.28" assigningAuthorityName="CCD"/>
449 <!--Problem observation template-->
450
451 <!-- <id> -->
452 <xsl:call-template name="ccdID">
453 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
454 <xsl:with-param name="suffix"></xsl:with-param>
455 </xsl:call-template>
456
457 <code code="64572001" displayName="Condition" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT"/>
458
459 <text>
460 <reference>
461 <xsl:attribute name="value">
462 <xsl:text>#</xsl:text>
463 <xsl:value-of select="a:CCRDataObjectID"/>
464 </xsl:attribute>
465 </reference>
466 </text>
467
468 <statusCode code="completed"/>
469
470 <xsl:call-template name="ccdDateTime">
471 <xsl:with-param name="dt" select="a:DateTime"/>
472 </xsl:call-template>
473
474 <xsl:call-template name="ccdCodedValue">
475 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
476 </xsl:call-template>
477
478 <xsl:call-template name="ccdStatus">
479 <xsl:with-param name="ccrStatus" select="a:Status"/>
480 </xsl:call-template>
481 </observation>
482 </entryRelationship>
483
484 </act>
485 </entry>
486 </xsl:for-each>
487 </section>
488 </component>
489 </xsl:if>
490 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Procedures">
491 <component>
492 <section>
493 <templateId root="2.16.840.1.113883.10.20.1.12"/>
494 <code code="47519-4" codeSystem="2.16.840.1.113883.6.1"/>
495 <title>Procedures</title>
496 <text>
497 <table>
498 <tbody>
499 <tr>
500 <th>Type</th>
501 <th>Date</th>
502 <th>Code</th>
503 <th>Description</th>
504 <th>Location</th>
505 <th>Substance</th>
506 <th>Method</th>
507 <th>Position</th>
508 <th>Site</th>
509 <th>Status</th>
510 <th>Source</th>
511 </tr>
512 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
513 <tr>
514 <xsl:attribute name="id">
515 <xsl:value-of select="a:CCRDataObjectID"/>
516 </xsl:attribute>
517
518 <td>
519 <xsl:value-of select="a:Type/a:Text"/>
520 </td>
521 <table>
522 <tbody>
523 <xsl:apply-templates select="a:DateTime"/>
524 </tbody>
525 </table>
526 <td>
527 <xsl:apply-templates select="a:Description/a:Code"/>
528 </td>
529 <td>
530 <xsl:value-of select="a:Description/a:Text"/>
531 </td>
532 <td>
533 <xsl:for-each select="a:Locations/a:Location">
534 <xsl:value-of select="a:Description/a:Text"/>
535 <xsl:if test="a:Actor">
536 (<xsl:call-template name="actorName">
537 <xsl:with-param name="objID" select="a:Actor/a:ActorID"/>
538 </xsl:call-template>
539 <xsl:if test="a:Actor/a:ActorRole/a:Text">
540 <xsl:text xml:space="preserve"> - </xsl:text><xsl:value-of select="a:ActorRole/a:Text"/>)
541 </xsl:if>
542 </xsl:if>)
543 <xsl:if test="position() != last()">
544 <br/>
545 </xsl:if>
546 </xsl:for-each>
547 </td>
548 <td>
549 <xsl:for-each select="a:Substance">
550 <xsl:value-of select="a:Text"/>
551 </xsl:for-each>
552 </td>
553 <td>
554 <xsl:value-of select="a:Method/a:Text"/>
555 </td>
556 <td>
557 <xsl:value-of select="a:Position/a:Text"/>
558 </td>
559 <td>
560 <xsl:value-of select="a:Site/a:Text"/>
561 </td>
562 <td>
563 <xsl:value-of select="a:Status/a:Text"/>
564 </td>
565 <td>
566 <xsl:call-template name="actorName">
567 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
568 </xsl:call-template>
569 </td>
570 </tr>
571 </xsl:for-each>
572 </tbody>
573 </table>
574 </text>
575
576 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
577 <entry typeCode="DRIV">
578 <procedure classCode="PROC" moodCode="EVN">
579 <templateId root="2.16.840.1.113883.3.88.11.83.17" assigningAuthorityName="HITSP C83"/>
580 <templateId root="2.16.840.1.113883.10.20.1.29" assigningAuthorityName="CCD"/>
581 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.19" assigningAuthorityName="IHE PCC"/>
582
583 <!-- <id> -->
584 <xsl:call-template name="ccdID">
585 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
586 </xsl:call-template>
587
588 <!-- <code> -->
589 <xsl:call-template name="ccdCodedValue">
590 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
591 <xsl:with-param name="nodeName" select="'code'"/>
592 </xsl:call-template>
593
594 <text>
595 <reference>
596 <xsl:attribute name="value">
597 <xsl:text>#</xsl:text>
598 <xsl:value-of select="a:CCRDataObjectID"/>
599 </xsl:attribute>
600 </reference>
601 </text>
602
603 <xsl:call-template name="ccdStatusProcedure">
604 <xsl:with-param name="status" select="a:Status"/>
605 </xsl:call-template>
606
607 <xsl:call-template name="ccdDateTime">
608 <xsl:with-param name="dt" select="a:DateTime"/>
609 </xsl:call-template>
610
611 <xsl:if test="a:Method">
612 <xsl:call-template name="ccdCodedValue">
613 <xsl:with-param name="ccrCodedDescription" select="a:Method"/>
614 <xsl:with-param name="nodeName" select="'approachSiteCode'"/>
615 </xsl:call-template>
616 </xsl:if>
617
618 <xsl:if test="a:Site">
619 <xsl:call-template name="ccdCodedValue">
620 <xsl:with-param name="ccrCodedDescription" select="a:Site"/>
621 <xsl:with-param name="nodeName" select="'targetSiteCode'"/>
622 </xsl:call-template>
623 </xsl:if>
624
625 <xsl:if test="a:Practitioners/a:Practitioner">
626 <xsl:call-template name="ccdPerformer">
627 <xsl:with-param name="ccrActorReference" select="a:Practitioners/a:Practitioner[1]"/>
628 </xsl:call-template>
629 </xsl:if>
630 </procedure>
631 </entry>
632 </xsl:for-each>
633 </section>
634 </component>
635 </xsl:if>
636 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Medications">
637 <component>
638 <section>
639 <templateId root="2.16.840.1.113883.3.88.11.83.112" assigningAuthorityName="HITSP/C83"/>
640 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.19" assigningAuthorityName="IHE PCC"/>
641 <templateId root="2.16.840.1.113883.10.20.1.8" assigningAuthorityName="HL7 CCD"/>
642 <!--Medications section template-->
643 <code code="10160-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="History of medication use"/>
644 <title>Medications</title>
645 <text>
646 <table>
647 <tbody>
648 <tr>
649 <th>Medication</th>
650 <th>Date</th>
651 <th>Status</th>
652 <th>Form</th>
653 <th>Strength</th>
654 <th>Quantity</th>
655 <th>SIG</th>
656 <th>Indications</th>
657 <th>Instruction</th>
658 <th>Refills</th>
659 <th>Source</th>
660 </tr>
661 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Medications/a:Medication">
662 <tr>
663 <td>
664 <xsl:value-of select="a:Product/a:ProductName/a:Text"/>
665 <xsl:if test="a:Product/a:BrandName">
666 <xsl:text xml:space="preserve"> </xsl:text>(<xsl:value-of select="a:Product/a:BrandName/a:Text"/>)
667 </xsl:if>
668 </td>
669 <td>
670 <xsl:call-template name="date:format-date">
671 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
672 </xsl:call-template>
673 </td>
674 <td>
675 <xsl:value-of select="a:Status/a:Text"/>
676 </td>
677 <td>
678 <xsl:value-of select="a:Product/a:Form/a:Text"/>
679 </td>
680 <td>
681 <xsl:for-each select="a:Product/a:Strength">
682 <xsl:if test="position() > 1">
683 <xsl:text>/</xsl:text>
684 </xsl:if>
685 <xsl:value-of select="a:Value"/>
686 <xsl:text xml:space="preserve"> </xsl:text>
687 <xsl:value-of select="a:Units/a:Unit"/>
688 </xsl:for-each>
689 </td>
690 <td>
691 <xsl:value-of select="a:Quantity/a:Value"/>
692 <xsl:text xml:space="preserve"> </xsl:text>
693 <xsl:value-of select="a:Quantity/a:Units/a:Unit"/>
694 </td>
695 <td>
696 <xsl:for-each select="a:Directions/a:Direction">
697 <xsl:choose>
698 <xsl:when test="a:Description/a:Text">
699 <xsl:value-of select="a:Description/a:Text"/>
700 </xsl:when>
701 <xsl:otherwise>
702 <xsl:value-of select="a:Dose/a:Value"/>
703 <xsl:text xml:space="preserve"> </xsl:text>
704 <xsl:value-of select="a:Dose/a:Units/a:Unit"/>
705 <xsl:text xml:space="preserve"> </xsl:text>
706 <xsl:value-of select="a:Route/a:Text"/>
707 <xsl:text xml:space="preserve"> </xsl:text>
708 <xsl:value-of select="a:Frequency/a:Value"/>
709 <xsl:if test="a:Duration">
710 <xsl:text xml:space="preserve">( </xsl:text>for <xsl:value-of select="a:Duration/a:Value"/><xsl:text xml:space="preserve"> </xsl:text><xsl:value-of select="a:Duration/a:Units/a:Unit"/><xsl:text xml:space="preserve"> )</xsl:text>
711 </xsl:if>
712 <xsl:if test="a:MultipleDirectionModifier/a:ObjectAttribute">
713 <xsl:for-each select="a:MultipleDirectionModifier/a:ObjectAttribute">
714 <xsl:value-of select="a:Attribute"/>
715 <br/>
716 <xsl:value-of select="a:AttributeValue/a:Value"/>
717 </xsl:for-each>
718 </xsl:if>
719 </xsl:otherwise>
720 </xsl:choose>
721 </xsl:for-each>
722 </td>
723 <td>
724 <xsl:for-each select="a:Directions/a:Direction[1]/a:Indication">
725 <xsl:call-template name="problemDescription">
726 <xsl:with-param name="objID" select="a:InternalCCRLink/a:LinkID"/>
727 </xsl:call-template>
728 <br/>
729 </xsl:for-each>
730 </td>
731 <td>
732 <xsl:for-each select="a:PatientInstructions/a:Instruction">
733 <xsl:value-of select="a:Text"/>
734 <br/>
735 </xsl:for-each>
736 </td>
737 <td>
738 <xsl:for-each select="a:Refills/a:Refill">
739 <xsl:value-of select="a:Number"/>
740 <xsl:text xml:space="preserve"> </xsl:text>
741 </xsl:for-each>
742 </td>
743 <td>
744 <xsl:call-template name="actorName">
745 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
746 </xsl:call-template>
747 </td>
748 </tr>
749 </xsl:for-each>
750 </tbody>
751 </table>
752 </text>
753 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Medications/a:Medication">
754 <entry typeCode="DRIV">
755 <substanceAdministration classCode="SBADM" moodCode="EVN">
756 <templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
757 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.1" assigningAuthorityName="IHE PCC"/>
758
759 <!--Medication activity template -->
760
761 <!-- <id> -->
762 <xsl:call-template name="ccdID">
763 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
764 </xsl:call-template>
765
766 <statusCode code='completed'/>
767
768 <xsl:call-template name="ccdDateTime">
769 <xsl:with-param name="dt" select="a:DateTime"/>
770 <xsl:with-param name="type" select="'IVL_TS'"/>
771 </xsl:call-template>
772
773 <xsl:call-template name="ccdMedicationFrequency">
774 <xsl:with-param name="frequency" select="a:Directions/a:Direction/a:Frequency"/>
775 </xsl:call-template>
776
777 <xsl:call-template name="ccdCodedValue">
778 <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Route"/>
779 <xsl:with-param name="nodeName" select="'routeCode'"/>
780 <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
781 </xsl:call-template>
782
783 <xsl:if test="a:Directions/a:Direction/a:Dose">
784 <doseQuantity>
785 <low>
786 <xsl:attribute name="value">
787 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
788 </xsl:attribute>
789 <xsl:attribute name="unit">
790 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
791 </xsl:attribute>
792 </low>
793 <high>
794 <xsl:attribute name="value">
795 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
796 </xsl:attribute>
797 <xsl:attribute name="unit">
798 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
799 </xsl:attribute>
800 </high>
801 </doseQuantity>
802 </xsl:if>
803 <consumable>
804 <manufacturedProduct>
805 <templateId root="2.16.840.1.113883.3.88.11.83.8.2" assigningAuthorityName="HITSP C83"/>
806 <templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
807 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
808
809 <!-- Product template -->
810
811 <manufacturedMaterial>
812 <xsl:call-template name="ccdCodedValue">
813 <xsl:with-param name="ccrCodedDescription" select="a:Product/a:ProductName"/>
814 <xsl:with-param name="nodeName" select="'code'"/>
815 <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
816 </xsl:call-template>
817 <name>
818 <xsl:value-of select="a:Product/a:BrandName/a:Text"></xsl:value-of>
819 </name>
820 </manufacturedMaterial>
821 </manufacturedProduct>
822 </consumable>
823 </substanceAdministration>
824 </entry>
825 </xsl:for-each>
826 </section>
827 </component>
828 </xsl:if>
829 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Immunizations">
830 <component>
831 <section>
832 <templateId root="2.16.840.1.113883.10.20.1.6"/>
833 <code code="11369-6" codeSystem="2.16.840.1.113883.6.1"/>
834 <title>Immunizations</title>
835 <text>
836 <table>
837 <tbody>
838 <tr>
839 <th>Code</th>
840 <th>Vaccine</th>
841 <th>Date</th>
842 <th>Route</th>
843 <th>Site</th>
844 <th>Source</th>
845 </tr>
846 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Immunizations/a:Immunization">
847 <tr>
848 <td>
849 <xsl:apply-templates select="a:Product/a:ProductName/a:Code"/>
850 </td>
851 <td>
852
853 <xsl:value-of select="a:Product/a:ProductName/a:Text"/>
854 <xsl:if test="a:Product/a:Form">
855 <xsl:text xml:space="preserve"> </xsl:text>(<xsl:value-of select="a:Product/a:Form/a:Text"/>)
856 </xsl:if>
857 </td>
858 <td>
859 <xsl:call-template name="date:format-date">
860 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
861 </xsl:call-template>
862 </td>
863 <td>
864 <xsl:value-of select="a:Directions/a:Direction/a:Route/a:Text"/>
865 </td>
866 <td>
867 <xsl:value-of select="a:Directions/a:Direction/a:Site/a:Text"/>
868 </td>
869 <td>
870 <xsl:call-template name="actorName">
871 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
872 </xsl:call-template>
873 </td>
874 </tr>
875 </xsl:for-each>
876 </tbody>
877 </table>
878 </text>
879 </section>
880 </component>
881 </xsl:if>
882 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:VitalSigns">
883 <component>
884 <section>
885 <templateId root="2.16.840.1.113883.10.20.1.16"/>
886 <code code="8716-3" codeSystem="2.16.840.1.113883.6.1"/>
887 <title>Vital Signs</title>
888 <text>
889 <table>
890 <tbody>
891 <tr>
892 <th>Vital Sign</th>
893 <th>Date</th>
894 <th>Result</th>
895 <th>Source</th>
896 </tr>
897 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:VitalSigns/a:Result">
898 <tr>
899 <td>
900 <xsl:value-of select="a:Description/a:Text"/>
901 </td>
902 <td>
903 <xsl:call-template name="date:format-date">
904 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
905 </xsl:call-template>
906 </td>
907 <td>
908 <xsl:for-each select="a:Test">
909 <xsl:value-of select="a:Description/a:Text"/>
910 <xsl:text xml:space="preserve"> </xsl:text>
911 <xsl:value-of select="a:TestResult/a:Value"/>
912 <xsl:text xml:space="preserve"> </xsl:text>
913 <xsl:value-of select="a:TestResult/a:Units/a:Unit"/>
914 <xsl:text xml:space="preserve"> </xsl:text>
915 <xsl:value-of select="a:Flag/a:Text"/>
916 <br/>
917 </xsl:for-each>
918 </td>
919 <td>
920 <xsl:call-template name="actorName">
921 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
922 </xsl:call-template>
923 </td>
924 </tr>
925 </xsl:for-each>
926 </tbody>
927 </table>
928 </text>
929 </section>
930 </component>
931 </xsl:if>
932 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Encounters">
933 <component>
934 <section>
935 <templateId root="2.16.840.1.113883.3.88.11.83.127" assigningAuthorityName="HITSP/C83"/>
936 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.1.5.3.3" assigningAuthorityName="IHE PCC"/>
937 <templateId root="2.16.840.1.113883.10.20.1.3" assigningAuthorityName="HL7 CCD"/>
938 <!--Encounters section template-->
939 <code code="46240-8" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="History of encounters"/>
940 <title>Encounters</title>
941 <text>
942 <table>
943 <tbody>
944 <tr>
945 <th>Type</th>
946 <th>Date</th>
947 <th>Location</th>
948 <th>Status</th>
949 <th>Practitioner</th>
950 <th>Description</th>
951 <th>Indications</th>
952 <th>Source</th>
953 </tr>
954 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Encounters/a:Encounter">
955 <tr>
956 <xsl:attribute name="id">
957 <xsl:value-of select="a:CCRDataObjectID"/>
958 </xsl:attribute>
959
960 <td>
961 <xsl:value-of select="a:Type/a:Text"/>
962 </td>
963 <td>
964 <xsl:call-template name="date:format-date">
965 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
966 </xsl:call-template>
967 </td>
968 <td>
969 <xsl:for-each select="a:Locations/a:Location">
970 <xsl:value-of select="a:Description/a:Text"/>
971 <xsl:call-template name="actorName">
972 <xsl:with-param name="objID" select="a:Actor/a:ActorID"/>
973 </xsl:call-template>
974 <br/>
975 </xsl:for-each>
976 </td>
977 <td>
978 <xsl:value-of select="a:Status/a:Text"/>
979 </td>
980 <td>
981 <xsl:for-each select="a:Practitioners/a:Practitioner">
982 <xsl:call-template name="actorName">
983 <xsl:with-param name="objID" select="a:ActorID"/>
984 </xsl:call-template>
985 <br/>
986 </xsl:for-each>
987 </td>
988 <td>
989 <xsl:value-of select="a:Description/a:Text"/>
990 </td>
991 <td>
992 <xsl:for-each select="a:Indications/a:Indication">
993 <xsl:call-template name="problemDescription">
994 <xsl:with-param name="objID" select="a:InternalCCRLink/a:LinkID"/>
995 </xsl:call-template>
996 <br/>
997 </xsl:for-each>
998 </td>
999 <td>
1000 <xsl:call-template name="actorName">
1001 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1002 </xsl:call-template>
1003 </td>
1004 </tr>
1005 </xsl:for-each>
1006 </tbody>
1007 </table>
1008 </text>
1009 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Encounters/a:Encounter">
1010 <entry typeCode="DRIV">
1011 <encounter classCode="ENC" moodCode="EVN">
1012 <templateId root="2.16.840.1.113883.3.88.11.83.16" assigningAuthorityName="HITSP C83"/>
1013 <templateId root="2.16.840.1.113883.10.20.1.21" assigningAuthorityName="CCD"/>
1014 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.14" assigningAuthorityName="IHE PCC"/>
1015
1016 <!-- Encounter activity template -->
1017
1018 <!-- <id> -->
1019 <xsl:call-template name="ccdID">
1020 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1021 </xsl:call-template>
1022
1023
1024 <xsl:call-template name="ccdCodedValue">
1025 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1026 <xsl:with-param name="nodeName" select="'code'"/>
1027 </xsl:call-template>
1028
1029 <text>
1030 <reference>
1031 <xsl:attribute name="value">
1032 <xsl:text>#</xsl:text>
1033 <xsl:value-of select="a:CCRDataObjectID"/>
1034 </xsl:attribute>
1035 </reference>
1036 </text>
1037
1038 <xsl:call-template name="ccdDateTime">
1039 <xsl:with-param name="dt" select="a:DateTime"/>
1040 </xsl:call-template>
1041
1042 <xsl:if test="a:Practitioners[1]/a:Practitioner">
1043 <xsl:call-template name="ccdPerformer">
1044 <xsl:with-param name="ccrActorReference" select="a:Practitioners/a:Practitioner[1]"/>
1045 </xsl:call-template>
1046 </xsl:if>
1047
1048 <xsl:if test="a:Locations[1]/a:Location">
1049 <participant typeCode="LOC">
1050 <templateId root="2.16.840.1.113883.10.20.1.45"/>
1051 <!-- Location participation template -->
1052 <xsl:choose>
1053 <xsl:when test="a:Locations[1]/a:Location/a:ActorID">
1054 <xsl:call-template name="ccdParticipantRoleActor">
1055 <xsl:with-param name="ccrActorObjectID" select="a:Locations[1]/a:Location/a:ActorID"/>
1056 </xsl:call-template>
1057 </xsl:when>
1058 <xsl:otherwise>
1059 <xsl:call-template name="ccdParticipantRoleCodedDescription">
1060 <xsl:with-param name="ccrCodedDescription" select="a:Locations[1]/a:Location/a:Description"/>
1061 </xsl:call-template>
1062 </xsl:otherwise>
1063 </xsl:choose>
1064 </participant>
1065 </xsl:if>
1066 </encounter>
1067 </entry>
1068 </xsl:for-each>
1069 </section>
1070 </component>
1071 </xsl:if>
1072 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:SocialHistory">
1073 <component>
1074 <section>
1075 <templateId root="2.16.840.1.113883.10.20.1.15"/>
1076 <code code="29762-2" codeSystem="2.16.840.1.113883.6.1"/>
1077 <title>Social History</title>
1078 <text>
1079 <table>
1080 <tbody>
1081 <tr>
1082 <th>Type</th>
1083 <th>Date</th>
1084 <th>Code</th>
1085 <th>Description</th>
1086 <th>Status</th>
1087 <th>Source</th>
1088 </tr>
1089 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement">
1090 <tr>
1091 <td>
1092 <xsl:value-of select="a:Type/a:Text"/>
1093 </td>
1094 <td>
1095 <xsl:call-template name="date:format-date">
1096 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1097 </xsl:call-template>
1098 </td>
1099 <td>
1100 <xsl:apply-templates select="a:Description/a:Code"/>
1101 </td>
1102 <td>
1103 <xsl:value-of select="a:Description/a:Text" disable-output-escaping="yes"/>
1104 </td>
1105 <td>
1106 <xsl:value-of select="a:Status/a:Text"/>
1107 </td>
1108 <td>
1109 <xsl:call-template name="actorName">
1110 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1111 </xsl:call-template>
1112 </td>
1113 </tr>
1114 </xsl:for-each>
1115 </tbody>
1116 </table>
1117 </text>
1118 </section>
1119 </component>
1120 </xsl:if>
1121 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:FamilyHistory">
1122 <component>
1123 <section>
1124 <templateId root="2.16.840.1.113883.10.20.1.4"/>
1125 <code code="10157-6" codeSystem="2.16.840.1.113883.6.1"/>
1126 <title>Family History</title>
1127 <text>
1128 <table>
1129 <tbody>
1130 <tr>
1131 <th>Type</th>
1132 <th>Date</th>
1133 <th>Code</th>
1134 <th>Description</th>
1135 <th>Relationship(s)</th>
1136 <th>Status</th>
1137 <th>Source</th>
1138 </tr>
1139 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:FamilyHistory/a:FamilyProblemHistory">
1140 <tr>
1141 <td>
1142 <xsl:value-of select="a:Type/a:Text"/>
1143 </td>
1144 <td>
1145 <xsl:call-template name="date:format-date">
1146 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1147 </xsl:call-template>
1148 </td>
1149 <td>
1150 <xsl:apply-templates select="a:Problem/a:Description/a:Code"/>
1151 </td>
1152 <td>
1153 <xsl:for-each select="a:Problem">
1154 <xsl:value-of select="a:Description/a:Text"/>
1155 <br/>
1156 </xsl:for-each>
1157 </td>
1158 <td>
1159 <xsl:value-of select="a:FamilyMember/a:ActorRole/a:Text"/>
1160 </td>
1161 <td>
1162 <xsl:value-of select="a:Status/a:Text"/>
1163 </td>
1164 <td>
1165 <xsl:call-template name="actorName">
1166 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1167 </xsl:call-template>
1168 </td>
1169 </tr>
1170 </xsl:for-each>
1171 </tbody>
1172 </table>
1173 </text>
1174 </section>
1175 </component>
1176 </xsl:if>
1177 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
1178 <component>
1179 <section>
1180 <templateId root="2.16.840.1.113883.10.20.1.14"/>
1181 <code code="30954-2" codeSystem="2.16.840.1.113883.6.1"/>
1182 <title>Results</title>
1183 <text>
1184 <table>
1185 <tbody>
1186 <tr>
1187 <th>Test</th>
1188 <th>Date</th>
1189 <th>Result</th>
1190 <th>Source</th>
1191 </tr>
1192 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
1193 <tr>
1194 <xsl:attribute name="id">
1195 <xsl:value-of select="a:CCRDataObjectID"/>
1196 </xsl:attribute>
1197 <td>
1198 <xsl:value-of select="a:Description/a:Text"/>
1199 </td>
1200 <td>
1201 <xsl:call-template name="date:format-date">
1202 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1203 </xsl:call-template>
1204 </td>
1205 <td>
1206 <xsl:for-each select="a:Test[a:TestResult/a:Value!='']">
1207 <div>
1208 <xsl:attribute name="id">
1209 <xsl:value-of select="a:CCRDataObjectID"/>
1210 </xsl:attribute>
1211
1212 <xsl:value-of select="a:Description/a:Text"/>
1213 <xsl:text xml:space="preserve"> </xsl:text>
1214 <xsl:value-of select="a:TestResult/a:Value"/>
1215 <xsl:text xml:space="preserve"> </xsl:text>
1216 <xsl:value-of select="a:TestResult/a:Units/a:Unit"/>
1217 <xsl:text xml:space="preserve"> </xsl:text>
1218 <xsl:value-of select="a:Flag/a:Text"/>
1219 <br/>
1220 </div>
1221 </xsl:for-each>
1222 <xsl:for-each select="a:Test[a:TestResult/a:Description/a:Text!='']">
1223 <div>
1224 <xsl:attribute name="id">
1225 <xsl:value-of select="a:CCRDataObjectID"/>
1226 </xsl:attribute>
1227
1228 <xsl:value-of select="a:Description/a:Text"/>
1229 <xsl:text xml:space="preserve"> </xsl:text>
1230 <xsl:value-of select="a:TestResult/a:Description/a:Text" disable-output-escaping="yes"/>
1231 <xsl:text xml:space="preserve"> </xsl:text>
1232 <xsl:value-of select="a:Flag/a:Text"/>
1233 <br/>
1234 </div>
1235 </xsl:for-each>
1236 </td>
1237 <td>
1238 <xsl:call-template name="actorName">
1239 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1240 </xsl:call-template>
1241 </td>
1242 </tr>
1243 </xsl:for-each>
1244 </tbody>
1245 </table>
1246 </text>
1247 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
1248 <entry typeCode="DRIV">
1249 <xsl:variable name="testDate" select="a:DateTime"/>
1250
1251 <xsl:choose>
1252 <xsl:when test="count(a:Test)>1">
1253 <organizer classCode="BATTERY" moodCode="EVN">
1254 <templateId root="2.16.840.1.113883.10.20.1.32"/>
1255 <!--Result organizer template -->
1256
1257 <!-- <id> -->
1258 <xsl:call-template name="ccdID">
1259 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1260 </xsl:call-template>
1261
1262 <!-- <code> -->
1263 <xsl:call-template name="ccdCodedValue">
1264 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1265 <xsl:with-param name="nodeName" select="'code'"/>
1266 </xsl:call-template>
1267
1268 <statusCode code="completed"/>
1269
1270 <!-- <effectiveTime> -->
1271 <xsl:call-template name="ccdDateTime">
1272 <xsl:with-param name="dt" select="$testDate"/>
1273 </xsl:call-template>
1274
1275 <xsl:call-template name="ccdPerformer">
1276 <xsl:with-param name="ccrActorReference" select="a:Source/a:Actor"/>
1277 </xsl:call-template>
1278
1279 <xsl:for-each select="a:Test">
1280 <xsl:call-template name="labObservation">
1281 <xsl:with-param name="ccrTestNode" select="."/>
1282 <xsl:with-param name="testDate" select="$testDate"/>
1283 </xsl:call-template>
1284 </xsl:for-each>
1285
1286 </organizer>
1287
1288 </xsl:when>
1289 <xsl:otherwise>
1290 <xsl:call-template name="labObservation">
1291 <xsl:with-param name="ccrTestNode" select="a:Test[1]"/>
1292 <xsl:with-param name="testDate" select="$testDate"/>
1293 </xsl:call-template>
1294
1295 </xsl:otherwise>
1296 </xsl:choose>
1297 </entry>
1298 </xsl:for-each>
1299 </section>
1300 </component>
1301 </xsl:if>
1302 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Payers">
1303 <component>
1304 <section>
1305 <templateId root="2.16.840.1.113883.10.20.1.9"/>
1306 <code code="48768-6" codeSystem="2.16.840.1.113883.6.1"/>
1307 <title>Insurance</title>
1308 <text>
1309 <table>
1310 <tbody>
1311 <tr>
1312 <th>Type</th>
1313 <th>Date</th>
1314 <th>Identification Numbers</th>
1315 <th>Payment Provider</th>
1316 <th>Subscriber</th>
1317 <th>Source</th>
1318 </tr>
1319 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Payers/a:Payer">
1320 <tr>
1321 <td>
1322 <xsl:value-of select="a:Type/a:Text"/>
1323 </td>
1324 <td>
1325 <xsl:call-template name="date:format-date">
1326 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1327 </xsl:call-template>
1328 </td>
1329 <td>
1330 <xsl:for-each select="a:IDs">
1331 <xsl:value-of select="a:Type/a:Text"/>:<xsl:text xml:space="preserve"> </xsl:text><xsl:value-of select="a:ID"/><br/>
1332 </xsl:for-each>
1333 </td>
1334 <td>
1335 <xsl:call-template name="actorName">
1336 <xsl:with-param name="objID" select="a:PaymentProvider/a:ActorID"/>
1337 </xsl:call-template>
1338 </td>
1339 <td>
1340 <xsl:call-template name="actorName">
1341 <xsl:with-param name="objID" select="a:Subscriber/a:ActorID"/>
1342 </xsl:call-template>
1343 </td>
1344 <td>
1345 <xsl:call-template name="actorName">
1346 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1347 </xsl:call-template>
1348 </td>
1349 </tr>
1350 </xsl:for-each>
1351 </tbody>
1352 </table>
1353 </text>
1354 </section>
1355 </component>
1356 </xsl:if>
1357 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare">
1358 <component>
1359 <section>
1360 <templateId root="2.16.840.1.113883.10.20.1.10"/>
1361 <code code="18776-5" codeSystem="2.16.840.1.113883.6.1"/>
1362 <title>Plan Of Care</title>
1363 <text>
1364 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Treatment Recommendation']">
1365 <xsl:text>Plan Of Care Recommendations</xsl:text>
1366 <br/>
1367 <table>
1368 <tbody>
1369 <tr>
1370 <th>Description</th>
1371 <th>Recommendation</th>
1372 <th>Goal</th>
1373 <th>Status</th>
1374 <th>Source</th>
1375 </tr>
1376 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Treatment Recommendation']">
1377 <tr>
1378 <td>
1379 <xsl:value-of select="a:Description/a:Text"/>
1380 </td>
1381 <td>
1382 <xsl:value-of select="a:OrderRequest/a:Description/a:Text" disable-output-escaping="yes"/>
1383 </td>
1384 <td>
1385 <xsl:value-of select="a:OrderRequest/a:Goals/a:Goal/a:Description/a:Text" disable-output-escaping="yes"/>
1386 </td>
1387 <td>
1388 <xsl:value-of select="a:Status/a:Text"/>
1389 </td>
1390 <td>
1391 <xsl:call-template name="actorName">
1392 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1393 </xsl:call-template>
1394 </td>
1395 </tr>
1396 </xsl:for-each>
1397 </tbody>
1398 </table>
1399 </xsl:if>
1400 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Order']">
1401 <xsl:text>Plan Of Care Orders</xsl:text>
1402 <br/>
1403 <table>
1404 <tbody>
1405 <tr>
1406 <th>Descripion</th>
1407 <th>Plan Status</th>
1408 <th>Type</th>
1409 <th>Date</th>
1410 <th>Procedure</th>
1411 <th>Schedule</th>
1412 <th>Location</th>
1413 <th>Substance</th>
1414 <th>Method</th>
1415 <th>Position</th>
1416 <th>Site</th>
1417 <th>Status</th>
1418 <th>Source</th>
1419 </tr>
1420 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Order']">
1421 <tr>
1422 <td>
1423 <xsl:apply-templates select="a:Description/a:Text"/>
1424 </td>
1425 <td>
1426 <xsl:value-of select="a:Status/a:Text"/>
1427 </td>
1428 <td>
1429 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Type/a:Text"/>
1430 </td>
1431 <td>
1432 <xsl:call-template name="date:format-date">
1433 <xsl:with-param name="date-time" select="a:OrderRequest/a:Procedures/a:Procedure/a:DateTime/a:ExactDateTime"/>
1434 </xsl:call-template>
1435 </td>
1436 <td>
1437 <xsl:apply-templates select="a:OrderRequest/a:Procedures/a:Procedure/a:Description/a:Text"/>
1438 </td>
1439 <td>
1440 <xsl:text xml:space="preserve">Every </xsl:text>
1441 <xsl:apply-templates select="a:OrderRequest/a:Procedures/a:Procedure/a:Interval/a:Value"/>
1442 <xsl:text xml:space="preserve"> </xsl:text>
1443 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Interval/a:Units/a:Unit"/>
1444 <xsl:text xml:space="preserve"> for </xsl:text>
1445 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Duration/a:Value"/>
1446 <xsl:text xml:space="preserve"> </xsl:text>
1447 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Duration/a:Units/a:Unit"/>
1448 </td>
1449 <td>
1450 <xsl:for-each select="a:OrderRequest/a:Procedures/a:Procedure/a:Locations">
1451 <xsl:value-of select="a:Location/a:Description/a:Text"/>
1452 <xsl:if test="position() != last()">
1453 <br/>
1454 </xsl:if>
1455 </xsl:for-each>
1456 </td>
1457 <td>
1458 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Substance/a:Text"/>
1459 </td>
1460 <td>
1461 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Method/a:Text"/>
1462 </td>
1463 <td>
1464 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Position/a:Text"/>
1465 </td>
1466 <td>
1467 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Site/a:Text"/>
1468 </td>
1469 <td/>
1470 <td>
1471 <xsl:call-template name="actorName">
1472 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1473 </xsl:call-template>
1474 </td>
1475 </tr>
1476 </xsl:for-each>
1477 </tbody>
1478 </table>
1479 </xsl:if>
1480 </text>
1481 </section>
1482 </component>
1483 </xsl:if>
1484 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders">
1485 <component>
1486 <section>
1487 <title>Health Care Providers</title>
1488 <text>
1489 <table>
1490 <tbody>
1491 <tr>
1492 <th>Role</th>
1493 <th>Name</th>
1494 </tr>
1495 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders/a:Provider">
1496 <tr>
1497 <td>
1498 <xsl:value-of select="a:ActorRole/a:Text"/>
1499 </td>
1500 <td>
1501 <xsl:call-template name="actorName">
1502 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1503 </xsl:call-template>
1504 </td>
1505 </tr>
1506 </xsl:for-each>
1507 </tbody>
1508 </table>
1509 </text>
1510 </section>
1511 </component>
1512 </xsl:if>
1513 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:SupportProviders">
1514 <component>
1515 <section>
1516 <title>Support Providers</title>
1517 <text>
1518 <table>
1519 <tbody>
1520 <tr>
1521 <th>Role</th>
1522 <th>Name</th>
1523 </tr>
1524 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Support/a:SupportProvider">
1525 <tr>
1526 <td>
1527 <xsl:value-of select="a:ActorRole/a:Text"/>
1528 </td>
1529 <td>
1530 <xsl:call-template name="actorName">
1531 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1532 </xsl:call-template>
1533 </td>
1534 </tr>
1535 </xsl:for-each>
1536 </tbody>
1537 </table>
1538 </text>
1539 </section>
1540 </component>
1541 </xsl:if>
1542 <xsl:if test="a:ContinuityOfCareRecord/a:References">
1543 <component>
1544 <section>
1545 <title>References</title>
1546 <text>
1547 <table>
1548 <tbody>
1549 <tr>
1550 <th>Type</th>
1551 <th>Date</th>
1552 <th>Description</th>
1553 <th>Location</th>
1554 <th>Source</th>
1555 </tr>
1556 <xsl:for-each select="/a:ContinuityOfCareRecord/a:References/a:Reference">
1557 <tr>
1558 <td>
1559 <xsl:value-of select="a:Type/a:Text"/>
1560 </td>
1561 <td>
1562 <xsl:call-template name="date:format-date">
1563 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1564 </xsl:call-template>
1565 </td>
1566 <td>
1567 <strong class="clinical">
1568 <xsl:value-of select="a:Description/a:Text"/>
1569 </strong>
1570 </td>
1571 <td>
1572 <xsl:value-of select="a:Locations/a:Location/a:Description/a:Text"/>
1573 </td>
1574 <td>
1575 <xsl:call-template name="actorName">
1576 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1577 </xsl:call-template>
1578 </td>
1579 </tr>
1580 </xsl:for-each>
1581 </tbody>
1582 </table>
1583 </text>
1584 </section>
1585 </component>
1586 </xsl:if>
1587 <component>
1588 <section>
1589 <title>Additional Information About People &amp; Organizations</title>
1590 <text>
1591 <xsl:if test="a:ContinuityOfCareRecord/a:Actors/a:Actor[a:Person]">
1592 <table>
1593 <tbody>
1594 <tr>
1595 <th>Name</th>
1596 <th>Specialty</th>
1597 <th>Relation</th>
1598 <th>Identification Numbers</th>
1599 <th>Phone</th>
1600 <th>Address/ E-mail</th>
1601 </tr>
1602 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
1603 <xsl:sort select="a:Person/a:Name/a:DisplayName|a:Person/a:Name/a:CurrentName/a:Family" data-type="text" order="ascending"/>
1604 <xsl:if test="a:Person">
1605 <tr>
1606 <td>
1607 <xsl:call-template name="actorName">
1608 <xsl:with-param name="objID" select="a:ActorObjectID"/>
1609 </xsl:call-template>
1610 </td>
1611 <td>
1612 <xsl:value-of select="a:Specialty/a:Text"/>
1613 </td>
1614 <td>
1615 <xsl:value-of select="a:Relation/a:Text"/>
1616 </td>
1617 <td>
1618 <xsl:for-each select="a:IDs">
1619 <xsl:value-of select="a:Type/a:Text"/>
1620 <xsl:text>: </xsl:text>
1621 <xsl:value-of select="a:ID"/>
1622 </xsl:for-each>
1623 </td>
1624 <td>
1625 <xsl:for-each select="a:Telephone">
1626 <xsl:value-of select="a:Type/a:Text"/>
1627 <xsl:text>: </xsl:text>
1628 <xsl:value-of select="a:Value"/>
1629 </xsl:for-each>
1630 </td>
1631 <td>
1632 <xsl:for-each select="a:Address">
1633 <xsl:if test="a:Type">
1634 <xsl:value-of select="a:Type/a:Text"/>
1635 <xsl:text>:</xsl:text>
1636 <br/>
1637 </xsl:if>
1638 <xsl:if test="a:Line1">
1639 <xsl:value-of select="a:Line1"/>
1640 <br/>
1641 </xsl:if>
1642 <xsl:if test="a:Line2">
1643 <xsl:value-of select="a:Line2"/>
1644 <br/>
1645 </xsl:if>
1646 <xsl:if test="a:City">
1647 <xsl:value-of select="a:City"/>
1648 <xsl:text>, </xsl:text>
1649 </xsl:if>
1650 <xsl:value-of select="a:State"/>
1651 <xsl:value-of select="a:PostalCode"/>
1652 <br/>
1653 </xsl:for-each>
1654 <xsl:for-each select="a:EMail">
1655 <br/>
1656 <xsl:value-of select="a:Value"/>
1657 </xsl:for-each>
1658 </td>
1659 </tr>
1660 </xsl:if>
1661 </xsl:for-each>
1662 </tbody>
1663 </table>
1664 </xsl:if>
1665 <xsl:if test="a:ContinuityOfCareRecord/a:Actors/a:Actor[a:Organization]">
1666 <table>
1667 <tbody>
1668 <tr>
1669 <th>Name</th>
1670 <th>Specialty</th>
1671 <th>Relation</th>
1672 <th>Identification Numbers</th>
1673 <th>Phone</th>
1674 <th>Address/ E-mail</th>
1675 </tr>
1676 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
1677 <xsl:sort select="a:Organization/a:Name" data-type="text" order="ascending"/>
1678 <xsl:if test="a:Organization">
1679 <tr>
1680 <td>
1681 <xsl:value-of select="a:Organization/a:Name"/>
1682 </td>
1683 <td>
1684 <xsl:value-of select="a:Specialty/a:Text"/>
1685 </td>
1686 <td>
1687 <xsl:value-of select="a:Relation/a:Text"/>
1688 </td>
1689 <td>
1690 <xsl:for-each select="a:IDs">
1691 <xsl:value-of select="a:Type/a:Text"/>
1692 <xsl:text>: </xsl:text>
1693 <xsl:value-of select="a:ID"/>
1694 </xsl:for-each>
1695 </td>
1696 <td>
1697 <xsl:for-each select="a:Telephone">
1698 <xsl:value-of select="a:Type/a:Text"/>
1699 <xsl:text>: </xsl:text>
1700 <xsl:value-of select="a:Value"/>
1701 </xsl:for-each>
1702 </td>
1703 <td>
1704 <xsl:for-each select="a:Address">
1705 <xsl:if test="a:Type">
1706 <xsl:value-of select="a:Type/a:Text"/>
1707 <xsl:text>:</xsl:text>
1708 <br/>
1709 </xsl:if>
1710 <xsl:if test="a:Line1">
1711 <xsl:value-of select="a:Line1"/>
1712 <br/>
1713 </xsl:if>
1714 <xsl:if test="a:Line2">
1715 <xsl:value-of select="a:Line2"/>
1716 <br/>
1717 </xsl:if>
1718 <xsl:if test="a:City">
1719 <xsl:value-of select="a:City"/>
1720 <xsl:text>, </xsl:text>
1721 </xsl:if>
1722 <xsl:value-of select="a:State"/>
1723 <xsl:value-of select="a:PostalCode"/>
1724 <br/>
1725 </xsl:for-each>
1726 <xsl:for-each select="a:EMail">
1727 <br/>
1728 <xsl:value-of select="a:Value"/>
1729 </xsl:for-each>
1730 </td>
1731 </tr>
1732 </xsl:if>
1733 </xsl:for-each>
1734 </tbody>
1735 </table>
1736 </xsl:if>
1737 <xsl:if test="a:ContinuityOfCareRecord/a:Actors/a:Actor[a:InformationSystem]">
1738 <table>
1739 <tbody>
1740 <tr>
1741 <th>Name</th>
1742 <th>Type</th>
1743 <th>Version</th>
1744 <th>Identification Numbers</th>
1745 <th>Phone</th>
1746 <th>Address/ E-mail</th>
1747 </tr>
1748 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
1749 <xsl:sort select="a:InformationSystem/a:Name" data-type="text" order="ascending"/>
1750 <xsl:if test="a:InformationSystem">
1751 <tr>
1752 <td>
1753 <xsl:value-of select="a:InformationSystem/a:Name"/>
1754 </td>
1755 <td>
1756 <xsl:value-of select="a:InformationSystem/a:Type"/>
1757 </td>
1758 <td>
1759 <xsl:value-of select="a:InformationSystem/a:Version"/>
1760 </td>
1761 <td>
1762 <xsl:for-each select="a:IDs">
1763 <xsl:value-of select="a:Type/a:Text"/>
1764 <xsl:text>: </xsl:text>
1765 <xsl:value-of select="a:ID"/>
1766 </xsl:for-each>
1767 </td>
1768 <td>
1769 <xsl:for-each select="a:Telephone">
1770 <xsl:value-of select="a:Type/a:Text"/>
1771 <xsl:text>: </xsl:text>
1772 <xsl:value-of select="a:Value"/>
1773 </xsl:for-each>
1774 </td>
1775 <td>
1776 <xsl:for-each select="a:Address">
1777 <xsl:if test="Type">
1778 <xsl:value-of select="a:Type/a:Text"/>
1779 <xsl:text>:</xsl:text>
1780 <br/>
1781 </xsl:if>
1782 <xsl:if test="a:Line1">
1783 <xsl:value-of select="a:Line1"/>
1784 <br/>
1785 </xsl:if>
1786 <xsl:if test="a:Line2">
1787 <xsl:value-of select="a:Line2"/>
1788 <br/>
1789 </xsl:if>
1790 <xsl:if test="a:City">
1791 <xsl:value-of select="a:City"/>
1792 <xsl:text>, </xsl:text>
1793 </xsl:if>
1794 <xsl:value-of select="a:State"/>
1795 <xsl:value-of select="a:PostalCode"/>
1796 <br/>
1797 </xsl:for-each>
1798 <xsl:for-each select="a:EMail">
1799 <br/>
1800 <xsl:value-of select="a:Value"/>
1801 </xsl:for-each>
1802 </td>
1803 </tr>
1804 </xsl:if>
1805 </xsl:for-each>
1806 </tbody>
1807 </table>
1808 </xsl:if>
1809 </text>
1810 </section>
1811 </component>
1812 </structuredBody>
1813 </component>
1814 </ClinicalDocument>
1815 </xsl:template>
1816
1817 <xsl:template name="ccdAssignedEntity">
1818 <xsl:param name="ccrActorObjectID"/>
1819
1820 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
1821
1822 <assignedEntity>
1823 <xsl:call-template name="ccdEntityID">
1824 <xsl:with-param name="CCRActor" select="$CCRActor"/>
1825 </xsl:call-template>
1826
1827 <xsl:call-template name="ccdAddress">
1828 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address"/>
1829 </xsl:call-template>
1830
1831 <xsl:call-template name="ccdTelecom">
1832 <xsl:with-param name="CCRActor" select="$CCRActor"/>
1833 </xsl:call-template>
1834
1835 <xsl:if test="$CCRActor/a:Person">
1836 <xsl:call-template name="ccdPerson">
1837 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
1838 <xsl:with-param name="personNodeName" select="'assignedPerson'"/>
1839 </xsl:call-template>
1840 </xsl:if>
1841
1842 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
1843 <xsl:call-template name="ccdOrganization">
1844 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
1845 <xsl:with-param name="organizationNodeName" select="'representedOrganization'"/>
1846 </xsl:call-template>
1847 </xsl:if>
1848
1849 </assignedEntity>
1850 </xsl:template>
1851
1852 <xsl:template name="ccdPatient">
1853 <xsl:param name="CCRActorPerson"/>
1854 <patient>
1855 <xsl:call-template name="ccdPersonName">
1856 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
1857 </xsl:call-template>
1858
1859 <xsl:if test="$CCRActorPerson/a:Gender">
1860 <xsl:call-template name="ccdCodedValue">
1861 <xsl:with-param name="ccrCodedDescription" select="$CCRActorPerson/a:Gender"/>
1862 <xsl:with-param name="domain" select="'AdministrativeGender'"/>
1863 <xsl:with-param name="nodeName" select="'administrativeGenderCode'"/>
1864 </xsl:call-template>
1865 </xsl:if>
1866
1867 <xsl:if test="$CCRActorPerson/a:DateOfBirth">
1868 <birthTime>
1869 <xsl:attribute name="value">
1870 <xsl:call-template name="date:format-date">
1871 <xsl:with-param name="date-time" select="$CCRActorPerson/a:DateOfBirth/a:ExactDateTime"/>
1872 <xsl:with-param name="pattern">yyyyMMddhhmmss</xsl:with-param>
1873 </xsl:call-template>
1874 </xsl:attribute>
1875 </birthTime>
1876 </xsl:if>
1877
1878 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']">
1879 <xsl:call-template name="ccdCodedValue">
1880 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']/a:Description"/>
1881 <xsl:with-param name="domain" select="'MaritalStatus'"/>
1882 <xsl:with-param name="nodeName" select="'maritalStatusCode'"/>
1883 </xsl:call-template>
1884 </xsl:if>
1885
1886 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']">
1887 <languageCommunication>
1888 <templateId root="2.16.840.1.113883.3.88.11.83.2" assigningAuthorityName="HITSP/C83"/>
1889 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.2.1" assigningAuthorityName="IHE/PCC"/>
1890 <xsl:call-template name="ccdCodedValue">
1891 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']/a:Description"></xsl:with-param>
1892 <xsl:with-param name="domain" select="'HumanLanguage'"/>
1893 <xsl:with-param name="nodeName" select="'languageCode'"/>
1894 </xsl:call-template>
1895 </languageCommunication>
1896 </xsl:if>
1897 </patient>
1898 </xsl:template>
1899
1900 <xsl:template name="ccdPerformer">
1901 <xsl:param name="ccrActorReference"/>
1902 <performer typeCode="PRF">
1903 <xsl:if test="$ccrActorReference/a:ActorRole">
1904 <xsl:call-template name="ccdCodedValue">
1905 <xsl:with-param name="ccrCodedDescription" select="$ccrActorReference/a:ActorRole"/>
1906 <xsl:with-param name="nodeName" select="'functionCode'"/>
1907 </xsl:call-template>
1908 </xsl:if>
1909 <xsl:call-template name="ccdAssignedEntity">
1910 <xsl:with-param name="ccrActorObjectID" select="$ccrActorReference/a:ActorID"/>
1911 </xsl:call-template>
1912 </performer>
1913 </xsl:template>
1914
1915 <xsl:template name="ccdPerson">
1916 <xsl:param name="CCRActorPerson"/>
1917 <xsl:param name="personNodeName">assignedPerson</xsl:param>
1918 <xsl:element name="{$personNodeName}">
1919 <xsl:call-template name="ccdPersonName">
1920 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
1921 </xsl:call-template>
1922 </xsl:element>
1923 </xsl:template>
1924
1925 <xsl:template name="ccdPersonName">
1926 <xsl:param name="CCRActorName"/>
1927 <name>
1928 <xsl:if test="$CCRActorName/a:CurrentName/a:Title">
1929 <prefix>
1930 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Title"/>
1931 </prefix>
1932 </xsl:if>
1933 <xsl:if test="$CCRActorName/a:CurrentName/a:Given">
1934 <given>
1935 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Given"/>
1936 </given>
1937 </xsl:if>
1938 <xsl:if test="$CCRActorName/a:CurrentName/a:Middle">
1939 <given>
1940 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Middle"/>
1941 </given>
1942 </xsl:if>
1943 <xsl:if test="$CCRActorName/a:CurrentName/a:Family">
1944 <family>
1945 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Family"/>
1946 </family>
1947 </xsl:if>
1948 <xsl:if test="$CCRActorName/a:CurrentName/a:Suffix">
1949 <suffix>
1950 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Suffix"/>
1951 </suffix>
1952 </xsl:if>
1953 </name>
1954 </xsl:template>
1955
1956 <xsl:template name="ccdOrganization">
1957 <xsl:param name="ccrActorObjectID"/>
1958 <xsl:param name="organizationNodeName"/>
1959
1960 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
1961
1962 <xsl:element name="{$organizationNodeName}">
1963 <xsl:call-template name="ccdEntityID">
1964 <xsl:with-param name="CCRActor" select="$CCRActor"/>
1965 </xsl:call-template>
1966
1967 <xsl:if test="$CCRActor/a:Organization">
1968 <name>
1969 <xsl:value-of select="$CCRActor/a:Organization/a:Name"/>
1970 </name>
1971 </xsl:if>
1972
1973 <xsl:call-template name="ccdTelecom">
1974 <xsl:with-param name="CCRActor" select="$CCRActor"/>
1975 </xsl:call-template>
1976
1977 <xsl:call-template name="ccdAddress">
1978 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
1979 </xsl:call-template>
1980 </xsl:element>
1981 </xsl:template>
1982
1983 <xsl:template name="ccdPatientRole">
1984 <xsl:param name="ccrActorObjectID"/>
1985
1986 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
1987
1988 <xsl:call-template name="ccdEntityID">
1989 <xsl:with-param name="CCRActor" select="$CCRActor"/>
1990 </xsl:call-template>
1991
1992 <xsl:call-template name="ccdAddress">
1993 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
1994 </xsl:call-template>
1995
1996 <xsl:call-template name="ccdTelecom">
1997 <xsl:with-param name="CCRActor" select="$CCRActor"/>
1998 </xsl:call-template>
1999
2000 <xsl:call-template name="ccdPatient">
2001 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
2002 </xsl:call-template>
2003 </xsl:template>
2004
2005 <xsl:template name="ccdAssignedAuthor">
2006 <xsl:param name="ccrActorObjectID"/>
2007
2008 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
2009
2010 <xsl:call-template name="ccdEntityID">
2011 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2012 </xsl:call-template>
2013
2014 <xsl:call-template name="ccdAddress">
2015 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
2016 </xsl:call-template>
2017
2018 <xsl:call-template name="ccdTelecom">
2019 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2020 </xsl:call-template>
2021
2022 <xsl:call-template name="ccdPerson">
2023 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
2024 </xsl:call-template>
2025
2026 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
2027 <representedOrganization>
2028 <xsl:call-template name="ccdOrganization">
2029 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
2030 </xsl:call-template>
2031 </representedOrganization>
2032 </xsl:if>
2033 </xsl:template>
2034
2035 <xsl:template name="ccdParticipantRoleActor">
2036 <xsl:param name="ccrActorObjectID"/>
2037
2038 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
2039
2040 <xsl:call-template name="ccdEntityID">
2041 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2042 </xsl:call-template>
2043
2044 <xsl:call-template name="ccdAddress">
2045 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
2046 </xsl:call-template>
2047
2048 <xsl:call-template name="ccdTelecom">
2049 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2050 </xsl:call-template>
2051
2052 <xsl:if test="$CCRActor/a:Organization/a:Name">
2053 <playingEntity classCode="PLC">
2054 <name>
2055 <xsl:value-of select="$CCRActor/a:Organization/a:Name"/>
2056 </name>
2057 </playingEntity>
2058 </xsl:if>
2059 </xsl:template>
2060
2061 <xsl:template name="ccdParticipantRoleCodedDescription">
2062 <xsl:param name="ccrCodedDescription"/>
2063
2064 <addr/>
2065 <telecom/>
2066 <playingEntity classCode="PLC">
2067 <xsl:if test="$ccrCodedDescription/a:Code">
2068 <xsl:call-template name="ccdCodedValue">
2069 <xsl:with-param name="ccrCodedDescription" select="$ccrCodedDescription"/>
2070 <xsl:with-param name="nodeName" select="'code'"/>
2071 </xsl:call-template>
2072 </xsl:if>
2073 <name>
2074 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
2075 </name>
2076 </playingEntity>
2077 </xsl:template>
2078
2079 <xsl:template name="ccdEntityID">
2080 <xsl:param name="CCRActor"/>
2081 <id>
2082 <xsl:choose>
2083 <xsl:when test="$CCRActor/a:IDs">
2084 <xsl:attribute name="extension">
2085 <xsl:value-of select="$CCRActor/a:IDs[1]/a:ID"/>
2086 </xsl:attribute>
2087 <xsl:attribute name="root">
2088 <xsl:value-of select="$CCRActor/a:IDs[1]/a:Type/a:Text"/>
2089 </xsl:attribute>
2090 </xsl:when>
2091 <xsl:otherwise>
2092 <xsl:attribute name="extension">
2093 <xsl:value-of select="$CCRActor/a:ActorObjectID"/>
2094 </xsl:attribute>
2095 <xsl:attribute name="root">
2096 <xsl:text>CCRActorID</xsl:text>
2097 </xsl:attribute>
2098 </xsl:otherwise>
2099 </xsl:choose>
2100 </id>
2101 <xsl:if test="$CCRActor/a:Organization">
2102 <name><xsl:value-of select="$CCRActor/a:Organization/a:Name"></xsl:value-of></name>
2103 </xsl:if>
2104 </xsl:template>
2105 <xsl:template name="ccdAddress">
2106 <xsl:param name="CCRActorAddress"/>
2107 <addr>
2108 <xsl:choose>
2109 <xsl:when test="$CCRActorAddress">
2110 <xsl:attribute name="use">
2111 <xsl:call-template name="CDAVocabularyLookup">
2112 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
2113 <xsl:with-param name="ccrtext" select="$CCRActorAddress/a:Type/a:Text"/>
2114 </xsl:call-template>
2115 </xsl:attribute>
2116 <streetAddressLine>
2117 <xsl:value-of select="$CCRActorAddress/a:Line1"/>
2118 </streetAddressLine>
2119 <city>
2120 <xsl:value-of select="$CCRActorAddress/a:City"/>
2121 </city>
2122 <state>
2123 <xsl:value-of select="$CCRActorAddress/a:State"/>
2124 </state>
2125 <postalCode>
2126 <xsl:value-of select="$CCRActorAddress/a:PostalCode"/>
2127 </postalCode>
2128 </xsl:when>
2129 <xsl:otherwise>
2130 <streetAddressLine/>
2131 </xsl:otherwise>
2132 </xsl:choose>
2133 </addr>
2134 </xsl:template>
2135
2136 <xsl:template name="ccdTelecom">
2137 <xsl:param name="CCRActor"/>
2138 <xsl:if test="$CCRActor/a:Telephone">
2139 <telecom>
2140 <xsl:attribute name="use">
2141 <xsl:call-template name="CDAVocabularyLookup">
2142 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
2143 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
2144 </xsl:call-template>
2145 </xsl:attribute>
2146 <xsl:attribute name="value">
2147 <xsl:text>tel:+1-</xsl:text>
2148 <xsl:value-of select="$CCRActor/a:Telephone[1]/a:Value"/>
2149 </xsl:attribute>
2150 </telecom>
2151 </xsl:if>
2152
2153 <xsl:if test="$CCRActor/a:Email">
2154 <telecom>
2155 <xsl:choose>
2156 <xsl:when test="$CCRActor/a:Telephone">
2157 <xsl:attribute name="use">
2158 <xsl:call-template name="CDAVocabularyLookup">
2159 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
2160 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
2161 </xsl:call-template>
2162 </xsl:attribute>
2163 <xsl:attribute name="value">
2164 <xsl:text>mailto:</xsl:text>
2165 <xsl:value-of select="$CCRActor/a:Email[1]/a:Value"/>
2166 </xsl:attribute>
2167 </xsl:when>
2168 <xsl:otherwise>
2169 <xsl:attribute name="value">Unknown</xsl:attribute>
2170 </xsl:otherwise>
2171 </xsl:choose>
2172 </telecom>
2173 </xsl:if>
2174 </xsl:template>
2175
2176 <xsl:template name="ccdID">
2177 <xsl:param name="ccrObjectID"/>
2178 <xsl:param name="suffix"/>
2179 <id>
2180 <xsl:attribute name="extension">
2181 <xsl:value-of select="$ccrObjectID"></xsl:value-of>
2182 <xsl:value-of select="$suffix"></xsl:value-of>
2183 </xsl:attribute>
2184 <xsl:attribute name="extension">CCRObjectID</xsl:attribute>
2185 </id>
2186 </xsl:template>
2187
2188 <xsl:template name="ccdCodedValue">
2189 <xsl:param name="ccrCodedDescription"/>
2190 <xsl:param name="type"/>
2191 <xsl:param name="domain"/>
2192 <xsl:param name="nodeName">value</xsl:param>
2193
2194 <xsl:element name="{$nodeName}">
2195 <xsl:if test="$type">
2196 <xsl:attribute name="xsi:type">
2197 <xsl:value-of select="$type"/>
2198 </xsl:attribute>
2199 </xsl:if>
2200 <xsl:choose>
2201 <xsl:when test="$ccrCodedDescription/a:Code">
2202 <xsl:attribute name="displayName">
2203 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
2204 </xsl:attribute>
2205 <xsl:attribute name="code">
2206 <xsl:value-of select="$ccrCodedDescription/a:Code/a:Value"/>
2207 </xsl:attribute>
2208 <xsl:attribute name="codeSystemName">
2209 <xsl:value-of select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
2210 </xsl:attribute>
2211 <xsl:attribute name="codeSystem">
2212 <xsl:call-template name="HL7OIDLookup">
2213 <xsl:with-param name="name" select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
2214 </xsl:call-template>
2215 </xsl:attribute>
2216 </xsl:when>
2217 <xsl:when test="$domain">
2218 <xsl:variable name="cdaCode">
2219 <xsl:call-template name="CDAVocabularyLookup">
2220 <xsl:with-param name="domain" select="$domain"/>
2221 <xsl:with-param name="ccrtext" select="$ccrCodedDescription/a:Text"/>
2222 </xsl:call-template>
2223 </xsl:variable>
2224 <xsl:attribute name="displayName">
2225 <xsl:call-template name="CDADisplayNameLookup">
2226 <xsl:with-param name="domain" select="$domain"/>
2227 <xsl:with-param name="cdacode" select="$cdaCode"/>
2228 </xsl:call-template>
2229 </xsl:attribute>
2230 <xsl:attribute name="code">
2231 <xsl:value-of select="$cdaCode"></xsl:value-of>
2232 </xsl:attribute>
2233 <xsl:attribute name="codeSystemName">
2234 <xsl:call-template name="CDAVocabularyCodeSystemNameLookup">
2235 <xsl:with-param name="domain" select="$domain"/>
2236 </xsl:call-template>
2237 </xsl:attribute>
2238 <xsl:attribute name="codeSystemName">
2239 <xsl:call-template name="CDAVocabularyCodeSystemLookup">
2240 <xsl:with-param name="domain" select="$domain"/>
2241 </xsl:call-template>
2242 </xsl:attribute>
2243 </xsl:when>
2244 <xsl:otherwise>
2245 <xsl:attribute name="displayName">
2246 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
2247 </xsl:attribute>
2248 </xsl:otherwise>
2249 </xsl:choose>
2250 </xsl:element>
2251 </xsl:template>
2252
2253 <xsl:template name="ccdDateTime">
2254 <xsl:param name="dt"/>
2255 <xsl:param name="type"/>
2256 <xsl:if test="$dt">
2257 <xsl:if test="$dt[1]/a:ExactDateTime">
2258 <effectiveTime>
2259 <xsl:if test="$type">
2260 <xsl:attribute name="xsi:type">
2261 <xsl:value-of select="$type"></xsl:value-of>
2262 </xsl:attribute>
2263 </xsl:if>
2264 <low>
2265 <xsl:attribute name="value">
2266 <xsl:call-template name="date:format-date">
2267 <xsl:with-param name="date-time" select="$dt[1]/a:ExactDateTime"/>
2268 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
2269 </xsl:call-template>
2270 </xsl:attribute>
2271 </low>
2272 <high nullFlavor="UNK"/>
2273 </effectiveTime>
2274 </xsl:if>
2275 <xsl:if test="$dt[1]/a:DateTimeRange">
2276 <effectiveTime>
2277 <low>
2278 <xsl:attribute name="value">
2279 <xsl:call-template name="date:format-date">
2280 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:BeginRange/a:ExactDateTime"/>
2281 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
2282 </xsl:call-template>
2283 </xsl:attribute>
2284 </low>
2285 <high>
2286 <xsl:attribute name="value">
2287 <xsl:call-template name="date:format-date">
2288 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:EndRange/a:ExactDateTime"/>
2289 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
2290 </xsl:call-template>
2291 </xsl:attribute>
2292 </high>
2293 </effectiveTime>
2294 </xsl:if>
2295 </xsl:if>
2296 </xsl:template>
2297
2298 <xsl:template name="ccdMedicationFrequency">
2299 <xsl:param name="frequency"/>
2300 <xsl:if test="$frequency">
2301 <xsl:choose>
2302 <xsl:when test="$frequency/a:Value='qd'">
2303 <effectiveTime xsi:type="PIVL_TS" operator="A">
2304 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2305 <period>
2306 <xsl:attribute name="value">24</xsl:attribute>
2307 <xsl:attribute name="unit">h</xsl:attribute>
2308 </period>
2309 </effectiveTime>
2310 </xsl:when>
2311 <xsl:when test="$frequency/a:Value='bid'">
2312 <effectiveTime xsi:type="PIVL_TS" operator="A">
2313 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2314 <period>
2315 <xsl:attribute name="value">12</xsl:attribute>
2316 <xsl:attribute name="unit">h</xsl:attribute>
2317 </period>
2318 </effectiveTime>
2319 </xsl:when>
2320 <xsl:when test="$frequency/a:Value='tid'">
2321 <effectiveTime xsi:type="PIVL_TS" operator="A">
2322 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2323 <period>
2324 <xsl:attribute name="value">8</xsl:attribute>
2325 <xsl:attribute name="unit">h</xsl:attribute>
2326 </period>
2327 </effectiveTime>
2328 </xsl:when>
2329 <xsl:when test="$frequency/a:Value='qid'">
2330 <effectiveTime xsi:type="PIVL_TS" operator="A">
2331 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2332 <period>
2333 <xsl:attribute name="value">6</xsl:attribute>
2334 <xsl:attribute name="unit">h</xsl:attribute>
2335 </period>
2336 </effectiveTime>
2337 </xsl:when>
2338 <xsl:when test="$frequency/a:Value='qam'">
2339 <effectiveTime xsi:type='EIVL' operator='A'>
2340 <event code='ACM'/>
2341 </effectiveTime>
2342 </xsl:when>
2343 <xsl:when test="$frequency/a:Value='qpm'">
2344 <effectiveTime xsi:type='EIVL' operator='A'>
2345 <event code='PCV'/>
2346 </effectiveTime>
2347 </xsl:when>
2348 </xsl:choose>
2349 </xsl:if>
2350 </xsl:template>
2351
2352 <xsl:template name="ccdStatus">
2353 <xsl:param name="ccrStatus"/>
2354
2355 <entryRelationship typeCode="REFR">
2356 <observation classCode="OBS" moodCode="EVN">
2357 <templateId root="2.16.840.1.113883.10.20.1.50"/>
2358 <!-- Problem status observation template -->
2359 <code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/>
2360 <statusCode code="completed"/>
2361 <xsl:call-template name="ccdCodedValue">
2362 <xsl:with-param name="ccrCodedDescription" select="$ccrStatus"/>
2363 </xsl:call-template>
2364 </observation>
2365 </entryRelationship>
2366 </xsl:template>
2367
2368 <xsl:template name="ccdStatusObservation">
2369 <xsl:param name="status"/>
2370 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
2371 <xsl:choose>
2372 <xsl:when test="$statusText='Active'">
2373 <xsl:call-template name="ccdStatusElement">
2374 <xsl:with-param name="statusCode" select="'55561003'"/>
2375 <xsl:with-param name="statusDisplayName" select="$statusText"/>
2376 </xsl:call-template>
2377 </xsl:when>
2378 <xsl:when test="$statusText='Inactive'">
2379 <xsl:call-template name="ccdStatusElement">
2380 <xsl:with-param name="statusCode" select="'73425007'"/>
2381 <xsl:with-param name="statusDisplayName" select="$statusText"/>
2382 </xsl:call-template>
2383 </xsl:when>
2384 <xsl:when test="$statusText='Chronic'">
2385 <xsl:call-template name="ccdStatusElement">
2386 <xsl:with-param name="statusCode" select="'90734009'"/>
2387 <xsl:with-param name="statusDisplayName" select="$statusText"/>
2388 </xsl:call-template>
2389 </xsl:when>
2390 </xsl:choose>
2391 </xsl:template>
2392
2393 <xsl:template name="ccdStatusProcedure">
2394 <xsl:param name="status"/>
2395 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
2396 <xsl:choose>
2397 <xsl:when test="$statusText='Completed'">
2398 <statusCode code="completed"/>
2399 </xsl:when>
2400 <xsl:when test="$statusText='Active'">
2401 <statusCode code="active"/>
2402 </xsl:when>
2403 <xsl:when test="$statusText='Aborted'">
2404 <statusCode code="aborted"/>
2405 </xsl:when>
2406 <xsl:when test="$statusText='Cancelled' or $statusText='Canceled'">
2407 <statusCode code="cancelled"/>
2408 </xsl:when>
2409 <xsl:otherwise>
2410 <statusCode>
2411 <xsl:attribute name="code">
2412 <xsl:value-of select="$statusText"></xsl:value-of>
2413 </xsl:attribute>
2414 </statusCode>
2415 </xsl:otherwise>
2416 </xsl:choose>
2417 </xsl:template>
2418
2419 <xsl:template name="ccdStatusElement">
2420 <xsl:param name="statusCode"/>
2421 <xsl:param name="statusDisplayName"/>
2422 <value>
2423 <xsl:attribute name="xsi:type">CE</xsl:attribute>
2424 <xsl:attribute name="code">
2425 <xsl:value-of select="$statusCode"></xsl:value-of>
2426 </xsl:attribute>
2427 <xsl:attribute name="codeSystem">2.16.840.1.113883.6.96</xsl:attribute>
2428 <xsl:attribute name="displayName">
2429 <xsl:value-of select="$statusDisplayName"></xsl:value-of>
2430 </xsl:attribute>
2431 </value>
2432 </xsl:template>
2433
2434 <xsl:template name="labObservation">
2435 <xsl:param name="ccrTestNode"/>
2436 <xsl:param name="testDate"/>
2437
2438 <component>
2439 <observation classCode="OBS" moodCode="EVN">
2440 <templateId root="2.16.840.1.113883.3.88.11.83.15" assigningAuthorityName="HITSP C83"/>
2441 <templateId root="2.16.840.1.113883.10.20.1.31" assigningAuthorityName="CCD"/>
2442 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13" assigningAuthorityName="IHE PCC"/>
2443 <!-- Result observation template -->
2444
2445 <xsl:call-template name="ccdID">
2446 <xsl:with-param name="ccrObjectID" select="$ccrTestNode/a:CCRDataObjectID"/>
2447 </xsl:call-template>
2448
2449 <!-- <code> -->
2450 <xsl:call-template name="ccdCodedValue">
2451 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Description"/>
2452 <xsl:with-param name="nodeName" select="'code'"/>
2453 </xsl:call-template>
2454
2455 <text>
2456 <reference>
2457 <xsl:attribute name="value">
2458 <xsl:text>#</xsl:text>
2459 <xsl:value-of select="$ccrTestNode/a:CCRDataObjectID"/>
2460 </xsl:attribute>
2461 </reference>
2462 </text>
2463
2464 <statusCode code="completed"/>
2465
2466 <!-- <effectiveTime> -->
2467 <xsl:choose>
2468 <xsl:when test="$ccrTestNode/a:DateTime">
2469 <xsl:call-template name="ccdDateTime">
2470 <xsl:with-param name="dt" select="$ccrTestNode/a:DateTime"/>
2471 </xsl:call-template>
2472 </xsl:when>
2473 <xsl:otherwise>
2474 <xsl:call-template name="ccdDateTime">
2475 <xsl:with-param name="dt" select="$testDate"/>
2476 </xsl:call-template>
2477 </xsl:otherwise>
2478 </xsl:choose>
2479
2480 <xsl:choose>
2481 <xsl:when test="$ccrTestNode/a:TestResult[a:Value!='']">
2482 <value xsi:type="PQ">
2483 <xsl:attribute name="value">
2484 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Value"/>
2485 </xsl:attribute>
2486 <xsl:attribute name="unit">
2487 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Units/a:Unit"/>
2488 </xsl:attribute>
2489 </value>
2490 </xsl:when>
2491 <xsl:when test="$ccrTestNode/a:TestResult[a:Description/a:Text!='']">
2492 <value xsi:type="TX">
2493 <xsl:attribute name="value">
2494 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Description/a:Text"/>
2495 </xsl:attribute>
2496 </value>
2497 </xsl:when>
2498 </xsl:choose>
2499
2500 <xsl:if test="$ccrTestNode/a:Flag">
2501 <xsl:call-template name="ccdCodedValue">
2502 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Flag"/>
2503 <xsl:with-param name="nodeName" select="'interpretationCode'"/>
2504 <xsl:with-param name="domain" select="'ObservationInterpretation'"/>
2505 </xsl:call-template>
2506 </xsl:if>
2507
2508 <xsl:if test="$ccrTestNode/a:NormalResult">
2509 <referenceRange>
2510 <xsl:if test="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text">
2511 <observationRange>
2512 <text>
2513 <xsl:value-of select="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text"/>
2514 </text>
2515 </observationRange>
2516 </xsl:if>
2517 </referenceRange>
2518 </xsl:if>
2519
2520 </observation>
2521 </component>
2522
2523 </xsl:template>
2524</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.