<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/WEB-INF/dateformat.tld" prefix="da" %>
<%--
  ~ This file is part of DebGen Biobank Software developed by ASTRID Research.
  ~ All rights reserved. Reproduction, modification, use or disclosure
  ~ to third parties without express authority is forbidden.
  ~
  ~ Copyright ASTRID Research Inc., Hungary, 2009-2011.
  ~
  ~ ASTRID Research
  ~ Headquaters: Csapo utca 42. Debrecen H-4029 HUNGARY
  ~ Phone: +36-52-533-173        Fax: +36-52-533-174
  ~ Web: http://www.astrid.hu    E-mail: info@astrid.hu
  ~
  ~ Project name: DebGen Biobank Software project.
  ~ URLS:
  ~ Developers: Istvan Zoltan Nagy (istvan.nagy@astrid.hu)
  --%>

<script type="text/javascript">
    setWebTitle('<fmt:message key="BIOBANK_BETEG" /> - ${patient.patientCode}');

    function deletePatient() {
        if (confirm('<fmt:message key="torlesBiztos" />'))
            document.location.href = 'deletepatient.html?patient=${patient.id}';
    }
    autocompleteOff();
</script>
<div class="window500">
    <div class="title"><fmt:message key="BIOBANK_BETEG" /> - ${patient.patientCode}</div>
    <div class="content">
        <div style="padding: 10px;">
            <table border="0" cellspacing="10" cellpadding="5">
                <tbody>
                    <tr>
                        <td class="patientheader"></td>
                        <td><fmt:message key="BIOBANK_BETEG" /></td>
                </tr>
                </tbody>
            </table>
            <table align="center" border="0" cellspacing="10" cellpadding="0">
                <tbody>
                    <tr>
                <c:if test="${user.dataRecorder}">
                    <td class="button" align="center" valign="middle"
                        style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');"><a class="menulink" style="display: block; width: 70px; padding-top: 4px;" href="createpatient.html?patient=${patient.id}"><fmt:message key="SZERKESZTÉS" /></a>
                    </td>
                </c:if>
                <c:if test="${user.userAdministrator}">
                    <td class="button" align="center" valign="middle"
                        style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');"><a class="menulink" style="display: block; width: 70px; padding-top: 4px;" href="javascript:deletePatient();"><fmt:message key="TORLES" /></a>
                    </td>
                </c:if>
                </tr>
                </tbody>
            </table>
            <div style="width: 476px;" class="patientline">
                <fmt:message key="BIOBANK_ADATOK" />
            </div>
            <%@ include file="../showembedederror.jsp" %>
            <div id="userdiv">
                <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                    <tbody>
                        <tr>
                            <td style="width: 120px;"><fmt:message key="patientCode" />:</td>
                    <td>
                        ${patient.patientCode}
                    </td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="BEVITEL_MODJA" />:</td>
                    <td>
                    <fmt:message key="${not patient.named ? 'NEV_NELKUL' : ''}${not patient.anonymous ? 'NEVVEL' : ''}${patient.namedAndAnonymous ? 'NEV_NELKUL_ES_NEVVEL' : ''}" />
                    </td>
                    </tr>
                    </tbody>
                </table>
                <div id="monogram" style="display: ${empty patient or (patient.anonymous and not patient.named) or (not user.dataRecorder and patient.namedAndAnonymous) ? 'block' : 'none'}">
                    <div class="patientline"><fmt:message key="anonymData" /></div>
                    <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                        <tbody>
                            <tr>
                                <td style="width: 120px;" ><fmt:message key="monogram" />:</td>
                        <td>
                            ${patient.anonymousData.monogram}
                        </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div id="anonymous" style="display: ${patient.anonymous ? 'block' : 'none'}">
                    <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                        <tbody>
                            <tr>
                                <td style="width: 120px;" ></td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div id="named" style="display: ${patient.named ? 'block' : 'none'}">
                    <c:if test="${user.dataRecorder}">
                        <div class="patientline"><fmt:message key="personalData" /></div>
                        <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                            <tbody>
                                <tr>
                                    <td style="width: 120px;"><fmt:message key="BETEG_NEV" />:</td>
                            <td>${patient.identity.patientName}</td>
                            </tr>
                            <tr>
                                <td style="width: 120px;"><fmt:message key="SZULETESI_NEV" />:</td>
                            <td>${patient.identity.maidenName}</td>
                            </tr>
                            <tr>
                                <td style="width: 120px;"><fmt:message key="dateOfBirth" />:</td>
                            <td>${patient.dateOfBirthForWeb}</td>
                            </tr>
                            <tr>
                                <td style="width: 120px;"><fmt:message key="TAJ" />:</td>
                            <td>${patient.identity.tajNumber}</td>
                            </tr>
                            <tr>
                                <td style="width: 120px;"><fmt:message key="IRSZ" /> <fmt:message key="TELEPULES" />:</td>
                            <td nowrap>${patient.identity.zipCode gt 0 ? patient.identity.zipCode : ''} ${patient.identity.city}</td>
                            </tr>
                            <tr>
                                <td style="width: 120px;"><fmt:message key="CIM" />:</td>
                            <td>${patient.identity.address}</td>
                            </tr>
                            <tr>
                                <td style="width: 120px;"><fmt:message key="ANYJA_NEVE" />:</td>
                            <td>${patient.identity.mothersName}</td>
                            </tr>
                            <%--<tr>
                                <td style="width: 120px;"><fmt:message key="NAPLO_SZAM" />:</td>
                            <td>${patient.identity.logNumber}</td>
                            </tr>
                            --%></tbody>
                        </table>
                    </c:if>
                </div>
                <%--<c:if test="${user.dataRecorder}">
                    <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                        <!--div class="patientline"><fmt:message key="otherData" /></div-->
                        <tbody>
                            <tr>
                                <td style="width: 120px;"><fmt:message key="dateOfBirth" />:</td>
                        <td>${patient.dateOfBirthForWeb}</td>
                        </tr>
                        </tbody>
                    </table>
                </c:if>--%>

                <div id="named" style="display: ${patient.named ? 'block' : 'none'}">
                	<div class="patientline"><fmt:message key="BIOBANK_ANALYSIS_SHEETS" /></div>

                	<table class="formtable" width="477px" cellspacing="0" cellpadding="3">
                    <tbody>
                    <c:if test="${empty patient.requests}">
                        <tr style="vertical-align: top;">
                            <td class="lined" style="width: 120px;">${item.createdOnForWeb}</td>
                            <td class="lined" style="width: 340px;">
                                <fmt:message key="noRequest"/>
                            </td>
                        </tr>
                    </c:if>
                    <c:forEach items="${patient.requests}" var="item">
                        <c:if test="${not empty old and old.createdOnForWeb ne item.createdOnForWeb}">
                            </td>
                            </tr>
                        </c:if>
                        <c:if test="${old.createdOnForWeb ne item.createdOnForWeb}">
                            <tr style="vertical-align: top;">
                                <td class="lined" style="width: 120px;">${item.createdOnForWeb}</td>
                                <td class="lined" style="width: 340px;"></c:if>
                        <a href="showrequest.html?patient=${patient.id}&request=${item.id}"><fmt:message key="${item.localizeableName}" /></a><br />
                        <c:set var="old" value="${item}" />
                        <%--</c:if>--%>
                    </c:forEach>
                    <c:if test="${not empty patient.analysisList}">
                        </td>
                        </tr>
                    </c:if>
                    </tbody>
                </table>


                </div>


                <table class="formtable" width="477px" cellspacing="0" cellpadding="3">
                    <div class="patientline"><fmt:message key="moduls" /></div>
                    <tbody>
                    <c:forEach items="${patient.modules}" var="item">
                        <%--<c:if test="${item.classType eq 'AnalysisRequest' or empty item.request}">--%>
                        <c:if test="${not empty old and old.createdOnForWeb ne item.createdOnForWeb}">
                            </td>
                            </tr>
                        </c:if>
                        <c:if test="${old.createdOnForWeb ne item.createdOnForWeb}">
                            <tr style="vertical-align: top;">
                                <td class="lined" style="width: 120px;">${item.createdOnForWeb}</td>
                                <td class="lined" style="width: 340px;"></c:if>
                        <a href="show${item.classType eq 'AnalysisRequest' ? 'request.html?request=' : 'module.html?module='}${item.id}"><fmt:message key="${item.localizeableName}" /></a><br />
                        <c:if test="${item.classType eq 'AnalysisRequest' and not empty item.result}">- <fmt:message key="LELET_EZ" />: <a href="showmodule.html?module=${item.result.id}"><fmt:message key="${item.result.localizeableName}" /></a><br /></c:if>
                        <c:set var="old" value="${item}" />
                        <%--</c:if>--%>
                    </c:forEach>
                    <c:if test="${not empty patient.modules}">
                        </td>
                        </tr>
                    </c:if>
                    </tbody>
                </table>
                <%--TODO: rh ezeken az egymasbaagyazott ciklusokon es felteteleken lehetoseg szerint egyszerusiteni kene.--%>
                <%--TODO: rh nehezen olvashato--%>
                <c:if test="${empty patient.modules}">
                    <div style="color: #777777; font-size: 12px; padding: 3px"><fmt:message key="noModules"/></div>
                    <br/></c:if>
                <table class="formtable" width="477px" cellspacing="0" cellpadding="3">
                    <div class="patientline"><fmt:message key="samples"/></div>
                    <tbody>
                    <c:remove var="old" />
                    <c:forEach items="${patient.analysisList}" var="item">
                        <%--<c:if test="${item.classType eq 'AnalysisRequest' or empty item.request}">--%>
                        <c:if test="${not empty old and old.createdOnForWeb ne item.createdOnForWeb and not empty item.samples}">
                            </td>
                            </tr>
                        </c:if>
                        <%--<c:if test="${old.createdOnForWeb ne item.createdOnForWeb and not empty item.samples}">
                            <tr style="vertical-align: top;">
                                <td class="lined" style="width: 120px;">${item.createdOnForWeb}s</td>
                                <td class="lined" style="width: 340px;"></c:if>
                                    <c:if test="${not empty old and old.createdOnForWeb ne item.createdOnForWeb and not empty item.samples}">
                                </td>
                            </tr>
                        </c:if>--%>
                    <c:if test="${(empty old and not empty item.samples) or (old.createdOnForWeb ne item.createdOnForWeb and not empty item.samples)}">
                        <tr style="vertical-align: top;">
                            <td class="lined" style="width: 120px;">${item.createdOnForWeb}</td>
                            <td class="lined" style="width: 340px;">
                                <c:set var="old" value="${item}"/>
                                </c:if>
                                <c:forEach items="${item.samples}" var="s">
                                    <a href="showsample.html?sample=${s.id}">${s.sampleCode}</a>
                                </c:forEach>

                                    <%--</c:if>--%>
                                </c:forEach>
                                <c:if test="${not empty patient.analysisList and not empty old}">
                            </td>
                        </tr>
                    </c:if>
                    </tbody>
                </table>

                <table class="formtable" width="477px" cellspacing="0" cellpadding="3">
                    <div class="patientline"><fmt:message key="newModul" /></div>
                    <tbody>
                        <tr>
                    <c:if test="${user.dataRecorder}">
                        <td class="lined" style="width: 120px;"></td>
                        <td class="lined"><a href="createrequest.html?patient=${patient.id}"><fmt:message key="newAnalysisRequest" /></a><br />
                        <a href="showrequests.html?patient=${patient.id}"><fmt:message key="newResultModule" /></a><br /><br />
                        </td>
                    </c:if>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="copyright">
        &copy; 2009-2010 Astrid Research Inc.
    </div>
</div>
