  [% META title = 'Outreach &raquo; Doubling times' %]
<!-- BEGIN [% template.name %] -->
    [% # PROCESS dumper.tt dump = data %]
    [% # PROCESS dumper.tt dump = duration %]
    
    <h3>Calculation of doubling time for param: [% param.field_label %]</h3>
    
    <h4 class="indent">
        [% patient.last_name | upper %], [% patient.first_name | ucfirst %] ::
        [% patient.dob.strftime('%d.%b.%Y') %] :: [% patient.nhs_number %]
    </h4>
    
  <form method="post" action="[% app_url %]/outreach/doubling_time/[% c.param('id')
    %]/[% c.param('Id') %]" name="data_table" id="dataTable">
	<table class="indent borderless">
        <tr>
            <th scope="col">Date</th>
            <th scope="col">Result</th>
            <th scope="col">A</th>
            <th scope="col">B</th>
            <td rowspan="[% data.size + 2 %]" valign="top">
                <div style="padding: 20px 50px">
                <img src="[% app_url %]/chart/outreach_param/[% c.param('id')
                    %]/[% c.param('Id') %]?dynamic_adjust=1" />
                </div>
            </td>
        </tr>
        [% FOREACH entry IN data; NEXT UNLESS entry.result; %]
        <tr>
            <td>[% entry.created_at.strftime('%d.%m.%Y') %]</td>
            <td align="center">[% sig_figs(entry.result) || entry.result %]</td>
            <td>
                <input type="radio" name="from" value="[% loop.count %]"
                    [% 'checked' IF loop.count == c.query.param('from') %] />
            </td>
            <td>
                <input type="radio" name="to" value="[% loop.count %]"
                    [% 'checked' IF loop.count == c.query.param('to') %] />
            </td>
        </tr>
        [% END %]
        <tr>
            <td align="right" colspan="4">[% site.html.submit %]</td>
        </tr>
    </table>
    </form>
  
    [% IF duration; USE Math; %]
        <p class="title">Calculated doubling time:
            <span class="highlight">
                [% round( duration.in_units('months') ) %]</span>
            months
        </p>
        <div class="indent" style="font-size: smaller">
           T<sub>d</sub> = (t2 - t1) * log(2) / log(q2 / q1)
           = [% delta_days %] * [% Math.log(2) %] / log([% q2 / q1 %])
        </div>
    [% ELSIF eval_err %]
        <p>Error: <span class="error">[% eval_err %]</span></p>
    [% END %]

<!-- END [% template.name %] -->