@extends('layouts.main') @push('styles') @endpush @section('content')

{{ __('patient_accounts.patient_account_statement') }}

@include('patient_discounts::patient_accounts.menu')
@include('flash::message') {{ Form::open(['url' => '/patient_accounts/statement', 'method' => 'ANY']) }}
{{ Form::label('search_by', __('family_accounts.date')) }} {{ Form::select('search_by', ['0'=>__('family_accounts.last_24_hours'),'1'=>__('family_accounts.custom_date'),'2'=>__('family_accounts.custom_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}

{{ Form::button(__('family_accounts.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
{{ Form::close() }}
{{ Form::open(['url' => '/patient_accounts/print_statement', 'target' => '_blank'])}} {{ Form::hidden('reg_date', $reg_date) }} {{ Form::hidden('start_date', $start_date) }} {{ Form::hidden('end_date', $end_date) }} {{ Form::hidden('search_by', $search_by) }} {{ Form::close() }}
@include('patient_discounts::patient_accounts.patient_details') @if(count($patient_deposits) > 0)

{{ __('patient_accounts.deposits') }}

@php $counter = 1; $total_deposits = 0; @endphp @foreach($patient_deposits as $deposit) @php $counter++; @endphp @endforeach
# {{ __('patient_accounts.patient_names') }} {{ __('patient_accounts.deposit_amount') }} {{ __('patient_accounts.deposit_date') }} {{ __('patient_accounts.received_by') }}
{{ $counter }} {{ get_full_name($deposit->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ get_name($deposit->patient_id, 'id', 'number', 'patients') }}) {{ ugandan_shillings($deposit->deposit_amount) }} @php $total_deposits += $deposit->deposit_amount; @endphp {{ streamline_date($deposit->deposit_date) }} {{ get_full_name($deposit->created_by, 'id', 'first_name', 'last_name', 'users') }}
{{ __('family_accounts.total') }} {{ ugandan_shillings($total_deposits) }}

@endif @if(count($patient_refunds) > 0)

{{ __('patient_accounts.refunds') }}

@php $counter = 1; $total_refunds = 0; @endphp @foreach($patient_refunds as $refund) @php $counter++; @endphp @endforeach
# {{ __('patient_accounts.patient_names') }} {{ __('patient_accounts.refund_amount') }} {{ __('patient_accounts.refund_date') }} {{ __('patient_accounts.received_by') }}
{{ $counter }} {{ get_full_name($refund->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ get_name($refund->patient_id, 'id', 'number', 'patients') }}) {{ ugandan_shillings($refund->refund_amount) }} @php $total_refunds += $refund->refund_amount; @endphp {{ streamline_date($refund->refund_date) }} {{ get_full_name($refund->created_by, 'id', 'first_name', 'last_name', 'users') }}
{{ __('family_accounts.total') }} {{ ugandan_shillings($total_refunds) }}

@endif @if(count($patient_consumptions) > 0)

{{ __('patient_accounts.consumption') }}

@php $counter = 1; $total_consumption = 0; @endphp @foreach($patient_consumptions as $record) @php $tag_id = $record->tag_id; $items_received_array = []; if($tag_id == 6 || $tag_id == 8){ $service_deposit_record = \Streamline\Models\ServiceDeposit::where('receipt_number', $record->receipt_number)->first(); if ($service_deposit_record){ $items_received = explode(",", $service_deposit_record->items_ids); for($i = 0; $i < count($items_received); $i++){ $items_received_array[] = get_name($items_received[$i], "id", "name", "services"); } } } elseif($tag_id == 3){ $treatment_deposit_record = \Streamline\Models\TreatmentDeposits::where('receipt_number', $record->receipt_number)->first(); if ($treatment_deposit_record){ $items_received = explode(",", $treatment_deposit_record->treatment_items); for($i = 0; $i < count($items_received); $i++){ $items_received_array[] = get_name($items_received[$i], "id", "name", "drugs"); } } } elseif($tag_id == 5){ $sundries_deposit_record = \Streamline\Models\SundryDeposit::where('receipt_number', $record->receipt_number)->first(); if ($sundries_deposit_record){ $items_received = explode(",", $sundries_deposit_record->sundry_items); for($i = 0; $i < count($items_received); $i++){ $items_received_array[] = get_name($items_received[$i], "id", "name", "sundries"); } } } elseif($tag_id == 2){ $investigation_deposit_record = \Streamline\Models\InvestigationDeposit::where('receipt_number', $record->receipt_number)->first(); if ($investigation_deposit_record){ $items_received = explode(",", $investigation_deposit_record->investigation_items); for($i = 0; $i < count($items_received); $i++){ $items_received_array[] = get_name($items_received[$i], "id", "name", "investigations"); } } } elseif($tag_id == 4){ $procedure_deposit_record = \Streamline\Models\ProcedureDeposit::where('receipt_number', $record->receipt_number)->first(); if ($procedure_deposit_record){ $items_received = explode(",", $procedure_deposit_record->procedure_items); for($i = 0; $i < count($items_received); $i++){ $items_received_array[] = get_name($items_received[$i], "id", "name", "procedures"); } } } @endphp @php $counter++; @endphp @endforeach
# {{ __('patient_accounts.patient_names') }} {{ __('patient_accounts.amount_consumed') }} {{ __('patient_accounts.date_consumed') }} {{ __('patient_accounts.reason') }}
{{ $counter }} {{ get_full_name($record->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ get_name($record->patient_id, 'id', 'number', 'patients') }}) {{ ugandan_shillings($record->amount_consumed) }} @php $total_consumption += $record->amount_consumed; @endphp {{ streamline_date_time($record->created_at) }} {{ get_name($record->tag_id, 'id', 'name', 'finance_point_tags') }}
    @for($j = 0; $j < count($items_received_array); $j++)
  1. {{ $items_received_array[$j] }}
  2. @endfor
{{ __('family_accounts.total') }} {{ ugandan_shillings($total_consumption) }}

@endif


{{ __('patient_accounts.current_balance') }}: {{ ugandan_shillings($patient->patient_account_balance) }}
@if(Auth::user()->can('view-patient-accounts-deposits')) @endif @if(Auth::user()->can('view-patient-accounts-refunds')) @endif
@endsection @push('scripts') @endpush