[% content_only = 1 # no html wrappers %]
    [% # shared by print_record - called by outreach/report.tt & print_run - called direct %]
<!-- BEGIN outreach/report_body.tt -->    
  [%
    data     = request.data; # PROCESS dumper.tt dump = data.as_tree;
    patient  = data.patient_case.patient;
    outreach = request.outreach; # PROCESS dumper.tt dump = outreach;
    history  = request.history; # PROCESS dumper.tt dump = history;
  %]

    <div align="right">
		<a href="[% app_url %]">
			<img class="href" src="/images/logo.jpeg" alt="" />
		</a>
	</div>

    <div align="center">
        <p>
            <font size="+1" color="blue">
                Haematological Malignancy Diagnostic Service
            </font>
        </p>
    
        <p>
            [% c.cfg('settings').service_address %]
            [% c.cfg('settings').service_telno %]
        </p>
    
        <h3 align="center">
            Outreach Report on Ref. [% PROCESS site/lab_number.tt; want_url=0 %]
        </h3>
    </div>
		
	<p class="h4">Patient details:</p>
	
    <table id="patient_details">		
		<tr>
			<td class="header">Name:</td>
			<td>
                [% patient.last_name   | upper %],
                [% patient.first_name  | ucfirst %]
                [% patient.middle_name | ucfirst %]

                <b>DoB</b>: [% patient.dob.strftime('%d.%b.%Y') %]
                <b>NHS No</b>:
                [% INCLUDE site/nhs_number.tt nhs_number = patient.nhs_number %]
            </td>
		</tr>
		
		<tr>
			<td class="header">Address:</td>
			<td>
                [% outreach.demographics.address | html %],
                [% outreach.demographics.post_code %]
            </td>
		</tr>

		<tr>
			<td class="header">GP:</td>
			<td>
                [% outreach.demographics.practitioner || 'UNKNOWN' %],
                [% outreach.demographics.display_name | html %]
              </td>
		</tr>			
    </table>
		
	<p class="h4">Laboratory results:</p>
    
	<div id="report">
        [% img_url = app_url _ '/chart/outreach/' _ data.patient_case.patient_id;
            # append "?CGISESSION=c.session.id" to pass session from URL
            IF use_file_sessions; # eg called from cron script
                img_url = img_url _ '?USE_FILE_SESSIONS=1'; END; # not using 'url' now:
        %]

		<!-- BEGIN outreach charts - div width to prevent wrapping when printed -->
        <div style="width: 740px">
          <img src="[% app_url %]/chart/outreach_common/[% data.patient_case.patient_id %]" />
		  [% IF outreach.requested_lab_tests.grep('rq_cml').size %]
            <img src="[% app_url %]/chart/imatinib/[% data.id %]?outreach=1" />
          [% ELSE %]
            <img src="[% app_url %]/chart/outreach_others/[% data.patient_case.patient_id %]" />
          [% END %]
        </div>
		<!-- END outreach charts -->

        <div id="data_summary" align="center">
            [% INCLUDE outreach/data_summary.tt skip_url = 1 # switches off td hrefs %]
        </div>
        
      [% IF history.authorised # allowing interim - only display if authorised %]
		<p class="h4">Comment:</p>
		<p id="comment">
            <div>
              [% 
                formatted_comment = symbolise(data.request_report.comment);
                formatted_comment | html_line_break;
              %]
            </div>
			[%
                follow_opt_id = outreach.followup.followup_option_id;
                option = outreach.menu_options.followup_options.item(follow_opt_id).option;
                label  = outreach.menu_options.followup_options.item(follow_opt_id).label;
            %]

            [% IF option.match('month') %]
                Suitable for community monitoring: a pack will be sent out 
                [% UNLESS option.match('zero') %]in[% END %]
                [% label %].
            [% ELSIF option.match('clinic_return') %]
                Currently unsuitable for community monitoring: an appointment
                will be made at the haematology clinic.
            [% END %]
        </p>	
	
		<p class="h4">Diagnosis:</p>
		<p><b>[% data.request_report.diagnosis.name | html %]</b></p>	
	
		<div align="right">
            <div>
              <i>Reported by</i>:
              [% history.reported.user.first_name | ucfirst %]
              [% history.reported.user.last_name  | ucfirst %]
              on [% history.reported.time.strftime('%d.%b.%Y at %H:%M') %]
            </div>
  
            [% IF history.authorised %]
            <div>
                <i>Authorised by</i>:
                [% history.authorised.user.first_name | ucfirst %]
                [% history.authorised.user.last_name  | ucfirst %]
                on [% history.authorised.time.strftime('%d.%b.%Y at %H:%M') %]
            </div>
            [% END %]  
        </div>
      [% ELSE # allowing interim report: %]
        <p class="h4">Diagnosis and comment:</p>
        <p>[ not yet available - interim report only ]</p>  
      [% END %]
	</div>
<!-- BEGIN outreach/report_body.tt -->    
