[%
    skip_wrappers = 1;
    self_close = 30 * 1000;
    body_attr =	PROCESS site/js/windowClose.tt;
%]

<!-- BEGIN history/previous_diagnosis.tt -->
    [% # PROCESS dumper.tt dump = request_data %]
    
    [% patient = request_data.patient_case.patient %]

    <script type="text/javascript" src="/js/jquery.countdown.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#refresh').countdown(
                { until: +[% self_close / 1000 %], format: 's', compact: true }
            );
        });
    </script>
    
    <h4>Previous diagnoses for
        [% PROCESS site/lab_number.tt want_url = 0 , data = request_data %]
        [ [% patient.last_name | upper %], [% patient.first_name | ucfirst %] ]
    </h4>

    [% # PROCESS dumper.tt dump = previous_diagnoses %]
    
    <table class="indent">
        <tr>
            <th scope="col">Old diagnosis</th>
            <th scope="col">Changed by</th>
            <th scope="col">Reason</th>
            <th scope="col">Day/Date</th>
        </tr>
    [% FOREACH d IN previous_diagnoses %]
        <tr>
            <td>
                [% d.diagnosis.name | html %]
            </td>
            <td>
                [% d.user.first_name | ucfirst %]
                [% d.user.last_name | ucfirst %]
            </td>
            <td>
                [% d.option.option_name %]
            </td>
            <td>
                [% d.time.strftime('%a %d.%b.%Y @ ');
                    d.time.strftime('%T').match('00:00:00') # for legacy data:
                        ? '??:??:??' : d.time.strftime('%T') %]
            </td>
        </tr>
    [% END %]        
    </table>
    
    <p align="right">
        [ window will auto-close in <i><span id="refresh"></span> sec</i>;
        <a href="javascript:window.close();">close now</a>  ]      
    </p>
<!-- END history/previous_diagnosis.tt -->
