{% 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 %}
<!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>DSRC Letter</title>
</head>
<body style="font-family:'Arial'; font-size:15px;">
<div style="width:768px; height: 882px; position: relative; padding:0px; margin: 0 auto; box-shadow:3px 1px 10px 1px;">
	<div style="width:100%; height: 100px; text-align: left; position: relative;">
		<div style="width: 40%; float: left;">
			<img src="{{ app.request.getSchemeAndHttpHost() ~ asset('bundles/rxconnexion/admin/images/dynamiclogo.jpg') }}" style="width: 100%;"/>
		</div>
		 <div style="float: right; height: 100%; width: 60%;">
			<div style="float: left; width: 60%; height: 100%; text-align: right;">
				{% set faxBranchSelection = [] %}
				<div style="width: 100%; height: 100%;">
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') in ['QSC EDM Mira', 'DSRC EDM Mira'] or 1 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 20px;">Edmonton North Fax : 780-757-1210</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') in ['QSC EDM South', 'DSRC EDM South', 'AMS EDM South'] or 2 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 18px;">Edmonton South Fax : 780-757-1491</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') in ['QSC Sherwood Park', 'DSRC Sherwood Park'] or 3 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 19px;">Sherwood Park Fax &ensp;: 780-570-0046</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') == 'DSRC Calgary North' or 4 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 20px;">Calgary North Fax&ensp;&emsp;: 403-220-0038</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') == 'DSRC Calgary South' or 5 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 21px;">Calgary South Fax&ensp;&emsp;: 780-300-0640</strong></label>
				</div>
			</div>
			<div style="float: right; width: 40%; height: 100%;">
				<img src="{{ app.request.getSchemeAndHttpHost() ~ asset('bundles/rxconnexion/admin/images/bbc.JPG') }}" style="width: 100%; height: auto;"/>
			</div> 
		</div> 
	</div>
	
	<h2 style="text-align: center; margin-top:40px; padding-right: 20px;">Fax Cover Sheet</h2>
	<div style="margin-top:20px; height: 150px; width:100%;">
		<div style="width: 50%; height: 150px; float: left; box-sizing: border-box; padding-right: 5px;">
			<p>TO:</p>
			<div style="width: 100%; height: 100%; border:1px solid #000; box-sizing: border-box; padding:10px;">
				<table>
					<tr>
						<td style="width: 40%;">ATTN</td>
						<td>:</td>
						<td>{{ attn }}</td>
					</tr>
					<tr>
						<td style="width: 40%;">RE</td>
						<td>:</td>
						<td>{{ patient.fullName }}</td>
					</tr>
					<tr>
						<td style="width: 40%;">Date</td>
						<td>:</td>
						<td>{{ 'now'|date('F j, Y') }}</td>
					</tr>
					<tr>
						<td style="width: 40%;">Phone</td>
						<td>:</td>
						<td>{{ phoneNo }}</td>
					</tr>
					<tr>
						<td style="width: 40%;">Fax</td>
						<td>:</td>
						<td>{{ faxNo }}</td>
					</tr>
				</table>
			</div>
		</div>
		<div style="width: 50%; height: 150px; float: right; box-sizing: border-box; padding-left: 5px;">
			<p>FROM:</p>
			<div style="width: 100%; height: 100%; border:1px solid #000; box-sizing: border-box; padding:10px;">
				<table>
					<tr>
						<td style="width: 60%;">Name</td>
						<td>: {{ schedule.provider.fullName|default('') }}</td>
					</tr>
					<tr>
						<td style="width: 60%;">Pages</td>
						<td>: 2</td>
					</tr>
					<tr>
						<td style="width: 60%;">CC</td>
						<td>:___________</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
    {% set faxCoverSelection = schedule.faxCoverSelection|split(',') %}
	<div style="width:100%; height: 70px; margin-top: 80px; box-sizing: border-box; padding:20px; border:1px solid #000;">
		<div style="width: 100%; height: 100%;">
			<input type="checkbox" id="urgent" style="height: 18px; width:18px;" {{ 1 in faxCoverSelection ? 'checked' : '' }}><label style="font-size: 18px; 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: 18px; 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: 18px; margin-right:40px;"><strong>Please Reply</strong></label>
		</div>
	</div>
	<div style="width: 100%; height: auto; margin-top:25px; border: 1px solid #000; box-sizing: border-box; padding:20px;">
		<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;">Dynamic Sleep Respiratory Care</p>
	</div>
	<p style="font-size: 10px;">"This Facsimile transmission contains information which is confidential and/or privileged. This information is intended for use only by the addressee indicated above. If you are not the intended recipient, please be advised that any disclosure, copying, distribution or use of the contents of this information is stricly prohibited, and that any misdirected or improperly received information must be returned to this company immediately. Your cooperation in phoning us of erroneous receipt is requested."</p>
	<!-- <div style="height: 400px; position: relative;"></div>
	<div style="width: 100%; height: 60px; color:#717171; position: fixed;">
		<div style="width:20%; float: left; font-size: 12px;">
			<p style="margin:0;"><strong>EDMONTON NORTH</strong></p>
			<p style="margin:0;">Mira Health Clinic</p>
			<p style="margin:0;">Unit 108, 1190-111 Ave.</p>
			<p style="margin:0;">Edmonton, Alberta</p>
			<p style="margin:0;">T5G 3G6</p>
		</div>
		<div style="width:20%; float: left; font-size: 12px;">
			<p style="margin:0;"><strong>EDMONTON SOUTH</strong></p>
			<p style="margin:0;">Millwoods</p>
			<p style="margin:0;">6570 28 Ave NW</p>
			<p style="margin:0;">Edmonton, Alberta</p>
			<p style="margin:0;">T6L 6N3</p>
		</div>
		<div style="width:19%; float: left; font-size: 12px;">
			<p style="margin:0;"><strong>CALGARY NORTH</strong></p>
			<p style="margin:0;">Bldg. 107, 12 Ave. NW</p>
			<p style="margin:0;">Calgary, Alberta</p>
			<p style="margin:0;">T2M 0C4</p>
		</div>
		<div style="width:19%; float: left; font-size: 12px;">
			<p style="margin:0;"><strong>CALGARY SOUTH</strong></p>
			<p style="margin:0;">#44, 6130-1A Street</p>
			<p style="margin:0;">Calgary, Alberta</p>
			<p style="margin:0;">T2H 0G3</p>
		</div>
		<div style="width:22%; float: left; font-size: 12px;">
			<p style="margin:0;"><strong>SHERWOOD PARK</strong></p>
			<p style="margin:0;">Unit 168, 150 Chippewa Road</p>
			<p style="margin:0;">Sherwood Park, Alberta</p>
			<p style="margin:0;">T8A 6A</p>
		</div>
	</div> -->

</div>

<!------ 2ND PAGE -------->
<div style="width:768px; height: 882px; position: relative; padding:0px; margin: 0 auto; box-shadow:3px 1px 10px 1px;">
	<div>
		<div style="width:100%; height: 80px; text-align: left; position: relative; margin-top:500px;">
			<div style="width: 40%; float: left;">
				<img src="{{ app.request.getSchemeAndHttpHost() ~ asset('bundles/rxconnexion/admin/images/dynamiclogo.jpg') }}" style="width: 100%;"/>
			</div>
			<div style="float: right; height: 100%; width: 60%;">
				<div style="float: left; width: 60%; height: 100%; text-align: right;">
				{% set faxBranchSelection = [] %}
				<div style="width: 100%; height: 100%;">
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') in ['QSC EDM Mira', 'DSRC EDM Mira'] or 1 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 20px;">Edmonton North Fax : 780-757-1210</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') in ['QSC EDM South', 'DSRC EDM South', 'AMS EDM South'] or 2 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 18px;">Edmonton South Fax : 780-757-1491</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') in ['QSC Sherwood Park', 'DSRC Sherwood Park'] or 3 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 19px;">Sherwood Park Fax &ensp;: 780-570-0046</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') == 'DSRC Calgary North' or 4 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 20px;">Calgary North Fax&ensp;&emsp;: 403-220-0038</strong></label>
					<br>
					<input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.healthFacility.description|default('') == 'DSRC Calgary South' or 5 in faxBranchSelection ? 'checked' : '' }}><label style="font-size: 13px;"><strong style="margin-right: 21px;">Calgary South Fax&ensp;&emsp;: 780-300-0640</strong></label>
				</div>
				</div>
				<div style="float: right; width: 40%; height: 100%;">
					<img src="{{ app.request.getSchemeAndHttpHost() ~ asset('bundles/rxconnexion/admin/images/bbc.JPG') }}" style="width: 100%; height: auto;"/>
				</div>
			</div>
		</div>
		<br>
		<br>
		<div style="width: 100%; height: 35px; background-color: #f0f0f0; box-sizing: border-box; padding:8px; position: relative;">
			<p style="margin:0; font-size: 18px; float: left;"><strong>APPOINTMENT NOTICE</strong></p>
			<p style="margin:0; font-size: 18px; float: right;"><strong>1 833 DYNA SLEEP</strong></p>
		</div>
		<hr style="margin: 0; height: 4px; background-color: #1676a9; margin-top:3px; margin-bottom: 20px;">
		<!-- <div style="width: 100%; height: 300px;">
            <div style="width: 50%">

            </div>
        </div> -->
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 50%; height: 100%; float: left; text-align: left; font-size:18px;">
				<p style="margin:0">Last Name : {{ patient.lastName }}</p>
			</div>
			<div style="width: 50%; height: 100%; float:right; text-align: left; font-size:18px;">
				<p style="margin:0">First Name : {{ patient.firstName }}</p>
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 50%; height: 100%; float: left; text-align: left; font-size:18px;">
				<span style="margin-right: 40px;"><input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.gender == 'Male' ? 'checked' : '' }}><label style="font-size: 16px; margin-left:15px;">Male</label></span>
				<span style="margin-right: 40px;"><input type="checkbox" id="add" style="height: 15px; width:15px;" {{ patient.gender == 'Female' ? 'checked' : '' }}><label style="font-size: 16px; margin-left:15px;">Female</label></span>
			</div>
			<div style="width: 50%; height: 100%; float:right; text-align: left; font-size:18px;">
				<p style="margin:0">Date of Birth : {{ patient.birthDate|date("Y/d/m") }}</p>
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 50%; height: 100%; float: left; text-align: left; font-size:18px;">
				
				<p style="margin:0">Physician : {{ attn }}</p>
			</div>
			<div style="width: 50%; height: 100%; float:right; text-align: left; font-size:18px;">
				<p style="margin:0">Sleep Clinician : {{ schedule.provider.fullName|default('') }}</p>
				
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 50%; height: 100%; float: right; text-align: left; font-size:18px;">
				<p style="margin:0">Date : {{ 'now'|date('F j, Y') }}</p>
			</div>
			<div style="width: 50%; height: 100%; float:right; text-align: left; font-size:18px;">
				<p style="margin:0">ULI/PHN : {{ patient.personalHealthNo }}</p>
				
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 50%; height: 100%; float:left; text-align: left; font-size:18px;">
				<p style="margin:0">Phone : {{ phoneNo }}</p>
			</div>
			<div style="width: 50%; height: 100%; float: left; text-align: left; font-size:18px;">
				<p style="margin:0">Fax : {{ faxNo }}</p>
				
			</div>
		</div>
		<br />
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative; margin-top: 25px;">
			<div style="margin: 0 auto; height: 100%; font-size:18px;">
				<p style="margin:0">Thank you for the referral. Your patient is booked for a sleep study test on:</p>
			</div>
		</div>

		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="margin: 0 auto; height: 100%; font-size:18px;">
				<p style="margin:0">Date: {{ schedule.scheduleDate|date('F j, Y') }}  Time: {{ schedule.startTime }}</p>
					
			</div>
		</div>
		<div style="width: 100%; height: 140px; box-sizing: border-box; padding:10px; border:2px solid #000; position: relative; text-align: left;">
						<p style="margin:0;">NOTES: </p>
						<p style="margin:0;">{{ schedule.note }}</p>
					</div>
        {#<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
            <div style="width: 80%; margin: 0 auto; height: 100%; font-size:18px;">
                <p style="margin: 0;">Notes: {{ schedule.note }}</p>
            </div>
        </div>#}
		<div style="width: 100%; height: auto; box-sizing: border-box; padding:5px; position: relative;">
			<p style="margin:0; font-size: 18px;">Your patient will be using a <strong>HOME SLEEP APNEA TESTING DEVICE</strong> overnight and it needs
				to be collected/returned the following day between 9:00am and 11:00am. The instructions
				for how to use the <strong>SLEEP TESTING DEVICE</strong> will be given to the patient during her/his
				appointment date.</p>
		</div>
        {% set faxBodySelection = schedule.faxBodySelection|split(',') %}
        
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 100%; height: 100%; float: left; text-align: left;">
				<span style="margin-right: 40px;"><input type="checkbox" id="add" style="height: 15px; width:15px; margin-left: 15px" {{ 1 in faxBodySelection ? 'checked' : '' }}><label style="font-size: 18px; margin-left:15px;">Patient is aware of the appointment</label></span>
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 100%; height: 100%; float: left; text-align: left;">
				<span style="margin-right: 40px;"><input type="checkbox" id="add" style="height: 15px; width:15px; margin-left: 15px" {{ 2 in faxBodySelection ? 'checked' : '' }}><label style="font-size: 18px; margin-left:15px;">Message left on the voicemail</label></span>
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 100%; height: 100%; float: left; text-align: left;">
				<span style="margin-right: 40px;"><input type="checkbox" id="add" style="height: 15px; width:15px; margin-left: 15px" {{ 3 in faxBodySelection ? 'checked' : '' }}><label style="font-size: 18px; margin-left:15px;">Patient declined test</label></span>
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 100%; height: 100%; float: left; text-align: left;">
				<span style="margin-right: 40px;"><input type="checkbox" id="add" style="height: 15px; width:15px; margin-left: 15px" {{ 4 in faxBodySelection ? 'checked' : '' }}><label style="font-size: 15px; margin-left:15px;">Patient is unable to contact. Please inform the patient of the appointment.</label></span>
			</div>
		</div>
		<div style="width: 100%; height: 40px; box-sizing: border-box; padding:5px; position: relative;">
			<div style="width: 100%; height: 100%; float: left; text-align: left;">
				<span style="margin-right: 40px;"><input type="checkbox" id="add" style="height: 15px; width:15px; margin-left: 15px" {{ 5 in faxBodySelection ? 'checked' : '' }}><label style="font-size: 18px; margin-left:15px;">Patient is on CPAP Trial/Evaluation.</label></span>
			</div>
		</div>
		<div style="width: 100%; height: 20px; box-sizing: border-box; padding:5px; position: relative; text-align: center;">
			<p style="margin:0; font-size: 18px;"><strong>If you have any questions, please feel free to contact the Office.</strong></p>	<!--  -->
		</div>
	</div>
</div>
</body>
</html>