[% # set some template params for easy access:
    patient     = data.patient_case.patient;
    last_name   = patient.last_name | upper;
    first_name  = patient.first_name | ucfirst;
    middle_name = patient.middle_name | ucfirst;
    source      = data.patient_case.referral_source;
    specimen    = specimen_map.item(data.id).sample_code.join(', ');
    full_name   = last_name _ ', ' _ first_name _ ' ' _ middle_name;
%]

[% # PROCESS dumper.tt dump = data %]

<table>
      <tr>
        <td class="label">Name:</td>
        <td class="content">
            <input type="text" value="[% full_name %]"
                size="40" class="field" [% site.html.readonly %] />
        </td>
      </tr>
      <tr>
        <td class="label">NHS No:</td>
        <td class="content">
            <input type="text" value="[% patient.nhs_number %]" size="12"
                class="field" [% site.html.readonly %] />
            <span class="box">Patient No:</span>
            <input type="text" value="[% data.patient_case.unit_number %]"
                size="12" class="field" [% site.html.readonly %] />
        </td>
      </tr>
      <tr>
        <td class="label">DoB:</td>
        <td class="content">
            <input type="text" value="[% patient.dob.strftime('%d.%b.%Y') %]"
                size="12" class="field" [% site.html.readonly %] />
      </tr>
      <tr>
        <td class="label">Lab No:</td>
        <td class="content">
            <input type="text" value="[% PROCESS site/lab_number.tt %]" size="12"
                class="field" [% site.html.readonly %] />
            <span class="box">Date:</span>
            <input type="text" value="[% data.created_at.strftime('%d.%b.%Y') %]"
                size="12" class="field" [% site.html.readonly %] />
        </td>
      </tr>
      <tr>
        <td class="label">Source:</td>
        <td class="content">
          <input type="text" value="[% source.display_name %]"
                size="40" class="field" [% site.html.readonly %] />
        </td>
      </tr>
      <tr>
        [%
            IF data.referrer_department.referrer.national_code.match('9999998');
                referrer = 'Unknown';
            ELSE;
                referrer = data.referrer_department.referrer.name || 'Unknown';
            END;
        %]
        <td class="label">Referrer:</td>
        <td class="content">
            <input type="text" value="[% referrer %]" size="40" class="field"
                [% site.html.readonly %] />
        </td>
      </tr>

    <tr>
        <td class="label">Gender:</td>
        <td class="content">
            <input type="text" value="[% patient.gender %]" size="2"
                class="field" [% site.html.readonly %] />
      </tr>
      <tr>
        <td class="label">Specimen:</td>
        <td class="content">
            <input type="text" value="[% specimen %]"
                size="30" class="field" [% site.html.readonly %] />
        </td>
      </tr>
      <tr>
        <td class="label"> Block ref:</td>
        <td class="content">
            <input type="text" value="" size="30" class="field"
                [% site.html.readonly %] />
        </td>
      </tr>
    </table>