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

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

added some additional code for allergy templates, added some missing markup in a couple sections

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