<?xml version='1.0' encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sciphox="urn:sciphox"
>

<xsl:output method="html" indent="yes" version="4.01" doctype-public="-//W3C//DTD HTML 4.01//EN"/>

<!-- variable for outlook -->
<xsl:variable name="sciphoxHeadings" select="'#FFCC99'"/>
<xsl:variable name="sciphoxDIAGtableheader" select="'#FF99CC'"/>
<xsl:variable name="sciphoxLABtableheader" select="'#99FF99'"/>
<xsl:variable name="sciphoxMEDtableheader" select="'#CCCCFF'"/>

<!-- variables for SCIPHOX stylesheet -->
	<xsl:variable name="docType" select="/levelone/clinical_document_header/document_type_cd/@DN"/>
	<xsl:variable name="orgName" select="/levelone/clinical_document_header/originating_organization/organization/organization.nm/@V"/>
	<xsl:variable name="title">
		<xsl:value-of select="$orgName"/>
		<xsl:text>
			--
		</xsl:text>
		<xsl:value-of select="$docType"/>
	</xsl:variable>


	<xsl:template match="/levelone">
		<html>
			<head>
				<meta name="Generator" content="SCIPHOX-Stylesheet (kh)"/>
				<xsl:comment>
					do NOT edit this HTML directly, it was generated via an XSLT transformation from the original Level 1 document.
				</xsl:comment>
				<STYLE TYPE="text/css">
					<xsl:text>
						TD { font: arial }
					</xsl:text>
				</STYLE>
				<title>
					<xsl:value-of select="$title"/>
				</title>
			</head>
			<body>
				<H2>
					<xsl:value-of select="$title"/>
				</H2>
				<br/>
				<xsl:apply-templates select="clinical_document_header"/>
				<br/>
				<HR/>
				<xsl:apply-templates select="body"/>
				<xsl:call-template name="signature"/>
			</body>
		</html>
	</xsl:template>
	<!--
     generate a table at the top of the document containing
	 encounter and patient information.  Encounter info is
	 rendered in the left column(s) and patient info is
	 rendered in the right column(s).
	 
	 This assumes several things about the source document which
	 won't be true in the general case:
	 
	 	1. there is only 1 of everything (i.e., physcian, patient, etc.)
		2. I haven't bothered to map all HL7 table values
		   (e.g., actor.type_cd and administrative_gender_cd)
		   and have only those that are used in the sample document
		
		I tried to do the table formting with CSS2 rules, but Netscape
		doesn't seem to handle the table rules well (or at all:-( so I
		just gave up
  -->
	<xsl:template match="clinical_document_header">
		<TABLE BORDER="0" CELLPADDING="3" WIDTH="100%">
			<TR>
              <TD COLSPAN="2">
              <xsl:attribute name="bgcolor">
                <xsl:value-of select="$sciphoxHeadings"/>
              </xsl:attribute>
			  Ereignis:</TD>
			</TR>
			<xsl:call-template name="encounter"/>
			<TR>
              <TD COLSPAN="2">
              <xsl:attribute name="bgcolor">
                <xsl:value-of select="$sciphoxHeadings"/>
              </xsl:attribute>
			  Patient:</TD>
			</TR>

			<xsl:call-template name="patient"/>
			<TR>
              <TD COLSPAN="2">
              <xsl:attribute name="bgcolor">
                <xsl:value-of select="$sciphoxHeadings"/>
              </xsl:attribute>
			  Empfänger:</TD>
			</TR>
			<xsl:call-template name="intended_recipient"/>
		</TABLE>
	</xsl:template>
	<xsl:template name="encounter">
		<tr>
			<xsl:apply-templates select="provider"/>
		</tr>
		<tr>
			<xsl:apply-templates select="patient_encounter/encounter_tmr"/>
		</tr>
	</xsl:template>
	<xsl:template match="encounter_tmr">
		<TR>
			<TD>Datum:</TD>
			<TD ALIGN="LEFT">
				<xsl:call-template name="toDate">
					<xsl:with-param name="date" select="@V"/>
				</xsl:call-template>
			</TD>
		</TR>
	</xsl:template>
	<xsl:template match="provider">
		<th align="left" width="20%">
			<xsl:call-template name="provider_type_cd">
				<xsl:with-param name="type_cd" select="provider.type_cd/@V"/>
			</xsl:call-template>
			<xsl:text>:</xsl:text>
		</th>
		<td align="left" width="20%">
			<xsl:variable name="ptr" select="person/id/@EX"/>
			<xsl:for-each select="/levelone/clinical_document_header/originator/person[id/@EX=$ptr]">
				<xsl:call-template name="getName"/>
			</xsl:for-each>
			<xsl:for-each select="/levelone/clinical_document_header/provider/person">
				<xsl:call-template name="getName"/>
			</xsl:for-each>
		</td>
	</xsl:template>
	<xsl:template name="intended_recipient">
		<td align="left" width="20%"/>
		<td>
			<xsl:for-each select="/levelone/clinical_document_header/intended_recipient/person">
				<B>
					<xsl:call-template name="getName"/>
				</B>
				<xsl:text>
					--
				</xsl:text>
				<xsl:call-template name="getAddr"/>
				<BR/>
			</xsl:for-each>
		</td>
	</xsl:template>
	<xsl:template name="patient">
		<tr>
			<xsl:apply-templates select="patient"/>
		</tr>
		<tr>
			<xsl:apply-templates select="patient/birth_dttm"/>
		</tr>
		<tr>
			<td>
				Adresse:
			</td>
			<td>
				<xsl:apply-templates select="patient/person/addr"/>
			</td>
		</tr>
		<tr>
			<xsl:apply-templates select="patient/person/telecom"/>
		</tr>
	</xsl:template>
	<xsl:template match="birth_dttm">
		<TR>
			<TD>
				Geburtsdatum:
			</TD>
			<TD ALIGN="LEFT">
				<xsl:call-template name="toDate">
					<xsl:with-param name="date" select="@V"/>
				</xsl:call-template>
			</TD>
		</TR>
	</xsl:template>
	<xsl:template match="patient">
		<TR>
			<TD>
				Name
			</TD>
			<TD>
				<B>
					<xsl:for-each select="person">
						<xsl:call-template name="getName"/>
					</xsl:for-each>
				</B>
			</TD>
		</TR>
		<TR>
			<TD>
				ID:
			</TD>
			<TD ALIGN="LEFT">
				<xsl:value-of select="person/id/@EX"/>
			</TD>
		</TR>
		<TR>
			<TD>
				Geschlecht:
			</TD>
			<TD ALIGN="LEFT">
				<xsl:call-template name="administrative_gender_cd">
					<xsl:with-param name="gender_cd" select="administrative_gender_cd/@V"/>
				</xsl:call-template>
			</TD>
		</TR>
	</xsl:template>
	<!--
    just apply the default template for these
  -->
	<xsl:template match="body|caption|content">
		<xsl:apply-templates/>
	</xsl:template>
	<!--
    spit out the caption (in the 'caption' style)
	followed by applying whatever templates we
	have for the applicable children
  -->
	<xsl:template match="section">
		<div>
			<B>
				<xsl:apply-templates select="caption"/>
			</B>
			<xsl:apply-templates select="paragraph|list|table|section|local_markup"/>
		</div>
	</xsl:template>
	<xsl:template match="section/section">
		<ul>
			<li>
				<span class="caption">
					<xsl:apply-templates select="caption"/>
					<xsl:text>
						::
					</xsl:text>
				</span>
				<xsl:apply-templates select="paragraph|list|table|section"/>
			</li>
		</ul>
	</xsl:template>
	<!--
    currently ignores paragraph captions...
	
	I need samples of the use description and render
	to know what really should be done with them
  -->
	<xsl:template match="paragraph">
		<p>
			<xsl:apply-templates select="content"/>
		</p>
	</xsl:template>
	<!--
    currently ignore caption's on the list itself,
	but handles them on the list items
  -->
	<xsl:template match="list">
		<ul>
			<xsl:for-each select="item">
				<li>
					<xsl:if test="caption">
						<xsl:apply-templates select="caption"/>
						<xsl:text>
							::
						</xsl:text>
					</xsl:if>
					<xsl:apply-templates select="content"/>
				</li>
			</xsl:for-each>
		</ul>
	</xsl:template>
	<!--
    currently ignore caption's on the list itself,
	but handles them on the list items
  -->
	<xsl:template match="section/section/list">
		<xsl:for-each select="item">
			<xsl:apply-templates select="content"/>
			<xsl:if test="position()!=last()">
				<xsl:text>
					;
				</xsl:text>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="section/section/paragraph">
		<span>
			<xsl:apply-templates/>
		</span>
	</xsl:template>
	<!-- 
     Tables
	 
     just copy over the entire subtree, as is
	 except that the children of CAPTION are possibly handled by
	 other templates in this stylesheet
  -->
	<xsl:template match="table|table/caption|thead|tfoot|tbody|colgroup|col|tr|th|td">
		<xsl:copy>
			<xsl:apply-templates select="*|@*|text()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="table/@*|thead/@*|tfoot/@*|tbody/@*|colgroup/@*|col/@*|tr/@*|th/@*|td/@*">
		<xsl:copy>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	<!--
     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
  -->
	<xsl:template match="observation_media">
		<xsl:if test='observation_media.value[
			@MT="image/gif" or @MT="image/jpeg"
			]'>
			<br clear="all"/>
			<xsl:element name="img">
				<xsl:attribute name="src">
					<xsl:value-of select="observation_media.value/REF/@V"/>
				</xsl:attribute>
			</xsl:element>
		</xsl:if>
	</xsl:template>
	<!--
	turn the link_html subelement into an HTML a element,
	complete with any attributes and content it may have,
	while stripping off any CDA specific attributes
  -->
	<xsl:template match="link">
		<xsl:element name="a">
			<xsl:for-each select="link_html/@*">
				<xsl:if test='not(name()="originator" or name()="confidentiality")'>
					<xsl:attribute name="{name()}">
						<xsl:value-of select="."/>
					</xsl:attribute>
				</xsl:if>
			</xsl:for-each>
			<xsl:value-of select="link_html"/>
		</xsl:element>
	</xsl:template>

<!--
    this doesn't do anything with the description
	or render attributes...it simply decides whether
	to remove the entire subtree or just pass the
	content thru
	
	I need samples of the use description and render
	to know what really should be done with them
 -->
	<xsl:template match="local_markup">
		<xsl:choose>
			<xsl:when test='@ignore="markup"'>
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:when test='@descriptor="sciphox"'>
			  <xsl:apply-templates select="sciphox-ssu/*"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="@ignore">
		<xsl:choose>
			<xsl:when test='.="markup"'>
				<xsl:apply-templates select="../text()"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
<!--
    SCIPHOX specific definitions ***************************
-->

<xsl:template match="sciphox-ssu/Diagnosen">
  <xsl:choose>
    <xsl:when test='//sciphox-ssu[@version="v1"]'>
      <table border="0" cellpadding="5" cellspacing="1" width="100%">
        <tr>
          <xsl:attribute name="bgcolor">
            <xsl:value-of select="$sciphoxDIAGtableheader"/>
          </xsl:attribute>
          <td><B>Diagnose</B></td>
          <td><B>Code</B></td>
          <td><B>Codesystem</B></td>
          <td><B>Lok./Zusatz</B></td>
          <td><B>Datum</B></td>
    	</tr>
      <xsl:for-each select="./Diagnose">
        <tr>
          <xsl:if test="position() mod 2 = 0">
            <xsl:attribute name="bgcolor">#CCCCCC</xsl:attribute>
          </xsl:if>
          <xsl:if test="position() mod 2 = 1">
            <xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
          </xsl:if>
 	      <td><xsl:value-of select='./Text/@value'/></td>
          <td><xsl:value-of select='./Code/@value'/></td>
	      <td>
		    <xsl:call-template name="OID2Name">
			  <xsl:with-param name="oid" select="./Codesystem/@value"/>
			</xsl:call-template>
	      </td>
	      <td><xsl:value-of select='./Lokalisation/@value'/>
	    	 <xsl:text> </xsl:text>
	    	 <xsl:value-of select='./Zusatz/@value'/>
	      </td>
	      <td>
		    <xsl:call-template name="toDate2">
			  <xsl:with-param name="date" select="./Datum/@value"/>
			</xsl:call-template>
	      </td>
        </tr>
      </xsl:for-each>
      </table><P></P>
    </xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match="sciphox-ssu/Laborwerte">
  <xsl:choose>
    <xsl:when test='//sciphox-ssu[@version="v1"]'>
      <table border="0" cellpadding="5" cellspacing="1" width="100%">
        <tr>
          <xsl:attribute name="bgcolor">
            <xsl:value-of select="$sciphoxLABtableheader"/>
          </xsl:attribute>
          <td><B>Parameter</B></td>
          <td><B>Ergebnis</B></td>
          <td><B>Normbereich</B></td>
          <td><B>Datum</B></td>
          <td><B>Status</B></td>
    	</tr>
      <xsl:for-each select="./Laborwert">
        <tr>
          <xsl:if test="position() mod 2 = 0">
            <xsl:attribute name="bgcolor">#CCCCCC</xsl:attribute>
          </xsl:if>
          <xsl:if test="position() mod 2 = 1">
            <xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
          </xsl:if>
 	      <td><xsl:value-of select='./Parameter/@value'/></td>
          <td>
            <xsl:value-of select='./Ergebniswert/@value'/>
            <xsl:text> </xsl:text>
	        <xsl:value-of select='./Einheit/@value'/>
            <xsl:text> </xsl:text>
	        <xsl:value-of select='./Ergebnistext/@value'/>
	      </td>
          <td>
            <xsl:if test="./NormbereichUntergrenze/@value != ''">
              <xsl:value-of select='./NormbereichUntergrenze/@value'/>
              <xsl:text> - </xsl:text>
	          <xsl:value-of select='./NormbereichObergrenze/@value'/>
              <xsl:text> </xsl:text>
            </xsl:if>
	        <xsl:value-of select='./NormbereichText/@value'/>
	      </td>
	      <td>
		    <xsl:call-template name="toDate2">
			  <xsl:with-param name="date" select="./Datum/@value"/>
			</xsl:call-template>
	      </td>
	      <td>
		    <xsl:call-template name="LabStatus">
			  <xsl:with-param name="status" select="./Status/@value"/>
			</xsl:call-template>
	      </td>
        </tr>
      </xsl:for-each>
      </table><P></P>
    </xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match="sciphox-ssu/Medikationen">
  <xsl:choose>
    <xsl:when test='//sciphox-ssu[@version="v1"]'>
      <table border="0" cellpadding="5" cellspacing="1" width="100%">
        <tr>
          <xsl:attribute name="bgcolor">
            <xsl:value-of select="$sciphoxMEDtableheader"/>
          </xsl:attribute>
          <td><B>Handelsname</B></td>
          <td><B>PZN</B></td>
          <td><B>Dosis</B></td>
          <td><B>Verabreichung</B></td>
          <td><B>Status</B></td>
          <td><B>Dauer</B></td>
          <td><B>Datum</B></td>
    	</tr>
      <xsl:for-each select="./Medikation">
        <tr>
          <xsl:if test="position() mod 2 = 0">
            <xsl:attribute name="bgcolor">#CCCCCC</xsl:attribute>
          </xsl:if>
          <xsl:if test="position() mod 2 = 1">
            <xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
          </xsl:if>
		  <td><xsl:value-of select='./Bezeichnung/Handelsname/@value'/></td>
		  <td><xsl:value-of select='./Bezeichnung/PZN/@value'/></td>
		  <td><xsl:value-of select='./Dosierung/Dosis/@value'/></td>
		  <td><xsl:value-of select='./Dosierung/Verabreichung/@value'/></td>
	      <td>
		    <xsl:call-template name="MedStatus">
			  <xsl:with-param name="status" select="./Status/@value"/>
			</xsl:call-template>
	      </td>
		  <td><xsl:value-of select='./Dosierung/Einnahmedauer/@value'/></td>
	      <td>
		    <xsl:call-template name="toDate2">
			  <xsl:with-param name="date" select="./Datum/@value"/>
			</xsl:call-template>
	      </td>
        </tr>
      </xsl:for-each>
      </table><P></P>
    </xsl:when>
  </xsl:choose>
</xsl:template>



<!--
     elements to ignore
-->
	<xsl:template match="coded_entry">
				<i>
					<xsl:text>[</xsl:text>
   		            <xsl:call-template name="OID2Name">
			          <xsl:with-param name="oid" select="coded_entry.value/@S"/>
			        </xsl:call-template>
					<xsl:text> </xsl:text>
					<xsl:value-of select="coded_entry.value/@V"/>
					<xsl:text>]</xsl:text>
				</i>
	</xsl:template>
	<xsl:template match="caption_cd"/>
	<!--
     template(s) to output signature block

     Assumes there is only one signer at this time
  -->
	<xsl:template name="signature">
		<xsl:variable name="signers" select="/levelone/clinical_document_header/legal_authenticator/person"/>
		<xsl:if test="$signers">
			<div>
				<HR/>
				<span class="caption">
					Unterzeichnet durch:
				</span>
				<ul>
					<xsl:for-each select="$signers">
						<li>
							<xsl:call-template name="getName">
								<xsl:with-param name="person" select="."/>
							</xsl:call-template>
							<xsl:text>
								am
							</xsl:text>
							<xsl:call-template name="toDate">
								<xsl:with-param name="date" select="../participation_tmr/@V"/>
							</xsl:call-template>
						</li>
					</xsl:for-each>
				</ul>
			</div>
		</xsl:if>
	</xsl:template>
	<!--
     general purpose (named) templates used in multiple places
  -->
	<!--
     assumes current node is a <person_name> node

     Does not handle nearly all of the complexity of the person datatype,
	 but is illustritive of what would be required to do so in the future
  -->
	<xsl:template name="getName">
		<xsl:apply-templates select='person_name[person_name.type_cd/@V="L"]'/>
	</xsl:template>
	<xsl:template match="person_name">
		<xsl:choose>
			<xsl:when test='nm/PFX[@QUAL="RE"]/@V'>
				<xsl:text> </xsl:text>
				<xsl:value-of select='nm/PFX[@QUAL="AC"]/@V'/>
				<xsl:text> </xsl:text>
			</xsl:when>
			<xsl:when test="nm/PFX/@V">
				<xsl:text> </xsl:text>
				<xsl:value-of select="nm/PFX/@V"/>
				<xsl:text> </xsl:text>
			</xsl:when>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test='nm/GIV[@QUAL="RE"]/@V'>
				<xsl:value-of select='nm/GIV[@QUAL="RE"]/@V'/>
			</xsl:when>
			<xsl:when test='nm/GIV[@CLAS="N"]/@V'>
				<xsl:value-of select='nm/GIV[@CLAS="N"]/@V'/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="nm/GIV/@V"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:text> </xsl:text>
		<xsl:choose>
			<xsl:when test='nm/FAM[@QUAL="RE"]/@V'>
				<xsl:value-of select='nm/FAM[@QUAL="RE"]/@V'/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="nm/FAM/@V"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test='nm/SFX[@QUAL="RE"]/@V'>
				<xsl:text>
					,
				</xsl:text>
				<xsl:value-of select='nm/SFX[@QUAL="RE"]/@V'/>
			</xsl:when>
			<xsl:when test="nm/SFX/@V">
				<xsl:text>
					,
				</xsl:text>
				<xsl:value-of select="nm/SFX/@V"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
<!-- convert "YYYY-MM-DD" to "DD. Monat YYYY" -->
<xsl:template name="toDate">
		<xsl:param name="date"/>
		<xsl:variable name="month" select="'Januar    Februar   März      April     Mai       Juni      Juli      August    September Oktober   November  Dezember  '"/>
		<xsl:value-of select="substring($date, 9, 2)"/>
		<xsl:text>
			.
		</xsl:text>
		<xsl:value-of select="normalize-space(substring($month, (substring($date, 6, 2) - 1) * 10, 10))"/>
		<xsl:text> </xsl:text>
		<xsl:value-of select="substring($date, 1, 4)"/>
	</xsl:template>
<!-- convert "YYYY-MM-DD" to "DD.MM.YYYY" -->
<xsl:template name="toDate2">
	<xsl:param name="date"/>
	<xsl:value-of select="substring($date,9,2)"/><xsl:text>.</xsl:text>
	<xsl:value-of select="substring($date,6,2)"/><xsl:text>.</xsl:text>
	<xsl:value-of select="substring($date,1,4)"/>
</xsl:template>

<!-- table lookup functions SCIPHOX -->
<xsl:template name="OID2Name">
	<xsl:param name="oid"/>
		<xsl:choose>
			<xsl:when test='$oid="2.16.840.1.113883.6.1"'>LOINC</xsl:when>
			<xsl:when test='$oid="2.16.840.1.113883.6.2"'>ICD 9</xsl:when>
			<xsl:when test='$oid="2.16.840.1.113883.6.3"'>ICD 10</xsl:when>
			<xsl:when test='$oid="ICD10-OID"'>ICD 10</xsl:when>
			<xsl:when test='$oid="2.16.840.1.113883.6.4"'>ICPM</xsl:when>
			<xsl:when test='$oid="PZN-OID"'>PZN</xsl:when>
	    </xsl:choose>
</xsl:template>
<xsl:template name="LabStatus">
	<xsl:param name="status"/>
		<xsl:choose>
			<xsl:when test='$status="E"'>endgültig</xsl:when>
	    </xsl:choose>
</xsl:template>
<xsl:template name="MedStatus">
	<xsl:param name="status"/>
		<xsl:choose>
			<xsl:when test='$status="V"'>verabreicht</xsl:when>
			<xsl:when test='$status="E"'>empfohlen</xsl:when>
	    </xsl:choose>
</xsl:template>

<!--
     table lookups
-->
	<xsl:template name="provider_type_cd">
		<xsl:param name="type_cd"/>
		<xsl:choose>
			<xsl:when test='$type_cd="CON"'>
				<xsl:text>
					Behandelnder Arzt
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="PRISURG"'>
				<xsl:text>
					Primary surgeon
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="FASST"'>
				<xsl:text>
					First assistant
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="SASST"'>
				<xsl:text>
					Second assistant
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="SNRS"'>
				<xsl:text>
					Scrub nurse
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="TASST"'>
				<xsl:text>
					Third assistant
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="NASST"'>
				<xsl:text>
					Nurse assistant
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="ANEST"'>
				<xsl:text>
					Anesthetist
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="ANRS"'>
				<xsl:text>
					Anesthesia nurse
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="MDWF"'>
				<xsl:text>
					Midwife
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="ATTPHYS"'>
				<xsl:text>
					Attending physician
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="ADMPHYS"'>
				<xsl:text>
					Admitting physician
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="DISPHYS"'>
				<xsl:text>
					Discharging physician
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="RNDPHYS"'>
				<xsl:text>
					Rounding physician
				</xsl:text>
			</xsl:when>
			<xsl:when test='$type_cd="PCP"'>
				<xsl:text>
					Primary care provider
				</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$type_cd"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="administrative_gender_cd">
		<xsl:param name="gender_cd"/>
		<xsl:choose>
			<xsl:when test='$gender_cd="M"'>
				<xsl:text>
					männlich
				</xsl:text>
			</xsl:when>
			<xsl:when test='$gender_cd="F"'>
				<xsl:text>
					weiblich
				</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$gender_cd"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="telecom">
		<xsl:choose>
			<xsl:when test="starts-with(@V, 'tel:')">
				<TD>
					Tel:
				</TD>
				<TD ALIGN="LEFT">
					<xsl:value-of select="substring(@V, 5)"/>
				</TD>
			</xsl:when>
			<xsl:when test="starts-with(@V, 'fax:')">
				<TD>
					Fax:
				</TD>
				<TD ALIGN="LEFT">
					<xsl:value-of select="substring(@V, 5)"/>
				</TD>
			</xsl:when>
			<xsl:when test="starts-with(@V, 'mailto:')">
				<TD>
					Email:
				</TD>
				<TD ALIGN="LEFT">
					<xsl:value-of select="substring(@V, 5)"/>
				</TD>
			</xsl:when>
			<xsl:when test="starts-with(@V, 'http:')">
				<TD>
					Web:
				</TD>
				<TD ALIGN="LEFT">
					<xsl:value-of select="substring(@V, 5)"/>
				</TD>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="getAddr">
		<xsl:apply-templates select="./addr"/>
	</xsl:template>
	<xsl:template match="addr">
		<xsl:value-of select="STR/@V"/>
		<xsl:text> </xsl:text>
		<xsl:value-of select="HNR/@V"/>
		<xsl:text>
			,
		</xsl:text>
		<xsl:value-of select="ZIP/@V"/>
		<xsl:text> </xsl:text>
		<xsl:value-of select="CTY/@V"/>
	</xsl:template>
</xsl:stylesheet>

