-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCDA.xsl
1446 lines (1395 loc) · 62.6 KB
/
CDA.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n1="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="html" indent="yes" version="4.01" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.01//EN"/>
<!-- CDA document -->
<xsl:variable name="textEncoding">ISO-8859-1</xsl:variable>
<xsl:variable name="tableWidth">50%</xsl:variable>
<xsl:variable name="title">
<xsl:choose>
<xsl:when test="//n1:ClinicalDocument/n1:title">
<xsl:value-of select="//n1:ClinicalDocument/n1:title"/>
</xsl:when>
<xsl:when test="//n1:ClinicalDocument/n1:code/@displayName">
<xsl:value-of select="//n1:ClinicalDocument/n1:code/@displayName"/>
</xsl:when>
<xsl:otherwise>Clinical Document</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="n1:ClinicalDocument"/>
</xsl:template>
<xsl:template match="n1:ClinicalDocument">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={$textEncoding}"/>
<!-- <meta name='Generator' content='&CDA-Stylesheet;'/> -->
<xsl:comment> Do NOT edit this HTML directly, it was generated via an XSLt transformation from the original release 2 CDA Document. </xsl:comment>
<xsl:comment>Derived from HL7 Finland R2 Tyylitiedosto: Tyyli_R2_B3_01.xslt</xsl:comment>
<xsl:comment>Updated by Calvin E. Beebe, Mayo Clinic - Rochester Mn. </xsl:comment>
<xsl:comment>Updated by Keith W. Boone, Dictaphone - Burlington, MA </xsl:comment>
<xsl:comment>Updated by Kai U. Heitmann, Heitmann Consulting & Service, NL for VHitG, Germany </xsl:comment>
<xsl:comment>Updated by René Spronk, translate back to English-language labels</xsl:comment>
<xsl:comment>Updated by Dick Donker, Philips Medical Systems include linkHtml</xsl:comment>
<xsl:comment>Updated by Tony Schaller, medshare GmbH, for HL7 affiliate Switzerland</xsl:comment>
<xsl:comment xml:space="preserve">Updated by Alexander Henket, E.Novation B.V.
- added meta tag that includes the encoding of the rendered document
- changed/updated the BottomLine to include every header participation, except those behind Encounter
- changed "Attending physician" at the top of the document. Only displayed if available, and now includes
Location if present too
- added support for all? missing attributes from NarrativeBlock, including all styleCodes
- added CSS class for inserted text with overline and underline and a tooltip
- changed the way the title is retrieved by also checking ClinicalDocument/code/@displayName
- changed names and addresses so they follow all parts as present instead of a few in arbitrary order
- Lots of minor bug fixes
- Known issue: footNote/footNoteRef and most Acts on the header not supported
</xsl:comment>
<title>
<xsl:value-of select="$title"/>
</title>
<style type="text/css" media="screen">
body {
color: #003366;
font-size: 12px;
line-height: normal;
font-family: Verdana, Arial, sans-serif;
margin: 10px;
scrollbar-3dlight-color: #EEEEEE;
scrollbar-arrow-color: #003366;
scrollbar-darkshadow-color: #EEEEEE;
scrollbar-face-color: #EEEEEE;
scrollbar-highlight-color: #003366;
scrollbar-shadow-color: #003366;
scrollbar-track-color: #EEEEEE;
}
a {
color: #0099ff;
text-decoration: none;
}
table {
font-size: 10pt;
background-repeat: no-repeat;
border: 2px #bacd0c;
line-height: 10pt;
border-width: 0;
border-color: #eeeeee
}
.input {
color: #003366;
font-size: 10pt;
font-family: Verdana, Arial, sans-serif;
background-color: #ffffff;
border: solid 1px
}
h1 {
font-size: 12pt;
}
h2 {
font-size: 11pt;
}
.revision_insert {
text-decoration: underline overline;
}</style>
</head>
<body>
<table style="width: 100%">
<tr bgcolor="#3399ff">
<td width="15%" valign="top">
<span style="color:white;font-weight:bold;">
<xsl:text>Patient:</xsl:text>
</span>
</td>
<td width="45%" valign="top">
<span style="color:white;font-weight:bold; ">
<xsl:call-template name="getName">
<xsl:with-param name="name" select="n1:recordTarget/n1:patientRole/n1:patient/n1:name"/>
</xsl:call-template>
</span>
</td>
<td width="10%" align="right" valign="top">
<span style="color:white; ">
<xsl:text>DOB:</xsl:text>
</span>
</td>
<td width="30%" valign="top">
<span style="color:white; ">
<xsl:call-template name="formatDate">
<xsl:with-param name="date" select="n1:recordTarget/n1:patientRole/n1:patient/n1:birthTime/@value"/>
</xsl:call-template>
</span>
</td>
</tr>
<tr bgcolor="#ccccff">
<td valign="top"> </td>
<td valign="top">
<xsl:call-template name="getContactInfo">
<xsl:with-param name="contact" select="n1:recordTarget/n1:patientRole"/>
</xsl:call-template>
</td>
<td valign="top" align="right">
<xsl:text>Patient-ID:</xsl:text>
</td>
<td valign="top">
<xsl:apply-templates select="n1:recordTarget/n1:patientRole/n1:id" mode="getIDs"/>
</td>
</tr>
<tr bgcolor="#ccccff">
<td valign="top">
<xsl:text>Created on:</xsl:text>
</td>
<td valign="top">
<xsl:call-template name="formatDate">
<xsl:with-param name="date" select="n1:effectiveTime/@value"/>
</xsl:call-template>
</td>
<td valign="top" align="right">
<xsl:text>Gender:</xsl:text>
</td>
<td valign="top">
<xsl:variable name="sex" select="n1:recordTarget/n1:patientRole/n1:patient/n1:administrativeGenderCode/@code"/>
<xsl:choose>
<xsl:when test="$sex='M'">Male</xsl:when>
<xsl:when test="$sex='F'">Female</xsl:when>
<xsl:when test="$sex='U'">Undifferentiated</xsl:when>
<xsl:otherwise>Unknown</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<xsl:if test="n1:componentOf/n1:encompassingEncounter/n1:responsibleParty/n1:assignedEntity/n1:assignedPerson/n1:name">
<tr bgcolor="#ccccff">
<td valign="top">
<xsl:text>Attending physician:</xsl:text>
</td>
<td valign="top">
<xsl:call-template name="getName">
<xsl:with-param name="name" select="n1:componentOf/n1:encompassingEncounter/n1:responsibleParty/n1:assignedEntity/n1:assignedPerson/n1:name"/>
</xsl:call-template>
<br/>
<xsl:call-template name="getContactInfo">
<xsl:with-param name="contact" select="n1:componentOf/n1:encompassingEncounter/n1:responsibleParty/n1:assignedEntity/n1:representedOrganization"/>
</xsl:call-template>
</td>
<td valign="top" align="right">
<xsl:text>Location:</xsl:text>
</td>
<td valign="top">
<xsl:apply-templates select="n1:componentOf/n1:encompassingEncounter/n1:location/n1:healthCareFacility/n1:code" mode="getText"/>
</td>
</tr>
</xsl:if>
</table>
<hr/>
<h2>
<xsl:value-of select="$title"/>
</h2>
<xsl:apply-templates select="n1:component/n1:structuredBody|n1:component/n1:nonXMLBody"/>
<hr/>
<xsl:call-template name="bottomline"/>
</body>
</html>
</xsl:template>
<!-- Get from a code originalText, displayName or code -->
<xsl:template match="n1:code" mode="getText">
<xsl:choose>
<xsl:when test="n1:originalText">
<xsl:value-of select="n1:originalText"/>
</xsl:when>
<xsl:when test="@displayName">
<xsl:value-of select="@displayName"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@code"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Get all IDs -->
<xsl:template match="n1:id" mode="getIDs">
<table width="100%" cellspacing="0" cellpadding="0">
<xsl:for-each select="../n1:id">
<tr>
<td width="40%" align="left">
<xsl:value-of select="./@extension"/>
</td>
<td width="60%" align="left">
<xsl:value-of select="./@root"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<!-- Get a Name -->
<!--
20090415: (AH) Now handles data type as given in XML, including mixed content,
instead of calling fixed parts in arbitrary order. It is also possible to activate
a tooltip on the name that lists the IDs this person has. Deactivated that because
it can be annoying when used in production.
-->
<xsl:template name="getName">
<xsl:param name="name"/>
<!--span>
<xsl:attribute name="title">
<xsl:for-each select="$name/../../n1:id">
<xsl:text>ID: </xsl:text>
<xsl:value-of select="@extension"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="@root"/>
<xsl:text>)</xsl:text>
<br/>
</xsl:for-each>
</xsl:attribute-->
<xsl:for-each select="$name/node()">
<xsl:if test="name() = 'suffix' or substring-after(name(),':') = 'suffix'">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
<xsl:if test="name() = 'given' or substring-after(name(),':') = 'given'">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
<!--/span-->
</xsl:template>
<!-- getLastFirstName: derived from Switzerland stylesheet but not called right now -->
<xsl:template name="getLastFirstName">
<xsl:param name="name"/>
<xsl:choose>
<xsl:when test="$name/n1:family">
<xsl:value-of select="$name/n1:family"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$name/n1:given"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Format Date: outputs a date in Month Day, Year form -->
<xsl:template name="formatDate">
<xsl:param name="date"/>
<xsl:variable name="month" select="substring ($date, 5, 2)"/>
<xsl:choose>
<xsl:when test="$month='01'">
<xsl:text>January </xsl:text>
</xsl:when>
<xsl:when test="$month='02'">
<xsl:text>February </xsl:text>
</xsl:when>
<xsl:when test="$month='03'">
<xsl:text>March</xsl:text>
</xsl:when>
<xsl:when test="$month='04'">
<xsl:text>April </xsl:text>
</xsl:when>
<xsl:when test="$month='05'">
<xsl:text>May </xsl:text>
</xsl:when>
<xsl:when test="$month='06'">
<xsl:text>June </xsl:text>
</xsl:when>
<xsl:when test="$month='07'">
<xsl:text>July </xsl:text>
</xsl:when>
<xsl:when test="$month='08'">
<xsl:text>August </xsl:text>
</xsl:when>
<xsl:when test="$month='09'">
<xsl:text>September </xsl:text>
</xsl:when>
<xsl:when test="$month='10'">
<xsl:text>October </xsl:text>
</xsl:when>
<xsl:when test="$month='11'">
<xsl:text>November </xsl:text>
</xsl:when>
<xsl:when test="$month='12'">
<xsl:text>December </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="substring ($date, 7, 1)='0'">
<xsl:value-of select="substring ($date, 8, 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring ($date, 7, 2)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>, </xsl:text>
<xsl:value-of select="substring ($date, 1, 4)"/>
</xsl:template>
<!-- nonXMLBody -->
<xsl:template match="n1:component/n1:nonXMLBody">
<xsl:choose>
<!-- if there is a reference, use that in an IFRAME -->
<xsl:when test="n1:text/n1:reference">
<iframe name="nonXMLBody" id="nonXMLBody" WIDTH="100%" HEIGHT="66%" src="{n1:text/n1:reference/@value}"/>
</xsl:when>
<xsl:when test="n1:text/@mediaType='text/plain'">
<pre>
<xsl:value-of select="n1:text/text()"/>
</pre>
</xsl:when>
<xsl:when test="n1:text/@mediaType='text/html'">
<div WIDTH="100%" HEIGHT="66%">
<!--
<xsl:copy-of select="n1:text/n1:html/n1:body/n1:div"/>
-->
<!--<xsl:apply-templates select="n1:text"/>-->
<xsl:apply-templates/>
</div>
</xsl:when>
<xsl:otherwise>
<center>Cannot display the text</center>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- StructuredBody -->
<xsl:template match="n1:component/n1:structuredBody">
<xsl:apply-templates select="n1:component/n1:section"/>
</xsl:template>
<!-- Component/Section -->
<xsl:template match="n1:component/n1:section">
<xsl:apply-templates select="n1:title">
<xsl:with-param name="code" select="n1:code/@code"/>
</xsl:apply-templates>
<ul>
<xsl:apply-templates select="n1:text"/>
<xsl:if test="n1:component/n1:section">
<div>
<br/>
<xsl:apply-templates select="n1:component/n1:section"/>
</div>
</xsl:if>
</ul>
</xsl:template>
<!-- Title -->
<xsl:template match="n1:title">
<xsl:param name="code" select="''"/>
<span style="font-weight:bold;" title="{$code}">
<xsl:value-of select="."/>
</span>
</xsl:template>
<!-- Text -->
<xsl:template match="n1:text">
<xsl:apply-templates/>
</xsl:template>
<!-- paragraph -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:paragraph">
<p>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</p>
</xsl:template>
<!-- linkHtml -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:linkHtml">
<xsl:element name="a">
<xsl:attribute name="target">
<xsl:text>_blank</xsl:text>
</xsl:attribute>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!-- line break -->
<xsl:template match="n1:br">
<br/>
</xsl:template>
<!-- Content w/ deleted text is hidden -->
<xsl:template match="n1:content[@revised='delete']"/>
<!-- content -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:content">
<span>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</span>
</xsl:template>
<!-- list -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:list">
<!-- caption -->
<xsl:if test="n1:caption">
<span style="font-weight:bold; ">
<xsl:apply-templates select="n1:caption"/>
</span>
</xsl:if>
<!-- item -->
<xsl:choose>
<xsl:when test="@listType='ordered'">
<ol>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:for-each select="n1:item">
<li>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</li>
</xsl:for-each>
</ol>
</xsl:when>
<xsl:otherwise>
<!-- list is unordered -->
<ul>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:for-each select="n1:item">
<li>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</li>
</xsl:for-each>
</ul>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- caption -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:caption">
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
<xsl:text>: </xsl:text>
</xsl:template>
<!-- tables -->
<xsl:template match="n1:table/@*|n1:thead/@*|n1:tfoot/@*|n1:tbody/@*|n1:colgroup/@*|n1:col/@*|n1:tr/@*|n1:th/@*|n1:td/@*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<!-- table -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:table">
<table>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</table>
</xsl:template>
<!-- thead -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:thead">
<thead>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</thead>
</xsl:template>
<!-- tfoot -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:tfoot">
<tfoot>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</tfoot>
</xsl:template>
<!-- tbody -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:tbody">
<tbody>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</tbody>
</xsl:template>
<!-- colgroup -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:colgroup">
<colgroup>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</colgroup>
</xsl:template>
<!-- col -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:col">
<col>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</col>
</xsl:template>
<!-- tr -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:tr">
<tr bgcolor="#ffff66">
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</tr>
</xsl:template>
<!-- th -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:th">
<th bgcolor="#ffd700">
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</th>
</xsl:template>
<!-- td -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:td">
<td>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</td>
</xsl:template>
<!-- table/caption -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 attributes -->
<xsl:template match="n1:table/n1:caption">
<caption>
<xsl:apply-templates select="." mode="handleStyleCode"/>
<xsl:apply-templates select="." mode="handleOtherStyleCodes"/>
<xsl:apply-templates/>
</caption>
</xsl:template>
<!-- RenderMultiMedia
this currently only handles GIF's and JPEG's. It could, however,
be extended by including other image MIME types in the predicate
and/or by generating <object> or <applet> tag with the correct
params depending on the media type @ID =$imageRef referencedObject
-->
<xsl:template match="n1:renderMultiMedia">
<xsl:variable name="imageRef" select="@referencedObject"/>
<xsl:choose>
<xsl:when test="//n1:regionOfInterest[@ID=$imageRef]">
<!-- Here is where the Region of Interest image referencing goes -->
<xsl:if test="//n1:regionOfInterest[@ID=$imageRef]//n1:observationMedia/n1:value[@mediaType='image/gif' or @mediaType='image/jpeg']">
<br clear="all"/>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="//n1:regionOfInterest[@ID=$imageRef]//n1:observationMedia/n1:value/n1:reference/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<!-- Here is where the direct MultiMedia image referencing goes -->
<xsl:if test="//n1:observationMedia[@ID=$imageRef]/n1:value[@mediaType='image/gif' or @mediaType='image/jpeg']">
<br clear="all"/>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="//n1:observationMedia[@ID=$imageRef]/n1:value/n1:reference/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Stylecode processing -->
<!-- 20090415: (AH) Now supports all allowable CDAr2 style codes -->
<xsl:template match="*" mode="handleStyleCode">
<xsl:if test="@styleCode">
<xsl:attribute name="style">
<xsl:if test="contains(@styleCode,'Bold')">
<xsl:text>font-weight:bold;</xsl:text>
</xsl:if>
<xsl:if test="contains(@styleCode,'Italics')">
<xsl:text>font-style: italic;</xsl:text>
</xsl:if>
<xsl:if test="contains(@styleCode,'Underline')">
<xsl:text>text-decoration: underline;</xsl:text>
</xsl:if>
<xsl:if test="contains(@styleCode,'Emphasis')">
<xsl:text>font-weight:bold; font-style: italic;</xsl:text>
</xsl:if>
<xsl:if test="contains(@styleCode,'Lrule')">
<xsl:text>border-left-width: 5px; border-left-style: solid;</xsl:text>
</xsl:if>
<xsl:if test="contains(@styleCode,'Rrule')">
<xsl:text>border-right-width: 5px; border-right-style: solid;</xsl:text>
</xsl:if>
<xsl:if test="contains(@styleCode,'Toprule')">
<xsl:text>border-top-width: 5px; border-top-style: solid;</xsl:text>
</xsl:if>
<xsl:if test="contains(@styleCode,'Botrule')">
<xsl:text>border-bottom-width: 5px; border-bottom-style: solid;</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="contains(@styleCode,'Arabic')">
<xsl:text>list-style: arabic;</xsl:text>
</xsl:when>
<xsl:when test="contains(@styleCode,'LittleRoman')">
<xsl:text>list-style: lower-roman;</xsl:text>
</xsl:when>
<xsl:when test="contains(@styleCode,'BigRoman')">
<xsl:text>list-style: upper-roman;</xsl:text>
</xsl:when>
<xsl:when test="contains(@styleCode,'LittleAlpha')">
<xsl:text>list-style: lower-alpha;</xsl:text>
</xsl:when>
<xsl:when test="contains(@styleCode,'BigAlpha')">
<xsl:text>list-style: upper-alpha</xsl:text>
</xsl:when>
<xsl:when test="contains(@styleCode,'Disc')">
<xsl:text>list-style: disc;</xsl:text>
</xsl:when>
<xsl:when test="contains(@styleCode,'Circle')">
<xsl:text>list-style: circle;</xsl:text>
</xsl:when>
<xsl:when test="contains(@styleCode,'Square')">
<xsl:text>list-style: square;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:if>
</xsl:template>
<!-- Other style attribute processing -->
<!-- 20090415: (AH) New: does all other allowable CDAr2 style codes and ID -->
<xsl:template match="*" mode="handleOtherStyleCodes">
<!-- General stuff -->
<xsl:if test="@ID">
<xsl:attribute name="id">
<xsl:value-of select="@ID"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@IDREF">
<xsl:attribute name="idref">
<xsl:value-of select="@IDREF"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@language">
<xsl:attribute name="lang">
<xsl:value-of select="@language"/>
</xsl:attribute>
</xsl:if>
<!-- Table stuff -->
<xsl:if test="@border">
<xsl:attribute name="border">
<xsl:value-of select="@border"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@frame">
<xsl:attribute name="frame">
<xsl:value-of select="@frame"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@rules">
<xsl:attribute name="rules">
<xsl:value-of select="@rules"/>
</xsl:attribute>
</xsl:if>
<xsl:if test=". = n1:table">
<xsl:choose>
<xsl:when test="@cellpadding">
<xsl:attribute name="cellpadding">
<xsl:value-of select="@cellpadding"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="cellpadding">
<xsl:text>1</xsl:text>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test=". = n1:table">
<xsl:choose>
<xsl:when test="@cellspacing">
<xsl:attribute name="cellspacing">
<xsl:value-of select="@cellspacing"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="cellspacing">
<xsl:text>4</xsl:text>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="@span">
<xsl:attribute name="span">
<xsl:value-of select="@span"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@summary">
<xsl:attribute name="summary">
<xsl:value-of select="@summary"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@width">
<xsl:attribute name="width">
<xsl:value-of select="@width"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@align">
<xsl:attribute name="align">
<xsl:value-of select="@align"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@valign">
<xsl:attribute name="valign">
<xsl:value-of select="@valign"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@char">
<xsl:attribute name="char">
<xsl:value-of select="@char"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@charoff">
<xsl:attribute name="charoff">
<xsl:value-of select="@charoff"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@abbr">
<xsl:attribute name="abbr">
<xsl:value-of select="@abbr"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@scope">
<xsl:attribute name="scope">
<xsl:value-of select="@scope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@headers">
<xsl:attribute name="headers">
<xsl:value-of select="@headers"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@axis">
<xsl:attribute name="axis">
<xsl:value-of select="@axis"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@colspan">
<xsl:attribute name="colspan">
<xsl:value-of select="@colspan"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@rowspan">
<xsl:attribute name="rowspan">
<xsl:value-of select="@rowspan"/>
</xsl:attribute>
</xsl:if>
<!-- Text stuff -->
<xsl:if test="@revised">
<xsl:attribute name="class">
<xsl:text>revision_</xsl:text>
<xsl:value-of select="@revised"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:text>inserted</xsl:text>
</xsl:attribute>
</xsl:if>
<!-- LinkHTML stuff -->
<xsl:if test="@name">
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@rel">
<xsl:attribute name="rel">
<xsl:value-of select="@rel"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@href">
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@title">
<xsl:attribute name="title">
<xsl:value-of select="@title"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@rev">
<xsl:attribute name="rev">
<xsl:value-of select="@rev"/>
</xsl:attribute>
</xsl:if>
</xsl:template>
<!-- superscript -->
<xsl:template match="n1:sup">
<sup>
<xsl:apply-templates/>
</sup>
</xsl:template>
<!-- subscript -->
<xsl:template match="n1:sub">
<sub>
<xsl:apply-templates/>
</sub>
</xsl:template>
<!-- Contact Information -->
<xsl:template name="getContactInfo">
<xsl:param name="contact"/>
<xsl:apply-templates select="$contact/n1:addr"/>
<xsl:if test="$contact/n1:addr and $contact/n1:telecom">
<br/>
</xsl:if>
<xsl:apply-templates select="$contact/n1:telecom"/>
</xsl:template>
<!-- addr -->
<!--
20090415: (AH) Now handles data type as given in XML, including mixed content,
instead of calling fixed parts in arbitrary order.
-->
<xsl:template match="n1:addr">
<xsl:if test="position() > 1">
<br/>
</xsl:if>
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="name() = 'streetName' or substring-after(name(),':') = 'streetName'">
<xsl:value-of select="."/>
<xsl:if test="../n1:houseNumber">
<xsl:text> </xsl:text>
<xsl:value-of select="../n1:houseNumber"/>
</xsl:if>
<xsl:if test="../n1:additionalLocator">
<xsl:text> </xsl:text>
<xsl:value-of select="../n1:additionalLocator"/>
</xsl:if>
<br/>
</xsl:when>
<xsl:when
test="((name() = 'houseNumber' or substring-after(name(),':') = 'houseNumber') or
(name() = 'additionalLocator' or substring-after(name(),':') = 'additionalLocator')) and
not(../n1:streetName)">
<xsl:value-of select="."/>
<br/>
</xsl:when>
<xsl:when
test="((name() = 'houseNumber' or substring-after(name(),':') = 'houseNumber') or
(name() = 'additionalLocator' or substring-after(name(),':') = 'additionalLocator'))"/>
<xsl:when test="name() = 'city' or substring-after(name(),':') = 'city'">
<xsl:value-of select="."/>
<xsl:if test="../n1:state">
<xsl:text>, </xsl:text>
<xsl:value-of select="../n1:state"/>
<br/>
</xsl:if>
</xsl:when>
<xsl:when test="(name() = 'state' or substring-after(name(),':') = 'state') and not(../n1:city)">
<xsl:value-of select="."/>
<br/>
</xsl:when>
<xsl:when test="name() = 'state' or substring-after(name(),':') = 'state'"/>
<xsl:otherwise>
<xsl:if test="string-length(./text()) > 0">
<xsl:value-of select="."/>
<br/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- telecom -->
<xsl:template match="n1:telecom">
<xsl:variable name="type" select="substring-before(@value, ':')"/>
<xsl:variable name="value" select="substring-after(@value, ':')"/>
<xsl:if test="$type">
<xsl:call-template name="translateCode">
<xsl:with-param name="code" select="$type"/>
</xsl:call-template>
<xsl:text>: </xsl:text>
<xsl:value-of select="$value"/>
<xsl:if test="@use">
<xsl:text> (</xsl:text>
<xsl:call-template name="translateCode">
<xsl:with-param name="code" select="@use"/>
</xsl:call-template>
<xsl:text>)</xsl:text>
</xsl:if>
<br/>
</xsl:if>
</xsl:template>
<!-- Bottomline -->
<!-- 20090415: (AH) Now lists every partipation -->
<xsl:template name="bottomline">
<table width="100%" cellspacing="1" cellpadding="5">
<!-- Consent taken from Swiss stylesheet -->
<xsl:if test="/n1:ClinicalDocument/n1:authorization/n1:consent/n1:code/n1:originalText">
<tr>
<td width="20%" bgcolor="#3399ff" valign="top">
<span style="color:white;font-weight:bold; ">
<xsl:text>Consent:</xsl:text>
</span>
</td>
<td width="80%" bgcolor="#ccccff" valign="top">
<xsl:value-of select="/n1:ClinicalDocument/n1:authorization/n1:consent/n1:code/n1:originalText"/>
</td>
</tr>
<tr>
<td width="20%" bgcolor="#3399ff" valign="top">
<span style="color:white;font-weight:bold; ">
<xsl:text>Custodian organization:</xsl:text>
</span>
</td>
<td width="80%" bgcolor="#ccccff" valign="top">
<xsl:if test="n1:custodian/n1:assignedCustodian/n1:representedCustodianOrganization">
<xsl:call-template name="getName">
<xsl:with-param name="name" select="n1:custodian/n1:assignedCustodian/n1:representedCustodianOrganization/n1:name"/>
</xsl:call-template>
</xsl:if>
</td>
</tr>
<tr>
<td/>
<td width="80%" bgcolor="#ccccff" valign="top">
<xsl:call-template name="getContactInfo">
<xsl:with-param name="contact" select="n1:custodian/n1:assignedCustodian/n1:representedCustodianOrganization"/>
</xsl:call-template>
</td>
</tr>
</xsl:if>
<xsl:for-each select="/n1:ClinicalDocument/n1:author">
<tr>
<td width="20%" bgcolor="#3399ff">
<span style="color:white;font-weight:bold; ">
<xsl:text>Author:</xsl:text>
</span>
</td>
<td width="80%" bgcolor="#ccccff" valign="top">
<xsl:if test="n1:assignedAuthor/n1:representedOrganization/n1:name">
<xsl:call-template name="getName">
<xsl:with-param name="name" select="n1:assignedAuthor/n1:representedOrganization/n1:name"/>
</xsl:call-template>
<br/>
</xsl:if>