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

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

some additional changes were unsaved in TortoiseMerge, when I committed (whoops, so this file is correct

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