source: ccr2ccd-xslt/trunk/make/ccd-util.xsl@ 1033

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

broke the stylesheet into pieces with a script to reassemble

File size: 31.6 KB
Line 
1 <xsl:template name="ccdAssignedEntity">
2 <xsl:param name="ccrActorObjectID"/>
3
4 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
5
6 <assignedEntity>
7 <xsl:call-template name="ccdEntityID">
8 <xsl:with-param name="CCRActor" select="$CCRActor"/>
9 </xsl:call-template>
10
11 <xsl:call-template name="ccdAddress">
12 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address"/>
13 </xsl:call-template>
14
15 <xsl:call-template name="ccdTelecom">
16 <xsl:with-param name="CCRActor" select="$CCRActor"/>
17 </xsl:call-template>
18
19 <xsl:if test="$CCRActor/a:Person">
20 <xsl:call-template name="ccdPerson">
21 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
22 <xsl:with-param name="personNodeName" select="'assignedPerson'"/>
23 </xsl:call-template>
24 </xsl:if>
25
26 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
27 <xsl:call-template name="ccdOrganization">
28 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
29 <xsl:with-param name="organizationNodeName" select="'representedOrganization'"/>
30 </xsl:call-template>
31 </xsl:if>
32
33 </assignedEntity>
34 </xsl:template>
35
36 <xsl:template name="ccdPatient">
37 <xsl:param name="CCRActorPerson"/>
38 <patient>
39 <xsl:call-template name="ccdPersonName">
40 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
41 </xsl:call-template>
42
43 <xsl:if test="$CCRActorPerson/a:Gender">
44 <xsl:call-template name="ccdCodedValue">
45 <xsl:with-param name="ccrCodedDescription" select="$CCRActorPerson/a:Gender"/>
46 <xsl:with-param name="domain" select="'AdministrativeGender'"/>
47 <xsl:with-param name="nodeName" select="'administrativeGenderCode'"/>
48 </xsl:call-template>
49 </xsl:if>
50
51 <xsl:if test="$CCRActorPerson/a:DateOfBirth">
52 <birthTime>
53 <xsl:attribute name="value">
54 <xsl:call-template name="date:format-date">
55 <xsl:with-param name="date-time" select="$CCRActorPerson/a:DateOfBirth/a:ExactDateTime"/>
56 <xsl:with-param name="pattern">yyyyMMddhhmmss</xsl:with-param>
57 </xsl:call-template>
58 </xsl:attribute>
59 </birthTime>
60 </xsl:if>
61
62 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']">
63 <xsl:call-template name="ccdCodedValue">
64 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']/a:Description"/>
65 <xsl:with-param name="domain" select="'MaritalStatus'"/>
66 <xsl:with-param name="nodeName" select="'maritalStatusCode'"/>
67 </xsl:call-template>
68 </xsl:if>
69
70 <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']">
71 <languageCommunication>
72 <templateId root="2.16.840.1.113883.3.88.11.83.2" assigningAuthorityName="HITSP/C83"/>
73 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.2.1" assigningAuthorityName="IHE/PCC"/>
74 <xsl:call-template name="ccdCodedValue">
75 <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']/a:Description"></xsl:with-param>
76 <xsl:with-param name="domain" select="'HumanLanguage'"/>
77 <xsl:with-param name="nodeName" select="'languageCode'"/>
78 </xsl:call-template>
79 </languageCommunication>
80 </xsl:if>
81 </patient>
82 </xsl:template>
83
84 <xsl:template name="ccdPerformer">
85 <xsl:param name="ccrActorReference"/>
86 <performer typeCode="PRF">
87 <xsl:if test="$ccrActorReference/a:ActorRole">
88 <xsl:call-template name="ccdCodedValue">
89 <xsl:with-param name="ccrCodedDescription" select="$ccrActorReference/a:ActorRole"/>
90 <xsl:with-param name="nodeName" select="'functionCode'"/>
91 </xsl:call-template>
92 </xsl:if>
93 <xsl:call-template name="ccdAssignedEntity">
94 <xsl:with-param name="ccrActorObjectID" select="$ccrActorReference/a:ActorID"/>
95 </xsl:call-template>
96 </performer>
97 </xsl:template>
98
99 <xsl:template name="ccdPerson">
100 <xsl:param name="CCRActorPerson"/>
101 <xsl:param name="personNodeName">assignedPerson</xsl:param>
102 <xsl:element name="{$personNodeName}">
103 <xsl:call-template name="ccdPersonName">
104 <xsl:with-param name="CCRActorName" select="$CCRActorPerson/a:Name"/>
105 </xsl:call-template>
106 </xsl:element>
107 </xsl:template>
108
109 <xsl:template name="ccdPersonName">
110 <xsl:param name="CCRActorName"/>
111 <name>
112 <xsl:if test="$CCRActorName/a:CurrentName/a:Title">
113 <prefix>
114 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Title"/>
115 </prefix>
116 </xsl:if>
117 <xsl:if test="$CCRActorName/a:CurrentName/a:Given">
118 <given>
119 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Given"/>
120 </given>
121 </xsl:if>
122 <xsl:if test="$CCRActorName/a:CurrentName/a:Middle">
123 <given>
124 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Middle"/>
125 </given>
126 </xsl:if>
127 <xsl:if test="$CCRActorName/a:CurrentName/a:Family">
128 <family>
129 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Family"/>
130 </family>
131 </xsl:if>
132 <xsl:if test="$CCRActorName/a:CurrentName/a:Suffix">
133 <suffix>
134 <xsl:value-of select="$CCRActorName/a:CurrentName/a:Suffix"/>
135 </suffix>
136 </xsl:if>
137 </name>
138 </xsl:template>
139
140 <xsl:template name="ccdOrganization">
141 <xsl:param name="ccrActorObjectID"/>
142 <xsl:param name="organizationNodeName"/>
143
144 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
145
146 <xsl:element name="{$organizationNodeName}">
147 <xsl:call-template name="ccdEntityID">
148 <xsl:with-param name="CCRActor" select="$CCRActor"/>
149 </xsl:call-template>
150 <xsl:call-template name="ccdTelecom">
151 <xsl:with-param name="CCRActor" select="$CCRActor"/>
152 </xsl:call-template>
153
154 <xsl:call-template name="ccdAddress">
155 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
156 </xsl:call-template>
157 </xsl:element>
158 </xsl:template>
159
160 <xsl:template name="ccdPatientRole">
161 <xsl:param name="ccrActorObjectID"/>
162
163 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
164
165 <xsl:call-template name="ccdEntityID">
166 <xsl:with-param name="CCRActor" select="$CCRActor"/>
167 </xsl:call-template>
168
169 <xsl:call-template name="ccdAddress">
170 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
171 </xsl:call-template>
172
173 <xsl:call-template name="ccdTelecom">
174 <xsl:with-param name="CCRActor" select="$CCRActor"/>
175 </xsl:call-template>
176
177 <xsl:call-template name="ccdPatient">
178 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
179 </xsl:call-template>
180 </xsl:template>
181
182 <xsl:template name="ccdAssignedAuthor">
183 <xsl:param name="ccrActorObjectID"/>
184 <assignedAuthor>
185 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
186
187 <xsl:call-template name="ccdEntityID">
188 <xsl:with-param name="CCRActor" select="$CCRActor"/>
189 </xsl:call-template>
190
191 <xsl:call-template name="ccdAddress">
192 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
193 </xsl:call-template>
194
195 <xsl:call-template name="ccdTelecom">
196 <xsl:with-param name="CCRActor" select="$CCRActor"/>
197 </xsl:call-template>
198
199 <xsl:call-template name="ccdPerson">
200 <xsl:with-param name="CCRActorPerson" select="$CCRActor/a:Person"/>
201 </xsl:call-template>
202
203 <xsl:if test="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']">
204 <representedOrganization>
205 <xsl:call-template name="ccdOrganization">
206 <xsl:with-param name="ccrActorObjectID" select="$CCRActor/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"/>
207 </xsl:call-template>
208 </representedOrganization>
209 </xsl:if>
210 </assignedAuthor>
211 </xsl:template>
212
213 <xsl:template name="ccdParticipantRoleActor">
214 <xsl:param name="ccrActorObjectID"/>
215
216 <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
217
218 <xsl:call-template name="ccdEntityID">
219 <xsl:with-param name="CCRActor" select="$CCRActor"/>
220 </xsl:call-template>
221
222 <xsl:call-template name="ccdAddress">
223 <xsl:with-param name="CCRActorAddress" select="$CCRActor/a:Address[1]"/>
224 </xsl:call-template>
225
226 <xsl:call-template name="ccdTelecom">
227 <xsl:with-param name="CCRActor" select="$CCRActor"/>
228 </xsl:call-template>
229
230 <xsl:if test="$CCRActor/a:Organization/a:Name">
231 <playingEntity classCode="PLC">
232 <name>
233 <xsl:value-of select="$CCRActor/a:Organization/a:Name"/>
234 </name>
235 </playingEntity>
236 </xsl:if>
237 </xsl:template>
238
239 <xsl:template name="ccdParticipantRoleCodedDescription">
240 <xsl:param name="ccrCodedDescription"/>
241 <participantRole classCode="MANU">
242 <!--Product Detail-->
243 <playingEntity classCode="MMAT">
244 <xsl:if test="$ccrCodedDescription/a:Code">
245 <xsl:call-template name="ccdCodedValue">
246 <xsl:with-param name="ccrCodedDescription" select="$ccrCodedDescription"/>
247 <xsl:with-param name="nodeName" select="'code'"/>
248 </xsl:call-template>
249 </xsl:if>
250 <name>
251 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
252 </name>
253 </playingEntity>
254 </participantRole>
255 </xsl:template>
256
257 <xsl:template name="ccdEntityID">
258 <xsl:param name="CCRActor"/>
259 <id>
260 <xsl:choose>
261 <xsl:when test="$CCRActor/a:IDs">
262 <xsl:attribute name="extension">
263 <xsl:value-of select="$CCRActor/a:IDs[1]/a:ID"/>
264 </xsl:attribute>
265 <xsl:attribute name="root">
266 <xsl:value-of select="$CCRActor/a:IDs[1]/a:Type/a:Text"/>
267 </xsl:attribute>
268 </xsl:when>
269 <xsl:otherwise>
270 <xsl:attribute name="extension">
271 <xsl:value-of select="$CCRActor/a:ActorObjectID"/>
272 </xsl:attribute>
273 <xsl:attribute name="root">
274 <xsl:text>CCRActorID</xsl:text>
275 </xsl:attribute>
276 </xsl:otherwise>
277 </xsl:choose>
278 </id>
279 <xsl:if test="$CCRActor/a:Organization">
280 <name><xsl:value-of select="$CCRActor/a:Organization/a:Name"></xsl:value-of></name>
281 </xsl:if>
282 </xsl:template>
283 <xsl:template name="ccdAddress">
284 <xsl:param name="CCRActorAddress"/>
285 <addr>
286 <xsl:choose>
287 <xsl:when test="$CCRActorAddress">
288 <xsl:attribute name="use">
289 <xsl:call-template name="CDAVocabularyLookup">
290 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
291 <xsl:with-param name="ccrtext" select="$CCRActorAddress/a:Type/a:Text"/>
292 </xsl:call-template>
293 </xsl:attribute>
294 <streetAddressLine>
295 <xsl:value-of select="$CCRActorAddress/a:Line1"/>
296 </streetAddressLine>
297 <city>
298 <xsl:value-of select="$CCRActorAddress/a:City"/>
299 </city>
300 <state>
301 <xsl:value-of select="$CCRActorAddress/a:State"/>
302 </state>
303 <postalCode>
304 <xsl:value-of select="$CCRActorAddress/a:PostalCode"/>
305 </postalCode>
306 </xsl:when>
307 <xsl:otherwise>
308 <streetAddressLine/>
309 </xsl:otherwise>
310 </xsl:choose>
311 </addr>
312 </xsl:template>
313
314 <xsl:template name="ccdTelecom">
315 <xsl:param name="CCRActor"/>
316 <telecom>
317 <xsl:if test="$CCRActor/a:Telephone">
318 <xsl:attribute name="use">
319 <xsl:call-template name="CDAVocabularyLookup">
320 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
321 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
322 </xsl:call-template>
323 </xsl:attribute>
324 <xsl:attribute name="value">
325 <xsl:text>tel:+1-</xsl:text>
326 <xsl:value-of select="$CCRActor/a:Telephone[1]/a:Value"/>
327 </xsl:attribute>
328 </xsl:if>
329 </telecom>
330
331 <xsl:if test="$CCRActor/a:Email">
332 <telecom>
333 <xsl:choose>
334 <xsl:when test="$CCRActor/a:Telephone">
335 <xsl:attribute name="use">
336 <xsl:call-template name="CDAVocabularyLookup">
337 <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
338 <xsl:with-param name="ccrtext" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
339 </xsl:call-template>
340 </xsl:attribute>
341 <xsl:attribute name="value">
342 <xsl:text>mailto:</xsl:text>
343 <xsl:value-of select="$CCRActor/a:Email[1]/a:Value"/>
344 </xsl:attribute>
345 </xsl:when>
346 <xsl:otherwise>
347 <xsl:attribute name="value">
348 <xsl:text>Unknown</xsl:text>
349 </xsl:attribute>
350 </xsl:otherwise>
351 </xsl:choose>
352 </telecom>
353 </xsl:if>
354 </xsl:template>
355
356 <xsl:template name="ccdID">
357 <xsl:param name="ccrObjectID"/>
358 <xsl:param name="suffix"/>
359 <id>
360 <xsl:attribute name="root">
361 <xsl:value-of select="$ccrObjectID"></xsl:value-of>
362 </xsl:attribute>
363 <xsl:attribute name="extension">CCRObjectID</xsl:attribute>
364 </id>
365 </xsl:template>
366
367 <xsl:template name="ccdCodedValue">
368 <xsl:param name="ccrCodedDescription"/>
369 <xsl:param name="type"/>
370 <xsl:param name="domain"/>
371 <xsl:param name="nodeName">value</xsl:param>
372 <xsl:param name="originalTextReference"/>
373
374 <xsl:element name="{$nodeName}">
375 <xsl:if test="$type">
376 <xsl:attribute name="xsi:type">
377 <xsl:value-of select="$type"/>
378 </xsl:attribute>
379 </xsl:if>
380 <xsl:choose>
381 <xsl:when test="$ccrCodedDescription/a:Code">
382 <xsl:attribute name="displayName">
383 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
384 </xsl:attribute>
385 <xsl:attribute name="code">
386 <xsl:value-of select="$ccrCodedDescription/a:Code/a:Value"/>
387 </xsl:attribute>
388 <xsl:attribute name="codeSystemName">
389 <xsl:value-of select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
390 </xsl:attribute>
391 <xsl:attribute name="codeSystem">
392 <xsl:call-template name="HL7OIDLookup">
393 <xsl:with-param name="name" select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
394 </xsl:call-template>
395 </xsl:attribute>
396 </xsl:when>
397 <xsl:when test="$domain">
398 <xsl:variable name="cdaCode">
399 <xsl:call-template name="CDAVocabularyLookup">
400 <xsl:with-param name="domain" select="$domain"/>
401 <xsl:with-param name="ccrtext" select="$ccrCodedDescription/a:Text"/>
402 </xsl:call-template>
403 </xsl:variable>
404 <xsl:attribute name="displayName">
405 <xsl:call-template name="CDADisplayNameLookup">
406 <xsl:with-param name="domain" select="$domain"/>
407 <xsl:with-param name="cdacode" select="$cdaCode"/>
408 </xsl:call-template>
409 </xsl:attribute>
410 <xsl:attribute name="code">
411 <xsl:value-of select="$cdaCode"></xsl:value-of>
412 </xsl:attribute>
413 <xsl:attribute name="codeSystemName">
414 <xsl:call-template name="CDAVocabularyCodeSystemNameLookup">
415 <xsl:with-param name="domain" select="$domain"/>
416 </xsl:call-template>
417 </xsl:attribute>
418 <xsl:attribute name="codeSystemName">
419 <xsl:call-template name="CDAVocabularyCodeSystemLookup">
420 <xsl:with-param name="domain" select="$domain"/>
421 </xsl:call-template>
422 </xsl:attribute>
423 </xsl:when>
424 <xsl:otherwise>
425 <originalText>
426 <xsl:value-of select="$ccrCodedDescription/a:Text"/>
427 <xsl:if test="$originalTextReference">
428 <reference>
429 <xsl:attribute name="value">
430 <xsl:value-of select="$originalTextReference"/>
431 </xsl:attribute>
432 </reference>
433 </xsl:if>
434 </originalText>
435 </xsl:otherwise>
436 </xsl:choose>
437 </xsl:element>
438 </xsl:template>
439
440 <xsl:template name="ccdDateTime">
441 <xsl:param name="dt"/>
442 <xsl:param name="type"/>
443 <xsl:if test="$dt">
444 <xsl:if test="$dt[1]/a:ExactDateTime">
445 <effectiveTime>
446 <xsl:if test="$type">
447 <xsl:attribute name="xsi:type">
448 <xsl:value-of select="$type"></xsl:value-of>
449 </xsl:attribute>
450 </xsl:if>
451 <low>
452 <xsl:attribute name="value">
453 <xsl:call-template name="date:format-date">
454 <xsl:with-param name="date-time" select="$dt[1]/a:ExactDateTime"/>
455 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
456 </xsl:call-template>
457 </xsl:attribute>
458 </low>
459 <high nullFlavor="UNK"/>
460 </effectiveTime>
461 </xsl:if>
462 <xsl:if test="$dt[1]/a:DateTimeRange">
463 <effectiveTime>
464 <low>
465 <xsl:attribute name="value">
466 <xsl:call-template name="date:format-date">
467 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:BeginRange/a:ExactDateTime"/>
468 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
469 </xsl:call-template>
470 </xsl:attribute>
471 </low>
472 <high>
473 <xsl:attribute name="value">
474 <xsl:call-template name="date:format-date">
475 <xsl:with-param name="date-time" select="$dt[1]/a:DateTimeRange/a:EndRange/a:ExactDateTime"/>
476 <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
477 </xsl:call-template>
478 </xsl:attribute>
479 </high>
480 </effectiveTime>
481 </xsl:if>
482 </xsl:if>
483 </xsl:template>
484
485 <xsl:template name="ccdMedicationFrequency">
486 <xsl:param name="frequency"/>
487 <xsl:if test="$frequency">
488 <xsl:choose>
489 <xsl:when test="$frequency/a:Value='qd'">
490 <effectiveTime xsi:type="PIVL_TS" operator="A">
491 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
492 <period>
493 <xsl:attribute name="value">24</xsl:attribute>
494 <xsl:attribute name="unit">h</xsl:attribute>
495 </period>
496 </effectiveTime>
497 </xsl:when>
498 <xsl:when test="$frequency/a:Value='bid'">
499 <effectiveTime xsi:type="PIVL_TS" operator="A">
500 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
501 <period>
502 <xsl:attribute name="value">12</xsl:attribute>
503 <xsl:attribute name="unit">h</xsl:attribute>
504 </period>
505 </effectiveTime>
506 </xsl:when>
507 <xsl:when test="$frequency/a:Value='tid'">
508 <effectiveTime xsi:type="PIVL_TS" operator="A">
509 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
510 <period>
511 <xsl:attribute name="value">8</xsl:attribute>
512 <xsl:attribute name="unit">h</xsl:attribute>
513 </period>
514 </effectiveTime>
515 </xsl:when>
516 <xsl:when test="$frequency/a:Value='qid'">
517 <effectiveTime xsi:type="PIVL_TS" operator="A">
518 <xsl:attribute name="institutionSpecified">true</xsl:attribute>
519 <period>
520 <xsl:attribute name="value">6</xsl:attribute>
521 <xsl:attribute name="unit">h</xsl:attribute>
522 </period>
523 </effectiveTime>
524 </xsl:when>
525 <xsl:when test="$frequency/a:Value='qam'">
526 <effectiveTime xsi:type='EIVL' operator='A'>
527 <event code='ACM'/>
528 </effectiveTime>
529 </xsl:when>
530 <xsl:when test="$frequency/a:Value='qpm'">
531 <effectiveTime xsi:type='EIVL' operator='A'>
532 <event code='PCV'/>
533 </effectiveTime>
534 </xsl:when>
535 </xsl:choose>
536 </xsl:if>
537 </xsl:template>
538
539 <xsl:template name="ccdStatus">
540 <xsl:param name="ccrStatus"/>
541
542 <entryRelationship typeCode="REFR">
543 <observation classCode="OBS" moodCode="EVN">
544 <templateId root="2.16.840.1.113883.10.20.1.50"/>
545 <!-- Problem status observation template -->
546 <code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/>
547 <statusCode code="completed"/>
548 <xsl:call-template name="ccdCodedValue">
549 <xsl:with-param name="ccrCodedDescription" select="$ccrStatus"/>
550 </xsl:call-template>
551 </observation>
552 </entryRelationship>
553 </xsl:template>
554
555 <xsl:template name="ccdStatusObservation">
556 <xsl:param name="status"/>
557 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
558 <xsl:choose>
559 <xsl:when test="$statusText='Active'">
560 <xsl:call-template name="ccdStatusElement">
561 <xsl:with-param name="statusCode" select="'55561003'"/>
562 <xsl:with-param name="statusDisplayName" select="$statusText"/>
563 </xsl:call-template>
564 </xsl:when>
565 <xsl:when test="$statusText='Inactive'">
566 <xsl:call-template name="ccdStatusElement">
567 <xsl:with-param name="statusCode" select="'73425007'"/>
568 <xsl:with-param name="statusDisplayName" select="$statusText"/>
569 </xsl:call-template>
570 </xsl:when>
571 <xsl:when test="$statusText='Chronic'">
572 <xsl:call-template name="ccdStatusElement">
573 <xsl:with-param name="statusCode" select="'90734009'"/>
574 <xsl:with-param name="statusDisplayName" select="$statusText"/>
575 </xsl:call-template>
576 </xsl:when>
577 </xsl:choose>
578 </xsl:template>
579
580 <xsl:template name="ccdStatusProcedure">
581 <xsl:param name="status"/>
582 <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
583 <xsl:choose>
584 <xsl:when test="$statusText='Completed'">
585 <statusCode code="completed"/>
586 </xsl:when>
587 <xsl:when test="$statusText='Active'">
588 <statusCode code="active"/>
589 </xsl:when>
590 <xsl:when test="$statusText='Aborted'">
591 <statusCode code="aborted"/>
592 </xsl:when>
593 <xsl:when test="$statusText='Cancelled' or $statusText='Canceled'">
594 <statusCode code="cancelled"/>
595 </xsl:when>
596 <xsl:otherwise>
597 <statusCode>
598 <xsl:attribute name="code">
599 <xsl:value-of select="$statusText"></xsl:value-of>
600 </xsl:attribute>
601 </statusCode>
602 </xsl:otherwise>
603 </xsl:choose>
604 </xsl:template>
605
606 <xsl:template name="ccdStatusElement">
607 <xsl:param name="statusCode"/>
608 <xsl:param name="statusDisplayName"/>
609 <value>
610 <xsl:attribute name="xsi:type">CE</xsl:attribute>
611 <xsl:attribute name="code">
612 <xsl:value-of select="$statusCode"></xsl:value-of>
613 </xsl:attribute>
614 <xsl:attribute name="codeSystem">2.16.840.1.113883.6.96</xsl:attribute>
615 <xsl:attribute name="displayName">
616 <xsl:value-of select="$statusDisplayName"></xsl:value-of>
617 </xsl:attribute>
618 </value>
619 </xsl:template>
620
621 <xsl:template name="ccdObservation">
622 <xsl:param name="ccrTestNode"/>
623 <xsl:param name="testDate"/>
624
625 <component>
626 <observation classCode="OBS" moodCode="EVN">
627 <templateId root="2.16.840.1.113883.3.88.11.83.15" assigningAuthorityName="HITSP C83"/>
628 <templateId root="2.16.840.1.113883.10.20.1.31" assigningAuthorityName="CCD"/>
629 <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13" assigningAuthorityName="IHE PCC"/>
630
631 <!-- Result observation template -->
632
633 <xsl:call-template name="ccdID">
634 <xsl:with-param name="ccrObjectID" select="$ccrTestNode/a:CCRDataObjectID"/>
635 </xsl:call-template>
636
637 <!-- <code> -->
638 <xsl:call-template name="ccdCodedValue">
639 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Description"/>
640 <xsl:with-param name="nodeName" select="'code'"/>
641 </xsl:call-template>
642
643 <text>
644 <reference>
645 <xsl:attribute name="value">
646 <xsl:text>#</xsl:text>
647 <xsl:value-of select="$ccrTestNode/a:CCRDataObjectID"/>
648 </xsl:attribute>
649 </reference>
650 </text>
651
652 <statusCode code="completed"/>
653
654 <!-- <effectiveTime> -->
655 <xsl:choose>
656 <xsl:when test="$ccrTestNode/a:DateTime">
657 <xsl:call-template name="ccdDateTime">
658 <xsl:with-param name="dt" select="$ccrTestNode/a:DateTime"/>
659 </xsl:call-template>
660 </xsl:when>
661 <xsl:otherwise>
662 <xsl:call-template name="ccdDateTime">
663 <xsl:with-param name="dt" select="$testDate"/>
664 </xsl:call-template>
665 </xsl:otherwise>
666 </xsl:choose>
667
668 <xsl:choose>
669 <xsl:when test="$ccrTestNode/a:TestResult[a:Value!='']">
670 <value xsi:type="PQ">
671 <xsl:attribute name="value">
672 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Value"/>
673 </xsl:attribute>
674 <xsl:attribute name="unit">
675 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Units/a:Unit"/>
676 </xsl:attribute>
677 </value>
678 </xsl:when>
679 <xsl:when test="$ccrTestNode/a:TestResult[a:Description/a:Text!='']">
680 <value xsi:type="TX">
681 <xsl:attribute name="value">
682 <xsl:value-of select="$ccrTestNode/a:TestResult/a:Description/a:Text"/>
683 </xsl:attribute>
684 </value>
685 </xsl:when>
686 </xsl:choose>
687
688 <xsl:if test="$ccrTestNode/a:Flag">
689 <xsl:call-template name="ccdCodedValue">
690 <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Flag"/>
691 <xsl:with-param name="nodeName" select="'interpretationCode'"/>
692 <xsl:with-param name="domain" select="'ObservationInterpretation'"/>
693 </xsl:call-template>
694 </xsl:if>
695
696 <xsl:if test="$ccrTestNode/a:NormalResult">
697 <referenceRange>
698 <xsl:if test="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text">
699 <observationRange>
700 <text>
701 <xsl:value-of select="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text"/>
702 </text>
703 </observationRange>
704 </xsl:if>
705 </referenceRange>
706 </xsl:if>
707
708 </observation>
709 </component>
710
711 </xsl:template>
712</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.