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

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

new file

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