Files

413 lines
25 KiB
PHP
Executable File

@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css"/>
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet"/>
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-4 col-md-5 col-sm-5 col-xs-12">
<h4 class="page-title">{{ __('investigations.authenticate_lab_investigations') }}</h4>
</div>
<div class="col-lg-8 col-sm-7 col-md-7 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('investigations.dashboard') }}</a></li>
<li><a href="/investigations/index">{{ __('investigations.investigations') }}</a></li>
<li class="active">{{ __('investigations.authenticate') }}</li>
</ol>
</div>
</div>
<div class="white-box">
{{ Form::open(['method'=>'post','route' => 'investigations.authenticate_labs']) }}
{{ Form::hidden('patient_id', 0, ['id' => 'patient_id']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>{{ __('pharmacy.select_date') }}:</label>
<select class="form-control compulsory required" name="search_date_by" id="search_date_by" required>
<option value="today">{{ __('pharmacy.today') }}</option>
<option value="yesterday">{{ __('pharmacy.yesterday') }}</option>
<option value="custom_date">{{ __('pharmacy.custom_date') }}</option>
<option value="custom_date_range">{{ __('pharmacy.date_range') }}</option>
</select>
</div>
</div>
<div class="col-md-2" id="start_date_div" style="display: none;">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.date_on')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-2" id="end_date_div" style="display: none;">
<div class="form-group">
{{ Form::label('end_date', __('pharmacy.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3">
{{ Form::label('search_patient', __('investigations.search_by_patient')) }}
<div class="input-group">
<select class="form-control" name="patient_number" id="patient_number"></select>
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-top: 25px;">
{{ Form::submit(__('investigations.search'), ['class'=>'btn btn-success pull-right']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
{{ Form::open(['route' => 'investigations.authenticate_investigations']) }}
<div class="white-box">
@include('flash::message')
@php
$indicator = '';
$normal_orders =array_filter($orders, function ($item) use ($indicator) {
return $item['urgent_ids'] == $indicator;
});
$urgent_orders= array_filter($orders, function ($item) use ($indicator) {
return $item['urgent_ids'] !== $indicator;
});
@endphp
@if($search_text != "")
<h4>
<label class="label label-info">{{ $search_text }}</label>
@if (count($urgent_orders) > 0)
&nbsp;&nbsp;<label class="label label-danger">{{ __('investigations.auth_incoming_lab_results_warning') }}</label>
@endif
</h4>
@endif
<div class="row">
<div class="col-md-9">
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs" role="tablist">
@if (count($urgent_orders)>0)
<li role="presentation" class="nav-item"> <a href="#orders_nav_pill" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('investigations.authenticate_lab_investigations') }} ({{ count($normal_orders) }})</a> </li>
<li role="presentation" class="nav-item active"> <a href="#urgent_orders" class="nav-link text-danger" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('investigations.auth_incoming_lab_investigations') }} ({{ count($urgent_orders) }})</a> </li>
@else
<li role="presentation" class="nav-item active"> <a href="#orders_nav_pill" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('investigations.authenticate_lab_investigations') }} ({{ count($normal_orders) }})</a> </li>
@endif
</ul>
</div>
<div class="card-block tab-content">
<div class="table-responsive tab-pane <?php if(count($urgent_orders) < 1) echo 'active'; ?>" id="orders_nav_pill">
<table class="table table-striped table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('investigations.date') }}</th>
<th>{{ __('investigations.patient_number') }}</th>
<th>{{ __('investigations.patient_names') }}</th>
<th>{{ __('investigations.investigations') }}</th>
<th>{{ __('investigations.results') }}</th>
<th>{{ __('investigations.select') }}</th>
</tr>
</thead>
<tbody>
@foreach($normal_orders as $order)
{{ Form::hidden('order_id[]',$order['order_id']) }}
<tr>
<td>
{{ $order['date'] }}
</td>
<td>
{{ $order['number'] }}
</td>
<td>
{!! insurance_flag($order['id']) !!}
</td>
<td colspan="3">
<table class="table table-bordered table-striped table-borderless">
<tbody>
<?php $count = 0; ?>
@foreach($order['values'] as $value)
@if(get_name($value['investigation_id'], 'id', 'type', 'investigations') == 1)
<tr>
<td colspan="2">
{{ $value['name'] }}
</td>
<td>
@if(empty($value['per_investigation']) || $value['per_investigation'] == 0)
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $order['order_id'] }}/{{ $count }}">
@else
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $order['order_id'] }}/{{ $count }}" checked>
@endif
</td>
</tr>
@php
// get the specialised results and check if it is valid
$specialised_results = \Illuminate\Support\Facades\DB::table('investigation_specialised_results')->find($value['value']);
$specialised_ids = [];
$specialised_values = [];
if(!is_null($specialised_results)){
$specialised_ids = explode(",", $specialised_results->specialised_variable_id);
$specialised_values = explode(",", $specialised_results->value);
}
@endphp
@if(count($specialised_ids) > 0)
@for($i = 0; $i < count($specialised_ids); $i++)
<tr>
<td>
{{ get_name($specialised_ids[$i], 'id', 'name', 'investigation_specialised_variables') }}
</td>
<td colspan="2">{{ $specialised_values[$i] }}</td>
</tr>
@endfor
@else
<tr><td></td><td colspan="2"></td></tr>
@endif
<tr><td colspan="3"></td></tr>
@else
<tr>
<td>
{{ $value['name'] }}
</td>
<td>
{{ $value['value'] }}
@if (!empty($value['document']))
<br><br><a class="label label-info" href="/patient_documents/{{ $value['document'] }}" target="_blank"> {{ $value['title'] }}</a>
@endif
</td>
<td>
@if(empty($value['per_investigation']) || $value['per_investigation'] == 0)
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $order['order_id'] }}/{{ $count }}">
@else
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $order['order_id'] }}/{{ $count }}" checked>
@endif
</td>
</tr>
@endif
<?php $count++; ?>
@endforeach
{{ Form::hidden('count[]',$count) }}
</tbody>
</table>
</td>
</tr>
@endforeach
@if(count($orders) <= 0)
<tr>
<td colspan="6" class='text-center' style='color: maroon; font-weight: bold;'>{{ __('investigations.all_results_authenticated') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
@if (count($urgent_orders) > 0)
<div class="table-responsive tab-pane active" id="urgent_orders">
<table class="table table-striped table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('investigations.date') }}</th>
<th>{{ __('investigations.patient_number') }}</th>
<th>{{ __('investigations.patient_names') }}</th>
<th>{{ __('investigations.investigations') }}</th>
<th>{{ __('investigations.results') }}</th>
<th>{{ __('investigations.select') }}</th>
</tr>
</thead>
<tbody>
@foreach($urgent_orders as $urgent_order)
{{ Form::hidden('order_id[]',$urgent_order['order_id']) }}
<tr>
<td>
{{ $urgent_order['date'] }}
</td>
<td>
{{ $urgent_order['number'] }}
</td>
<td>
{!! insurance_flag($urgent_order['id']) !!}
</td>
<td colspan="3">
<table class="table table-bordered table-striped table-borderless">
<tbody>
<?php $count = 0; ?>
@foreach($urgent_order['values'] as $value)
@if(get_name($value['investigation_id'], 'id', 'type', 'investigations') == 1)
<tr>
<td colspan="2">
{{ $value['name'] }}
</td>
<td>
@if(empty($value['per_investigation']) || $value['per_investigation'] == 0)
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $urgent_order['order_id'] }}/{{ $count }}">
@else
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $urgent_order['order_id'] }}/{{ $count }}" checked>
@endif
</td>
</tr>
@php
// get the specialised results and check if it is valid
$specialised_results = \Illuminate\Support\Facades\DB::table('investigation_specialised_results')->find($value['value']);
$specialised_ids = [];
$specialised_values = [];
if(!is_null($specialised_results)){
$specialised_ids = explode(",", $specialised_results->specialised_variable_id);
$specialised_values = explode(",", $specialised_results->value);
}
@endphp
@if(count($specialised_ids) > 0)
@for($i = 0; $i < count($specialised_ids); $i++)
<tr>
<td>
{{ get_name($specialised_ids[$i], 'id', 'name', 'investigation_specialised_variables') }}
</td>
<td colspan="2">{{ $specialised_values[$i] }}</td>
</tr>
@endfor
@else
<tr><td></td><td colspan="2"></td></tr>
@endif
<tr><td colspan="3"></td></tr>
@else
<tr>
<td>
{{ $value['name'] }}
</td>
<td>
{{ $value['value'] }}
@if (!empty($value['document']))
<br><br><a class="label label-info" href="/patient_documents/{{ $value['document'] }}" target="_blank"> {{ $value['title'] }}</a>
@endif
</td>
<td>
@if(empty($value['per_investigation']) || $value['per_investigation'] == 0)
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $urgent_order['order_id'] }}/{{ $count }}">
@else
<input type="checkbox" name="investigation_id[]" class="investigation_id" value="{{ $urgent_order['order_id'] }}/{{ $count }}" checked>
@endif
</td>
</tr>
@endif
<?php $count++; ?>
@endforeach
{{ Form::hidden('count[]',$count) }}
</tbody>
</table>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
</div>
<div class="col-md-3">
<h5 class="heading btn-link">{{ __('investigations.please_login_as_senior_lab') }}</h5>
<div class="form-group">
{{ Form::label('username', __('investigations.username')) }}
{{ Form::text('username', '', ['class' => 'form-control compulsory', 'required']) }}
</div>
<div class="form-group">
{{ Form::label('password', __('investigations.password')) }}
<input class="form-control compulsory" type="password" name="password" required>
</div>
{{ Form::button(__('investigations.authenticate_results'),['type'=>'submit','id'=>'authenticate_submit_button','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
</div>
</div>
</div>
{{ Form::close() }}
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('#patient_number').change(function () {
let id = $('#patient_number').val();
$('#patient_id').val(id);
});
$('#patient_number').select2({
placeholder: 'Search by patient details (names and number)',
ajax: {
url: '/patients/search_patient_by_name_number',
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.first_name + " " + item.last_name + " (" + item.number + ")",
id: item.id
}
})
};
},
cache: true
}
});
$('#search_date_by').change(function() {
if($(this).val() === "custom_date"){
$("#end_date_div").hide();
$("#start_date_div").show();
} else if($(this).val() === "custom_date_range") {
$("#start_date_div").show();
$("#end_date_div").show();
} else {
$("#end_date_div").hide();
$("#start_date_div").hide();
}
});
$('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$("#authenticate_submit_button").click(function (e) { // loop thru for checked checkboxes and fill in array
var non_empty_investigations_ids_array = [];
$(".investigation_id").each(function () {
if ($(this).is(":checked")) {
var textname = $(this).attr('name');
$(this).focus();
non_empty_investigations_ids_array.push(textname);
}
});
/* check if the non_empty_investigations_ids_array array is empty and require atleast one id then return false */
if (non_empty_investigations_ids_array.length === 0) {
alert("Please check atleast one investigation to authenitcate<?php echo __('investigations.please_login_as_senior_lab') ?>");
console.log(non_empty_investigations_ids_array);
e.preventDefault();
return false;
}
});
</script>
@endpush