<commit_before><?php
/**
 * OpenEyes
 *
 * (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011
 * (C) OpenEyes Foundation, 2011-2013
 * This file is part of OpenEyes.
 * OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
 *
 * @package OpenEyes
 * @link http://www.openeyes.org.uk
 * @author OpenEyes <<EMAIL>>
 * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust
 * @copyright Copyright (c) 2011-2013, OpenEyes Foundation
 * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0
 */
?>

<section class="box patient-info associated-data js-toggle-container">

	<header class="box-header">
		<h3 class="box-title">
			<span class="icon-patient-clinician-hd_flag"></span>
			Medication
		</h3>
		<a href="#" class="toggle-trigger toggle-hide js-toggle">
			<span class="icon-showhide">
				Show/hide this section
			</span>
		</a>
	</header>

	<div class="js-toggle-body">
		<table class="plain patient-data">
			<thead>
			<tr>
				<th>Medication</th>
				<th>Route</th>
				<th>Option</th>
				<th>Frequency</th>
				<th>Start date</th>
				<?php if ($this->checkAccess('OprnEditMedication')) { ?><th>Actions</th><?php } ?>
			</tr>
			</thead>
			<tbody>
			<?php foreach ($this->patient->medications as $medication) {?>
				<tr>
					<td><?php echo $medication->drug->name?></td>
					<td><?php echo $medication->route->name?></td>
					<td><?php echo $medication->option ? $medication->option->name : '-'?></td>
					<td><?php echo $medication->frequency->name?></td>
					<td><?php echo $medication->NHSDate('start_date')?></td>
					<?php if ($this->checkAccess('OprnEditMedication')): ?>
						<td>
							<a href="#" class="editMedication" rel="<?php echo $medication->id?>">Edit</a>&nbsp;&nbsp;
							<a href="#" class="removeMedication" rel="<?php echo $medication->id?>">Remove</a>
						</td>
					<?php endif ?>
				</tr>
			<?php }?>
			</tbody>
		</table>

		<?php if ($this->checkAccess('OprnEditMedication')): ?>
			<div class="box-actions">
				<button  id="btn-add_medication" class="secondary small">
					Add Medication
				</button>
			</div>

			<div id="add_medication" style="display: none;">
				<?php
				$form = $this->beginWidget('FormLayout', array(
					'id'=>'add-medication',
					'enableAjaxValidation'=>false,
					'htmlOptions' => array('class'=>'sliding form add-data'),
					'action'=>array('patient/addMedication'),
					'layoutColumns'=>array(
						'label' => 3,
						'field' => 9
					),
				))?>
				<fieldset class="field-row">

					<legend><strong>Add medication</strong></legend>

					<input type="hidden" name="edit_medication_id" id="edit_medication_id" value="" />
					<input type="hidden" name="patient_id" value="<?php echo $this->patient->id?>" />

					<div class="patientMedication field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="drug_id">Medication:</label>
						</div>
						<div class="<?php echo $form->columns('field');?>">

							<div class="field-row hide" id="selectedMedicationName" style="font-weight: bold;">
							</div>

							<div class="field-row">
								<?php echo CHtml::dropDownList('drug_id','',Drug::model()->listBySubspecialty($firm->getSubspecialtyID()),array('empty'=>'- Select -'))?>
							</div>

							<div class="patientMedication field-row">
								<div class="label"></div>
								<?php
								$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
										'name' => 'drug_id',
										'id' => 'autocomplete_drug_id',
										'source' => "js:function(request, response) {
											$.getJSON('".$this->createUrl('DrugList')."', {
												term : request.term,
											}, response);
										}",
										'options' => array(
										'select' => "js:function(event, ui) {
												$('#selectedMedicationName').text(ui.item.value).show();
												$('#selectedMedicationID').val(ui.item.id);
												$(this).val('');
												return false;
											}",
										),
										'htmlOptions' => array(
											'placeholder' => 'or search formulary',
										),
									))?>
							</div>
						</div>
					</div>

					<input type="hidden" name="selectedMedicationID" id="selectedMedicationID" value="" />

					<div class="field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="route_id">Option:</label>
						</div>
						<div class="<?php echo $form->columns('field');?>">
							<?php echo CHtml::dropDownList('route_id','',CHtml::listData(DrugRoute::model()->findAll(),'id','name'),array('empty'=>'- Select -'))?>
						</div>
					</div>

					<div class="patientMedication routeOption row field-row" style="display: none;">
						<div class="<?php echo $form->columns('label');?>">
							<label for="option_id">Option:</label>
						</div>
						<div class="data <?php echo $form->columns('field');?>">
						</div>
					</div>

					<div class="field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="frequency_id">Frequency:</label>
						</div>
						<div class="<?php echo $form->columns('field');?>">
							<?php echo CHtml::dropDownList('frequency_id','',CHtml::listData(DrugFrequency::model()->findAll(array('order'=>'display_order')),'id','name'),array('empty'=>'- Select -'))?>
						</div>
					</div>

					<div class="field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="start_date">Date from:</label>
						</div>
						<div class="<?php echo $form->columns(3, true);?>">
							<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
								'name'=>'start_date',
								'id'=>'start_date',
								'options'=>array(
									'showAnim'=>'fold',
									'dateFormat'=>Helper::NHS_DATE_FORMAT_JS
								),
							))?>
						</div>
					</div>

					<div class="medication_form_errors alert-box alert hide"></div>
<commit_msg>[OE-3987] hide deleted items<commit_after><?php
/**
 * OpenEyes
 *
 * (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011
 * (C) OpenEyes Foundation, 2011-2013
 * This file is part of OpenEyes.
 * OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
 *
 * @package OpenEyes
 * @link http://www.openeyes.org.uk
 * @author OpenEyes <<EMAIL>>
 * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust
 * @copyright Copyright (c) 2011-2013, OpenEyes Foundation
 * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0
 */
?>

<section class="box patient-info associated-data js-toggle-container">

	<header class="box-header">
		<h3 class="box-title">
			<span class="icon-patient-clinician-hd_flag"></span>
			Medication
		</h3>
		<a href="#" class="toggle-trigger toggle-hide js-toggle">
			<span class="icon-showhide">
				Show/hide this section
			</span>
		</a>
	</header>

	<div class="js-toggle-body">
		<table class="plain patient-data">
			<thead>
			<tr>
				<th>Medication</th>
				<th>Route</th>
				<th>Option</th>
				<th>Frequency</th>
				<th>Start date</th>
				<?php if ($this->checkAccess('OprnEditMedication')) { ?><th>Actions</th><?php } ?>
			</tr>
			</thead>
			<tbody>
			<?php foreach ($this->patient->medications as $medication) {?>
				<tr>
					<td><?php echo $medication->drug->name?></td>
					<td><?php echo $medication->route->name?></td>
					<td><?php echo $medication->option ? $medication->option->name : '-'?></td>
					<td><?php echo $medication->frequency->name?></td>
					<td><?php echo $medication->NHSDate('start_date')?></td>
					<?php if ($this->checkAccess('OprnEditMedication')): ?>
						<td>
							<a href="#" class="editMedication" rel="<?php echo $medication->id?>">Edit</a>&nbsp;&nbsp;
							<a href="#" class="removeMedication" rel="<?php echo $medication->id?>">Remove</a>
						</td>
					<?php endif ?>
				</tr>
			<?php }?>
			</tbody>
		</table>

		<?php if ($this->checkAccess('OprnEditMedication')): ?>
			<div class="box-actions">
				<button  id="btn-add_medication" class="secondary small">
					Add Medication
				</button>
			</div>

			<div id="add_medication" style="display: none;">
				<?php
				$form = $this->beginWidget('FormLayout', array(
					'id'=>'add-medication',
					'enableAjaxValidation'=>false,
					'htmlOptions' => array('class'=>'sliding form add-data'),
					'action'=>array('patient/addMedication'),
					'layoutColumns'=>array(
						'label' => 3,
						'field' => 9
					),
				))?>
				<fieldset class="field-row">

					<legend><strong>Add medication</strong></legend>

					<input type="hidden" name="edit_medication_id" id="edit_medication_id" value="" />
					<input type="hidden" name="patient_id" value="<?php echo $this->patient->id?>" />

					<div class="patientMedication field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="drug_id">Medication:</label>
						</div>
						<div class="<?php echo $form->columns('field');?>">

							<div class="field-row hide" id="selectedMedicationName" style="font-weight: bold;">
							</div>

							<div class="field-row">
								<?php echo CHtml::dropDownList('drug_id','',Drug::model()->listBySubspecialty($firm->getSubspecialtyID()),array('empty'=>'- Select -'))?>
							</div>

							<div class="patientMedication field-row">
								<div class="label"></div>
								<?php
								$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
										'name' => 'drug_id',
										'id' => 'autocomplete_drug_id',
										'source' => "js:function(request, response) {
											$.getJSON('".$this->createUrl('DrugList')."', {
												term : request.term,
											}, response);
										}",
										'options' => array(
										'select' => "js:function(event, ui) {
												$('#selectedMedicationName').text(ui.item.value).show();
												$('#selectedMedicationID').val(ui.item.id);
												$(this).val('');
												return false;
											}",
										),
										'htmlOptions' => array(
											'placeholder' => 'or search formulary',
										),
									))?>
							</div>
						</div>
					</div>

					<input type="hidden" name="selectedMedicationID" id="selectedMedicationID" value="" />

					<div class="field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="route_id">Option:</label>
						</div>
						<div class="<?php echo $form->columns('field');?>">
							<?php echo CHtml::dropDownList('route_id','',CHtml::listData(DrugRoute::model()->active()->findAll(),'id','name'),array('empty'=>'- Select -'))?>
						</div>
					</div>

					<div class="patientMedication routeOption row field-row" style="display: none;">
						<div class="<?php echo $form->columns('label');?>">
							<label for="option_id">Option:</label>
						</div>
						<div class="data <?php echo $form->columns('field');?>">
						</div>
					</div>

					<div class="field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="frequency_id">Frequency:</label>
						</div>
						<div class="<?php echo $form->columns('field');?>">
							<?php echo CHtml::dropDownList('frequency_id','',CHtml::listData(DrugFrequency::model()->active()->findAll(array('order'=>'display_order')),'id','name'),array('empty'=>'- Select -'))?>
						</div>
					</div>

					<div class="field-row row">
						<div class="<?php echo $form->columns('label');?>">
							<label for="start_date">Date from:</label>
						</div>
						<div class="<?php echo $form->columns(3, true);?>">
							<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
								'name'=>'start_date',
								'id'=>'start_date',
								'options'=>array(
									'showAnim'=>'fold',
									'dateFormat'=>Helper::NHS_DATE_FORMAT_JS
								),
							))?>
						</div>
					</div>

					<div class="medication_form_errors alert-box alert hide"></div>

{'fraction_non_alphanumeric': 0.19462571976967372, 'fraction_numerical': 0.006756238003838772, 'mean_word_length': 3.195169082125604, 'pattern_counts': {'":': 0, '<': 299, '<?xml version=': 0, '>': 423, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2126201', 'n_tokens_mistral': 5518, 'n_tokens_neox': 4095, 'n_words': 915}