Files
streamline-emr/docker/statistics/Modules/PatientFinance/Resources/views/patient_finance/home.blade.php
T
2025-03-31 03:46:05 +03:00

554 lines
32 KiB
PHP
Executable File

@php use Modules\PatientFinance\Http\Controllers\PatientFinanceController; @endphp
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}"
rel="stylesheet">
<style type="text/css">
#t_header th {
background-color: #708090;
color: #000;
}
.color-tr {
background: #FFFF99;
}
.aTable tr {
background-color: #DDD;
}
.table_no_padding td {
padding: 4px;
}
span.not_paid {
color: red;
}
span.paid {
color: green;
}
span.partial_paid {
color: orange;
}
span.invoiced {
color: blue;
}
</style>
@endpush
@section('content')
@if(session()->get("print_patient_account_receipt_pdf") == 1)
{{ Form::hidden('print_patient_account_receipt_pdf', 1, ['id' => 'print_patient_account_receipt_pdf']) }}
@endif
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('patient_finance.patient_finance') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> {{ __('patients.dashboard') }}</a></li>
<li><a href="{{ route('finance') }}"><i
class="fa fa-money"></i> {{ __('patient_finance.finance_home') }}</a></li>
<li class="active"><i class="fa fa-user"></i> {{ __('patient_finance.patient_finance') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('layouts.finance_header')
</div>
</div>
{{ Form::open(['route' => 'patient_finance.select_payment_option']) }}
<div class="row">
<div class="col-md-12">
<div class="white-box">
@include('flash::message')
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('patient_finance.date') }}</th>
<th>{{ __('patient_finance.consultation') }}</th>
<th>{{ __('patient_finance.treatment') }}</th>
<th>{{ __('patient_finance.investigations') }}</th>
<th>{{ __('patient_finance.procedures') }}</th>
<th>{{ __('patient_finance.other_services') }}</th>
<th>{{ __('patient_finance.inpatient_deposits') }}</th>
<th>{{ __('patient_finance.sundries') }}</th>
@if(is_eye_module_enabled())
<th>{{ __('patient_finance.eye_glasses') }}</th>
@endif
<th>{{ __('patient_finance.co_payment') }}</th>
<th>{{ __('patient_finance.debts') }}</th>
<th>{{ __('patient_finance.select') }}</th>
</tr>
</thead>
<tbody>
@if(!is_null($episodes))
@foreach($episodes as $episode)
@php
$service_items = PatientFinanceController::get_service_items_string($episode->id);
$service_items_pay_later = PatientFinanceController::get_service_items_pay_later_string($episode->id);
$service_items_inpatient_deposit = PatientFinanceController::get_inpatient_deposit_string($episode->id);
$used_services = \Streamline\Models\OrderedService::where(['patient_id' => $episode->patient_id, 'episode_id' => $episode->id, 'payment_status' => 0,'inpatient_bill_generated' => 0])->get();
$consultation_payment_status = "<span class='no_records'>NA</span>";
$other_services_payment_status = "<span class='no_records'>NA</span>";
$service_items_ids_array = [];
foreach ($service_items as $item){
array_push($service_items_ids_array, explode(',', $item['items_ids']));
}
foreach ($service_items_pay_later as $item){
array_push($service_items_ids_array, explode(',', $item['items_ids']));
}
$service_deposits_types = [];
foreach($service_items_ids_array as $service_item_id){
if (is_array($service_item_id)) {
foreach ($service_item_id as $id) {
$service_deposits_types[] = get_name($id, "id", "item_type", "services");
}
} else {
$service_deposits_types[] = get_name($service_item_id, "id", "item_type", "services");
}
}
if (in_array('Consultation', $service_deposits_types)) {
if (in_array($patient->category_id, $pay_later_categories)){
$consultation_payment_status = "<span class='invoiced'>Invoiced</span>";
} elseif ($episode->paid_over == "pos") {
$consultation_payment_status = "<label class='label label-success'>POS</span>";
} else {
$consultation_payment_status = "<span class='paid'>Paid</span>";
}
}
if (in_array('Service', $service_deposits_types) || in_array('Other_service', $service_deposits_types) || in_array('Services', $service_deposits_types)) {
$other_services = 1; // paid services
if (in_array($patient->category_id, $pay_later_categories)){
$other_services_payment_status = "<span class='invoiced'>Invoiced</span>";
} else {
$other_services_payment_status = "<span class='paid'>Paid</span>";
}
}
foreach($used_services as $service){
$single_order_services_ids_array = explode(",",$service->service_id);
foreach ($single_order_services_ids_array as $single_order_services_id) {
$service_type = get_name($single_order_services_id, "id", "item_type", "services");
if ($service_type == 'Consultation') {
$consultation_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} elseif ($service_type == 'Service' || $service_type == 'Other_service' || $service_type == 'Services') {
$other_services_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
}
}
}
if (in_array('Co_Payment', $service_deposits_types)) {
if (in_array($patient->category_id, $pay_later_categories)){
$copayment_payment_status = "<span class='invoiced'>Invoiced</span>";
} else {
$copayment_payment_status = isset($other_services_payment_status) ? $other_services_payment_status : "<span class='paid'>Paid</span>";
}
} else {
$copayment_payment_status = "<span class='no_records'>NA</span>";
}
if(count($service_items_inpatient_deposit) > 0){
$inpatient_deposits = 1;
} else {
$inpatient_deposits = 0;
}
$investigations = PatientFinanceController::check_investigations_payment($episode->id);
$prescription = PatientFinanceController::check_prescription_payment($episode->id);
$is_inpatient = get_name($episode->id, "episode_id", "payment_status", "inpatient_info");
$procedures_paid = PatientFinanceController::check_procedures_payment($episode->id);
$sundries_paid = PatientFinanceController::check_sundry_payment($episode->id);
$debt_paid = PatientFinanceController::check_debt($episode->id);
$debt_plans = PatientFinanceController::check_patient_debt_plan($episode->id);
$opticals_paid = PatientFinanceController::check_optical_payment($episode->id);
//process all the copayments
if ($episode->co_payment == 0) {
$valueCo = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} else {
if (in_array($patient->category_id, $pay_later_categories)){
$valueCo = "<span class='invoiced'>Invoiced</span>";
}else{
$valueCo = "<span class='not_paid'>Unpaid</span>";
}
}
//process all the investigations
if ($investigations === 0 ) {
$investigations_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} elseif ($investigations === 1) {
if (in_array($patient->category_id, $pay_later_categories)){
$investigations_payment_status = "<span class='invoiced'>Invoiced</span>";
}else{
$investigations_payment_status = "<span class='paid'>Paid</span>";
}
} else {
$investigations_payment_status = "<span class='no_records'>NA</span>";
}
//process all the prescription payment status
if ($prescription == 0) {
$treatment_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} elseif ($prescription == 1) {
if (in_array($patient->category_id, $pay_later_categories)){
$treatment_payment_status = "<span class='invoiced'>Invoiced</span>";
}else{
$treatment_payment_status = "<span class='paid'> Paid</span>";
}
} else {
$treatment_payment_status = "<span class='no_records'>NA</span>";
}
// check if the patient is admitted
if ($is_inpatient == '1' || $is_inpatient == '0'){
//process all the inpatient deposits
$real_inpatient_deposit_status = PatientFinanceController::get_inpatient_deposit_status($episode->id);
if ($inpatient_deposits == '0') {
$inpatient_deposits_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} elseif ($real_inpatient_deposit_status == '1') {
$inpatient_deposits_payment_status = "<span class='paid'>" . __('patient_finance.paid') . "</span>";
} elseif ($real_inpatient_deposit_status == '2') {
$inpatient_deposits_payment_status = "<span class='partial_paid'>" . __('patient_finance.partial_payment') . "</span>";
}
} else {
$inpatient_deposits_payment_status = "<span class='no_records'>NA</span>";
}
//process all procedure payments
if ($procedures_paid === 0) {
$procedures_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} elseif ($procedures_paid === 1) {
if (in_array($patient->category_id, $pay_later_categories)){
$procedures_payment_status = "<span class='invoiced'>Invoiced</span>";
}else{
$procedures_payment_status = "<span class='paid'>Paid</span>";
}
} else {
$procedures_payment_status = "<span class='no_records'>NA</span>";
}
//process all sundries payments
if ($sundries_paid === 0) {
$sundries_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} elseif ($sundries_paid === 1) {
if (in_array($patient->category_id, $pay_later_categories)){
$sundries_payment_status = "<span class='invoiced'>Invoiced</span>";
}else{
$sundries_payment_status = "<span class='paid'>Paid</span>";
}
} else {
$sundries_payment_status = "<span class='no_records'>NA</span>";
}
// process all optical payments
if ($opticals_paid === 0) {
$optical_payment_status = "<span class='not_paid'>" . __('patient_finance.unpaid') . "</span>";
} elseif ($opticals_paid === 1) {
if (in_array($patient->category_id, $pay_later_categories)){
$optical_payment_status = "<span class='invoiced'>Invoiced</span>";
} else {
$optical_payment_status = "<span class='paid'>Paid</span>";
}
} else {
$optical_payment_status = "<span class='no_records'>NA</span>";
}
//debt status
if ($debt_paid === 0) {
$debt_value = "<span class='not_paid'>" . __('patient_finance.patient_debts_unpaid') . "</span>";
} elseif ($debt_paid === 1) {
$debt_value = "<span class='paid'>" . __('patient_finance.patient_debts_paid') . "</span>";
} else{
$debt_value = ""; //"<span class='no_records'>NA</span>";
}
if($debt_plans === 0) {
$debt_value .= "<br/><span class='not_paid'>" . __('patient_finance.unpaid_debt_plan') . "</span>";
} elseif($debt_plans === 1) {
$debt_value .= "<br/><span class='paid'>" . __('patient_finance.paid_debt_plan') . "</span>";
}
$patient_ran_away_without_paying = check_if_patient_ran_away_without_paying($episode->id);
$episode_appointment = get_all_first(['episode_id' => $episode->id, 'patient_id' => $episode->patient_id], 'patient_appointments');
@endphp
<tr id='my_row{{ $episode->id }}'>
<td width='15%'>
<a href='#'
style='color: #0099CC'>{{ streamline_date($episode->created_at) }}</a>
@if(check_if_episode_is_a_followup($episode->id))
@php $original_episode = \Streamline\Models\PatientEpisode::find($episode->parent_episode_id); @endphp
@if ($original_episode)
<small style="color: green"><br>({{ __('patient_finance.reviewed_from') }} {{ streamline_date($original_episode->created_at) }}
)</small>
@endif
@endif
</td>
<td>
@if($episode->episode_type == 1)
<span class="label label-info">{{ __('patient_flow_monitoring.lab_self_request') }}</span>
@else
@php
$consultation_done_by = get_doctor_who_has_done_episode_consultation($episode->patient_id, $episode->id);
if(!is_null($consultation_done_by)){
$consultation_id = get_consultation_service_id_allocated_at_episode_consultation($episode->patient_id, $episode->id);
$price_list_id = is_patient_category_attached_to_price_list($episode->patient_id);
if($price_list_id){
$consultation_fee = get_price_list_category_price($price_list_id, 6, $consultation_id);
} else {
$consultation_fee = get_name($consultation_id, "id", "non_insured_price", "services");
}
}
@endphp
{!! $consultation_payment_status !!}
@if(!is_null($consultation_done_by))
<br>
<b>{{ __('patient_finance.done_by') }}
:</b> {{ get_full_name($consultation_done_by, "id", "first_name", "last_name", "users") }}
<br>
<b>{{ __('patient_finance.fee') }}
:</b>{{ ugandan_shillings($consultation_fee) }}
@endif
@endif
</td>
<td>
@if($prescription === 0)
<span class='not_paid'>{{ __('patient_finance.unpaid') }}</span>
@elseif ($prescription === 1)
@if(in_array($patient->category_id, $pay_later_categories))
<span class='invoiced'>{{ __('patient_finance.invoiced') }}</span>
@else
<span class='paid'>{{ __('patient_finance.paid') }}</span>
@endif
@else
<span class='no_records'>NA</span>
@endif
</td>
<td>{!! $investigations_payment_status !!}</td>
<td>{!! $procedures_payment_status !!}</td>
<td>{!! $other_services_payment_status !!}</td>
<td>{!! $inpatient_deposits_payment_status !!}</td>
<td>{!! $sundries_payment_status !!}</td>
@if(is_eye_module_enabled())
<td>{!! $optical_payment_status !!}</td>
@endif
<td>{!! $copayment_payment_status !!}</td>
<td>{!! $debt_value !!}</td>
<td>
<input type="radio" onchange="show()" class="radio-option" name="episode_id"
id="episode_id" value="{{ $episode->id }}"/>
</td>
</tr>
@if($patient_ran_away_without_paying)
<tr style="background-color: #ffcccc">
<td>
<a href='#'
style='color: #0099CC'>{{ streamline_date($episode->created_at) }}</a>
</td>
<td colspan="11" class="text-center">
<span style="color: orangered">{{ __('patient_finance.patient_ran_away') }}</span>
</td>
</tr>
@endif
@endforeach
@else
<tr>
<td colspan="11" class="center"
style="color: red">{{ __('patient_finance.no_patient_episode') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
{{ $episodes->links() }}
</div>
<div id="payment_buttons" style="display: none;">
<div class="row">
<div class="col-sm-2">
@if(Auth::user()->can('make-consultation-deposits'))
<button type="submit" name="consultation" class="btn btn-success btn-sm col-sm-12"
value="consultation">{{ __('patient_finance.consultation') }}</button>
@endif
</div>
<div class="col-sm-2">
@if(Auth::user()->can('make-treatment-deposits'))
<button type="submit" name="treatment" class="btn btn-success btn-sm col-sm-12"
value="treatment">{{ __('patient_finance.treatment') }}</button>
@endif
</div>
<div class="col-sm-2">
@if(Auth::user()->can('make-investigations-deposits'))
<button type="submit" name="investigations" class="btn btn-success btn-sm col-sm-12"
value="investigations">{{ __('patient_finance.investigations') }}</button>
@endif
</div>
<div class="col-sm-2">
@if(Auth::user()->can('make-procedures-deposits'))
<button type="submit" name="procedures" class="btn btn-success btn-sm col-sm-12"
value="procedures">{{ __('patient_finance.procedures') }}</button>
@endif
</div>
<div class="col-sm-2">
@if(Auth::user()->can('make-co-payments-deposits'))
<button type="submit" name="co_payments" class="btn btn-success btn-sm col-sm-12"
value="co_payments">{{ __('patient_finance.co_payment') }}</button>
@endif
</div>
<div class="col-sm-2">
@if(Auth::user()->can('make-other-services-deposits'))
<button type="submit" name="other_services" class="btn btn-success btn-sm col-sm-12"
value="other_services">{{ __('patient_finance.other_services') }}</button>
@endif
</div>
</div>
<br><br>
<div class="row">
<div class="col-sm-2">
@if(Auth::user()->can('make-patient-refund'))
<button type="submit" name="refund_patient"
class="btn btn-success btn-sm pull-right col-sm-12"
value="refund_patient">{{ __('patient_finance.refund_patient') }}</button>
@endif
</div>
<div class="col-sm-2">
@if(Auth::user()->can('make-central-billing'))
<button type="submit" name="central_billing"
class="btn btn-success btn-sm pull-right col-sm-12"
value="central_billing">{{ __('patient_finance.central_billing') }}</button>
@endif
</div>
<div class="col-sm-2">
@if(Auth::user()->can('make-sundries-deposits'))
<button type="submit" name="sundries" class="btn btn-success btn-sm pull-right col-sm-12"
value="sundries">{{ __('patient_finance.sundries') }}</button>
@endif
</div>
<div class="col-sm-2">
<button type="submit" name="inpatient_billing" class="btn btn-success btn-sm col-sm-12"
value="inpatient_billing">{{ __('patient_finance.inpatient_billing') }}</button>
</div>
<div class="col-sm-2">
<button type="submit" name="inpatient_deposit"
class="btn btn-success btn-sm pull-right col-sm-12"
value="inpatient_deposit">{{ __('patient_finance.inpatient_deposits') }}</button>
</div>
<div class="col-sm-2">
<button type="submit" name="patient_debts" class="btn btn-success btn-sm pull-right col-sm-12"
value="patient_debts">{{ __('patient_finance.patient_debts') }}</button>
</div>
</div>
<br><br>
<div class="row">
<div class="col-sm-2">
<button type="button" class="btn btn-success btn-sm pull-right col-sm-12"
id="customer_episode_statement">{{ __('patient_finance.customer_episode_statement') }}</button>
</div>
@if(is_patient_category_pay_later($patient->category_id))
<div class="col-sm-2">
<button type="submit" name="edit_claim_number"
class="btn btn-success btn-sm pull-right col-sm-12"
value="edit_claim_number">{{ __('patient_finance.edit_claim_number') }}</button>
</div>
@endif
<div class="col-sm-2">
<button type="submit" name="patient_debt_plan"
class="btn btn-success btn-sm pull-right col-sm-12"
value="patient_debt_plan">{{ __('patient_finance.patient_debt_plan') }}</button>
</div>
@if(is_eye_module_enabled())
<div class="col-sm-2">
<button type="submit" name="optical_items"
class="btn btn-success btn-sm pull-right col-sm-12"
value="optical_items">{{ __('patient_finance.eye_glasses') }}</button>
</div>
@endif
</div>
</div>
</div>
</div>
{{ Form::close() }}
@endsection
@push('scripts')
<script type="text/javascript">
if ($('#print_patient_account_receipt_pdf').val() == 1) {
var win = window.open('/patient_accounts/print_receipt_pdf_details', '_blank');
if (win) {
win.focus();
} else {
alert('Please allow popups for Stre@mline');
}
}
function show() {
$('#payment_buttons').show();
}
$('.radio-option').change(function () {
//this is to highlight the clicked episode row
let episode_id = $(this).val();
if (this.checked) {
// remove the class that highlights the selected row
$('[id^=my_row]').removeClass('color-tr');
$('#my_row' + episode_id).addClass('color-tr');
}
});
$("#customer_episode_statement").click(function () {
let current_episode_id = $('input[name=episode_id]:checked').val();
let win = window.open('/patient_finance/customer_episode_statement/' + current_episode_id, '_blank');
if (win) {
win.focus();
} else {
alert("Please allow pop-ups for this system")
}
});
</script>
@endpush
<style type="text/css">
.modal-dialog {
position: absolute;
top: 40%;
left: 30%;
transform: translate(-50%, -50%) !important;
}
</style>