source: ccr2ccd-xslt/trunk/make/ccr_ccd.xsl@ 1806

Last change on this file since 1806 was 876, checked in by George Lilly, 14 years ago

test of the reassembly

File size: 197.4 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3Conversion of CCR to Level 3 CCD
4
5Orginal Author: Ken Miller
6Solventus LLC
7ken.miller@solventus.coms
8
9Contributors:
10Richard Braman, EHR Doctors, Inc rbraman@ehrdoctors.com
11George Lilly (WorldVistA glilly@glilly.net)
12xxxx - Oroville Hospital
13
14Date: 2010-05-5
15Version: 0.1
16
17License :
18
19 This program is free software: you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation, either version 3 of the License, or
22 (at your option) any later version.
23
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
28
29 You should have received a copy of the GNU General Public License
30 along with this program. If not, see http://www.gnu.org/licenses.
31
32-->
33<xsl:stylesheet version="1.0" xmlns="urn:hl7-org:v3" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:astm-org:CCR" xmlns:date="http://exslt.org/dates-and-times"
34xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="a date">
35 <xsl:import href="./templates/cdavocablookup.xsl"/>
36 <xsl:import href="./templates/hl7oidlookup.xsl"/>
37 <xsl:import href="./templates/code.xsl"/>
38 <xsl:import href="./templates/actor.xsl"/>
39 <xsl:import href="./templates/datetime.xsl"/>
40 <xsl:import href="./templates/problemDescription.xsl"/>
41
42 <xsl:output method="xml" encoding="utf-8" version="1.0" indent="yes"/>
43 <xsl:template match="/">
44 <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:sdtc="urn:hl7-org:sdtc" xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd" classCode="DOCCLIN" moodCode="EVN">
45 <realmCode code="US"/>
46 <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
47 <templateId root="2.16.840.1.113883.10.20.1"/>
48 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.1.1"/>
49 <templateId root="2.16.840.1.113883.10.20.3"/>
50 <templateId root="2.16.840.1.113883.3.88.11.32.1"/>
51
52 <id>
53 <xsl:attribute name="root">
54 <xsl:value-of select="/a:ContinuityOfCareRecord/a:CCRDocumentObjectID"></xsl:value-of>
55 </xsl:attribute>
56 </id>
57 <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Summarization of episode note"/>
58 <xsl:variable name="fromID" select="/a:ContinuityOfCareRecord/a:From/a:ActorLink[1]/a:ActorID"/>
59 <xsl:variable name="ccrFromActorObjectID" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$fromID]/a:InternalCCRLink[a:LinkRelationship='representedOrganization']/a:LinkID"/>
60 <title>Continuity of Care Document from <xsl:value-of select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrFromActorObjectID]/a:Organization/a:Name"/></title>
61 <effectiveTime>
62 <xsl:attribute name="value">
63 <xsl:call-template name="date:format-date">
64 <xsl:with-param name="date-time" select="/a:ContinuityOfCareRecord/a:DateTime/a:ExactDateTime"/>
65 <xsl:with-param name="pattern">yyyyMMddhhmmss+0000</xsl:with-param>
66 </xsl:call-template>
67 </xsl:attribute>
68 </effectiveTime>
69 <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/>
70 <languageCode code="en-US"/>
71
72 <recordTarget typeCode="RCT" contextControlCode="OP">
73 <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" assigningAuthorityName="HL7 CCD"/>
306 <templateId root="2.16.840.1.113883.3.88.11.83.116" assigningAuthorityName="HITSP/C83"/>
307 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.35" assigningAuthorityName="IHE PCC"/>
308 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.34" assigningAuthorityName="IHE PCC"/>
309 <!--Advance Directives section template-->
310 <code code="42348-3" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Advance directives"/>
311 <title>Advance Directives</title>
312 <text>
313 <table>
314 <tbody>
315 <tr>
316 <th>Type</th>
317 <th>Date</th>
318 <th>Description</th>
319 <th>Status</th>
320 <th>Source</th>
321 </tr>
322 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:AdvanceDirectives/a:AdvanceDirective">
323 <tr>
324 <xsl:attribute name="id">
325 <xsl:value-of select="a:CCRDataObjectID"/>
326 </xsl:attribute>
327 <td>
328 <xsl:value-of select="a:Type/a:Text"/>
329 </td>
330 <td>
331 <xsl:call-template name="date:format-date">
332 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
333 </xsl:call-template>
334 </td>
335 <td>
336 <xsl:attribute name="id">
337 <xsl:value-of select="a:CCRDataObjectID"/>
338 <xsl:text>:Narrative</xsl:text>
339 </xsl:attribute>
340
341 <xsl:value-of select="a:Description/a:Text"/>
342 </td>
343 <td>
344 <xsl:value-of select="a:Status/a:Text"/>
345 </td>
346 <td>
347 <xsl:call-template name="actorName">
348 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
349 </xsl:call-template>
350 </td>
351 </tr>
352 </xsl:for-each>
353 </tbody>
354 </table>
355 </text>
356 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:AdvanceDirectives/a:AdvanceDirective">
357 <entry typeCode="DRIV">
358 <observation classCode="OBS" moodCode="EVN">
359 <templateId root="2.16.840.1.113883.3.88.11.83.12" assigningAuthorityName="HITSP C83"/>
360 <templateId root="2.16.840.1.113883.10.20.1.17" assigningAuthorityName="CCD"/>
361 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13" assigningAuthorityName="IHE PCC"/>
362 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13.7" assigningAuthorityName="IHE PCC"/>
363 <!-- Advance directive observation template -->
364
365 <!-- <id> -->
366 <xsl:call-template name="ccdID">
367 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
368 </xsl:call-template>
369
370 <text>
371 <reference>
372 <xsl:attribute name="value">
373 <xsl:text>#</xsl:text>
374 <xsl:value-of select="a:CCRDataObjectID"/>
375 </xsl:attribute>
376 </reference>
377 </text>
378
379 <statusCode code="completed"/>
380
381 <xsl:call-template name="ccdDateTime">
382 <xsl:with-param name="dt" select="a:DateTime"/>
383 </xsl:call-template>
384
385 <xsl:call-template name="ccdCodedValue">
386 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
387 <xsl:with-param name="originalTextReference">
388 <xsl:text>#</xsl:text>
389 <xsl:value-of select="a:CCRDataObjectID"/>
390 <xsl:text>:Narrative</xsl:text>
391 </xsl:with-param>
392 </xsl:call-template>
393
394 <participant typeCode="VRF">
395 <templateId root="2.16.840.1.113883.10.20.1.58"/>
396 <!--Verification of an advance directive observation template -->
397 <time nullFlavor="UNK"/>
398 <xsl:call-template name="ccdParticipantRoleActor">
399 <xsl:with-param name="ccrActorObjectID" select="a:Source[1]/a:ActorID"/>
400 </xsl:call-template>
401 </participant>
402
403 <xsl:if test="a:ReferenceID">
404 <reference typeCode="REFR">
405 <externalDocument>
406 <templateId root="2.16.840.1.113883.10.20.1.36"/>
407 <!-- Advance directive reference template -->
408 <xsl:variable name="referenceID" select="a:ReferenceID"/>
409 <!-- <id> -->
410 <xsl:call-template name="ccdID">
411 <xsl:with-param name="ccrObjectID" select="$referenceID"/>
412 </xsl:call-template>
413 <code code="371538006" codeSystem="2.16.840.1.113883.6.96" displayName="Advance directive"/>
414 <xsl:variable name="reference" select="/a:ContinuityOfCareRecord/a:References/a:Reference[a:ReferenceObjectID=$referenceID]"/>
415 <text>
416 <xsl:attribute name="mediaType">
417 <xsl:value-of select="$reference/a:Type/a:Text"/>
418 </xsl:attribute>
419 <reference>
420 <xsl:value-of select="$reference/a:Location[1]/a:Description/a:Text"/>
421 </reference>
422 </text>
423 </externalDocument>
424 </reference>
425 </xsl:if>
426 </observation>
427 </entry>
428
429 </xsl:for-each>
430 </section>
431 </component>
432 </xsl:if>
433 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:FunctionalStatus">
434 <component>
435 <section>
436 <templateId root="2.16.840.1.113883.10.20.1.5"/>
437 <code code="47420-5" codeSystem="2.16.840.1.113883.6.1"/>
438 <title>Functional Status</title>
439 <text>
440 <table>
441 <tbody>
442 <tr>
443 <th>Type</th>
444 <th>Date</th>
445 <th>Code</th>
446 <th>Description</th>
447 <th>Status</th>
448 <th>Source</th>
449 </tr>
450 <tr>
451 <td>
452 <xsl:value-of select="a:Type/a:Text"/>
453 </td>
454 <td>
455 <xsl:call-template name="date:format-date">
456 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
457 </xsl:call-template>
458 </td>
459 <td>
460 <xsl:apply-templates select="a:Description/a:Code"/>
461 </td>
462 <td>
463 <xsl:value-of select="a:Description/a:Text"/>
464 </td>
465 <td>
466 <xsl:value-of select="a:Status/a:Text"/>
467 </td>
468 <td>
469 <xsl:call-template name="actorName">
470 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
471 </xsl:call-template>
472 </td>
473 </tr>
474 </tbody>
475 </table>
476 </text>
477 </section>
478 </component>
479 </xsl:if>
480 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Problems">
481 <component>
482 <section>
483 <templateId root="2.16.840.1.113883.3.88.11.83.103" assigningAuthorityName="HITSP/C83"/>
484 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.6" assigningAuthorityName="IHE PCC"/>
485 <templateId root="2.16.840.1.113883.10.20.1.11" assigningAuthorityName="HL7 CCD"/>
486 <code code="11450-4" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Problem list"/>
487 <title>Problems</title>
488 <text>
489 <table>
490 <tbody>
491 <tr>
492 <th>Type</th>
493 <th>Date</th>
494 <th>Code</th>
495 <th>Description</th>
496 <th>Status</th>
497 <th>Source</th>
498 </tr>
499 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
500 <tr>
501 <td>
502 <xsl:value-of select="a:Type/a:Text"/>
503 </td>
504 <td>
505 <table>
506 <tbody>
507 <xsl:apply-templates select="a:DateTime"/>
508 </tbody>
509 </table>
510 </td>
511 <td>
512 <xsl:apply-templates select="a:Description/a:Code"/>
513 </td>
514 <td>
515 <xsl:attribute name="ID">
516 <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
517 </xsl:attribute>
518 <xsl:value-of select="a:Description/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 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
534 <entry typeCode="DRIV">
535 <act classCode="ACT" moodCode="EVN">
536 <templateId root="2.16.840.1.113883.10.20.1.27"/>
537 <!-- Problem act template -->
538
539 <!-- <id> -->
540 <xsl:call-template name="ccdID">
541 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
542 </xsl:call-template>
543
544 <code nullFlavor="NA"/>
545
546 <xsl:call-template name="ccdPerformer">
547 <xsl:with-param name="ccrActorReference" select="a:Source/a:Actor"/>
548 </xsl:call-template>
549
550 <entryRelationship typeCode="SUBJ">
551 <observation classCode="OBS" moodCode="EVN">
552 <templateId root="2.16.840.1.113883.10.20.1.28" assigningAuthorityName="CCD"/>
553 <!--Problem observation template-->
554
555 <!-- <id> -->
556 <xsl:call-template name="ccdID">
557 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
558 <xsl:with-param name="suffix"></xsl:with-param>
559 </xsl:call-template>
560
561 <code code="55607006" displayName="Problem" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT"/>
562
563 <text>
564 <reference>
565 <xsl:attribute name="value">
566 <xsl:text>#</xsl:text>
567 <xsl:value-of select="a:CCRDataObjectID"/>
568 </xsl:attribute>
569 </reference>
570 </text>
571
572 <statusCode code="completed"/>
573
574 <xsl:call-template name="ccdDateTime">
575 <xsl:with-param name="dt" select="a:DateTime"/>
576 </xsl:call-template>
577
578 <xsl:call-template name="ccdCodedValue">
579 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
580 </xsl:call-template>
581
582 <xsl:call-template name="ccdStatus">
583 <xsl:with-param name="ccrStatus" select="a:Status"/>
584 </xsl:call-template>
585 </observation>
586 </entryRelationship>
587
588 </act>
589 </entry>
590 </xsl:for-each>
591 </section>
592 </component>
593 </xsl:if>
594 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Procedures">
595 <component>
596 <section>
597 <templateId root="2.16.840.1.113883.10.20.1.12"/>
598 <code code="47519-4" codeSystem="2.16.840.1.113883.6.1"/>
599 <title>Procedures</title>
600 <text>
601 <table>
602 <tbody>
603 <tr>
604 <th>Type</th>
605 <th>Date</th>
606 <th>Code</th>
607 <th>Description</th>
608 <th>Location</th>
609 <th>Substance</th>
610 <th>Method</th>
611 <th>Position</th>
612 <th>Site</th>
613 <th>Status</th>
614 <th>Source</th>
615 </tr>
616 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
617 <tr>
618 <xsl:attribute name="id">
619 <xsl:value-of select="a:CCRDataObjectID"/>
620 </xsl:attribute>
621
622 <td>
623 <xsl:value-of select="a:Type/a:Text"/>
624 </td>
625 <table>
626 <tbody>
627 <xsl:apply-templates select="a:DateTime"/>
628 </tbody>
629 </table>
630 <td>
631 <xsl:apply-templates select="a:Description/a:Code"/>
632 </td>
633 <td>
634 <xsl:value-of select="a:Description/a:Text"/>
635 </td>
636 <td>
637 <xsl:for-each select="a:Locations/a:Location">
638 <xsl:value-of select="a:Description/a:Text"/>
639 <xsl:if test="a:Actor">
640 (<xsl:call-template name="actorName">
641 <xsl:with-param name="objID" select="a:Actor/a:ActorID"/>
642 </xsl:call-template>
643 <xsl:if test="a:Actor/a:ActorRole/a:Text">
644 <xsl:text xml:space="preserve"> - </xsl:text><xsl:value-of select="a:ActorRole/a:Text"/>)
645 </xsl:if>
646 </xsl:if>)
647 <xsl:if test="position() != last()">
648 <br/>
649 </xsl:if>
650 </xsl:for-each>
651 </td>
652 <td>
653 <xsl:for-each select="a:Substance">
654 <xsl:value-of select="a:Text"/>
655 </xsl:for-each>
656 </td>
657 <td>
658 <xsl:value-of select="a:Method/a:Text"/>
659 </td>
660 <td>
661 <xsl:value-of select="a:Position/a:Text"/>
662 </td>
663 <td>
664 <xsl:value-of select="a:Site/a:Text"/>
665 </td>
666 <td>
667 <xsl:value-of select="a:Status/a:Text"/>
668 </td>
669 <td>
670 <xsl:call-template name="actorName">
671 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
672 </xsl:call-template>
673 </td>
674 </tr>
675 </xsl:for-each>
676 </tbody>
677 </table>
678 </text>
679
680 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
681 <entry typeCode="DRIV">
682 <procedure classCode="PROC" moodCode="EVN">
683 <templateId root="2.16.840.1.113883.3.88.11.83.17" assigningAuthorityName="HITSP C83"/>
684 <templateId root="2.16.840.1.113883.10.20.1.29" assigningAuthorityName="CCD"/>
685 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.19" assigningAuthorityName="IHE PCC"/>
686
687 <!-- <id> -->
688 <xsl:call-template name="ccdID">
689 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
690 </xsl:call-template>
691
692 <!-- <code> -->
693 <xsl:call-template name="ccdCodedValue">
694 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
695 <xsl:with-param name="nodeName" select="'code'"/>
696 </xsl:call-template>
697
698 <text>
699 <reference>
700 <xsl:attribute name="value">
701 <xsl:text>#</xsl:text>
702 <xsl:value-of select="a:CCRDataObjectID"/>
703 </xsl:attribute>
704 </reference>
705 </text>
706
707 <xsl:call-template name="ccdStatusProcedure">
708 <xsl:with-param name="status" select="a:Status"/>
709 </xsl:call-template>
710
711 <xsl:call-template name="ccdDateTime">
712 <xsl:with-param name="dt" select="a:DateTime"/>
713 </xsl:call-template>
714
715 <xsl:if test="a:Method">
716 <xsl:call-template name="ccdCodedValue">
717 <xsl:with-param name="ccrCodedDescription" select="a:Method"/>
718 <xsl:with-param name="nodeName" select="'approachSiteCode'"/>
719 </xsl:call-template>
720 </xsl:if>
721
722 <xsl:if test="a:Site">
723 <xsl:call-template name="ccdCodedValue">
724 <xsl:with-param name="ccrCodedDescription" select="a:Site"/>
725 <xsl:with-param name="nodeName" select="'targetSiteCode'"/>
726 </xsl:call-template>
727 </xsl:if>
728
729 <xsl:if test="a:Practitioners/a:Practitioner">
730 <xsl:call-template name="ccdPerformer">
731 <xsl:with-param name="ccrActorReference" select="a:Practitioners/a:Practitioner[1]"/>
732 </xsl:call-template>
733 </xsl:if>
734 </procedure>
735 </entry>
736 </xsl:for-each>
737 </section>
738 </component>
739 </xsl:if>
740 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Medications">
741 <component>
742 <section>
743 <templateId root="2.16.840.1.113883.3.88.11.83.112" assigningAuthorityName="HITSP/C83"/>
744 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.19" assigningAuthorityName="IHE PCC"/>
745 <templateId root="2.16.840.1.113883.10.20.1.8" assigningAuthorityName="HL7 CCD"/>
746 <!--Medications section template-->
747 <code code="10160-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="History of medication use"/>
748 <title>Medications</title>
749 <text>
750 <table>
751 <tbody>
752 <tr>
753 <th>Medication</th>
754 <th>Date</th>
755 <th>Status</th>
756 <th>Form</th>
757 <th>Strength</th>
758 <th>Quantity</th>
759 <th>SIG</th>
760 <th>Indications</th>
761 <th>Instruction</th>
762 <th>Refills</th>
763 <th>Source</th>
764 </tr>
765 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Medications/a:Medication">
766 <tr>
767 <td>
768 <xsl:value-of select="a:Product/a:ProductName/a:Text"/>
769 <xsl:if test="a:Product/a:BrandName">
770 <xsl:text xml:space="preserve"> </xsl:text>(<xsl:value-of select="a:Product/a:BrandName/a:Text"/>)
771 </xsl:if>
772 </td>
773 <td>
774 <xsl:call-template name="date:format-date">
775 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
776 </xsl:call-template>
777 </td>
778 <td>
779 <xsl:value-of select="a:Status/a:Text"/>
780 </td>
781 <td>
782 <xsl:value-of select="a:Product/a:Form/a:Text"/>
783 </td>
784 <td>
785 <xsl:for-each select="a:Product/a:Strength">
786 <xsl:if test="position() > 1">
787 <xsl:text>/</xsl:text>
788 </xsl:if>
789 <xsl:value-of select="a:Value"/>
790 <xsl:text xml:space="preserve"> </xsl:text>
791 <xsl:value-of select="a:Units/a:Unit"/>
792 </xsl:for-each>
793 </td>
794 <td>
795 <xsl:value-of select="a:Quantity/a:Value"/>
796 <xsl:text xml:space="preserve"> </xsl:text>
797 <xsl:value-of select="a:Quantity/a:Units/a:Unit"/>
798 </td>
799 <td>
800 <xsl:for-each select="a:Directions/a:Direction">
801 <xsl:choose>
802 <xsl:when test="a:Description/a:Text">
803 <xsl:value-of select="a:Description/a:Text"/>
804 </xsl:when>
805 <xsl:otherwise>
806 <xsl:value-of select="a:Dose/a:Value"/>
807 <xsl:text xml:space="preserve"> </xsl:text>
808 <xsl:value-of select="a:Dose/a:Units/a:Unit"/>
809 <xsl:text xml:space="preserve"> </xsl:text>
810 <xsl:value-of select="a:Route/a:Text"/>
811 <xsl:text xml:space="preserve"> </xsl:text>
812 <xsl:value-of select="a:Frequency/a:Value"/>
813 <xsl:if test="a:Duration">
814 <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>
815 </xsl:if>
816 <xsl:if test="a:MultipleDirectionModifier/a:ObjectAttribute">
817 <xsl:for-each select="a:MultipleDirectionModifier/a:ObjectAttribute">
818 <xsl:value-of select="a:Attribute"/>
819 <br/>
820 <xsl:value-of select="a:AttributeValue/a:Value"/>
821 </xsl:for-each>
822 </xsl:if>
823 </xsl:otherwise>
824 </xsl:choose>
825 </xsl:for-each>
826 </td>
827 <td>
828 <xsl:for-each select="a:Directions/a:Direction[1]/a:Indication">
829 <xsl:call-template name="problemDescription">
830 <xsl:with-param name="objID" select="a:InternalCCRLink/a:LinkID"/>
831 </xsl:call-template>
832 <br/>
833 </xsl:for-each>
834 </td>
835 <td>
836 <xsl:for-each select="a:PatientInstructions/a:Instruction">
837 <xsl:value-of select="a:Text"/>
838 <br/>
839 </xsl:for-each>
840 </td>
841 <td>
842 <xsl:for-each select="a:Refills/a:Refill">
843 <xsl:value-of select="a:Number"/>
844 <xsl:text xml:space="preserve"> </xsl:text>
845 </xsl:for-each>
846 </td>
847 <td>
848 <xsl:call-template name="actorName">
849 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
850 </xsl:call-template>
851 </td>
852 </tr>
853 </xsl:for-each>
854 </tbody>
855 </table>
856 </text>
857 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Medications/a:Medication">
858 <entry typeCode="DRIV">
859 <substanceAdministration classCode="SBADM" moodCode="EVN">
860 <templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
861 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.1" assigningAuthorityName="IHE PCC"/>
862
863 <!--Medication activity template -->
864
865 <!-- <id> -->
866 <xsl:call-template name="ccdID">
867 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
868 </xsl:call-template>
869
870 <statusCode code='completed'/>
871
872 <xsl:call-template name="ccdDateTime">
873 <xsl:with-param name="dt" select="a:DateTime"/>
874 <xsl:with-param name="type" select="'IVL_TS'"/>
875 </xsl:call-template>
876
877 <xsl:call-template name="ccdMedicationFrequency">
878 <xsl:with-param name="frequency" select="a:Directions/a:Direction/a:Frequency"/>
879 </xsl:call-template>
880
881 <xsl:call-template name="ccdCodedValue">
882 <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Route"/>
883 <xsl:with-param name="nodeName" select="'routeCode'"/>
884 <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
885 </xsl:call-template>
886
887 <xsl:if test="a:Directions/a:Direction/a:Dose">
888 <doseQuantity>
889 <low>
890 <xsl:attribute name="value">
891 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
892 </xsl:attribute>
893 <xsl:attribute name="unit">
894 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
895 </xsl:attribute>
896 </low>
897 <high>
898 <xsl:attribute name="value">
899 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
900 </xsl:attribute>
901 <xsl:attribute name="unit">
902 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
903 </xsl:attribute>
904 </high>
905 </doseQuantity>
906 </xsl:if>
907 <consumable>
908 <manufacturedProduct>
909 <templateId root="2.16.840.1.113883.3.88.11.83.8.2" assigningAuthorityName="HITSP C83"/>
910 <templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
911 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
912
913 <!-- Product template -->
914
915 <manufacturedMaterial>
916 <xsl:call-template name="ccdCodedValue">
917 <xsl:with-param name="ccrCodedDescription" select="a:Product/a:ProductName"/>
918 <xsl:with-param name="nodeName" select="'code'"/>
919 </xsl:call-template>
920 <name>
921 <xsl:value-of select="a:Product/a:BrandName/a:Text"/>
922 </name>
923 </manufacturedMaterial>
924 </manufacturedProduct>
925 </consumable>
926 </substanceAdministration>
927 </entry>
928 </xsl:for-each>
929 </section>
930 </component>
931 </xsl:if>
932 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Immunizations">
933 <component>
934 <section>
935 <templateId root="2.16.840.1.113883.10.20.1.6"/>
936 <code code="11369-6" codeSystem="2.16.840.1.113883.6.1"/>
937 <title>Immunizations</title>
938 <text>
939 <table>
940 <tbody>
941 <tr>
942 <th>Code</th>
943 <th>Vaccine</th>
944 <th>Date</th>
945 <th>Route</th>
946 <th>Site</th>
947 <th>Source</th>
948 </tr>
949 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Immunizations/a:Immunization">
950 <tr>
951 <xsl:attribute name="id">
952 <xsl:value-of select="a:CCRDataObjectID"/>
953 </xsl:attribute>
954 <td>
955 <xsl:apply-templates select="a:Product/a:ProductName/a:Code"/>
956 </td>
957 <td>
958
959 <xsl:value-of select="a:Product/a:ProductName/a:Text"/>
960 <xsl:if test="a:Product/a:Form">
961 <xsl:text xml:space="preserve"> </xsl:text>(<xsl:value-of select="a:Product/a:Form/a:Text"/>)
962 </xsl:if>
963 </td>
964 <td>
965 <xsl:call-template name="date:format-date">
966 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
967 </xsl:call-template>
968 </td>
969 <td>
970 <xsl:value-of select="a:Directions/a:Direction/a:Route/a:Text"/>
971 </td>
972 <td>
973 <xsl:attribute name="id">
974 <xsl:value-of select="a:CCRDataObjectID"/>
975 <xsl:text>:Site</xsl:text>
976 </xsl:attribute>
977
978 <xsl:value-of select="a:Directions/a:Direction/a:Site/a:Text"/>
979 </td>
980 <td>
981 <xsl:call-template name="actorName">
982 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
983 </xsl:call-template>
984 </td>
985 </tr>
986 </xsl:for-each>
987 </tbody>
988 </table>
989 </text>
990 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Immunizations/a:Immunization">
991 <entry typeCode="DRIV">
992 <substanceAdministration classCode="SBADM" moodCode="EVN">
993 <templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
994 <templateId root="2.16.840.1.113883.3.88.11.83.13" assigningAuthorityName="HITSP C83"/>
995 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.12" assigningAuthorityName="IHE PCC"/>
996
997 <!-- Medication activity template -->
998
999 <!-- <id> -->
1000 <xsl:call-template name="ccdID">
1001 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1002 </xsl:call-template>
1003
1004 <code code="IMMUNIZ" codeSystem="2.16.840.1.113883.5.4" codeSystemName="HL7 ActCode"/>
1005 <text>
1006 <reference>
1007 <xsl:attribute name="value">
1008 <xsl:text>#</xsl:text>
1009 <xsl:value-of select="a:CCRDataObjectID"/>
1010 </xsl:attribute>
1011 </reference>
1012 </text>
1013
1014 <statusCode code='completed'/>
1015
1016 <xsl:call-template name="ccdDateTime">
1017 <xsl:with-param name="dt" select="a:DateTime"/>
1018 <xsl:with-param name="type" select="'IVL_TS'"/>
1019 </xsl:call-template>
1020
1021 <xsl:call-template name="ccdCodedValue">
1022 <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Route"/>
1023 <xsl:with-param name="nodeName" select="'routeCode'"/>
1024 <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
1025 </xsl:call-template>
1026
1027 <xsl:if test="a:Directions/a:Direction/a:Site">
1028 <xsl:call-template name="ccdCodedValue">
1029 <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Site"/>
1030 <xsl:with-param name="nodeName" select="'approachSiteCode'"/>
1031 <xsl:with-param name="originalTextReference">
1032 <xsl:text>#</xsl:text>
1033 <xsl:value-of select="a:CCRDataObjectID"/>
1034 <xsl:text>:Site</xsl:text>
1035 </xsl:with-param>
1036 </xsl:call-template>
1037 </xsl:if>
1038
1039 <consumable>
1040 <manufacturedProduct>
1041 <templateId root="2.16.840.1.113883.3.88.11.83.8.2" assigningAuthorityName="HITSP C83"/>
1042 <templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
1043 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
1044
1045 <!-- Product template -->
1046
1047 <manufacturedMaterial>
1048 <xsl:call-template name="ccdCodedValue">
1049 <xsl:with-param name="ccrCodedDescription" select="a:Product/a:ProductName"/>
1050 <xsl:with-param name="nodeName" select="'code'"/>
1051 </xsl:call-template>
1052 <name>
1053 <xsl:value-of select="a:Product/a:BrandName/a:Text"/>
1054 </name>
1055 </manufacturedMaterial>
1056 </manufacturedProduct>
1057 </consumable>
1058
1059 </substanceAdministration>
1060 </entry>
1061 </xsl:for-each>
1062 </section>
1063 </component>
1064 </xsl:if>
1065 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:VitalSigns">
1066 <component>
1067 <section>
1068 <templateId root="2.16.840.1.113883.10.20.1.16"/>
1069 <code code="8716-3" codeSystem="2.16.840.1.113883.6.1"/>
1070 <title>Vital Signs</title>
1071 <text>
1072 <table>
1073 <tbody>
1074 <tr>
1075 <th>Vital Sign</th>
1076 <th>Date</th>
1077 <th>Result</th>
1078 <th>Source</th>
1079 </tr>
1080 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:VitalSigns/a:Result">
1081 <tr>
1082 <xsl:attribute name="id">
1083 <xsl:value-of select="a:CCRDataObjectID"/>
1084 </xsl:attribute>
1085
1086 <td>
1087 <xsl:value-of select="a:Description/a:Text"/>
1088 </td>
1089 <td>
1090 <xsl:call-template name="date:format-date">
1091 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1092 </xsl:call-template>
1093 </td>
1094 <td>
1095 <xsl:for-each select="a:Test">
1096 <xsl:value-of select="a:Description/a:Text"/>
1097 <xsl:text xml:space="preserve"> </xsl:text>
1098 <xsl:value-of select="a:TestResult/a:Value"/>
1099 <xsl:text xml:space="preserve"> </xsl:text>
1100 <xsl:value-of select="a:TestResult/a:Units/a:Unit"/>
1101 <xsl:text xml:space="preserve"> </xsl:text>
1102 <xsl:value-of select="a:Flag/a:Text"/>
1103 <br/>
1104 </xsl:for-each>
1105 </td>
1106 <td>
1107 <xsl:call-template name="actorName">
1108 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1109 </xsl:call-template>
1110 </td>
1111 </tr>
1112 </xsl:for-each>
1113 </tbody>
1114 </table>
1115 </text>
1116 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:VitalSigns/a:Result">
1117 <entry typeCode="DRIV">
1118 <organizer classCode="CLUSTER" moodCode="EVN">
1119 <templateId root="2.16.840.1.113883.10.20.1.32" assigningAuthorityName="CCD"/>
1120 <templateId root="2.16.840.1.113883.10.20.1.35" assigningAuthorityName="CCD"/>
1121 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13.1" assigningAuthorityName="IHE PCC"/>
1122 <!-- Vital signs organizer template -->
1123
1124 <xsl:variable name="testDate" select="a:DateTime"/>
1125
1126 <!-- <id> -->
1127 <xsl:call-template name="ccdID">
1128 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1129 </xsl:call-template>
1130
1131 <code code="46680005" codeSystem="2.16.840.1.113883.6.96" displayName="Vital signs" codeSystemName="SNOMED CT"/>
1132 <statusCode code="completed"/>
1133 <xsl:call-template name="ccdDateTime">
1134 <xsl:with-param name="dt" select="$testDate"/>
1135 </xsl:call-template>
1136
1137 <xsl:call-template name="ccdObservation">
1138 <xsl:with-param name="ccrTestNode" select="a:Test[1]"/>
1139 <xsl:with-param name="testDate" select="$testDate"/>
1140 </xsl:call-template>
1141
1142 </organizer>
1143 </entry>
1144 </xsl:for-each>
1145 </section>
1146 </component>
1147 </xsl:if>
1148 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Encounters">
1149 <component>
1150 <section>
1151 <templateId root="2.16.840.1.113883.3.88.11.83.127" assigningAuthorityName="HITSP/C83"/>
1152 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.1.5.3.3" assigningAuthorityName="IHE PCC"/>
1153 <templateId root="2.16.840.1.113883.10.20.1.3" assigningAuthorityName="HL7 CCD"/>
1154 <!--Encounters section template-->
1155 <code code="46240-8" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="History of encounters"/>
1156 <title>Encounters</title>
1157 <text>
1158 <table>
1159 <tbody>
1160 <tr>
1161 <th>Type</th>
1162 <th>Date</th>
1163 <th>Location</th>
1164 <th>Status</th>
1165 <th>Practitioner</th>
1166 <th>Description</th>
1167 <th>Indications</th>
1168 <th>Source</th>
1169 </tr>
1170 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Encounters/a:Encounter">
1171 <tr>
1172 <xsl:attribute name="id">
1173 <xsl:value-of select="a:CCRDataObjectID"/>
1174 </xsl:attribute>
1175
1176 <td>
1177 <xsl:value-of select="a:Type/a:Text"/>
1178 </td>
1179 <td>
1180 <xsl:call-template name="date:format-date">
1181 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1182 </xsl:call-template>
1183 </td>
1184 <td>
1185 <xsl:for-each select="a:Locations/a:Location">
1186 <xsl:value-of select="a:Description/a:Text"/>
1187 <xsl:call-template name="actorName">
1188 <xsl:with-param name="objID" select="a:Actor/a:ActorID"/>
1189 </xsl:call-template>
1190 <br/>
1191 </xsl:for-each>
1192 </td>
1193 <td>
1194 <xsl:value-of select="a:Status/a:Text"/>
1195 </td>
1196 <td>
1197 <xsl:for-each select="a:Practitioners/a:Practitioner">
1198 <xsl:call-template name="actorName">
1199 <xsl:with-param name="objID" select="a:ActorID"/>
1200 </xsl:call-template>
1201 <br/>
1202 </xsl:for-each>
1203 </td>
1204 <td>
1205 <xsl:value-of select="a:Description/a:Text"/>
1206 </td>
1207 <td>
1208 <xsl:for-each select="a:Indications/a:Indication">
1209 <xsl:call-template name="problemDescription">
1210 <xsl:with-param name="objID" select="a:InternalCCRLink/a:LinkID"/>
1211 </xsl:call-template>
1212 <br/>
1213 </xsl:for-each>
1214 </td>
1215 <td>
1216 <xsl:call-template name="actorName">
1217 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1218 </xsl:call-template>
1219 </td>
1220 </tr>
1221 </xsl:for-each>
1222 </tbody>
1223 </table>
1224 </text>
1225 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Encounters/a:Encounter">
1226 <entry typeCode="DRIV">
1227 <encounter classCode="ENC" moodCode="EVN">
1228 <templateId root="2.16.840.1.113883.3.88.11.83.16" assigningAuthorityName="HITSP C83"/>
1229 <templateId root="2.16.840.1.113883.10.20.1.21" assigningAuthorityName="CCD"/>
1230 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.14" assigningAuthorityName="IHE PCC"/>
1231
1232 <!-- Encounter activity template -->
1233
1234 <!-- <id> -->
1235 <xsl:call-template name="ccdID">
1236 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1237 </xsl:call-template>
1238
1239 <xsl:call-template name="ccdCodedValue">
1240 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1241 <xsl:with-param name="nodeName" select="'code'"/>
1242 </xsl:call-template>
1243
1244 <text>
1245 <reference>
1246 <xsl:attribute name="value">
1247 <xsl:text>#</xsl:text>
1248 <xsl:value-of select="a:CCRDataObjectID"/>
1249 </xsl:attribute>
1250 </reference>
1251 </text>
1252
1253 <xsl:call-template name="ccdDateTime">
1254 <xsl:with-param name="dt" select="a:DateTime"/>
1255 </xsl:call-template>
1256
1257 <xsl:if test="a:Practitioners[1]/a:Practitioner">
1258 <xsl:call-template name="ccdPerformer">
1259 <xsl:with-param name="ccrActorReference" select="a:Practitioners/a:Practitioner[1]"/>
1260 </xsl:call-template>
1261 </xsl:if>
1262
1263 <xsl:if test="a:Locations[1]/a:Location">
1264 <participant typeCode="LOC">
1265 <templateId root="2.16.840.1.113883.10.20.1.45"/>
1266 <!-- Location participation template -->
1267 <xsl:choose>
1268 <xsl:when test="a:Locations[1]/a:Location/a:ActorID">
1269 <xsl:call-template name="ccdParticipantRoleActor">
1270 <xsl:with-param name="ccrActorObjectID" select="a:Locations[1]/a:Location/a:ActorID"/>
1271 </xsl:call-template>
1272 </xsl:when>
1273 <xsl:otherwise>
1274 <xsl:call-template name="ccdParticipantRoleCodedDescription">
1275 <xsl:with-param name="ccrCodedDescription" select="a:Locations[1]/a:Location/a:Description"/>
1276 </xsl:call-template>
1277 </xsl:otherwise>
1278 </xsl:choose>
1279 </participant>
1280 </xsl:if>
1281 </encounter>
1282 </entry>
1283 </xsl:for-each>
1284 </section>
1285 </component>
1286 </xsl:if>
1287 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:SocialHistory">
1288 <component>
1289 <section>
1290 <templateId root="2.16.840.1.113883.10.20.1.15"/>
1291 <code code="29762-2" codeSystem="2.16.840.1.113883.6.1"/>
1292 <title>Social History</title>
1293 <text>
1294 <table>
1295 <tbody>
1296 <tr>
1297 <th>Type</th>
1298 <th>Date</th>
1299 <th>Code</th>
1300 <th>Description</th>
1301 <th>Status</th>
1302 <th>Source</th>
1303 </tr>
1304 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement">
1305 <tr>
1306 <td>
1307 <xsl:value-of select="a:Type/a:Text"/>
1308 </td>
1309 <td>
1310 <xsl:call-template name="date:format-date">
1311 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1312 </xsl:call-template>
1313 </td>
1314 <td>
1315 <xsl:apply-templates select="a:Description/a:Code"/>
1316 </td>
1317 <td>
1318 <xsl:value-of select="a:Description/a:Text" disable-output-escaping="yes"/>
1319 </td>
1320 <td>
1321 <xsl:value-of select="a:Status/a:Text"/>
1322 </td>
1323 <td>
1324 <xsl:call-template name="actorName">
1325 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1326 </xsl:call-template>
1327 </td>
1328 </tr>
1329 </xsl:for-each>
1330 </tbody>
1331 </table>
1332 </text>
1333 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement">
1334 <entry typeCode="DRIV">
1335 <observation classCode="OBS" moodCode="EVN">
1336 <templateId root="2.16.840.1.113883.3.88.11.83.19" assigningAuthorityName="HITSP C83"/>
1337 <templateId root="2.16.840.1.113883.10.20.1.33" assigningAuthorityName="CCD"/>
1338 <!-- Social history observation template -->
1339 <!-- <id> -->
1340 <xsl:call-template name="ccdID">
1341 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1342 </xsl:call-template>
1343 <statusCode code="completed"/>
1344 <xsl:call-template name="ccdDateTime">
1345 <xsl:with-param name="dt" select="a:DateTime"/>
1346 </xsl:call-template>
1347 <entryRelationship typeCode="SUBJ" inversionInd="true">
1348 <observation classCode="OBS" moodCode="EVN">
1349 <templateId root="2.16.840.1.113883.10.20.1.41"/>
1350 <!-- Episode observation template -->
1351 <statusCode code="completed"/>
1352 <entryRelationship typeCode="SAS">
1353 <observation classCode="OBS" moodCode="EVN">
1354 <xsl:call-template name="ccdCodedValue">
1355 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1356 <xsl:with-param name="nodeName" select="'code'"/>
1357 </xsl:call-template>
1358 </observation>
1359 </entryRelationship>
1360 </observation>
1361 </entryRelationship>
1362 </observation>
1363 </entry>
1364 </xsl:for-each>
1365 </section>
1366 </component>
1367 </xsl:if>
1368 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:FamilyHistory">
1369 <component>
1370 <section>
1371 <templateId root="2.16.840.1.113883.10.20.1.4"/>
1372 <code code="10157-6" codeSystem="2.16.840.1.113883.6.1"/>
1373 <title>Family History</title>
1374 <text>
1375 <table>
1376 <tbody>
1377 <tr>
1378 <th>Type</th>
1379 <th>Date</th>
1380 <th>Code</th>
1381 <th>Description</th>
1382 <th>Relationship(s)</th>
1383 <th>Status</th>
1384 <th>Source</th>
1385 </tr>
1386 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:FamilyHistory/a:FamilyProblemHistory">
1387 <tr>
1388 <td>
1389 <xsl:value-of select="a:Type/a:Text"/>
1390 </td>
1391 <td>
1392 <xsl:call-template name="date:format-date">
1393 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1394 </xsl:call-template>
1395 </td>
1396 <td>
1397 <xsl:apply-templates select="a:Problem/a:Description/a:Code"/>
1398 </td>
1399 <td>
1400 <xsl:for-each select="a:Problem">
1401 <xsl:value-of select="a:Description/a:Text"/>
1402 <br/>
1403 </xsl:for-each>
1404 </td>
1405 <td>
1406 <xsl:value-of select="a:FamilyMember/a:ActorRole/a:Text"/>
1407 </td>
1408 <td>
1409 <xsl:value-of select="a:Status/a:Text"/>
1410 </td>
1411 <td>
1412 <xsl:call-template name="actorName">
1413 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1414 </xsl:call-template>
1415 </td>
1416 </tr>
1417 </xsl:for-each>
1418 </tbody>
1419 </table>
1420 </text>
1421 </section>
1422 </component>
1423 </xsl:if>
1424 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
1425 <component>
1426 <section>
1427 <templateId root="2.16.840.1.113883.10.20.1.14"/>
1428 <code code="30954-2" codeSystem="2.16.840.1.113883.6.1"/>
1429 <title>Results</title>
1430 <text>
1431 <table>
1432 <tbody>
1433 <tr>
1434 <th>Test</th>
1435 <th>Date</th>
1436 <th>Result</th>
1437 <th>Source</th>
1438 </tr>
1439 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
1440 <tr>
1441 <xsl:attribute name="id">
1442 <xsl:value-of select="a:CCRDataObjectID"/>
1443 </xsl:attribute>
1444 <td>
1445 <xsl:value-of select="a:Description/a:Text"/>
1446 </td>
1447 <td>
1448 <xsl:call-template name="date:format-date">
1449 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1450 </xsl:call-template>
1451 </td>
1452 <td>
1453 <xsl:for-each select="a:Test[a:TestResult/a:Value!='']">
1454 <div>
1455 <xsl:attribute name="id">
1456 <xsl:value-of select="a:CCRDataObjectID"/>
1457 </xsl:attribute>
1458
1459 <xsl:value-of select="a:Description/a:Text"/>
1460 <xsl:text xml:space="preserve"> </xsl:text>
1461 <xsl:value-of select="a:TestResult/a:Value"/>
1462 <xsl:text xml:space="preserve"> </xsl:text>
1463 <xsl:value-of select="a:TestResult/a:Units/a:Unit"/>
1464 <xsl:text xml:space="preserve"> </xsl:text>
1465 <xsl:value-of select="a:Flag/a:Text"/>
1466 <br/>
1467 </div>
1468 </xsl:for-each>
1469 <xsl:for-each select="a:Test[a:TestResult/a:Description/a:Text!='']">
1470 <div>
1471 <xsl:attribute name="id">
1472 <xsl:value-of select="a:CCRDataObjectID"/>
1473 </xsl:attribute>
1474
1475 <xsl:value-of select="a:Description/a:Text"/>
1476 <xsl:text xml:space="preserve"> </xsl:text>
1477 <xsl:value-of select="a:TestResult/a:Description/a:Text" disable-output-escaping="yes"/>
1478 <xsl:text xml:space="preserve"> </xsl:text>
1479 <xsl:value-of select="a:Flag/a:Text"/>
1480 <br/>
1481 </div>
1482 </xsl:for-each>
1483 </td>
1484 <td>
1485 <xsl:call-template name="actorName">
1486 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1487 </xsl:call-template>
1488 </td>
1489 </tr>
1490 </xsl:for-each>
1491 </tbody>
1492 </table>
1493 </text>
1494 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
1495 <entry typeCode="DRIV">
1496 <xsl:variable name="testDate" select="a:DateTime"/>
1497
1498 <xsl:choose>
1499 <xsl:when test="count(a:Test)>1">
1500 <organizer classCode="BATTERY" moodCode="EVN">
1501 <templateId root="2.16.840.1.113883.10.20.1.32"/>
1502 <!--Result organizer template -->
1503
1504 <!-- <id> -->
1505 <xsl:call-template name="ccdID">
1506 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1507 </xsl:call-template>
1508
1509 <!-- <code> -->
1510 <xsl:call-template name="ccdCodedValue">
1511 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1512 <xsl:with-param name="nodeName" select="'code'"/>
1513 </xsl:call-template>
1514
1515 <statusCode code="completed"/>
1516
1517 <!-- <effectiveTime> -->
1518 <xsl:call-template name="ccdDateTime">
1519 <xsl:with-param name="dt" select="$testDate"/>
1520 </xsl:call-template>
1521
1522 <xsl:call-template name="ccdPerformer">
1523 <xsl:with-param name="ccrActorReference" select="a:Source/a:Actor"/>
1524 </xsl:call-template>
1525
1526 <xsl:for-each select="a:Test">
1527 <xsl:call-template name="ccdObservation">
1528 <xsl:with-param name="ccrTestNode" select="."/>
1529 <xsl:with-param name="testDate" select="$testDate"/>
1530 </xsl:call-template>
1531 </xsl:for-each>
1532
1533 </organizer>
1534
1535 </xsl:when>
1536 <xsl:otherwise>
1537 <xsl:call-template name="ccdObservation">
1538 <xsl:with-param name="ccrTestNode" select="a:Test[1]"/>
1539 <xsl:with-param name="testDate" select="$testDate"/>
1540 </xsl:call-template>
1541 </xsl:otherwise>
1542 </xsl:choose>
1543 </entry>
1544 </xsl:for-each>
1545 </section>
1546 </component>
1547 </xsl:if>
1548 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Payers">
1549 <component>
1550 <section>
1551 <templateId root="2.16.840.1.113883.10.20.1.9"/>
1552 <code code="48768-6" codeSystem="2.16.840.1.113883.6.1"/>
1553 <title>Insurance</title>
1554 <text>
1555 <table>
1556 <tbody>
1557 <tr>
1558 <th>Type</th>
1559 <th>Date</th>
1560 <th>Identification Numbers</th>
1561 <th>Payment Provider</th>
1562 <th>Subscriber</th>
1563 <th>Source</th>
1564 </tr>
1565 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Payers/a:Payer">
1566 <tr>
1567 <td>
1568 <xsl:value-of select="a:Type/a:Text"/>
1569 </td>
1570 <td>
1571 <xsl:call-template name="date:format-date">
1572 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
1573 </xsl:call-template>
1574 </td>
1575 <td>
1576 <xsl:for-each select="a:IDs">
1577 <xsl:value-of select="a:Type/a:Text"/>:<xsl:text xml:space="preserve"> </xsl:text><xsl:value-of select="a:ID"/><br/>
1578 </xsl:for-each>
1579 </td>
1580 <td>
1581 <xsl:call-template name="actorName">
1582 <xsl:with-param name="objID" select="a:PaymentProvider/a:ActorID"/>
1583 </xsl:call-template>
1584 </td>
1585 <td>
1586 <xsl:call-template name="actorName">
1587 <xsl:with-param name="objID" select="a:Subscriber/a:ActorID"/>
1588 </xsl:call-template>
1589 </td>
1590 <td>
1591 <xsl:call-template name="actorName">
1592 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1593 </xsl:call-template>
1594 </td>
1595 </tr>
1596 </xsl:for-each>
1597 </tbody>
1598 </table>
1599 </text>
1600 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Payers/a:Payer">
1601 <entry typeCode="DRIV">
1602 <act classCode="ACT" moodCode="DEF">
1603 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.17" assigningAuthorityName="IHE PCC"/>
1604 <templateId root="2.16.840.1.113883.10.20.1.20" assigningAuthorityName="CCD"/>
1605 <!-- Coverage entry template -->
1606 <!-- <id> -->
1607 <xsl:call-template name="ccdID">
1608 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1609 </xsl:call-template>
1610 <code code="48768-6" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Payment sources"/>
1611 <statusCode code="completed"/>
1612 <entryRelationship typeCode="COMP">
1613 <act classCode="ACT" moodCode="EVN">
1614 <templateId root="2.16.840.1.113883.3.88.11.83.5" assigningAuthorityName="HITSP C83"/>
1615 <templateId root="2.16.840.1.113883.10.20.1.26" assigningAuthorityName="CCD"/>
1616 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.18" assigningAuthorityName="IHE PCC"/>
1617 <!--Insurance provider template -->
1618 <id>
1619 <xsl:attribute name="root">
1620 <xsl:value-of select="a:IDs[1]/a:ID"/>
1621 </xsl:attribute>
1622 <xsl:attribute name="extension">
1623 <xsl:value-of select="a:IDs[1]/a:Type/a:Text"/>
1624 </xsl:attribute>
1625 </id>
1626
1627 <!-- <code> -->
1628 <xsl:call-template name="ccdCodedValue">
1629 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1630 <xsl:with-param name="nodeName" select="'code'"/>
1631 </xsl:call-template>
1632
1633 <statusCode code="completed"/>
1634
1635 <xsl:call-template name="ccdPerformer">
1636 <xsl:with-param name="ccrActorReference" select="a:PaymentProvider"/>
1637 </xsl:call-template>
1638
1639 <participant typeCode="HLD">
1640 <xsl:call-template name="ccdParticipantRoleActor">
1641 <xsl:with-param name="ccrActorReference" select="a:Subscriber"/>
1642 </xsl:call-template>
1643 </participant>
1644 </act>
1645 </entryRelationship>
1646 </act>
1647 </entry>
1648 </xsl:for-each>
1649 </section>
1650 </component>
1651 </xsl:if>
1652 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare">
1653 <component>
1654 <section>
1655 <templateId root="2.16.840.1.113883.10.20.1.10"/>
1656 <code code="18776-5" codeSystem="2.16.840.1.113883.6.1"/>
1657 <title>Plan Of Care</title>
1658 <text>
1659 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Treatment Recommendation']">
1660 <xsl:text>Plan Of Care Recommendations</xsl:text>
1661 <br/>
1662 <table>
1663 <tbody>
1664 <tr>
1665 <th>Description</th>
1666 <th>Recommendation</th>
1667 <th>Goal</th>
1668 <th>Status</th>
1669 <th>Source</th>
1670 </tr>
1671 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Treatment Recommendation']">
1672 <tr>
1673 <td>
1674 <xsl:value-of select="a:Description/a:Text"/>
1675 </td>
1676 <td>
1677 <xsl:value-of select="a:OrderRequest/a:Description/a:Text" disable-output-escaping="yes"/>
1678 </td>
1679 <td>
1680 <xsl:value-of select="a:OrderRequest/a:Goals/a:Goal/a:Description/a:Text" disable-output-escaping="yes"/>
1681 </td>
1682 <td>
1683 <xsl:value-of select="a:Status/a:Text"/>
1684 </td>
1685 <td>
1686 <xsl:call-template name="actorName">
1687 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1688 </xsl:call-template>
1689 </td>
1690 </tr>
1691 </xsl:for-each>
1692 </tbody>
1693 </table>
1694 </xsl:if>
1695 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Order']">
1696 <xsl:text>Plan Of Care Orders</xsl:text>
1697 <br/>
1698 <table>
1699 <tbody>
1700 <tr>
1701 <th>Descripion</th>
1702 <th>Plan Status</th>
1703 <th>Type</th>
1704 <th>Date</th>
1705 <th>Procedure</th>
1706 <th>Schedule</th>
1707 <th>Location</th>
1708 <th>Substance</th>
1709 <th>Method</th>
1710 <th>Position</th>
1711 <th>Site</th>
1712 <th>Status</th>
1713 <th>Source</th>
1714 </tr>
1715 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Order']">
1716 <tr>
1717 <td>
1718 <xsl:apply-templates select="a:Description/a:Text"/>
1719 </td>
1720 <td>
1721 <xsl:value-of select="a:Status/a:Text"/>
1722 </td>
1723 <td>
1724 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Type/a:Text"/>
1725 </td>
1726 <td>
1727 <xsl:call-template name="date:format-date">
1728 <xsl:with-param name="date-time" select="a:OrderRequest/a:Procedures/a:Procedure/a:DateTime/a:ExactDateTime"/>
1729 </xsl:call-template>
1730 </td>
1731 <td>
1732 <xsl:apply-templates select="a:OrderRequest/a:Procedures/a:Procedure/a:Description/a:Text"/>
1733 </td>
1734 <td>
1735 <xsl:text xml:space="preserve">Every </xsl:text>
1736 <xsl:apply-templates select="a:OrderRequest/a:Procedures/a:Procedure/a:Interval/a:Value"/>
1737 <xsl:text xml:space="preserve"> </xsl:text>
1738 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Interval/a:Units/a:Unit"/>
1739 <xsl:text xml:space="preserve"> for </xsl:text>
1740 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Duration/a:Value"/>
1741 <xsl:text xml:space="preserve"> </xsl:text>
1742 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Duration/a:Units/a:Unit"/>
1743 </td>
1744 <td>
1745 <xsl:for-each select="a:OrderRequest/a:Procedures/a:Procedure/a:Locations">
1746 <xsl:value-of select="a:Location/a:Description/a:Text"/>
1747 <xsl:if test="position() != last()">
1748 <br/>
1749 </xsl:if>
1750 </xsl:for-each>
1751 </td>
1752 <td>
1753 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Substance/a:Text"/>
1754 </td>
1755 <td>
1756 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Method/a:Text"/>
1757 </td>
1758 <td>
1759 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Position/a:Text"/>
1760 </td>
1761 <td>
1762 <xsl:value-of select="a:OrderRequest/a:Procedures/a:Procedure/a:Site/a:Text"/>
1763 </td>
1764 <td/>
1765 <td>
1766 <xsl:call-template name="actorName">
1767 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
1768 </xsl:call-template>
1769 </td>
1770 </tr>
1771 </xsl:for-each>
1772 </tbody>
1773 </table>
1774 </xsl:if>
1775 </text>
1776 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan/a:OrderRequest/a:Procedures/a:Procedure">
1777 <entry typeCode="DRIV">
1778 <observation classCode="OBS" moodCode="RQO">
1779 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.1.20.3.1"/>
1780
1781 <!-- <id> -->
1782 <xsl:call-template name="ccdID">
1783 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1784 </xsl:call-template>
1785
1786 <!-- <code> -->
1787 <xsl:call-template name="ccdCodedValue">
1788 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1789 <xsl:with-param name="nodeName" select="'code'"/>
1790 </xsl:call-template>
1791
1792 <statusCode code="new"/>
1793
1794 <effectiveTime>
1795 <xsl:choose>
1796 <xsl:when test="a:DateTime">
1797 <xsl:call-template name="ccdDateTime">
1798 <xsl:with-param name="dt" select="a:DateTime"/>
1799 </xsl:call-template>
1800 </xsl:when>
1801 <xsl:when test="a:Interval">
1802 <xsl:attribute name="xsi:type">PIVL_TS</xsl:attribute>
1803 <xsl:attribute name="operator">A</xsl:attribute>
1804 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
1805 <period>
1806 <xsl:attribute name="value">
1807 <xsl:value-of select="a:Interval/a:Value"/>
1808 </xsl:attribute>
1809 <xsl:attribute name="unit">
1810 <xsl:value-of select="a:Interval/a:Units/a:Unit"/>
1811 </xsl:attribute>
1812 </period>
1813 </xsl:when>
1814 </xsl:choose>
1815 </effectiveTime>
1816 </observation>
1817 </entry>
1818 </xsl:for-each>
1819
1820 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan/a:OrderRequest/a:Medications/a:Medication">
1821 <entry typeCode="DRIV">
1822 <substanceAdministration classCode="SBADM" moodCode="INT">
1823 <templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
1824 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.1" assigningAuthorityName="IHE PCC"/>
1825
1826 <!--Medication activity template -->
1827
1828 <!-- <id> -->
1829 <xsl:call-template name="ccdID">
1830 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1831 </xsl:call-template>
1832
1833 <statusCode code='completed'/>
1834
1835 <xsl:call-template name="ccdDateTime">
1836 <xsl:with-param name="dt" select="a:DateTime"/>
1837 <xsl:with-param name="type" select="'IVL_TS'"/>
1838 </xsl:call-template>
1839
1840 <xsl:call-template name="ccdMedicationFrequency">
1841 <xsl:with-param name="frequency" select="a:Directions/a:Direction/a:Frequency"/>
1842 </xsl:call-template>
1843
1844 <xsl:call-template name="ccdCodedValue">
1845 <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Route"/>
1846 <xsl:with-param name="nodeName" select="'routeCode'"/>
1847 <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
1848 </xsl:call-template>
1849
1850 <xsl:if test="a:Directions/a:Direction/a:Dose">
1851 <doseQuantity>
1852 <low>
1853 <xsl:attribute name="value">
1854 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
1855 </xsl:attribute>
1856 <xsl:attribute name="unit">
1857 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
1858 </xsl:attribute>
1859 </low>
1860 <high>
1861 <xsl:attribute name="value">
1862 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
1863 </xsl:attribute>
1864 <xsl:attribute name="unit">
1865 <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
1866 </xsl:attribute>
1867 </high>
1868 </doseQuantity>
1869 </xsl:if>
1870 <consumable>
1871 <manufacturedProduct>
1872 <templateId root="2.16.840.1.113883.3.88.11.83.8.2" assigningAuthorityName="HITSP C83"/>
1873 <templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
1874 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
1875
1876 <!-- Product template -->
1877
1878 <manufacturedMaterial>
1879 <xsl:call-template name="ccdCodedValue">
1880 <xsl:with-param name="ccrCodedDescription" select="a:Product/a:ProductName"/>
1881 <xsl:with-param name="nodeName" select="'code'"/>
1882 </xsl:call-template>
1883 <name>
1884 <xsl:value-of select="a:Product/a:BrandName/a:Text"/>
1885 </name>
1886 </manufacturedMaterial>
1887 </manufacturedProduct>
1888 </consumable>
1889 </substanceAdministration>
1890 </entry>
1891 </xsl:for-each>
1892 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan/a:OrderRequest/a:Immunizations/a:Immunization">
1893
1894 <entry typeCode="DRIV">
1895 <substanceAdministration classCode="SBADM" moodCode="EVN">
1896 <templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
1897 <templateId root="2.16.840.1.113883.3.88.11.83.13" assigningAuthorityName="HITSP C83"/>
1898 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.12" assigningAuthorityName="IHE PCC"/>
1899
1900 <!-- Medication activity template -->
1901
1902 <!-- <id> -->
1903 <xsl:call-template name="ccdID">
1904 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1905 </xsl:call-template>
1906
1907 <code code="IMMUNIZ" codeSystem="2.16.840.1.113883.5.4" codeSystemName="HL7 ActCode"/>
1908 <text>
1909 <reference>
1910 <xsl:attribute name="value">
1911 <xsl:text>#</xsl:text>
1912 <xsl:value-of select="a:CCRDataObjectID"/>
1913 </xsl:attribute>
1914 </reference>
1915 </text>
1916
1917 <statusCode code='completed'/>
1918
1919 <xsl:call-template name="ccdDateTime">
1920 <xsl:with-param name="dt" select="a:DateTime"/>
1921 <xsl:with-param name="type" select="'IVL_TS'"/>
1922 </xsl:call-template>
1923
1924 <xsl:call-template name="ccdCodedValue">
1925 <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Route"/>
1926 <xsl:with-param name="nodeName" select="'routeCode'"/>
1927 <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
1928 </xsl:call-template>
1929
1930 <xsl:if test="a:Directions/a:Direction/a:Site">
1931 <xsl:call-template name="ccdCodedValue">
1932 <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Site"/>
1933 <xsl:with-param name="nodeName" select="'approachSiteCode'"/>
1934 <xsl:with-param name="originalTextReference">
1935 <xsl:text>#</xsl:text>
1936 <xsl:value-of select="a:CCRDataObjectID"/>
1937 <xsl:text>:Site</xsl:text>
1938 </xsl:with-param>
1939 </xsl:call-template>
1940 </xsl:if>
1941
1942 <consumable>
1943 <manufacturedProduct>
1944 <templateId root="2.16.840.1.113883.3.88.11.83.8.2" assigningAuthorityName="HITSP C83"/>
1945 <templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
1946 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
1947
1948 <!-- Product template -->
1949
1950 <manufacturedMaterial>
1951 <xsl:call-template name="ccdCodedValue">
1952 <xsl:with-param name="ccrCodedDescription" select="a:Product/a:ProductName"/>
1953 <xsl:with-param name="nodeName" select="'code'"/>
1954 </xsl:call-template>
1955 <name>
1956 <xsl:value-of select="a:Product/a:BrandName/a:Text"/>
1957 </name>
1958 </manufacturedMaterial>
1959 </manufacturedProduct>
1960 </consumable>
1961
1962 </substanceAdministration>
1963 </entry>
1964 </xsl:for-each>
1965
1966 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan/a:OrderRequest/a:Encounters/a:Encounter">
1967 <entry typeCode="DRIV">
1968 <encounter classCode="ENC" moodCode="INT">
1969 <templateId root="2.16.840.1.113883.3.88.11.83.16" assigningAuthorityName="HITSP C83"/>
1970 <templateId root="2.16.840.1.113883.10.20.1.21" assigningAuthorityName="CCD"/>
1971 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.14" assigningAuthorityName="IHE PCC"/>
1972
1973 <!-- Encounter activity template -->
1974
1975 <!-- <id> -->
1976 <xsl:call-template name="ccdID">
1977 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
1978 </xsl:call-template>
1979
1980 <xsl:call-template name="ccdCodedValue">
1981 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
1982 <xsl:with-param name="nodeName" select="'code'"/>
1983 </xsl:call-template>
1984
1985 <text>
1986 <reference>
1987 <xsl:attribute name="value">
1988 <xsl:text>#</xsl:text>
1989 <xsl:value-of select="a:CCRDataObjectID"/>
1990 </xsl:attribute>
1991 </reference>
1992 </text>
1993
1994 <xsl:call-template name="ccdDateTime">
1995 <xsl:with-param name="dt" select="a:DateTime"/>
1996 </xsl:call-template>
1997
1998 <xsl:if test="a:Practitioners[1]/a:Practitioner">
1999 <xsl:call-template name="ccdPerformer">
2000 <xsl:with-param name="ccrActorReference" select="a:Practitioners/a:Practitioner[1]"/>
2001 </xsl:call-template>
2002 </xsl:if>
2003
2004 <xsl:if test="a:Locations[1]/a:Location">
2005 <participant typeCode="LOC">
2006 <templateId root="2.16.840.1.113883.10.20.1.45"/>
2007 <!-- Location participation template -->
2008 <xsl:choose>
2009 <xsl:when test="a:Locations[1]/a:Location/a:ActorID">
2010 <xsl:call-template name="ccdParticipantRoleActor">
2011 <xsl:with-param name="ccrActorObjectID" select="a:Locations[1]/a:Location/a:ActorID"/>
2012 </xsl:call-template>
2013 </xsl:when>
2014 <xsl:otherwise>
2015 <xsl:call-template name="ccdParticipantRoleCodedDescription">
2016 <xsl:with-param name="ccrCodedDescription" select="a:Locations[1]/a:Location/a:Description"/>
2017 </xsl:call-template>
2018 </xsl:otherwise>
2019 </xsl:choose>
2020 </participant>
2021 </xsl:if>
2022 </encounter>
2023 </entry>
2024 </xsl:for-each>
2025 </section>
2026 </component>
2027 </xsl:if>
2028 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders">
2029 <component>
2030 <section>
2031 <title>Health Care Providers</title>
2032 <text>
2033 <table>
2034 <tbody>
2035 <tr>
2036 <th>Role</th>
2037 <th>Name</th>
2038 </tr>
2039 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders/a:Provider">
2040 <tr>
2041 <td>
2042 <xsl:value-of select="a:ActorRole/a:Text"/>
2043 </td>
2044 <td>
2045 <xsl:call-template name="actorName">
2046 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
2047 </xsl:call-template>
2048 </td>
2049 </tr>
2050 </xsl:for-each>
2051 </tbody>
2052 </table>
2053 </text>
2054 </section>
2055 </component>
2056 </xsl:if>
2057 <!--
2058 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:SupportProviders">
2059 <component>
2060 <section>
2061 <title>Support Providers</title>
2062 <text>
2063 <table>
2064 <tbody>
2065 <tr>
2066 <th>Role</th>
2067 <th>Name</th>
2068 </tr>
2069 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Support/a:SupportProvider">
2070 <tr>
2071 <td>
2072 <xsl:value-of select="a:ActorRole/a:Text"/>
2073 </td>
2074 <td>
2075 <xsl:call-template name="actorName">
2076 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
2077 </xsl:call-template>
2078 </td>
2079 </tr>
2080 </xsl:for-each>
2081 </tbody>
2082 </table>
2083 </text>
2084 </section>
2085 </component>
2086 </xsl:if>
2087 <xsl:if test="a:ContinuityOfCareRecord/a:References">
2088 <component>
2089 <section>
2090 <title>References</title>
2091 <text>
2092 <table>
2093 <tbody>
2094 <tr>
2095 <th>Type</th>
2096 <th>Date</th>
2097 <th>Description</th>
2098 <th>Location</th>
2099 <th>Source</th>
2100 </tr>
2101 <xsl:for-each select="/a:ContinuityOfCareRecord/a:References/a:Reference">
2102 <tr>
2103 <td>
2104 <xsl:value-of select="a:Type/a:Text"/>
2105 </td>
2106 <td>
2107 <xsl:call-template name="date:format-date">
2108 <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
2109 </xsl:call-template>
2110 </td>
2111 <td>
2112 <strong class="clinical">
2113 <xsl:value-of select="a:Description/a:Text"/>
2114 </strong>
2115 </td>
2116 <td>
2117 <xsl:value-of select="a:Locations/a:Location/a:Description/a:Text"/>
2118 </td>
2119 <td>
2120 <xsl:call-template name="actorName">
2121 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
2122 </xsl:call-template>
2123 </td>
2124 </tr>
2125 </xsl:for-each>
2126 </tbody>
2127 </table>
2128 </text>
2129 </section>
2130 </component>
2131 </xsl:if>
2132 -->
2133 <!--
2134 <component>
2135 <section>
2136 <title>Additional Information About People &amp; Organizations</title>
2137 <text>
2138 <xsl:if test="a:ContinuityOfCareRecord/a:Actors/a:Actor[a:Person]">
2139 <table>
2140 <tbody>
2141 <tr>
2142 <th>Name</th>
2143 <th>Specialty</th>
2144 <th>Relation</th>
2145 <th>Identification Numbers</th>
2146 <th>Phone</th>
2147 <th>Address/ E-mail</th>
2148 </tr>
2149 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
2150 <xsl:sort select="a:Person/a:Name/a:DisplayName|a:Person/a:Name/a:CurrentName/a:Family" data-type="text" order="ascending"/>
2151 <xsl:if test="a:Person">
2152 <tr>
2153 <td>
2154 <xsl:call-template name="actorName">
2155 <xsl:with-param name="objID" select="a:ActorObjectID"/>
2156 </xsl:call-template>
2157 </td>
2158 <td>
2159 <xsl:value-of select="a:Specialty/a:Text"/>
2160 </td>
2161 <td>
2162 <xsl:value-of select="a:Relation/a:Text"/>
2163 </td>
2164 <td>
2165 <xsl:for-each select="a:IDs">
2166 <xsl:value-of select="a:Type/a:Text"/>
2167 <xsl:text>: </xsl:text>
2168 <xsl:value-of select="a:ID"/>
2169 </xsl:for-each>
2170 </td>
2171 <td>
2172 <xsl:for-each select="a:Telephone">
2173 <xsl:value-of select="a:Type/a:Text"/>
2174 <xsl:text>: </xsl:text>
2175 <xsl:value-of select="a:Value"/>
2176 </xsl:for-each>
2177 </td>
2178 <td>
2179 <xsl:for-each select="a:Address">
2180 <xsl:if test="a:Type">
2181 <xsl:value-of select="a:Type/a:Text"/>
2182 <xsl:text>:</xsl:text>
2183 <br/>
2184 </xsl:if>
2185 <xsl:if test="a:Line1">
2186 <xsl:value-of select="a:Line1"/>
2187 <br/>
2188 </xsl:if>
2189 <xsl:if test="a:Line2">
2190 <xsl:value-of select="a:Line2"/>
2191 <br/>
2192 </xsl:if>
2193 <xsl:if test="a:City">
2194 <xsl:value-of select="a:City"/>
2195 <xsl:text>, </xsl:text>
2196 </xsl:if>
2197 <xsl:value-of select="a:State"/>
2198 <xsl:value-of select="a:PostalCode"/>
2199 <br/>
2200 </xsl:for-each>
2201 <xsl:for-each select="a:EMail">
2202 <br/>
2203 <xsl:value-of select="a:Value"/>
2204 </xsl:for-each>
2205 </td>
2206 </tr>
2207 </xsl:if>
2208 </xsl:for-each>
2209 </tbody>
2210 </table>
2211 </xsl:if>
2212 <xsl:if test="a:ContinuityOfCareRecord/a:Actors/a:Actor[a:Organization]">
2213 <table>
2214 <tbody>
2215 <tr>
2216 <th>Name</th>
2217 <th>Specialty</th>
2218 <th>Relation</th>
2219 <th>Identification Numbers</th>
2220 <th>Phone</th>
2221 <th>Address/ E-mail</th>
2222 </tr>
2223 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
2224 <xsl:sort select="a:Organization/a:Name" data-type="text" order="ascending"/>
2225 <xsl:if test="a:Organization">
2226 <tr>
2227 <td>
2228 <xsl:value-of select="a:Organization/a:Name"/>
2229 </td>
2230 <td>
2231 <xsl:value-of select="a:Specialty/a:Text"/>
2232 </td>
2233 <td>
2234 <xsl:value-of select="a:Relation/a:Text"/>
2235 </td>
2236 <td>
2237 <xsl:for-each select="a:IDs">
2238 <xsl:value-of select="a:Type/a:Text"/>
2239 <xsl:text>: </xsl:text>
2240 <xsl:value-of select="a:ID"/>
2241 </xsl:for-each>
2242 </td>
2243 <td>
2244 <xsl:for-each select="a:Telephone">
2245 <xsl:value-of select="a:Type/a:Text"/>
2246 <xsl:text>: </xsl:text>
2247 <xsl:value-of select="a:Value"/>
2248 </xsl:for-each>
2249 </td>
2250 <td>
2251 <xsl:for-each select="a:Address">
2252 <xsl:if test="a:Type">
2253 <xsl:value-of select="a:Type/a:Text"/>
2254 <xsl:text>:</xsl:text>
2255 <br/>
2256 </xsl:if>
2257 <xsl:if test="a:Line1">
2258 <xsl:value-of select="a:Line1"/>
2259 <br/>
2260 </xsl:if>
2261 <xsl:if test="a:Line2">
2262 <xsl:value-of select="a:Line2"/>
2263 <br/>
2264 </xsl:if>
2265 <xsl:if test="a:City">
2266 <xsl:value-of select="a:City"/>
2267 <xsl:text>, </xsl:text>
2268 </xsl:if>
2269 <xsl:value-of select="a:State"/>
2270 <xsl:value-of select="a:PostalCode"/>
2271 <br/>
2272 </xsl:for-each>
2273 <xsl:for-each select="a:EMail">
2274 <br/>
2275 <xsl:value-of select="a:Value"/>
2276 </xsl:for-each>
2277 </td>
2278 </tr>
2279 </xsl:if>
2280 </xsl:for-each>
2281 </tbody>
2282 </table>
2283 </xsl:if>
2284 <xsl:if test="a:ContinuityOfCareRecord/a:Actors/a:Actor[a:InformationSystem]">
2285 <table>
2286 <tbody>
2287 <tr>
2288 <th>Name</th>
2289 <th>Type</th>
2290 <th>Version</th>
2291 <th>Identification Numbers</th>
2292 <th>Phone</th>
2293 <th>Address/ E-mail</th>
2294 </tr>
2295 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
2296 <xsl:sort select="a:InformationSystem/a:Name" data-type="text" order="ascending"/>
2297 <xsl:if test="a:InformationSystem">
2298 <tr>
2299 <td>
2300 <xsl:value-of select="a:InformationSystem/a:Name"/>
2301 </td>
2302 <td>
2303 <xsl:value-of select="a:InformationSystem/a:Type"/>
2304 </td>
2305 <td>
2306 <xsl:value-of select="a:InformationSystem/a:Version"/>
2307 </td>
2308 <td>
2309 <xsl:for-each select="a:IDs">
2310 <xsl:value-of select="a:Type/a:Text"/>
2311 <xsl:text>: </xsl:text>
2312 <xsl:value-of select="a:ID"/>
2313 </xsl:for-each>
2314 </td>
2315 <td>
2316 <xsl:for-each select="a:Telephone">
2317 <xsl:value-of select="a:Type/a:Text"/>
2318 <xsl:text>: </xsl:text>
2319 <xsl:value-of select="a:Value"/>
2320 </xsl:for-each>
2321 </td>
2322 <td>
2323 <xsl:for-each select="a:Address">
2324 <xsl:if test="Type">
2325 <xsl:value-of select="a:Type/a:Text"/>
2326 <xsl:text>:</xsl:text>
2327 <br/>
2328 </xsl:if>
2329 <xsl:if test="a:Line1">
2330 <xsl:value-of select="a:Line1"/>
2331 <br/>
2332 </xsl:if>
2333 <xsl:if test="a:Line2">
2334 <xsl:value-of select="a:Line2"/>
2335 <br/>
2336 </xsl:if>
2337 <xsl:if test="a:City">
2338 <xsl:value-of select="a:City"/>
2339 <xsl:text>, </xsl:text>
2340 </xsl:if>
2341 <xsl:value-of select="a:State"/>
2342 <xsl:value-of select="a:PostalCode"/>
2343 <br/>
2344 </xsl:for-each>
2345 <xsl:for-each select="a:EMail">
2346 <br/>
2347 <xsl:value-of select="a:Value"/>
2348 </xsl:for-each>
2349 </td>
2350 </tr>
2351 </xsl:if>
2352 </xsl:for-each>
2353 </tbody>
2354 </table>
2355 </xsl:if>
2356 </text>
2357 </section>
2358 </component>
2359 -->
2360 </structuredBody>
2361 </component>
2362 </ClinicalDocument>
2363 </xsl:template>
2364
2365 <xsl:template name="ccdAssignedEntity">
2366 <xsl:param name="ccrActorObjectID"/>
2367
2368 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
2369
2370 <assignedEntity>
2371 <xsl:call-template name="ccdEntityID">
2372 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2373 </xsl:call-template>
2374
2375 <xsl:call-template name="ccdAddress">
2376 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address"/>
2377 </xsl:call-template>
2378
2379 <xsl:call-template name="ccdTelecom">
2380 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2381 </xsl:call-template>
2382
2383 <xsl:if test="$CCRActor/a:Person">
2384 <xsl:call-template name="ccdPerson">
2385 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
2386 <xsl:with-param name="personNodeName" select="'assignedPerson'"/>
2387 </xsl:call-template>
2388 </xsl:if>
2389
2390 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
2391 <xsl:call-template name="ccdOrganization">
2392 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
2393 <xsl:with-param name="organizationNodeName" select="'representedOrganization'"/>
2394 </xsl:call-template>
2395 </xsl:if>
2396
2397 </assignedEntity>
2398 </xsl:template>
2399
2400 <xsl:template name="ccdPatient">
2401 <xsl:param name="CCRActorPerson"/>
2402 <patient>
2403 <xsl:call-template name="ccdPersonName">
2404 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
2405 </xsl:call-template>
2406
2407 <xsl:if test="$CCRActorPerson/a:Gender">
2408 <xsl:call-template name="ccdCodedValue">
2409 <xsl:with-param name="ccrCodedDescription" select="$CCRActorPerson/a:Gender"/>
2410 <xsl:with-param name="domain" select="'AdministrativeGender'"/>
2411 <xsl:with-param name="nodeName" select="'administrativeGenderCode'"/>
2412 </xsl:call-template>
2413 </xsl:if>
2414
2415 <xsl:if test="$CCRActorPerson/a:DateOfBirth">
2416 <birthTime>
2417 <xsl:attribute name="value">
2418 <xsl:call-template name="date:format-date">
2419 <xsl:with-param name="date-time" select="$CCRActorPerson/a:DateOfBirth/a:ExactDateTime"/>
2420 <xsl:with-param name="pattern">yyyyMMddhhmmss</xsl:with-param>
2421 </xsl:call-template>
2422 </xsl:attribute>
2423 </birthTime>
2424 </xsl:if>
2425
2426 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']">
2427 <xsl:call-template name="ccdCodedValue">
2428 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']/a:Description"/>
2429 <xsl:with-param name="domain" select="'MaritalStatus'"/>
2430 <xsl:with-param name="nodeName" select="'maritalStatusCode'"/>
2431 </xsl:call-template>
2432 </xsl:if>
2433
2434 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']">
2435 <languageCommunication>
2436 <templateId root="2.16.840.1.113883.3.88.11.83.2" assigningAuthorityName="HITSP/C83"/>
2437 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.2.1" assigningAuthorityName="IHE/PCC"/>
2438 <xsl:call-template name="ccdCodedValue">
2439 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']/a:Description"></xsl:with-param>
2440 <xsl:with-param name="domain" select="'HumanLanguage'"/>
2441 <xsl:with-param name="nodeName" select="'languageCode'"/>
2442 </xsl:call-template>
2443 </languageCommunication>
2444 </xsl:if>
2445 </patient>
2446 </xsl:template>
2447
2448 <xsl:template name="ccdPerformer">
2449 <xsl:param name="ccrActorReference"/>
2450 <performer typeCode="PRF">
2451 <xsl:if test="$ccrActorReference/a:ActorRole">
2452 <xsl:call-template name="ccdCodedValue">
2453 <xsl:with-param name="ccrCodedDescription" select="$ccrActorReference/a:ActorRole"/>
2454 <xsl:with-param name="nodeName" select="'functionCode'"/>
2455 </xsl:call-template>
2456 </xsl:if>
2457 <xsl:call-template name="ccdAssignedEntity">
2458 <xsl:with-param name="ccrActorObjectID" select="$ccrActorReference/a:ActorID"/>
2459 </xsl:call-template>
2460 </performer>
2461 </xsl:template>
2462
2463 <xsl:template name="ccdPerson">
2464 <xsl:param name="CCRActorPerson"/>
2465 <xsl:param name="personNodeName">assignedPerson</xsl:param>
2466 <xsl:element name="{$personNodeName}">
2467 <xsl:call-template name="ccdPersonName">
2468 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
2469 </xsl:call-template>
2470 </xsl:element>
2471 </xsl:template>
2472
2473 <xsl:template name="ccdPersonName">
2474 <xsl:param name="CCRActorName"/>
2475 <name>
2476 <xsl:if test="$CCRActorName/a:CurrentName/a:Title">
2477 <prefix>
2478 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Title"/>
2479 </prefix>
2480 </xsl:if>
2481 <xsl:if test="$CCRActorName/a:CurrentName/a:Given">
2482 <given>
2483 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Given"/>
2484 </given>
2485 </xsl:if>
2486 <xsl:if test="$CCRActorName/a:CurrentName/a:Middle">
2487 <given>
2488 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Middle"/>
2489 </given>
2490 </xsl:if>
2491 <xsl:if test="$CCRActorName/a:CurrentName/a:Family">
2492 <family>
2493 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Family"/>
2494 </family>
2495 </xsl:if>
2496 <xsl:if test="$CCRActorName/a:CurrentName/a:Suffix">
2497 <suffix>
2498 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Suffix"/>
2499 </suffix>
2500 </xsl:if>
2501 </name>
2502 </xsl:template>
2503
2504 <xsl:template name="ccdOrganization">
2505 <xsl:param name="ccrActorObjectID"/>
2506 <xsl:param name="organizationNodeName"/>
2507
2508 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
2509
2510 <xsl:element name="{$organizationNodeName}">
2511 <xsl:call-template name="ccdEntityID">
2512 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2513 </xsl:call-template>
2514 <xsl:call-template name="ccdTelecom">
2515 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2516 </xsl:call-template>
2517
2518 <xsl:call-template name="ccdAddress">
2519 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
2520 </xsl:call-template>
2521 </xsl:element>
2522 </xsl:template>
2523
2524 <xsl:template name="ccdPatientRole">
2525 <xsl:param name="ccrActorObjectID"/>
2526
2527 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
2528
2529 <xsl:call-template name="ccdEntityID">
2530 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2531 </xsl:call-template>
2532
2533 <xsl:call-template name="ccdAddress">
2534 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
2535 </xsl:call-template>
2536
2537 <xsl:call-template name="ccdTelecom">
2538 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2539 </xsl:call-template>
2540
2541 <xsl:call-template name="ccdPatient">
2542 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
2543 </xsl:call-template>
2544 </xsl:template>
2545
2546 <xsl:template name="ccdAssignedAuthor">
2547 <xsl:param name="ccrActorObjectID"/>
2548 <assignedAuthor>
2549 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
2550
2551 <xsl:call-template name="ccdEntityID">
2552 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2553 </xsl:call-template>
2554
2555 <xsl:call-template name="ccdAddress">
2556 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
2557 </xsl:call-template>
2558
2559 <xsl:call-template name="ccdTelecom">
2560 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2561 </xsl:call-template>
2562
2563 <xsl:call-template name="ccdPerson">
2564 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
2565 </xsl:call-template>
2566
2567 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
2568 <representedOrganization>
2569 <xsl:call-template name="ccdOrganization">
2570 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
2571 </xsl:call-template>
2572 </representedOrganization>
2573 </xsl:if>
2574 </assignedAuthor>
2575 </xsl:template>
2576
2577 <xsl:template name="ccdParticipantRoleActor">
2578 <xsl:param name="ccrActorObjectID"/>
2579
2580 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
2581
2582 <xsl:call-template name="ccdEntityID">
2583 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2584 </xsl:call-template>
2585
2586 <xsl:call-template name="ccdAddress">
2587 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
2588 </xsl:call-template>
2589
2590 <xsl:call-template name="ccdTelecom">
2591 <xsl:with-param name="CCRActor" select="$CCRActor"/>
2592 </xsl:call-template>
2593
2594 <xsl:if test="$CCRActor/a:Organization/a:Name">
2595 <playingEntity classCode="PLC">
2596 <name>
2597 <xsl:value-of select="$CCRActor/a:Organization/a:Name"/>
2598 </name>
2599 </playingEntity>
2600 </xsl:if>
2601 </xsl:template>
2602
2603 <xsl:template name="ccdParticipantRoleCodedDescription">
2604 <xsl:param name="ccrCodedDescription"/>
2605 <participantRole classCode="MANU">
2606 <!--Product Detail-->
2607 <playingEntity classCode="MMAT">
2608 <xsl:if test="$ccrCodedDescription/a:Code">
2609 <xsl:call-template name="ccdCodedValue">
2610 <xsl:with-param name="ccrCodedDescription" select="$ccrCodedDescription"/>
2611 <xsl:with-param name="nodeName" select="'code'"/>
2612 </xsl:call-template>
2613 </xsl:if>
2614 <name>
2615 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
2616 </name>
2617 </playingEntity>
2618 </participantRole>
2619 </xsl:template>
2620
2621 <xsl:template name="ccdEntityID">
2622 <xsl:param name="CCRActor"/>
2623 <id>
2624 <xsl:choose>
2625 <xsl:when test="$CCRActor/a:IDs">
2626 <xsl:attribute name="extension">
2627 <xsl:value-of select="$CCRActor/a:IDs[1]/a:ID"/>
2628 </xsl:attribute>
2629 <xsl:attribute name="root">
2630 <xsl:value-of select="$CCRActor/a:IDs[1]/a:Type/a:Text"/>
2631 </xsl:attribute>
2632 </xsl:when>
2633 <xsl:otherwise>
2634 <xsl:attribute name="extension">
2635 <xsl:value-of select="$CCRActor/a:ActorObjectID"/>
2636 </xsl:attribute>
2637 <xsl:attribute name="root">
2638 <xsl:text>CCRActorID</xsl:text>
2639 </xsl:attribute>
2640 </xsl:otherwise>
2641 </xsl:choose>
2642 </id>
2643 <xsl:if test="$CCRActor/a:Organization">
2644 <name><xsl:value-of select="$CCRActor/a:Organization/a:Name"></xsl:value-of></name>
2645 </xsl:if>
2646 </xsl:template>
2647 <xsl:template name="ccdAddress">
2648 <xsl:param name="CCRActorAddress"/>
2649 <addr>
2650 <xsl:choose>
2651 <xsl:when test="$CCRActorAddress">
2652 <xsl:attribute name="use">
2653 <xsl:call-template name="CDAVocabularyLookup">
2654 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
2655 <xsl:with-param name="ccrtext" select="$CCRActorAddress/a:Type/a:Text"/>
2656 </xsl:call-template>
2657 </xsl:attribute>
2658 <streetAddressLine>
2659 <xsl:value-of select="$CCRActorAddress/a:Line1"/>
2660 </streetAddressLine>
2661 <city>
2662 <xsl:value-of select="$CCRActorAddress/a:City"/>
2663 </city>
2664 <state>
2665 <xsl:value-of select="$CCRActorAddress/a:State"/>
2666 </state>
2667 <postalCode>
2668 <xsl:value-of select="$CCRActorAddress/a:PostalCode"/>
2669 </postalCode>
2670 </xsl:when>
2671 <xsl:otherwise>
2672 <streetAddressLine/>
2673 </xsl:otherwise>
2674 </xsl:choose>
2675 </addr>
2676 </xsl:template>
2677
2678 <xsl:template name="ccdTelecom">
2679 <xsl:param name="CCRActor"/>
2680 <telecom>
2681 <xsl:if test="$CCRActor/a:Telephone">
2682 <xsl:attribute name="use">
2683 <xsl:call-template name="CDAVocabularyLookup">
2684 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
2685 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
2686 </xsl:call-template>
2687 </xsl:attribute>
2688 <xsl:attribute name="value">
2689 <xsl:text>tel:+1-</xsl:text>
2690 <xsl:value-of select="$CCRActor/a:Telephone[1]/a:Value"/>
2691 </xsl:attribute>
2692 </xsl:if>
2693 </telecom>
2694
2695 <xsl:if test="$CCRActor/a:Email">
2696 <telecom>
2697 <xsl:choose>
2698 <xsl:when test="$CCRActor/a:Telephone">
2699 <xsl:attribute name="use">
2700 <xsl:call-template name="CDAVocabularyLookup">
2701 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
2702 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
2703 </xsl:call-template>
2704 </xsl:attribute>
2705 <xsl:attribute name="value">
2706 <xsl:text>mailto:</xsl:text>
2707 <xsl:value-of select="$CCRActor/a:Email[1]/a:Value"/>
2708 </xsl:attribute>
2709 </xsl:when>
2710 <xsl:otherwise>
2711 <xsl:attribute name="value">
2712 <xsl:text>Unknown</xsl:text>
2713 </xsl:attribute>
2714 </xsl:otherwise>
2715 </xsl:choose>
2716 </telecom>
2717 </xsl:if>
2718 </xsl:template>
2719
2720 <xsl:template name="ccdID">
2721 <xsl:param name="ccrObjectID"/>
2722 <xsl:param name="suffix"/>
2723 <id>
2724 <xsl:attribute name="root">
2725 <xsl:value-of select="$ccrObjectID"></xsl:value-of>
2726 </xsl:attribute>
2727 <xsl:attribute name="extension">CCRObjectID</xsl:attribute>
2728 </id>
2729 </xsl:template>
2730
2731 <xsl:template name="ccdCodedValue">
2732 <xsl:param name="ccrCodedDescription"/>
2733 <xsl:param name="type"/>
2734 <xsl:param name="domain"/>
2735 <xsl:param name="nodeName">value</xsl:param>
2736 <xsl:param name="originalTextReference"/>
2737
2738 <xsl:element name="{$nodeName}">
2739 <xsl:if test="$type">
2740 <xsl:attribute name="xsi:type">
2741 <xsl:value-of select="$type"/>
2742 </xsl:attribute>
2743 </xsl:if>
2744 <xsl:choose>
2745 <xsl:when test="$ccrCodedDescription/a:Code">
2746 <xsl:attribute name="displayName">
2747 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
2748 </xsl:attribute>
2749 <xsl:attribute name="code">
2750 <xsl:value-of select="$ccrCodedDescription/a:Code/a:Value"/>
2751 </xsl:attribute>
2752 <xsl:attribute name="codeSystemName">
2753 <xsl:value-of select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
2754 </xsl:attribute>
2755 <xsl:attribute name="codeSystem">
2756 <xsl:call-template name="HL7OIDLookup">
2757 <xsl:with-param name="name" select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
2758 </xsl:call-template>
2759 </xsl:attribute>
2760 </xsl:when>
2761 <xsl:when test="$domain">
2762 <xsl:variable name="cdaCode">
2763 <xsl:call-template name="CDAVocabularyLookup">
2764 <xsl:with-param name="domain" select="$domain"/>
2765 <xsl:with-param name="ccrtext" select="$ccrCodedDescription/a:Text"/>
2766 </xsl:call-template>
2767 </xsl:variable>
2768 <xsl:attribute name="displayName">
2769 <xsl:call-template name="CDADisplayNameLookup">
2770 <xsl:with-param name="domain" select="$domain"/>
2771 <xsl:with-param name="cdacode" select="$cdaCode"/>
2772 </xsl:call-template>
2773 </xsl:attribute>
2774 <xsl:attribute name="code">
2775 <xsl:value-of select="$cdaCode"></xsl:value-of>
2776 </xsl:attribute>
2777 <xsl:attribute name="codeSystemName">
2778 <xsl:call-template name="CDAVocabularyCodeSystemNameLookup">
2779 <xsl:with-param name="domain" select="$domain"/>
2780 </xsl:call-template>
2781 </xsl:attribute>
2782 <xsl:attribute name="codeSystemName">
2783 <xsl:call-template name="CDAVocabularyCodeSystemLookup">
2784 <xsl:with-param name="domain" select="$domain"/>
2785 </xsl:call-template>
2786 </xsl:attribute>
2787 </xsl:when>
2788 <xsl:otherwise>
2789 <originalText>
2790 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
2791 <xsl:if test="$originalTextReference">
2792 <reference>
2793 <xsl:attribute name="value">
2794 <xsl:value-of select="$originalTextReference"/>
2795 </xsl:attribute>
2796 </reference>
2797 </xsl:if>
2798 </originalText>
2799 </xsl:otherwise>
2800 </xsl:choose>
2801 </xsl:element>
2802 </xsl:template>
2803
2804 <xsl:template name="ccdDateTime">
2805 <xsl:param name="dt"/>
2806 <xsl:param name="type"/>
2807 <xsl:if test="$dt">
2808 <xsl:if test="$dt[1]/a:ExactDateTime">
2809 <effectiveTime>
2810 <xsl:if test="$type">
2811 <xsl:attribute name="xsi:type">
2812 <xsl:value-of select="$type"></xsl:value-of>
2813 </xsl:attribute>
2814 </xsl:if>
2815 <low>
2816 <xsl:attribute name="value">
2817 <xsl:call-template name="date:format-date">
2818 <xsl:with-param name="date-time" select="$dt[1]/a:ExactDateTime"/>
2819 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
2820 </xsl:call-template>
2821 </xsl:attribute>
2822 </low>
2823 <high nullFlavor="UNK"/>
2824 </effectiveTime>
2825 </xsl:if>
2826 <xsl:if test="$dt[1]/a:DateTimeRange">
2827 <effectiveTime>
2828 <low>
2829 <xsl:attribute name="value">
2830 <xsl:call-template name="date:format-date">
2831 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:BeginRange/a:ExactDateTime"/>
2832 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
2833 </xsl:call-template>
2834 </xsl:attribute>
2835 </low>
2836 <high>
2837 <xsl:attribute name="value">
2838 <xsl:call-template name="date:format-date">
2839 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:EndRange/a:ExactDateTime"/>
2840 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
2841 </xsl:call-template>
2842 </xsl:attribute>
2843 </high>
2844 </effectiveTime>
2845 </xsl:if>
2846 </xsl:if>
2847 </xsl:template>
2848
2849 <xsl:template name="ccdMedicationFrequency">
2850 <xsl:param name="frequency"/>
2851 <xsl:if test="$frequency">
2852 <xsl:choose>
2853 <xsl:when test="$frequency/a:Value='qd'">
2854 <effectiveTime xsi:type="PIVL_TS" operator="A">
2855 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2856 <period>
2857 <xsl:attribute name="value">24</xsl:attribute>
2858 <xsl:attribute name="unit">h</xsl:attribute>
2859 </period>
2860 </effectiveTime>
2861 </xsl:when>
2862 <xsl:when test="$frequency/a:Value='bid'">
2863 <effectiveTime xsi:type="PIVL_TS" operator="A">
2864 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2865 <period>
2866 <xsl:attribute name="value">12</xsl:attribute>
2867 <xsl:attribute name="unit">h</xsl:attribute>
2868 </period>
2869 </effectiveTime>
2870 </xsl:when>
2871 <xsl:when test="$frequency/a:Value='tid'">
2872 <effectiveTime xsi:type="PIVL_TS" operator="A">
2873 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2874 <period>
2875 <xsl:attribute name="value">8</xsl:attribute>
2876 <xsl:attribute name="unit">h</xsl:attribute>
2877 </period>
2878 </effectiveTime>
2879 </xsl:when>
2880 <xsl:when test="$frequency/a:Value='qid'">
2881 <effectiveTime xsi:type="PIVL_TS" operator="A">
2882 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
2883 <period>
2884 <xsl:attribute name="value">6</xsl:attribute>
2885 <xsl:attribute name="unit">h</xsl:attribute>
2886 </period>
2887 </effectiveTime>
2888 </xsl:when>
2889 <xsl:when test="$frequency/a:Value='qam'">
2890 <effectiveTime xsi:type='EIVL' operator='A'>
2891 <event code='ACM'/>
2892 </effectiveTime>
2893 </xsl:when>
2894 <xsl:when test="$frequency/a:Value='qpm'">
2895 <effectiveTime xsi:type='EIVL' operator='A'>
2896 <event code='PCV'/>
2897 </effectiveTime>
2898 </xsl:when>
2899 </xsl:choose>
2900 </xsl:if>
2901 </xsl:template>
2902
2903 <xsl:template name="ccdStatus">
2904 <xsl:param name="ccrStatus"/>
2905
2906 <entryRelationship typeCode="REFR">
2907 <observation classCode="OBS" moodCode="EVN">
2908 <templateId root="2.16.840.1.113883.10.20.1.50"/>
2909 <!-- Problem status observation template -->
2910 <code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/>
2911 <statusCode code="completed"/>
2912 <xsl:call-template name="ccdCodedValue">
2913 <xsl:with-param name="ccrCodedDescription" select="$ccrStatus"/>
2914 </xsl:call-template>
2915 </observation>
2916 </entryRelationship>
2917 </xsl:template>
2918
2919 <xsl:template name="ccdStatusObservation">
2920 <xsl:param name="status"/>
2921 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
2922 <xsl:choose>
2923 <xsl:when test="$statusText='Active'">
2924 <xsl:call-template name="ccdStatusElement">
2925 <xsl:with-param name="statusCode" select="'55561003'"/>
2926 <xsl:with-param name="statusDisplayName" select="$statusText"/>
2927 </xsl:call-template>
2928 </xsl:when>
2929 <xsl:when test="$statusText='Inactive'">
2930 <xsl:call-template name="ccdStatusElement">
2931 <xsl:with-param name="statusCode" select="'73425007'"/>
2932 <xsl:with-param name="statusDisplayName" select="$statusText"/>
2933 </xsl:call-template>
2934 </xsl:when>
2935 <xsl:when test="$statusText='Chronic'">
2936 <xsl:call-template name="ccdStatusElement">
2937 <xsl:with-param name="statusCode" select="'90734009'"/>
2938 <xsl:with-param name="statusDisplayName" select="$statusText"/>
2939 </xsl:call-template>
2940 </xsl:when>
2941 </xsl:choose>
2942 </xsl:template>
2943
2944 <xsl:template name="ccdStatusProcedure">
2945 <xsl:param name="status"/>
2946 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
2947 <xsl:choose>
2948 <xsl:when test="$statusText='Completed'">
2949 <statusCode code="completed"/>
2950 </xsl:when>
2951 <xsl:when test="$statusText='Active'">
2952 <statusCode code="active"/>
2953 </xsl:when>
2954 <xsl:when test="$statusText='Aborted'">
2955 <statusCode code="aborted"/>
2956 </xsl:when>
2957 <xsl:when test="$statusText='Cancelled' or $statusText='Canceled'">
2958 <statusCode code="cancelled"/>
2959 </xsl:when>
2960 <xsl:otherwise>
2961 <statusCode>
2962 <xsl:attribute name="code">
2963 <xsl:value-of select="$statusText"></xsl:value-of>
2964 </xsl:attribute>
2965 </statusCode>
2966 </xsl:otherwise>
2967 </xsl:choose>
2968 </xsl:template>
2969
2970 <xsl:template name="ccdStatusElement">
2971 <xsl:param name="statusCode"/>
2972 <xsl:param name="statusDisplayName"/>
2973 <value>
2974 <xsl:attribute name="xsi:type">CE</xsl:attribute>
2975 <xsl:attribute name="code">
2976 <xsl:value-of select="$statusCode"></xsl:value-of>
2977 </xsl:attribute>
2978 <xsl:attribute name="codeSystem">2.16.840.1.113883.6.96</xsl:attribute>
2979 <xsl:attribute name="displayName">
2980 <xsl:value-of select="$statusDisplayName"></xsl:value-of>
2981 </xsl:attribute>
2982 </value>
2983 </xsl:template>
2984
2985 <xsl:template name="ccdObservation">
2986 <xsl:param name="ccrTestNode"/>
2987 <xsl:param name="testDate"/>
2988
2989 <component>
2990 <observation classCode="OBS" moodCode="EVN">
2991 <templateId root="2.16.840.1.113883.3.88.11.83.15" assigningAuthorityName="HITSP C83"/>
2992 <templateId root="2.16.840.1.113883.10.20.1.31" assigningAuthorityName="CCD"/>
2993 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13" assigningAuthorityName="IHE PCC"/>
2994
2995 <!-- Result observation template -->
2996
2997 <xsl:call-template name="ccdID">
2998 <xsl:with-param name="ccrObjectID" select="$ccrTestNode/a:CCRDataObjectID"/>
2999 </xsl:call-template>
3000
3001 <!-- <code> -->
3002 <xsl:call-template name="ccdCodedValue">
3003 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Description"/>
3004 <xsl:with-param name="nodeName" select="'code'"/>
3005 </xsl:call-template>
3006
3007 <text>
3008 <reference>
3009 <xsl:attribute name="value">
3010 <xsl:text>#</xsl:text>
3011 <xsl:value-of select="$ccrTestNode/a:CCRDataObjectID"/>
3012 </xsl:attribute>
3013 </reference>
3014 </text>
3015
3016 <statusCode code="completed"/>
3017
3018 <!-- <effectiveTime> -->
3019 <xsl:choose>
3020 <xsl:when test="$ccrTestNode/a:DateTime">
3021 <xsl:call-template name="ccdDateTime">
3022 <xsl:with-param name="dt" select="$ccrTestNode/a:DateTime"/>
3023 </xsl:call-template>
3024 </xsl:when>
3025 <xsl:otherwise>
3026 <xsl:call-template name="ccdDateTime">
3027 <xsl:with-param name="dt" select="$testDate"/>
3028 </xsl:call-template>
3029 </xsl:otherwise>
3030 </xsl:choose>
3031
3032 <xsl:choose>
3033 <xsl:when test="$ccrTestNode/a:TestResult[a:Value!='']">
3034 <value xsi:type="PQ">
3035 <xsl:attribute name="value">
3036 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Value"/>
3037 </xsl:attribute>
3038 <xsl:attribute name="unit">
3039 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Units/a:Unit"/>
3040 </xsl:attribute>
3041 </value>
3042 </xsl:when>
3043 <xsl:when test="$ccrTestNode/a:TestResult[a:Description/a:Text!='']">
3044 <value xsi:type="TX">
3045 <xsl:attribute name="value">
3046 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Description/a:Text"/>
3047 </xsl:attribute>
3048 </value>
3049 </xsl:when>
3050 </xsl:choose>
3051
3052 <xsl:if test="$ccrTestNode/a:Flag">
3053 <xsl:call-template name="ccdCodedValue">
3054 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Flag"/>
3055 <xsl:with-param name="nodeName" select="'interpretationCode'"/>
3056 <xsl:with-param name="domain" select="'ObservationInterpretation'"/>
3057 </xsl:call-template>
3058 </xsl:if>
3059
3060 <xsl:if test="$ccrTestNode/a:NormalResult">
3061 <referenceRange>
3062 <xsl:if test="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text">
3063 <observationRange>
3064 <text>
3065 <xsl:value-of select="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text"/>
3066 </text>
3067 </observationRange>
3068 </xsl:if>
3069 </referenceRange>
3070 </xsl:if>
3071
3072 </observation>
3073 </component>
3074
3075 </xsl:template>
3076</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.