{% extends 'base.html.twig' %}
{% block title %}Add Test Sample{% endblock %}
{% block content %}
<div class="kt-subheader kt-grid__item"></div>
<div class="kt-container kt-grid__item kt-grid__item--fluid">
<div class="kt-portlet kt-portlet--mobile">
<div class="kt-portlet__head kt-portlet__head--lg">
<div class="kt-portlet__head-label">
<h3 class="kt-portlet__head-title">Add Test Sample</h3>
</div>
<div class="kt-portlet__head-toolbar">
<div class="kt-portlet__head-wrapper">
<a href="{{ path('case_lab_test') }}" class="btn btn-clean btn-icon-sm"><i
class="la la-long-arrow-left"></i>Back</a>
</div>
</div>
</div>
<div class="kt-portlet__body">
{% include 'parts/flash.html.twig' %}
<div class="accordion accordion-toggle-arrow" id="case-details">
<div class="card">
<div class="card-header" id="patient-info-heading">
<div class="card-title" data-toggle="collapse" data-target="#patient-info" aria-expanded="true"
aria-controls="patient-info">
Patient Information
</div>
</div>
<div id="patient-info" class="show" aria-labelledby="patient-info-label"
data-parent="#case-details">
<div class="card-body">
{{ render(controller('App\\Controller\\PatientController::personalInfo', {'id':
patient_id})) }}
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="sample-heading">
<div class="card-title" data-toggle="collapse" data-target="#case-samples" aria-expanded="true"
aria-controls="case-samples">
Collect Samples
</div>
</div>
<div id="case-samples" class="show" aria-labelledby="sample-label" data-parent="#case-details">
<div class="card-body">
<div class="row">
<div class="col col-lg-6">
{{ form_start(form, {'attr': {'class': 'kt-form' } }) }}
<div class="kt-portlet__body">
<div class="form-group row">
{{ form_label(form.type, '', {'label_attr': { 'class': 'col-form-label
col-lg-3 col-sm-12 font-weight-bold' }}) }}
<div class="col-lg-4 col-md-9 col-sm-12">
{{ form_widget(form.type, {'attr': { 'class': 'form-control
select-picker' }}) }}
{{ form_errors(form.type) }}
</div>
<button type="submit" class="btn btn-brand">Add Sample</button>
</div>
</div>
{{ form_end(form) }}
</div>
<div class="col col-lg-6">
<div class="kt-portlet__body">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Type</th>
<th>Sample No.</th>
<th width="5%">Action</th>
</tr>
</thead>
<tbody>
{% for sample in samples %}
<tr>
<td>{{ sample.type }}</td>
<td>{{ sample.number }}</td>
<td class="text-center">
<a href="{{ path('case_lab_sample_delete', {'id': sample.id | nzo_encrypt}) }}"
onclick="return confirm('Are you sure?');"
data-toggle="kt-tooltip" title="Delete Sample">
<i class="fa far fa-trash fa-2x kt-font-danger"></i>
</a>
</td>
</tr>
{% else %}
<td colspan="3" class="text-center">No records found</td>
{% endfor %}
</tbody>
</table>
</div>
<div class="kt-portlet__foot">
<div class="kt-form__actions text-right">
<button type="button" class="btn btn-brand">Print Labels</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="tests-info-heading">
<div class="card-title" data-toggle="collapse" data-target="#tests-info" aria-expanded="true"
aria-controls="tests-info">
Tests to be done
</div>
</div>
<div id="tests-info" class="show" aria-labelledby="tests-info-label" data-parent="#case-details">
<div class="card-body">
<form id="case_lab_test_form" class="kt-form" method="post"
action="{{ path('case_lab_add_test_sample', {'case_id': case_id}) }}">
<div class="kt-portlet__body">
<table class="table table-striped table-bordered table-hover table-checkable"
id="kt_table_2">
<thead>
<tr>
<th width="50">
<label
class="kt-checkbox kt-checkbox--single kt-checkbox--bold kt-checkbox--brand">
<input id="header_checkbox" type="checkbox"
class="kt-group-checkable">
<span></span>
</label>
</th>
<th>Test Name</th>
<th>Method</th>
<th>Normal Range</th>
<th width="300">Sample No.</th>
<th>Send To</th>
</tr>
</thead>
<tbody>
{% for test in tests %}
<tr>
<td>
<label
class="kt-checkbox kt-checkbox--single kt-checkbox--bold kt-checkbox--brand">
<input data-chkReport="chkReport{{ loop.index }}"
type="checkbox" name="confirm_samples[]"
value="{{ loop.index }}" {% if test.sample_id %} checked{%
endif %} class="kt-group-checkable" {% if test.result %}
disabled{% endif %}>
<span></span>
</label>
{% if not test.result %}
<input type="hidden" name="tests[{{ loop.index }}]"
value="{{ test.id }}">
{% endif %}
</td>
<td>{{ test.test_name }}</td>
<td>
{% if test.method_names %}
{% set methods = test.method_names|split(',') %}
<ul>
{% for method in methods %}
<li>{{ method }}</li>
{% endfor %}
</ul>
{% else %}
—
{% endif %}
</td>
<td>
{% if test.normal_range %}
{% set ranges = test.normal_range|split(',') %}
<ul>
{% for range in ranges %}
<li>{{ range }}</li>
{% endfor %}
</ul>
{% else %}
—
{% endif %}
</td>
<td>
<div class="form-group">
<select name="samples[{{ loop.index }}]"
data-dd-report="{{ loop.index }}"
class="select-picker form-control" {% if test.result %}
disabled{% endif %}>
<option value="">Select Sample</option>
{% if samples %}
{% for sample in samples %}
<option value="{{ sample.id }}" {% if
(sample.id==test.sample_id) %} selected {% endif %}>{{
sample.number }}</option>
{% endfor %}
{% endif %}
</select>
</div>
</td>
<td>
<div class="form-group">
<select name="hospitals[{{ loop.index }}]"
data-dd-report="{{ loop.index }}"
class="select-picker form-control" {% if test.result %}
disabled{% endif %}>
<option value="">Select Hospital</option>
{% if hospitals %}
{% for hospital in hospitals %}
<option value="{{ hospital.id }}" {% if
(hospital.id==test.hospital_id) %} selected {% endif %}>
{{ hospital.name }}</option>
{% endfor %}
{% endif %}
</select>
</div>
</td>
</tr>
{% else %}
<td colspan="6" class="text-center">No records found</td>
{% endfor %}
</tbody>
</table>
</div>
<div class="kt-portlet__foot">
<div class="kt-form__actions text-right">
{% if tests %}
<input type="submit" id="assign_sample" class="btn btn-brand">
{% endif %}
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
{{ parent() }}
<script>
$('.select-picker').selectpicker();
$('#header_checkbox').on('click', function () {
$("input[name='confirm_samples[]']:not(:disabled)").prop('checked', $(this).prop('checked'));
});
$('#case_lab_test_form').on('submit', function (e) {
e.preventDefault();
var isBlank = true, isValid = true;
$("input[name='confirm_samples[]']:checked").each(function () {
if (this.value) {
isBlank = false;
if (!$('select[name="samples[' + this.value + ']"]').val()) {
isValid = false;
swal.fire({
text: "Please select sample of selected tests.",
type: 'error',
showCancelButton: true,
showConfirmButton: false,
animation: false,
cancelButtonText: "Cancel",
cancelButtonClass: "btn btn-default"
});
return false;
}
}
});
if (isBlank) {
swal.fire({
text: "Please select at least one sample!",
type: 'info',
animation: false,
showCancelButton: true,
showConfirmButton: false,
cancelButtonText: "Cancel",
cancelButtonClass: "btn btn-default"
});
return false;
} else {
if (isValid) {
this.submit();
}
}
});
$('td select').on('change', function () {
if (this.value) {
if (!$('input[data-chkReport="chkReport' + $(this).data('dd-report') + '"]').is(':checked')) {
swal.fire({
text: "Please select the report to save report data.",
type: 'info',
animation: false,
showCancelButton: true,
showConfirmButton: false,
cancelButtonText: "Cancel",
cancelButtonClass: "btn btn-default"
});
}
}
});
</script>
{% endblock %}