source: ccr2ccd-xslt/trunk/make/M1-ccr_qrda-M1.xsl@ 1550

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

latest

File size: 45.7 KB
Line 
1 <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Procedures">
2 <component>
3 <section>
4 <templateId root="2.16.840.1.113883.10.20.1.12"/>
5 <code code="47519-4" codeSystem="2.16.840.1.113883.6.1"/>
6 <title>Procedures</title>
7 <text>
8 <table>
9 <tbody>
10 <tr>
11 <th>Type</th>
12 <th>Date</th>
13 <th>Code</th>
14 <th>Description</th>
15 <th>Location</th>
16 <th>Substance</th>
17 <th>Method</th>
18 <th>Position</th>
19 <th>Site</th>
20 <th>Status</th>
21 <th>Source</th>
22 </tr>
23 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
24 <tr>
25 <xsl:attribute name="id">
26 <xsl:value-of select="a:CCRDataObjectID"/>
27 </xsl:attribute>
28
29 <td>
30 <xsl:value-of select="a:Type/a:Text"/>
31 </td>
32 <table>
33 <tbody>
34 <xsl:apply-templates select="a:DateTime"/>
35 </tbody>
36 </table>
37 <td>
38 <xsl:apply-templates select="a:Description/a:Code"/>
39 </td>
40 <td>
41 <xsl:value-of select="a:Description/a:Text"/>
42 </td>
43 <td>
44 <xsl:for-each select="a:Locations/a:Location">
45 <xsl:value-of select="a:Description/a:Text"/>
46 <xsl:if test="a:Actor">
47 (<xsl:call-template name="actorName">
48 <xsl:with-param name="objID" select="a:Actor/a:ActorID"/>
49 </xsl:call-template>
50 <xsl:if test="a:Actor/a:ActorRole/a:Text">
51 <xsl:text xml:space="preserve"> - </xsl:text><xsl:value-of select="a:ActorRole/a:Text"/>)
52 </xsl:if>
53 </xsl:if>)
54 <xsl:if test="position() != last()">
55 <br/>
56 </xsl:if>
57 </xsl:for-each>
58 </td>
59 <td>
60 <xsl:for-each select="a:Substance">
61 <xsl:value-of select="a:Text"/>
62 </xsl:for-each>
63 </td>
64 <td>
65 <xsl:value-of select="a:Method/a:Text"/>
66 </td>
67 <td>
68 <xsl:value-of select="a:Position/a:Text"/>
69 </td>
70 <td>
71 <xsl:value-of select="a:Site/a:Text"/>
72 </td>
73 <td>
74 <xsl:value-of select="a:Status/a:Text"/>
75 </td>
76 <td>
77 <xsl:call-template name="actorName">
78 <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
79 </xsl:call-template>
80 </td>
81 </tr>
82 </xsl:for-each>
83 </tbody>
84 </table>
85 </text>
86
87 <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
88 <entry typeCode="DRIV">
89 <procedure classCode="PROC" moodCode="EVN">
90 <templateId root="2.16.840.1.113883.3.88.11.83.17" assigningAuthorityName="HITSP C83"/>
91 <templateId root="2.16.840.1.113883.10.20.1.29" assigningAuthorityName="CCD"/>
92 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.19" assigningAuthorityName="IHE PCC"/>
93
94 <!-- <id> -->
95 <xsl:call-template name="ccdID">
96 <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
97 </xsl:call-template>
98
99 <!-- <code> -->
100 <xsl:call-template name="ccdCodedValue">
101 <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
102 <xsl:with-param name="nodeName" select="'code'"/>
103 </xsl:call-template>
104
105 <text>
106 <reference>
107 <xsl:attribute name="value">
108 <xsl:text>#</xsl:text>
109 <xsl:value-of select="a:CCRDataObjectID"/>
110 </xsl:attribute>
111 </reference>
112 </text>
113
114 <xsl:call-template name="ccdStatusProcedure">
115 <xsl:with-param name="status" select="a:Status"/>
116 </xsl:call-template>
117
118 <xsl:call-template name="ccdDateTime">
119 <xsl:with-param name="dt" select="a:DateTime"/>
120 </xsl:call-template>
121
122 <xsl:if test="a:Method">
123 <xsl:call-template name="ccdCodedValue">
124 <xsl:with-param name="ccrCodedDescription" select="a:Method"/>
125 <xsl:with-param name="nodeName" select="'approachSiteCode'"/>
126 </xsl:call-template>
127 </xsl:if>
128
129 <xsl:if test="a:Site">
130 <xsl:call-template name="ccdCodedValue">
131 <xsl:with-param name="ccrCodedDescription" select="a:Site"/>
132 <xsl:with-param name="nodeName" select="'targetSiteCode'"/>
133 </xsl:call-template>
134 </xsl:if>
135
136 <xsl:if test="a:Practitioners/a:Practitioner">
137 <xsl:call-template name="ccdPerformer">
138 <xsl:with-param name="ccrActorReference" select="a:Practitioners/a:Practitioner[1]"/>
139 </xsl:call-template>
140 </xsl:if>
141 </procedure>
142 </entry>
143 </xsl:for-each>
144 </section>
145 </component>
146 </xsl:if>
147<component>
148<section>
149<!--We are including only a coverage activity for Medicare here. There is also policy activity and and authorization activity that I don't think we need to report for QRDA, at least not for most reports-->
150<templateId root="2.16.840.1.113883.10.20.1.9"/>
151<!-- 48768-6 is payment sources and is fixed CQ-188,189,190-->
152<code code="48768-6" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Payment Sources"/>
153<!--CQ-191,192-->
154<title>Payers</title>
155<text>
156</text
157<!--medicare-->
158<entry typeCode="DRIV">
159<!--WVP moodCode is DEF is definition to describe the characteristics of who must be involved in an act CQ-194,195-->
160<act classCode="ACT" moodCode="DEF">
161<!--WVP coverage activity template is the 10.20.1.20 CQ-193-->
162<templateId root="2.16.840.1.113883.10.20.1.20"/>
163<!--Coverage Shall Include and Act ID CQ-196-->
164<!--looks like a UUID to me-->
165<id root="2.16.840.1.113883.3.543" extension="@@@UUID-PAYER@@@"/><!--FIX!!!???-->
166<!--CQ-197-198 It appears that statusCode="completed" need to follow the code code ... here and below-->
167
168<!--CQ199,200-->
169<code code="48768-6" codeSystem="2.16.840.1.113883.6.1" displayName="Payment sources"/>
170<statusCode code="completed"/>
171
172<!--A coverage activity shall contain on or more act/entryRelationship. The value for act/entryRelationship/@typeCode shall be COMP which SHALL be the CMS QRDA Policy Activity CQ-201, 203-->
173<!--It MAY contain an entryRelationship/sequenceNumber CQ-202-->
174<entryRelationship typeCode="COMP">
175<!-- for the act is event with moodCode EVN CQ-205,206,207-->
176<act classCode="ACT" moodCode="EVN">
177<!--Policy activity is the 10.20.1.26 template CQ-205-->
178<templateId root="2.16.840.1.113883.10.20.1.26"/>
179<templateId root="2.16.840.1.113883.3.249.11.100.7"/>
180
181<!-- act/id which is the group or contract number related to the insurance policy or program CQ-208-->
182<id root="dbbb6311-8a4d-11df-a4ee-0800200c9c66"/><!--!!!FIX-->
183<!--Act statusCode must be completed CQ-210-->
184<!--This SHOULD be present and comes from the downloadable resource S display name is in quotes AUTOPOL - "automobile" policy;EHCPOL additional insurance in addition to Medicare in this case
185HSAPOL "Health Spending Account";PUBLICPOL "public healthcare" which is NOT Medicare - maybe a state program for example
186WBCPOL is "workers compensation" CQ-211,212-->
187<!--<code code="PUBLICPOL" codeSystem="2.16.840.1.113883.5.4" displayName="Public Healthcare"/>-->
188<code code="PUBLICPOL" codeSystem="2.16.840.1.113883.5.4" displayName="Public Healthcare"/>
189<!--WVP performer type codes are numerous but PRF is performer representing the Payer CQ-213-->
190<statusCode code="completed"/>
191<performer typeCode="PRF">
192
193<!--performer/assignedEntity id is the payer identification and the extension comes from the downloadable resource section I insurance plan TYPE CQ-214-->
194<assignedEntity>
195<id root="2.16.840.1.113883.12.86" extension="MC"/>
196<!--<representedOrganization>
197<name>CMS</name>
198</representedOrganization>-->
199</assignedEntity>
200</performer>
201<!-- Act/participant @typeCode this represents the covered party CQ-215-->
202<participant typeCode="COV">
203<participantRole>
204<!--A covered party in a policy activity SHOULD contain one or more participant/participantRole/id to represent the patien's member of subscriber identifier with respect to the payer
205For participant/paricipantRole/id either the Social Security Number or HIC Number SHALL be submitted for Medicare patients. for SSN the ID @root SHALL be 2.16.840.1.113883.4.1 where
206the HIC id/@root shall be 2.16.840.1.113883.3.249.13 CQ-216"RoleCode" in the downloadable resource-->
207<!-- in this case theextension is the patients SSN for a medicare patient so it is the same each time for one patient-->
208<id root="2.16.840.1.113883.4.1" extension="@@SSN@@"/>
209<!--The covered party in tha policy activity SHOULD contain exactly one particpant/participantRole/code for self, family etc from the valuse set PolicyOrPrograCoverageRoleType 2.16.840.1.113883.1.11.19809 CQ-217,218-->
210<code code="SELF" codeSystem="2.16.840.1.113883.5.111" displayName="Self"/>
211</participantRole>
212</participant>
213</act>
214</entryRelationship>
215</act>
216</entry>
217</section>
218</component>
219</section>
220</component>
221</section>
222</component>
223</structuredBody>
224</component>
225</ClinicalDocument>
226 </xsl:template>
227 <xsl:template name="ccdAssignedEntity">
228 <xsl:param name="ccrActorObjectID"/>
229
230 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
231
232 <assignedEntity>
233 <xsl:call-template name="ccdEntityID">
234 <xsl:with-param name="CCRActor" select="$CCRActor"/>
235 </xsl:call-template>
236
237 <xsl:call-template name="ccdAddress">
238 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address"/>
239 </xsl:call-template>
240
241 <xsl:call-template name="ccdTelecom">
242 <xsl:with-param name="CCRActor" select="$CCRActor"/>
243 </xsl:call-template>
244
245 <xsl:if test="$CCRActor/a:Person">
246 <xsl:call-template name="ccdPerson">
247 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
248 <xsl:with-param name="personNodeName" select="'assignedPerson'"/>
249 </xsl:call-template>
250 </xsl:if>
251
252 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
253 <xsl:call-template name="ccdOrganization">
254 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
255 <xsl:with-param name="organizationNodeName" select="'representedOrganization'"/>
256 </xsl:call-template>
257 </xsl:if>
258
259 </assignedEntity>
260 </xsl:template>
261
262 <xsl:template name="ccdPatient">
263 <xsl:param name="CCRActorPerson"/>
264 <patient>
265 <xsl:call-template name="ccdPersonName">
266 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
267 </xsl:call-template>
268
269 <xsl:if test="$CCRActorPerson/a:Gender">
270 <xsl:call-template name="ccdCodedValue">
271 <xsl:with-param name="ccrCodedDescription" select="$CCRActorPerson/a:Gender"/>
272 <xsl:with-param name="domain" select="'AdministrativeGender'"/>
273 <xsl:with-param name="nodeName" select="'administrativeGenderCode'"/>
274 </xsl:call-template>
275 </xsl:if>
276
277 <xsl:if test="$CCRActorPerson/a:DateOfBirth">
278 <birthTime>
279 <xsl:attribute name="value">
280 <xsl:call-template name="date:format-date">
281 <xsl:with-param name="date-time" select="$CCRActorPerson/a:DateOfBirth/a:ExactDateTime"/>
282 <xsl:with-param name="pattern">yyyyMMddhhmmss</xsl:with-param>
283 </xsl:call-template>
284 </xsl:attribute>
285 </birthTime>
286 </xsl:if>
287
288 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']">
289 <xsl:call-template name="ccdCodedValue">
290 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']/a:Description"/>
291 <xsl:with-param name="domain" select="'MaritalStatus'"/>
292 <xsl:with-param name="nodeName" select="'maritalStatusCode'"/>
293 </xsl:call-template>
294 </xsl:if>
295
296 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']">
297 <languageCommunication>
298 <templateId root="2.16.840.1.113883.3.88.11.83.2" assigningAuthorityName="HITSP/C83"/>
299 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.2.1" assigningAuthorityName="IHE/PCC"/>
300 <xsl:call-template name="ccdCodedValue">
301 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']/a:Description"></xsl:with-param>
302 <xsl:with-param name="domain" select="'HumanLanguage'"/>
303 <xsl:with-param name="nodeName" select="'languageCode'"/>
304 </xsl:call-template>
305 </languageCommunication>
306 </xsl:if>
307 </patient>
308 </xsl:template>
309
310 <xsl:template name="ccdPerformer">
311 <xsl:param name="ccrActorReference"/>
312 <performer typeCode="PRF">
313 <xsl:if test="$ccrActorReference/a:ActorRole">
314 <xsl:call-template name="ccdCodedValue">
315 <xsl:with-param name="ccrCodedDescription" select="$ccrActorReference/a:ActorRole"/>
316 <xsl:with-param name="nodeName" select="'functionCode'"/>
317 </xsl:call-template>
318 </xsl:if>
319 <xsl:call-template name="ccdAssignedEntity">
320 <xsl:with-param name="ccrActorObjectID" select="$ccrActorReference/a:ActorID"/>
321 </xsl:call-template>
322 </performer>
323 </xsl:template>
324
325 <xsl:template name="ccdPerson">
326 <xsl:param name="CCRActorPerson"/>
327 <xsl:param name="personNodeName">assignedPerson</xsl:param>
328 <xsl:element name="{$personNodeName}">
329 <xsl:call-template name="ccdPersonName">
330 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
331 </xsl:call-template>
332 </xsl:element>
333 </xsl:template>
334
335 <xsl:template name="ccdPersonName">
336 <xsl:param name="CCRActorName"/>
337 <name>
338 <xsl:if test="$CCRActorName/a:CurrentName/a:Title">
339 <prefix>
340 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Title"/>
341 </prefix>
342 </xsl:if>
343 <xsl:if test="$CCRActorName/a:CurrentName/a:Given">
344 <given>
345 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Given"/>
346 </given>
347 </xsl:if>
348 <xsl:if test="$CCRActorName/a:CurrentName/a:Middle">
349 <given>
350 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Middle"/>
351 </given>
352 </xsl:if>
353 <xsl:if test="$CCRActorName/a:CurrentName/a:Family">
354 <family>
355 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Family"/>
356 </family>
357 </xsl:if>
358 <xsl:if test="$CCRActorName/a:CurrentName/a:Suffix">
359 <suffix>
360 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Suffix"/>
361 </suffix>
362 </xsl:if>
363 </name>
364 </xsl:template>
365
366 <xsl:template name="ccdOrganization">
367 <xsl:param name="ccrActorObjectID"/>
368 <xsl:param name="organizationNodeName"/>
369
370 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
371
372 <xsl:element name="{$organizationNodeName}">
373 <xsl:call-template name="ccdEntityID">
374 <xsl:with-param name="CCRActor" select="$CCRActor"/>
375 </xsl:call-template>
376 <xsl:call-template name="ccdTelecom">
377 <xsl:with-param name="CCRActor" select="$CCRActor"/>
378 </xsl:call-template>
379
380 <xsl:call-template name="ccdAddress">
381 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
382 </xsl:call-template>
383 </xsl:element>
384 </xsl:template>
385
386 <xsl:template name="ccdPatientRole">
387 <xsl:param name="ccrActorObjectID"/>
388
389 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
390
391 <xsl:call-template name="ccdEntityID">
392 <xsl:with-param name="CCRActor" select="$CCRActor"/>
393 </xsl:call-template>
394
395 <xsl:call-template name="ccdAddress">
396 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
397 </xsl:call-template>
398
399 <xsl:call-template name="ccdTelecom">
400 <xsl:with-param name="CCRActor" select="$CCRActor"/>
401 </xsl:call-template>
402
403 <xsl:call-template name="ccdPatient">
404 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
405 </xsl:call-template>
406 </xsl:template>
407
408 <xsl:template name="ccdAssignedAuthor">
409 <xsl:param name="ccrActorObjectID"/>
410 <assignedAuthor>
411 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
412
413 <xsl:call-template name="ccdEntityID">
414 <xsl:with-param name="CCRActor" select="$CCRActor"/>
415 </xsl:call-template>
416
417 <xsl:call-template name="ccdAddress">
418 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
419 </xsl:call-template>
420
421 <xsl:call-template name="ccdTelecom">
422 <xsl:with-param name="CCRActor" select="$CCRActor"/>
423 </xsl:call-template>
424
425 <xsl:call-template name="ccdPerson">
426 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
427 </xsl:call-template>
428
429 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
430 <representedOrganization>
431 <xsl:call-template name="ccdOrganization">
432 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
433 </xsl:call-template>
434 </representedOrganization>
435 </xsl:if>
436 </assignedAuthor>
437 </xsl:template>
438
439 <xsl:template name="ccdParticipantRoleActor">
440 <xsl:param name="ccrActorObjectID"/>
441
442 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
443
444 <xsl:call-template name="ccdEntityID">
445 <xsl:with-param name="CCRActor" select="$CCRActor"/>
446 </xsl:call-template>
447
448 <xsl:call-template name="ccdAddress">
449 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
450 </xsl:call-template>
451
452 <xsl:call-template name="ccdTelecom">
453 <xsl:with-param name="CCRActor" select="$CCRActor"/>
454 </xsl:call-template>
455
456 <xsl:if test="$CCRActor/a:Organization/a:Name">
457 <playingEntity classCode="PLC">
458 <name>
459 <xsl:value-of select="$CCRActor/a:Organization/a:Name"/>
460 </name>
461 </playingEntity>
462 </xsl:if>
463 </xsl:template>
464
465 <xsl:template name="ccdParticipantRoleCodedDescription">
466 <xsl:param name="ccrCodedDescription"/>
467 <participantRole classCode="MANU">
468 <!--Product Detail-->
469 <playingEntity classCode="MMAT">
470 <xsl:if test="$ccrCodedDescription/a:Code">
471 <xsl:call-template name="ccdCodedValue">
472 <xsl:with-param name="ccrCodedDescription" select="$ccrCodedDescription"/>
473 <xsl:with-param name="nodeName" select="'code'"/>
474 </xsl:call-template>
475 </xsl:if>
476 <name>
477 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
478 </name>
479 </playingEntity>
480 </participantRole>
481 </xsl:template>
482
483 <xsl:template name="ccdEntityID">
484 <xsl:param name="CCRActor"/>
485 <id>
486 <xsl:choose>
487 <xsl:when test="$CCRActor/a:IDs">
488 <xsl:attribute name="extension">
489 <xsl:value-of select="$CCRActor/a:IDs[1]/a:ID"/>
490 </xsl:attribute>
491 <xsl:attribute name="root">
492 <xsl:value-of select="$CCRActor/a:IDs[1]/a:Type/a:Text"/>
493 </xsl:attribute>
494 </xsl:when>
495 <xsl:otherwise>
496 <xsl:attribute name="extension">
497 <xsl:value-of select="$CCRActor/a:ActorObjectID"/>
498 </xsl:attribute>
499 <xsl:attribute name="root">
500 <xsl:text>CCRActorID</xsl:text>
501 </xsl:attribute>
502 </xsl:otherwise>
503 </xsl:choose>
504 </id>
505 <xsl:if test="$CCRActor/a:Organization">
506 <name><xsl:value-of select="$CCRActor/a:Organization/a:Name"></xsl:value-of></name>
507 </xsl:if>
508 </xsl:template>
509 <xsl:template name="ccdAddress">
510 <xsl:param name="CCRActorAddress"/>
511 <addr>
512 <xsl:choose>
513 <xsl:when test="$CCRActorAddress">
514 <xsl:attribute name="use">
515 <xsl:call-template name="CDAVocabularyLookup">
516 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
517 <xsl:with-param name="ccrtext" select="$CCRActorAddress/a:Type/a:Text"/>
518 </xsl:call-template>
519 </xsl:attribute>
520 <streetAddressLine>
521 <xsl:value-of select="$CCRActorAddress/a:Line1"/>
522 </streetAddressLine>
523 <city>
524 <xsl:value-of select="$CCRActorAddress/a:City"/>
525 </city>
526 <state>
527 <xsl:value-of select="$CCRActorAddress/a:State"/>
528 </state>
529 <postalCode>
530 <xsl:value-of select="$CCRActorAddress/a:PostalCode"/>
531 </postalCode>
532 </xsl:when>
533 <xsl:otherwise>
534 <streetAddressLine/>
535 </xsl:otherwise>
536 </xsl:choose>
537 </addr>
538 </xsl:template>
539
540 <xsl:template name="ccdTelecom">
541 <xsl:param name="CCRActor"/>
542 <telecom>
543 <xsl:if test="$CCRActor/a:Telephone">
544 <xsl:attribute name="use">
545 <xsl:call-template name="CDAVocabularyLookup">
546 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
547 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
548 </xsl:call-template>
549 </xsl:attribute>
550 <xsl:attribute name="value">
551 <xsl:text>tel:+1-</xsl:text>
552 <xsl:value-of select="$CCRActor/a:Telephone[1]/a:Value"/>
553 </xsl:attribute>
554 </xsl:if>
555 </telecom>
556
557 <xsl:if test="$CCRActor/a:Email">
558 <telecom>
559 <xsl:choose>
560 <xsl:when test="$CCRActor/a:Telephone">
561 <xsl:attribute name="use">
562 <xsl:call-template name="CDAVocabularyLookup">
563 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
564 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
565 </xsl:call-template>
566 </xsl:attribute>
567 <xsl:attribute name="value">
568 <xsl:text>mailto:</xsl:text>
569 <xsl:value-of select="$CCRActor/a:Email[1]/a:Value"/>
570 </xsl:attribute>
571 </xsl:when>
572 <xsl:otherwise>
573 <xsl:attribute name="value">
574 <xsl:text>Unknown</xsl:text>
575 </xsl:attribute>
576 </xsl:otherwise>
577 </xsl:choose>
578 </telecom>
579 </xsl:if>
580 </xsl:template>
581
582 <xsl:template name="ccdID">
583 <xsl:param name="ccrObjectID"/>
584 <xsl:param name="suffix"/>
585 <id>
586 <xsl:attribute name="root">
587 <xsl:value-of select="$ccrObjectID"></xsl:value-of>
588 </xsl:attribute>
589 <xsl:attribute name="extension">CCRObjectID</xsl:attribute>
590 </id>
591 </xsl:template>
592
593 <xsl:template name="ccdCodedValue">
594 <xsl:param name="ccrCodedDescription"/>
595 <xsl:param name="type"/>
596 <xsl:param name="domain"/>
597 <xsl:param name="nodeName">value</xsl:param>
598 <xsl:param name="originalTextReference"/>
599
600 <xsl:element name="{$nodeName}">
601 <xsl:if test="$type">
602 <xsl:attribute name="xsi:type">
603 <xsl:value-of select="$type"/>
604 </xsl:attribute>
605 </xsl:if>
606 <xsl:choose>
607 <xsl:when test="$ccrCodedDescription/a:Code">
608 <xsl:attribute name="displayName">
609 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
610 </xsl:attribute>
611 <xsl:attribute name="code">
612 <xsl:value-of select="$ccrCodedDescription/a:Code/a:Value"/>
613 </xsl:attribute>
614 <xsl:attribute name="codeSystemName">
615 <xsl:value-of select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
616 </xsl:attribute>
617 <xsl:attribute name="codeSystem">
618 <xsl:call-template name="HL7OIDLookup">
619 <xsl:with-param name="name" select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
620 </xsl:call-template>
621 </xsl:attribute>
622 </xsl:when>
623 <xsl:when test="$domain">
624 <xsl:variable name="cdaCode">
625 <xsl:call-template name="CDAVocabularyLookup">
626 <xsl:with-param name="domain" select="$domain"/>
627 <xsl:with-param name="ccrtext" select="$ccrCodedDescription/a:Text"/>
628 </xsl:call-template>
629 </xsl:variable>
630 <xsl:attribute name="displayName">
631 <xsl:call-template name="CDADisplayNameLookup">
632 <xsl:with-param name="domain" select="$domain"/>
633 <xsl:with-param name="cdacode" select="$cdaCode"/>
634 </xsl:call-template>
635 </xsl:attribute>
636 <xsl:attribute name="code">
637 <xsl:value-of select="$cdaCode"></xsl:value-of>
638 </xsl:attribute>
639 <xsl:attribute name="codeSystemName">
640 <xsl:call-template name="CDAVocabularyCodeSystemNameLookup">
641 <xsl:with-param name="domain" select="$domain"/>
642 </xsl:call-template>
643 </xsl:attribute>
644 <xsl:attribute name="codeSystemName">
645 <xsl:call-template name="CDAVocabularyCodeSystemLookup">
646 <xsl:with-param name="domain" select="$domain"/>
647 </xsl:call-template>
648 </xsl:attribute>
649 </xsl:when>
650 <xsl:otherwise>
651 <originalText>
652 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
653 <xsl:if test="$originalTextReference">
654 <reference>
655 <xsl:attribute name="value">
656 <xsl:value-of select="$originalTextReference"/>
657 </xsl:attribute>
658 </reference>
659 </xsl:if>
660 </originalText>
661 </xsl:otherwise>
662 </xsl:choose>
663 </xsl:element>
664 </xsl:template>
665
666 <xsl:template name="ccdDateTime">
667 <xsl:param name="dt"/>
668 <xsl:param name="type"/>
669 <xsl:if test="$dt">
670 <xsl:if test="$dt[1]/a:ExactDateTime">
671 <effectiveTime>
672 <xsl:if test="$type">
673 <xsl:attribute name="xsi:type">
674 <xsl:value-of select="$type"></xsl:value-of>
675 </xsl:attribute>
676 </xsl:if>
677 <low>
678 <xsl:attribute name="value">
679 <xsl:call-template name="date:format-date">
680 <xsl:with-param name="date-time" select="$dt[1]/a:ExactDateTime"/>
681 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
682 </xsl:call-template>
683 </xsl:attribute>
684 </low>
685 <high nullFlavor="UNK"/>
686 </effectiveTime>
687 </xsl:if>
688 <xsl:if test="$dt[1]/a:DateTimeRange">
689 <effectiveTime>
690 <low>
691 <xsl:attribute name="value">
692 <xsl:call-template name="date:format-date">
693 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:BeginRange/a:ExactDateTime"/>
694 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
695 </xsl:call-template>
696 </xsl:attribute>
697 </low>
698 <high>
699 <xsl:attribute name="value">
700 <xsl:call-template name="date:format-date">
701 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:EndRange/a:ExactDateTime"/>
702 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
703 </xsl:call-template>
704 </xsl:attribute>
705 </high>
706 </effectiveTime>
707 </xsl:if>
708 </xsl:if>
709 </xsl:template>
710
711 <xsl:template name="ccdMedicationFrequency">
712 <xsl:param name="frequency"/>
713 <xsl:if test="$frequency">
714 <xsl:choose>
715 <xsl:when test="$frequency/a:Value='qd'">
716 <effectiveTime xsi:type="PIVL_TS" operator="A">
717 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
718 <period>
719 <xsl:attribute name="value">24</xsl:attribute>
720 <xsl:attribute name="unit">h</xsl:attribute>
721 </period>
722 </effectiveTime>
723 </xsl:when>
724 <xsl:when test="$frequency/a:Value='bid'">
725 <effectiveTime xsi:type="PIVL_TS" operator="A">
726 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
727 <period>
728 <xsl:attribute name="value">12</xsl:attribute>
729 <xsl:attribute name="unit">h</xsl:attribute>
730 </period>
731 </effectiveTime>
732 </xsl:when>
733 <xsl:when test="$frequency/a:Value='tid'">
734 <effectiveTime xsi:type="PIVL_TS" operator="A">
735 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
736 <period>
737 <xsl:attribute name="value">8</xsl:attribute>
738 <xsl:attribute name="unit">h</xsl:attribute>
739 </period>
740 </effectiveTime>
741 </xsl:when>
742 <xsl:when test="$frequency/a:Value='qid'">
743 <effectiveTime xsi:type="PIVL_TS" operator="A">
744 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
745 <period>
746 <xsl:attribute name="value">6</xsl:attribute>
747 <xsl:attribute name="unit">h</xsl:attribute>
748 </period>
749 </effectiveTime>
750 </xsl:when>
751 <xsl:when test="$frequency/a:Value='qam'">
752 <effectiveTime xsi:type='EIVL' operator='A'>
753 <event code='ACM'/>
754 </effectiveTime>
755 </xsl:when>
756 <xsl:when test="$frequency/a:Value='qpm'">
757 <effectiveTime xsi:type='EIVL' operator='A'>
758 <event code='PCV'/>
759 </effectiveTime>
760 </xsl:when>
761 </xsl:choose>
762 </xsl:if>
763 </xsl:template>
764
765 <xsl:template name="ccdStatus">
766 <xsl:param name="ccrStatus"/>
767
768 <entryRelationship typeCode="REFR">
769 <observation classCode="OBS" moodCode="EVN">
770 <templateId root="2.16.840.1.113883.10.20.1.50"/>
771 <!-- Problem status observation template -->
772 <code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/>
773 <statusCode code="completed"/>
774 <xsl:call-template name="ccdCodedValue">
775 <xsl:with-param name="ccrCodedDescription" select="$ccrStatus"/>
776 </xsl:call-template>
777 </observation>
778 </entryRelationship>
779 </xsl:template>
780
781 <xsl:template name="ccdStatusObservation">
782 <xsl:param name="status"/>
783 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
784 <xsl:choose>
785 <xsl:when test="$statusText='Active'">
786 <xsl:call-template name="ccdStatusElement">
787 <xsl:with-param name="statusCode" select="'55561003'"/>
788 <xsl:with-param name="statusDisplayName" select="$statusText"/>
789 </xsl:call-template>
790 </xsl:when>
791 <xsl:when test="$statusText='Inactive'">
792 <xsl:call-template name="ccdStatusElement">
793 <xsl:with-param name="statusCode" select="'73425007'"/>
794 <xsl:with-param name="statusDisplayName" select="$statusText"/>
795 </xsl:call-template>
796 </xsl:when>
797 <xsl:when test="$statusText='Chronic'">
798 <xsl:call-template name="ccdStatusElement">
799 <xsl:with-param name="statusCode" select="'90734009'"/>
800 <xsl:with-param name="statusDisplayName" select="$statusText"/>
801 </xsl:call-template>
802 </xsl:when>
803 </xsl:choose>
804 </xsl:template>
805
806 <xsl:template name="ccdStatusProcedure">
807 <xsl:param name="status"/>
808 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
809 <xsl:choose>
810 <xsl:when test="$statusText='Completed'">
811 <statusCode code="completed"/>
812 </xsl:when>
813 <xsl:when test="$statusText='Active'">
814 <statusCode code="active"/>
815 </xsl:when>
816 <xsl:when test="$statusText='Aborted'">
817 <statusCode code="aborted"/>
818 </xsl:when>
819 <xsl:when test="$statusText='Cancelled' or $statusText='Canceled'">
820 <statusCode code="cancelled"/>
821 </xsl:when>
822 <xsl:otherwise>
823 <statusCode>
824 <xsl:attribute name="code">
825 <xsl:value-of select="$statusText"></xsl:value-of>
826 </xsl:attribute>
827 </statusCode>
828 </xsl:otherwise>
829 </xsl:choose>
830 </xsl:template>
831
832 <xsl:template name="ccdStatusElement">
833 <xsl:param name="statusCode"/>
834 <xsl:param name="statusDisplayName"/>
835 <value>
836 <xsl:attribute name="xsi:type">CE</xsl:attribute>
837 <xsl:attribute name="code">
838 <xsl:value-of select="$statusCode"></xsl:value-of>
839 </xsl:attribute>
840 <xsl:attribute name="codeSystem">2.16.840.1.113883.6.96</xsl:attribute>
841 <xsl:attribute name="displayName">
842 <xsl:value-of select="$statusDisplayName"></xsl:value-of>
843 </xsl:attribute>
844 </value>
845 </xsl:template>
846
847 <xsl:template name="ccdObservation">
848 <xsl:param name="ccrTestNode"/>
849 <xsl:param name="testDate"/>
850
851 <component>
852 <observation classCode="OBS" moodCode="EVN">
853 <templateId root="2.16.840.1.113883.3.88.11.83.15" assigningAuthorityName="HITSP C83"/>
854 <templateId root="2.16.840.1.113883.10.20.1.31" assigningAuthorityName="CCD"/>
855 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13" assigningAuthorityName="IHE PCC"/>
856
857 <!-- Result observation template -->
858
859 <xsl:call-template name="ccdID">
860 <xsl:with-param name="ccrObjectID" select="$ccrTestNode/a:CCRDataObjectID"/>
861 </xsl:call-template>
862
863 <!-- <code> -->
864 <xsl:call-template name="ccdCodedValue">
865 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Description"/>
866 <xsl:with-param name="nodeName" select="'code'"/>
867 </xsl:call-template>
868
869 <text>
870 <reference>
871 <xsl:attribute name="value">
872 <xsl:text>#</xsl:text>
873 <xsl:value-of select="$ccrTestNode/a:CCRDataObjectID"/>
874 </xsl:attribute>
875 </reference>
876 </text>
877
878 <statusCode code="completed"/>
879
880 <!-- <effectiveTime> -->
881 <xsl:choose>
882 <xsl:when test="$ccrTestNode/a:DateTime">
883 <xsl:call-template name="ccdDateTime">
884 <xsl:with-param name="dt" select="$ccrTestNode/a:DateTime"/>
885 </xsl:call-template>
886 </xsl:when>
887 <xsl:otherwise>
888 <xsl:call-template name="ccdDateTime">
889 <xsl:with-param name="dt" select="$testDate"/>
890 </xsl:call-template>
891 </xsl:otherwise>
892 </xsl:choose>
893
894 <xsl:choose>
895 <xsl:when test="$ccrTestNode/a:TestResult[a:Value!='']">
896 <value xsi:type="PQ">
897 <xsl:attribute name="value">
898 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Value"/>
899 </xsl:attribute>
900 <xsl:attribute name="unit">
901 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Units/a:Unit"/>
902 </xsl:attribute>
903 </value>
904 </xsl:when>
905 <xsl:when test="$ccrTestNode/a:TestResult[a:Description/a:Text!='']">
906 <value xsi:type="TX">
907 <xsl:attribute name="value">
908 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Description/a:Text"/>
909 </xsl:attribute>
910 </value>
911 </xsl:when>
912 </xsl:choose>
913
914 <xsl:if test="$ccrTestNode/a:Flag">
915 <xsl:call-template name="ccdCodedValue">
916 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Flag"/>
917 <xsl:with-param name="nodeName" select="'interpretationCode'"/>
918 <xsl:with-param name="domain" select="'ObservationInterpretation'"/>
919 </xsl:call-template>
920 </xsl:if>
921
922 <xsl:if test="$ccrTestNode/a:NormalResult">
923 <referenceRange>
924 <xsl:if test="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text">
925 <observationRange>
926 <text>
927 <xsl:value-of select="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text"/>
928 </text>
929 </observationRange>
930 </xsl:if>
931 </referenceRange>
932 </xsl:if>
933
934 </observation>
935 </component>
936
937 </xsl:template>
938</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.