{% set absUrl = app.request.getSchemeAndHttpHost() ~ app.request.baseUrl|replace({'/app_dev.php': ''}) %}
{% set userData = app.session.get('userData') %}
<!DOCTYPE html>
<html class="no-js" lang="en" dir="ltr">
<head>
	<meta charset="utf-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>PSS Letter</title>
</head>
<body style="font-family:'Arial'; font-size:18px;">
{% set schedule = anf.schedule %}
{% set patient = anf.patient %}
{% set patientInsurance = patient.activePatientInsurance %}
{% if 'Referring Affiliate' == anf.affiliateType %}
	{% set rhf = anf.patientReferringHealthFacility.referringHealthFacility %}
	{% set attn = rhf.description %}
	{% set phoneNo = rhf.phoneNo %}
	{% set faxNo = rhf.faxNo %}
	{% set notes = '' %}
{% elseif 'Referring Physician' == anf.affiliateType %}
	{% set rp = anf.patientReferringProvider.referringProvider %}
	{% set attn = rp.honorific ~ ' ' ~ rp.fullName|title %}
	{% if rp.phoneNo != '' or rp.phoneNo is not null %}
		{% set phoneNo = rp.phoneNo %}
	{% else %}
		{% set phoneNo = '' %}
		{% for prhf in patient.patientReferringHealthFacilities %}
			{% for rhfp in rp.referringHealthFacilityProviders %}
				{% if prhf.referringHealthFacility.id == rhfp.referringHealthFacility.id %}
					{% set phoneNo = prhf.referringHealthFacility.phoneNo %}
				{% endif %}
			{% endfor %}
		{% endfor %}
	{% endif %}
	{% if rp.faxNo != '' or rp.faxNo is not null %}
		{% set faxNo = rp.faxNo %}
	{% else %}
		{% set faxNo = '' %}
		{% for prhf in patient.patientReferringHealthFacilities %}
			{% for rhfp in rp.referringHealthFacilityProviders %}
				{% if prhf.referringHealthFacility.id == rhfp.referringHealthFacility.id %}
					{% set faxNo = prhf.referringHealthFacility.faxNo %}
				{% endif %}
			{% endfor %}
		{% endfor %}
	{% endif %}
	{% set notes = rp.note %}
{% else %}
	{% set ins = anf.patientInsurance.insurance %}
	{% set attn = ins.description %}
	{% set phoneNo = ins.phoneNo %}
	{% set faxNo = ins.faxNo %}
	{% set notes = '' %}
{% endif %}
<div style="width:768px; position: relative; padding:0px; margin: 0 auto; box-shadow:3px 1px 10px 1px;">
	{#<h3 style="text-align: center; margin-top:35px; padding-right: 40px; border:1px solid #6F71B3; margin-left: 60px; margin-right: 60px; box-sizing: border-box;">FAX FORM</h3>#}
	<div style="margin-top:12px; height: 150px; width:100%;">
		<div style="width: 50%; height: 230px; float: left; box-sizing: border-box; padding-right: 5px;">
			<p style="margin-bottom: 5px;">TO:</p>
			<div style="width: 100%; height: 100%; border:1px solid #6F71B3; box-sizing: border-box; padding:10px;">
				<table>
					<tr>
						<td style="width: 15%;">Attention</td>
						<td style="width: 2%;">:</td>
						<td style="width: 83%;">{{ attn }}</td>
					</tr>
					<tr>
						<td style="width: 15%;">RE</td>
						<td style="width: 2%;">:</td>
						<td style="width: 83%;">{{ patient.fullName }}</td>
					</tr>
					<tr>
						<td style="width: 15%;">Date</td>
						<td style="width: 2%;">:</td>
						<td style="width: 83%;">{{ 'now'|date('F j, Y') }}</td>
					</tr>
					<tr>
						<td style="width: 15%;">Phone</td>
						<td style="width: 2%;">:</td>
						<td style="width: 83%;">{{ phoneNo }}</td>
					</tr>
					<tr>
						<td style="width: 15%;">Fax</td>
						<td style="width: 2%;">:</td>
						<td style="width: 83%;">{{ faxNo }}</td>
					</tr>
				</table>
			</div>
		</div>
		<div style="width: 50%; height: 150px; float: right; box-sizing: border-box; padding-left: 5px;">
			<p style="margin-bottom: 5px;">FROM:</p>
			<div style="width: 100%; height: 100%; border:1px solid #6F71B3; box-sizing: border-box; padding:10px;">
				<table>
					<tr>
						<td style="width: 40%;">Name</td>
						<td style="width: 60%;">: {{ schedule.provider.fullName|default('') }}</td>
					</tr>
					<tr>
						<td style="width: 40%;">Pages</td>
						{#<td style="width: 60%;">: {{ patientLetter.page != '' or patientLetter.page is not null ? patientLetter.page : '2' }}</td>#}
						<td style="width: 60%;">: 2</td>
					</tr>
					<tr>
						<td style="width: 40%;">CC</td>
						{#<td style="width: 60%;">: {{ patientLetter.carbonCopy != '' or patientLetter.carbonCopy is not null ? patientLetter.carbonCopy : '_______' }}</td>#}
						<td style="width: 60%;">: ___________</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	{% set faxCoverSelection = schedule.faxCoverSelection|split(',') %}
	<div style="width:49.5%; height: 70px; margin-top: 51px; box-sizing: border-box; padding:15px; float: right">
		<div style="width: 100%; height: 100%;">
			<input type="checkbox" id="urgent" style="height: 18px; width:18px;" {{ 1 in faxCoverSelection ? 'checked' : '' }}><label style="font-size: 11px; margin-right:40px;"><strong>Urgent</strong></label>
			<input type="checkbox" id="urgent" style="height: 18px; width:18px;" {{ 2 in faxCoverSelection ? 'checked' : '' }}><label style="font-size: 11px; margin-right:40px;"><strong>For Review</strong></label>
			{#<input type="checkbox" id="urgent" style="height: 18px; width:18px;" {{ 3 in faxCoverSelection ? 'checked' : '' }}><label style="font-size: 18px; margin-right:40px;"><strong>Please Comment</strong></label>#}
			<input type="checkbox" id="urgent" style="height: 18px; width:18px;" {{ 4 in faxCoverSelection ? 'checked' : '' }}><label style="font-size: 11px; margin-right:40px;"><strong>Please Reply</strong></label>
		</div>
	</div>
	<div style="width: 100%; height: 600px; margin-top:11px; border: 1px solid #6F71B3; box-sizing: border-box; padding:20px; float: left;">
		<p><strong>Notes:</strong></p>
		<p>Good day {{ attn }}.</p>
		<p>Thank you for your referral.</p>
		<p>Please find attached letter regarding your patient {{ patient.fullName }}</p>
		<p>Kind regards,</p>
		<br>
		<p style="margin:0;">{{ schedule.provider.fullName|default('') }}</p>
		<p style="margin:0;">Freedom Respiratory & Sleep Centre</p>
	</div>
</div>
</body>
</html>