@extends('layouts.main') @push('styles') @endpush @section('content')
@if(session()->has('alter_episode_id'))

Alter Prescriptions

@else

{{ __('prescriptions.treatment_for_episode') }}:{{ streamline_date(get_name($episode_id, 'id', 'created_at', 'patient_episodes')) }}

@endif
@include('patients::allergies.header')
@if( Auth::user()->can('view-previous-patient-prescriptions')) @if(count($previous_treatments) > 0)

{{ __('prescriptions.previous_prescriptions') }}

@foreach($previous_treatments as $past_treatment) @php $past_drug_ids_array = explode(",", $past_treatment->drugs); $past_dosage_array = explode(",", $past_treatment->doses); $past_quantities_array = explode(",", $past_treatment->quantities_dispensed); $past_frequencies_array = explode(",", $past_treatment->frequencies); $past_durations_array = explode(",", $past_treatment->durations); $past_instructions_array = explode(",", $past_treatment->instructions); @endphp @endforeach
{{ __('prescriptions.date') }} {{ __('prescriptions.clinic') }} {{ __('prescriptions.primary_diagnosis') }} {{ __('prescriptions.other_diagnoses') }} {{ __('prescriptions.prescribed_by') }}
{{ streamline_date_time($past_treatment->created_at) }}
@if(check_if_episode_is_a_followup($past_treatment->episode_id))
({{ __('patient_episode.review_from') }} {{ streamline_date(get_name(get_name($past_treatment->episode_id, 'id', 'parent_episode_id', 'patient_episodes'), 'id', 'created_at', 'patient_episodes')) }})
@endif
{{ get_name(get_name($past_treatment->episode_id, 'id', 'clinic_id', 'patient_episodes'), "id", "name", "clinics") }} {{ get_name(get_name($past_treatment->episode_id, 'episode_id', 'primary_diagnosis', 'consultations'), 'id', 'name', 'diagnoses') }} {{ get_full_name($past_treatment->created_by, "id", "first_name", "last_name", "users") }} {{ __('prescriptions.view_details') }}
@if(Auth::user()->can('view-patients-home')) {{ __('prescriptions.patient_home') }} @endif
@endif @endif {{ Form::open(['route' => 'prescriptions.process' , 'data-toggle' => 'validator', 'id' => 'selected_drugs_form']) }}
@if (count($chronic_drugs_array) > 0) @foreach ($chronic_drugs_array as $chronic_drug) @if(isset($drugs[$chronic_drug->drug_id])) @endif @endforeach
Patient's Chronic Drugs
{{ $drugs[$chronic_drug->drug_id] }}

@endif {{ Form::hidden('is_progressive_treatment_setup', 0, ['id' => 'is_progressive_treatment_setup']) }}
@php $patient_insurance_status = patient_insurance_status($patient_id); @endphp {{ Form::hidden('patient_id', $patient_id, ['id' => 'patient_id']) }} {{ Form::hidden('patient_insurance_status', $patient_insurance_status, ['id' => 'patient_insurance_status']) }} @if(!is_out_of_stock_message_disabled()) {{ Form::hidden('show_out_of_stock_message', 1, ['id' => 'show_out_of_stock_message']) }} @endif @php $option_drugs = ""; foreach ($drugs as $key => $value){ $drug_name = str_replace("'", '', $value); $drug_name = str_replace("\"", '', $drug_name); $drug_name = str_replace("+", '', $drug_name); //$drug_name = preg_replace('/[^A-Za-z0-9\-]/', '', $drug_name); $option_drugs .= ""; } $option_frequencies = ""; foreach ($dosage_frequencies as $key => $value){ $option_frequencies .= ""; } $counter = 0; $total_amount = 0; $first_dose_total_amount = 0; $treatment_opd_progressive_id = 0; @endphp @if($treatment) @php if ($treatment->is_treatment_progressive != 0) { $treatment_progressive = Streamline\Models\TreatmentOpdProgressive::find($treatment->is_treatment_progressive); } if (isset($treatment_progressive) && $treatment_progressive->treatment_ids == $treatment->id) { $treatment_opd_progressive_id = $treatment_progressive->id; $progressive_quantity_dispensed_array = explode(",", $treatment->quantities_dispensed); $progressive_durations_array = explode(",", $treatment->durations); $treatment = $treatment_progressive; $drugs_array = explode(",", $treatment->drugs); $dosage_array = explode(",", $treatment->dose); $frequencies_array = explode(",", $treatment->drug_frequency); $duration_array = explode(",", $treatment->durations); $quantity_dispensed_array = explode(",", $treatment->quantities_to_dispense); $instructions_array = explode(",", $treatment->instruction); $purchased_elsewhere_array = explode(",", $treatment->purchased_elsewhere); } else { $drugs_array = explode(",", $treatment->drugs); $progressive_quantity_dispensed_array = array_fill(0, count($drugs_array), 0); $progressive_durations_array = array_fill(0, count($drugs_array), 0); $dosage_array = explode(",", $treatment->doses); $frequencies_array = explode(",", $treatment->frequencies); $duration_array = explode(",", $treatment->durations); $quantity_dispensed_array = explode(",", $treatment->quantities_dispensed); $instructions_array = explode(",", $treatment->instruction); $purchased_elsewhere_array = explode(",", $treatment->purchased_elsewhere); } $total_drug_price = 0; $eye_array = explode(",", $treatment->eye); @endphp @for ($x = 0; $x < count($drugs_array); $x++) @php $treament_drug = \DB::table('drugs')->where('id',$drugs_array[$x])->first(); if(!is_numeric($quantity_dispensed_array[$x])) { $quantity_dispensed_array[$x] = 0; } // check if the patient category is attached to a price list $treatment_drug_price = 0; $price_list_id = is_patient_category_attached_to_price_list($patient_id); if (is_numeric($drugs_array[$x])) { if ($patient_insurance_status == 1) { $treatment_drug_price = get_item_insurance_co_payment($patient_id, $drugs_array[$x], 4, false, 0); } else { if ($price_list_id) { $treatment_drug_price = get_price_list_category_price($price_list_id, 3, $drugs_array[$x]); } else { $treatment_drug_price = get_name($drugs_array[$x], "id", "non_insured_price", "drugs"); } } if (!is_numeric($treatment_drug_price)) { $treatment_drug_price = 0; } $total_amount += $treatment_drug_price * $quantity_dispensed_array[$x]; $reference_array = explode(",", $treament_drug->reference_areas); $reference_name = explode(",", $treament_drug->reference_name); } else { continue; } @endphp @php $counter++; @endphp @endfor @else @endif @if( Auth::user()->can('add-row-on-prescription')) @endif
{{ __('prescriptions.drug') }}
{{ __('prescriptions.dosage') }}
{{ __('prescriptions.prompt') }}
{{ __('prescriptions.duration') }}
{{ __('prescriptions.dispense') }}
{{ __('prescriptions.instructions') }}
{{ Form::select('drug_id[]', $drugs, $drugs_array[$x], ['class' => 'form-control compulsory drugs_id_class', 'id' => 'drugs_id_' . $counter]) }} @php $pharm_comment = trim($treament_drug->pharmacy_comment); @endphp
@for ($j = 0; $j < count($reference_array); $j++) @if(isset($reference_array[$j]) && isset($reference_name[$j])) {{ $reference_name[$j] }}
@endif @endfor
  
@if (!is_chi_enabled() && !is_drug_covered_by_pay_later_category(get_name($patient_id, 'id', 'category_id', 'patients'), $treament_drug->id)) Not covered by {{ get_name(get_name($patient_id, 'id', 'category_id', 'patients'), 'id', 'name', 'patient_categories') }} @endif
@if (is_chi_enabled()) @if (is_patient_item_covered($patient_id, $drugs_array[$x], 4))   
Covered by CHI @else   
Not covered by CHI @endif @endif

{{ Form::select('eye[]', [2 => 'Both', 0 => 'Left', 1 => 'Right'], $eye_array[$x] ?? 2, ['class' => 'form-control compulsory', 'required']) }}
@if(!is_incoming_prescriptions_feature_enabled())
Tick if drug will be purchased elsewhere @endif
{{ get_name($treament_drug->unit_id, 'id', 'name', 'drug_units') }}
{{ Form::select('frequency[]', $dosage_frequencies, $frequencies_array[$x], ['class' => 'form-control frequency_class', 'id' => 'frequency' . $counter]) }}
{!! read_more($treament_drug->prompt, 'prompt_short' . $treament_drug->id, 'prompt_long' . $treament_drug->id) !!}
Days
@if($counter == 0) @else @endif
  

@if(!is_incoming_prescriptions_feature_enabled())
Tick if drug will be purchased elsewhere @endif
Days
@if(view_prescription_price_on_order())

Total: {{ ugandan_shillings($total_amount) }}

@endif
{{ Form::label('order_comments', 'Treatment Order Comments') }}

@if(str_replace(url('/'), '', url()->previous()) != "/confirm_prescriptions") Ignore prescription @endif @if(!session()->has('alter_episode_id')) @endif @if(session()->has('alter_episode_id'))

Alter Prescriptions Details

{{ __('pharmacy.type_of_error') }}
{{ __('pharmacy.wrong_dosage') }}
{{ __('pharmacy.wrong_frequency') }}
{{ __('pharmacy.inadequate_funds') }}
{{ __('pharmacy.other') }}
{{ __('pharmacy.severity_of_error') }}
{{ __('pharmacy.mild') }}
{{ __('pharmacy.moderate') }}
{{ __('pharmacy.severe') }}
{{ __('pharmacy.comments') }}



@endif
{{ Form::close() }}

{{ __('prescriptions.treatment_for_given_episode') }}

@if(count($dispensed_drugs) > 0) @foreach($dispensed_drugs as $treatment) @php $drugs_array = explode(",", $treatment->drugs); $dosage_array = explode(",", $treatment->doses); $dosage2_array = explode(",", $treatment->dose2); $frequencies_array = explode(",", $treatment->frequencies); $duration_array = explode(",", $treatment->durations); $quantity_dispensed_array = explode(",", $treatment->quantities_dispensed); $instructions_array = explode(",", $treatment->instruction); $purchased_elsewhere_array = is_null($treatment->purchased_elsewhere) ? [] : explode(",", $treatment->purchased_elsewhere); @endphp @for($x = 0; $x < count($drugs_array); $x++) @php $frequency_name = get_name($frequencies_array[$x], 'id', 'name', 'dosage_frequencies'); $unit = get_name($drugs_array[$x], 'id', 'name', 'drug_units'); $unit = $unit=="N/A"?"":$unit; $drug_unit = "" . $unit . ""; $dose2 = (empty($dosage2_array[$x])) ? "" : " | " . $dosage2_array[$x] . $drug_unit; $status_text = ""; if($treatment->payment_status == 1) { $status_text .= "Paid, "; } else { $status_text .= "Not Paid, "; } if($treatment->dispense_status == 1) { $status_text .= "Dispensed"; } else { $status_text .= "Not Dispensed"; } if($treatment->altered == 1) { $status_text .= ", Altered"; } @endphp @if(isset($purchased_elsewhere_array[$x]) && $purchased_elsewhere_array[$x] == 1) @else @endif @endfor @endforeach @else @endif
{{ __('prescriptions.date') }} {{ __('prescriptions.drug') }} {{ __('prescriptions.dosage') }} {{ __('prescriptions.duration') }} {{ __('prescriptions.quantity') }} {{ __('prescriptions.status') }} {{ __('prescriptions.instructions') }}
{{ streamline_date_time($treatment->updated_at) }} {{ get_name($drugs_array[$x], 'id', "name", 'drugs') }} {{ $dosage_array[$x] }} {!! $drug_unit !!} {{ $dose2 }}    {{ $frequency_name }} {{ $duration_array[$x] }} {{ $quantity_dispensed_array[$x] }}Purchased From Elsewhere{{ $status_text }} {{ isset($instructions_array[$x]) ? trim($instructions_array[$x]) : 'N/A' }} @if(array_key_exists($drugs_array[$x], $drugs)) @endif
{{ __('prescriptions.no_treatment_history') }}
@endsection @push('scripts') @endpush