{% 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 %}
<!------ 1ST PAGE ------>
{% include '@RxConnexion/Patient/FaxTemplate/PerfectSleepTemplate/pss_fax_cover_appointment_notice.wkpdf.twig' with {anf: anf} %}
<div style="page-break-before: always"></div>
<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;">Appointment Notice</h3>
	<div style="margin-top:12px; height: 150px; width:100%; font-size: 15px;">
		<p>Date: {{ 'now'|date('m/d/Y') }}</p>
		<p>Full Name: {{ patient.lastName~' ,'~patient.firstName }}</p>
		<div style="float: left; width: 100%;">
			<span style="width: 40%; float: left;">Address: {{ patient.street }}</span>
			<span style="width: 20%; float: left;">City: {{ patient.city.description|default('') }}</span>
			<span style="width: 20%; float: left;">Province: {{ patient.city.province.description|default('') }}</span>
			<span style="width: 20%; float: left;">Postal: {{ patient.postalCode.description }}</span>
		</div>
		<div style="float: left">
			<p>Date of Birth: {{ patient.birthDate|date('m/d/y') }}</p>
			<p>Physician: {{ attn|default('') }}</p>
			<p>Phone: {{ phoneNo }}</p>
		</div>
		<div style="float: right">
			<div style="float: right">
				<span><input type="checkbox" {{ patient.gender == 'Male' ? 'checked' : '' }}>&nbsp; Male</span>
				<span><input type="checkbox" {{ patient.gender == 'Female' ? 'checked' : '' }}>&nbsp; Female</span>
				<span><input type="checkbox" {{ patient.gender == 'null' ? 'checked' : '' }}>&nbsp; Undeclared</span>
				<p>ULI/PHN: {{ patient.personalHealthNo|default('') }}</p>
				<p>Fax: {{ faxNo }}</p>
			</div>
		</div>
	</div>
	<div style="width: 100%; height: 400px; margin-top:11px; margin-bottom: 5%; border: 1px solid #6F71B3; box-sizing: border-box; padding-top:20px; float: left; font-size: 15px; padding-left: 10%; padding-right: 10%;">
		<div style="text-align: center;">
			<div>Thank you for the Referral</div>
			<div>Your patient is booked for a sleep test on:</div>
		</div>
		<div>
			<p>Appointment Date: {{ schedule.scheduleDate|date('F j, Y') }}</p>
			<p>Appointment Time: {{ schedule.startTime }}</p>
		</div>
		<div>Notes: {{ schedule.note }}</div>

		{% set faxBodySelection = schedule.faxBodySelection|split(',') %}
		<div style="margin-left: 10%; margin-top: 30px;">
			<div><input type="checkbox" {{ 1 in faxBodySelection ? 'checked' : '' }}> Patient is aware of the appointment.</div>
			<div><input type="checkbox" {{ 2 in faxBodySelection ? 'checked' : '' }}> Message left on the voicemail.</div>
			<div><input type="checkbox" {{ 3 in faxBodySelection ? 'checked' : '' }}> Patient declined the test.</div>
			<div><input type="checkbox" {{ 4 in faxBodySelection ? 'checked' : '' }}> Patient is unable to contact. Please inform the patient of the appointment</div>
			<div><input type="checkbox" {{ 5 in faxBodySelection ? 'checked' : '' }}> Patient is on CPAP Trial/Evaluation</div>
		</div>
	</div>
	<div style="width: 100%; float: left;">
		<div style="text-align: center; font-size: 15px;">
			<div>Your patient will be using a <strong>Home Sleep Apnea Testing Device</strong> overnight and it needs to be</div>
			<div>returned the following day between 9:00am and 11:00am. The instructions for how to use</div>
			<div>the device will be given to the patient during their appointment.</div>
		</div>
	</div>
</div>
</body>
</html>