<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:n1="urn:hl7-org:v3"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:n2="urn:hl7-org:v3/meta/voc"
    xmlns:voc="urn:hl7-org:v3/voc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:fias="urn:hl7-ru:fias"
	xmlns:medService="urn:hl7-ru:medService"
    xmlns:identity="urn:hl7-ru:identity"
    xmlns:address="urn:hl7-ru:address"
	xmlns:PII="urn:hl7-ru:PII">
    <xsl:output method="html" indent="yes" encoding="utf-8"/>
    <xsl:template match="/">
        <xsl:apply-templates select="n1:ClinicalDocument"/>
    </xsl:template>
    <xsl:template match="n1:ClinicalDocument">
	    <html>
		<!-- Файл для трансформации XML->HTML->PDF при помощи библиотек iText Core, iText XMLWorker или аналогичных
             Данный файл должен использоваться только для трансформации документа СЭМД (92) Эпикриз по законченному случаю амбулаторный (CDA) Редакция 4, v1.2
	         Разработан по заказу Минздрава РФ компанией ООО "Цифромед" 17.04.2024
	         Замечания по данному файлу можно направить на почту egisz@stp-egisz.ru
			 Тема сообщения: замечания и вопросы по файлам визуализации -->
            <head>
                <style>
                    @page {
                        size: A4 portrait;
					    margin-top: 20pt;
					    margin-bottom: 156pt;
					    margin-left: 10pt;
					    margin-right: 20pt;
                    }

                    table {
                        table-layout: fixed;
                        width: 98%;
                        border-collapse: collapse;

                        font-family: Arial, sans-serif;
                        word-wrap: break-word;
					    margin-top: 0;
                        margin-bottom: 10pt;
					    margin-left: 20pt;
                    }

                    td {
					    vertical-align: top;
					    padding: 2;
                    }

					.table-break {
					    margin-left: 0;
						border-collapse: collapse;
					}

					.param {
					    font-size: 15px;
					    border: 1pt solid gray;

						word-wrap: none;
					}

					.paramuslugi {
					    font-size: 14px;
					    border: 1pt solid gray;

						word-wrap: none;
					}

					.paramless {
					    font-size: 15px;
					    border: 1pt solid gray;
						background-color: #D9D9D6;

						word-wrap: none;
					}

					.created {
					    vertical-align: middle;
					}

                    .medorg {
                        text-align: left;
                        font-size: 15px;
                        font-weight: 400;
                        color: #000000;
                        margin-top: 5pt;
                        margin-bottom: 5pt;
                        white-space: normal;
                    }

                    .address {
                        text-align: left;
                        font-size: 15px;
                        font-weight: 100;
                        color: #000000;
                        margin-top: 5pt;
                        margin-bottom: 5pt;
                        white-space: normal;
                    }

                    .emd {
                        text-align: center;
                        font-size: 18px;
                        font-weight: 400;
                        color: #000000;
                        margin-top: 25pt;
                        margin-bottom: 25pt;
                        white-space: normal;
                    }

                    .date {
                        text-align: center;
                        font-size: 15px;
                        font-weight: 400;
                        color: #000000;
                        margin-top: 5pt;
                        margin-bottom: 5pt;
                        white-space: normal;
                    }

					.tablegray {
                        text-align: left;
                        font-size: 15px;
                        font-weight: 100;
                        color: #aaaaaa;
                        margin-top: 5pt;
                        margin-bottom: 5pt;
                    }

					.tablegrayhead {
                        text-align: left;
                        font-size: 15px;
                        font-weight: bold;
                        color: #aaaaaa;
						margin-top: 5pt;
                        margin-bottom: 5pt;
                    }

					.tableblack {
                        text-align: left;
                        font-size: 15px;
                        font-weight: 100;
                        color: #000000;
                        margin-top: 0;
                        margin-bottom: 3pt;
                        white-space: normal;
                    }

					.tableresult {
						text-align: left;
                        font-size: 15px;
                        font-weight: 100;
                        color: #000000;
                        margin-top: 2pt;
						margin-bottom: 2pt;
                        white-space: normal;
					}

					.tableresultuslugi {
						text-align: left;
                        font-size: 14px;
                        font-weight: 100;
                        color: #000000;
                        margin-top: 2pt;
						margin-bottom: 2pt;
                        white-space: normal;
					}

					.tableresultscore {
						text-align: left;
                        font-size: 15px;
                        font-weight: bold;
                        color: #000000;
                        margin-top: 0;
						margin-bottom: 5pt;
                        white-space: normal;
					}

					.createdate {
                        text-align: right;
                        font-size: 15px;
                        font-weight: 100;
                        color: #aaaaaa;
					    margin-right: 10pt;
                    }

					.pagenumber {
                        text-align: center;
					    valign: center;
                        font-size: 15px;
                        font-weight: 100;
                        color: #aaaaaa;
					    margin-right: 10pt;
                    }

					h2+p {
                        page-break-inside: avoid;
                    }

					th {
					    text-align: left;
					    font-size: 15px;
						padding: 5pt;
						background-color: #D9D9D6;
					}

					.first-block-form {
					    margin-top: -10pt;
					}

					.block-form {
					    border-collapse: collapse;
						margin-top: 0;
						margin-bottom: 0;
					    border-bottom: 1pt solid #e0e0e0;
					}

					.end-block-form {
					}
                </style>
            </head>
			<body>
			        <table class="first-block-form">
					    <tr>
                            <td colspan="8">
                                <p class="medorg">
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization[not(@nullFlavor)]">
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:name"/>
                                        </xsl:when>
                                    </xsl:choose>
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:addr[not(@nullFlavor)]">
										    <br/><xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:addr/n1:postalCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:addr/n1:postalCode"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:addr/address:stateCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:addr/address:stateCode/@displayName"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:addr/n1:streetAddressLine"/>
                                        </xsl:when>
                                    </xsl:choose>
									<xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props[not(@nullFlavor)]">
									        <br/>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Ogrn[not(@nullFlavor)]">
									            	<xsl:text>ОГРН: </xsl:text>
									            	<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Ogrn"/>
									        		<xsl:text>; </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
								            <xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Ogrnip[not(@nullFlavor)]">
								            		<xsl:text>ОГРНИП: </xsl:text>
								            		<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Ogrnip"/>
									        		<xsl:text>; </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
									        <xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Okpo[not(@nullFlavor)]">
								            		<xsl:text>ОКПО: </xsl:text>
								            		<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Okpo"/>
									        		<xsl:text>; </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
								            <xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Okato[not(@nullFlavor)]">
								            		<xsl:text>ОКАТО: </xsl:text>
								            		<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/identity:Props/identity:Okato"/>
									        		<xsl:text>; </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
										</xsl:when>
                                    </xsl:choose>
								    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:id[2][not(@nullFlavor)]">
								    		<br/><xsl:text>Лицензия на осуществление медицинской деятельности: </xsl:text>
								    		<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:id[2]/@extension"/>
								    		<xsl:text> </xsl:text>
								    		<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:id[2]/@assigningAuthorityName"/>
                                        </xsl:when>
                                    </xsl:choose>
								    <br/><xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:telecom[not(@nullFlavor)]">
								    		<xsl:for-each select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:providerOrganization/n1:telecom">
								    		    <xsl:call-template name="formatContact">
                                                    <xsl:with-param name="contact" select="./@value"/>
                                                </xsl:call-template>
												<xsl:text> </xsl:text>
								    		</xsl:for-each>
                                        </xsl:when>
                                    </xsl:choose>
                                </p>
						    </td>
                        </tr>
						<xsl:choose>
                            <xsl:when test="/n1:ClinicalDocument/n1:informationRecipient[position()>1]/n1:intendedRecipient/n1:receivedOrganization/n1:name">
						        <tr>
                                    <td colspan="8">
									    <xsl:for-each select="/n1:ClinicalDocument/n1:informationRecipient[position()>1]">
                                            <p class="tableblack">
						        		        <xsl:text>Для предоставления в: </xsl:text>
										    	<xsl:value-of select="./n1:intendedRecipient/n1:receivedOrganization/n1:name"/>
                                            </p>
										</xsl:for-each>
                                    </td>
					            </tr>
						    </xsl:when>
                        </xsl:choose>
					</table>
					<table class="block-form">
				        <tr>
                            <td colspan="8">
                                <h1 class="emd">
                                    <b>
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:title[not(@nullFlavor)]">
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:title"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:text>[Название вида медицинского документа]</xsl:text>
                                        </xsl:otherwise>
                                     </xsl:choose>
                                    </b>
                                </h1>
                             </td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                <h2 class="tablegray">
                                    <xsl:text>Пациент</xsl:text>
                                </h2>
						    	<p class="tableblack">
								    <xsl:text>ФИО: </xsl:text>
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:name[not(@nullFlavor)]">
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:name"/>
                                        </xsl:when>
										<xsl:otherwise>
										    <xsl:call-template name="formatNullFlavor">
                                                <xsl:with-param name="nullflavor" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:name/@nullFlavor"/>
                                            </xsl:call-template>
										</xsl:otherwise>
                                    </xsl:choose>
                                </p>
								<p class="tableblack">
								    <xsl:text>Дата рождения: </xsl:text>
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:birthTime[not(@nullFlavor)]">
                                            <xsl:call-template name="formatDate">
                                                <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:birthTime/@value"/>
                                            </xsl:call-template>
											<xsl:text> </xsl:text>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:effectiveTime[not(@nullFlavor)]">
                                                    <xsl:text> (</xsl:text>
					    					        <xsl:call-template name="getAge">
                                                        <xsl:with-param name="birthdate" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:birthTime/@value"/>
					    					            <xsl:with-param name="deathdate" select="/n1:ClinicalDocument/n1:effectiveTime/@value"/>
					    					            <xsl:with-param name="withtext" select="1"/>
                                                    </xsl:call-template>
					    					        <xsl:text>)</xsl:text>
												</xsl:when>
											</xsl:choose>
					    				</xsl:when>
                                    </xsl:choose>
                                </p>
								<p class="tableblack">
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:administrativeGenderCode[not(@nullFlavor)]">
										    <xsl:text>Пол: </xsl:text>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:administrativeGenderCode/@displayName"/>
                                        </xsl:when>
										<xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:administrativeGenderCode/@nullFlavor">
											<xsl:text>Пол: </xsl:text>
											<xsl:call-template name="formatNullFlavor">
                                                <xsl:with-param name="nullflavor" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:administrativeGenderCode/@nullFlavor"/>
                                            </xsl:call-template>
										</xsl:when>
                                    </xsl:choose>
                                </p>
                            </td>
                            <td colspan="4">
							    <h2 class="tablegray">
								    <xsl:text>&#160;</xsl:text>
                                </h2>
						    	<p class="tableblack">
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:InsurancePolicy[not(@nullFlavor)]">
										    <xsl:text>Полис ОМС: </xsl:text>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:InsurancePolicy/identity:Series"/>
											<xsl:text> </xsl:text>
						    				<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:InsurancePolicy/identity:Number"/>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:participant/n1:associatedEntity/n1:scopingOrganization/n1:name[not(@nullFlavor)]">
									        	    <xsl:text> (</xsl:text>
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:participant/n1:associatedEntity/n1:scopingOrganization/n1:name"/>
													<xsl:text>)</xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
                                        </xsl:when>
                                    </xsl:choose>
                                </p>
								<p class="tableblack">
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:id[2]/@extension[not(@nullFlavor)]">
										    <xsl:text>СНИЛС: </xsl:text>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:id[2]/@extension"/>
                                        </xsl:when>
                                    </xsl:choose>
                                </p>
								<xsl:choose>
                                    <xsl:when test="/n1:ClinicalDocument/n1:componentOf/n1:encompassingEncounter/n1:id[2]/@extension[not(@nullFlavor)]">
					                    <p class="tableblack">
							                <xsl:call-template name="formatMedCard">
                                                <xsl:with-param name="medcard" select="/n1:ClinicalDocument/n1:componentOf/n1:encompassingEncounter/n1:code/@code"/>
                                            </xsl:call-template>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:componentOf/n1:encompassingEncounter/n1:id[2]/@extension"/>
                                        </p>
						            </xsl:when>
                                </xsl:choose>
                            </td>
                        </tr>
						<xsl:choose>
                            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='1']/n1:streetAddressLine">
						        <tr>
                                    <td colspan="8">
                                        <p class="tableblack">
						        		    <xsl:text>Адрес по месту жительства (постоянной регистрации): </xsl:text>
                                            <xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='1']/n1:postalCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='1']/n1:postalCode"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='1']/address:stateCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='1']/address:stateCode/@displayName"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
											<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='1']/n1:streetAddressLine"/>
                                        </p>
                                    </td>
					            </tr>
						    </xsl:when>
                        </xsl:choose>
						<xsl:choose>
                            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='2']/n1:streetAddressLine">
						        <tr>
                                    <td colspan="8">
                                        <p class="tableblack">
						        		    <xsl:text>Адрес по месту пребывания (временной регистрации): </xsl:text>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='2']/n1:postalCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='2']/n1:postalCode"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='2']/address:stateCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='2']/address:stateCode/@displayName"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='2']/n1:streetAddressLine"/>
                                        </p>
                                    </td>
					            </tr>
						    </xsl:when>
                        </xsl:choose>
						<xsl:choose>
                            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='3']/n1:streetAddressLine">
						        <tr>
                                    <td colspan="8">
                                        <p class="tableblack">
						        		    <xsl:text>Адрес фактического проживания (пребывания): </xsl:text>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='3']/n1:postalCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='3']/n1:postalCode"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
											<xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='3']/address:stateCode[not(@nullFlavor)]">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='3']/address:stateCode/@displayName"/>
													<xsl:text>, </xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:addr[address:Type/@code='3']/n1:streetAddressLine"/>
                                        </p>
                                    </td>
					            </tr>
						    </xsl:when>
                        </xsl:choose>
						<xsl:choose>
					    	<xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc[not(@nullFlavor)]">
					            <tr>
                                    <td colspan="8">
                                        <p class="tableblack">
						        		    <xsl:text>Документ, удостоверяющий личность: </xsl:text>
											<xsl:choose>
					    	                    <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc[not(@nullFlavor)]">
					            			        <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:IdentityCardType/@displayName"/>
											        <xsl:text> </xsl:text>
					            			        <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:Series[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:Series"/>
											        		<xsl:text> </xsl:text>
					            			            </xsl:when>
					            			        </xsl:choose>
					            			        <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:Number"/>
											        <xsl:text> </xsl:text>
					            			        <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:IssueOrgName[not(@nullFlavor)]">
					            			            	<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:IssueOrgName"/><xsl:text> </xsl:text>
					            			            </xsl:when>
					            			        </xsl:choose>
					            			        <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:IssueOrgCode[not(@nullFlavor)]">
					            			            	<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:IssueOrgCode"/>
											        		<xsl:text> </xsl:text>
					            			            </xsl:when>
					            			        </xsl:choose>
					            			        <xsl:text>Дата выдачи: </xsl:text>
					            			        <xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/identity:IdentityDoc/identity:IssueDate/@value"/>
                                                    </xsl:call-template>
												</xsl:when>
					            			</xsl:choose>
                                        </p>
                                    </td>
					            </tr>
							</xsl:when>
						</xsl:choose>
					    <xsl:choose>
					        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:telecom[not(@nullFlavor)]">
					            <tr>
                                    <td colspan="8">
									    <p class="tableblack">
					                        <xsl:for-each select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:telecom">
						    	            	<xsl:call-template name="formatContact">
                                                    <xsl:with-param name="contact" select="./@value"/>
                                                </xsl:call-template>
												<xsl:text> </xsl:text>
						    	            </xsl:for-each>
										</p>
                                    </td>
				                </tr>
			                </xsl:when>
			            </xsl:choose>
						<xsl:choose>
					        <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry/n1:observation[n1:code/@code='811']/n1:value[not(@nullFlavor)]">
					            <tr>
                                    <td colspan="8">
									    <p class="tableblack">
										    <xsl:text>Код льготы: </xsl:text>
											<xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:value/@code"/>
											<xsl:text> </xsl:text>
										    <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:value/@displayName"/>
											<xsl:choose>
											    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:high[not(@nullFlavor)] and /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:low[not(@nullFlavor)]">
                                                    <xsl:text> (</xsl:text>
													<xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:low/@value"/>
                                                    </xsl:call-template>
													<xsl:text> &#8212; </xsl:text>
												    <xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:high/@value"/>
                                                    </xsl:call-template>
							        			    <xsl:text>)</xsl:text>
                                                </xsl:when>
                                                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:high[not(@nullFlavor)]">
                                                    <xsl:text> (действует до </xsl:text>
												    <xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:high/@value"/>
                                                    </xsl:call-template>
							        			    <xsl:text>)</xsl:text>
                                                </xsl:when>
												<xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:low[not(@nullFlavor)]">
                                                    <xsl:text> (с </xsl:text>
												    <xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][1]/n1:observation[n1:code/@code='811']/n1:effectiveTime/n1:low/@value"/>
                                                    </xsl:call-template>
							        			    <xsl:text>)</xsl:text>
                                                </xsl:when>
                                            </xsl:choose>
											<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='BENEFITS']/n1:entry[n1:observation/n1:code/@code='811'][position()>1]/n1:observation[n1:code/@code='811']">
												<xsl:text>; </xsl:text>
												<xsl:value-of select="./n1:value/@code"/>
											    <xsl:text> </xsl:text>
										        <xsl:value-of select="./n1:value/@displayName"/>
											    <xsl:choose>
												    <xsl:when test="./n1:effectiveTime/n1:high[not(@nullFlavor)] and ./n1:effectiveTime/n1:low[not(@nullFlavor)]">
                                                        <xsl:text> (</xsl:text>
												    	<xsl:call-template name="formatDate">
                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/n1:low/@value"/>
                                                        </xsl:call-template>
												    	<xsl:text> &#8212; </xsl:text>
												        <xsl:call-template name="formatDate">
                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/n1:high/@value"/>
                                                        </xsl:call-template>
							        			        <xsl:text>)</xsl:text>
                                                    </xsl:when>
                                                    <xsl:when test="./n1:effectiveTime/n1:high[not(@nullFlavor)]">
                                                        <xsl:text> (действует до </xsl:text>
											    	    <xsl:call-template name="formatDate">
                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/n1:high/@value"/>
                                                        </xsl:call-template>
							        		    	    <xsl:text>)</xsl:text>
                                                    </xsl:when>
													<xsl:when test="./n1:effectiveTime/n1:low[not(@nullFlavor)]">
                                                    <xsl:text> (с </xsl:text>
												    <xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="./n1:effectiveTime/n1:low/@value"/>
                                                    </xsl:call-template>
							        			    <xsl:text>)</xsl:text>
                                                </xsl:when>
                                                </xsl:choose>
						    	            </xsl:for-each>
										</p>
                                    </td>
				                </tr>
			                </xsl:when>
			            </xsl:choose>
					</table>
					<xsl:choose>
                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian[not(@nullFlavor)]">
					        <table class="block-form">
							    <tr>
                                    <td colspan="8">
                                        <h2 class="tablegray">
                                            <xsl:text>Законный (уполномоченный) представитель пациента</xsl:text>
                                        </h2>
						        		<xsl:choose>
                                            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:guardianPerson/n1:name[not(@nullFlavor)]">
						        		        <p class="tableblack">
							    		            <xsl:text>ФИО: </xsl:text>
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:guardianPerson/n1:name"/>
													<xsl:choose>
                                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:code[not(@nullFlavor)]">
                                                            <xsl:text> (</xsl:text>
															<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:code/@displayName"/>
							        						<xsl:text>)</xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
                                                </p>
											</xsl:when>
                                        </xsl:choose>
										<xsl:choose>
                                            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:guardianOrganization/n1:name[not(@nullFlavor)]">
						        		        <p class="tableblack">
							    		            <xsl:text>Наименование организации: </xsl:text>
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:guardianOrganization/n1:name"/>
                                                </p>
											</xsl:when>
                                        </xsl:choose>
							    		<xsl:choose>
                                            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/PII:birthTime[not(@nullFlavor)]">
					                            <p class="tableblack">
							    		        	<xsl:text>Дата рождения: </xsl:text>
                                                    <xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/PII:birthTime/@value"/>
                                                    </xsl:call-template>
                                                </p>
						                    </xsl:when>
                                        </xsl:choose>
						                <xsl:choose>
                                            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:id/@extension[not(@nullFlavor)]">
					                            <p class="tableblack">
							            		    <xsl:text>СНИЛС: </xsl:text>
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:id/@extension"/>
                                                </p>
						                    </xsl:when>
                                        </xsl:choose>
                                    </td>
						        </tr>
							    <xsl:choose>
                                    <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='1']/n1:streetAddressLine">
						                <tr>
                                            <td colspan="8">
                                                <p class="tableblack">
						                		    <xsl:text>Адрес по месту жительства (постоянной регистрации): </xsl:text>
                                                    <xsl:choose>
                                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='1']/n1:postalCode[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='1']/n1:postalCode"/>
							        						<xsl:text>, </xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
							        				<xsl:choose>
                                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='1']/address:stateCode[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='1']/address:stateCode/@displayName"/>
							        						<xsl:text>, </xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
							        				<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='1']/n1:streetAddressLine"/>
                                                </p>
                                            </td>
					                    </tr>
						            </xsl:when>
                                </xsl:choose>
						        <xsl:choose>
                                    <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='2']/n1:streetAddressLine">
						                <tr>
                                            <td colspan="8">
                                                <p class="tableblack">
						                		    <xsl:text>Адрес по месту пребывания (временной регистрации): </xsl:text>
						        					<xsl:choose>
                                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='2']/n1:postalCode[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='2']/n1:postalCode"/>
						        							<xsl:text>, </xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
						        					<xsl:choose>
                                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='2']/address:stateCode[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='2']/address:stateCode/@displayName"/>
						        							<xsl:text>, </xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='2']/n1:streetAddressLine"/>
                                                </p>
                                            </td>
					                    </tr>
						            </xsl:when>
                                </xsl:choose>
						        <xsl:choose>
                                    <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='3']/n1:streetAddressLine[not(@nullFlavor)]">
						                <tr>
                                            <td colspan="8">
						                		<p class="tableblack">
							    				    <xsl:text>Адрес фактического проживания (пребывания): </xsl:text>
							    					<xsl:choose>
                                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='3']/n1:postalCode[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='3']/n1:postalCode"/>
							    					    	<xsl:text>, </xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
							    				    <xsl:choose>
                                                        <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='3']/address:stateCode[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='3']/address:stateCode/@displayName"/>
							    				    		<xsl:text>, </xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:addr[address:Type/@code='3']/n1:streetAddressLine"/>
                                                </p>
                                            </td>
                                        </tr>
						            </xsl:when>
                                </xsl:choose>
						        <tr>
                                    <td colspan="8">
						        		<p class="tableblack">
					            		    <xsl:choose>
					            			    <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian /identity:IdentityDoc[not(@nullFlavor)]">
					            				    <xsl:text>Документ, удостоверяющий личность: </xsl:text>
							    					<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:IdentityCardType/@displayName"/>
						        					<xsl:text> </xsl:text>
					            				    <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:Series[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:Series"/>
						        							<xsl:text> </xsl:text>
					            				        </xsl:when>
					            				    </xsl:choose>
					            					<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:Number"/><xsl:text> </xsl:text>
					            				    <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:IssueOrgName[not(@nullFlavor)]">
					            				        	<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:IssueOrgName"/>
						        							<xsl:text> </xsl:text>
					            				        </xsl:when>
					            				    </xsl:choose>
					            				    <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:IssueOrgCode[not(@nullFlavor)]">
					            				        	<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:IssueOrgCode"/>
						        							<xsl:text> </xsl:text>
					            				        </xsl:when>
					            				    </xsl:choose>
					            					<xsl:text>Дата выдачи: </xsl:text>
					            					<xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:IdentityDoc/identity:IssueDate/@value"/>
                                                    </xsl:call-template>
                                                </xsl:when>
							    				<xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian /identity:IdentityDoc/@nullFlavor">
						                            <xsl:text>Документ, удостоверяющий личность: </xsl:text>
							    					<xsl:call-template name="formatNullFlavor">
                                                        <xsl:with-param name="nullflavor" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian /identity:IdentityDoc/@nullFlavor"/>
                                                    </xsl:call-template>
						 	                    </xsl:when>
                                            </xsl:choose>
                                        </p>
                                    </td>
					            </tr>
						        <tr>
                                    <td colspan="8">
						        		<p class="tableblack">
					            		    <xsl:choose>
					            			    <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian /identity:AuthorityDoc[not(@nullFlavor)]">
					            				    <xsl:text>Документ, удостоверяющий полномочия: </xsl:text>
							    					<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:IdentityCardType/@displayName"/>
						        					<xsl:text> </xsl:text>
					            				    <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:Series[not(@nullFlavor)]">
                                                            <xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:Series"/>
						        							<xsl:text> </xsl:text>
					            				        </xsl:when>
					            				    </xsl:choose>
					            					<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:Number"/>
						        					<xsl:text> </xsl:text>
					            				    <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:IssueOrgName[not(@nullFlavor)]">
					            				        	<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:IssueOrgName"/>
						        							<xsl:text> </xsl:text>
					            				        </xsl:when>
					            				    </xsl:choose>
					            				    <xsl:choose>
					            			            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:IssueOrgCode[not(@nullFlavor)]">
					            				        	<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:IssueOrgCode"/>
						        							<xsl:text> </xsl:text>
					            				        </xsl:when>
					            				    </xsl:choose>
					            					<xsl:text>Дата выдачи: </xsl:text>
					            					<xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/identity:AuthorityDoc/identity:IssueDate/@value"/>
                                                    </xsl:call-template>
                                                </xsl:when>
					            				<xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian /identity:AuthorityDoc/@nullFlavor">
						                            <xsl:text>Документ, удостоверяющий полномочия: </xsl:text>
							    					<xsl:call-template name="formatNullFlavor">
                                                        <xsl:with-param name="nullflavor" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian /identity:AuthorityDoc/@nullFlavor"/>
                                                    </xsl:call-template>
						 	                    </xsl:when>
                                            </xsl:choose>
                                        </p>
                                    </td>
					            </tr>
						        <xsl:choose>
				    	            <xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:telecom[not(@nullFlavor)]">
				    	                <tr>
                                            <td colspan="8">
						        				<p class="tableblack">
				    	                            <xsl:for-each select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:guardian/n1:telecom">
				    	         	        	        <xsl:call-template name="formatContact">
                                                            <xsl:with-param name="contact" select="./@value"/>
                                                        </xsl:call-template>
														<xsl:text> </xsl:text>
				    	         	                </xsl:for-each>
						        				</p>
                                            </td>
				                        </tr>
			                        </xsl:when>
			                    </xsl:choose>
							</table>
					    </xsl:when>
                    </xsl:choose>
					<table class="block-form">
					    <tr>
                            <td colspan="8">
							    <h2 class="tablegray">
						    	    <xsl:text>Обращение</xsl:text>
                                </h2>
                                <p class="tableblack">
								    <xsl:text>Тип обращения: </xsl:text>
									<xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:encounter/n1:entryRelationship/n1:observation/n1:code[@code='2']/@displayName"/>
                                </p>
								<p class="tableblack">
								    <xsl:text>Даты случая: </xsl:text>
									<xsl:call-template name="formatDatewithTime">
                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:encounter//n1:effectiveTime/n1:low/@value"/>
                                    </xsl:call-template>
									<xsl:choose>
						    		    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:encounter/n1:effectiveTime/n1:high[not(@nullFlavor)]">
									        <xsl:text> &#8212; </xsl:text>
								            <xsl:call-template name="formatDatewithTime">
                                                <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:encounter/n1:effectiveTime/n1:high/@value"/>
                                            </xsl:call-template>
										</xsl:when>
					        	    </xsl:choose>
						        </p>
								<p class="tableblack">
								    <xsl:text>Шифр МКБ данного случая: </xsl:text>
									<xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:encounter/n1:entryRelationship/n1:act/n1:code/@code"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:encounter/n1:entryRelationship/n1:act/n1:code/@displayName"/>
                                </p>
								<xsl:choose>
						    		<xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:observation/n1:code[@code='1'][not(@nullFlavor)]">
								        <p class="tableblack">
								            <xsl:text>Результат обращения: </xsl:text>
								        	<xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:observation/n1:code[@code='1']/@displayName"/>
                                        </p>
									</xsl:when>
					        	</xsl:choose>
                                <xsl:choose>
						    		<xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:observation/n1:code[@code='3'][not(@nullFlavor)]">
								        <p class="tableblack">
								            <xsl:text>Направление по завершению обращения: </xsl:text>
								        	<xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:observation/n1:code[@code='3']/@displayName"/>
                                        </p>
									</xsl:when>
					        	</xsl:choose>
                            </td>
					    </tr>
						<xsl:if test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:act[n1:code/@code='1']">
					        <tr>
                                <td colspan="8">
                                    <h2 class="tablegray">
						    			<xsl:text>Предварительный диагноз</xsl:text>
                                    </h2>
						    		<p class="tableblack">
						    	        <table class="table-break">
						    	            <tr>
					                            <th class="param">Вид нозологической единицы диагноза</th>
						                        <th class="param">Клиническая формулировка диагноза</th>
						                        <th class="param">Код по МКБ-10</th>
												<th class="param">Диспансерное наблюдение</th>
						    	           	    <th class="param">Дополнительные сведения о заболевании</th>
						                    </tr>
						    	           	<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:act[n1:code/@code='1']/n1:entryRelationship/n1:observation">
						    	           		<tr>
                                                    <td class="param">
                                                        <p class="tableresult">
						                                   	<xsl:value-of select="./n1:code/@displayName"/>
						                                </p>
                                                    </td>
						                            <td class="param">
                                                        <p class="tableresult">
						    								<xsl:choose>
						    								    <xsl:when test="./n1:text and ./n1:value/@displayName">
						    					                	<xsl:value-of select="./n1:value/@displayName"/>
						    										<xsl:text> (</xsl:text>
						    										<xsl:value-of select="./n1:text"/>
						    										<xsl:text>)</xsl:text>
					        	                                </xsl:when>
					                                            <xsl:when test="./n1:text">
						    					                	<xsl:value-of select="./n1:text"/>
					        	                                </xsl:when>
						    									<xsl:otherwise>
						    									    <xsl:value-of select="./n1:value/@displayName"/>
						    									</xsl:otherwise>
					        	                            </xsl:choose>
						                                </p>
                                                    </td>
						                            <td class="param">
                                                        <p class="tableresult">
						    	           	                <xsl:value-of select="./n1:value/@code"/>
						                                </p>
                                                    </td>
													<td class="param">
													    <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1047'][not(@nullFlavor)]">
																<p class="tableresult">
						    					                    <xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1047']/@displayName"/>
						                                        </p>
																<xsl:choose>
					                                                <xsl:when test="./n1:entryRelationship/n1:act[n1:code/@code='3'][n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@code='1' and @codeSystem='1.2.643.5.1.13.13.11.1045'][not(@nullFlavor)]">
																        <p class="tableresult">
																		    <xsl:text>Причина прекращения: </xsl:text>
						    					                            <xsl:value-of select="./n1:entryRelationship/n1:act[n1:code/@code='3'][n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@code='1' and @codeSystem='1.2.643.5.1.13.13.11.1045']/@displayName"/>
						                                                </p>
																	</xsl:when>
					        	                                </xsl:choose>
														    </xsl:when>
															<xsl:otherwise>
															    <p class="tableresult">
						    							        	<xsl:text>-</xsl:text>
																</p>
						    							    </xsl:otherwise>
														</xsl:choose>
                                                    </td>
						    	           	        <td class="param">
						    					        <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1049']">
						    			    	               	<p class="tableblack">
						    										<xsl:text>Характер заболевания: </xsl:text>
						    										<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1049']/@displayName"/>
					        	                                </p>
						    								</xsl:when>
					        	                        </xsl:choose>
						    					        <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code">
						    			    	               	<p class="tableblack">
						    										<xsl:text>Внешняя причина: </xsl:text>
						    					               		<xsl:value-of select="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code/@displayName"/>
					        	                                </p>
						    							    </xsl:when>
					        	                        </xsl:choose>
						    					        <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='14' and @codeSystem='1.2.643.5.1.13.13.11.1036']">
						    			    	               	<p class="tableblack">
						    										<xsl:text>Вид травмы по способу получения: </xsl:text>
						    					               		<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='14' and @codeSystem='1.2.643.5.1.13.13.11.1036']/@displayName"/>
					        	                                </p>
						    							    </xsl:when>
					        	                        </xsl:choose>
                                                    </td>
						                        </tr>
						    	           	</xsl:for-each>
						    	        </table>
					                </p>
                                </td>
                            </tr>
			            </xsl:if>
						<xsl:if test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:act[n1:code/@code='3']">
					        <tr>
                                <td colspan="8">
                                    <h2 class="tablegray">
						    			<xsl:text>Заключительный диагноз</xsl:text>
                                    </h2>
						    		<p class="tableblack">
						    	        <table class="table-break">
						    	            <tr>
					                            <th class="param">Вид нозологической единицы диагноза</th>
						                        <th class="param">Клиническая формулировка диагноза</th>
						                        <th class="param">Код по МКБ-10</th>
												<th class="param">Диспансерное наблюдение</th>
						    	           	    <th class="param">Дополнительные сведения о заболевании</th>
						                    </tr>
						    	           	<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBS']/n1:entry/n1:act[n1:code/@code='3']/n1:entryRelationship/n1:observation">
						    	           		<tr>
                                                    <td class="param">
                                                        <p class="tableresult">
						                                   	<xsl:value-of select="./n1:code/@displayName"/>
						                                </p>
                                                    </td>
						                            <td class="param">
                                                        <p class="tableresult">
						    								<xsl:choose>
						    								    <xsl:when test="./n1:text and ./n1:value/@displayName">
						    					                	<xsl:value-of select="./n1:value/@displayName"/>
						    										<xsl:text> (</xsl:text>
						    										<xsl:value-of select="./n1:text"/>
						    										<xsl:text>)</xsl:text>
					        	                                </xsl:when>
					                                            <xsl:when test="./n1:text">
						    					                	<xsl:value-of select="./n1:text"/>
					        	                                </xsl:when>
						    									<xsl:otherwise>
						    									    <xsl:value-of select="./n1:value/@displayName"/>
						    									</xsl:otherwise>
					        	                            </xsl:choose>
						                                </p>
                                                    </td>
						                            <td class="param">
                                                        <p class="tableresult">
						    	           	                <xsl:value-of select="./n1:value/@code"/>
						                                </p>
                                                    </td>
													<td class="param">
													    <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1047'][not(@nullFlavor)]">
																<p class="tableresult">
						    					                    <xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1047']/@displayName"/>
						                                        </p>
																<xsl:choose>
					                                                <xsl:when test="./n1:entryRelationship/n1:act[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1045'][not(@nullFlavor)]">
																        <p class="tableresult">
																		    <xsl:text>Причина прекращения: </xsl:text>
						    					                            <xsl:value-of select="./n1:entryRelationship/n1:act[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1045']/@displayName"/>
						                                                </p>
																	</xsl:when>
					        	                                </xsl:choose>
														    </xsl:when>
															<xsl:otherwise>
															    <p class="tableresult">
						    							        	<xsl:text>-</xsl:text>
																</p>
						    							    </xsl:otherwise>
														</xsl:choose>
                                                    </td>
						    	           	        <td class="param">
						    					        <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1049']">
						    			    	               	<p class="tableblack">
						    										<xsl:text>Характер заболевания: </xsl:text>
						    										<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1049']/@displayName"/>
					        	                                </p>
						    								</xsl:when>
					        	                        </xsl:choose>
						    					        <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code">
						    			    	               	<p class="tableblack">
						    										<xsl:text>Внешняя причина: </xsl:text>
						    					               		<xsl:value-of select="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code/@displayName"/>
					        	                                </p>
						    							    </xsl:when>
					        	                        </xsl:choose>
						    					        <xsl:choose>
					                                        <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1036']">
						    			    	               	<p class="tableblack">
						    										<xsl:text>Вид травмы по способу получения: </xsl:text>
						    					               		<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1036']/@displayName"/>
					        	                                </p>
						    							    </xsl:when>
					        	                        </xsl:choose>
                                                    </td>
						                        </tr>
						    	           	</xsl:for-each>
						    	        </table>
					                </p>
                                </td>
                            </tr>
			            </xsl:if>
					</table>
					<xsl:choose>
                        <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='ALL']">
					        <table class="block-form">
							    <xsl:choose>
                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='ALL'][not(@nullFlavor)]">
					            	    <tr>
									        <td colspan="8">
									            <h2 class="tablegray">
                                                    <xsl:text>Аллергии и непереносимость</xsl:text>
                                                </h2>
									            <xsl:choose>
					                                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='ALL']/n1:entry/n1:observation[not(@nullFlavor)]">
									               	    <p class="tableblack">
								                            <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='ALL']/n1:entry/n1:observation[n1:code/@code='7006']/n1:value"/>
									               		</p>
								                    </xsl:when>
								                </xsl:choose>
								                <xsl:choose>
					                                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='ALL']/n1:entry/n1:observation/n1:text[not(@nullFlavor)]">
								                        <p class="tableblack">
					                        	  	        <table class="table-break">
					                                            <thead>
					                        	  			        <th class="param">Дата выявления</th>
					                                                <th class="param">Описание агента</th>
					                        	                    <th class="param">Тип реакции</th>
					                        	  			        <th class="param">Клинические проявления</th>
												                    <th class="param">Комментарий</th>
					                        	                </thead>
					                        	  		        <tbody>
					                        	                    <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='ALL']/n1:entry/n1:observation">
					                        	                        <tr>
                                                                            <td class="param">
                                                                                <p class="tableresult">
					                        	                               		<xsl:call-template name="formatDate">
                                                                                        <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                    </xsl:call-template>
					                        	                               	</p>
                                                                            </td>
					                        	                           	<td class="param">
                                                                                <p class="tableresult">
					                        	  						            <xsl:choose>
									            				                        <xsl:when test="./n1:participant/n1:participantRole/n1:playingEntity/n1:code[not(@nullFlavor)] and ./n1:participant/n1:participantRole/n1:playingEntity/n1:desc">
								                        		                            <xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:code/@displayName"/>
									            				                    		<xsl:text> (</xsl:text>
									            				                    		<xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:desc"/>
									            				                    		<xsl:text>)</xsl:text>
								                        		                        </xsl:when>
					                                                                    <xsl:when test="./n1:participant/n1:participantRole/n1:playingEntity/n1:code[not(@nullFlavor)]">
								                        		                            <xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:code/@displayName"/>
								                        		                        </xsl:when>
								                        		                    	<xsl:when test="./n1:participant/n1:participantRole/n1:playingEntity/n1:code/@nullFlavor">
								                        		                            <xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:desc"/>
								                        		                        </xsl:when>
								                        		                    </xsl:choose>
					                        	                               	</p>
                                                                            </td>
					                        	  					        <td class="param">
                                                                                <p class="tableresult">
					                        	  							        <xsl:value-of select="./n1:code/@displayName"/>
					                                    	                   	</p>
                                                                            </td>
					        		        	  					        <td class="param">
                                                                                <p class="tableresult">
					                        		       							<xsl:value-of select="./n1:entryRelationship/n1:observation/n1:code/@displayName"/>
					                                          	                </p>
                                                                            </td>
													                        <td class="param">
                                                                                <p class="tableresult">
					                        	                               		<xsl:value-of select="./n1:text"/>
					                        	                               	</p>
                                                                            </td>
					                        	                        </tr>
					                        	                    </xsl:for-each>
					                        	  		        </tbody>
					                        	  	        </table>
					                        	        </p>
								                	</xsl:when>
													<xsl:otherwise>
								                        <p class="tableblack">
					                        		       	<table class="table-break">
					                                            <thead>
					                        		       			<th class="param">Дата выявления</th>
					                                                <th class="param">Описание агента</th>
					                        	                    <th class="param">Тип реакции</th>
					                        		       			<th class="param">Клинические проявления</th>
					                        	                </thead>
					                        		       		<tbody>
					                        	                    <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='ALL']/n1:entry/n1:observation">
					                        	                        <tr>
                                                                            <td class="param">
                                                                                <p class="tableresult">
					                        	                               		<xsl:call-template name="formatDate">
                                                                                        <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                    </xsl:call-template>
					                        	                               	</p>
                                                                            </td>
					                        	                            <td class="param">
                                                                                <p class="tableresult">
					                        		       						    <xsl:choose>
									                   			                        <xsl:when test="./n1:participant/n1:participantRole/n1:playingEntity/n1:code[not(@nullFlavor)] and ./n1:participant/n1:participantRole/n1:playingEntity/n1:desc">
								                              		                        <xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:code/@displayName"/>
									                   			                    	    <xsl:text> (</xsl:text>
									                   			                    	    <xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:desc"/>
									                   			                    	    <xsl:text>)</xsl:text>
								                              		                    </xsl:when>
					                                                                    <xsl:when test="./n1:participant/n1:participantRole/n1:playingEntity/n1:code[not(@nullFlavor)]">
								                              		                        <xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:code/@displayName"/>
								                              		                    </xsl:when>
								                              		                    <xsl:when test="./n1:participant/n1:participantRole/n1:playingEntity/n1:code/@nullFlavor">
								                              		                        <xsl:value-of select="./n1:participant/n1:participantRole/n1:playingEntity/n1:desc"/>
								                              		                    </xsl:when>
								                              		                </xsl:choose>
					                        	                                </p>
                                                                            </td>
					                        		       					<td class="param">
                                                                                <p class="tableresult">
					                        		       							<xsl:value-of select="./n1:code/@displayName"/>
					                                          	                </p>
                                                                            </td>
					        		        		       					<td class="param">
                                                                                <p class="tableresult">
					                        		       							<xsl:value-of select="./n1:entryRelationship/n1:observation/n1:code/@displayName"/>
					                                          	                </p>
                                                                            </td>
					                        	                        </tr>
					                        	                    </xsl:for-each>
					                        		       		</tbody>
					                        		       	</table>
					                        		    </p>
								                    </xsl:otherwise>
								                </xsl:choose>
								            </td>
							            </tr>
					        	    </xsl:when>
                                </xsl:choose>
								<xsl:choose>
                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']">
							            <tr>
					                        <td colspan="8">
                                                <h2 class="tablegrayhead">
                                                    <xsl:text>Социальный анамнез</xsl:text>
                                                </h2>
								        		<xsl:choose>
                                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1038'][not(@nullFlavor)]">
						                          		<tr>
					                              	        <td colspan="8">
                                                                <h2 class="tablegray">
						                          				    <xsl:text>Занятость</xsl:text>
                                                                </h2>
					                              		        <p class="tableblack">
						                          				    <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1038']/@displayName"/>
								        							<xsl:choose>
					                        		        		    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1038']/n1:text[not(@nullFlavor)]">
								        								    <xsl:text> (</xsl:text>
					                        		        		        <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1038']/n1:text"/>
								        									<xsl:text>)</xsl:text>
								        			        			</xsl:when>
					                        		        		</xsl:choose>
                                                                </p>
						                          			</td>
						                          		</tr>
						                          	</xsl:when>
                                                </xsl:choose>
								        		<xsl:choose>
                                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[1][not(@nullFlavor)]">
								        				<tr>
					    	                                <td colspan="8">
								        						<h2 class="tablegray">
							                        		        <xsl:text>Инвалидность</xsl:text>
                                                                </h2>
					    	                        	        <p class="tableblack">
							                        		        <xsl:text>Группа инвалидности: </xsl:text>
								        					        <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[1]/n1:code/@displayName"/>
                                                                </p>
							                        		    <xsl:choose>
                                                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[1][not(@nullFlavor)]">
							                        		            <p class="tableblack">
							                        		        	    <xsl:text>Установлена: </xsl:text>
							                        		                <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation/n1:code/n1:qualifier/n1:value/@displayName"/>
                                                                        </p>
							                        		        </xsl:when>
                                                                </xsl:choose>
								        						<p class="tableblack">
							                        		        <xsl:text>Дата установления инвалидности: </xsl:text>
								        							<xsl:call-template name="formatDate">
                                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[1]/n1:effectiveTime/n1:low/@value"/>
                                                                    </xsl:call-template>
                                                                </p>
								        					</td>
							                        	</tr>
								        			</xsl:when>
                                                </xsl:choose>
								        		<xsl:choose>
                                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1059'][not(@nullFlavor)]">
						                          		<tr>
					                              	        <td colspan="8">
                                                                <h2 class="tablegray">
						                          				    <xsl:text>Потенциально-опасные для здоровья социальные факторы</xsl:text>
                                                                </h2>
						                                        <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1059']">
					                              		            <p class="tableblack">
						                          				        <xsl:value-of select="./n1:code/@displayName"/>
                                                                    </p>
						                                        </xsl:for-each>
						                          			</td>
						                          		</tr>
						                          	</xsl:when>
                                                </xsl:choose>
								        		<xsl:choose>
                                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1060'][not(@nullFlavor)]">
						                          		<tr>
					                              	        <td colspan="8">
                                                                <h2 class="tablegray">
						                          				    <xsl:text>Вредные производственные факторы</xsl:text>
                                                                </h2>
						                                        <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1060']">
					                              		            <p class="tableblack">
						                          				        <xsl:value-of select="./n1:code/@displayName"/>
                                                                    </p>
						                                        </xsl:for-each>
						                          			</td>
						                          		</tr>
						                          	</xsl:when>
                                                </xsl:choose>
								        		<xsl:choose>
                                                    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation/n1:code[@codeSystem='1.2.643.5.1.13.13.11.1058'][not(@nullFlavor)]">
						                          		<tr>
					                              	        <td colspan="8">
                                                                <h2 class="tablegray">
						                          				    <xsl:text>Вредные привычки или зависимости</xsl:text>
                                                                </h2>
						                                        <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SOCANAM']/n1:entry/n1:observation[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1058']">
					                              		            <p class="tableblack">
						                          				        <xsl:value-of select="./n1:code/@displayName"/>
                                                                    </p>
						                                        </xsl:for-each>
						                          			</td>
						                          		</tr>
						                          	</xsl:when>
                                                </xsl:choose>
							            	</td>
							            </tr>
									</xsl:when>
                                </xsl:choose>
					        </table>
						</xsl:when>
                    </xsl:choose>
					<xsl:choose>
						<xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBSV']">
						    <table class="block-form">
						        <tr>
								 	<td colspan="8">
								 		<h2 class="tablegray">
										    <xsl:text>Посещения</xsl:text>
										</h2>
										<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='AMBSV']/n1:entry/n1:encounter">
								            <p class="tableblack">
					                	     	<table class="table-break">
					                                <thead>
											 		    <tr>
                                                            <th class="param" colspan="5">
											 		    	    <xsl:call-template name="formatDatewithTime">
                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/n1:low/@value"/>
                                                                </xsl:call-template>
											                    <xsl:choose>
                                                                    <xsl:when test="./n1:effectiveTime/n1:high[not(@nullFlavor)]">
						                      		               	    <xsl:text> &#8212; </xsl:text>
						                      		               	    <xsl:call-template name="formatDatewithTime">
                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/n1:high/@value"/>
                                                                        </xsl:call-template>
						                      		                </xsl:when>
						                                        </xsl:choose>
					    	        		 		    	    <xsl:text> (</xsl:text>
					    	        		 		    	    <xsl:value-of select="./n1:participant/n1:participantRole/n1:code/@displayName"/>
					    	        		 		    	    <xsl:text>) </xsl:text>
											                    <xsl:value-of select="./n1:performer/n1:assignedEntity/n1:code/@displayName"/>
											                    <xsl:text>, </xsl:text>
											 		    		<xsl:value-of select="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name"/>
                                                             </th>
					    	        		 		    </tr>
														<tr>
					                	     			    <th class="param">Жалобы пациента</th>
					                                        <th class="param">Объективно</th>
					                	                    <th class="param">Заключение</th>
					                	     			    <th class="param">Рекомендации</th>
							        	     			    <th class="param">Оказанные услуги</th>
														</tr>
					                	            </thead>
					                	     		<tbody>
					                	                <tr>
					                		 			    <td class="param">
					                		 				    <p class="tableresult">
					                		 			            <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='835']/n1:value"/>
					                		 					</p>
					                		 				</td>
                                                            <td class="param">
                                                                <p class="tableresult">
					                	                        	<xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='836']/n1:value"/>
					                	                        </p>
                                                            </td>
					                	                    <td class="param">
                                                                <p class="tableresult">
					                		 					    <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='837']/n1:value"/>
					                	                        </p>
                                                            </td>
					                		 				<td class="param">
                                                                <p class="tableresult">
											 					    <xsl:choose>
					                		 						    <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='839']/n1:value[not(@nullFlavor)]">
					                		 					            <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='839']/n1:value"/>
											 							</xsl:when>
											 							<xsl:otherwise>
											 							    <xsl:text>-</xsl:text>
											 							</xsl:otherwise>
					                		 						</xsl:choose>
					                           	                </p>
                                                            </td>
							        		 				<td class="param">
											                    <xsl:for-each select="./n1:entryRelationship/n1:act[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1070'][not(@nullFlavor)]">
                                                                    <p class="tableresult">
											                            <xsl:value-of select="./n1:code/@code"/>
												                        <xsl:text> </xsl:text>
					                		 					        <xsl:value-of select="./n1:code/@displayName"/>
												                        <xsl:choose>
                                                                            <xsl:when test="./n1:effectiveTime[not(@nullFlavor)]">
						                      		                    	    <xsl:text> от </xsl:text>
						                      		                    	    <xsl:call-template name="formatDatewithTime">
                                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                </xsl:call-template>
						                      		                        </xsl:when>
						                                                </xsl:choose>
					                	                        	</p>
																</xsl:for-each>
                                                            </td>
					                	                </tr>
					                	     		</tbody>
													<xsl:if test="./n1:entryRelationship/n1:act[n1:code/@code='1']">
													    <tr>
					                                        <td class="paramless" colspan="5">Предварительный диагноз</td>
						                                </tr>
														<tr>
					                                        <td class="paramless">Вид нозологической единицы диагноза</td>
						                                    <td class="paramless">Клиническая формулировка диагноза</td>
						                                    <td class="paramless">Код по МКБ-10</td>
											            	<td class="paramless">Диспансерное наблюдение</td>
						    	           	                <td class="paramless">Дополнительные сведения о заболевании</td>
						                                </tr>
						    	           	            <xsl:for-each select="./n1:entryRelationship/n1:act[n1:code/@code='1']/n1:entryRelationship/n1:observation">
						    	           	            	<tr>
                                                                <td class="param">
                                                                    <p class="tableresult">
						                                               	<xsl:value-of select="./n1:code/@displayName"/>
						                                            </p>
                                                                </td>
						                                        <td class="param">
                                                                    <p class="tableresult">
						    				            				<xsl:choose>
						    				            				    <xsl:when test="./n1:text and ./n1:value/@displayName">
						    				            	                	<xsl:value-of select="./n1:value/@displayName"/>
						    				            						<xsl:text> (</xsl:text>
						    				            						<xsl:value-of select="./n1:text"/>
						    				            						<xsl:text>)</xsl:text>
					        	                                            </xsl:when>
					                                                        <xsl:when test="./n1:text">
						    				            	                	<xsl:value-of select="./n1:text"/>
					        	                                            </xsl:when>
						    				            					<xsl:otherwise>
						    				            					    <xsl:value-of select="./n1:value/@displayName"/>
						    				            					</xsl:otherwise>
					        	                                        </xsl:choose>
						                                            </p>
                                                                </td>
						                                        <td class="param">
                                                                    <p class="tableresult">
						    	           	                            <xsl:value-of select="./n1:value/@code"/>
						                                            </p>
                                                                </td>
											            		<td class="param">
											            		    <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1047'][not(@nullFlavor)]">
											            					<p class="tableresult">
						    				            	                    <xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1047']/@displayName"/>
						                                                    </p>
											            					<xsl:choose>
					                                                            <xsl:when test="./n1:entryRelationship/n1:act[n1:code/@code='3'][n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@code='1' and @codeSystem='1.2.643.5.1.13.13.11.1045'][not(@nullFlavor)]">
											            					        <p class="tableresult">
											            							    <xsl:text>Причина прекращения: </xsl:text>
						    				            	                            <xsl:value-of select="./n1:entryRelationship/n1:act[n1:code/@code='3'][n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@code='1' and @codeSystem='1.2.643.5.1.13.13.11.1045']/@displayName"/>
						                                                            </p>
											            						</xsl:when>
					        	                                            </xsl:choose>
											            			    </xsl:when>
											            				<xsl:otherwise>
											            				    <p class="tableresult">
						    				            			        	<xsl:text>-</xsl:text>
											            					</p>
						    				            			    </xsl:otherwise>
											            			</xsl:choose>
                                                                </td>
						    	           	                    <td class="param">
						    				            	        <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1049']">
						    			                	               	<p class="tableblack">
						    				            						<xsl:text>Характер заболевания: </xsl:text>
						    				            						<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1049']/@displayName"/>
					        	                                            </p>
						    				            				</xsl:when>
					        	                                    </xsl:choose>
						    				            	        <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code">
						    			                	               	<p class="tableblack">
						    				            						<xsl:text>Внешняя причина: </xsl:text>
						    				            	               		<xsl:value-of select="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code/@displayName"/>
					        	                                            </p>
						    				            			    </xsl:when>
					        	                                    </xsl:choose>
						    				            	        <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='14' and @codeSystem='1.2.643.5.1.13.13.11.1036']">
						    			                	               	<p class="tableblack">
						    				            						<xsl:text>Вид травмы по способу получения: </xsl:text>
						    				            	               		<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='14' and @codeSystem='1.2.643.5.1.13.13.11.1036']/@displayName"/>
					        	                                            </p>
						    				            			    </xsl:when>
					        	                                    </xsl:choose>
                                                                </td>
						                                    </tr>
						    	           	            </xsl:for-each>
													</xsl:if>
													<xsl:if test="./n1:entryRelationship/n1:act[n1:code/@code='3']">
													    <tr>
					                                        <td class="paramless" colspan="5">Заключительный диагноз</td>
						                                </tr>
														<tr>
					                                        <td class="paramless">Вид нозологической единицы диагноза</td>
						                                    <td class="paramless">Клиническая формулировка диагноза</td>
						                                    <td class="paramless">Код по МКБ-10</td>
											            	<td class="paramless">Диспансерное наблюдение</td>
						    	           	                <td class="paramless">Дополнительные сведения о заболевании</td>
						                                </tr>
						    	           	            <xsl:for-each select="./n1:entryRelationship/n1:act[n1:code/@code='3']/n1:entryRelationship/n1:observation">
						    	           	            	<tr>
                                                                <td class="param">
                                                                    <p class="tableresult">
						                                               	<xsl:value-of select="./n1:code/@displayName"/>
						                                            </p>
                                                                </td>
						                                        <td class="param">
                                                                    <p class="tableresult">
						    				            				<xsl:choose>
						    				            				    <xsl:when test="./n1:text and ./n1:value/@displayName">
						    				            	                	<xsl:value-of select="./n1:value/@displayName"/>
						    				            						<xsl:text> (</xsl:text>
						    				            						<xsl:value-of select="./n1:text"/>
						    				            						<xsl:text>)</xsl:text>
					        	                                            </xsl:when>
					                                                        <xsl:when test="./n1:text">
						    				            	                	<xsl:value-of select="./n1:text"/>
					        	                                            </xsl:when>
						    				            					<xsl:otherwise>
						    				            					    <xsl:value-of select="./n1:value/@displayName"/>
						    				            					</xsl:otherwise>
					        	                                        </xsl:choose>
						                                            </p>
                                                                </td>
						                                        <td class="param">
                                                                    <p class="tableresult">
						    	           	                            <xsl:value-of select="./n1:value/@code"/>
						                                            </p>
                                                                </td>
											            		<td class="param">
											            		    <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1047'][not(@nullFlavor)]">
											            					<p class="tableresult">
						    				            	                    <xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1047']/@displayName"/>
						                                                    </p>
											            					<xsl:choose>
					                                                            <xsl:when test="./n1:entryRelationship/n1:act[n1:code/@code='3'][n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@code='1' and @codeSystem='1.2.643.5.1.13.13.11.1045'][not(@nullFlavor)]">
											            					        <p class="tableresult">
											            							    <xsl:text>Причина прекращения: </xsl:text>
						    				            	                            <xsl:value-of select="./n1:entryRelationship/n1:act[n1:code/@code='3'][n1:code/@codeSystem='1.2.643.5.1.13.13.11.1047']/n1:entryRelationship/n1:act/n1:code[@code='1' and @codeSystem='1.2.643.5.1.13.13.11.1045']/@displayName"/>
						                                                            </p>
											            						</xsl:when>
					        	                                            </xsl:choose>
											            			    </xsl:when>
											            				<xsl:otherwise>
											            				    <p class="tableresult">
						    				            			        	<xsl:text>-</xsl:text>
											            					</p>
						    				            			    </xsl:otherwise>
											            			</xsl:choose>
                                                                </td>
						    	           	                    <td class="param">
						    				            	        <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1049']">
						    			                	               	<p class="tableblack">
						    				            						<xsl:text>Характер заболевания: </xsl:text>
						    				            						<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='3' and @codeSystem='1.2.643.5.1.13.13.11.1049']/@displayName"/>
					        	                                            </p>
						    				            				</xsl:when>
					        	                                    </xsl:choose>
						    				            	        <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code">
						    			                	               	<p class="tableblack">
						    				            						<xsl:text>Внешняя причина: </xsl:text>
						    				            	               		<xsl:value-of select="./n1:entryRelationship[@typeCode='CAUS' and @inversionInd='true']/n1:act/n1:code/@displayName"/>
					        	                                            </p>
						    				            			    </xsl:when>
					        	                                    </xsl:choose>
						    				            	        <xsl:choose>
					                                                    <xsl:when test="./n1:entryRelationship/n1:act/n1:code[@code='14' and @codeSystem='1.2.643.5.1.13.13.11.1036']">
						    			                	               	<p class="tableblack">
						    				            						<xsl:text>Вид травмы по способу получения: </xsl:text>
						    				            	               		<xsl:value-of select="./n1:entryRelationship/n1:act/n1:code[@code='14' and @codeSystem='1.2.643.5.1.13.13.11.1036']/@displayName"/>
					        	                                            </p>
						    				            			    </xsl:when>
					        	                                    </xsl:choose>
                                                                </td>
						                                    </tr>
						    	           	            </xsl:for-each>
													</xsl:if>
					                	     	</table>
					                	    </p>
										</xsl:for-each>
									</td>
								</tr>
							</table>
						</xsl:when>
					</xsl:choose>
					<xsl:choose>
					    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='VITALPARAM'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SCORES']">
						    <table class="block-form">
							    <xsl:choose>
					                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='VITALPARAM']">
                                        <tr>
                                            <td colspan="8">
                                                <h2 class="tablegray">
 					                                <xsl:text>Витальные параметры</xsl:text>
                                                </h2>
					                         	<p class="tableblack">
					                         	    <table class="table-break">
					                                    <thead>
								                            <th class="param">Дата</th>
					                                        <th class="param">Параметр</th>
					                         	            <th class="param">Значение</th>
					                         	            <th class="param">Ед. изм.</th>
					                         	        </thead>
					                         	   	    <tbody>
					                         	            <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='VITALPARAM']/n1:entry/n1:organizer[n1:statusCode/@code='completed']/n1:component/n1:observation">
					                         	                <tr>
                                                                    <td class="param">
                                                                        <p class="tableresult">
					                         	                         	<xsl:call-template name="formatDatewithTime">
                                                                                <xsl:with-param name="newdate" select="../../n1:effectiveTime/@value"/>
                                                                            </xsl:call-template>
					                         	                        </p>
                                                                    </td>
								                                    <td class="param">
                                                                        <p class="tableresult">
					                         	                            <xsl:value-of select="./n1:code/@displayName"/>
						                     	   				            <xsl:choose>
                                                                                <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='6034']/n1:value[not(@nullFlavor)]">
                                                                                    <xsl:text> (</xsl:text>
						                     	   						            <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='6034']/n1:value/@displayName"/>
						                     	   						            <xsl:text>) </xsl:text>
                                                                                </xsl:when>
                                                                            </xsl:choose>
						                     	   				            <xsl:choose>
                                                                                <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='8034']">
                                                                                    <xsl:text> [</xsl:text>
						                     	   						            <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='8034']/n1:value/@value"/>
						                     	   						            <xsl:text>]</xsl:text>
                                                                                </xsl:when>
                                                                            </xsl:choose>
					                         	                        </p>
                                                                    </td>
					                         	                    <td class="param">
                                                                         <p class="tableresult">
					                         	   			     	        <xsl:choose>
					                         	   			     	            <xsl:when test="./n1:value[not(@nullFlavor)]">
						                     	   				                    <xsl:if test="./n1:value/@xsi:type='ST'">
						                     	   				                        <xsl:value-of select="./n1:value"/>
						                     	   				                    </xsl:if>
						                     	   				                    <xsl:if test="./n1:value/@xsi:type='PQ'">
						                     	   				                        <xsl:value-of select="./n1:value/@value"/>
						                     	   				                    </xsl:if>
						                     	   				                    <xsl:if test="./n1:value/@xsi:type='CD'">
						                     	   				                        <xsl:value-of select="./n1:value/@displayName"/>
						                     	   				                    </xsl:if>
						                     								        <xsl:if test="./n1:value/@xsi:type='INT'">
						                     	   				                        <xsl:value-of select="./n1:value/@value"/>
						                     	   				                    </xsl:if>
						                     	   				                    <xsl:if test="./n1:value/@xsi:type='BL'">
						                     	   				                        <xsl:if test="./n1:value/@value='true'">
						                     	   				                            <xsl:text>Да</xsl:text>
						                     	   				                        </xsl:if>
						                     	   				                    	<xsl:if test="./n1:value/@value='false'">
						                     	   				                            <xsl:text>Нет</xsl:text>
						                     	   				                        </xsl:if>
						                     	   				                    </xsl:if>
						                     								        <xsl:if test="./n1:value/@xsi:type='IVL_TS'">
						                     					                        <xsl:call-template name="formatDate">
                                                                                            <xsl:with-param name="newdate" select="./n1:value/n1:low/@value"/>
                                                                                        </xsl:call-template>
						                     		                                    <xsl:choose>
                                                                                            <xsl:when test="./n1:value/n1:high">
						                     		                                        	<xsl:text> &#8212; </xsl:text>
						                     		                                        	<xsl:call-template name="formatDate">
                                                                                                    <xsl:with-param name="newdate" select="./n1:value/n1:high/@value"/>
                                                                                                </xsl:call-template>
						                     		                                        </xsl:when>
						                                                                </xsl:choose>
						                     					                    </xsl:if>
						                     								        <xsl:if test="./n1:value/@xsi:type='TS'">
						                     					                        <xsl:call-template name="formatDate">
                                                                                            <xsl:with-param name="newdate" select="./n1:value/@value"/>
                                                                                        </xsl:call-template>
						                     	       			                    </xsl:if>
						                     	   				                </xsl:when>
						                     									<xsl:when test="./n1:value/@nullFlavor">
						                     										<xsl:call-template name="formatNullFlavor">
                                                                                        <xsl:with-param name="nullflavor" select="./n1:value/@nullFlavor"/>
                                                                                    </xsl:call-template>
						                     	                                </xsl:when>
					                         	   			     	        </xsl:choose>
					                         	                        </p>
                                                                    </td>
						                     	   				    <td class="param">
                                                                        <p class="tableresult">
					                         	                         	<xsl:value-of select="./n1:value/n1:translation/@displayName"/>
					                         	                        </p>
                                                                    </td>
					                         	                </tr>
					                         	   			</xsl:for-each>
					                         	   	    </tbody>
					                         	   	</table>
					                         	</p>
					                        </td>
					                    </tr>
									</xsl:when>
					            </xsl:choose>
								<xsl:choose>
					        	    <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='IMM']">
					        	        <tr>
                                            <td colspan="8">
                                                <h2 class="tablegray">
 					                             	<xsl:text>Вакцинация и иммунизация</xsl:text>
                                                </h2>
					        	                <p class="tableblack">
					        	                    <xsl:choose>
					        	                		<xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='IMM']/n1:entry/n1:substanceAdministration/n1:text">
					        	                            <table class="table-break">
					                                            <tr>
					                                                <th class="param">Дата вакцинации</th>
					        	                                    <th class="param">Иммунобиологический лекарственный препарат</th>
					        	                      	            <th class="param">Комментарий</th>
					        	                                </tr>
					        	                      	        <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='IMM']/n1:entry/n1:substanceAdministration">
					        	                                    <tr>
					        	        							    <td class="param">
                                                                            <p class="tableresult">
					        	        									    <xsl:call-template name="formatDatewithTime">
                                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                </xsl:call-template>
					        	                                            </p>
                                                                        </td>
					        	                               	        <td class="param">
                                                                            <p class="tableresult">
					        	                                                <xsl:value-of select="./n1:consumable/n1:manufacturedProduct/n1:manufacturedMaterial/n1:code/@displayName"/>
					        	                                            </p>
                                                                        </td>
					        	                               	        <td class="param">
                                                                            <p class="tableresult">
					        	                                               	<xsl:value-of select="./n1:text"/>
					        	                                            </p>
                                                                        </td>
					        	                                    </tr>
					        	                                </xsl:for-each>
					        	                      	    </table>
					        	                		</xsl:when>
					        	                		<xsl:otherwise>
					        	                            <table class="table-break">
					                                            <tr>
					                                                <th class="param">Дата вакцинации</th>
					        	                                    <th class="param">Иммунобиологический лекарственный препарат</th>
					        	                                </tr>
					        	                      	        <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='IMM']/n1:entry/n1:substanceAdministration">
					        	                                    <tr>
					        	                               	        <td class="param">
                                                                            <p class="tableresult">
					        	        						                <xsl:call-template name="formatDatewithTime">
                                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                </xsl:call-template>
					        	                                            </p>
                                                                        </td>
																        <td class="param">
                                                                            <p class="tableresult">
					        	                                                <xsl:value-of select="./n1:consumable/n1:manufacturedProduct/n1:manufacturedMaterial/n1:code/@displayName"/>
					        	                                            </p>
                                                                        </td>
					        	                                    </tr>
					        	                                </xsl:for-each>
					        	                      	    </table>
					        	                		</xsl:otherwise>
					        	                	</xsl:choose>
					                            </p>
                                            </td>
                                        </tr>
					        	    </xsl:when>
					        	</xsl:choose>
							</table>
						</xsl:when>
					</xsl:choose>
					<xsl:choose>
                        <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESLAB'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESINSTR'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESMOR'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESCONS']">
					        <table class="block-form">
					            <tr>
					                <td colspan="8">
                                        <h2 class="tablegrayhead">
                                            <xsl:text>Диагностические исследования и консультации</xsl:text>
                                        </h2>
										<xsl:choose>
                                            <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESINSTR'][not(@nullFlavor)]">
					        		            <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESINSTR']/n1:entry/n1:observation">
					             	                <tr>
					                                    <td colspan="8">
                                                            <h2 class="tablegray">
					        								    <xsl:value-of select="./n1:code/@displayName"/>
					        									<xsl:choose>
																	<xsl:when test="./n1:effectiveTime/@value">
					        											<xsl:text> (</xsl:text>
					        									        <xsl:call-template name="formatDatewithTime">
                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                        </xsl:call-template>
					        									        <xsl:text>)</xsl:text>
					        										</xsl:when>
					        			             			</xsl:choose>
                                                            </h2>
															<p class="tableblack">
					        								    <xsl:text>Приоритет: </xsl:text>
					             	               		        <xsl:value-of select="./n1:priorityCode/@displayName"/>
                                                            </p>
					                                        <p class="tableblack">
					        								    <xsl:text>Заключение: </xsl:text>
					             	               		        <xsl:value-of select="./n1:value"/>
                                                            </p>
					        								<xsl:choose>
					        			             			<xsl:when test="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name[not(@nullFlavor)]">
					        								        <p class="tableblack">
					        								            <xsl:text>Медицинский работник: </xsl:text>
																		<xsl:value-of select="./n1:performer/n1:assignedEntity/n1:code/@displayName"/>
																		<xsl:text>, </xsl:text>
																		<xsl:value-of select="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name"/>
                                                                    </p>
					        									</xsl:when>
					        			             		</xsl:choose>
					                                	</td>
					                                </tr>
					        			        </xsl:for-each>
					        				</xsl:when>
                                        </xsl:choose>
					        			<xsl:choose>
                                            <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESLAB'][not(@nullFlavor)]">
					        		            <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESLAB']/n1:entry/n1:organizer">
					             	                <tr>
					                                    <td colspan="8">
                                                            <h2 class="tablegray">
					        								    <xsl:choose>
					        										<xsl:when test="./n1:component/n1:organizer/n1:code/n1:originalText">
					        			             			        <xsl:value-of select="./n1:component/n1:organizer/n1:code/n1:originalText"/>
					        			             				</xsl:when>
					        			             			</xsl:choose>
                                                            </h2>
															<xsl:choose>
					        			             			<xsl:when test="./n1:component/n1:organizer/n1:text[not(@nullFlavor)]">
					        								        <p class="tableblack">
					             	               		                <xsl:value-of select="./n1:component/n1:organizer/n1:text"/>
                                                                    </p>
					        									</xsl:when>
					        			             		</xsl:choose>
															<xsl:choose>
					        			             			<xsl:when test="./n1:component/n1:act[n1:code/@code='901']/n1:text[not(@nullFlavor)]">
					                                                <p class="tableblack">
					        								            <xsl:text>Заключение: </xsl:text>
					             	               		                <xsl:value-of select="./n1:component/n1:act[n1:code/@code='901']/n1:text"/>
																		<xsl:choose>
																        	<xsl:when test="./n1:component/n1:act[n1:code/@code='901']/n1:author/n1:time/@value">
					        									        		<xsl:text> (</xsl:text>
					        									                <xsl:call-template name="formatDate">
                                                                                    <xsl:with-param name="newdate" select="./n1:component/n1:act[n1:code/@code='901']/n1:author/n1:time/@value"/>
                                                                                </xsl:call-template>
					        									                <xsl:text>)</xsl:text>
					        									        	</xsl:when>
					        			             			        </xsl:choose>
                                                                    </p>
																</xsl:when>
					        			             		</xsl:choose>
					        								<xsl:choose>
					        			             			<xsl:when test="./n1:component/n1:act[n1:code/@code='901']/n1:author/n1:assignedAuthor/n1:assignedPerson/n1:name[not(@nullFlavor)]">
					        								        <p class="tableblack">
					        								            <xsl:text>Автор заключения: </xsl:text>
																		<xsl:value-of select="./n1:component/n1:act[n1:code/@code='901']/n1:author/n1:assignedAuthor/n1:code/@displayName"/>
																		<xsl:text>, </xsl:text>
					             	               		                <xsl:value-of select="./n1:component/n1:act[n1:code/@code='901']/n1:author/n1:assignedAuthor/n1:assignedPerson/n1:name"/>
                                                                    </p>
					        									</xsl:when>
					        			             		</xsl:choose>
					        								<xsl:choose>
					        	                                <xsl:when test="./n1:component/n1:organizer/n1:component/n1:observation">
					                                                <xsl:choose>
					        	                                        <xsl:when test="./n1:component/n1:organizer/n1:component/n1:observation/n1:referenceRange/n1:observationRange/n1:text and ./n1:component/n1:organizer/n1:component/n1:observation/n1:interpretationCode/@code">
					                        			                    <p class="tableblack">
					                        			                    	<table class="table-break">
					                                                                <thead>
																					    <th class="param">Дата</th>
					                        			                    			<th class="param">Показатель</th>
					                                                                    <th class="param">Значение</th>
					                        	                                        <th class="param">Ед. изм.</th>
																						<th class="param">Интерпретация</th>
					                        			                    			<th class="param">Референтный интервал</th>
																						<th class="param">Материал</th>
																				        <th class="param">Оборудование</th>
																				        <th class="param">Исполнитель</th>
					                        	                                    </thead>
					                        			                    		<tbody>
					                        	                                        <xsl:for-each select="./n1:component/n1:organizer/n1:component/n1:observation">
					                        	                                            <tr>
																							    <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:call-template name="formatDatewithTime">
                                                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                                        </xsl:call-template>
					                        	                                                   	</p>
                                                                                                </td>
                                                                                                <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:value-of select="./n1:code/@displayName"/>
					                        	                                                   	</p>
                                                                                                </td>
					                        	                                               	<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    						    <xsl:choose>
					                         	   			     	                                        <xsl:when test="./n1:value[not(@nullFlavor)]">
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='ST'">
						                     	   				                                                    <xsl:value-of select="./n1:value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='PQ'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='CD'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@displayName"/>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='INT'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='BL'">
						                     	   				                                                    <xsl:if test="./n1:value/@value='true'">
						                     	   				                                                        <xsl:text>Да</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                	<xsl:if test="./n1:value/@value='false'">
						                     	   				                                                        <xsl:text>Нет</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='IVL_TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/n1:low/@value"/>
                                                                                                                    </xsl:call-template>
						                     		                                                                <xsl:choose>
                                                                                                                        <xsl:when test="./n1:value/n1:high">
						                     		                                                                    	<xsl:text> &#8212; </xsl:text>
						                     		                                                                    	<xsl:call-template name="formatDate">
                                                                                                                                <xsl:with-param name="newdate" select="./n1:value/n1:high/@value"/>
                                                                                                                            </xsl:call-template>
						                     		                                                                    </xsl:when>
						                                                                                            </xsl:choose>
						                     					                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/@value"/>
                                                                                                                    </xsl:call-template>
						                     	       			                                                </xsl:if>
						                     	   				                                            </xsl:when>
						                     								                            	<xsl:when test="./n1:value/@nullFlavor">
						                     								                            		<xsl:call-template name="formatNullFlavor">
                                                                                                                    <xsl:with-param name="nullflavor" select="./n1:value/@nullFlavor"/>
                                                                                                                </xsl:call-template>
						                     	                                                            </xsl:when>
					                         	   			     	                                    </xsl:choose>
					                        	                                                   	</p>
                                                                                                </td>
					                        			                    					<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    							<xsl:value-of select="./n1:value/n1:translation/@displayName"/>
					                                                        	                   	</p>
                                                                                                </td>
																								<td class="param">
                                                                                                    <p class="tableresult">
																										<xsl:call-template name="formatInterpretationCode">
                                                                                                            <xsl:with-param name="intercode" select="./n1:interpretationCode/@code"/>
                                                                                                        </xsl:call-template>
					                                                        	                   	</p>
                                                                                                </td>
					        		        			                    					<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    						    <xsl:value-of select="./n1:referenceRange/n1:observationRange/n1:text"/>
					                        	                                                   	</p>
                                                                                                </td>
																								<td class="param">
                                                                                                    <p class="tableresult">
																									    <xsl:choose>
					            			    			     	                                        <xsl:when test="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc[not(@nullFlavor)]">
					                        	                                                   		        <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc"/>
																											</xsl:when>
																											<xsl:otherwise>
																											    <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:code/@displayName"/>
																											</xsl:otherwise>
					            			    			     	                                    </xsl:choose>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@value"/>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@unit"/>
					                        	                                                   	</p>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:participant/n1:participantRole/n1:playingDevice">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:manufacturerModelName"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:performer/n1:assignedEntity">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:code/@displayName"/>
																                                            <xsl:text>, </xsl:text>
																                                            <xsl:value-of select="./n1:assignedPerson/n1:name"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
					                        	                                            </tr>
					                        	                                        </xsl:for-each>
																						<xsl:choose>
																	                        <xsl:when test="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text">
					                                                                            <tr>
					                                                                                <td  class="param" colspan="9">
                                                                                                        <p class="tableresult">
					                                                                                 		<xsl:value-of select="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text"/>
					                                                                                 	</p>
                                                                                                    </td>
					                                                                            </tr>
					                                                                        </xsl:when>
					                                                                    </xsl:choose>
					                        			                    		</tbody>
					                        			                    	</table>
					                        			                    </p>
					        			                                </xsl:when>
																		<xsl:when test="./n1:component/n1:organizer/n1:component/n1:observation/n1:referenceRange/n1:observationRange/n1:text">
					                        			                    <p class="tableblack">
					                        			                    	<table class="table-break">
					                                                                <thead>
																					    <th class="param">Дата</th>
					                        			                    			<th class="param">Показатель</th>
					                                                                    <th class="param">Значение</th>
					                        	                                        <th class="param">Ед. изм.</th>
					                        			                    			<th class="param">Референтный интервал</th>
																						<th class="param">Материал</th>
																				        <th class="param">Оборудование</th>
																				        <th class="param">Исполнитель</th>
					                        	                                    </thead>
					                        			                    		<tbody>
					                        	                                        <xsl:for-each select="./n1:component/n1:organizer/n1:component/n1:observation">
					                        	                                            <tr>
																							    <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:call-template name="formatDatewithTime">
                                                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                                        </xsl:call-template>
					                        	                                                   	</p>
                                                                                                </td>
                                                                                                <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:value-of select="./n1:code/@displayName"/>
					                        	                                                   	</p>
                                                                                                </td>
					                        	                                               	<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    						    <xsl:choose>
					                         	   			     	                                        <xsl:when test="./n1:value[not(@nullFlavor)]">
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='ST'">
						                     	   				                                                    <xsl:value-of select="./n1:value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='PQ'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='CD'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@displayName"/>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='INT'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='BL'">
						                     	   				                                                    <xsl:if test="./n1:value/@value='true'">
						                     	   				                                                        <xsl:text>Да</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                	<xsl:if test="./n1:value/@value='false'">
						                     	   				                                                        <xsl:text>Нет</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='IVL_TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/n1:low/@value"/>
                                                                                                                    </xsl:call-template>
						                     		                                                                <xsl:choose>
                                                                                                                        <xsl:when test="./n1:value/n1:high">
						                     		                                                                    	<xsl:text> &#8212; </xsl:text>
						                     		                                                                    	<xsl:call-template name="formatDate">
                                                                                                                                <xsl:with-param name="newdate" select="./n1:value/n1:high/@value"/>
                                                                                                                            </xsl:call-template>
						                     		                                                                    </xsl:when>
						                                                                                            </xsl:choose>
						                     					                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/@value"/>
                                                                                                                    </xsl:call-template>
						                     	       			                                                </xsl:if>
						                     	   				                                            </xsl:when>
						                     								                            	<xsl:when test="./n1:value/@nullFlavor">
						                     								                            		<xsl:call-template name="formatNullFlavor">
                                                                                                                    <xsl:with-param name="nullflavor" select="./n1:value/@nullFlavor"/>
                                                                                                                </xsl:call-template>
						                     	                                                            </xsl:when>
					                         	   			     	                                    </xsl:choose>
					                        	                                                   	</p>
                                                                                                </td>
					                        			                    					<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    							<xsl:value-of select="./n1:value/n1:translation/@displayName"/>
					                                                        	                   	</p>
                                                                                                </td>
					        		        			                    					<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    						    <xsl:value-of select="./n1:referenceRange/n1:observationRange/n1:text"/>
					                        	                                                   	</p>
                                                                                                </td>
																								<td class="param">
                                                                                                    <p class="tableresult">
																									    <xsl:choose>
					            			    			     	                                        <xsl:when test="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc[not(@nullFlavor)]">
					                        	                                                   		        <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc"/>
																											</xsl:when>
																											<xsl:otherwise>
																											    <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:code/@displayName"/>
																											</xsl:otherwise>
					            			    			     	                                    </xsl:choose>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@value"/>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@unit"/>
					                        	                                                   	</p>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:participant/n1:participantRole/n1:playingDevice">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:manufacturerModelName"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:performer/n1:assignedEntity">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:code/@displayName"/>
																                                            <xsl:text>, </xsl:text>
																                                            <xsl:value-of select="./n1:assignedPerson/n1:name"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
					                        	                                            </tr>
					                        	                                        </xsl:for-each>
																						<xsl:choose>
																	                        <xsl:when test="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text">
					                                                                            <tr>
					                                                                                <td  class="param" colspan="8">
                                                                                                        <p class="tableresult">
					                                                                                 		<xsl:value-of select="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text"/>
					                                                                                 	</p>
                                                                                                    </td>
					                                                                            </tr>
					                                                                        </xsl:when>
					                                                                    </xsl:choose>
					                        			                    		</tbody>
					                        			                    	</table>
					                        			                    </p>
					        			                                </xsl:when>
																		<xsl:when test="./n1:component/n1:organizer/n1:component/n1:observation/n1:interpretationCode/@code">
					                        			                    <p class="tableblack">
					                        			                    	<table class="table-break">
					                                                                <thead>
																					    <th class="param">Дата</th>
					                        			                    			<th class="param">Показатель</th>
					                                                                    <th class="param">Значение</th>
					                        	                                        <th class="param">Ед. изм.</th>
																						<th class="param">Интерпретация</th>
																						<th class="param">Материал</th>
																				        <th class="param">Оборудование</th>
																				        <th class="param">Исполнитель</th>
					                        	                                    </thead>
					                        			                    		<tbody>
					                        	                                        <xsl:for-each select="./n1:component/n1:organizer/n1:component/n1:observation">
					                        	                                            <tr>
																							    <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:call-template name="formatDatewithTime">
                                                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                                        </xsl:call-template>
					                        	                                                   	</p>
                                                                                                </td>
                                                                                                <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:value-of select="./n1:code/@displayName"/>
					                        	                                                   	</p>
                                                                                                </td>
					                        	                                               	<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    						    <xsl:choose>
					                         	   			     	                                        <xsl:when test="./n1:value[not(@nullFlavor)]">
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='ST'">
						                     	   				                                                    <xsl:value-of select="./n1:value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='PQ'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='CD'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@displayName"/>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='INT'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='BL'">
						                     	   				                                                    <xsl:if test="./n1:value/@value='true'">
						                     	   				                                                        <xsl:text>Да</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                	<xsl:if test="./n1:value/@value='false'">
						                     	   				                                                        <xsl:text>Нет</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='IVL_TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/n1:low/@value"/>
                                                                                                                    </xsl:call-template>
						                     		                                                                <xsl:choose>
                                                                                                                        <xsl:when test="./n1:value/n1:high">
						                     		                                                                    	<xsl:text> &#8212; </xsl:text>
						                     		                                                                    	<xsl:call-template name="formatDate">
                                                                                                                                <xsl:with-param name="newdate" select="./n1:value/n1:high/@value"/>
                                                                                                                            </xsl:call-template>
						                     		                                                                    </xsl:when>
						                                                                                            </xsl:choose>
						                     					                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/@value"/>
                                                                                                                    </xsl:call-template>
						                     	       			                                                </xsl:if>
						                     	   				                                            </xsl:when>
						                     								                            	<xsl:when test="./n1:value/@nullFlavor">
						                     								                            		<xsl:call-template name="formatNullFlavor">
                                                                                                                    <xsl:with-param name="nullflavor" select="./n1:value/@nullFlavor"/>
                                                                                                                </xsl:call-template>
						                     	                                                            </xsl:when>
					                         	   			     	                                    </xsl:choose>
					                        	                                                   	</p>
                                                                                                </td>
					                        			                    					<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    							<xsl:value-of select="./n1:value/n1:translation/@displayName"/>
					                                                        	                   	</p>
                                                                                                </td>
																								<td class="param">
                                                                                                    <p class="tableresult">
																										<xsl:call-template name="formatInterpretationCode">
                                                                                                            <xsl:with-param name="intercode" select="./n1:interpretationCode/@code"/>
                                                                                                        </xsl:call-template>
					                                                        	                   	</p>
                                                                                                </td>
																								<td class="param">
                                                                                                    <p class="tableresult">
																									    <xsl:choose>
					            			    			     	                                        <xsl:when test="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc[not(@nullFlavor)]">
					                        	                                                   		        <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc"/>
																											</xsl:when>
																											<xsl:otherwise>
																											    <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:code/@displayName"/>
																											</xsl:otherwise>
					            			    			     	                                    </xsl:choose>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@value"/>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@unit"/>
					                        	                                                   	</p>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:participant/n1:participantRole/n1:playingDevice">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:manufacturerModelName"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:performer/n1:assignedEntity">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:code/@displayName"/>
																                                            <xsl:text>, </xsl:text>
																                                            <xsl:value-of select="./n1:assignedPerson/n1:name"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
					                        	                                            </tr>
					                        	                                        </xsl:for-each>
																						<xsl:choose>
																	                        <xsl:when test="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text">
					                                                                            <tr>
					                                                                                <td  class="param" colspan="8">
                                                                                                        <p class="tableresult">
					                                                                                 		<xsl:value-of select="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text"/>
					                                                                                 	</p>
                                                                                                    </td>
					                                                                            </tr>
					                                                                        </xsl:when>
					                                                                    </xsl:choose>
					                        			                    		</tbody>
					                        			                    	</table>
					                        			                    </p>
					        			                                </xsl:when>
					        			                                <xsl:otherwise>
					                        			                    <p class="tableblack">
					                        			                    	<table class="table-break">
					                                                                <thead>
																					    <th class="param">Дата</th>
					                        			                    			<th class="param">Показатель</th>
					                                                                    <th class="param">Значение</th>
					                        	                                        <th class="param">Ед. изм.</th>
																						<th class="param">Материал</th>
																				        <th class="param">Оборудование</th>
																				        <th class="param">Исполнитель</th>
					                        	                                    </thead>
					                        			                    		<tbody>
					                        	                                        <xsl:for-each select="./n1:component/n1:organizer/n1:component/n1:observation">
					                        	                                            <tr>
																							    <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:call-template name="formatDatewithTime">
                                                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                                        </xsl:call-template>
					                        	                                                   	</p>
                                                                                                </td>
                                                                                                <td class="param">
                                                                                                    <p class="tableresult">
					                        	                                                   		<xsl:value-of select="./n1:code/@displayName"/>
					                        	                                                   	</p>
                                                                                                </td>
					                        	                                               	<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    						    <xsl:choose>
					                         	   			     	                                        <xsl:when test="./n1:value[not(@nullFlavor)]">
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='ST'">
						                     	   				                                                    <xsl:value-of select="./n1:value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='PQ'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='CD'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@displayName"/>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='INT'">
						                     	   				                                                    <xsl:value-of select="./n1:value/@value"/>
						                     	   				                                                </xsl:if>
						                     	   				                                                <xsl:if test="./n1:value/@xsi:type='BL'">
						                     	   				                                                    <xsl:if test="./n1:value/@value='true'">
						                     	   				                                                        <xsl:text>Да</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                	<xsl:if test="./n1:value/@value='false'">
						                     	   				                                                        <xsl:text>Нет</xsl:text>
						                     	   				                                                    </xsl:if>
						                     	   				                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='IVL_TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/n1:low/@value"/>
                                                                                                                    </xsl:call-template>
						                     		                                                                <xsl:choose>
                                                                                                                        <xsl:when test="./n1:value/n1:high">
						                     		                                                                    	<xsl:text> &#8212; </xsl:text>
						                     		                                                                    	<xsl:call-template name="formatDate">
                                                                                                                                <xsl:with-param name="newdate" select="./n1:value/n1:high/@value"/>
                                                                                                                            </xsl:call-template>
						                     		                                                                    </xsl:when>
						                                                                                            </xsl:choose>
						                     					                                                </xsl:if>
						                     								                                    <xsl:if test="./n1:value/@xsi:type='TS'">
						                     					                                                    <xsl:call-template name="formatDate">
                                                                                                                        <xsl:with-param name="newdate" select="./n1:value/@value"/>
                                                                                                                    </xsl:call-template>
						                     	       			                                                </xsl:if>
						                     	   				                                            </xsl:when>
						                     								                            	<xsl:when test="./n1:value/@nullFlavor">
						                     								                            		<xsl:call-template name="formatNullFlavor">
                                                                                                                    <xsl:with-param name="nullflavor" select="./n1:value/@nullFlavor"/>
                                                                                                                </xsl:call-template>
						                     	                                                            </xsl:when>
					                         	   			     	                                    </xsl:choose>
					                        	                                                   	</p>
                                                                                                </td>
					                        			                    					<td class="param">
                                                                                                    <p class="tableresult">
					                        			                    							<xsl:value-of select="./n1:value/n1:translation/@displayName"/>
					                                                        	                   	</p>
                                                                                                </td>
																								<td class="param">
                                                                                                    <p class="tableresult">
																									    <xsl:choose>
					            			    			     	                                        <xsl:when test="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc[not(@nullFlavor)]">
					                        	                                                   		        <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:desc"/>
																											</xsl:when>
																											<xsl:otherwise>
																											    <xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:code/@displayName"/>
																											</xsl:otherwise>
					            			    			     	                                    </xsl:choose>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@value"/>
																						        		<xsl:text> </xsl:text>
																						        		<xsl:value-of select="./n1:specimen/n1:specimenRole/n1:specimenPlayingEntity/n1:quantity/@unit"/>
					                        	                                                   	</p>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:participant/n1:participantRole/n1:playingDevice">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:manufacturerModelName"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
																						        <td class="param">
																						            <xsl:for-each select="./n1:performer/n1:assignedEntity">
                                                                                                        <p class="tableresult">
					                        	                                                   	    	<xsl:value-of select="./n1:code/@displayName"/>
																                                            <xsl:text>, </xsl:text>
																                                            <xsl:value-of select="./n1:assignedPerson/n1:name"/>
					                        	                                                   	    </p>
																						        	</xsl:for-each>
                                                                                                </td>
					                        	                                            </tr>
					                        	                                        </xsl:for-each>
																						<xsl:choose>
																	                        <xsl:when test="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text">
					                                                                            <tr>
					                                                                                <td  class="param" colspan="7">
                                                                                                        <p class="tableresult">
					                                                                                 		<xsl:value-of select="./n1:component/n1:organizer/n1:component/n1:act[n1:code/@code='900']/n1:text"/>
					                                                                                 	</p>
                                                                                                    </td>
					                                                                            </tr>
					                                                                        </xsl:when>
					                                                                    </xsl:choose>
					                        			                    		</tbody>
					                        			                    	</table>
					                        			                    </p>
					        			                                </xsl:otherwise>
					                                                </xsl:choose>
					                                        	</xsl:when>
					                                        </xsl:choose>
					                                	</td>
					                                </tr>
					        			        </xsl:for-each>
					        				</xsl:when>
                                        </xsl:choose>
					        			<xsl:choose>
                                            <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESMOR'][not(@nullFlavor)]">
					        		            <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESMOR']/n1:entry/n1:observation">
					             	                <tr>
					                                    <td colspan="8">
                                                            <h2 class="tablegray">
																<xsl:choose>
																	<xsl:when test="./n1:code[not(@nullFlavor)]">
					        											<xsl:value-of select="./n1:code/@displayName"/>
					        										</xsl:when>
																	<xsl:otherwise>
																	    <xsl:text>Иммуногистохимическое исследование</xsl:text>
																	</xsl:otherwise>
					        			             			</xsl:choose>
					        									<xsl:choose>
																	<xsl:when test="./n1:effectiveTime/@value">
					        											<xsl:text> (</xsl:text>
					        									        <xsl:call-template name="formatDatewithTime">
                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                        </xsl:call-template>
					        									        <xsl:text>)</xsl:text>
					        										</xsl:when>
					        			             			</xsl:choose>
                                                            </h2>
															<p class="tableblack">
					        								    <xsl:text>Приоритет: </xsl:text>
					             	               		        <xsl:value-of select="./n1:priorityCode/@displayName"/>
                                                            </p>
					                                        <p class="tableblack">
					        								    <xsl:text>Заключение: </xsl:text>
					             	               		        <xsl:value-of select="./n1:value"/>
                                                            </p>
					        								<xsl:choose>
					        			             			<xsl:when test="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name[not(@nullFlavor)]">
					        								        <p class="tableblack">
					        								            <xsl:text>Медицинский работник: </xsl:text>
																		<xsl:value-of select="./n1:performer/n1:assignedEntity/n1:code/@displayName"/>
																		<xsl:text>, </xsl:text>
																		<xsl:value-of select="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name"/>
                                                                    </p>
					        									</xsl:when>
					        			             		</xsl:choose>
					                                	</td>
					                                </tr>
					        			        </xsl:for-each>
					        				</xsl:when>
                                        </xsl:choose>
										<xsl:choose>
					                        <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESCONS'][not(@nullFlavor)]">
							        	        <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROC']/n1:component/n1:section[n1:code/@code='RESCONS']/n1:entry/n1:observation">
			                                        <tr>
                                                        <td colspan="8">
                                                            <h2 class="tablegray">
                                                                <xsl:value-of select="./n1:code/@displayName"/>
																<xsl:text>, </xsl:text>
																<xsl:value-of select="./n1:performer/n1:assignedEntity/n1:code/@displayName"/>
										    				    <xsl:text>, </xsl:text>
						                                        <xsl:value-of select="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name"/>
																<xsl:choose>
																	<xsl:when test="./n1:effectiveTime/@value">
					        											<xsl:text> (</xsl:text>
					        									        <xsl:call-template name="formatDatewithTime">
                                                                            <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                        </xsl:call-template>
					        									        <xsl:text>)</xsl:text>
					        										</xsl:when>
					        			             			</xsl:choose>
                                                            </h2>
															<p class="tableblack">
					    	           	    	    			<xsl:value-of select="./n1:value"/>
					    	           	    	    		</p>
															<p class="tableblack">
					        								    <xsl:text>Приоритет: </xsl:text>
					             	               		        <xsl:value-of select="./n1:priorityCode/@displayName"/>
                                                            </p>
															<p class="tableblack">
										    				    <xsl:text>Состояние: </xsl:text>
					    	           	    	    			<xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1006']/n1:code/@displayName"/>
					    	           	    	    		</p>
										    				<xsl:choose>
                                                                <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='805']/n1:value[not(@nullFlavor)]">
										    					    <p class="tableblack">
                                                                        <xsl:text>Протокол консультации: </xsl:text>
						                                                <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='805']/n1:value"/>
										    						</p>
                                                                </xsl:when>
                                                            </xsl:choose>
										    				<p class="tableblack">
										    				    <xsl:text>Заключение: </xsl:text>
					    	           	    	    			<xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='806']/n1:value"/>
					    	           	    	    		</p>
										    				<xsl:choose>
                                                                <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='807']/n1:value[not(@nullFlavor)]">
										    					    <p class="tableblack">
                                                                        <xsl:text>Рекомендации: </xsl:text>
						                                                <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='807']/n1:value"/>
										    						</p>
                                                                </xsl:when>
                                                            </xsl:choose>
															<xsl:choose>
                                                                <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='808']/n1:value[not(@nullFlavor)]">
										    					    <p class="tableblack">
                                                                        <xsl:text>Выявленные патологии: </xsl:text>
						                                                <xsl:value-of select="./n1:entryRelationship[n1:observation/n1:code/@code='808'][1]/n1:observation[n1:code/@code='808']/n1:value/@displayName"/>
																		<xsl:for-each select="./n1:entryRelationship[n1:observation/n1:code/@code='808'][position()>1]/n1:observation[n1:code/@code='808']">
																		    <xsl:text>; </xsl:text>
						                                                    <xsl:value-of select="./n1:value/@displayName"/>
																		</xsl:for-each>
										    						</p>
                                                                </xsl:when>
                                                            </xsl:choose>
															<xsl:choose>
                                                                <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='809']/n1:value[not(@nullFlavor)]">
										    					    <p class="tableblack">
                                                                        <xsl:text>Шифр по МКБ-10: </xsl:text>
																		<xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='809']/n1:value/@code"/>
																		<xsl:text> </xsl:text>
						                                                <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='809']/n1:value/@displayName"/>
										    						</p>
                                                                </xsl:when>
                                                            </xsl:choose>
															<xsl:choose>
                                                                <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='810']/n1:value[not(@nullFlavor)]">
										    					    <p class="tableblack">
                                                                        <xsl:text>Результат консультации: </xsl:text>
						                                                <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='810']/n1:value/@displayName"/>
										    						</p>
                                                                </xsl:when>
                                                            </xsl:choose>
                                                        </td>
                                                    </tr>
							        	    	</xsl:for-each>
					    	           	    </xsl:when>
					    	            </xsl:choose>
					        	    </td>
					            </tr>
					        </table>
					    </xsl:when>
                    </xsl:choose>
					<xsl:choose>
						<xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='DRUG'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='NONDRUG'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUR']">
					        <table class="block-form">
					        	<xsl:choose>
					                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='DRUG'][not(@nullFlavor)]">
			                            <tr>
                                            <td colspan="8">
                                                <h2 class="tablegray">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='DRUG']/n1:title"/>
                                                </h2>
												<p class="tableblack">
													<table class="table-break">
					    	       				        <tr>
														    <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='DRUG']/n1:text/n1:table/n1:tbody/n1:tr/n1:th">
															    <th class="param">
														            <xsl:value-of select="."/>
                                                                </th>
															</xsl:for-each>
														</tr>
														<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='DRUG']/n1:text/n1:table/n1:tbody/n1:tr[position()>1]">
														    <tr>
														        <xsl:for-each select="./n1:td">
														    	    <td class="param">
                                                                        <p class="tableresult">
														                    <xsl:value-of select="."/>
														    		    </p>
                                                                    </td>
														    	</xsl:for-each>
														    </tr>
														</xsl:for-each>
													</table>
					    	       				</p>
                                            </td>
                                        </tr>
					    	        </xsl:when>
					    	    </xsl:choose>
							    <xsl:choose>
					                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='NONDRUG'][not(@nullFlavor)]">
			                            <tr>
                                            <td colspan="8">
                                                <h2 class="tablegray">
                                                    <xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='NONDRUG']/n1:title"/>
                                                </h2>
											    <p class="tableblack">
													<table class="table-break">
					    	       				        <tr>
														    <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='NONDRUG']/n1:text/n1:table/n1:tbody/n1:tr/n1:th">
															    <th class="param">
														            <xsl:value-of select="."/>
                                                                </th>
															</xsl:for-each>
														</tr>
														<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUM']/n1:component/n1:section[n1:code/@code='NONDRUG']/n1:text/n1:table/n1:tbody/n1:tr[position()>1]">
														    <tr>
														        <xsl:for-each select="./n1:td">
														    	    <td class="param">
                                                                        <p class="tableresult">
														                    <xsl:value-of select="."/>
														    		    </p>
                                                                    </td>
														    	</xsl:for-each>
														    </tr>
														</xsl:for-each>
													</table>
					    	       				</p>
                                            </td>
                                        </tr>
					    	       	</xsl:when>
					    	    </xsl:choose>
								<xsl:choose>
					                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUR'][not(@nullFlavor)]">
							            <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SUR']/n1:entry/n1:procedure">
			                                <tr>
                                                <td colspan="8">
                                                    <h2 class="tablegray">
													    <xsl:choose>
															<xsl:when test="./n1:text[not(@nullFlavor)]">
					        									<xsl:value-of select="./n1:text"/>
					        								</xsl:when>
															<xsl:otherwise>
															    <xsl:value-of select="./n1:code/@displayName"/>
															</xsl:otherwise>
					        			             	</xsl:choose>
									                    <xsl:choose>
									                    	<xsl:when test="./n1:effectiveTime/@value">
					        				                    <xsl:text> (</xsl:text>
					        		                            <xsl:call-template name="formatDatewithTime">
                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                </xsl:call-template>
					        		                            <xsl:text>)</xsl:text>
					        			                    </xsl:when>
					        	        			    </xsl:choose>
                                                    </h2>
													<xsl:choose>
                                                        <xsl:when test="./n1:participant/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1048']/n1:code[not(@nullFlavor)]">
												            <p class="tableblack">
                                                                <xsl:text>Аппаратура: </xsl:text>
						                                        <xsl:value-of select="./n1:participant[n1:participantRole/n1:playingDevice/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1048'][1]/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1048']/n1:code/@displayName"/>
											                    <xsl:for-each select="./n1:participant[n1:participantRole/n1:playingDevice/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1048'][position()>1]/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1048']">
											                        <xsl:text>; </xsl:text>
						                                            <xsl:value-of select="./n1:code/@displayName"/>
											                    </xsl:for-each>
													        </p>
                                                        </xsl:when>
                                                    </xsl:choose>
													<xsl:choose>
                                                        <xsl:when test="./n1:participant/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079']/n1:code[not(@nullFlavor)]">
												            <p class="tableblack">
                                                                <xsl:text>Устройства и импланты: </xsl:text>
						                                        <xsl:value-of select="./n1:participant[n1:participantRole/n1:playingDevice/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079'][1]/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079']/n1:code/@displayName"/>
											                    <xsl:for-each select="./n1:participant[n1:participantRole/n1:playingDevice/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079'][position()>1]/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079']">
											                        <xsl:text>; </xsl:text>
						                                            <xsl:value-of select="./n1:code/@displayName"/>
											                    </xsl:for-each>
													        </p>
                                                        </xsl:when>
                                                    </xsl:choose>
													<xsl:choose>
                                                        <xsl:when test="./n1:entryRelationship/n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033']/n1:code[not(@nullFlavor)]">
												            <p class="tableblack">
                                                                <xsl:text>Анестезия: </xsl:text>
						                                        <xsl:value-of select="./n1:entryRelationship[n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033'][1]/n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033']/n1:code/@displayName"/>
											                    <xsl:for-each select="./n1:entryRelationship[n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033'][position()>1]/n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033']">
											                        <xsl:text>; </xsl:text>
						                                            <xsl:value-of select="./n1:code/@displayName"/>
											                    </xsl:for-each>
													        </p>
                                                        </xsl:when>
                                                    </xsl:choose>
								                    <xsl:choose>
					        			            	<xsl:when test="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name[not(@nullFlavor)]">
					        						        <p class="tableblack">
					        						            <xsl:text>Медицинский работник: </xsl:text>
															    <xsl:value-of select="./n1:performer/n1:assignedEntity/n1:code/@displayName"/>
															    <xsl:text>, </xsl:text>
															    <xsl:value-of select="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name"/>
                                                            </p>
					        						    </xsl:when>
					        			            </xsl:choose>
                                                </td>
                                            </tr>
							      	    </xsl:for-each>
					    	        </xsl:when>
					    	    </xsl:choose>
					        </table>
						</xsl:when>
					</xsl:choose>
					<xsl:choose>
                        <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROCEDURE'] or /n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SERVICES']">
							<table class="block-form">
							    <xsl:choose>
					                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROCEDURE'][not(@nullFlavor)]">
							            <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='PROCEDURE']/n1:entry/n1:procedure">
			                                <tr>
                                                <td colspan="8">
                                                    <h2 class="tablegray">
													    <xsl:choose>
															<xsl:when test="./n1:text[not(@nullFlavor)]">
					        									<xsl:value-of select="./n1:text"/>
					        								</xsl:when>
															<xsl:otherwise>
															    <xsl:value-of select="./n1:code/@displayName"/>
															</xsl:otherwise>
					        			             	</xsl:choose>
									                    <xsl:choose>
									                    	<xsl:when test="./n1:effectiveTime/@value">
					        				                    <xsl:text> (</xsl:text>
					        		                            <xsl:call-template name="formatDatewithTime">
                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                </xsl:call-template>
					        		                            <xsl:text>)</xsl:text>
					        			                    </xsl:when>
					        	        			    </xsl:choose>
                                                    </h2>
													<xsl:choose>
                                                        <xsl:when test="./n1:participant/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079']/n1:code[not(@nullFlavor)]">
												            <p class="tableblack">
                                                                <xsl:text>Устройства и импланты: </xsl:text>
						                                        <xsl:value-of select="./n1:participant[n1:participantRole/n1:playingDevice/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079'][1]/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079']/n1:code/@displayName"/>
											                    <xsl:for-each select="./n1:participant[n1:participantRole/n1:playingDevice/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079'][position()>1]/n1:participantRole/n1:playingDevice[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1079']">
											                        <xsl:text>; </xsl:text>
						                                            <xsl:value-of select="./n1:code/@displayName"/>
											                    </xsl:for-each>
													        </p>
                                                        </xsl:when>
                                                    </xsl:choose>
													<xsl:choose>
                                                        <xsl:when test="./n1:entryRelationship/n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033']/n1:code[not(@nullFlavor)]">
												            <p class="tableblack">
                                                                <xsl:text>Анестезия: </xsl:text>
						                                        <xsl:value-of select="./n1:entryRelationship[n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033'][1]/n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033']/n1:code/@displayName"/>
											                    <xsl:for-each select="./n1:entryRelationship[n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug/n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033'][position()>1]/n1:substanceAdministration/n1:consumable/n1:manufacturedProduct/n1:manufacturedLabeledDrug[n1:code/@codeSystem='1.2.643.5.1.13.13.11.1033']">
											                        <xsl:text>; </xsl:text>
						                                            <xsl:value-of select="./n1:code/@displayName"/>
											                    </xsl:for-each>
													        </p>
                                                        </xsl:when>
                                                    </xsl:choose>
								                    <xsl:choose>
					        			            	<xsl:when test="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name[not(@nullFlavor)]">
					        						        <p class="tableblack">
					        						            <xsl:text>Медицинский работник: </xsl:text>
															    <xsl:value-of select="./n1:performer/n1:assignedEntity/n1:code/@displayName"/>
															    <xsl:text>, </xsl:text>
															    <xsl:value-of select="./n1:performer/n1:assignedEntity/n1:assignedPerson/n1:name"/>
                                                            </p>
					        						    </xsl:when>
					        			            </xsl:choose>
                                                </td>
                                            </tr>
							      	    </xsl:for-each>
					    	        </xsl:when>
					    	    </xsl:choose>
								<xsl:choose>
					                <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SERVICES']">
			                            <tr>
                                            <td colspan="8">
                                                <h2 class="tablegray">
                                                    <xsl:text>Оказанные услуги</xsl:text>
                                                </h2>
					                            <xsl:choose>
						                            <xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SERVICES']/n1:entry/n1:act/n1:text">
										                <p class="tableblack">
										                	<table class="table-break">
					                                            <tr>
					                                                <th class="paramuslugi">Дата оказания услуги</th>
						                                            <th class="paramuslugi">Оказанная медицинская услуга</th>
						                                			<th class="paramuslugi">Примечание</th>
						                                        </tr>
						                                		<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SERVICES']/n1:entry/n1:act">
						                                            <tr>
								                        	            <td class="param">
                                                                            <p class="tableresultuslugi">
								                        			   	        <xsl:call-template name="formatDatewithTime">
                                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                </xsl:call-template>
						                                                    </p>
                                                                        </td>
								                        	            <td class="param">
								                        	            	<p class="tableresultuslugi">
								                        			    	    <xsl:value-of select="./n1:code/@code"/>
										                		                <xsl:text> </xsl:text>
										                		                <xsl:value-of select="./n1:code/@displayName"/>
						                                                    </p>
								                        	            </td>
								                        	            <td class="param">
                                                                            <p class="tableresultuslugi">
						                                                       	<xsl:value-of select="./n1:text"/>
						                                                    </p>
                                                                        </td>
								                        	        </tr>
						                                        </xsl:for-each>
						                                    </table>
										                </p>
										        	</xsl:when>
										        	<xsl:otherwise>
										                <p class="tableblack">
										                	<table class="table-break">
					                                            <tr>
					                                                <th class="paramuslugi" width="20%">Дата оказания услуги</th>
						                                            <th class="paramuslugi">Оказанная медицинская услуга</th>
						                                        </tr>
						                                		<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='SERVICES']/n1:entry/n1:act">
						                                            <tr>
								                        	            <td class="param">
                                                                            <p class="tableresultuslugi" width="20%">
								                        			   	        <xsl:call-template name="formatDatewithTime">
                                                                                    <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                                </xsl:call-template>
						                                                    </p>
                                                                        </td>
								                        	            <td class="param">
								                        	            	<p class="tableresultuslugi">
								                        			    	    <xsl:value-of select="./n1:code/@code"/>
										                		                <xsl:text> </xsl:text>
										                		                <xsl:value-of select="./n1:code/@displayName"/>
						                                                    </p>
								                        	            </td>
								                        	        </tr>
						                                        </xsl:for-each>
						                                    </table>
										                </p>
										        	</xsl:otherwise>
					                            </xsl:choose>
                                            </td>
                                        </tr>
					        		</xsl:when>
					        	</xsl:choose>
							</table>
						</xsl:when>
                    </xsl:choose>
					<xsl:choose>
						<xsl:when test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='LINKDOCS']">
						    <table class="block-form">
						        <tr>
								 	<td colspan="8">
								 		<h2 class="tablegrayhead">
										    <xsl:text>Связанные документы</xsl:text>
										</h2>
								        <xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:code/@code='LINKDOCS']/n1:entry/n1:act">
					                        <tr>
								         		<td colspan="8">
								         		    <h2 class="tablegray">
                                                        <xsl:value-of select="./n1:code/@displayName"/>
								        	            <xsl:choose>
								         				    <xsl:when test="./n1:effectiveTime/@value">
								         				        <xsl:text> от </xsl:text>
								         				        <xsl:call-template name="formatDate">
                                                                     <xsl:with-param name="newdate" select="./n1:effectiveTime/@value"/>
                                                                </xsl:call-template>
								         					</xsl:when>
								         				</xsl:choose>
								         				<xsl:choose>
								         				    <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='11002']/n1:value[not(@nullFlavor)]">
								         				        <xsl:text> (</xsl:text>
								         				        <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='11002']/n1:value"/>
								        			            <xsl:text>)</xsl:text>
								         					</xsl:when>
								         				</xsl:choose>
								         				<xsl:choose>
								         				    <xsl:when test="./n1:entryRelationship/n1:observation[n1:code/@code='11003']/n1:value[not(@nullFlavor)]">
								         				        <xsl:text> № </xsl:text>
								         				        <xsl:value-of select="./n1:entryRelationship/n1:observation[n1:code/@code='11003']/n1:value"/>
								         					</xsl:when>
								         				</xsl:choose>
                                                    </h2>
                                                    <p class="tableblack">
                                                        <xsl:value-of select="./n1:text"/>
                                                    </p>
                                                </td>
								         	</tr>
								        </xsl:for-each>
									</td>
								</tr>
							</table>
						</xsl:when>
					</xsl:choose>
					<table class="end-block-form">
			            <tr>
                            <td colspan="4">
                                <h2 class="tablegray">
                                    <xsl:text>Документ составил</xsl:text>
                                </h2>
					    		<p class="tableblack">
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:author/n1:assignedAuthor/n1:code[not(@nullFlavor)]">
										    <xsl:value-of select="/n1:ClinicalDocument/n1:author/n1:assignedAuthor/n1:code/@displayName"/>
											<xsl:text>, </xsl:text>
                                            <xsl:value-of select="/n1:ClinicalDocument/n1:author/n1:assignedAuthor/n1:assignedPerson/n1:name"/>
                                        </xsl:when>
                                    </xsl:choose>
                                </p>
                            </td>
							<xsl:choose>
                                <xsl:when test="/n1:ClinicalDocument/n1:effectiveTime[not(@nullFlavor)]">
                                    <td colspan="4">
                                        <h2 class="tablegray">
                                            <xsl:text>Дата составления</xsl:text>
                                        </h2>
					    	        	<p class="tableblack">
                                            <xsl:choose>
                                                <xsl:when test="/n1:ClinicalDocument/n1:effectiveTime[not(@nullFlavor)]">
                                                    <xsl:call-template name="formatDate">
                                                        <xsl:with-param name="newdate" select="/n1:ClinicalDocument/n1:effectiveTime/@value"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                            </xsl:choose>
                                        </p>
                                    </td>
								</xsl:when>
                            </xsl:choose>
                        </tr>
						<tr>
                            <td colspan="4">
                                <h2 class="tablegray">
                                    <xsl:text>Документ заверил</xsl:text>
                                </h2>
								<p class="tableblack">
                                    <xsl:choose>
                                        <xsl:when test="/n1:ClinicalDocument/n1:legalAuthenticator/n1:assignedEntity/n1:code[not(@nullFlavor)]">
					    					<xsl:value-of select="/n1:ClinicalDocument/n1:legalAuthenticator/n1:assignedEntity/n1:code/@displayName"/>
											<xsl:text>, </xsl:text>
											<xsl:value-of select="/n1:ClinicalDocument/n1:legalAuthenticator/n1:assignedEntity/n1:assignedPerson/n1:name"/>
                                        </xsl:when>
                                    </xsl:choose>
                                </p>
                            </td>
                        </tr>
                    </table>
            </body>
		</html>
	</xsl:template>
	<xsl:template name="getR">
        <xsl:param name="templateId"/>
        <xsl:variable name="templateIdLength" select="string-length($templateId)"/>
        <xsl:value-of select="substring ($templateId, $templateIdLength, 1)"/>
    </xsl:template>
    <xsl:template name="getYear">
        <xsl:param name="date"/>
        <xsl:variable name="dateLength" select="string-length($date)"/>
                <xsl:value-of select="substring ($date, 1, 4)"/>
    </xsl:template>
    <xsl:template name="getMonth">
        <xsl:param name="date"/>
        <xsl:variable name="dateLength" select="string-length($date)"/>
        <xsl:variable name="month" select="substring ($date, 5, 2)"/>
        <xsl:choose>
            <xsl:when test="$dateLength>=6">
                <xsl:value-of select="substring ($date, 5, 2)"/>
			    <xsl:text>&#46;</xsl:text>
			</xsl:when>
        </xsl:choose>
    </xsl:template>
	<xsl:template name="getTextMonth">
        <xsl:param name="date"/>
        <xsl:variable name="dateLength" select="string-length($date)"/>
        <xsl:variable name="month" select="substring ($date, 5, 2)"/>
        <xsl:choose>
            <xsl:when test="$dateLength>=6">
                <xsl:choose>
                    <xsl:when test="$month='01'">
                        <xsl:text>января</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='02'">
                        <xsl:text>Февраля</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='03'">
                        <xsl:text>марта</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='04'">
                        <xsl:text>апреля</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='05'">
                        <xsl:text>мая</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='06'">
                        <xsl:text>июня</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='07'">
                        <xsl:text>июля</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='08'">
                        <xsl:text>августа</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='09'">
                        <xsl:text>сентября</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='10'">
                        <xsl:text>октября</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='11'">
                        <xsl:text>ноября</xsl:text>
                    </xsl:when>
                    <xsl:when test="$month='12'">
                        <xsl:text>декабря</xsl:text>
                    </xsl:when>
                </xsl:choose>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getDay">
        <xsl:param name="date"/>
        <xsl:variable name="dateLength" select="string-length($date)"/>
        <xsl:choose>
            <xsl:when test="$dateLength>=8">
                <xsl:value-of select="substring ($date, 7, 2)"/>
				<xsl:text>&#46;</xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getName">
        <xsl:param name="name"/>
        <xsl:choose>
            <xsl:when test="$name/n1:family">
                <xsl:if test="$name/n1:prefix">
                    <xsl:value-of select="$name/n1:prefix"/>
                    <xsl:text></xsl:text>
                </xsl:if>
                <xsl:value-of select="$name/n1:family"/>
                <xsl:text></xsl:text>
                <xsl:value-of select="$name/n1:given[1]"/>
                <xsl:text></xsl:text>
                <xsl:value-of select="$name/n1:given[2]"/>
                <xsl:text></xsl:text>
                <xsl:if test="$name/n1:suffix">
                    <xsl:value-of select="$name/n1:suffix"/>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$name"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getHour">
        <xsl:param name="date"/>
        <xsl:variable name="dateLength" select="string-length($date)"/>
        <xsl:choose>
            <xsl:when test="$dateLength>=10">
			    <xsl:text> </xsl:text>
                <xsl:value-of select="substring ($date, 9, 2)"/>
				<xsl:text>&#58;</xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getMinute">
        <xsl:param name="date"/>
        <xsl:variable name="dateLength" select="string-length($date)"/>
        <xsl:choose>
            <xsl:when test="$dateLength>=12">
                <xsl:value-of select="substring ($date, 11, 2)"/>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getSecond">
        <xsl:param name="date"/>
        <xsl:variable name="dateLength" select="string-length($date)"/>
        <xsl:choose>
            <xsl:when test="$dateLength>=14">
                <xsl:value-of select="substring ($date, 13, 5)"/>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getMKB">
        <xsl:param name="code"/>
        <xsl:param name="pos"/>
        <xsl:value-of select="substring ($code, $pos, 1)"/>
    </xsl:template>
	<xsl:template name="getAges">
	    <xsl:param name="age"/>
		<xsl:variable name="agestr" select="string($age)"/>
        <xsl:variable name="agebefore100" select="substring($agestr, 2, 1)"/>
		<xsl:variable name="ageafter100" select="substring($agestr, 3, 1)"/>
		<xsl:variable name="age1234" select="substring($agestr, 1, 1)"/>
            <xsl:if test="string-length($agestr)=2">
                <xsl:choose>
                    <xsl:when test="($agebefore100='1') and (number($agestr)&gt;20)">
                        <xsl:text> год</xsl:text>
                    </xsl:when>
					<xsl:when test="(($agebefore100='2') or ($agebefore100='3') or ($agebefore100='4')) and (number($agestr)&gt;20)">
                        <xsl:text> года</xsl:text>
                    </xsl:when>
			        <xsl:otherwise>
                        <xsl:text> лет</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
			</xsl:if>
			<xsl:if test="string-length($agestr)=1">
                <xsl:choose>
                    <xsl:when test="$age1234='1'">
                        <xsl:text> год</xsl:text>
                    </xsl:when>
					<xsl:when test="($age1234='2') or ($age1234='3') or ($age1234='4')">
                        <xsl:text> года</xsl:text>
                    </xsl:when>
			        <xsl:otherwise>
                        <xsl:text> лет</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
			</xsl:if>
			<xsl:if test="(number($agestr)&gt;100) and (number($agestr)&lt;110)">
                 <xsl:choose>
                     <xsl:when test="($ageafter100='1')">
                         <xsl:text> год</xsl:text>
                     </xsl:when>
					 <xsl:when test="($ageafter100='2') or ($ageafter100='3') or ($ageafter100='4')">
                         <xsl:text> года</xsl:text>
                     </xsl:when>
			        <xsl:otherwise>
                        <xsl:text> лет</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:if>
			<xsl:if test="(number($agestr)&gt;120)">
                 <xsl:choose>
				 <xsl:when test="($ageafter100='1')">
                         <xsl:text> год</xsl:text>
                     </xsl:when>
					 <xsl:when test="($ageafter100='2') or ($ageafter100='3') or ($ageafter100='4')">
                        <xsl:text> года</xsl:text>
                     </xsl:when>
			        <xsl:otherwise>
                        <xsl:text> лет</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:if>
	</xsl:template>
    <xsl:template name="getAge">
        <xsl:param name="birthdate"/>
        <xsl:param name="deathdate"/>
        <xsl:param name="withtext"/>
        <xsl:variable name="bDay" select="substring ($birthdate, 7, 2)"/>
        <xsl:variable name="dDay" select="substring ($deathdate, 7, 2)"/>
        <xsl:variable name="bMonth" select="substring ($birthdate, 5, 2)"/>
        <xsl:variable name="dMonth" select="substring ($deathdate, 5, 2)"/>
        <xsl:variable name="bYear" select="substring ($birthdate, 1, 4)"/>
        <xsl:variable name="dYear" select="substring ($deathdate, 1, 4)"/>
		<xsl:variable name="age1" select="number($dYear)-number($bYear)"/>
		<xsl:variable name="age2" select="number($dYear)-number($bYear)-1"/>
        <xsl:choose>
            <xsl:when test="number($dDay)-number($bDay)&gt;=0">
                <xsl:choose>
                    <xsl:when test="number($dMonth)-number($bMonth)&gt;=0">
                        <xsl:value-of select="$age1"/>
						<xsl:if test="$withtext=1">
						    <xsl:call-template name="getAges">
                                <xsl:with-param name="age" select="$age1"/>
                            </xsl:call-template>
						</xsl:if>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$age2"/>
						<xsl:if test="$withtext=1">
							<xsl:call-template name="getAges">
                                <xsl:with-param name="age" select="$age2"/>
                            </xsl:call-template>
						</xsl:if>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="number($dMonth)-number($bMonth)-1&gt;=0">
                        <xsl:value-of select="$age1"/>
						<xsl:if test="$withtext=1">
							<xsl:call-template name="getAges">
                                <xsl:with-param name="age" select="$age1"/>
                            </xsl:call-template>
						</xsl:if>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$age2"/>
						<xsl:if test="$withtext=1">
							<xsl:call-template name="getAges">
                                <xsl:with-param name="age" select="$age2"/>
                            </xsl:call-template>
						</xsl:if>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getMonths">
        <xsl:param name="birthdate"/>
        <xsl:param name="deathdate"/>
        <xsl:variable name="bDay" select="substring ($birthdate, 7, 2)"/>
        <xsl:variable name="dDay" select="substring ($deathdate, 7, 2)"/>
        <xsl:variable name="bMonth" select="substring ($birthdate, 5, 2)"/>
        <xsl:variable name="dMonth" select="substring ($deathdate, 5, 2)"/>
        <xsl:variable name="bYear" select="substring ($birthdate, 1, 4)"/>
        <xsl:variable name="dYear" select="substring ($deathdate, 1, 4)"/>
        <xsl:choose>
            <xsl:when test="number($dYear)=number($bYear)">
                <xsl:choose>
                    <xsl:when test="(string-length($birthdate)>=8) and (string-length($deathdate)>=8)">
                        <xsl:choose>
                            <xsl:when test="number($dDay)&gt;=number($bDay)">
                                <xsl:value-of select="number($dMonth)-number($bMonth)"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="number($dMonth)-number($bMonth)-1"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:choose>
                            <xsl:when test="(string-length($birthdate)&lt;6) or (string-length($deathdate)&lt;6)">
                                <xsl:value-of select="0"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="number($dMonth)-number($bMonth)"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="(string-length($birthdate)>=8) and (string-length($deathdate)>=8)">
                        <xsl:choose>
                            <xsl:when test="number($dDay)&gt;=number($bDay)">
                                <xsl:value-of select="number($dMonth)+12-number($bMonth)"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="number($dMonth)+12-number($bMonth)-1"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:choose>
                            <xsl:when test="(string-length($birthdate)&lt;6) or (string-length($deathdate)&lt;6)">
                                <xsl:value-of select="12"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="number($dMonth)+12-number($bMonth)"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getDays">
        <xsl:param name="birthdate"/>
        <xsl:param name="deathdate"/>
        <xsl:variable name="bDay" select="substring ($birthdate, 7, 2)"/>
        <xsl:variable name="dDay" select="substring ($deathdate, 7, 2)"/>
        <xsl:variable name="bMonth" select="substring ($birthdate, 5, 2)"/>
        <xsl:variable name="dMonth" select="substring ($deathdate, 5, 2)"/>
        <xsl:variable name="dYear" select="substring ($deathdate, 1, 4)"/>
        <xsl:choose>
            <xsl:when test="(string-length($birthdate)>=8) and (string-length($deathdate)>=8)">
                <xsl:choose>
                    <xsl:when test="number($dDay)&gt;=number($bDay)">
                        <xsl:value-of select="number($dDay)-number($bDay)"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:choose>
                            <xsl:when test="number($dMonth)=1">
                                <xsl:value-of select="number($dDay)+31-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=2">
                                <xsl:value-of select="number($dDay)+31-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=3">
                                <xsl:choose>
                                    <xsl:when test="number($dYear) mod 4=0">
                                        <xsl:choose>
                                            <xsl:when test="(number($dYear) mod 100)=0">
                                                <xsl:choose>
                                                    <xsl:when test="(number($dYear) mod 400)=0">
                                                        <xsl:value-of select="number($dDay)+28-number($bDay)"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:value-of select="number($dDay)+29-number($bDay)"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="number($dDay)+29-number($bDay)"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="number($dDay)+28-number($bDay)"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=4">
                                <xsl:value-of select="number($dDay)+31-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=5">
                                <xsl:value-of select="number($dDay)+30-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=6">
                                <xsl:value-of select="number($dDay)+31-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=7">
                                <xsl:value-of select="number($dDay)+30-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=8">
                                <xsl:value-of select="number($dDay)+31-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=9">
                                <xsl:value-of select="number($dDay)+31-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=10">
                                <xsl:value-of select="number($dDay)+30-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=11">
                                <xsl:value-of select="number($dDay)+31-number($bDay)"/>
                            </xsl:when>
                            <xsl:when test="number($dMonth)=12">
                                <xsl:value-of select="number($dDay)+30-number($bDay)"/>
                            </xsl:when>
                        </xsl:choose>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="0"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="formatDate">
        <xsl:param name="newdate"/>
			<xsl:call-template name="getDay">
                <xsl:with-param name="date" select="$newdate"/>
            </xsl:call-template>
			<xsl:call-template name="getMonth">
                <xsl:with-param name="date" select="$newdate"/>
            </xsl:call-template>
			<xsl:call-template name="getYear">
                <xsl:with-param name="date" select="$newdate"/>
            </xsl:call-template>
	</xsl:template>
	<xsl:template name="formatDatewithTime">
        <xsl:param name="newdate"/>
		<xsl:call-template name="getDay">
            <xsl:with-param name="date" select="$newdate"/>
        </xsl:call-template>
		<xsl:call-template name="getMonth">
            <xsl:with-param name="date" select="$newdate"/>
        </xsl:call-template>
		<xsl:call-template name="getYear">
            <xsl:with-param name="date" select="$newdate"/>
        </xsl:call-template>
		<xsl:call-template name="getHour">
            <xsl:with-param name="date" select="$newdate"/>
        </xsl:call-template>
		<xsl:call-template name="getMinute">
            <xsl:with-param name="date" select="$newdate"/>
        </xsl:call-template>
	</xsl:template>
	<xsl:template name="formatContact">
        <xsl:param name="contact"/>
		    <xsl:choose>
			    <xsl:when test="substring($contact,1,4)='tel:'">
				    <xsl:text>Тел: </xsl:text>
					<xsl:choose>
			            <xsl:when test="substring-after(substring-before($contact[1], '='), ';')='ext'">
					        <xsl:value-of select="substring-after(substring-before($contact[1], ';'), ':')"/>
							<xsl:text> доб.[</xsl:text>
					        <xsl:value-of select="substring-after($contact[1], '=')"/>
					        <xsl:text>]</xsl:text>
						</xsl:when>
						<xsl:otherwise>
						    <xsl:value-of select="substring-after($contact[1], ':')"/>
						</xsl:otherwise>
					</xsl:choose>
				    <xsl:for-each select="$contact[position()>1]">
					    <xsl:text>; </xsl:text>
						<xsl:choose>
			                <xsl:when test="substring-after(substring-before($contact[1], '='), ';')='ext'">
					            <xsl:value-of select="substring-after(substring-before($contact[1], ';'), ':')"/>
					    		<xsl:text> доб.[</xsl:text>
					            <xsl:value-of select="substring-after($contact[1], '=')"/>
					            <xsl:text>]</xsl:text>
					    	</xsl:when>
					    	<xsl:otherwise>
					    	    <xsl:value-of select="substring-after($contact[1], ':')"/>
					    	</xsl:otherwise>
					    </xsl:choose>
					</xsl:for-each>
                </xsl:when>
                <xsl:when test="substring($contact,1,7)='mailto:'">
				    <xsl:text>E-mail: </xsl:text>
					<xsl:value-of select="substring-after($contact[1], ':')"/>
				    <xsl:for-each select="$contact[position()>1]">
					    <xsl:text>; </xsl:text>
                        <xsl:value-of select="substring-after($contact[position()>1], ':')"/>
					</xsl:for-each>
                </xsl:when>
				<xsl:when test="substring($contact,1,5)='http:'">
				    <xsl:text>Сайт: </xsl:text>
					<xsl:value-of select="substring-after($contact[1], ':')"/>
				    <xsl:for-each select="$contact[position()>1]">
					    <xsl:text>; </xsl:text>
                        <xsl:value-of select="substring-after($contact[position()>1], ':')"/>
					</xsl:for-each>
                </xsl:when>
				<xsl:when test="substring($contact,1,4)='fax:'">
				    <xsl:text>Факс: </xsl:text>
					<xsl:value-of select="substring-after($contact[1], ':')"/>
				    <xsl:for-each select="$contact[position()>1]">
					    <xsl:text>; </xsl:text>
                        <xsl:value-of select="substring-after($contact[position()>1], ':')"/>
					</xsl:for-each>
                </xsl:when>
			</xsl:choose>
	</xsl:template>
	<xsl:template name="formatMedCard">
        <xsl:param name="medcard"/>
		    <xsl:choose>
			    <xsl:when test="$medcard='1'">
                    <xsl:text>Номер	амбулаторной карты: </xsl:text>
                </xsl:when>
                <xsl:when test="$medcard='2'">
                    <xsl:text>Номер	стационарной карты: </xsl:text>
                </xsl:when>
                <xsl:when test="$medcard='3'">
                    <xsl:text>Номер	медицинской карты: </xsl:text>
                </xsl:when>
				<xsl:otherwise>
                    <xsl:text>Номер	медицинской карты: </xsl:text>
                </xsl:otherwise>
			</xsl:choose>
	</xsl:template>
	<xsl:template name="formatNullFlavor">
        <xsl:param name="nullflavor"/>
		    <xsl:choose>
			    <xsl:when test="$nullflavor='INV'">
                    <xsl:text>Недопустимое значение</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='NI'">
                    <xsl:text>Нет информации</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='OTH'">
                    <xsl:text>Другое</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='NINF'">
                    <xsl:text>Минус бесконечность</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='PINF'">
                    <xsl:text>Плюс бесконечность</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='NA'">
                    <xsl:text>Неприменимо</xsl:text>
                </xsl:when>
				<xsl:when test="$nullflavor='UNK'">
                    <xsl:text>Неизвестно</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='ASKU'">
                    <xsl:text>Запрошено, но неизвестно</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='NAV'">
                    <xsl:text>Временно недоступно</xsl:text>
                </xsl:when>
				<xsl:when test="$nullflavor='NASK'">
                    <xsl:text>Не запрашивалось</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='TRC'">
                    <xsl:text>Трудноразличимо</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='MSK'">
                    <xsl:text>Скрыто</xsl:text>
                </xsl:when>
				<xsl:when test="$nullflavor='DER'">
                    <xsl:text>Извлекаемое значение</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='UNC'">
                    <xsl:text>Кодирование не проводилось</xsl:text>
                </xsl:when>
                <xsl:when test="$nullflavor='QS'">
                    <xsl:text>Достаточное количество</xsl:text>
                </xsl:when>
			</xsl:choose>
	</xsl:template>
	<xsl:template name="formatInterpretationCode">
        <xsl:param name="intercode"/>
			<xsl:choose>
				<xsl:when test="$intercode='&lt;' or $intercode='&#60;'">
				    <xsl:text>Ниже предела обнаружения</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='E'">
				    <xsl:text>Сомнительный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='EX'">
				    <xsl:text>Вне диапазона</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='EXP'">
				    <xsl:text>Ожидаемый результат/значение</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='H'">
				    <xsl:text>Повышенный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='HH'">
				    <xsl:text>Критически повышенный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='HU'">
				    <xsl:text>Значительно повышенный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='HX'">
				    <xsl:text>Больше верхнего порога</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='I'">
				    <xsl:text>Умеренно-устойчивый</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='IE'">
				    <xsl:text>Непоказательный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='IND'">
				    <xsl:text>Не определенный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='>' or $intercode='&gt;' or $intercode='&#62;'">
				    <xsl:text>Выше предела обнаружения</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='L'">
				    <xsl:text>Пониженный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='LL'">
				    <xsl:text>Критически пониженный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='LU'">
				    <xsl:text>Значительно пониженный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='LX'">
				    <xsl:text>Меньше нижнего порога</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='N'">
				    <xsl:text>Нормальный (в пределах референсного диапазона)</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='ND'">
				    <xsl:text>Не обнаружено</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='NEG'">
				    <xsl:text>Отрицательный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='NR'">
				    <xsl:text>Нет реакции</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='NS'">
				    <xsl:text>Нечувствительный при данных условиях</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='POS'">
				    <xsl:text>Положительный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='A'">
				    <xsl:text>Патологический (вне референсного диапазона)</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='QCF'">
				    <xsl:text>Контроль качества не пройден</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='R'">
				    <xsl:text>Устойчивый</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='RR'">
				    <xsl:text>Есть реакция</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='S'">
				    <xsl:text>Чувствительный</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='SDD'">
				    <xsl:text>Чувствительный-дозозависимый</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='SYN-R'">
				    <xsl:text>Устойчивый к комбинации</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='SYN-S'">
				    <xsl:text>Чувствительный к комбинации</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='TOX'">
				    <xsl:text>Присутствуют цитотоксические субстанции</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='U'">
				    <xsl:text>Значимо повысилось</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='UNE'">
				    <xsl:text>Неожиданный результат/значение</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='AA'">
				    <xsl:text>Критически патологический (критически вне референсного диапазона)</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='W'">
				    <xsl:text>Ухудшилось</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='WR'">
				    <xsl:text>Слабая реакция</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='AC'">
				    <xsl:text>Присутствуют антикомплиментарные субстанции</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='B'">
				    <xsl:text>Улучшилось</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='CAR'">
				    <xsl:text>Носитель</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='D'">
				    <xsl:text>Значимо понизилось</xsl:text>
				</xsl:when>
			    <xsl:when test="$intercode='DET'">
				    <xsl:text>Обнаружено</xsl:text>
				</xsl:when>
			</xsl:choose>
	</xsl:template>
</xsl:stylesheet>

<!-- Список изменений:

v1.0: первичная разработка

v1.1: Скорректировано отображение срока действия льготы в блоке Код льготы
      Скорректировано отображение блока Ед. изм. в секции RESLAB
      Добавлены блоки Материал, Оборудование и Исполнитель в секции RESLAB
      Скорректировано отображение блока Заключение в секции RESLAB

v1.2: Изменен блок style и getAges -->
