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