<?php //debug($deseases); ?>

<?php if(is_array($deseases) && !empty($deseases)): ?>

	<?php 
		$checkedAttr = isset($checked) && $checked ? 'checked' : '';
		$checkbox = '<input type="checkbox" name="data[icd10_desease][value][]" class="desease-id-checkbox" id="desease-id-checkbox-%s" value="%s" data-label="%s" '.$checkedAttr.' %s> '; 
		$parentLabel = '';
		$subDeseaseLabel = '';
	?>
	
	<ul>
		<?php foreach($deseases as $index => $desease): ?>
			<li class="list-no-type margin-bottom-10">
				
				<?php if($desease['parent_label'] != ''): ?>
					<?php $parentLabel = $this->helper->cleanText($desease['parent_label']); ?>
					<div class="text-muted"><small><?php echo $parentLabel; ?></small></div>
				<?php endif; ?>
				
				
				<?php //if($desease['label'] != ''): ?>
					<label class="label-main <?php echo isset($desease['disabled']) && $desease['disabled'] != '' ? 'text-muted' : ''; ?>" for="">
						<?php echo !isset($desease['subdeseases']) || empty($desease['subdeseases']) ? vsprintf($checkbox, [$desease['id'], $desease['id'], $parentLabel.' / '.$this->helper->cleanText($desease['label']), isset($desease['disabled']) ? $desease['disabled'] : '']) : ''; ?>
						<?php 
							$subDeseaseLabel = $this->helper->cleanText($desease['label']);
							echo $subDeseaseLabel; 
						?>
					</label>
				<?php //endif; ?>
				
				<?php if(isset($desease['subdeseases']) && is_array($desease['subdeseases']) && !empty($desease['subdeseases'])): ?>
					<ul>
						<?php foreach($desease['subdeseases'] as $deseaseId => $deseaseInfo): ?>
							<li class="list-no-type">
								<label for="" class="<?php echo $deseaseInfo['disabled'] != '' ? 'text-muted' : ''; ?>">
									<?php echo vsprintf($checkbox, [$deseaseId, $deseaseId, $subDeseaseLabel.' / '.$deseaseInfo['label'], $deseaseInfo['disabled']]); ?>
									<?php echo $deseaseInfo['label']; ?>
								</label>
							</li>
						<?php endforeach; ?>
					</ul>
				<?php endif; ?>
			</li>
		<?php endforeach; ?>
	</ul>
<?php endif; ?>