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

{{ __('consultations.view_consultation_details') }}

@php $patient_id = session('patient_id'); $episode_id = session('episode_id'); $episode_created_at = Carbon\Carbon::parse($episode->created_at); $episode_has_grand_parent_episode = false; @endphp
@include('patients::allergies.header')

@if(check_if_episode_is_a_followup($episode->id)) @php $parent_episode_details = \Streamline\Models\PatientEpisode::find($episode->parent_episode_id); $parent_consultations = \Streamline\Models\Consultation::where(['episode_id' => $parent_episode_details->id])->get(); $parent_consultation_details = count($parent_consultations) > 0 ? $parent_consultations->first() : null; $parent_triage_details = \Streamline\Models\Triage::where(['id' => $parent_episode_details->triage_id])->first(); $parent_consultation_notes = \Streamline\Models\WardInpatientDetailedNote::where(['patient_id' => $episode->patient_id, 'episode_id' => $episode->parent_episode_id, 'ward_id' => 0])->get(); if(check_if_episode_is_a_followup($parent_episode_details->id)){ $episode_has_grand_parent_episode = true; $grand_parent_episode_details = \Streamline\Models\PatientEpisode::find($parent_episode_details->parent_episode_id); $grand_parent_episode_treatments = \Streamline\Models\Treatment::where(['patient_id' => $patient_id, 'episode_id' => $grand_parent_episode_details->id, 'tta' => 0])->get(); $grand_parent_episode_ordered_procedures = \Streamline\Models\OrderedProcedure::where(['patient_id' => $patient_id, 'episode_id' => $grand_parent_episode_details->id])->get(); $grand_parent_episode_ordered_investigations = \Streamline\Models\OrderedInvestigation::where(['patient_id' => $patient_id, 'episode_id' => $grand_parent_episode_details->id])->get(); $grand_parent_episode_ordered_sundries = \Streamline\Models\OrderedSundry::where(['patient_id' => $patient_id, 'episode_id' => $grand_parent_episode_details->id])->get(); $grand_parent_episode_investigation_results = \Streamline\Models\InvestigationResults::where(['patient_id' => $patient_id, 'episode_id' => $grand_parent_episode_details->id])->get(); } @endphp @endif
{{ __('consultations.triage_grade') }} : @if($triage) @switch($triage->severe_grade) @case (1)
{{ __('consultations.green') }}
@break @case (2)
{{ __('consultations.yellow') }}
@break @case (3)
{{ __('consultations.red') }}
@break @default T{{ __('consultations.triage_grade_not_determined') }} @endswitch @endif
{{ __('consultations.symptoms') }} : @if($triage) @php $symptoms_array = explode(",", $triage->symptoms); @endphp @php $symptoms_duration_array = explode(",", $triage->symptom_duration); @endphp
@php $counter = 0; @endphp @for($i = 0; $i < count($symptoms_array); $i++) @endfor
{{ __('consultations.symptom') }} {{ __('consultations.duration') }}
{{ isset($symptoms[$symptoms_array[$i]]) ? $symptoms[$symptoms_array[$i]] : "" }} {{ isset($symptoms_duration_array[$i]) ? $symptoms_duration_array[$i] : "" }}
@else {{ __('consultations.no_symptom_recorded') }} @endif

@if($triage) @php $observations_array = explode(',', $triage->observations); //i.e[temp=44,height=2] $parent_observation_array = isset($parent_triage_details) ? explode(',', $parent_triage_details->observations): []; @endphp
@if(check_if_episode_is_a_followup($episode->id)) @endif @php $counter = 0; @endphp @foreach($observations_array as $observation) @php $item_array = explode('=', $observation); //i.e[temp,44] $counter++; @endphp @if($counter < 9) @if(check_if_episode_is_a_followup($episode->id)) @foreach($parent_observation_array as $parent_observation) @php $parent_item_array = isset($parent_triage_details) ? explode('=', $parent_observation) : []; @endphp @if($item_array[0] == $parent_item_array[0]) @endif @endforeach @endif @endif @endforeach
{{ __('consultations.observation') }} {{ __('consultations.value') }} {{ __('consultations.previous_value') }}
{{ $item_array[0] }} {{ $item_array[1] }} {{ $parent_item_array[1] }}
@if(check_if_episode_is_a_followup($episode->id)) @endif @php $counter=0; @endphp @foreach($observations_array as $observation) @php $item_array = explode('=', $observation); //i.e[temp,44] $counter++; @endphp @if($counter >= 9) @if(check_if_episode_is_a_followup($episode->id)) @foreach($parent_observation_array as $parent_observation) @php $parent_item_array = isset($parent_triage_details) ? explode('=', $parent_observation) : []; @endphp @if($item_array[0] == $parent_item_array[0]) @endif @endforeach @endif @endif @endforeach
{{ __('consultations.observation') }} {{ __('consultations.value') }} {{ __('consultations.previous_value') }}
{{ $item_array[0] }} {{ $item_array[1] }} {{ $parent_item_array[1] }}
{{ __('consultations.comment') }}: {{ !is_null($triage) ? $triage->comments : "" }}
@else {{ __('consultations.no_observations_recorded') }} @endif {{ __('consultations.triage_done_by') }} {!! isset($triage) ? ''.$users[$triage->created_by].' on '.streamline_date_time($triage->created_at).'' : "" !!}
@if(count($documents) > 0) @foreach($documents as $document)
  • {{ is_null($document->title) ? substr($document->description, 0, 5) : $document->title }} ({{ streamline_date_time($document->created_at) }})
  • @endforeach @else {{ __('consultations.no_patient_documents_available') }} @endif
    {{ __('consultations.add_new') }}
    @php $used_services = \Streamline\Models\OrderedService::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get(); $services_counter = 1; @endphp @if(count($used_services) > 0)
    @foreach($used_services as $service) @php $service_ids = explode(",", $service->service_id); $service_quantity = explode(",", $service->quantity); @endphp @for($i = 0; $i < count($service_ids); $i++) @endfor @endforeach
    {{ __('consultations.service') }} {{ __('consultations.quantity') }} {{ __('consultations.payment_status') }}
    {{ get_name($service_ids[$i], "id", "name", "services")}} {{ $service_quantity[$i] }} {!! $service->payment_status == 0 ? "Not Paid" : "Paid" !!}
    @else {{ __('consultations.no_used_services') }} @endif
    {{-- Display TB screening takend from triage --}} @if (is_tuberculosis_screening_enabled())
    @if($triage) @if ($triage->any_tb_sysmptoms == 1)
    A cough for more than two weeks ? {{ $triage->cough_for_2_weeks == 1 ? "Yes" : "No" }}
    Persistent fevers for 2 weeks or more ? {{ $triage->fever_for_2_weeks == 1 ? "Yes" : "No" }}
    Noticeable weight loss of more than 3 Kg? {{ $triage->tb_weight_loss == 1 ? "Yes" : "No" }}
    Poor weight gain in the last one month ? {{ $triage->tb_poor_weight_gain == 1 ? "Yes" : "No" }}
    Excessive night sweats for three weeks or more ? {{ $triage->tb_excessive_night_sweats == 1 ? "Yes" : "No" }}
    Contact with a person with pulmonary TB or chronic cough ? {{ $triage->tb_contact_with_tb_person == 1 ? "Yes" : "No" }}
    @endif @endif
    @endif {{-- end of tb details --}}
    @if(are_symptoms_on_consultation())
    @php $symptoms_explode = explode(",", $consultation->symptoms); $duration_explode = explode(",", $consultation->symptom_duration); @endphp @for ($i = 0; $i < count($symptoms_explode); $i++) @endfor
    {{ __('triage.symptoms') }} {{ __('triage.duration') }}
    {{ $symptoms[$symptoms_explode[$i]] ?? '' }} {{ $duration_explode[$i] ?? '' }}
    @endif @if($is_mental_health_clinic)
    {{ __('consultations.psychosis_symptom_scores') }}
    {{ __('consultations.hallucinations') }} {{ isset($mental_health_consultation->hallucinations) ? $mental_health_consultation->hallucinations : 'N/A' }}
    {{ __('consultations.delusions') }} {{ isset($mental_health_consultation->delusions) ? $mental_health_consultation->delusions : 'N/A' }}
    {{ __('consultations.disorganised_speech') }} {{ isset($mental_health_consultation->disorganised_speech) ? $mental_health_consultation->disorganised_speech : 'N/A' }}
    {{ __('consultations.abnormal_phychomotor_behaviour') }} {{ isset($mental_health_consultation->abnormal_psychomotor_behaviour) ? $mental_health_consultation->abnormal_psychomotor_behaviour : 'N/A' }}
    {{ __('consultations.negative_symptoms') }}
    {{ __('consultations.impaired_cognition') }} {{ isset($mental_health_consultation->impaired_cognition) ? $mental_health_consultation->impaired_cognition : 'N/A' }}
    {{ __('consultations.depression') }} {{ isset($mental_health_consultation->depression) ? $mental_health_consultation->depression : 'N/A' }}
    {{ __('consultations.mania') }} {{ isset($mental_health_consultation->mania) ? $mental_health_consultation->mania : 'N/A' }}
    {{ __('consultations.hamilton_anxiety_score') }} {{ isset($mental_health_consultation->hamilton_anxiety_score) ? $mental_health_consultation->hamilton_anxiety_score : 'N/A' }}

    {{ __('consultations.hamilton_anxiety_score') }}

    0-17 = no / mild anxiety

    18-24 = mild to moderate anxiety

    25-30 = moderate to severe anxiety

    {{ __('consultations.alcohol_score') }}
    {{ __('consultations.total_score') }} {{ isset($mental_health_consultation->alcohol_screening_score) ? $mental_health_consultation->alcohol_screening_score : 'N/A' }}
    {{ __('consultations.satisfaction_score') }}
    {{ __('consultations.patient') }} {{ isset($mental_health_consultation->patient_satisfaction_score) ? $mental_health_consultation->patient_satisfaction_score : 'N/A' }}
    {{ __('consultations.care_giver') }} {{ isset($mental_health_consultation->caregiver_satisfaction_score) ? $mental_health_consultation->caregiver_satisfaction_score : 'N/A' }}

    {{ __('consultations.alcohol_screening_score') }}

    1-7 = {{ __('consultations.low_risk') }}

    8-19 = {{ __('consultations.harmful_drinking') }}

    20 or above = {{ __('consultations.likely_dependency') }}

    @endif @if (is_tuberculosis_screening_enabled()) @include('patients::consultations.tb_screening') @endif
    @if(check_if_episode_is_a_followup($episode->id) && !is_null($parent_consultation_details) && $parent_consultation_details->primary_diagnosis != $consultation->primary_diagnosis) @endif
    {{ __('consultations.PRIMARY_DIAGNOSIS') }} {{ __('consultations.PROMPT') }} {{ __('consultations.REFERENCES') }}
    {{ Form::select('parent_primary_diagnosis', $diagnoses, $parent_consultation_details->primary_diagnosis, ['class' => 'form-control col-sm-12 compulsory', 'readonly']) }}

    ({{ __('consultations.as_diagnosed_on') }} {{ streamline_date($parent_episode_details->created_at) }})
    {{ isset($parent_consultation_details->primary_diagnosis) ? $diagnoses_all->firstWhere('id',$parent_consultation_details->primary_diagnosis)->prompts : "" }} 
    @if(!is_null($parent_consultation_details->primary_diagnosis)) @php $reference_names = explode(",", get_name($parent_consultation_details->primary_diagnosis, 'id', 'reference_names', 'diagnoses')); $reference_areas = explode(",", get_name($parent_consultation_details->primary_diagnosis, 'id', 'reference_areas', 'diagnoses')); @endphp @for($i = 0; $i < count($reference_areas); $i++) @if(isset($reference_areas[$i]) && isset($reference_names[$i])) {{ $reference_names[$i] }} | @endif @endfor @endif

    {{ isset($diagnoses[$consultation->primary_diagnosis]) ? $diagnoses[$consultation->primary_diagnosis] : "" }}

    {{ is_object($diagnoses_all) && isset($consultation->primary_diagnosis) ? $diagnoses_all->firstWhere('id',$consultation->primary_diagnosis)->prompts : null }} 
    @if(!is_null($consultation->primary_diagnosis)) @php $reference_names = explode(",", get_name($consultation->primary_diagnosis, 'id', 'reference_names', 'diagnoses')); $reference_areas = explode(",", get_name($consultation->primary_diagnosis, 'id', 'reference_areas', 'diagnoses')); @endphp @for($i = 0; $i < count($reference_areas); $i++) @if(isset($reference_areas[$i]) && isset($reference_names[$i])) {{ $reference_names[$i] }} | @endif @endfor @endif
    @if(check_if_episode_is_a_followup($episode->id) && !is_null($parent_consultation_details)) @php $parent_consultation_other_diagnoses = unserialize($parent_consultation_details->other_diagnoses); @endphp @if(!empty($parent_consultation_other_diagnoses) && $parent_consultation_other_diagnoses[0] != "") @foreach($parent_consultation_other_diagnoses as $diagnosis) @if($diagnosis != "") @endif @endforeach @endif @endif @php $other_diagnoses = unserialize($consultation->other_diagnoses); @endphp @if(!empty($other_diagnoses) && $other_diagnoses[0] != "") @foreach($other_diagnoses as $diagnosis) @if($diagnosis != "") @endif @endforeach @else @endif
    {{ __('consultations.OTHER_DIAGNOSIS') }} {{ __('consultations.PROMPT') }} {{ __('consultations.REFERENCES') }}

    {{ $diagnoses[$diagnosis] }}
    (As diagnosed on {{ streamline_date($parent_episode_details->created_at) }})

    {{ is_object($diagnoses_all->firstWhere('id',$diagnosis)) ? $diagnoses_all->firstWhere('id',$diagnosis)->prompts : '' }} 
    @if(!is_null($consultation->primary_diagnosis)) @php $reference_names = explode(",", get_name($parent_consultation_details->primary_diagnosis, 'id', 'reference_names', 'diagnoses')); $reference_areas = explode(",", get_name($parent_consultation_details->primary_diagnosis, 'id', 'reference_areas', 'diagnoses')); @endphp @for($i = 0; $i < count($reference_areas); $i++) @if(isset($reference_areas[$i]) && isset($reference_names[$i])) {{ $reference_names[$i] }} | @endif @endfor @endif

    {{ $diagnoses[$diagnosis] }}

    {{ is_object($diagnoses_all->firstWhere('id',$diagnosis)) ? $diagnoses_all->firstWhere('id',$diagnosis)->prompts : '' }} 
    @if(!is_null($consultation->primary_diagnosis)) @php $reference_names = explode(",", get_name($consultation->primary_diagnosis, 'id', 'reference_names', 'diagnoses')); $reference_areas = explode(",", get_name($consultation->primary_diagnosis, 'id', 'reference_areas', 'diagnoses')); @endphp @for($i = 0; $i < count($reference_areas); $i++) @if(isset($reference_areas[$i]) && isset($reference_names[$i])) {{ $reference_names[$i] }} | @endif @endfor @endif
    No other diagnoses available
    RDT RBS
    @if($consultation->rdt === 1) @elseif($consultation->rdt === 0) @elseif($consultation->rdt === null) @endif {{ $consultation->rbs }}
    @if($consultation_with_notes)

    Previously Added Consultation Notes

    @forelse ($consultation_notes as $consultation_note) @empty @endforelse
    {{ __('consultations.history') }} {{ __('consultations.clinical_examination') }} {{ __('consultations.investigation_and_mgt_plan') }} {{ __('consultations.date') }}
    {{ $consultation_note->history_comments }} {{ $consultation_note->clinic_examination_comments }} {{ $consultation_note->investigation_and_management_plan_comments}} {{ streamline_date_time($consultation_note->created_at) }}
    by {{ $users[$consultation_note->created_by]?? '' }}
    No previously added consultation notes.
    @if(check_if_episode_is_a_followup($episode->id) && !empty($parent_consultation_notes))
    @forelse ($parent_consultation_notes as $consultation_note) @empty @endforelse
    Previously Added Consultation Notes {{ __('consultations.for_episode_of') }} {{ streamline_date($parent_consultation_details->created_at) }}
    {{ __('consultations.history') }} {{ __('consultations.clinical_examination') }} {{ __('consultations.investigation_and_mgt_plan') }} {{ __('consultations.date') }}
    {{ $consultation_note->history_comments }} {{ $consultation_note->clinic_examination_comments }} {{ $consultation_note->investigation_and_management_plan_comments}} {{ streamline_date_time($consultation_note->created_at) }}
    by {{ $users[$consultation_note->created_by]?? '' }}
    No previously added consultation notes {{ __('consultations.for_episode_of') }} {{ streamline_date($parent_consultation_details->created_at) }}.
    @endif {{--
    {{ __('consultations.history') }}
    {!! ($consultation->history_comments) ? nl2br(e($consultation->history_comments)) : "No comments available" !!}
    --}} @endif

    {{ __('consultations.ordered_investigations') }}

    @if($episode_has_grand_parent_episode) @if(count($grand_parent_episode_investigation_results) > 0) @foreach($grand_parent_episode_investigation_results as $result) @php $investigation_ids_array = explode(',', $result->investigation_id); // authentication of investigations $per_investigation_array = explode(',', $result->per_investigation); $comments = explode(",", $result->comment); $results_values = explode(",", $result->value); @endphp @for($i = 0 ; $i < count($investigation_ids_array) ; $i++) @php $investigation = \Streamline\Models\Investigation::withTrashed()->find($investigation_ids_array[$i]); if(!$investigation) { continue; } @endphp @endfor @endforeach @elseif(count($grand_parent_episode_ordered_investigations) > 0) @foreach($grand_parent_episode_ordered_investigations as $investigation) @php $investigation_ids_array = explode(',', $investigation->investigation_id); @endphp @for($i = 0 ; $i < count($investigation_ids_array) ; $i++) @php $investigation = \Streamline\Models\Investigation::withTrashed()->find($investigation_ids_array[$i]); if(!$investigation) { continue; } @endphp @endfor @endforeach @endif @endif @if(count($parent_episode_investigation_results) > 0) @foreach($parent_episode_investigation_results as $result) @php $investigation_ids_array = explode(',', $result->investigation_id); // authentication of investigations $per_investigation_array = explode(',', $result->per_investigation); $comments = explode(",", $result->comment); $results_values = explode(",", $result->value); @endphp @for($i = 0 ; $i < count($investigation_ids_array) ; $i++) @php $investigation = \Streamline\Models\Investigation::withTrashed()->find($investigation_ids_array[$i]); if(!$investigation) { continue; } @endphp @endfor @endforeach @elseif(count($parent_episode_ordered_investigations) > 0) @foreach($parent_episode_ordered_investigations as $investigation) @php $investigation_ids_array = explode(',', $investigation->investigation_id); @endphp @for($i = 0 ; $i < count($investigation_ids_array) ; $i++) @php $investigation = \Streamline\Models\Investigation::withTrashed()->find($investigation_ids_array[$i]); if(!$investigation) { continue; } @endphp @endfor @endforeach @endif @if(count($investigation_results) > 0) @if(check_if_episode_is_a_followup($episode->id)) @endif @foreach($investigation_results as $result) @php $investigation_ids_array = explode(',', $result->investigation_id); // authentication of investigations $per_investigation_array = explode(',', $result->per_investigation); $comments = explode(",", $result->comment); $results_values = explode(",", $result->value); @endphp @for($i = 0 ; $i < count($investigation_ids_array) ; $i++) @php $investigation = \Streamline\Models\Investigation::withTrashed()->find($investigation_ids_array[$i]); if(!$investigation) { continue; } @endphp @if($investigation->type == 1 && isset($results_values[$i])) @php $specialised_results = \Streamline\Models\InvestigationSpecialisedResult::where('id', $results_values[$i])->first(); if($specialised_results) { $variable_id_array = explode(',', $specialised_results->specialised_variable_id); $variable_value_array = explode(',', $specialised_results->value); $variable_comment_array = explode(',', $specialised_results->comment); $variable_normal_range_array = explode(',', $specialised_results->normal_ranges); } @endphp @if($specialised_results) @for($x = 0; $x < count($variable_id_array); $x++) @endfor @endif @elseif($investigation->slug == 'echo' && $results_values[$i] == "") @else @endif @endfor @endforeach @elseif(count($ordered_investigations) > 0) @if(check_if_episode_is_a_followup($episode->id)) @endif @foreach($ordered_investigations as $investigation) @php $investigation_ids_array = explode(',', $investigation->investigation_id); @endphp @for($i = 0 ; $i < count($investigation_ids_array) ; $i++) @if(isset($investigation_ids_array[$i]) && $investigation_ids_array[$i] != "") @php $investigation = \Streamline\Models\Investigation::withTrashed()->find($investigation_ids_array[$i]); if(!$investigation) { continue; } @endphp @if($investigation->slug == 'echo') @else @endif @endif @endfor @endforeach @else @endif
    {{ __('investigations.investigation_name') }} {{ __('investigations.results') }} {{ __('investigations.normal_ranges') }} {{ __('investigations.unit') }} {{ __('investigations.comment') }}
    {{ __('consultations.investigation_for_episode_of') }}f {{ streamline_date($grand_parent_episode_details->created_at) }}
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif {{ $investigation->normal_ranges }} {!! $per_investigation_array[$i] == 0 ? '{{ __("consultations.pending") }}' : $results_values[$i] !!} @if(isset($comments[$i]) && $per_investigation_array[$i] != 0) {{ $comments[$i] }} @else {{ __("consultations.pending") }} @endif
    {{ __('consultations.authenticated_by') }}{{ get_name($result->authenticated_by, 'id', 'first_name', 'users')}} {{ get_name($result->authenticated_by, 'id', 'last_name', 'users')}}
    {{ __('consultations.investigation_for_episode_of') }} {{ streamline_date($grand_parent_episode_details->created_at) }}
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif {{ $investigation->normal_ranges }} {{ __('consultations.pending') }} {{ $investigation->comments }}
    {{ __('consultations.investigation_for_episode_of') }} {{ streamline_date($parent_episode_details->created_at) }}
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif {{ $investigation->normal_ranges }} {!! $per_investigation_array[$i] == 0 ? '{{ __("consultations.pending") }}' : $results_values[$i] !!} @if(isset($comments[$i]) && $per_investigation_array[$i] != 0) {{ $comments[$i] }} @else {{ __("consultations.pending") }} @endif
    {{ __('consultations.authenticated_by') }}y{{ get_name($result->authenticated_by, 'id', 'first_name', 'users')}} {{ get_name($result->authenticated_by, 'id', 'last_name', 'users')}}
    {{ __('consultations.investigation_for_episode_of') }} {{ streamline_date($parent_episode_details->created_at) }}
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif {{ $investigation->normal_ranges }} {{ __('consultations.pending') }} {{ $investigation->comments }}
    {{ __('consultations.investigation_for_review') }} ({{ streamline_date($episode->created_at)}})
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif
    {{ get_name($variable_id_array[$x], 'id', 'name', 'investigation_specialised_variables') }} {{ $variable_value_array[$x] }} @if(get_name($variable_id_array[$x], 'id', 'range_type', 'investigation_specialised_variables') == 1) {{ get_dynamic_normal_range_specialized($variable_id_array[$x], get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients')) }} @else {{ get_name($variable_id_array[$x], 'id', 'normal_ranges', 'investigation_specialised_variables') }} @endif @if(get_name(get_name($variable_id_array[$x], 'id', 'units', 'investigation_specialised_variables'), 'id', 'name', 'unit_of_measure') != "N/A") {{ get_name(get_name($variable_id_array[$x], 'id', 'units', 'investigation_specialised_variables'), 'id', 'name', 'unit_of_measure') }} @endif {{ $variable_comment_array[$x] }}
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif View results
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif @if($per_investigation_array[$i] == 0) {{ __("consultations.pending") }} @else {{ isset($results_values[$i]) ? $results_values[$i] : "" }} @endif @if($investigation->range_type == 1) {{ get_dynamic_normal_range($investigation->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients')) }} @else {{ $investigation->normal_ranges }} @endif {{ get_name(get_name($investigation->id, 'id', 'units', 'investigations'),'id', 'name', 'unit_of_measure') }} @if(isset($comments[$i]) && $per_investigation_array[$i] != 0) {{ $comments[$i] }} @else {{ __("consultations.pending") }} @endif
    {{ __('consultations.authenticated_by') }}{{ get_name($result->authenticated_by, 'id', 'first_name', 'users')}} {{ get_name($result->authenticated_by, 'id', 'last_name', 'users')}}
    {{ __('consultations.investigation_for_review') }} ({{ streamline_date($episode->created_at)}})
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif @if(($cardio_echo)) View results @else Pending @endif
    @if($investigation->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) {{ $investigation->name }} @else {{ $investigation->name }} @endif {{ __('consultations.pending') }} @if($investigation->range_type == 1) {{ get_dynamic_normal_range($investigation->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients')) }} @else {{ $investigation->normal_ranges }} @endif {{ $investigation->comments }}
    {{ __('consultations.investigation_not_ordered') }}

    {{ __('consultations.ordered_sundries') }}

    @if($episode_has_grand_parent_episode) @if(count($grand_parent_episode_ordered_sundries) > 0) @foreach($grand_parent_episode_ordered_sundries as $ordered_sundry) @php $sundry_ids = explode(",", $ordered_sundry->sundries_id); $sundry_quantity = explode(",", $ordered_sundry->quantity); @endphp @for($i = 0; $i < count($sundry_ids); $i++) @endfor @endforeach @endif @endif @if(count($parent_episode_ordered_sundries) > 0) @foreach($parent_episode_ordered_sundries as $ordered_sundry) @php $sundry_ids = explode(",", $ordered_sundry->sundries_id); $sundry_quantity = explode(",", $ordered_sundry->quantity); @endphp @for($i = 0; $i < count($sundry_ids); $i++) @endfor @endforeach @endif @if(count($ordered_sundries) > 0) @if(check_if_episode_is_a_followup($episode->id)) @endif @foreach($ordered_sundries as $ordered_sundry) @php $sundry_ids = explode(",", $ordered_sundry->sundries_id); $sundry_quantity = explode(",", $ordered_sundry->quantity); @endphp @for($i = 0; $i < count($sundry_ids); $i++) @endfor @endforeach @else @endif
    {{ __('consultations.SUNDRY') }} {{ __('consultations.QUANTITY') }}
    {{ __('consultations.sundries_for_episode_of') }} {{ streamline_date($grand_parent_episode_details->created_at) }}
    {{ get_name($sundry_ids[$i], 'id', 'name', 'sundries') }} {!! $sundry_quantity[$i] !!}
    {{ __('consultations.sundries_for_episode_of') }} {{ streamline_date($parent_episode_details->created_at) }}
    {{ get_name($sundry_ids[$i], 'id', 'name', 'sundries') }} {!! $sundry_quantity[$i] !!}
    {{ __('consultations.sundries_for_episode_review') }} ({{ streamline_date($episode->created_at)}})
    {{ get_name($sundry_ids[$i], 'id', 'name', 'sundries') }} {!! $sundry_quantity[$i] !!}
    {{ __('consultations.no_sundries_ordered') }} {{ check_if_episode_is_a_followup($episode->id) ? __('consultations.during_current_review') : '' }}.

    {{ __('consultations.treatment_given') }}

    @if($episode_has_grand_parent_episode) @if(count($grand_parent_episode_treatments) > 0) @foreach($grand_parent_episode_treatments 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'); $drug_unit_id = get_name($drugs_array[$x], 'id', 'unit_id', 'drugs'); $unit = get_name($drug_unit_id, 'id', 'name', 'drug_units'); $unit = $unit=="N/A"?"":$unit; $drug_unit = "" . $unit . ""; $dose2 = (empty($dosage2_array[$x])) ? "" : " | " . $dosage2_array[$x] . $drug_unit; @endphp @if(isset($purchased_elsewhere_array[$x]) && $purchased_elsewhere_array[$x] == 1) @else @if($treatment->dispense_status == 1) @else @endif @endif @endfor @endforeach @endif @endif @if(count($parent_episode_treatments) > 0) @foreach($parent_episode_treatments 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'); $drug_unit_id = get_name($drugs_array[$x], 'id', 'unit_id', 'drugs'); $unit = get_name($drug_unit_id, 'id', 'name', 'drug_units'); $unit = $unit=="N/A"?"":$unit; $drug_unit = "" . $unit . ""; $dose2 = (empty($dosage2_array[$x])) ? "" : " | " . $dosage2_array[$x] . $drug_unit; @endphp @if(isset($purchased_elsewhere_array[$x]) && $purchased_elsewhere_array[$x] == 1) @else @if($treatment->dispense_status == 1) @else @endif @endif @endfor @endforeach @endif @if(count($treatments) > 0) @if(check_if_episode_is_a_followup($episode->id)) @endif @foreach($treatments 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'); $drug_unit_id = get_name($drugs_array[$x], 'id', 'unit_id', 'drugs'); $unit = get_name($drug_unit_id, 'id', 'name', 'drug_units'); $unit = $unit=="N/A"?"":$unit; $drug_unit = "" . $unit . ""; $dose2 = (empty($dosage2_array[$x])) ? "" : " | " . $dosage2_array[$x] . $drug_unit; @endphp @if(isset($purchased_elsewhere_array[$x]) && $purchased_elsewhere_array[$x] == 1) @else @if($treatment->dispense_status == 1) @else @endif @endif @endfor @endforeach @else @endif
    {{ __('consultations.DRUG_NAME') }} {{ __('consultations.DOSAGE') }} {{ __('consultations.DURATION') }} {{ __('consultations.QUANTITY') }} {{ __('consultations.STATUS') }} {{ __('consultations.INSTRUCTION') }}
    {{ __('consultations.treatment_for_episode_of') }} {{ streamline_date($grand_parent_episode_details->created_at) }}
    {{ get_name($drugs_array[$x], 'id', "name", 'drugs') }} {{ $dosage_array[$x] }} {!! $drug_unit !!} {{ $dose2 }}    {{ $frequency_name }} {{ isset($duration_array[$x]) ? $duration_array[$x] : "" }} {{ $quantity_dispensed_array[$x] }}Purchased From Elsewhere{{ __('consultations.dispensed') }}{{ __('consultations.pending') }} {{ isset($instructions_array[$x]) ? trim($instructions_array[$x]) : 'N/A' }}
    {{ __('consultations.treatment_for_episode_of') }} {{ streamline_date($parent_episode_details->created_at) }}
    {{ get_name($drugs_array[$x], 'id', "name", 'drugs') }} {{ $dosage_array[$x] }} {!! $drug_unit !!} {{ $dose2 }}    {{ $frequency_name }} {{ isset($duration_array[$x]) ? $duration_array[$x] : "" }} {{ $quantity_dispensed_array[$x] }}Purchased From Elsewhere{{ __('consultations.dispensed') }}{{ __('consultations.pending') }} {{ isset($instructions_array[$x]) ? trim($instructions_array[$x]) : 'N/A' }}
    {{ __('consultations.treatment_for_episode_review') }} ({{ streamline_date($episode->created_at)}})
    {{ get_name($drugs_array[$x], 'id', "name", 'drugs') }} @if($treatment->is_treatment_progressive != 0) (Progressive Treatment) @endif {{ $dosage_array[$x] }} {!! $drug_unit !!} {{ $dose2 }}    {{ $frequency_name }} {{ isset($duration_array[$x]) ? $duration_array[$x] : "" }} {{ $quantity_dispensed_array[$x] }}Purchased From Elsewhere{{ __('consultations.dispensed') }}{{ __('consultations.pending') }} {{ isset($instructions_array[$x]) ? trim($instructions_array[$x]) : 'N/A' }}
    {{ __('consultations.no_prescription_made_yet') }} {{ check_if_episode_is_a_followup($episode->id) ? __('consultations.during_current_review') : '' }}

    {{ __('consultations.ordered_procedures') }}

    @if($episode_has_grand_parent_episode) @if(count($grand_parent_episode_ordered_procedures) > 0) @php $grand_parent_count = 1; @endphp @foreach($grand_parent_episode_ordered_procedures as $ordered_procedure) @php $procedure_id = explode(",", $ordered_procedure->procedure_id); $procedure_performed_array = explode(",", $ordered_procedure->performed); @endphp @for($i = 0; $i < count($procedure_id); $i++) @php $grand_parent_count++; @endphp @endfor @endforeach @endif @endif @if(count($parent_episode_ordered_procedures) > 0) @php $parent_count = 1; @endphp @foreach($parent_episode_ordered_procedures as $ordered_procedure) @php $procedure_id = explode(",", $ordered_procedure->procedure_id); $procedure_performed_array = explode(",", $ordered_procedure->performed); @endphp @for($i = 0; $i < count($procedure_id); $i++) @php $parent_count++; @endphp @endfor @endforeach @endif @if(count($ordered_procedures) > 0) @php $count = 1; @endphp @if(check_if_episode_is_a_followup($episode->id)) @endif @foreach($ordered_procedures as $ordered_procedure) @php $procedure_id = explode(",", $ordered_procedure->procedure_id); $procedure_performed_array = explode(",", $ordered_procedure->performed); @endphp @for($i = 0; $i < count($procedure_id); $i++) @php $count++; @endphp @endfor @endforeach @else @endif
    # {{ __('consultations.PROCEDURE') }} {{ __('consultations.STATUS') }}
    {{ __('consultations.procedures_for_episode_of') }} {{ streamline_date($grand_parent_episode_details->created_at) }}
    {{ $grand_parent_count }} {{ get_name($procedure_id[$i], 'id', 'name', 'procedures') }} {!! $procedure_performed_array[$i] == 1 ? ''.__("consultations.performed").'' : ''. __("consultations.pending").'' !!}
    {{ __('consultations.procedures_for_episode_of') }} {{ streamline_date($parent_episode_details->created_at) }}
    {{ $parent_count }} {{ get_name($procedure_id[$i], 'id', 'name', 'procedures') }} {!! $procedure_performed_array[$i] == 1 ? ''.__("consultations.performed").'' : ''. __("consultations.pending").'' !!}
    {{ __('consultations.procedures_for_episode_review') }} ({{ streamline_date($episode->created_at)}})
    {{ $count }} {{ get_name($procedure_id[$i], 'id', 'name', 'procedures') }} {!! $procedure_performed_array[$i] == 1 ? ''.__("consultations.performed").'' : ''. __("consultations.pending").'' !!}
    {{ __('consultations.no_procedure_has_been_ordered') }} {{ check_if_episode_is_a_followup($episode->id) ? __('consultations.during_current_review') : '' }}.

    {{ __('consultations.outcome') }}

    @if($consultation->outcome_id == 1) @elseif($consultation->outcome_id == 4) @elseif($consultation->outcome_id == 3) @else @endif
    {{ get_name($consultation->outcome_id, 'id', 'name', 'outcomes') }} {{ get_name($consultation->ward_id, 'id', 'name', 'wards') }} {{ get_name($consultation->outcome_id, 'id', 'name', 'outcomes') }} {{ get_name($consultation->referred_to, 'id', 'name', 'referral_hospitals') }}

    View referral notes
    {{ get_name($consultation->outcome_id, 'id', 'name', 'outcomes') }} {{ $consultation->followup_where }} {{ streamline_date($consultation->followup_when) }}{{ get_name($consultation->outcome_id, 'id', 'name', 'outcomes') }}
    @if(isset($grand_parent_episode_details) && !is_null($grand_parent_episode_details->consultation_id)) @php $grand_parent_consultation = \Streamline\Models\Consultation::where('episode_id',$grand_parent_episode_details->id)->first(); @endphp @if($grand_parent_consultation->comments)
    {{ __('consultations.consultation_comments_on') }} {{ streamline_date($grand_parent_consultation->created_at) }}
    {{ $grand_parent_consultation->comments }}
    @endif @endif @if(isset($parent_episode_details) && !is_null($parent_episode_details->consultation_id)) @php $parent_consultation = \Streamline\Models\Consultation::where('episode_id',$parent_episode_details->id)->first(); @endphp @if($parent_consultation->comments)
    {{ __('consultations.consultation_comments_on') }} {{ streamline_date($parent_consultation->created_at) }}
    {{ $parent_consultation->comments }}
    @endif @endif @if(!$consultation_with_notes)

    Consultation Comments

    @if($consultation->comments) {{ $consultation->comments }} @else N/A @endif @endif

    {{ __('consultations.consultation_started_by') }}

    {!! "".get_name($consultation->created_by, 'id', 'first_name', 'users')."" !!} {!! "".get_name($consultation->created_by, "id", 'last_name', "users")."" !!} on {{ streamline_date_time($consultation->created_at) }}

    @if(!is_null($consultation->updated_by))

    {{ __('consultations.consultation_completed_by') }}

    {!! "".get_name($consultation->updated_by, 'id', 'first_name', 'users')."" !!} {!! "".get_name($consultation->updated_by, "id", 'last_name', "users")."" !!} on {{ streamline_date_time($consultation->updated_at) }} @endif

    @if(Auth::user()->can('edit-patient-consultation')) {{ __('consultations.modify_consultation') }} @endif
    @endsection @push('scripts') @endpush