<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  ~ 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)
  --%>

<%--
    Document   : createanalysisrequest
    Created on : Dec 14, 2009, 10:40:14 AM
    Author     : inagy
--%>

<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="/WEB-INF/dateformat.tld" prefix="da" %>
<script type="text/javascript" src="javascript/telepulesek.js"></script>
<%--<link type="text/css" href="stylesheet/redmond/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type="text/javascript" src="javascript/jquery-1.3.2.js"></script>
<script type="text/javascript" src="javascript/ui.core.js"></script>--%>
<script type="text/javascript" src="javascript/ui.datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheet/jquery.autocomplete.css"/>
<%--<script type="text/javascript" src="http://www.google.com/jsapi"></script>--%>
<!--script type="text/javascript" src="javascript/jquery-1.3.1.min.js"></script-->
<script type="text/javascript">
<c:if test="${user.languageCode eq 'HU'}">
/* Hungarian initialisation for the jQuery UI date picker plugin. */
/* Written by Istvan Karaszi (jquerycalendar@spam.raszi.hu). */
jQuery(function($) {
    $.datepicker.regional['hu'] = {
        closeText: 'bezárás',
        prevText: '&laquo; vissza',
        nextText: 'előre &raquo;',
        currentText: 'ma',
        monthNames: ['Január', 'Február', 'Március', 'Április', 'Május', 'Június',
            'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December'],
        monthNamesShort: ['Jan', 'Feb', 'Már', 'Ápr', 'Máj', 'Jún',
            'Júl', 'Aug', 'Szep', 'Okt', 'Nov', 'Dec'],
        dayNames: ['Vasárnap', 'Hétfö', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat'],
        dayNamesMin: ['Vas', 'Hét', 'Ked', 'Sze', 'Csü', 'Pén', 'Szo'],
        dayNamesShort: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'],
        dateFormat: 'yy. mm. dd.', firstDay: 1,
        isRTL: false};
    $.datepicker.setDefaults($.datepicker.regional['hu']);
});

</c:if>

//google.load("jquery", "1");
$(document).ready(function() {

    autocompleteOff();
    $("#datepicker").datepicker({
        changeMonth: true,
        changeYear: true,
        maxDate: '+1d',
        yearRange: '1900:2500'
        <c:if test="${not empty request and request.objectType eq 'born'}">, defaultDate: new Date(${request.objectType eq 'born' ? request.bdDNAStoredSampleDate.time : ''})</c:if>

    });
    $("#datepicker2").datepicker({
        changeMonth: true,
        changeYear: true,
        maxDate: '+1m +1w',
        yearRange: '1900:2500'
        <c:if test="${not empty request}">, defaultDate: new Date(${request.startOfTherapy.time})</c:if>
    });
    $("#datepicker3").datepicker({
        changeMonth: true,
        changeYear: true,
        maxDate: '+1d',
        yearRange: '1900:2500'
        <c:if test="${not empty request}">, defaultDate: new Date(${request.dateOfSampleArrival.time})</c:if>

    });
    $("#datepicker4").datepicker({
        changeMonth: true,
        changeYear: true,
        maxDate: '+1d',
        yearRange: '1900:2500'
        <c:if test="${not empty request}">, defaultDate: new Date(${request.dateOfSampleProcessing.time})</c:if>
    });
    $("#datepicker").datepicker('option', {dateFormat: 'yy. mm. dd.'});
    $("#datepicker2").datepicker('option', {dateFormat: 'yy. mm. dd.'});
    $("#datepicker3").datepicker('option', {dateFormat: 'yy. mm. dd.'});
    $("#datepicker4").datepicker('option', {dateFormat: 'yy. mm. dd.'});

    $("#onDNAStoredSampleDate").datepicker({
        changeMonth: true,
        changeYear: true,
        maxDate: '+1d',
        yearRange: '1900:2500'
        <c:if test="${not empty request and request.objectType eq 'onkohaem'}">, defaultDate: new Date(${request.objectType eq 'onkohaem' ? request.onDNAStoredSampleDate.time : ''})</c:if>

    });
    $("#onDNAStoredSampleDate").datepicker('option', {dateFormat: 'yy. mm. dd.'});

    $("#onFishPreviousDate").datepicker({
        changeMonth: true,
        changeYear: true,
        maxDate: '+1d',
        yearRange: '1900:2500'
        <c:if test="${not empty request and request.objectType eq 'onkohaem'}">, defaultDate: new Date(${request.objectType eq 'onkohaem' ? request.onFishPreviousDate.time : ''})</c:if>

    });
    $("#onFishPreviousDate").datepicker('option', {dateFormat: 'yy. mm. dd.'});

    $("#onCitPreviousDate").datepicker({
        changeMonth: true,
        changeYear: true,
        maxDate: '+1d',
        yearRange: '1900:2500'
        <c:if test="${not empty request and request.objectType eq 'onkohaem'}">, defaultDate: new Date(${request.objectType eq 'onkohaem' ? request.onCitPreviousDate.time : ''})</c:if>

    });
    $("#onCitPreviousDate").datepicker('option', {dateFormat: 'yy. mm. dd.'});

    $("#nameOfSenderInstitute").autocomplete("autocompletesendername.html");
    $("#senderCode").autocomplete("autocompletesendercode.html");
    $("#diagnosis").autocomplete("autocompletediagnosis.html");
    $("#BNOCode").autocomplete("autocompletebnocode.html");

<c:choose>
<c:when test="${param.type eq 4}">
    document.getElementById('objectType').value = 'const';
    showHide('const');
    <c:set var="type" value="const" />
</c:when>
<c:when test="${param.type eq 5}">
    document.getElementById('objectType').value = 'born';
    showHide('born');
    <c:set var="type" value="born" />
</c:when>
<c:when test="${param.type eq 6}">
    document.getElementById('objectType').value = 'onkohaem';
    showHide('onkohaem');
    <c:set var="type" value="onkohaem" />
</c:when>
</c:choose>

});


setWebTitle('<fmt:message key="BIOBANK_ANALYSIS" />');
autocompleteOff();

function showHide(value) {
    if (value == 'born') {
        document.getElementById('born').style.display = 'block';
    } else {
        document.getElementById('born').style.display = 'none';
    }
    if (value == 'onkohaem') {
        document.getElementById('onkohaem').style.display = 'block';
    } else {
        document.getElementById('onkohaem').style.display = 'none';
    }
    if (value == 'const') {
        document.getElementById('const').style.display = 'block';
    } else {
        document.getElementById('const').style.display = 'none';
    }
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    }
}

function checkAllOrNone(where) {
    var root = document.getElementById(where + 'Div');
    var original = document.getElementById(where);
    var citControl = document.getElementById('onCitControll');
    var fishControl = document.getElementById('onFishControll');
    if (where == 'onCitogenetical' && !original.checked) {
        document.getElementById('onCitPreviousResult').value = '';
        document.getElementById('onCitPreviousDate').value = '';
    }
    if (where == 'onFish' && !original.checked) {
        document.getElementById('onFishPreviousResult').value = '';
        document.getElementById('onFishPreviousDate').value = '';
    }
    if (where == 'bdDNAPreparation') {
        var children = root.getElementsByTagName('input');
        for (i = 0; children[i]; i++) {
            if (original.checked) {
                children[i].value = '';
                children[i].disabled = false;
            } else {
                children[i].value = '';
                children[i].disabled = true;
            }
        }
    } else if (where == 'onDNAPreparation') {
        var children = root.getElementsByTagName('input');
        for (i = 0; children[i]; i++) {
            if (original.checked) {
                children[i].value = '';
                children[i].disabled = false;
            } else {
                children[i].value = '';
                children[i].disabled = true;
            }
        }
    } else {
        var children = root.getElementsByTagName('input');
        for (i = 0; children[i]; i++) {
            if (children[i].type == 'checkbox' || children[i].type == 'radio') {
                if (children[i] != citControl && children[i] != fishControl) {
                    children[i].checked = original.checked;
                } else if (!original.checked) {
                    children[i].checked = original.checked;
                }
            }
        }
    }
}

function check(where) {
    document.getElementById(where).checked = true;
    if (where == 'onCitogenetical' && document.getElementById('onCitFirst').checked) {
        document.getElementById('onCitPreviousResult').value = '';
        document.getElementById('onCitPreviousDate').value = '';
    } else if (where == 'onCitogenetical') {
        if (!document.getElementById('onCitControll').checked) {
            document.getElementById('onCitFirst').checked = true;
        }
    }
    if (where == 'onFish' && document.getElementById('onFishFirst').checked) {
        document.getElementById('onFishPreviousResult').value = '';
        document.getElementById('onFishPreviousDate').value = '';
    } else if (where == 'onFish') {
        if (!document.getElementById('onFishControll').checked) {
            document.getElementById('onFishFirst').checked = true;
        }
    }
}

function checkAndSelect(where, what) {
    document.getElementById(where).checked = true;
    var result = document.getElementById(what + 'PreviousResult').value;
    var date = document.getElementById(what + 'PreviousDate').value;
    if (result != '' || date != '') {
        document.getElementById(what + 'Controll').checked = true;
        //document.getElementById(what+'First').checked = false;
    } else {
        //document.getElementById(what+'Controll').checked = false;
        document.getElementById(what + 'First').checked = true;
    }
}

</script>
<script type="text/javascript" src="javascript/jquery.autocomplete.js"></script>
<div class="window500">
<div class="title"><fmt:message key="BIOBANK_ANALYSIS"/></div>
<div class="content">
<div style="padding: 10px;">
    <table border="0" cellspacing="10" cellpadding="5">
        <tbody>
        <tr>
            <td id="head" class="patientheader"></td>
            <td><fmt:message key="BIOBANK_ANALYSIS_DATA"/></td>
        </tr>
        </tbody>
    </table>
    <div id="line" style="width: 477px;" class="patientline">
        <fmt:message key="biobankAndPersonalData"/>
    </div>
    <form action="saverequest.html" method="POST">
        <input type="hidden" name="patient" value="${patient.id}">
        <input type="hidden" name="id" value="${request.id}">

        <%@ 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 style="width: 357px;"><a
                            href="showpatient.html?patient=${patient.id}">${patient.patientCode}</a>
                        <input class="input" type="hidden" name="patientCode" value="${patient.patientCode}">
                    </td>
                </tr>
                <c:if test="${not patient.named}">
                    <tr>
                        <td style="width: 120px;"><fmt:message key="monogram"/>:</td>
                        <td>
                                ${patient.anonymousData.monogram}
                        </td>
                    </tr>
                </c:if>
                <c:if test="${patient.named}">
                    <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="TAJ"/>:</td>
                        <td>${patient.identity.tajNumber}</td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="dateOfBirth"/>:</td>
                        <td>${patient.dateOfBirthForWeb}</td>
                    </tr>
                </c:if>
                <tr>
                    <td style="width: 120px;"><fmt:message key="Type"/>:</td>
                    <td style="width: 357px;">
                        <%--<c:if test="${empty request.id}">
                            <select class="styled" id="objectType" name="objectType"
                                    onclick="return showHide(document.getElementById('objectType').value);">
                                <option value="const" ${request.objectType eq 'const' ? 'selected' : ''}>
                                    <fmt:message
                                            key="constAnalysisRequest"/></option>
                                <option value="born" ${request.objectType eq 'born' ? 'selected' : ''}><fmt:message
                                        key="bornAnalysisRequest"/></option>
                                <option value="onkohaem" ${request.objectType eq 'onkohaem' ? 'selected' : ''}>
                                    <fmt:message
                                            key="onkohaemAnalysisRequest"/></option>
                            </select>
                        </c:if>
                        <c:if test="${not empty request.id}">--%>
                            <fmt:message key="${empty request ? type : request.objectType}AnalysisRequest"/>
                            <input class="input" type="hidden" name="objectType" value="${empty request ? type : request.objectType}">
                        <%--</c:if>--%>
                    </td>
                </tr>
                </tbody>
            </table>
            <div id="common" ${empty request or request.objectType eq 'common' ? 'style="display: block;"' : 'style="display: block;"'} >
                <div class="patientline"><fmt:message key="referralData"/></div>
                <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                    <tbody>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="dateOfSampleArrival"/>:</td>
                        <td style="width: 347px;"><input class="required" id="datepicker3" type="text"
                                                         name="dateOfSampleArrival"
                                                         value="${request.dateOfSampleArrivalForWeb}"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="dateOfSampleProcessing"/>:</td>
                        <td style="width: 347px;"><input class="required" id="datepicker4" type="text"
                                                         name="dateOfSampleProcessing"
                                                         value="${request.dateOfSampleProcessingForWeb}"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="NAPLO_SZAM"/>:</td>
                        <td style="width: 347px;"><input class="input" type="text" name="logNumber"
                                                         value="${request.logNumber}"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="diagnosis"/>:</td>
                        <td style="width: 347px;"><input class="required" id="diagnosis" type="text"
                                                         name="diagnosis"
                                                         value="${request.diagnosis}"/></td>
                    </tr>
                    <tr>
                        <td style="width: 112px;"><fmt:message key="BNOCode"/>:</td>
                        <td style="width: 347px;"><input class="input" type="text" id="BNOCode" name="BNOCode"
                                                         value="${request.BNOCode}"/></td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="nameOfSenderInstitute"/>:</td>
                        <td style="width: 347px;"><input class="required" id="nameOfSenderInstitute" type="text"
                                                         name="nameOfSenderInstitute"
                                                         value="${request.nameOfSenderInstitute}"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="senderCode"/>:</td>
                        <td style="width: 347px;"><input class="required" id="senderCode" type="text"
                                                         name="senderCode"
                                                         value="${request.senderCode}"/></td>
                    </tr>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="financialCategory"/>:</td>
                        <td style="width: 347px;"><select class="styled" name="financialCategory">
                            <option value="1" ${request.financialCategory eq 1 ? 'selected' : ''}><fmt:message
                                    key="FINCAT1"/></option>
                            <option value="2" ${request.financialCategory eq 2 ? 'selected' : ''}><fmt:message
                                    key="FINCAT2"/></option>
                            <option value="3" ${request.financialCategory eq 3 ? 'selected' : ''}><fmt:message
                                    key="FINCAT3"/></option>
                            <option value="4" ${request.financialCategory eq 4 ? 'selected' : ''}><fmt:message
                                    key="FINCAT4"/></option>
                            <option value="5" ${request.financialCategory eq 5 ? 'selected' : ''}><fmt:message
                                    key="FINCAT5"/></option>
                            <option value="6" ${request.financialCategory eq 6 ? 'selected' : ''}><fmt:message
                                    key="FINCAT6"/></option>
                            <option value="9" ${request.financialCategory eq 9 ? 'selected' : ''}><fmt:message
                                    key="FINCAT9"/></option>
                            <option value="10" ${request.financialCategory eq 10 ? 'selected' : ''}><fmt:message
                                    key="FINCAT10"/></option>
                            <option value="11" ${request.financialCategory eq 11 ? 'selected' : ''}><fmt:message
                                    key="FINCAT11"/></option>
                        </select></td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <%@ include file="createconstdata.jspf" %>
            <%@ include file="createborndata.jspf" %>
            <%@ include file="createoncohaemdata.jspf" %>
        </div>
        <br/>

        <div align="right">
            <input class="button" name="send" style="width: 200px;" type="submit"
                   value="<fmt:message key="PRINT_AND_SAVE" />">
            <input class="button" name="send" type="submit" value="<fmt:message key="MENTÉS" />">
        </div>
    </form>
</div>
</div>
<div class="copyright">
    &copy; 2009-2010 Astrid Research Inc.
</div>
</div>
