<?php echo $this->partial('Layout/nav'); ?>

<div class="container">
	<div class="container-page-wrapper shodowed bordered">
		<div class="container-page-container">
			<div class="row">
				<div class="col-lg-8">
					<h1>
						<?php echo $this->actionTitle; ?>
						<img src="/images/oticonotoaccess.png" class="btn-run-process" width="400" height="68" style="float: left; margin-top: 10px;">
					</h1>
				</div>
				<div class="col-lg-4 clearfix">
					<div class="float-right">
						
						<?php if($this->view->userIsModerator || $this->view->userIsAuthor): ?>
							<button type="button" class="btn btn-danger btn-delete-request" data-requestid="<?php echo $this->view->requestData['id']; ?>"><?php echo _('Delete request'); ?></button>
						<?php endif; ?>
						
					</div>
				</div>
			</div>
			<hr>
			<?php //debug($this->view->dreamData); ?>

			<form id="request-save">
				<input type="hidden" id="request-id" name="data[request_id][value]" value="<?php echo $this->view->requestId; ?>">
				<input type="hidden" id="request-unique-code" name="data[request_unique_code][value]" value="<?php echo $this->view->requestUniqueCode; ?>">
				<input type="hidden" id="request-page-type" value="request-edit">

				<input type="hidden" name="data[dream_data][value]" id="request_dream_data" value="<?php echo $this->view->dreamData; ?>">
				<input type="hidden" id="request-dream-evt-id" name="data[dream_evt_id][value]" value="">

				<div class="form-row">

					<div class="form-group col-lg-12">
						<h4 class="text-center"><?php echo _('Patient registry'); ?></h4>
						<hr>
					</div>

					<div class="form-group col-lg-5 cc-wrapper">
						<label class="label-main" for=""><?php echo _('Clinical Center'); ?></label>
						<select class="form-control field-request_cc" id="request_cc" name="data[request_cc][value]">
							<?php if(count($this->view->userClinicalCenters) > 1): ?>
								<option value=""></option>
							<?php endif; ?>
							<?php foreach($this->view->userClinicalCenters as $ccId => $ccItem): ?>
								<?php
									$selected = isset($ccItem['selected']) && $ccItem['selected'] ? 'selected' : '';
									if(count($this->view->userClinicalCenters) == 1) {
										$selected = 'selected';
									}
								?>
								<option value="<?php echo $ccId; ?>" <?php echo $selected; ?>><?php echo $ccItem['description']; ?></option>
							<?php endforeach; ?>
						</select>

						<input type="hidden" name="data[request_cc][required]" value="1">
						<input type="hidden" name="data[request_cc][type]" value="text">
						<input type="hidden" name="data[request_cc][class]" value="field-request_cc">
						<input type="hidden" name="data[request_cc][label]" value="<?php echo _('Clinical Center'); ?>">
					</div>

					<div class="form-group col-lg-3 dream-wrapper">
						<label class="label-main" for="dream_code"><?php echo _('DREAM Integration'); ?></label>

						<fieldset class="ws-cc-code-container" <?php //echo !$this->view->hasDreamIntegration ? 'disabled' : ''; ?>>
							<div class="row">
								<div class="col-lg-8">
									<input type="text" class="form-control" placeholder="<?php echo _('Code'); ?>" value="<?php echo $this->view->dreamCode; ?>" id="dream_code" name="data[dream_code][value]">
									<small class="text-muted"><span class="icon-checkmark"></span> <span class="ws-cc-name"></span></small>
								</div>
								<div class="col-lg-4">
									<button type="button" class="btn btn-light btn-block btn-ws-send-code"><span class="icon-point-right"></span></button>
								</div>


							</div>
						</fieldset>

						<input type="hidden" name="data[dream_code][required]" value="0">
					</div>
					
					<div class="form-group col-lg-3 dream-italy-wrapper">
						<label class="label-main" for="dream_italy_code"><?php echo _('DREAM Italy'); ?></label>

						<fieldset class="ws-cc-code-container" <?php //echo !$this->view->hasDreamIntegration ? 'disabled' : ''; ?>>
							<div class="row">
								<div class="col-lg-8">
									<input type="hidden" id="dream-italy-endpoint" value="<?php echo $this->view->dreamItalyEndPoint; ?>">
									<input type="hidden" id="dream-italy-apikey" value="<?php echo $this->view->dreamItalyApiKey; ?>">
									<input type="text" class="form-control" placeholder="<?php echo _('Code'); ?>" value="<?php echo $this->view->dreamCode; ?>" id="dream_italy_code" name="data[dream_italy_code][value]">
									
								</div>
								<div class="col-lg-4">
									<button type="button" class="btn btn-light btn-block btn-dream-italy-send-code"><span class="icon-point-right"></span></button>
								</div>


							</div>
						</fieldset>

						<input type="hidden" name="data[dream_code][required]" value="0">
					</div>
					
					<div class="form-group col-lg-3 sportellocura-wrapper">
						<label class="label-main" for="sportellocura_code">Sportello Cura</label>

						<fieldset class="ws-cc-code-container">
							<div class="row">
								<div class="col-lg-8">
									<input type="hidden" id="sportellocura-endpoint" value="<?php echo $this->view->sportelloCuraEndPoint; ?>">
									<input type="hidden" id="sportellocura-apikey" value="<?php echo $this->view->sportelloCuraApiKey; ?>">
									<input type="hidden" id="sportellocura-survey-data" name="data[sportellocura][value]" value="">
									<input type="text" class="form-control" placeholder="#ID" value="" id="sportellocura_code" name="data[sportellocura_code][value]">
									
								</div>
								<div class="col-lg-4">
									<button type="button" class="btn btn-light btn-block btn-sportellocura-send-code"><span class="icon-point-right"></span></button>
								</div>


							</div>
						</fieldset>

						<input type="hidden" name="data[dream_code][required]" value="0">
					</div>

					<div class="form-group col-lg-3 ws-reconnect-wrapper">
						<button type="button" class="btn btn-primary btn-block btn-ws-reconnect"><?php echo _('Reconnect'); ?></button>
					</div>

					<div class="form-group col-lg-3">
						<label class="label-main" for="request_name"><?php echo _('Name'); ?></label>
						<input type="text" class="form-control field-request_name" value="<?php echo isset($this->view->requestData['patient_name']) ? $this->view->requestData['patient_name'] : ''; ?>" id="request_name" name="data[request_name][value]">

						<input type="hidden" name="data[request_name][required]" value="1">
						<input type="hidden" name="data[request_name][type]" value="text">
						<input type="hidden" name="data[request_name][class]" value="field-request_name">
						<input type="hidden" name="data[request_name][label]" value="<?php echo _('Name'); ?>">
					</div>

					<div class="form-group col-lg-3">
						<label class="label-main" for="request_surname"><?php echo _('Surname'); ?></label>
						<input type="text" class="form-control field-request_surname" value="<?php echo isset($this->view->requestData['patient_surname']) ? $this->view->requestData['patient_surname'] : ''; ?>" id="request_surname" name="data[request_surname][value]">

						<input type="hidden" name="data[request_surname][required]" value="1">
						<input type="hidden" name="data[request_surname][type]" value="text">
						<input type="hidden" name="data[request_surname][class]" value="field-request_name">
						<input type="hidden" name="data[request_surname][label]" value="<?php echo _('Surname'); ?>">
					</div>

					<div class="form-group col-lg-1">
						<label class="label-main" for="request_gender"><?php echo _('Sex'); ?></label>

						<select class="form-control field-request_gender" value="" id="request_gender" name="data[request_gender][value]">
							<option value=""></option>
							<option value="f" <?php echo isset($this->view->requestData['gender']) && $this->view->requestData['gender'] == 'f' ? 'selected' : ''; ?>><?php echo _('F'); ?></option>
							<option value="m" <?php echo isset($this->view->requestData['gender']) && $this->view->requestData['gender'] == 'm' ? 'selected' : ''; ?>><?php echo _('M'); ?></option>
						</select>

						<input type="hidden" name="data[request_gender][required]" value="1">
						<input type="hidden" name="data[request_gender][type]" value="text">
						<input type="hidden" name="data[request_gender][class]" value="field-request_name">
						<input type="hidden" name="data[request_gender][label]" value="<?php echo _('Sex'); ?>">
					</div>

					<div class="form-group col-lg-5">
						<label class="label-main"><?php echo _('Date of birth / Age'); ?></label>
						<div class="form-check">
							<input class="form-check-input check-birth-type" name="data[request_birth_type][value]" type="radio" value="date" id="birth-as-date-radio" checked>
							<label class="form-check-label" for="birth-as-date-radio">
								<?php echo _('Date of birth known'); ?>
							</label>

						</div>
						<div class="form-check">
							<input class="form-check-input check-birth-type" name="data[request_birth_type][value]" type="radio" value="number" id="birth-as-number-radio">
							<label class="form-check-label" for="birth-as-number-radio">
								<?php echo _('Approximate age'); ?>
							</label>

						</div>

						<input name="data[request_birth_type][required]" type="hidden" value="0">
					</div>

					<?php /*if(!isset($this->view->requestData['birthdate'])): ?>
						<div class="form-group col-lg-7 birth-date-placeholder text-center text-muted"></div>
					<?php endif;*/ ?>

					<div class="form-group col-lg-2 birth-as-date <?php echo isset($this->view->requestData['birthdate']) ? 'birth-as-date-visible' : ''; ?>">
						<label class="label-main" for="request_birth_year"><?php echo _('Year of birth'); ?></label>

						<select class="form-control field-request_birth_year" id="request_birth_year" name="data[request_birth_year][value]">
							<option value="0"></option>
							<?php for($year=(int)date('Y'); $year>(int)date('Y')-120; $year--): ?>
								<?php
									$selected = '';
									if (isset($this->view->requestData['birthdate'])) {
										$birthYear = date('Y', strtotime($this->view->requestData['birthdate']));
										$selected = $year == $birthYear ? 'selected' : '';
									}
								?>
								<option value="<?php echo $year; ?>" <?php echo $selected; ?>><?php echo $year; ?></option>
							<?php endfor; ?>
						</select>

						<input type="hidden" name="data[request_birth_year][required]" value="0">
						<input type="hidden" name="data[request_birth_year][type]" value="text">
						<input type="hidden" name="data[request_birth_year][class]" value="field-request_birth_year">
						<input type="hidden" name="data[request_birth_year][label]" value="<?php echo _('Year of birth'); ?>">
					</div>

					<div class="form-group col-lg-2 birth-as-date">
						<label class="label-main" for="request_birth_month"><?php echo _('Month of birth'); ?></label>
						<select class="form-control field-request_birth_month" id="request_birth_month" name="data[request_birth_month][value]">
							<option value="0"></option>
							<?php for($m=1; $m<13; $m++): ?>
								<?php
									$selected = '';
									if (isset($this->view->requestData['birthdate'])) {
										$birthMonth = date('m', strtotime($this->view->requestData['birthdate']));
										$selected = $m == $birthMonth ? 'selected' : '';
									}
								?>
								<option value="<?php echo $m; ?>" <?php echo $selected; ?>><?php echo leadingZeros($m); ?></option>
							<?php endfor; ?>
						</select>

						<input type="hidden" name="data[request_birth_month][required]" value="0">
						<input type="hidden" name="data[request_birth_month][type]" value="text">
						<input type="hidden" name="data[request_birth_month][class]" value="field-request_name">
						<input type="hidden" name="data[request_birth_month][label]" value="<?php echo _('Month of birth'); ?>">
					</div>

					<div class="form-group col-lg-2 birth-as-date <?php echo isset($this->view->requestData['birthdate']) ? 'birth-as-date-visible' : ''; ?>">
						<label class="label-main" for="request_birth_month_day"><?php echo _('Day of birth'); ?></label>

						<select class="form-control field-request_birth_month_day" id="request_birth_month_day" name="data[request_birth_month_day][value]">
							<option value="0"></option>
							<?php for($d=1; $d<32; $d++): ?>
								<?php
									$selected = '';
									if (isset($this->view->requestData['birthdate'])) {
										$birthDay = date('d', strtotime($this->view->requestData['birthdate']));
										$selected = $d == $birthDay ? 'selected' : '';
									}
								?>
								<option value="<?php echo $d; ?>" <?php echo $selected; ?>><?php echo leadingZeros($d); ?></option>
							<?php endfor; ?>
						</select>

						<input type="hidden" name="data[request_birth_month_day][required]" value="0">
						<input type="hidden" name="data[request_birth_month_day][type]" value="text">
						<input type="hidden" name="data[request_birth_month_day][class]" value="field-request_name">
						<input type="hidden" name="data[request_birth_month_day][label]" value="<?php echo _('Day of birth'); ?>">
					</div>

					<div class="form-group col-lg-1 birth-as-number">
						<label class="label-main" for="request_age"><?php echo _('Age'); ?></label>
						<input min="0" max="150" step="1" type="number" class="form-control field-request_age" id="request_age" name="data[request_age][value]" value="">

						<input type="hidden" name="data[request_age][required]" value="0">
						<input type="hidden" name="data[request_age][type]" value="text">
						<input type="hidden" name="data[request_age][class]" value="field-request_age">
						<input type="hidden" name="data[request_age][label]" value="<?php echo _('Age'); ?>">
					</div>

					<div class="form-group col-lg-2 birth-as-number">
						<label class="label-main" for="request_unit_of_time"><?php echo _('Unit of time'); ?></label>
						<select class="form-control field-unit_of_time" id="request_unit_of_time" name="data[request_unit_of_time][value]">
							<option value="y"><?php echo _('Years'); ?></option>
							<option value="m"><?php echo _('Months'); ?></option>
						</select>

						<input type="hidden" name="data[request_unit_of_time][required]" value="0">
						<input type="hidden" name="data[request_unit_of_time][type]" value="text">
						<input type="hidden" name="data[request_unit_of_time][class]" value="field-unit_of_time">
						<input type="hidden" name="data[request_unit_of_time][label]" value="<?php echo _('Unit of time'); ?>">
					</div>

					<div class="form-group col-lg-1 text-center">
						<div id="calculated-age-number"></div>
					</div>

					<div class="form-group col-lg-12">
						<label class="label-main" for="request_anonymisation"><?php echo _('Anonymisation'); ?></label>

						<div class="form-check">
							<input type="hidden" name="data[request_anonymisation][value]" value="0">
							<input class="form-check-input field-request_anonymisation-0" type="checkbox" name="data[request_anonymisation][value]" value="1" id="request-anonymisation-0" <?php echo isset($this->view->requestData['request_anonymous']) && $this->view->requestData['request_anonymous'] == 1 ? 'checked' : ''; ?>>
							<label class="form-check-label" for="request-anonymisation-0">
								<?php echo _('Make this patient anonymous for everyone'); ?>
							</label>
						</div>

						<input type="hidden" name="data[request_anonymisation][required]" value="0">
						<input type="hidden" name="data[request_anonymisation][type]" value="text">
						<input type="hidden" name="data[request_anonymisation][class]" value="field-request_anonymisation">
						<input type="hidden" name="data[request_anonymisation][label]" value="<?php echo _('Anonymisation'); ?>">
					</div>

					<div class="form-group col-lg-12">
						<hr>
						<h4 class="text-center"><?php echo _('Request details'); ?></h4>
						<hr>
					</div>

					<div class="form-group col-lg-12">
						<div class="row">
							<div class="col-lg-6">
								<label class="label-main"><?php echo _('Triage'); ?></label>

								<div class="text-center">
									<div title="<?php echo _('White'); ?>" class="triage-radio triage-white" data-toggle="tooltip">
										<div class="triage-radio-wrap"><input type="radio" name="data[triage][value]" value="white" <?php echo !isset($this->view->requestData['triage_color']) || $this->view->requestData['triage_color'] == 'white' ? 'checked' : ''; ?>></div>
									</div>
									<div title="<?php echo _('Green'); ?>" class="triage-radio triage-green" data-toggle="tooltip">
										<div class="triage-radio-wrap"><input type="radio" name="data[triage][value]" value="green" <?php echo isset($this->view->requestData['triage_color']) && $this->view->requestData['triage_color'] == 'green' ? 'checked' : ''; ?>></div>
									</div>
									<div title="<?php echo _('Yellow'); ?>" class="triage-radio triage-yellow" data-toggle="tooltip">
										<div class="triage-radio-wrap"><input type="radio" name="data[triage][value]" value="yellow" <?php echo isset($this->view->requestData['triage_color']) && $this->view->requestData['triage_color'] == 'yellow' ? 'checked' : ''; ?>></div>
									</div>
									<div title="<?php echo _('Red'); ?>" class="triage-radio triage-red" data-toggle="tooltip">
										<div class="triage-radio-wrap"><input type="radio" name="data[triage][value]" value="red" <?php echo isset($this->view->requestData['triage_color']) && $this->view->requestData['triage_color'] == 'red' ? 'checked' : ''; ?>></div>
									</div>
								</div>
							</div>
							<div class="col-lg-6">

								<div class="row">
									<div class="col">
										<label class="label-main" for="request-bp-max"><?php echo _('B.P. Max'); ?></label>
										<input type="number" min="0" max="250" class="form-control text-center field-request_surname" value="<?php echo isset($this->view->requestData['max_arterial_pressure']) ? $this->view->requestData['max_arterial_pressure'] : ''; ?>" id="request-bp-max" name="data[request_bp_max][value]">

										<input type="hidden" name="data[request_bp_max][required]" value="1">
										<input type="hidden" name="data[request_bp_max][type]" value="text">
										<input type="hidden" name="data[request_bp_max][class]" value="field-request-bp-max">
										<input type="hidden" name="data[request_bp_max][label]" value="<?php echo _('B.P. Max'); ?>">
									</div>
									<div class="col">
										<label class="label-main" for="request-bp-min"><?php echo _('B.P. Min'); ?></label>
										<input type="number" min="0" max="250" class="form-control text-center field-request-bp-min" value="<?php echo isset($this->view->requestData['min_arterial_pressure']) ? $this->view->requestData['min_arterial_pressure'] : ''; ?>" id="request-bp-min" name="data[request_bp_min][value]">

										<input type="hidden" name="data[request_bp_min][required]" value="1">
										<input type="hidden" name="data[request_bp_min][type]" value="text">
										<input type="hidden" name="data[request_bp_min][class]" value="field-request-bp-min">
										<input type="hidden" name="data[request_bp_min][label]" value="<?php echo _('Blood Pressure Min'); ?>">
									</div>
									<div class="col">
										<label class="label-main" for="request_heart_rate"><?php echo _('H.R.'); ?></label>
										<input type="number" min="0" max="250" class="form-control text-center field-request_heart_rate" value="<?php echo isset($this->view->requestData['heart_rate']) ? $this->view->requestData['heart_rate'] : ''; ?>" id="request_heart_rate" name="data[request_heart_rate][value]">

										<input type="hidden" name="data[request_heart_rate][required]" value="1">
										<input type="hidden" name="data[request_heart_rate][type]" value="text">
										<input type="hidden" name="data[request_heart_rate][class]" value="field-request_heart_rate">
										<input type="hidden" name="data[request_heart_rate][label]" value="<?php echo _('Heart Rate'); ?>">
									</div>
									<div class="col">
										<label class="label-main" for="request_oxy_sat"><?php echo _('O.S.'); ?> %</label>
										<input type="number" min="0" max="100" class="form-control text-center field-request_oxy_sat" value="<?php echo isset($this->view->requestData['saturation']) ? $this->view->requestData['saturation'] : ''; ?>" id="request_oxy_sat" name="data[request_oxy_sat][value]">

										<input type="hidden" name="data[request_oxy_sat][required]" value="1">
										<input type="hidden" name="data[request_oxy_sat][type]" value="text">
										<input type="hidden" name="data[request_oxy_sat][class]" value="field-request_oxy_sat">
										<input type="hidden" name="data[request_oxy_sat][label]" value="<?php echo _('Oxygen Saturation'); ?> %">
									</div>
								</div>

							</div>
						</div>
					</div>

					<div class="form-group col-lg-12">
						<div class="row">
							<div class="col-lg-6">
								<div>
									<label class="label-main" for="request_medremarks"><?php echo _('Medical Remarks'); ?></label>
									<textarea class="form-control field-request_medremarks" name="data[request_medremarks][value]" rows="8" id="request_medremarks"><?php echo isset($this->view->requestData['clinical_remarks']) ? $this->helper->cleanText($this->view->requestData['clinical_remarks']) : ''; ?></textarea>

									<input type="hidden" name="data[request_medremarks][required]" value="1">
									<input type="hidden" name="data[request_medremarks][type]" value="text">
									<input type="hidden" name="data[request_medremarks][class]" value="field-request_medremarks">
									<input type="hidden" name="data[request_medremarks][label]" value="<?php echo _('Medical Remarks'); ?>">
								</div>

								<div class="margin-top-20">
									<label class="label-main" for="request_mainquestion"><?php echo _('Main Question'); ?></label>
									<textarea class="form-control field-request_mainquestion" name="data[request_mainquestion][value]" rows="4"><?php echo isset($this->view->requestData['request_question']) ? $this->helper->cleanText($this->view->requestData['request_question']) : ''; ?></textarea>

									<input type="hidden" name="data[request_mainquestion][required]" value="1">
									<input type="hidden" name="data[request_mainquestion][type]" value="text">
									<input type="hidden" name="data[request_mainquestion][class]" value="field-request_mainquestion">
									<input type="hidden" name="data[request_mainquestion][label]" value="<?php echo _('Main Question'); ?>">
								</div>

								<div class="margin-top-20">
									<label class="label-main" for="request_medicalhistory"><?php echo _('Medical History'); ?></label>
									<textarea class="form-control field-request_medicalhistory" name="data[request_medicalhistory][value]" rows="3" id="request_medicalhistory"><?php echo isset($this->view->requestData['medical_history']) ? $this->helper->cleanText($this->view->requestData['medical_history']) : ''; ?></textarea>

									<input type="hidden" name="data[request_medicalhistory][required]" value="0">
									<input type="hidden" name="data[request_medicalhistory][type]" value="text">
									<input type="hidden" name="data[request_medicalhistory][class]" value="field-request_medicalhistory">
									<input type="hidden" name="data[request_medicalhistory][label]" value="<?php echo _('Medical History'); ?>">
								</div>
							</div>
							<div class="col-lg-6">
								<div class="row">
									<div class="col-lg-12">
										<div>
											<label class="label-main" for="request_medremarks"><?php echo _('Attachments'); ?></label>
											<div class="text-right"><button type="button" class="btn btn-info btn-sm btn-show-tranfer"><?php echo _('Load files'); ?></button></div>

											<div class="margin-top-5">
												<?php echo $this->partial('Request/attach-edit-list', ['attachments'=>$this->view->attachments, 'requestUniqueCode'=>$this->view->requestUniqueCode]); ?>
											</div>
										</div>
									</div>
								</div>
								<hr>
								<div class="row">
									<div class="col-lg-6 margin-bottom-20">
										<div>
											<label class="label-main" for="request_medremarks"><?php echo _('ICD-10'); ?></label>
											<div id="icd10-list-content">
												<?php //WARNING: this HTML code also is in the Javascript function setDeseaseCheckboxesList() (app.js) ?>
												<?php if(is_array($this->view->icd10) && !empty($this->view->icd10)): ?>
													<?php foreach($this->view->icd10 as $icd10): ?>
														<div class="icd10-selected-desease" data-deseaseid="<?php echo $icd10['id']; ?>"><small><span class="icon-checkmark"></span> <?php echo $icd10['parent_label'] != '' ? $this->helper->cleanText($icd10['parent_label']).' / ' : ''; ?> <?php echo $this->helper->cleanText($icd10['label']); ?></small></div>
													<?php endforeach; ?>
													<hr>
												<?php endif; ?>
											</div>
											<div class="text-right"><button type="button" class="btn btn-secondary btn-sm btn-icd10-open"><?php echo _('Open'); ?></button></div>
										</div>
									</div>
									<div class="col-lg-6 margin-bottom-20">
										<div>
											<label class="label-main" for=""><?php echo _('Wizard Physical Examination'); ?></label>
											<div id="exam-wrapper-generic">
												<?php if(isset($this->view->wizards['generic']) && is_array($this->view->wizards['generic'])): ?>
													<?php foreach($this->view->wizards['generic'] as $item): ?>
														<div>
															<small><span class="icon-checkmark"></span> <?php echo $this->helper->cleanText($item['description']); ?></small>
														</div>
													<?php endforeach; ?>
													<hr>
												<?php endif; ?>
											</div>
											<div class="text-right"><button type="button" class="btn btn-secondary btn-sm btn-wiz-obj-open"><?php echo _('Open'); ?></button></div>
										</div>
									</div>
								</div>

								<div class="row">
									<div class="col-lg-6 margin-bottom-20">
										<div>
											<label class="label-main" for=""><?php echo _('Wizard Derma'); ?></label>
											<div id="position-wrapper-derma">
												<?php if(isset($this->view->dermaPositions) && is_array($this->view->dermaPositions)): ?>
													<?php foreach($this->view->dermaPositions as $item): ?>
														<div>
															<small><span class="icon-checkmark"></span> <?php echo _('Position'); ?>: <?php echo $this->helper->cleanText($this->view->dermaPositionLabels[$item['position_type']]); ?></small>
														</div>
													<?php endforeach; ?>
														<hr>
												<?php endif; ?>
											</div>
											<div id="exam-wrapper-derma">
												<?php if(isset($this->view->wizards['derma']) && is_array($this->view->wizards['derma'])): ?>
													<?php foreach($this->view->wizards['derma'] as $item): ?>
														<div>
															<small><span class="icon-checkmark"></span> <?php echo $this->helper->cleanText($item['description']); ?></small>
														</div>
													<?php endforeach; ?>
													<hr>
												<?php endif; ?>
											</div>
											<div class="text-right"><button type="button" class="btn btn-secondary btn-sm btn-sm btn-wiz-derma-open"><?php echo _('Open'); ?></button></div>
										</div>
									</div>
									<div class="col-lg-6 margin-bottom-20">
										<div>
											<label class="label-main" for=""><?php echo _('Wizard Cardio'); ?></label>
											<div id="exam-wrapper-cardio">
												<?php if(isset($this->view->wizards['cardio']) && is_array($this->view->wizards['cardio'])): ?>
													<?php foreach($this->view->wizards['cardio'] as $item): ?>
														<div>
															<small><span class="icon-checkmark"></span> <?php echo $this->helper->cleanText($item['description']); ?></small>
														</div>
													<?php endforeach; ?>
													<hr>
												<?php endif; ?>
											</div>
											<div class="text-right"><button type="button" class="btn btn-secondary btn-sm btn-wiz-cardio-open"><?php echo _('Open'); ?></button></div>
										</div>
									</div>
								</div>

								<div class="row">
									<div class="col-lg-6 margin-bottom-20">

										<div>
											<label class="label-main" for=""><?php echo _('Wizard Ear'); ?></label>
											<div id="images-wrapper-oto">
												<?php if(isset($this->view->otoImages) && is_array($this->view->otoImages)): ?>
													<?php foreach($this->view->otoImages as $item): ?>
														<div>
															<small><span class="icon-checkmark"></span> <?php echo $this->helper->cleanText($this->view->otoPositionLabels[$item['desease_type']]); ?></small>
														</div>
													<?php endforeach; ?>
														<hr>
												<?php endif; ?>
											</div>
											<div id="exam-wrapper-oto">
												<?php if(isset($this->view->wizards['oto']) && is_array($this->view->wizards['oto'])): ?>
													<?php foreach($this->view->wizards['oto'] as $item): ?>
														<div>
															<small><span class="icon-checkmark"></span> <?php echo $this->helper->cleanText($item['description']); ?></small>
														</div>
													<?php endforeach; ?>
													<hr>
												<?php endif; ?>
											</div>
											<div class="text-right"><button type="button" class="btn btn-secondary btn-sm btn-sm btn-wiz-oto-open"><?php echo _('Open'); ?></button></div>
										</div>

									</div>
								</div>

							</div>
						</div>
					</div>
					<div class="form-group col-lg-12">
						<hr>
						<h4 class="text-center"><?php echo _('Recipients'); ?></h4>
						<hr>
					</div>
					
					<div class="form-group col-lg-6">
						<label class="label-main" for="request-referral-ms"><?php echo _('Requested Medical Specialties'); ?></label>
						<input type="hidden" name="data[referral_ms][value]" value="">
						<select data-placeholder="<?php echo _('Select...'); ?>" class="form-control field-referral-ms chosen-select" multiple="multiple" id="request-referral-ms" name="data[referral_ms][value][]">
							<?php if(is_array($this->view->medicalSpecialties)): ?>
								<?php foreach($this->view->medicalSpecialties as $medSpec): ?>
									<?php $selected = (isset($medSpec['selected']) && (bool)$medSpec['selected']) ? 'selected' : ''; ?>
									<option value="<?php echo $medSpec['id']; ?>" <?php $selected; ?>><?php echo $medSpec['description']; ?></option>
								<?php endforeach; ?>
							<?php endif; ?>
						</select>

						<input type="hidden" name="data[referral_ms][required]" value="1">
						<input type="hidden" name="data[referral_ms][type]" value="text">
						<input type="hidden" name="data[referral_ms][class]" value="field-referral-ms">
						<input type="hidden" name="data[referral_ms][label]" value="<?php echo _('Requested Medical Specialties'); ?>">
					</div>

					<div class="form-group col-lg-6">
						<label class="label-main" for="request-referral-langs"><?php echo _('Default Languages for this request'); ?></label>
						<input type="hidden" name="data[referral_langs][value]" value="">
						<select data-placeholder="<?php echo _('Select...'); ?>" class="form-control field-referral-langs chosen-select" multiple="multiple" id="request-referral-langs" name="data[referral_langs][value][]">
							<?php if(is_array($this->view->languages)): ?>
								<?php foreach($this->view->languages as $languages): ?>
									<?php $selected = isset($languages['selected']) && $languages['selected'] ? 'selected' : ''; ?>
									<option value="<?php echo $languages['lang_code']; ?>" <?php echo $selected; ?>><?php echo $languages['name_string']; ?></option>
								<?php endforeach; ?>
							<?php endif; ?>
						</select>

						<input type="hidden" name="data[referral_langs][required]" value="1">
						<input type="hidden" name="data[referral_langs][type]" value="text">
						<input type="hidden" name="data[referral_langs][class]" value="field-referral-langs">
						<input type="hidden" name="data[referral_langs][label]" value="<?php echo _('Referral Default Languages'); ?>">
					</div>

					<div class="form-group col-lg-12 <?php echo !$this->view->advancedFields ? 'hide-request-field' : ''; ?>">
						<label class="label-main" for="request-referral-cc"><?php echo _('Clinical Centers for this request'); ?></label>
						<input type="hidden" name="data[referral_cc][value]" value="">
						<select data-placeholder="<?php echo _('Select...'); ?>" class="form-control field-referral-cc chosen-select" multiple="multiple" id="request-referral-cc" name="data[referral_cc][value][]">
							<?php if(is_array($this->view->ccReferral)): ?>
								<?php foreach($this->view->ccReferral as $ccReferral): ?>
									<?php $selected = isset($ccReferral['selected']) && $ccReferral['selected'] ? 'selected' : ''; ?>
									<option value="<?php echo $ccReferral['id']; ?>" <?php echo $selected; ?>><?php echo $ccReferral['description']; ?></option>
								<?php endforeach; ?>
							<?php endif; ?>
						</select>

						<input type="hidden" name="data[referral_cc][required]" value="1">
						<input type="hidden" name="data[referral_cc][type]" value="text">
						<input type="hidden" name="data[referral_cc][class]" value="field-referral-cc">
						<input type="hidden" name="data[referral_cc][label]" value="<?php echo _('Clinical Centers for this request'); ?>">
					</div>

					<div class="form-group col-lg-12 text-muted <?php echo !$this->view->advancedFields ? 'hide-request-field' : ''; ?>">
						<div class="strike-center"><span><?php echo _('OR'); ?></span></div>
					</div>

					<div class="form-group col-lg-12 <?php echo !$this->view->advancedFields ? 'hide-request-field' : ''; ?>">
						<label class="label-main" for="request-referral-list"><?php echo _('Specific Responders'); ?></label>
						<input type="hidden" name="data[request_referral_list][value]" value="">
						<select data-placeholder="<?php echo _('Select...'); ?>" class="form-control field-request-referral-list chosen-select" multiple="multiple" id="request-referral-list" name="data[request_referral_list][value][]">
							<?php if(is_array($this->view->referralList)): ?>
								<?php foreach($this->view->referralList as $referralList): ?>
									<?php $selected = isset($referralList['selected']) && $referralList['selected'] ? 'selected' : ''; ?>
									<option value="<?php echo $referralList['user_id']; ?>" <?php echo $selected; ?>><?php echo ucwords($referralList['user_surname']), ' ', ucwords($referralList['user_name']), ' ('.$this->helper->truncate($referralList['medspec_list'], 50).')'; ?></option>
								<?php endforeach; ?>
							<?php endif; ?>
						</select>

						<input type="hidden" name="data[request_referral_list][required]" value="1">
						<input type="hidden" name="data[request_referral_list][type]" value="text">
						<input type="hidden" name="data[request_referral_list][class]" value="field-request-referral-list">
						<input type="hidden" name="data[request_referral_list][label]" value="<?php echo _('Specific Responders'); ?>">
					</div>

					<div class="form-group col-lg-12 <?php echo !$this->view->advancedFields ? 'hide-request-field' : ''; ?>">
						<label class="label-main" for="request-referral-visibility"><?php echo _('Visibility'); ?></label>
						<div class="form-check">
							<input type="hidden" name="data[referral_visibility][value]" value="0">
							<input class="form-check-input field-request-visibility-0" type="checkbox" name="data[referral_visibility][value]" value="1" id="request-referral-visibility-0" <?php echo !isset($this->view->requestData['request_visibility']) || $this->view->requestData['request_visibility'] == 'all' ? 'checked' : ''; ?>>
							<label class="form-check-label" for="request-referral-visibility-0">
								<?php echo _('All my clinical centers'); ?>
							</label>
						</div>

						<input type="hidden" name="data[referral_visibility][required]" value="1">
						<input type="hidden" name="data[referral_visibility][type]" value="text">
						<input type="hidden" name="data[referral_visibility][class]" value="field-request-visibility-0">
						<input type="hidden" name="data[referral_visibility][label]" value="<?php echo _('Visibility'); ?>">
					</div>

					<div class="form-group col-lg-12">
						<div class="card bg-light">
							<div class="card-header"><?php echo _('Privacy Policy'); ?></div>
							<div class="card-body">
								<div class="form-check">
									<input type="hidden" name="data[privacy][value]" value="0">
									<input class="form-check-input field-privacy-0" type="checkbox" name="data[privacy][value]" value="1" id="request-privacy-0" <?php echo isset($this->view->requestData['patient_privacy']) && $this->view->requestData['patient_privacy'] == 1 ? 'checked' : ''; ?>>
									<label class="form-check-label" for="request-privacy-0">
										<?php echo _('The Patient has expressed consent to allow the processing of Sensitive and Personal Information.'); ?>
									</label>
								</div>

								<input type="hidden" name="data[privacy][required]" value="1">
								<input type="hidden" name="data[privacy][type]" value="text">
								<input type="hidden" name="data[privacy][class]" value="field-privacy-0">
								<input type="hidden" name="data[privacy][label]" value="<?php echo _('Privacy Policy'); ?>">
							</div>
						</div>
					</div>
					
					<div class="form-group col-lg-12">
						<button type="button" class="btn btn-secondary handle-more-details" href="#" role="button">
							<?php echo _('More details'); ?>
						</button>
					</div>
					
									
					<div class="form-group col-lg-3 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgnamesurname"><?php echo _('Name'); ?></label>
						<input type="text" class="form-control field-request_cgnamesurname" value="<?php echo isset($this->view->requestData['cgnamesurname']) ? $this->view->requestData['cgnamesurname'] : ''; ?>" id="request_cgnamesurname" name="data[cgnamesurname][value]">

					</div>
					
					<div class="form-group col-lg-3 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgrole"><?php echo _('Role'); ?></label>
						<select class="form-control field-request_cgrole" id="request_cgrole" name="data[cgrole][value]">
							<option value=""></option>
							<option <?php echo isset($this->view->requestData['cgrole']) && $this->view->requestData['cgrole'] == 'Son' ? 'selected' : ''; ?> value="<?php echo 'Son'; ?>"><?php echo _('Son'); ?></option>
							<option <?php echo isset($this->view->requestData['cgrole']) && $this->view->requestData['cgrole'] == 'Spouse' ? 'selected' : ''; ?> value="<?php echo 'Spouse'; ?>"><?php echo _('Spouse'); ?></option>
							<option <?php echo isset($this->view->requestData['cgrole']) && $this->view->requestData['cgrole'] == 'Relative' ? 'selected' : ''; ?> value="<?php echo 'Relative'; ?>"><?php echo _('Relative'); ?></option>
							<option <?php echo isset($this->view->requestData['cgrole']) && $this->view->requestData['cgrole'] == 'Caregiver' ? 'selected' : ''; ?> value="<?php echo 'Caregiver'; ?>"><?php echo _('Caregiver'); ?></option>
							<option <?php echo isset($this->view->requestData['cgrole']) && $this->view->requestData['cgrole'] == 'Other' ? 'selected' : ''; ?> value="<?php echo 'Other'; ?>"><?php echo _('Other'); ?></option>
						</select>

					</div>
					
					<div class="form-group col-lg-3 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgphone"><?php echo _('Phone'); ?></label>
						<input type="text" class="form-control field-request_cgphone" value="<?php echo isset($this->view->requestData['cgphone']) ? $this->view->requestData['cgphone'] : ''; ?>" id="request_cgphone" name="data[cgphone][value]">

					</div>
					
					<div class="form-group col-lg-3 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgemail"><?php echo _('E-mail'); ?></label>
						<input type="text" class="form-control field-request_cgemail" value="<?php echo isset($this->view->requestData['cgemail']) ? $this->view->requestData['cgemail'] : ''; ?>" id="request_cgemail" name="data[cgemail][value]">

					</div>
					
					<!-- $this->view->requestData['cgprovince'] -->
					<div class="form-group col-lg-6 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgprovince"><?php echo _('Province'); ?></label>
						<select class="form-control field-request_cgprovince" id="request_cgprovince" name="data[cgprovince][value]">
							<option value="0">...</option>
							<?php foreach($this->view->provinceList as $id => $name): ?>
								<?php $selected = isset($this->view->requestData['cgprovince']) && $id == $this->view->requestData['cgprovince'] ? 'selected' : ''; ?>
								<option value="<?php echo $id; ?>" <?php echo $selected; ?>><?php echo $name; ?></option>
							<?php endforeach; ?>
						</select>

					</div>
					
					<!-- $this->view->requestData['cgcity'] -->
					<div class="form-group col-lg-6 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgcity"><?php echo _('City'); ?></label>
						<input type="hidden" id="request_cgcity_selected" value="<?php echo isset($this->view->requestData['cgcity']) ? $this->view->requestData['cgcity'] : 0; ?>">
						<select disabled class="form-control field-request_cgcity" id="request_cgcity" name="data[cgcity][value]"><!-- AJAX: .on('click', '.request-province-list') in app.js --></select>

					</div>
					
					<div class="form-group col-lg-4 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgmmgnamesurname"><?php echo _('MMG (name and surname)'); ?></label>
						<input type="text" class="form-control field-request_cgmmgnamesurname" value="<?php echo isset($this->view->requestData['cgmmgnamesurname']) ? $this->view->requestData['cgmmgnamesurname'] : ''; ?>" id="request_cgmmgnamesurname" name="data[cgmmgnamesurname][value]">

					</div>
					
					<div class="form-group col-lg-4 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgmmgphone"><?php echo _('MMG (phone)'); ?></label>
						<input type="text" class="form-control field-request_cgmmgphone" value="<?php echo isset($this->view->requestData['cgmmgphone']) ? $this->view->requestData['cgmmgphone'] : ''; ?>" id="request_cgmmgphone" name="data[cgmmgphone][value]">

					</div>
					
					<div class="form-group col-lg-4 field-moredetails hide-moredtails">
						<label class="label-main" for="request_cgmmgemail"><?php echo _('MMG (e-mail)'); ?></label>
						<input type="text" class="form-control field-request_cgmmgemail" value="<?php echo isset($this->view->requestData['cgmmgemail']) ? $this->view->requestData['cgmmgemail'] : ''; ?>" id="request_cgmmgemail" name="data[cgmmgemail][value]">

					</div>
					
					<div class="form-group col-lg-12 field-moredetails hide-moredtails">
						<ul class="list-group" id="request_cg_file_list"></ul>
					</div>
						
					<div id="request_cg_input_list" style="display: none;"></div>	
					
					<div class="form-group col-lg-12">
						<hr>

						<div class="cleaerfix">
							<div class="float-left">
								<a  class="btn btn-warning" href="<?php echo $this->helper->setHash('requests/'.time().'/my/created_at/desc/1'); ?>"><?php echo _('Exit without saving'); ?></a>
							</div>
							<div class="float-right">
								<button type="button" class="btn btn-secondary btn-request-save" data-operation="draft"><?php echo _('Save as draft'); ?></button>
								<button type="button" class="btn btn-primary btn-request-save" data-operation="save"><?php echo _('Send Request'); ?></button>
								<?php if($this->view->advancedFields): ?>
									<button type="button" class="btn btn-warning btn-request-sending-preview"><?php echo _('Sending Preview'); ?></button>
								<?php endif; ?>
							</div>
						</div>
					</div>
				</div>

				<?php //debug($this->view->dreamData); ?>

				<?php //Dialogs ?>
				<?php echo $this->partial('Request/sending-preview'); ?>
				<?php echo $this->partial('Request/icd10-dialog'); ?>
				<?php echo $this->partial('Request/wizard-objective'); ?>
				<?php echo $this->partial('Request/wizard-derma'); ?>
				<?php echo $this->partial('Request/wizard-oto'); ?>
				<?php echo $this->partial('Request/wizard-cardio'); ?>
				<?php echo $this->partial('Request/attach-preview'); ?>

			</form>
	</div>
</div>
