{% set absUrl = app.request.getSchemeAndHttpHost() ~ app.request.baseUrl|replace({'/app_dev.php': ''}) %}
{% set customBody = patientLetter.customBody|replace({'{{PATIENT-FIRSTNAME}}' :  patientLetter.patient.firstName, '{{PATIENT-FULLNAME}}' : patientLetter.patient.fullName, '{{PATIENT-GENDER}}' : patientLetter.patient.gender == 'Male' ? 'he' : 'she', '{{PATIENT-GENDER2}}' : patientLetter.patient.gender == 'Male' ? 'him' : 'her', '{{PATIENT-GENDER3}}' : patientLetter.patient.gender == 'Male' ? 'his' : 'her', '{{PATIENT-GENDER4}}' : patientLetter.patient.gender == 'Male' ? 'He' : 'She'}) %}
{% 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>DSRC Letter</title>
</head>
<body style="font-family:'Arial'; font-size:18px;">
{% if patientLetter.patientReferringProvider %}
	{% set rp = patientLetter.patientReferringProvider.referringProvider %}
	{% set patient = patientLetter.patient %}
	{% set receiverFullName = patientLetter.patientReferringProvider.referringProvider.honorific ~ ' ' ~ patientLetter.patientReferringProvider.referringProvider.fullName|title %}
	{% if patientLetter.patientReferringProvider.referringProvider.phoneNo is null or patientLetter.patientReferringProvider.referringProvider.phoneNo == '' %}
		{% set receiverPhone = '' %}
		{% for prhf in patient.patientReferringHealthFacilities %}
			{% for rhfp in rp.referringHealthFacilityProviders %}
				{% if prhf.referringHealthFacility.id == rhfp.referringHealthFacility.id %}
					{% set receiverPhone = prhf.referringHealthFacility.phoneNo %}
				{% endif %}
			{% endfor %}
		{% endfor %}
	{% else %}
		{% set receiverPhone = patientLetter.patientReferringProvider.referringProvider.phoneNo %}
	{% endif %}
	{% if patientLetter.patientReferringProvider.referringProvider.faxNo is null or patientLetter.patientReferringProvider.referringProvider.faxNo == '' %}
		{% set receiverFax = '' %}
		{% for prhf in patient.patientReferringHealthFacilities %}
			{% for rhfp in rp.referringHealthFacilityProviders %}
				{% if prhf.referringHealthFacility.id == rhfp.referringHealthFacility.id %}
					{% set receiverFax = prhf.referringHealthFacility.faxNo %}
				{% endif %}
			{% endfor %}
		{% endfor %}
	{% else %}
		{% set receiverFax = patientLetter.patientReferringProvider.referringProvider.faxNo %}
	{% endif %}
{% endif %}
{% if patientLetter.patientReferringHealthFacility %}
	{% set receiverFullName = patientLetter.patientReferringHealthFacility.referringHealthFacility.description %}
	{% set receiverPhone = patientLetter.patientReferringHealthFacility.referringHealthFacility.phoneNo is null ? patientLetter.patientReferringHealthFacility.referringHealthFacility.phoneNoTwo : patientLetter.patientReferringHealthFacility.referringHealthFacility.phoneNo %}
	{% set receiverFax = patientLetter.patientReferringHealthFacility.referringHealthFacility.faxNo is null ? patientLetter.patientReferringHealthFacility.referringHealthFacility.faxNoTwo : patientLetter.patientReferringHealthFacility.referringHealthFacility.faxNo %}
{% endif %}
{% if patientLetter.patientInsurance %}
	{% set receiverFullName = patientLetter.patientInsurance.insurance.description %}
	{% set receiverPhone = patientLetter.patientInsurance.insurance.phoneNo is null ? patientLetter.patientInsurance.insurance.phoneNoTwo : patientLetter.patientInsurance.insurance.phoneNo %}
	{% set receiverFax = patientLetter.patientInsurance.insurance.faxNo is null ? patientLetter.patientInsurance.insurance.faxNoTwo : patientLetter.patientInsurance.insurance.faxNo %}
{% endif %}
{% set patientFullName = patientLetter.patient.fullName %}
{% set patientFirstName = patientLetter.patient.firstName %}
{% set patientLastName = patientLetter.patient.lastName %}
{% set patient = patientLetter.patient %}

{% set faxCoverCustomBody = patientLetter.faxCoverCustomBody|replace({'{{RECEVIER-FULLNAME}}' :  receiverFullName, '{{PATIENT-FULLNAME}}' : patientFullName, '{{USERDATA-FULLNAME}}' : userData.fullName}) %}

<!------ 1ST PAGE ------>
{% include '@RxConnexion/Patient/FaxTemplate/FreedomTemplate/frsi_fax_cover.wkpdf.twig' with {patientLetter: patientLetter} %}
<div style="page-break-before: always"></div>
<div style="width:1024px; position: relative; padding:0px; margin: 0 auto; box-shadow:3px 1px 10px 1px;">
	<h3 style="text-align: center; margin-top:35px; padding-right: 40px;">REFUSAL OF CARE AGAINST MEDICAL ADVICE</h3>
	<div style="margin-top:30px; width:100%; font-size: 22px; float: left;">
		<div>I, {{ patientLetterRefusalCare.name|default('_________________') }} acknowledge that i have been diagnosed with Obstructive Sleep Apnea which requires
		medical treatment/therapy, I have elected to seek an alternative treatment or refuse further evaluation and/or treatement at
		this time.</div>
		<br>
		<div>I have been advice by a Freedom Respiratory & Sleep Centre Clinician that, CPAP Treatment is necessary and that
		refusal of therapy could be hazardous to my health.</div>
		<br>
		<div>By signing this form, I am releasing Freedom Respiratory & Sleep Centre and all directors, constituents, employees, licensed
		clinicians from any and all liability or medical claims and demands resulting from my decision to refuse treatment of therapy
		care against medical advice</div>
	</div>
	<div style="margin-top:2%; width:100%; font-size: 22px; float: left;">
		<h3><strong>Patient Statement:</strong></h3>
		<div>Reason for Return/Refusal Treatment, please include date, time and specific names of individuals</div>
		<br>
		<div>{{ patientLetterRefusalCare.patientStatement|default('') }}</div>
		<br>
		<div>Furthermore, I understand Freedom Respiratory & Sleep Centre needs to notify my Physician about the decision to return the</div>
		<div>Therapy Device for treating Sleep Apnea</div>
		<br>
		<div>I have read and understand the above infomation, including the Release of Liability</div>
		<br>
		<div style="width: 100%;">
			<div style="width: 50%; float: left">Signature:_____________________________</div>
			<span style="width: 50%; float: right">Date: {{ patientLetterRefusalCare.getPatientStatementDateAsString|default('_____________________________') }}</span>
		</div>
	</div>
	<div style="margin-top:5%; width:100%; font-size: 22px; float: left;">
		<h3><strong>Witness Information</strong></h3>
		<div>Freedom Respiratory & Sleep Centre Respiratory</div>
		<div>Name: (printed) {{ patientLetterRefusalCare.getWitnessInfoName|default('________________________________') }}</div>
		<div>Signature:______________________________________</div>
		<div>Date: {{ patientLetterRefusalCare.getWitnessInfoDateAsString|default('___________________________________________') }}</div>
	</div>
</div>
</body>
</html>