[%- content_only = 1; # no html wrappers; called from record/default.tt -%]
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<!-- BEGIN [% component.name # *after* DOCTYPE for IE <9 formatting %] -->
<head>
  <!-- <meta charset="utf-8"> // wkhtmltopdf can't render em-dash & apostrophe chars -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>[%# INCLUDE site/lab_number.tt want_url = 0 %]</title>
  <meta name="description" content="">

  [% settings = c.cfg('settings') %]

  [%# base href only needed so wkhtmltopdf can find static files as http addr: %]
  <base href="[% settings.base_href %]">

  <link rel="stylesheet" href="/css/bootstrap.css">
  [% UNLESS is_print_request # wrecks span width formatting %]
    <link rel="stylesheet" href="/css/bootstrap-responsive.css">
  [% END %]
  <link rel="stylesheet" href="/css/print_view.css?v1.5" type="text/css">

  <link rel="stylesheet" href="/css/local/[% settings.item('_centre') %].css"
    type="text/css">

  <style type="text/css">
  [% IF is_print_request %]
    .demographics a { color: #513775 }
    .no-break  { page-break-inside: avoid }
  [% END -%]
    @media print {
      .printHide { display: none;  }
      .viewHide  { display: block; }
      .error     { color: #c44;    }
      a[href]:after { /* override idiotic bootstrap css entry: */
        content: none;
      }
    }
    @media screen {
      .viewHide  { display: none; }
    }
  </style>
  <!--[if lt IE 9]>
    <style type="text/css">
    /* corrections for noddy browser */
    #nav-bar {
      right: 200px;
      top: 80px;
    }
    /* // maybe not required
	#user-id {
		right: 300px;
		top: 65px;
	}
	*/
  </style>
  <![endif]-->
  <link rel="stylesheet" href="/css/font-awesome.min.css" />

  <script src="/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>

[% # define static vars - don't change between requests if print-run request:
    ukas = 'hmds.info/ukas';
    text_str = {
      csf => 'absence of involvement of the cerebro-spinal fluid does not'
        _ ' exclude the possibility of intracerebral disease',
      tests_pending => 'there are further laboratory investigations pending',
      service_url => 'the definitive report is available online at &lt;'
        _ settings.service_url _ '&gt;',
      pb_sample => 'please send a peripheral blood sample with all bone marrow specimens',
      clinic_return => 'Currently unsuitable for community monitoring: an appointment'
        _ ' will be made at the haematology clinic.',
#      clinic_return => 'A haematology clinic appointment is required. If you do not'
#        _ ' receive confirmation of an appointment within two weeks, please contact us.',
      pack_dispatch => 'Suitable for community monitoring: a pack will be sent out',
      ukas => 'all lab-tests performed were accredited to ISO 15189:2012 '
        _ "[ref <a target=\"_new\" href=\"http://${ukas}\">${ukas}</a>] "# include trailing space
    };

    acronym_class = is_print_request ? 'normal' : 'acronym'; # don't display if print req

    tt_name = c.cfg('settings').report_template;
    report_tmpl = "record/report/local/${tt_name}.tt"; # INCLUDE dumper.tt dump = report_tmpl;
%]

<body>
  [% # PROCESS dumper.tt dump = data.as_tree %]
  [% IF reports.size; # HTML print-run request:
      offset = c.query.param('offset') || 0; # next offset value
      count  = c.query.param('total')  || 0;  # total number of records in print run
      start  = c.query.param('start') | uri;
      end    = c.query.param('end')   | uri;

      offset_next  = offset + 50;
      offset_lower = offset_next + 1;  # start of next offset
      offset_upper = offset_next + 50; # end of next offset

      url = [];
      url.push("total=$count");
      url.push("offset=$offset_next");
      url.push("start=$start");
      url.push("end=$end"); # PROCESS dumper.tt dump = url;
  %]
    <p class="printHide">[% site.html.back_button %]
      <span style="font-weight: bold; float: right">
        [% IF count >= offset_lower; # still more records to print: %]
          <a class="button" href="[% app_url %]/printrun/do_offset?[% url.join(';') %]">
            [% offset_lower %] to [% ( offset_upper > count ) ? count : offset_upper %]
            &#187;
          </a>
        [% ELSE %]
          [finished]
        [% END %]
      </span>
    </p>
    [% FOREACH entry IN reports;
        import(entry); # clobbers all previous keys (history, has_optional, etc):
        # need to (re)define vars not set in caller record/default.tt:
        request_data = data.as_tree; # save multiple lookups if undefined
        report  = data.request_report; # PROCESS dumper.tt dump = report.as_tree;
        patient = data.patient_case.patient; # PROCESS dumper.tt dump = patient.as_tree;
      %]
        <div style="page-break-after: always">
          [% INCLUDE $report_tmpl %]
        </div>
      [% END %]
  [% ELSE; INCLUDE $report_tmpl; END %]

  <!-- // interferes with msg links
  [% UNLESS is_print_request # printed as wkhtmltopdf footer %]
    <div class="footer">
        <p class="pull-right"><img src="/images/cpa_logo.png" /></p>
    </div>
  [% END %]
   -->
  <!-- // not required if reports generated as PDF
  [% UNLESS c.get_current_runmode.match('_do_print') # print run %]
    <div class="viewHide error">THIS PAGE VIEW IS NOT FORMATTED FOR PRINTING.
      PLEASE USE THE "PRINT" ICON IN THE UPPER NAVIGATION SECTION.
    </div>
  [% END %]
  -->
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script>window.jQuery || document.write('<script src="/js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
  <script src="/js/vendor/bootstrap.min.js"></script>
  <script src="/js/main.js"></script>
</body>
</html>
<!-- END [% component.name %] -->
