Files

3555 lines
242 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@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" />
<style type="text/css">
.performance_fee{
padding: 7px 7px;
}
.form-control{
padding: 5px;
}
h5{
text-decoration: underline;
}
.history-container {
word-wrap: break-word;
overflow-wrap: break-word;
padding: 5px;
}
</style>
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('inpatient.inpatient_sheet') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('inpatient.dashboard') }}</a></li>
<li><a href="{{ route('wards.select') }}">{{ __('wards.select_ward') }}</a></li>
<li><a href="{{ route('patients.index') }}">{{ __('inpatient.patients') }}</a></li>
<li class="active">{{ __('inpatient.inpatient_sheet') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-12">
@include('patients::allergies.header')
</div>
</div>
{{-- check for maternity delivery record if patient has one --}}
@include('ward_management::inpatient.patient_delivery_record')
{{-- --}}
<div class="white-box">
<div class="row">
<div class="col-md-12">
@include('flash::message')
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
{{ __('inpatient.inpatient_warning') }}
</span>
</div>
</div>
<div class="col-md-12">
@php
$dob = new Carbon\Carbon(get_name($inpatient_info->patient_id, 'id', 'date_of_birth', 'patients'));
$age_diff_months = $dob->diffInMonths(Carbon\Carbon::now());
$discharge_mortality = \DB::table('discharge_mortality_risk')->where('patient_id', $inpatient_info->patient_id)
->where('episode_id', $inpatient_info->episode_id)
->first();
$eyes = [2 => 'Both eyes', 0 => 'Left eye', 1 => 'Right eye'];
$other_diagnoses = [];
@endphp
@if(is_smart_discharge_enabled() && $age_diff_months < 61 && $discharge_mortality)
<h3><span class="alert alert-danger">Patient's post discharge risk of mortality is being monitored. You can fill in the required fields <a href="/triage/edit_for_post_discharge/{{ $inpatient_info->episode_id }}">here</a></span></h3>
<br><br>
@if(is_null($discharge_mortality->post_discharge_mortality_risk))
{{ Form::hidden('is_under_pdrm_monitoring', 1, ['id' => 'is_under_pdrm_monitoring']) }}
@else
{{ Form::hidden('is_under_pdrm_monitoring', 0, ['id' => 'is_under_pdrm_monitoring']) }}
@endif
@endif
@if(is_null($inpatient_info->bed_category_id))
<h3><span class="label label-danger">{{ __('inpatient.bed_category_warning') }}</span></h3>
@endif
{{ Form::open(['route' => 'in_patient.store']) }}
@php $patient_insurance_status = patient_insurance_status($patient_id); @endphp
{{ Form::hidden('patient_id', $patient_id, ['id' => 'patient_id']) }}
{{ Form::hidden('episode_id', $inpatient_info->episode_id, ['id' => 'episode_id']) }}
{{ Form::hidden('inpatient_id', $inpatient_info->id, ['id' => 'inpatient_id']) }}
{{ Form::hidden('patient_insurance_status', $patient_insurance_status, ['id' => 'patient_insurance_status'])}}
{{ Form::hidden('redirect_to_pdrm_monitoring', 0, ['id' => 'redirect_to_pdrm_monitoring']) }}
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('inpatient.admitted') }}</th>
<th>{{ __('inpatient.discharged') }}</th>
<th>{{ __('inpatient.ward') }}</th>
<th>{{ __('inpatient.specialty') }}</th>
<th>{{ __('inpatient.residence') }}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ streamline_date($inpatient_info->admitted_on) }}</td>
@if($inpatient_info->discharged == 1)
<td style="color:green; font-weight:bold">{{ streamline_date($inpatient_info->discharged_on) }}</td>
@else
<td style="color:red; font-weight: bold">{{ __('inpatient.still_admitted') }}</td>
@endif
<td>{{ get_name($inpatient_info->ward_id, 'id', 'name', 'wards') }}</td>
<td>
{{ Form::select('speciality',$specialities,$inpatient_info->speciality_id,['class' => 'form-control']) }}
</td>
<td>{{ patient_residence($patient->id) }}</td>
</tr>
</tbody>
</table>
</div>
<hr/>
@if (is_tuberculosis_screening_enabled())
@include('patients::consultations.tb_screening')
@endif
<div class="row">
{{ Form::hidden('info_id', $inpatient_info->id) }}
{{ Form::hidden('ward_id', $inpatient_info->ward_id, ['id' => 'ward_id']) }}
<div class="col-md-8">
<h4>{{ __('inpatient.accomodation') }}</h4>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th style="width: 2%">{{ __('inpatient.bed_no') }}</th>
<th>{{ __('inpatient.bed_category') }}</th>
<th>{{ __('inpatient.ward') }}</th>
<th>{{ __('inpatient.from') }}</th>
<th>{{ __('inpatient.to') }}</th>
<th>{{ __('inpatient.duration') }}</th>
<th>{{ __('inpatient.bed_rate') }} <span data-toggle="tooltip" rel="tooltip" data-placement="top" title="{{ __('inpatient.bed_rate_warning') }}"> <i class="fa fa-info-circle"></i></span></th>
<th></th>
</tr>
</thead>
<tbody class="bed_history_field">
<?php
$admission_date = \Carbon\Carbon::createFromFormat('Y-m-d', $inpatient_info->admitted_on);
$ward_bed_stay_records = \Streamline\Models\WardBedStay::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
$bed_category_fields = 0;
$current_date = \Carbon\Carbon::now();
$duration_in_days = $admission_date->diffInDays($current_date);
?>
@if(count($ward_bed_stay_records) > 0)
@foreach($ward_bed_stay_records as $record)
<tr>
{{ Form::hidden('previous_bed_stays[]', $record->id) }}
<td>
{{ Form::text('on_bed_number[]', $record->bed_number, ['class' => 'form-control']) }}
</td>
<td>
{{ Form::select('on_bed_bedcategory[]', $bed_categories, $record->bed_category, ['class' => 'form-control bed_category', 'id' => 'bed_category_'.$bed_category_fields]) }}
</td>
<td>
{{ Form::select('bed_ward[]', $wards, $record->bed_ward, ['class' => 'form-control']) }}
</td>
<td>
<div class="input-group">
{{ Form::text('on_bed_from[]', $record->from, ['class' => 'form-control bed_dates','readonly','id'=>'on_bed_from_'.$bed_category_fields]) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</td>
<td>
@if($record->still_here == 1)
<select name="upto_option" class="form-control upto_option">
<option class="stillHere" selected>{{ __('inpatient.still_here') }}</option>
<option value="selectDate">{{ __('inpatient.select_date') }}</option>
</select>
<div class="input-group upto_date" style="display: none;">
{{ Form::text('on_bed_upto[]',\Carbon\Carbon::now()->toDateString(),['class' => 'form-control bed_dates','readonly','id'=>'on_bed_upto_'.$bed_category_fields]) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
@else
<div class="input-group upto_date">
{{ Form::text('on_bed_upto[]', $record->to, ['class' => 'form-control bed_dates', 'readonly', 'id'=>'on_bed_upto_'.$bed_category_fields]) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
@endif
</td>
<td>
<input type="number" name="bed_duration[]" id="bed_duration_{{ $bed_category_fields }}" value="{{ $record->duration }}" class="form-control">
</td>
<td>
<input type="number" name="bed_rate[]" value="{{ $record->bed_fee_rate }}" id="bed_rate_{{ $bed_category_fields }}" class="form-control">
</td>
<td>
<!-- remove record column -->
<a class='remove_field label label-danger' style='color: white;' title='{{ __('inpatient.remove') }}'><i class='fa fa-trash'></i></a>
</td>
</tr>
@php $bed_category_fields++; @endphp
@endforeach
@else
<tr>
<td>
{{ Form::text('on_bed_number[]', '', ['class' => 'form-control'])}}
</td>
<td>
{{ Form::select('on_bed_bedcategory[]', $bed_categories, $inpatient_info->bed_category_id, ['class' => 'form-control bed_category', 'id' => 'bed_category_0']) }}
</td>
<td>
{{ Form::select('bed_ward[]', $wards, $inpatient_info->ward_id, ['class' => 'form-control']) }}
</td>
<td>
<div class="input-group">
{{ Form::text('on_bed_from[]', $admission_date->toDateString(), ['class' => 'form-control bed_dates','readonly','id'=>'on_bed_from_0']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</td>
<td>
<select name="upto_option" class="form-control upto_option">
<option class="stillHere">{{ __('inpatient.still_here') }}</option>
<option value="selectDate">{{ __('inpatient.select_date') }}</option>
</select>
<div class="input-group upto_date" style="display: none;">
{{ Form::text('on_bed_upto[]', \Carbon\Carbon::now()->toDateString(), ['class' => 'form-control bed_dates','readonly','id'=>'on_bed_upto_0']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</td>
<td>
@php
$current_date = \Carbon\Carbon::now();
$duration_in_days = $admission_date->diffInDays($current_date);
@endphp
<input type="number" name="bed_duration[]" value="{{ $duration_in_days }}" id="bed_duration_0" class="form-control">
</td>
<td>
<input type="number" name="bed_rate[]" value="0" id="bed_rate_0" class="form-control">
</td>
<td></td>
</tr>
@php $bed_category_fields++; @endphp
@endif
</tbody>
</table>
<label class="label label-info" id="add_ward_bed_button">{{ __('inpatient.add_bed') }}</label><br><br>
</div> <hr>
@php
$cons_comments = \Illuminate\Support\Facades\DB::table('consultations')->where('episode_id', $episode_id)->select(['comments', 'history_comments', 'clinic_examination_comments', 'investigation_and_management_plan_comments'])->first();
$consultation_notes = \Streamline\Models\WardInpatientDetailedNote::where(['patient_id' => $patient_id, 'episode_id' => $episode_id, 'ward_id' => 0])->latest()->get(['investigation_and_management_plan_comments', 'clinic_examination_comments', 'history_comments', 'created_by','created_at']);
$right_eye_diagnoses = explode(',',get_name($episode_id, 'episode_id', 'right_eye_diagnosis', 'eye_clinic_main_exam'));
$left_eye_diagnoses = explode(',',get_name($episode_id, 'episode_id', 'left_eye_diagnosis', 'eye_clinic_main_exam'));
$is_eye_module_enabled = is_eye_module_enabled() && is_patient_in_eye_clinic($episode_id);
$diagnosis_categories_options = "<option value=''>-select-</option>";
$all_diagnosis_categories = ['' => '- select -'];
foreach ($diagnosis_categories as $item){
$diagnosis_categories_options .= "<option value='$item->id'>$item->name</option>";
$all_diagnosis_categories[$item->id] = $item->name;
}
@endphp
{{-- @dd($consultation_notes->toArray()) --}}
{{-- @if($cons_comments && ($cons_comments->comments || $cons_comments->history_comments || $cons_comments->clinic_examination_comments || $cons_comments->investigation_and_management_plan_comments))
<h4>{{ __('inpatient.opd_consultation_comments') }}</h4>
<table class="table table-striped color-table success-table table-bordered">
@if($cons_comments->comments)
<tr>
<td><b>{{ __('inpatient.comments') }}</b></td>
<td>{{ $cons_comments->comments }}</td>
</tr>
@endif
@if($cons_comments->history_comments)
<tr>
<td><b>{{ __('inpatient.history') }}</b></td>
<td>{{ $cons_comments->history_comments }}</td>
</tr>
@endif
@if($cons_comments->clinic_examination_comments)
<tr>
<td><b>{{ __('consultations.clinical_examination') }}</b></td>
<td>{{ $cons_comments->clinic_examination_comments }}</td>
</tr>
@endif
@if($cons_comments->investigation_and_management_plan_comments)
<tr>
<td><b>{{ __('consultations.investigation_and_mgt_plan') }}</b></td>
<td>{{ $cons_comments->investigation_and_management_plan_comments }}</td>
</tr>
@endif
</table>
<br>
@endif --}}
{{-- fetch consultation notes --}}
@if ( count($consultation_notes) > 0 )
{{-- History consultation notes --}}
<h4>{{ __('inpatient.opd_consultation_comments') }}</h4>
<table class="table table-condensed color-bordered-table success-bordered-table " style="table-layout: fixed; width:100%">
<tr>
<thead>
<th colspan="2" class="line-height-table" >{{ __('consultations.history') }}</th>
</thead>
</tr>
@forelse ($consultation_notes as $consultation_note)
@if(!empty($consultation_note->history_comments))
<tr>
<td class="line-height-table" style="width:60%; word-wrap:break-word;"> {{ $consultation_note->history_comments ?? '' }} </td>
<td class="line-height-table" style="width:40%; word-wrap:break-word;"> By {{ get_full_name($consultation_note->created_by, 'id', 'first_name', 'last_name', 'users') }} &nbsp; on {{ streamline_date_time($consultation_note->created_at) ?? '' }} </td>
</tr>
@endif
@empty
{{-- <tr><td colspan="4" class="line-height-table"><code>{{ __('consultations.no_previous_notes') }}</code></td></tr> --}}
@endforelse
</table>
{{-- Clinic Examination consultation notes --}}
<table class="table table-condensed color-bordered-table success-bordered-table " style="table-layout: fixed; width:100%">
<tr>
<thead>
<th colspan="2" class="line-height-table">{{ __('consultations.clinical_examination') }}</th>
</thead>
</tr>
@forelse ($consultation_notes as $consultation_note)
@if(!empty($consultation_note->clinic_examination_comments))
<tr>
<td class="line-height-table" style="width:60%; word-wrap:break-word;"> {{ $consultation_note->clinic_examination_comments ?? '' }} </td>
<td class="line-height-table" style="width:40%; word-wrap:break-word;"> By {{ get_full_name($consultation_note->created_by, 'id', 'first_name', 'last_name', 'users') }} &nbsp; on {{ streamline_date_time($consultation_note->created_at) ?? '' }} </td>
</tr>
@endif
@empty
{{-- <tr><td colspan="4" class="line-height-table"><code>{{ __('consultations.no_previous_notes') }}</code></td></tr> --}}
@endforelse
</table>
{{-- Investigation and Management Plan consultation notes --}}
<table class="table table-condensed color-bordered-table success-bordered-table " style="table-layout: fixed; width:100%">
<tr>
<thead>
<th colspan="2" class="line-height-table">{{ __('consultations.investigation_and_mgt_plan') }}</th>
</thead>
</tr>
@forelse ($consultation_notes as $consultation_note)
@if(!empty($consultation_note->investigation_and_management_plan_comments))
<tr>
<td class="line-height-table" style="width:60%; word-wrap:break-word;"> {{ $consultation_note->investigation_and_management_plan_comments ?? '' }} </td>
<td class="line-height-table" style="width:40%; word-wrap:break-word;"> By {{ get_full_name($consultation_note->created_by, 'id', 'first_name', 'last_name', 'users') }} &nbsp; on {{ streamline_date_time($consultation_note->created_at) ?? '' }} </td>
</tr>
@endif
@empty
{{-- <tr class="line-height-table"><td colspan="4"><code>{{ __('consultations.no_previous_notes') }}</code></td></tr> --}}
@endforelse
</table>
@endif
{{-- end fetch consultation notes --}}
@if($anc_comments && ($anc_comments->history_comments || $anc_comments->clinic_examination_comments || $anc_comments->investigation_and_management_plan_comments))
<h4>{{ __('inpatient.anc_consultation_comments') }}</h4>
<table class="table table-striped color-table success-table table-bordered">
@if($anc_comments->history_comments)
<tr>
<td><b>{{ __('inpatient.history') }}</b></td>
<td>{{ $anc_comments->history_comments }}</td>
</tr>
@endif
@if($anc_comments->clinic_examination_comments)
<tr>
<td><b>{{ __('consultations.clinical_examination') }}</b></td>
<td>{{ $anc_comments->clinic_examination_comments }}</td>
</tr>
@endif
@if($anc_comments->investigation_and_management_plan_comments)
<tr>
<td><b>{{ __('consultations.investigation_and_mgt_plan') }}</b></td>
<td>{{ $anc_comments->investigation_and_management_plan_comments }}</td>
</tr>
@endif
</table>
<br>
@endif
</div>
<div class="col-md-4">
<div class="panel-group" id="accordion">
<div class="panel panel-info">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse_patient_documents">{{ __('inpatient.patient_documents') }} ({{ count($documents) }})</a>
</h4>
</div>
<div id="collapse_patient_documents" class="panel-collapse collapse">
<div class="panel-body table-bordered">
<div class="row">
<div class="col-md-8">
@if(count($documents) > 0)
@foreach($documents as $document)
<li>
<a href="/patient_documents/{{ $document->id }}" target="_blank">{{ $document->title }}</a>
</li>
@endforeach
@else
{{ __('inpatient.no_documents_available') }}
@endif
</div>
<div class="col-md-4">
<a href="patient_documents/create" class="label label-warning" style="color: white">{{ __('inpatient.add_new') }}</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-group" id="accordion">
<div class="panel panel-info">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse_triage_symptoms">{{ __('inpatient.symptoms_triage') }} ({{ $triage ? count(explode(",", $triage->symptoms)) : 0 }})</a>
</h4>
</div>
<div id="collapse_triage_symptoms" class="panel-collapse collapse">
<div class="panel-body table-bordered">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th><b>{{ __('inpatient.symptoms') }}</b></th>
<th><b>{{ __('inpatient.duration') }}</b></th>
</tr>
</thead>
<tbody>
@if($triage)
@php
$symptoms_explode = explode(",", $triage->symptoms);
$duration_explode = explode(",", $triage->symptom_duration);
@endphp
@for($i = 0; $i < count($symptoms_explode); $i++)
<tr>
<td>
@if(isset($symptoms[$symptoms_explode[$i]]))
{{ $symptoms[$symptoms_explode[$i]] }}
@else
N/A
@endif
</td>
<td>{{ $duration_explode[$i] ?? '' }}</td>
</tr>
@endfor
@else
<tr>
<td colspan="2">{{ __('inpatient.no_symptoms_triage') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="panel-group" id="accordion">
<div class="panel panel-info">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse_opd_investigations">{{ __('inpatient.opd_invs') }} ({{ (count($opd_investigations) > 0) ? count($opd_investigations['name']) : 0 }})</a>
</h4>
</div>
<div id="collapse_opd_investigations" class="panel-collapse collapse">
<div class="panel-body table-bordered">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th><b>{{ __('inpatient.name') }}</b></th>
<th><b>{{ __('inpatient.value') }}</b></th>
<th><b>{{ __('inpatient.normal_range') }}</b></th>
<th><b>{{ __('inpatient.comment') }}</b></th>
</tr>
</thead>
<tbody>
@if(count($opd_investigations) > 0)
@for($i = 0; $i < count($opd_investigations['name']); $i++)
@if(isset($opd_investigations['name'][$i]))
@if(in_array($i, $opd_investigations_position))
<tr>
<td colspan="4">
<h5><code>{{ $opd_investigations_date[array_search($i, $opd_investigations_position)] }}</code></h5>
</td>
</tr>
@endif
<tr>
<td>{{ $opd_investigations['name'][$i] }}
@if ($is_eye_module_enabled && isset($opd_investigations['eye'][$i]))
<br><span class='label label-info' style='color: white;'>{{ $eyes[$opd_investigations['eye'][$i]] }}</span>
@endif
</td>
<td>
@if($opd_investigations['type'][$i] == 1 && $opd_investigations['value'][$i] != "Pending")
<a class="btn btn-sm btn-link text-blue" onclick="showComplexLabResults({{ $opd_investigations['value'][$i] }}, {{ $inpatient_info->patient_id }})">View Results</a>
@else
{{ $opd_investigations['value'][$i] }} <br>
<small><code>{{ $opd_investigations['result_time'][$i]?? '' }}</code></small>
@endif
</td>
<td>{{ $opd_investigations['normal_ranges'][$i] ?? '' }}</td>
<td>{{ $opd_investigations['comment'][$i] }}</td>
</tr>
@endif
@endfor
@else
<tr>
<td colspan="4">{{ __('inpatient.no_opd_invs') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="panel-group" id="accordion">
<div class="panel panel-info">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse_ward_investigations">{{ __('inpatient.ward_invs') }} ({{ (count($ward_investigations) > 0) ? count($ward_investigations['name']) : 0 }})</a>
</h4>
</div>
<div id="collapse_ward_investigations" class="panel-collapse collapse">
<div class="panel-body table-bordered">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th><b>{{ __('inpatient.name') }}</b></th>
<th><b>{{ __('inpatient.value') }}</b></th>
<th><b>{{ __('inpatient.normal_range') }}</b></th>
<th><b>{{ __('inpatient.comment') }}</b></th>
</tr>
</thead>
<tbody>
@if(count($ward_investigations) > 0)
@for($i = 0; $i < count($ward_investigations['name']); $i++)
@if(in_array($i, $ward_investigations_position))
<tr>
<td colspan="4">
<h5><code>{{ $ward_investigations_date[array_search($i, $ward_investigations_position)] }}</code></h5>
</td>
</tr>
@endif
<tr>
<td>{{ $ward_investigations['name'][$i] }}
<input type="hidden" name="ward_investigation_ids[]" value="{{ $ward_investigations['id'][$i] }}">
@if ($is_eye_module_enabled && isset($ward_investigations['eye'][$i]))
<br><span class='label label-info' style='color: white;'>{{ $eyes[$ward_investigations['eye'][$i]] }}</span>
@endif
</td>
<td>
@if($ward_investigations['type'][$i] == 1 && $ward_investigations['value'][$i] != "Pending")
<a class="btn btn-sm btn-link text-blue" onclick="showComplexLabResults({{ $ward_investigations['value'][$i] }}, {{ $inpatient_info->patient_id }})">View Results</a>
@else
{{ $ward_investigations['value'][$i] }} <br>
<small><code>{{ $ward_investigations['result_time'][$i]?? '' }}</code></small>
@endif
</td>
<td>{{ $ward_investigations['normal_ranges'][$i] ?? '' }}</td>
<td>{{ $ward_investigations['comment'][$i] }}</td>
</tr>
@endfor
@else
<tr>
<td colspan="4">{{ __('inpatient.no_ward_invs') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="panel-group" id="accordion">
<div class="panel panel-info">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse_patient_transfer">{{ __('inpatient.internal_patient_transfer') }}</a>
</h4>
</div>
<div id="collapse_patient_transfer" class="panel-collapse collapse">
<div class="panel-body table-bordered">
{{ __('inpatient.transfer') }} <font color="green">{{ $patient->first_name }} {{ $patient->last_name }}</font> {{ __('inpatient.to_another_ward') }}<br><br>
<div class="form-group row">
<div class="col-sm-4" style="padding-bottom: 0px;">
{{ Form::label('from',__('inpatient.from')) }}
</div>
<div class="col-sm-8">
{{ Form::text('from', $wards[$inpatient_info->ward_id], ['class' => 'form-control', 'readonly']) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4" style="padding-bottom: 0px;">
{{ Form::label('to',__('inpatient.to')) }}
</div>
<div class="col-sm-8">
{{ Form::select('to',$wards,'',['class' => 'form-control', 'id' => 'to_ward']) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4" style="padding-bottom: 0px;">
{{ Form::label('date_of_transfer',__('inpatient.date_of_transfer')) }}
</div>
<div class="col-sm-8 input-group">
{{ Form::text('date_of_transfer','',['class' => 'form-control','id' => 'date_of_transfer','readonly']) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4" style="padding-bottom: 0px;">
{{ Form::label('comments',__('inpatient.comment')) }}
</div>
<div class="col-sm-8">
{{ Form::textarea('transfer_comments','',['class' => 'form-control','rows'=>'4','id'=>'transfer_comments']) }}
</div>
</div>
<a class="btn btn-success pull-right" id="complete_transfer" style="color: white">{{ __('inpatient.complete_ward_transfer') }}</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<a class="btn btn-primary">{{ __('inpatient.historical_investigations') }}</a>
</div>
<div class="col-md-6">
{{ Form::button(__('inpatient.order_investigations'),['type'=>'submit','class'=>'btn btn-primary btn-small pull-right','name'=>'submit-btn','value'=>'order_investigation']) }}
</div>
</div>
</div>
</div>
<br><br>
@if(Auth::user()->can('view-patient-episode-primary-diagnoses') && !($is_eye_module_enabled))
<div class="row">
<div class="table-responsive">
<table class="table table-hover color-table success-table table-bordered">
<thead>
<tr>
<th>{{ __('inpatient.primary_diagnosis') }}</th>
<th>{{ __('inpatient.prompt') }}</th>
<th>{{ __('inpatient.references') }}</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 30%;">
<div class="form-group">
{{ Form::select('primary_diagnosis', $diagnoses, $inpatient_info->primary_diagnosis, ['class' => 'form-control select col-md-12 compulsory', 'required', 'id' => 'primary_diagnosis']) }}
</div>
</td>
<td style="width: 45%; color: #C85F6A;"><div class="well well-sm" id="primary_diagnosis_prompt">{{ (isset($inpatient_info->primary_diagnosis) && $inpatient_info->primary_diagnosis != 0) ? get_name($inpatient_info->primary_diagnosis, "id", "prompts", "diagnoses") : "" }}&nbsp;</div></td>
<td style="width: 25%">
<div class="well well-sm" id="primary_diagnosis_reference">
@if(!is_null($inpatient_info->primary_diagnosis) && $inpatient_info->primary_diagnosis != 0)
@php
$reference_names = explode(",", get_name($inpatient_info->primary_diagnosis, 'id', 'reference_names', 'diagnoses'));
$reference_areas = explode(",", get_name($inpatient_info->primary_diagnosis, 'id', 'reference_areas', 'diagnoses'));
@endphp
@for($i = 0; $i < count($reference_names); $i++)
@if(isset($reference_areas[$i]) && isset($reference_names[$i]))
<a href="{{ $reference_areas[$i] }}" target='_blank'> {{ $reference_names[$i] }} </a> <span style='color: red'> | </span>
@endif
@endfor
@endif
</div>
</td>
</tr>
@if( Auth::user()->can('add-new-diagnosis-from-consultation'))
<tr>
<td>
<a data-toggle="modal" data-target="#diagnosisModal" class="label labelLeft label-info pull-left" style="color: #fff;">{{ __('consultations.add_new_diagnosis') }}</a>
</td>
<td colspan="2"></td>
</tr>
@endif
</tbody>
</table>
</div><br>
</div>
<div class="row">
<div class="table-responsive">
<table class="table color-table success-table table-condensed table-bordered other_diagnosis_table1" id="other_diagnosis_table1">
<thead>
<tr>
<th>{{ __('inpatient.other_diagnosis') }}</th>
<th>{{ __('inpatient.prompt') }}</th>
<th>{{ __('inpatient.references') }}</th>
<th></th>
</tr>
</thead>
@php
$other_diagnoses = $inpatient_info->other_diagnoses ? @unserialize($inpatient_info->other_diagnoses) : [];
$other_diagnoses = is_array($other_diagnoses) ? $other_diagnoses : [];
$option_diagnoses = "";
foreach ($diagnoses as $key => $value){
$option_diagnoses .= "<option value='$key'>" . str_replace('"', "", $value) . "</option>";
}
@endphp
<tbody>
@if(empty($other_diagnoses))
<tr>
<td style='width: 30%;'>
<select name='other_diagnosis[]' class='form-control col-sm-12 sec_d' id='other_diagnosis_id_1' onchange="other_diagnosis_prompt(this.value, 1)">@php echo $option_diagnoses; @endphp</select>
</td>
<td style='width: 45%; color: #C85F6A;'><div class='well well-sm' id='secondary_diagnosis_prompt1'>&nbsp;</div></td>
<td style='width: 25%'><div class='well well-sm' id='secondary_diagnosis_reference1'>&nbsp;</div></td>
<td></td>
</tr>
@else
@foreach($other_diagnoses as $key => $diagnosis)
<tr>
<td style="width: 30%;">
{{ Form::select('other_diagnosis[]', $diagnoses, $diagnosis, ['class' => 'form-control col-sm-12 select sec_d','onchange'=>'other_diagnosis_prompt(this.value, '.$key.')' ]) }}
</td>
<td style="width: 45%; color: #C85F6A;"><div class="well well-sm" id="secondary_diagnosis_prompt{{ $key }}">{{ is_object($diagnoses_all->firstWhere('id',$diagnosis)) ? $diagnoses_all->firstWhere('id',$diagnosis)->prompts : '' }}&nbsp;</div></td>
<td style="width: 25%"><div class="well well-sm" id="secondary_diagnosis_reference{{ $key }}">{{ is_object($diagnoses_all->firstWhere('id',$diagnosis)) ? $diagnoses_all->firstWhere('id',$diagnosis)->reference_names : '' }}&nbsp;</div></td>
<td></td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
<a class="btn btn-success btn-xs m-t-10" onclick="add_diagnoses_row()" style="margin: 10px;">{{ __('consultations.add_row') }}</a>
@endif
<hr/>
<!--Eye clinic diagnosis-->
@if ($is_eye_module_enabled && Auth::user()->can('view-patient-episode-primary-diagnoses'))
<div class="row">
@if( Auth::user()->can('add-new-diagnosis-from-consultation'))
<a data-toggle="modal" data-target="#diagnosisModal" class="btn btn-info pull-left" style="color: #fff;">{{ __('consultations.add_new_diagnosis') }}</a>
@endif
</div>
<div class="row">
<div class="col-md-6">
@if($inpatient_info->right_eye_diagnosis)
<input type="hidden" name="right_eye_diagnosis[]" value="{{ $inpatient_info->right_eye_diagnosis }}">
<div class="table-responsive">
<div class="panel-wrapper collapse in table-responsive table-condensed">
<table class="table color-table success-table table-condensed table-bordered" id="right_eye_other_diagnosis_table">
<thead>
<tr><th colspan="2">{{ __('patient_episode.right_eye_diagnosis') }}</th></tr>
<tr>
<th>SECTION</th>
<th>DIAGNOSIS</th>
</tr>
</thead>
<tbody>
@php
$diagnosis_id_array = explode(",", $inpatient_info->right_eye_diagnosis);
@endphp
@if(count($diagnosis_id_array) > 0)
@foreach($diagnosis_id_array as $id)
<tr>
<td>{{ get_name(get_name($id, 'id', 'diagnosis_category', 'diagnoses'), 'id', 'name', 'diagnosis_categories') }}</td>
<td>{{ get_name($id, 'id', 'name', 'diagnoses') }}</td>
</tr>
@endforeach
@else
<tr>
<td colspan="3">No Diagnosis was registered for this patient...</td>
</tr>
<div id="wrapper"></div>
@endif
<tr id="Right_extra" style="display:none"><td colspan="2"><div class="right_input_fields_wrap"></div></td></tr>
<tr>
<td colspan="2"><button class="label label-success right_add_item" title="Add diagnosis" style="border-radius: 5px;"><i class="fa fa-plus" aria-hidden="true"></i><span style="margin-left: 5px">{{ __('diagnoses.add_diagnosis') }}</span></button></td>
</tr>
</tbody>
</table>
</div>
</div>
@else
<div class="table-responsive"><h4>{{ __('patient_episode.right_eye_diagnosis') }}</h4>
<div class="panel-wrapper collapse in table-responsive table-condensed">
<table class="table color-table success-table table-condensed table-bordered" id="right_eye_other_diagnosis_table">
<thead>
<tr>
<th colspan="3">
<div class="row">
<div class="col-md-4">SECTION</div>
<div class="col-md-8">DIAGNOSIS</div>
</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">
<div class="right_input_fields_wrap">
<div class="row" style="margin: 10px;">
<div class="col-md-4">
<select id="right_diagnosis_category_0" class="form-control select" onchange="get_right_eye_diagnoses(this.value, 0)">
<option value="">-select-</option>
@foreach($diagnosis_categories as $category)
<option value="{{ $category->id }}">{{ $category->name }}</option>
@endforeach
</select>
</div>
<div class="col-md-6">
<select id="right_eye_diagnosis_0" name="right_eye_diagnosis[]" class="form-control select">
<option value="">-select-</option>
</select>
</div>
<div class="col-md-2"><button class="label label-success right_add_item" title="Add diagnosis" style="border-radius: 5px;"><i class="fa fa-plus" aria-hidden="true"></i></button></div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
@endif
</div>
<div class="col-md-6">
@if($inpatient_info->left_eye_diagnosis)
<input type="hidden" name="left_eye_diagnosis[]" value="{{ $inpatient_info->left_eye_diagnosis }}">
<div class="table-responsive">
<div class="panel-wrapper collapse in table-responsive table-condensed">
<table class="table color-table success-table table-condensed table-bordered" id="left_eye_other_diagnosis_table">
<thead>
<tr><th colspan="2">{{ __('patient_episode.left_eye_diagnosis') }}</th></tr></tr>
<tr>
<th>SECTION</th>
<th>DIAGNOSIS</th>
</tr>
</thead>
<tbody>
@php
$diagnosis_id_array = explode(",", $inpatient_info->left_eye_diagnosis);
@endphp
@if(count($diagnosis_id_array) > 0)
@foreach($diagnosis_id_array as $id)
<tr>
<td>{{ get_name(get_name($id, 'id', 'diagnosis_category', 'diagnoses'), 'id', 'name', 'diagnosis_categories') }}</td>
<td>{{ get_name($id, 'id', 'name', 'diagnoses') }}</td>
</tr>
@endforeach
@else
<tr>
<td colspan="3">No Diagnosis was registered for this patient...</td>
</tr>
<div id="wrapper"></div>
@endif
<tr id="left_extra" style="display:none"><td colspan="2"><div class="left_input_fields_wrap"></div></td></tr>
<tr>
<td colspan="2"><button class="label label-success left_add_item" title="Add diagnosis" style="border-radius: 5px;"><i class="fa fa-plus" aria-hidden="true"></i><span style="margin-left: 5px">{{ __('diagnoses.add_diagnosis') }}</span></button></td>
</tr>
</tbody>
</table>
</div>
</div>
@else
<div class="table-responsive">
<h4>{{ __('patient_episode.left_eye_diagnosis') }}</h4>
<div class="panel-wrapper collapse in table-responsive table-condensed">
<table class="table color-table success-table table-condensed table-bordered" id="left_eye_other_diagnosis_table">
<thead>
<tr>
<th colspan="3">
<div class="row">
<div class="col-md-4">SECTION</div>
<div class="col-md-8">DIAGNOSIS</div>
</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">
<div class="left_input_fields_wrap">
<div class="row" style="margin: 10px;">
<div class="col-md-4">
<select id="left_diagnosis_category_0" class="form-control select" onchange="get_left_eye_diagnoses(this.value, 0)">
<option value="">-select-</option>
@foreach($diagnosis_categories as $category)
<option value="{{ $category->id }}">{{ $category->name }}</option>
@endforeach
</select>
</div>
<div class="col-md-6"><select name="left_eye_diagnosis[]" id="left_eye_diagnosis_0" class="form-control select"><option value="">-select-</option></select></div>
<div class="col-md-2"><button class="label label-success left_add_item" title="Add diagnosis" style="border-radius: 5px;"><i class="fa fa-plus" aria-hidden="true"></i></button></div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
@endif
</div>
</div>
<br><br>
<div class="row">
<div class="col-md-6">
<table class="table table-striped table-bordered">
<thead>
<tr>
<td>Main Exam {{ __('patient_episode.right_eye_diagnosis') }}</td>
</tr>
</thead>
<tbody>
<tr>
<td>
@if(count($right_eye_diagnoses) > 0 && $right_eye_diagnoses[0] !== 'N/A')
<ol>
@for($x = 0; $x < count($right_eye_diagnoses); $x++)
@php
$category_id = isset($right_eye_diagnoses[$x]) ? get_name($right_eye_diagnoses[$x], 'id', 'diagnosis_category', 'diagnoses') : 'N/A';
@endphp
<li>{{ ($category_id != 'N/A')? $all_diagnosis_categories[$category_id] : $category_id }} : {{ isset($right_eye_diagnoses[$x]) ? get_name($right_eye_diagnoses[$x], 'id', 'name', 'diagnoses') : 'N/A' }}</li>
@endfor
</ol>
@else
No Diagnosis
@endif
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-6">
<table class="table table-striped table-bordered">
<thead>
<tr>
<td> Main Exam {{ __('patient_episode.left_eye_diagnosis') }} </td>
</tr>
</thead>
<tbody>
<tr>
<td>
@if(count($left_eye_diagnoses) > 0 && $left_eye_diagnoses[0] != 'N/A')
<ol>
@for($x = 0; $x < count($left_eye_diagnoses); $x++)
@php $category_id = isset($left_eye_diagnoses[$x]) ? get_name($left_eye_diagnoses[$x], 'id', 'diagnosis_category', 'diagnoses') : 'N/A'; @endphp
<li>{{ ($category_id != 'N/A')? $all_diagnosis_categories[$category_id] : $category_id }} : {{ isset($left_eye_diagnoses[$x]) ? get_name($left_eye_diagnoses[$x], 'id', 'name', 'diagnoses') : 'N/A' }}</li>
@endfor
</ol>
@else
No Diagnosis
@endif
</td>
</tr>
</tbody>
</table>
</div>
</div>
<hr/>
@endif
<div class="row">
<div class="col-md-6">
@php
$opd_ordered_procedures = \Streamline\Models\OrderedProcedure::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
@endphp
@if (count($opd_ordered_procedures) > 0)
<h4>{{ __('inpatient.opd_ordered_procedures') }}</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th><strong>{{ __('inpatient.procedure') }}</strong></th>
<th><strong>{{ __('inpatient.performed') }}</strong></th>
<th><strong>{{ __('inpatient.performed_by') }}</strong></th>
</tr>
</thead>
<tbody>
@foreach ($opd_ordered_procedures as $opd_procedures)
@php
$procedure_ids_array = explode(",", $opd_procedures->procedure_id);
$procedure_performed_array = explode(",", $opd_procedures->performed);
@endphp
@for($i = 0; $i < count($procedure_ids_array); $i++)
<tr>
<td>{{ get_name($procedure_ids_array[$i], 'id', 'name', 'procedures') }}</td>
<td>
{!! $procedure_performed_array[$i] == 1 ? '<font style="color:Green">'.__("consultations.performed").'</font>' : '<font style="color:Orange">'. __("consultations.pending").'</font>' !!}
</td>
<td>
@php
$performance_details = \Streamline\Models\StaffPerformedService::where(['episode_id' => $episode_id, 'item_category' => 1, 'item_id' => $procedure_ids_array[$i]])->first();
@endphp
{{ ($procedure_performed_array[$i] == 1 && $performance_details)? get_full_name($performance_details->performed_by, "id", "first_name", "last_name", "users") : "N/A" }}
</td>
</tr>
@endfor
@endforeach
</tbody>
</table>
</div>
@endif
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>{{ __('inpatient.note_total_procedure_cost') }}</span>
</div>
<a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" style="padding: 0px;" data-target="#proceduresConsumptionDetails">{{ __('inpatient.view_procedures_details') }}</a>
@php $procedures_counter = 0; $can_edit_procedure_pricing = 0; @endphp
@if( Auth::user()->can('add-procedures-on-inpatient-sheet'))
<div class="row">
<div class="col-md-3">
<h5>{{ __('inpatient.procedures') }}</h5>
</div>
<div class="col-md-2">
<h5>{{ __('inpatient.hospital_fee') }}</h5>
</div>
<div class="col-md-2">
<h5>{{ __('inpatient.performed_by') }}</h5>
</div>
<div class="col-md-2">
<h5>{{ __('inpatient.staff_fee') }}</h5>
</div>
<div class="col-md-1">
<h5>{{ __('inpatient.date') }}</h5>
</div>
</div>
<div class="procedure_input_field">
<div class="row">
@php
// get the quantity given so far of this particular treatment
$ward_procedures_ordered = DB::table('ward_procedures')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
@endphp
@if(count($ward_procedures_ordered) > 0)
@foreach($ward_procedures_ordered as $ward_procedure)
<div class="row">
<div class='col-md-3'>
{{ Form::hidden('procedure_record_id[]', $ward_procedure->id) }}
{{ $procedures[$ward_procedure->procedure_id] ?? '' }}
@if ($is_eye_module_enabled && isset($eyes[$ward_procedure->eye]))
{{ Form::hidden('eye[]', $ward_procedure->eye) }}<span class='label label-info' style='color: white;'>{{ $eyes[$ward_procedure->eye] }}</span>
@endif
</div>
<div class="col-md-2">
{{ Form::number('procedure_hospital_fee_display[]', $ward_procedure->hospital_fee, ['class' => 'form-control performance_fee', 'readonly'])}}
</div>
<div class="col-md-2">
{{ Form::hidden('procedure_done_by_display[]', $ward_procedure->performed_by) }}
{{ Form::text('procedure_done_by_name_display[]', $users_array[$ward_procedure->performed_by] ?? '', ['class' => 'form-control', 'readonly']) }}
</div>
<div class="col-md-2">
{{ Form::number('procedure_performance_fee_display[]', $ward_procedure->staff_fee, ['class' => 'form-control performance_fee', 'readonly']) }}
</div>
<div class="col-md-2">
{{ Form::text('procedure_date_display[]',$ward_procedure->procedure_date,['class' => 'form-control procedure_date','readonly']) }}
</div>
<div class="col-md-1">
<a class='remove_field label label-danger' style='color: white;' title='{{ __('inpatient.remove') }}'><i class='fa fa-trash'></i></a>
</div>
</div><br>
@if(Auth::user()->can('add-ward-procedures-fees'))
@php $can_edit_procedure_pricing = 1; @endphp
@endif
@endforeach
@else
<div class="row">
<div class="col-md-3">
{{ Form::select('procedure_id[]', $procedures, '', ['class' => 'form-control select', 'id' => 'procedure_item_0']) }}
@if ($is_eye_module_enabled)
<br><br><label><b>Eye</b></label>
<select name='eye[]' class='form-control' id="eye_0">
<option disabled selected value> -- Select -- </option>
<option value='0'>Left</option>
<option value='1'>Right</option>
<option value='2'>Both</option>
</select>
@endif
</div>
<div class="col-md-2">
@if(Auth::user()->can('add-ward-procedures-fees'))
@php $can_edit_procedure_pricing = 1; @endphp
{{ Form::number('procedure_hospital_fee[]', '', ['class' => 'form-control performance_fee', 'id' => 'procedure_hospital_fee_0']) }}
@else
{{ Form::number('procedure_hospital_fee[]', '', ['class' => 'form-control performance_fee', 'readonly', 'id' => 'procedure_hospital_fee_0']) }}
@endif
</div>
<div class="col-md-2">
{{ Form::select('procedure_done_by[]', $users_array, '', ['class' => 'form-control select', 'id' => 'first_procedure_done_by_0'])}}
</div>
<div class="col-md-2">
@if( Auth::user()->can('add-ward-procedures-fees'))
{{ Form::number('procedure_performance_fee[]', 0, ['class' => 'form-control performance_fee','id' => 'first_procedure_performance_fee_0']) }}
@else
{{ Form::number('procedure_performance_fee[]', 0, ['class' => 'form-control performance_fee', 'readonly', 'id' => 'first_procedure_performance_fee_0']) }}
@endif
</div>
<div class="col-md-2">
<div class="input-group">
{{ Form::text('procedure_date[]','',['class' => 'form-control procedure_date','readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-md-1">
<a class='remove_field label label-danger' style='color: white;' title="{{ __('inpatient.remove') }}"><i class='fa fa-trash'></i></a>
</div>
</div>
@php $procedures_counter++; @endphp
@endif
</div>
</div>
<br>
<a class="label label-success add_procedure_item" style="color: white;">{{ __('inpatient.add_procedure') }}</a>
@endif
@php $sundries_counter = 0; @endphp
@if( Auth::user()->can('add-sundries-on-inpatient-sheet'))
<hr/>
<h4>{{ __('inpatient.sundries') }} <a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#sundriesConsumptionDetails">{{ __('inpatient.view_sundries_consumption_details') }}</a></h4>
<div class="sundry_input_field">
@php
//get the quantity given so far of this particular sundry
$ward_sundry_quantities_given = DB::table('ward_sundry_dispensations')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->groupBy('sundry_id')->selectRaw('*, sum(quantity_given) as quantity_given')->get();
@endphp
<div class="row">
<div class="col">
<table class="table">
<tbody id="sundries_info">
@forelse ($ward_sundry_quantities_given as $dispensed_sundry_record)
<tr>
<td>
{{ Form::hidden('sundry_id[]', $dispensed_sundry_record->sundry_id) }}
{{ $sundries[$dispensed_sundry_record->sundry_id] ?? '' }}
</td>
<td>
<div class="input-group">
{{ Form::text('sundry_date[]', $dispensed_sundry_record->dispensation_date, ['class' => 'form-control sundry_date','readonly']) }}
</div>
</td>
<td>
{{ Form::number('sundry_quantity_dispensed_so_far[]', $dispensed_sundry_record->quantity_given, ['class' => 'form-control', 'readonly' => 'true']) }}
</td>
<td>
{{ Form::number('sundry_quantity[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.add_more')]) }}
</td>
<td><button onclick="deleteRow(this)" class="btn btn-sm btn-rounded btn-danger" title="Delete this row" style="color: white;" type="button"><i class="fa fa-trash"></i></button></td>
</tr>
@empty
<tr>
<td>
{{ Form::select('sundry_id[]', $sundries, '', ['class' => 'form-control select']) }}
</td>
<td>
<div class="input-group">
{{ Form::text('sundry_date[]','',['class' => 'form-control sundry_date','readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</td>
<td>
<div class="input-group">
{{ Form::number('sundry_quantity[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.quantity')]) }}
</div>
</td>
<td></td>
<td></td>
</tr>
@endforelse
</tbody>
</table>
<br>
<a class="label label-success add_sundry_item" style="color: white;">{{ __('inpatient.add_sundry') }}</a>
</div>
</div>
</div>
@endif
@php $extras_counter = 0; @endphp
@if(Auth::user()->can('add-extras-on-inpatient-sheet') && is_inpatient_sheet_extras_enabled())
<hr/>
<h4>{{ __('inpatient.extras') }} <a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#extrasConsumptionDetails">{{ __('inpatient.view_extras_consumption_details') }}</a></h4>
<div class="extras_input_field">
<div class="row">
<?php
//get the quantity given so far of this particular treatment
$ward_extras_given = DB::table('ward_extras')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->whereNull('deleted_at')->get();
$extras_counter = 0;
?>
@if(count($ward_extras_given) > 0)
@foreach($ward_extras_given as $extras_record)
<div class="row">
<div class="col-md-5">
{{ Form::text('extra_name[]', $extras_record->extra_item, ['class' => 'form-control', 'readonly']) }}
</div>
<div class="col-md-3">
{{ Form::hidden('extra_cost[]', null, ['class'=>'form-control']) }}
{{ Form::number('already_extra_cost[]', $extras_record->extra_cost, ['class' => 'form-control', 'readonly']) }}
</div>
<div class="col-md-2">
<div class="input-group">
{{ Form::text('extra_date[]', $extras_record->dispensation_date, ['class' => 'form-control extra_date','readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-md-1">
<a class='remove_field label label-danger' style='color: white;' title='{{ __('inpatient.remove') }}'><i class='fa fa-trash'></i></a>
</div>
</div>
@endforeach
@endif
<div class="row">
<div class="col-md-5">
{{ Form::text('extra_name[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.add_extra')]) }}
</div>
<div class="col-md-3">
{{ Form::number('extra_cost[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.cost')]) }}
</div>
<div class="col-md-2">
<div class="input-group">
{{ Form::text('extra_date[]','',['class' => 'form-control extra_date','readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<br>
<a class="label label-success add_extras_item" style="color: white;">{{ __('inpatient.add_extras') }}</a>
@endif
@php
$services_counter = 1;
$opd_ordered_services = \Streamline\Models\OrderedService::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
$can_edit_services_pricing = 0;
@endphp
@if( Auth::user()->can('add-consultation-and-services-on-inpatient-sheet'))
@if (count($opd_ordered_services) > 0)
<hr>
<div class="row" style="margin: 2px; border: 2px solid #989393;">
<div class="col-sm-12">
<h4>{{ __('inpatient.opd_ordered_services') }}</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th><strong>{{ __('inpatient.service') }}</strong></th>
<th><strong>{{ __('inpatient.quantity') }}</strong></th>
<th><strong>{{ __('inpatient.performed') }}</strong></th>
</tr>
</thead>
<tbody>
@foreach($opd_ordered_services as $service)
@php
$service_ids = explode(",", $service->service_id);
$service_quantity = explode(",", $service->quantity);
$service_performed = explode(",", $service->performed);
@endphp
@for($i = 0; $i < count($service_ids); $i++)
<tr>
<td>{{ get_name($service_ids[$i], "id", "name", "services")}}</td>
<td>{{ $service_quantity[$i] ?? "N?A" }}</td>
<td>
{!! (isset($service_performed[$i]) && $service_performed[$i] == 1) ? '<font style="color:Green">'.__("consultations.performed").'</font>' : '<font style="color:Orange">'. __("consultations.pending").'</font>' !!}
</td>
</tr>
@endfor
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endif
<hr/>
<h4><a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#consultationAndServicesDetails">{{ __('inpatient.view_consultation_details') }}</a></h4>
<div class="row">
<div class="col-md-2">
<h5>{{ __('inpatient.consultation_and_services') }}</h5>
</div>
<div class="col-md-2">
<h5>{{ __('inpatient.unit_price') }}</h5>
</div>
<div class="col-md-2">
<h5>{{ __('inpatient.staff_fee') }}</h5>
</div>
<div class="col-md-2">
<h5>{{ __('inpatient.date') }}</h5>
</div>
<div class="col-md-2">
<h5>{{ __('inpatient.quantity') }}</h5>
</div>
</div>
<div class="service_input_field">
<div class="row">
<?php
// get the quantity given so far of this particular treatment
$ward_service_quantities_given = DB::table('ward_consultations_and_services')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
?>
@if(count($ward_service_quantities_given) > 0)
@foreach($ward_service_quantities_given as $record)
<div class="row">
<div class="col-md-2">
{{ Form::hidden('ward_consultations_and_services_record_id[]', $record->id) }}
{{ Form::hidden('service_id[]', $record->service_id) }}
{{ $service_items[$record->service_id] ?? "" }}
</div>
<div class="col-md-2">
{{ Form::number('service_unit_price[]', $record->unit_price, ['class' => 'form-control', 'readonly' => 'true']) }}
</div>
<div class="col-md-2">
{{ Form::number('service_staff_fee[]', $record->staff_fee, ['class' => 'form-control', 'readonly' => 'true']) }}
</div>
<div class="col-md-2">
<div class="input-group">
{{ Form::text('service_date[]', $record->dispensation_date, ['class' => 'form-control service_date','readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-md-2">
{{ Form::number('service_quantity_dispensed_so_far[]', $record->quantity_given, ['class' => 'form-control', 'readonly' => 'true']) }}
</div>
<div class="col-md-1">
{{ Form::number('service_quantity[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.add_more')]) }}
</div>
<div class="col-md-1">
<a class='remove_field label label-danger' style='color: white;' title='{{ __('inpatient.remove') }}'><i class='fa fa-trash'></i></a>
</div>
</div>
<br>
@endforeach
@endif
<div class="row">
<div class="col-md-2">
{{ Form::select('service_id[]', $service_items, '', ['class' => 'form-control select', 'id' => 'service_item_0']) }}
</div>
@if( Auth::user()->can('edit-services-prices-on-inpatient-sheet'))
@php
$can_edit_services_pricing = 1;
@endphp
<div class="col-md-2">
{{ Form::number('service_unit_price[]', '', ['class' => 'form-control', 'placeholder' => 'unit price', 'id' => 'service_unit_price_0']) }}
</div>
<div class="col-md-2">
{{ Form::number('service_staff_fee[]', '', ['class' => 'form-control', 'placeholder' => 'staff fee', 'id' => 'service_staff_fee_0']) }}
</div>
@else
<div class="col-md-2">
{{ Form::number('service_unit_price[]', '', ['class' => 'form-control', 'placeholder' => 'unit price', 'id' => 'service_unit_price_0', 'readonly']) }}
</div>
<div class="col-md-2">
{{ Form::number('service_staff_fee[]', '', ['class' => 'form-control', 'placeholder' => 'staff fee', 'id' => 'service_staff_fee_0', 'readonly']) }}
</div>
@endif
<div class="col-md-2">
<div class="input-group">
{{ Form::text('service_date[]','',['class' => 'form-control service_date','readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-md-2">
{{ Form::number('service_quantity[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.quantity')]) }}
</div>
</div>
</div>
</div>
<br>
<a class="label label-success add_service_item" style="color: white;">{{ __('inpatient.add_service') }}</a>
@endif
@include('ward_management::inpatient.patient_vitals')
</div>
<div class="col-md-6">
@php
$ward_treatment_counter = 0;
$opd_treatments = \Streamline\Models\Treatment::where(['patient_id' => $patient_id, 'episode_id' => $episode_id, 'tta' => 0])->get();
@endphp
@if( Auth::user()->can('add-ward-treatments-on-inpatient-sheet'))
@if(count($opd_treatments) > 0)
<div class="row" style="border: 2px solid #989393;">
<div class="col-sm-12">
<h4>{{ __('inpatient.opd_prescription') }}</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th><strong>{{ __('inpatient.name') }}</strong></th>
<th><strong>{{ __('inpatient.dose') }}</strong></th>
<th><strong>{{ __('inpatient.duration') }}</strong></th>
<th><strong>{{ __('inpatient.status') }}</strong></th>
</tr>
</thead>
@foreach ($opd_treatments as $opd_treatment)
@php
$opd_treatment_drugs = explode(",", $opd_treatment->drugs);
$opd_treatment_dose_array = isset($opd_treatment->doses) ? explode(",", $opd_treatment->doses) : [];
$opd_treatment_freq_array = isset($opd_treatment->frequencies) ? explode(",", $opd_treatment->frequencies) : [];
$opd_treatment_duration_array = isset($opd_treatment->durations) ? explode(",", $opd_treatment->durations) : [];
$opd_purchased_elsewhere_array = is_null($opd_treatment->purchased_elsewhere) ? [] : explode(",", $opd_treatment->purchased_elsewhere);
@endphp
@for($x = 0; $x < count($opd_treatment_drugs); $x++)
@php
$drug_name = get_name($opd_treatment_drugs[$x], 'id', "name", 'drugs');
$drug_unit = get_name(get_name($opd_treatment_drugs[$x], 'id', "unit_id", 'drugs'), "id", "name", "drug_units");
$frequency = get_name($opd_treatment_freq_array[$x], "id", "name", "dosage_frequencies");
@endphp
<tr class='gradeX'>
<td>{{ $x+1 }}. {{ $drug_name }}</td>
<td>{{ $opd_treatment_dose_array[$x] }} {{ $drug_unit }} {{ $frequency}} </td>
<td>{{ $opd_treatment_duration_array[$x] }}</td>
@if($opd_treatment->dispense_status == 1)
@if(isset($opd_purchased_elsewhere_array[$x]) && $opd_purchased_elsewhere_array[$x] == 1)
<td style='color: orange'>Purchased From Elsewhere</td>
@else
<td style='color: green;'>{{ __('inpatient.dispensed') }}</td>
@endif
@else
<td style='color: maroon;'>{{ __('inpatient.pending_dispensing') }}</td>
@endif
</tr>
@endfor
<tr>
<td><strong>{{ __('inpatient.prescribed_by') }}:</strong></td>
<td colspan="3"><span style="color: cornflowerblue"> <strong>{{ get_full_name($opd_treatment->created_by, "id", "first_name", "last_name", "users") }} {{ __('inpatient.on') }} {{ streamline_date_time($opd_treatment->created_at) }}</strong></span></td>
</tr>
@endforeach
</table>
</div>
</div>
</div>
@endif
@php
$stopped_ward_drugs_array = [];
@endphp
@if(get_ward_prescription_model() == 1)
<h4>{{ __('inpatient.ward_prescription') }}</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>{{ __('inpatient.name') }}</th>
<th>{{ __('inpatient.dose') }}</th>
<th>{{ __('inpatient.duration') }}</th>
<th>{{ ucfirst(__('inpatient.quantity')) }}</th>
</tr>
</thead>
<tbody>
@if(count($ward_prescriptions) > 0)
@foreach($ward_prescriptions as $ward_prescription)
@php
$ward_prescription_drugs = explode(",", $ward_prescription->drugs);
$ward_prescription_dose_array = isset($ward_prescription->doses) ? explode(",", $ward_prescription->doses) : [];
$ward_prescription_freq_array = isset($ward_prescription->frequencies) ? explode(",", $ward_prescription->frequencies) : [];
$ward_prescription_duration_array = isset($ward_prescription->durations) ? explode(",", $ward_prescription->durations) : [];
$ward_prescription_quantity_array = isset($ward_prescription->quantities_dispensed) ? explode(",", $ward_prescription->quantities_dispensed) : [];
$ward_prescription_eye_array = isset($ward_prescription->eye) ? explode(",", $ward_prescription->eye) : [];
$stopped_drugs_array = is_null($ward_prescription->stopped_drugs) ? [] : explode(",", $ward_prescription->stopped_drugs);
$stopped_ward_drugs_array = array_merge($stopped_ward_drugs_array, $stopped_drugs_array);
@endphp
<tr>
<td colspan="4" class="text-center" style="color: #0000FF; font-weight: small;">{{ __('inpatient.ordered_on') }} {{ streamline_date_time($ward_prescription->created_at) }} {{ __('inpatient.by') }} <strong>{{ get_name($ward_prescription->created_by, "id", "first_name", "users")}} {{ get_name($ward_prescription->created_by, "id", "last_name", "users")}}</strong></td>
</tr>
@for($x = 0; $x < count($ward_prescription_drugs); $x++)
@php
$drug_name = get_name($ward_prescription_drugs[$x], 'id', "name", 'drugs');
$drug_unit = get_name(get_name($ward_prescription_drugs[$x], 'id', "unit_id", 'drugs'), "id", "name", "drug_units");
$frequency = get_name($ward_prescription_freq_array[$x], "id", "name", "dosage_frequencies");
@endphp
<tr class='gradeX'>
<td>{{ $x+1 }}. {{ $drug_name }}
@if ($is_eye_module_enabled && !empty($ward_prescription_eye_array))
<br><span class='label label-info' style='color: white;'>{{ $eyes[$ward_prescription_eye_array[$x]] }}</span>
@endif
@if (in_array($ward_prescription_drugs[$x], $stopped_ward_drugs_array))
<a class="btn btn-rounded btn-info btn-xs" style="font-size: 12px" onclick="resumeWardDrug({{$ward_prescription->id}}, {{$ward_prescription_drugs[$x]}})">Resume Drug</a>
@else
<a class="btn btn-rounded btn-warning btn-xs" style="font-size: 12px" onclick="stopWardDrug({{$ward_prescription->id}}, {{$ward_prescription_drugs[$x]}})">Stop Drug</a>
@endif
</td>
<td>{{ $ward_prescription_dose_array[$x] }} {{ $drug_unit }} {{ $frequency}} </td>
<td>{{ $ward_prescription_duration_array[$x] }}</td>
<td>{{ $ward_prescription_quantity_array[$x] }}</td>
</tr>
@endfor
@if(Auth::user()->can('cancel-ward-prescription'))
<tr>
<td colspan="4"><a class="btn btn-default btn-sm btn-rounded" href="{{ url('cancel_ward_prescription') }}/{{ $ward_prescription->id }}" onclick="return confirm('Are you sure you want to cancel ward prescription?')">Cancel prescription</a></td>
</tr>
@endif
@endforeach
@else
<tr>
<td colspan="4" class="text-center" style="color: maroon">{{ __('inpatient.no_ward_drugs') }}</td>
</tr>
@endif
</tbody>
</table>
{{ Form::button(__('inpatient.order_ward_presc'),['type'=>'submit','class'=>'btn btn-primary btn-small pull-right','name'=>'submit-btn','value'=>'ward_prescription']) }}
</div>
<h4>{{ __('inpatient.ward_treatments') }} <a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#wardDispensationDetails">{{ __('inpatient.view_ward_treatment_details') }}</a> <a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#treatment_sheet_details">Treatment Sheet</a></h4>
<table class="table table-bordered">
<thead>
<tr>
<th>{{ __('inpatient.drug') }}</th>
<th>{{ __('inpatient.quantity_dispensed') }}&nbsp;&nbsp;&nbsp;<span data-toggle="tooltip" rel="tooltip" data-placement="top" title="{{ __('inpatient.quantity_dispensed_tooltip') }}"><i class="fa fa-info-circle"></i></span></th>
<th>{{ __('inpatient.quantity_administered') }}&nbsp;&nbsp;&nbsp;<span data-toggle="tooltip" rel="tooltip" data-placement="top" title="{{ __('inpatient.quantity_given_tooltip') }}"><i class="fa fa-info-circle"></i></span></th>
<th>{{ __('inpatient.ward_stock_dispensed') }}</th>
</tr>
</thead>
<tbody>
@php $avoid_double_display_array = []; @endphp
@if(!empty($ward_prescriptions))
@foreach($ward_prescriptions as $ward_prescription)
@php
$loaded_ward_prescriptions = explode(",", $ward_prescription->drugs);
$loaded_ward_eyes = explode(",", $ward_prescription->eye);
@endphp
@for($j = 0; $j < count($loaded_ward_prescriptions); $j++)
@if(!isset($avoid_double_display_array[$loaded_ward_prescriptions[$j]]))
@php
// get the quantity given so far of this particular treatment
$ward_quantities_given = \Streamline\Models\WardTreatmentDispensation::where(['patient_id' => $patient_id, 'episode_id' => $episode_id, 'drug_id' => $loaded_ward_prescriptions[$j]])->get();
$drug_quantity_dispensed_so_far = 0;
$drug_treatment_sheet_quantity_dispensed_so_far = 0;
foreach($ward_quantities_given as $ward_quantity_given){
$drug_quantity_dispensed_so_far += $ward_quantity_given->quantity_given;
}
foreach($ward_quantities_given as $ward_quantity_given){
$drug_treatment_sheet_quantity_dispensed_so_far += $ward_quantity_given->quantity_given_treatment_sheet;
}
@endphp
<tr>
<td>
{{ Form::hidden('ward_treatment_id[]', 0) }}
{{ Form::hidden('ward_dispensed_drug_id[]', $loaded_ward_prescriptions[$j]) }}
{{ Form::hidden('ward_dispensed_drug_name[]', get_name($loaded_ward_prescriptions[$j],'id','name','drugs')) }}
{{ get_name($loaded_ward_prescriptions[$j],'id','name','drugs') }}
@if ($is_eye_module_enabled && !empty($loaded_ward_eyes))
<br><span class='label label-info' style='color: white;'>{{ $eyes[$loaded_ward_eyes[$j]] }}</span>
@endif
@php $avoid_double_display_array[$loaded_ward_prescriptions[$j]] = $loaded_ward_prescriptions[$j]; @endphp
</td>
<td>
{{ Form::number('ward_quantity_dispensed_so_far[]', $drug_quantity_dispensed_so_far, ['class' => 'form-control', 'readonly' => 'true', 'step' => '.01']) }}
</td>
<td>
{{ Form::number('quantity_given_treatment_sheet[]', $drug_treatment_sheet_quantity_dispensed_so_far, ['class' => 'form-control', 'readonly' => 'true']) }}
</td>
@if (in_array($loaded_ward_prescriptions[$j], $stopped_ward_drugs_array))
<td>
{{ Form::number('ward_quantity_dispensed[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.drug_stopped'),'step' => '.01', 'readonly' => 'true']) }}
</td>
@else
<td>
{{ Form::number('ward_quantity_dispensed[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.add_more'),'step' => '.01']) }}
</td>
@endif
</tr>
@endif
@endfor
@endforeach
@endif
@php $ward_quantities_given_option = \Illuminate\Support\Facades\DB::table('ward_treatment_dispensations')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->groupBy('drug_id')->selectRaw('*, sum(quantity_given) as quantity_given, sum(quantity_given_treatment_sheet) as quantity_given_treatment_sheet')->get(); @endphp
@foreach($ward_quantities_given_option as $record)
@if(!isset($avoid_double_display_array[$record->drug_id]))
<tr>
<td>
{{ Form::hidden('ward_treatment_id[]', 0) }}
{{ Form::hidden('ward_dispensed_drug_id[]', $record->drug_id) }}
{{ Form::hidden('ward_dispensed_drug_name[]', get_name($record->drug_id,'id','name','drugs')) }}
{{ get_name($record->drug_id,'id','name','drugs') }}
</td>
<td>
{{ Form::number('ward_quantity_dispensed_so_far[]', $record->quantity_given, ['class' => 'form-control', 'readonly' => 'true', 'step' => '.01']) }}
</td>
<td>
{{ Form::number('quantity_given_treatment_sheet[]', $record->quantity_given_treatment_sheet, ['class' => 'form-control', 'readonly' => 'true']) }}
</td>
<td>
{{ Form::number('ward_quantity_dispensed[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.add_more'), 'step' => '.01']) }}
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
@endif
@php $ward_treatment_counter = 0; @endphp
@if(get_ward_prescription_model() == 2)
<h4>{{ __('inpatient.ward_treatments') }}</h4>
<div class="ward_treatment_input_field">
<div class="row">
@php
$inpatient_ward_treatment = @unserialize($inpatient_info->ward_treatments);
@endphp
@if(empty($inpatient_ward_treatment))
<div class="col-md-8">
{{ Form::select('drugs[]', $drugs, '', ['class' => 'form-control select']) }}
</div>
<div class="col-md-2">
{{ Form::number('drugs_days[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.days')]) }}
</div>
@else
@php
// for old streamline system records which were using a weird naming convention
$ward_drugs = isset($inpatient_ward_treatment['drugs']) ? $inpatient_ward_treatment['drugs'] : $inpatient_ward_treatment['Drugs'];
$days = isset($inpatient_ward_treatment['days']) ? $inpatient_ward_treatment['days'] : $inpatient_ward_treatment['Days'];
@endphp
@if(is_array($ward_drugs))
@for($i = 0; $i < count($ward_drugs); $i++)
@if($ward_treatment_counter > 0)
<div style='margin-top: 10px;'>
<div class="col-md-8">
{{ Form::select('drugs[]', $drugs, $ward_drugs[$i], ['class' => 'form-control select']) }}
</div>
<div class="col-md-2">
{{ Form::number('drugs_days[]', $days[$i], ['class' => 'form-control']) }}
</div>
<div class='col-md-2'>
<a class='remove_field label label-danger' style='color: white;' title='{{ __('inpatient.remove') }}'><i class='fa fa-trash'></i></a>
</div>
</div>
@else
<div class="col-md-8">
{{ Form::select('drugs[]', $drugs, $ward_drugs[$i], ['class' => 'form-control select']) }}
</div>
<div class="col-md-2">
{{ Form::number('drugs_days[]', $days[$i], ['class' => 'form-control']) }}
</div>
@endif
@php $ward_treatment_counter++; @endphp
@endfor
@else
<div class="col-md-8">
{{ Form::select('drugs[]', $drugs, '', ['class' => 'form-control select']) }}
</div>
<div class="col-md-2">
{{ Form::number('drugs_days[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.days')]) }}
</div>
@endif
@endif
</div>
</div>
<br>
<a class="label label-success add_ward_treatment_item" style="color: white;">{{ __('inpatient.add_treatment') }}</a>
@endif
<hr/>
<h4>Prescribed Protocols</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Protocol Name</th>
<th>Prescription Date</th>
<th>Prescribed By</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($ordered_cancer_protocols) > 0)
@foreach($ordered_cancer_protocols as $ordered_cancer_protocol)
{{ Form::hidden('ordered_cancer_protocol_id[]', $ordered_cancer_protocol->id) }}
<tr>
<td>{{ get_name($ordered_cancer_protocol->protocol_id, 'id', 'name', 'cancer_protocols') }}</td>
<td>{{ streamline_date_time($ordered_cancer_protocol->created_at) }}</td>
<td>{{ get_full_name($ordered_cancer_protocol->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ Form::select('ordered_cancer_protocol_status[]', [0 => 'Ongoing', 1 => 'Stopped', 2 => 'Completed'], $ordered_cancer_protocol->protocol_status, ['class' => 'form-control']) }}</td>
<td>
@if($ordered_cancer_protocol->pre_chemo_status == 0 && $ordered_cancer_protocol->chemo_status == 0 && $ordered_cancer_protocol->post_chemo_status == 0)
<a href="cancer_protocol/cancel_protocol_order/{{ $ordered_cancer_protocol->id }}" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to cancel this protocol')">Cancel Protocol</a>
@endif
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="5" class="text-center" style="color: maroon">No cancer protocols prescribed</td>
</tr>
@endif
</tbody>
</table>
@if(Auth::user()->can('prescribe-cancer-protocol'))
{{ Form::button("Prescribe Protocol",['type'=>'submit','class'=>'btn btn-primary btn-small pull-right','name'=>'submit-btn','value'=>'cancer_protocol']) }}
@endif
</div>
@endif
@if( Auth::user()->can('add-to-take-home-drugs-on-inpatient-sheet'))
<h4>{{ __('inpatient.tta') }}</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>{{ __('inpatient.name') }}</th>
<th>{{ __('inpatient.dose') }}</th>
<th>{{ __('inpatient.duration') }}</th>
<th>{{ __('inpatient.status') }}</th>
</tr>
</thead>
<tbody>
@if(count($treatment_to_take_away) > 0)
@foreach($treatment_to_take_away as $treatment)
@php
$tta_drugs_array = explode(",", $treatment->drugs);
$tta_dose_array = explode(",", $treatment->doses);
$tta_freq_array = explode(",", $treatment->frequencies);
$tta_duration_array = explode(",", $treatment->durations);
$tta_eyes_array = explode(",", $treatment->eye);
$purchased_elsewhere_array = is_null($treatment->purchased_elsewhere) ? [] : explode(",", $treatment->purchased_elsewhere);
@endphp
<tr>
<td colspan="4" class="text-center" style="color: #0000FF; font-weight: small;">{{ __('inpatient.ordered_on') }} {{ streamline_date_time($treatment->created_at) }} {{ __('inpatient.by') }} <b>{{ get_full_name($treatment->created_by, "id", "first_name", "last_name", "users") }}</b></td>
</tr>
@for($x = 0; $x < count($tta_drugs_array); $x++)
@php
$drug_name = get_name($tta_drugs_array[$x], 'id', "name", 'drugs');
$drug_unit = get_name(get_name($tta_drugs_array[$x], 'id', "unit_id", 'drugs'), "id", "name", "drug_units");
$frequency = get_name($tta_freq_array[$x], "id", "name", "dosage_frequencies");
@endphp
<tr class='gradeX'>
<td>{{ $drug_name }}
@if ($is_eye_module_enabled && !empty($tta_eyes_array))
<br><span class='label label-info' style='color: white;'>{{ $eyes[($tta_eyes_array[$x] ?? 0)] }}</span>
@endif
</td>
<input type="hidden" name="tta_drugs[]" value="{{ $tta_drugs_array[$x] }}">
<td>{{ $tta_dose_array[$x] }} {{ $drug_unit }} {{ $frequency}} </td>
<td>{{ $tta_duration_array[$x] }}</td>
@if(isset($purchased_elsewhere_array[$x]) && $purchased_elsewhere_array[$x] == 1)
<td style='color: orange'>Purchased From Elsewhere</td>
@else
@if($treatment->dispense_status == 1)
<td style='color: green;'>{{ __('inpatient.dispensed') }}</td>
@else
<td style='color: maroon;'>{{ __('inpatient.pending_dispensing') }}</td>
@endif
@endif
</tr>
@endfor
@endforeach
@else
<tr>
<td colspan="4" class="text-center" style="color: maroon">{{ __('inpatient.no_tta_ordered') }}</td>
</tr>
@endif
</tbody>
</table>
{{ Form::button(__('inpatient.order_tta'),['type'=>'submit','class'=>'btn btn-primary btn-small pull-right','name'=>'submit-btn','value'=>'order_tta']) }}
</div>
<hr/>
@endif
{{-- Adds Theatre Surgery Notes --}}
@php $theatre_surgeries = DB::table('surgeries')->orderBy('id', 'desc')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->take(20)->get(); @endphp
@if( Auth::user()->can('view-theatre-notes-from-the-inpatient-sheet') && count($theatre_surgeries) > 0)
@if(!is_null($theatre_surgeries->first()->comments))
<h4>{{ __('inpatient.theater_surgery_notes') }}</h4>
<table class="table color-bordered-table muted-bordered-table">
@foreach($theatre_surgeries as $surgery)
<tr>
<td>
{{ $surgery->comments }}
<br>
<sub class="pull-right" style="color: blue">{{ get_full_name($surgery->created_by, "id", "first_name", "last_name", "users") }} {{ __('inpatient.on') }} {{ streamline_date_time_short($surgery->created_at) }} <a class="btn btn-default btn-sm btn-rounded" style="float: right;" href="{{ url('surgery_print') }}/{{ $surgery->id }}" target="_blank">{{ __('inpatient.print_surgery_report') }}</a></sub>
</td>
</tr>
@endforeach
</table>
@endif
@endif
</div>
</div>
{{-- In patient sheet with detailed notes --}}
@if (is_inpatient_sheet_with_detailed_notes_enabled())
<hr>
@if( Auth::user()->can('view-medical-detailed-notes-on-inpatient-sheet'))
@php $inpatient_detailed_notes = DB::table('ward_inpatient_detailed_notes')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get(); @endphp
@if(count($inpatient_detailed_notes) > 0)
<table class="table color-bordered-table muted-bordered-table">
<tr>
<th>
<a class="btn btn-default btn-sm btn-rounded" style="float: right;" href="{{ url('inpatient_detailed_notes_print') }}" target="_blank">{{ __('inpatient.print_inpatient_detailed_notes') }}</a>
</th>
</tr>
@foreach($inpatient_detailed_notes as $comment_record)
<tr>
<td>
<h5 @if(is_null($comment_record->history)) style="display:none;"@endif>{{ __('inpatient.history') }}</h5>
{{ $comment_record->history }}
<h5 @if(is_null($comment_record->result)) style="display:none;"@endif>{{ __('inpatient.results') }}</h5>
{{ $comment_record->result }}
<h5 @if(is_null($comment_record->vitals)) style="display:none;"@endif>{{ __('inpatient.vitals_and_examination') }}</h5>
{{ $comment_record->vitals }}
<h5 @if(is_null($comment_record->impression)) style="display:none;"@endif>{{ __('inpatient.impression') }}</h5>
{{ $comment_record->impression }}
<h5 @if(is_null($comment_record->plan)) style="display:none;"@endif>{{ __('inpatient.plan') }}</h5>
{{ $comment_record->plan }}
&nbsp;
<sub style="color: blue">{{ get_full_name($comment_record->created_by, "id", "first_name", "last_name", "users") }} {{ __('inpatient.on') }} {{ streamline_date_time_short($comment_record->created_at) }}</sub>
{{-- edit_doctors_detailed_notes --}}
@if( Auth::user()->can('edit-inpatient-detailed-notes') && (auth()->user()->id == $comment_record->created_by))
<a href="/edit_inpatient_detailed_notes/{{ $comment_record->id }}" type="button" class="btn btn-info btn-xs btn-rounded" data-toggle="modal" data-target="#edit_doctors_detailed_notes{{ $comment_record->id }}" >Edit</a>
@endif
@if( Auth::user()->can('delete-inpatient-detailed-notes') && (auth()->user()->id == $comment_record->created_by))
<a class="btn btn-danger btn-xs btn-rounded" href="/delete_inpatient_detailed_notes/{{ $comment_record->id }}" onclick="return confirm('confirm to delete notes?')">{{ __('inpatient.delete') }}</a>
@endif
{{-- doctors detailed notes modal --}}
<div class="modal fade" id="edit_doctors_detailed_notes{{ $comment_record->id }}" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><strong> Update Doctor's Notes </strong></h4>
</div>
<form>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
{{-- pick dynamic id for detailed note to update --}}
<input type="hidden" name="inpatient_notes_id" id="inpatient_notes_id_{{ $comment_record->id }}" value="{{ $comment_record->id }}">
<div class="form-group">
<div class="mb-3">
<label for="history_{{ $comment_record->id }}" class="form-label">History</label>
<textarea class="form-control" name="history" id="history_{{ $comment_record->id }}" rows="3">{{ $comment_record->history ?? '' }}</textarea>
</div>
</div>
<div class="form-group">
<div class="mb-3">
<label for="result_{{ $comment_record->id }}" class="form-label">Results</label>
<textarea class="form-control" name="result" id="result_{{ $comment_record->id }}" rows="3">{{ $comment_record->result ?? '' }}</textarea>
</div>
</div>
<div class="form-group">
<div class="mb-3">
<label for="vitals_{{ $comment_record->id }}" class="form-label">Vitals and Examination</label>
<textarea class="form-control" name="vitals" id="vitals_{{ $comment_record->id }}" rows="3">{{ $comment_record->vitals ?? '' }}</textarea>
</div>
</div>
<div class="form-group">
<div class="mb-3">
<label for="impression_{{ $comment_record->id }}" class="form-label">Impression</label>
<textarea class="form-control" name="impression" id="impression_{{ $comment_record->id }}" rows="3">{{ $comment_record->impression ?? '' }}</textarea>
</div>
</div>
<div class="form-group">
<div class="mb-3">
<label for="plan_{{ $comment_record->id }}" class="form-label">Plan</label>
<textarea class="form-control" name="plan" id="plan_{{ $comment_record->id }}" rows="3">{{ $comment_record->plan ?? '' }}</textarea>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="javascript:void(0);" class="btn btn-success" onclick="updateInpatientNotes({{ $comment_record->id }})">{{ __('inpatient.update') }}</a>
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</form>
</div>
</div>
</div>
</td>
</tr>
@endforeach
</table>
<h4><a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#histories">{{ __('inpatient.view_all_notes') }}</a></h4>
@endif
@endif
<div class="row">
@if( Auth::user()->can('add-medical-history-on-inpatient-sheet'))
<div class="col">
<h4>{{ __('inpatient.history') }}</h4>
<textarea name="inpatient_history" placeholder="Please type history here" class="form-control" rows="5"></textarea>
</div>
@endif
@if( Auth::user()->can('add-medical-results-on-inpatient-sheet'))
<div class="col">
<h4>{{ __('inpatient.results') }}</h4>
<textarea name="inpatient_result" placeholder="Please type results here" class="form-control" rows="5"></textarea>
</div>
@endif
@if( Auth::user()->can('add-vitals-and-examination-on-inpatient-sheet'))
<div class="col">
<h4>{{ __('inpatient.vitals_and_examination') }}</h4>
<textarea name="inpatient_vitals_and_examinations" placeholder="Please type vitals and examinations here" class="form-control" rows="5"></textarea>
</div>
@endif
</div>
<div class="row">
@if( Auth::user()->can('add-impression-on-inpatient-sheet'))
<div class="col">
<h4>{{ __('inpatient.impression') }}</h4>
<textarea name="inpatient_impression" placeholder="Please type impression here" class="form-control" rows="5"></textarea>
</div>
@endif
@if( Auth::user()->can('add-plan-on-inpatient-sheet'))
<div class="col">
<h4>{{ __('inpatient.plan') }}</h4>
<textarea name="inpatient_plan" placeholder="Please type plan here" class="form-control" rows="5"></textarea>
</div>
@endif
</div>
@endif
<hr>
<div class="row">
<div class="col">
<h4>{{ __('inpatient.doctor_progress_notes') }}</h4>
@php $sheet_comments = DB::table('ward_inpatient_sheet_comments')->orderBy('id', 'desc')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->take(1)->get(); @endphp
@if(count($sheet_comments) > 0)
<table class="table color-bordered-table muted-bordered-table">
<tr>
<td>
<a class="btn btn-default btn-sm btn-rounded" style="float: right;" href="{{ url('inpatient_notes_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print_notes') }}</a>
</td>
</tr>
@foreach($sheet_comments as $comment_record)
<tr>
<td>
{{ $comment_record->ward_comments }}
<br><br>
<sub class="pull-right" style="color: blue">{{ get_full_name($comment_record->created_by, "id", "first_name", "last_name", "users") }} {{ __('inpatient.on') }} {{ streamline_date_time_short($comment_record->created_at) }}</sub>
</td>
</tr>
@endforeach
</table>
@endif
{{-- Adds Doctor's progress Notes --}}
@if( Auth::user()->can('add-comments-on-inpatient-sheet'))
<h4><a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#comments">{{ __('inpatient.view_all_comments') }}</a></h4>
<textarea name="comments" placeholder="Please type Notes here" class="form-control" rows="5"></textarea>
@endif
</div>
<div class="col">
<h4>{{ __('inpatient.nurse_progress_notes') }}</h4>
@php $sheet_comments = DB::table('ward_inpatient_sheet_nurse_comments')->orderBy('id', 'desc')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->take(1)->get(); @endphp
@if(count($sheet_comments) > 0)
<table class="table color-bordered-table muted-bordered-table">
<tr>
<td>
<a class="btn btn-default btn-sm btn-rounded" style="float: right;" href="{{ url('inpatient_notes_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print_notes') }}</a>
</td>
</tr>
@foreach($sheet_comments as $comment_record)
<tr>
<td>
{{ $comment_record->ward_comments }}
<br><br>
<sub class="pull-right" style="color: blue">{{ get_full_name($comment_record->created_by, "id", "first_name", "last_name", "users") }} on {{ streamline_date_time_short($comment_record->created_at) }}</sub>
</td>
</tr>
@endforeach
</table>
@endif
{{-- Adds Nurse's progress Notes --}}
@if( Auth::user()->can('add-nurse-comments-on-inpatient-sheet'))
<h4><a type="button" class="btn btn-sm btn-link text-blue" data-toggle="modal" data-target="#nurse_comments">{{ __('inpatient.view_all_comments') }}</a></h4>
<textarea name="nurse_comments" placeholder="Please type Notes here" class="form-control" rows="5"></textarea>
@endif
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
@if( Auth::user()->can('view-inpatient-billing'))
{{ Form::button(__('inpatient.inpatient_billing'),['type'=>'submit','class' => 'btn btn-info', 'name'=>'submit-btn','value'=>'billing', 'id' => 'submitInpatientBillButton']) }}
@endif
</div>
<div class="col-md-3">
@if( Auth::user()->can('add-inpatient-sheet-outcome'))
<h4>{{ __('inpatient.outcome') }}</h4>
{{ Form::select('outcome',$outcomes, $inpatient_info->outcome_id??'',['class' => 'form-control','id'=>'outcome']) }}
@endif
<div id="discharged_div" @if($inpatient_info->outcome_id !== 2) style="display: none;" @endif>
<br>
<div class="control-group">
<div class="input-group discharge_date">
<input class="form-control compulsory" size="16" type="text" id="discharge_date" name="discharge_date" readonly placeholder="{{ __('inpatient.when') }}" required value="{{ (!empty($inpatient_info->discharged_on))? Carbon\Carbon::parse($inpatient_info->discharged_on)->format('d/m/Y') : Date('d/m/Y') }}"/>
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div id="died_div" @if(empty($inpatient_info->died_on)) style="display: none;" @endif>
<div class="form-group">
{{ Form::label('died_on',__('inpatient.died_on')) }}
<div class="input-group">
<br>
{{ Form::text('died_on', '',['class' => 'form-control compulsory datepicker-autoclose', 'readonly', 'id'=>'died_on']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div id="follow_up_div" @if($inpatient_info->outcome_id !== 3) style="display: none;" @endif>
<br>
<div class="form-group">
{{ Form::label('followup_clinic_allocation', __('consultations.assigned_clinic')) }}
{{ Form::select('followup_clinic_allocation', $clinics, $patient_appointment->followup_clinic_allocation?? 0, ['class' => 'form-control col-sm-12 compulsory']) }}
</div>
<div class="form-group">
{{ Form::label('followup_in_charge', __('consultations.assign_incharge')) }}
<select name="followup_in_charge" class="form-control col-sm-12 compulsory">
<option value="0" selected>{{ __('consultations.not_assigned') }}</option>
@foreach($users as $user)
<option @if (!empty($patient_appointment->followup_in_charge)&& $user->id == $patient_appointment->followup_in_charge) selected @endif value="{{ $user->id }}">{{ $user->first_name }} {{ $user->last_name }}</option>
@endforeach
</select>
</div>
<div class="form-group">
{{ Form::label('followup_when',__('consultations.when')) }}
<div class="input-group">
{{ Form::text('followup_when', Carbon\Carbon::parse($inpatient_info->followup_when)->format('d/m/Y')?? '',['class' => 'form-control compulsory datepicker-autoclose','readonly', 'id' => 'followup_when']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="form-group">
{{ Form::label('followup_in_time', __('consultations.appointment_time')) }}
{{ Form::time('followup_in_time',$patient_appointment->appointment_time??'',['class' => 'form-control']) }}
</div>
</div>
<div id="referred_div" @if($inpatient_info->outcome_id !== 4) style="display: none;" @endif>
<br>
<div class="form-group">
{{ Form::label('referral_id',__('inpatient.referred_to')) }}
<div class="input-group">
{{ Form::select('referral_id', $referrals, $inpatient_info->referred_to?? '', ['class' => 'form-control compulsory']) }}
</div>
</div>
<div id="referral_notes" class="form-group">
{{ Form::label('referral_notes', __('inpatient.referral_notes')) }}
<textarea name="referral_notes" placeholder="Referral Notes" class="form-control" rows="5">{{ $inpatient_info->referral_notes?? '' }}</textarea>
</div>
</div>
<div id="discharge_and_clinical_summaries" @if($inpatient_info->outcome_id !== 3 && $inpatient_info->outcome_id !== 2) style="display: none;" @endif>
<br>
<div id="discharge_summary">
{{ Form::label('discharge_summary', __('inpatient.discharge_summary')) }}
<textarea name="discharge_summary" placeholder="Discharge Summary" class="form-control" rows="5">{{ $inpatient_info->discharge_summary ??'' }}</textarea>
</div>
<br>
<div id="clinical_summary">
{{ Form::label('clinical_summary', __('inpatient.clinical_summary')) }}
<textarea name="clinical_summary" placeholder="Clinical Summary" class="form-control" rows="5">{{ $inpatient_info->clinical_summary ?? '' }}</textarea>
</div>
</div>
</div>
<div class="col-md-3">
@if( Auth::user()->can('save-inpatient-sheet'))
{{ Form::button(__('inpatient.save_inpatient_sheet'),['type'=>'submit','class' => 'btn btn-success', 'style'=>'float:right;','name'=>'submit-btn','value'=>'save', 'id' => 'submitInpatientButton']) }}
@endif
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
<div class="modal" id="modal_show_lab_results" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title text-center"><b>{{ __('inpatient.investigation_results') }}</b></h4>
</div>
<div class="modal-body">
<div class="table-responsive" id="modal_table"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('inpatient.close') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="wardDispensationDetails" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="wardDispensationModalLabel1">{{ __('inpatient.ward_dispensation_details_of') }} <strong>{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }} ({{ $patient->number }})</strong> <a class="btn btn-info btn-rounded" style="float: right;" href="{{ url('inpatient_treatment_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print') }}</a></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<?php
//get the quantity given so far of this particular treatment
$ward_quantities_given_option = DB::table('ward_treatment_dispensations')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->groupBy('drug_id')->selectRaw('*, sum(quantity_given) as quantity_given')->get();
?>
@if(count($ward_quantities_given_option) > 0)
@foreach($ward_quantities_given_option as $record)
<div class="row" style="background-color: #dde4e6; padding: 5px; word-wrap: break-word;">
<div class="col-sm-8">
{{ get_name($record->drug_id, "id", "name", "drugs") }}
</div>
<div class="col-sm-4">
<strong>{{ __('inpatient.quantity_given') }}</strong>
</div>
<?php
$dispensation_details = \Streamline\Models\WardTreatmentDispensation::where(['patient_id' => $patient_id, 'episode_id' => $episode_id, 'drug_id' => $record->drug_id])->get();
?>
@foreach($dispensation_details as $dispensation)
<div class="col-sm-8">
{{ __('inpatient.date') }}: {{ streamline_date($dispensation->created_at)}}
{{ __('inpatient.by') }}: <font color="blue">{{ get_full_name($dispensation->created_by, "id", "first_name", "last_name", "users")}}</font>
</div>
<div class="col-sm-4">
{{ __('inpatient.quantity') }}:
{{ $dispensation->quantity_given }}
</div>
@endforeach
<div class="col-sm-8" style="border-top:1px solid rgb(173 171 171);"><strong>{{ __('inpatient.total') }}</strong></div>
<div class="col-sm-4" style="border-top:1px solid rgb(173 171 171);"><strong>{{ $record->quantity_given }}</strong></div>
</div>
@endforeach
@endif
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="consultationAndServicesDetails" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="wardDispensationModalLabel1">{{ __('inpatient.consultation_and_services') }} <strong>{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }} ({{ $patient->number }})</strong> <a class="btn btn-info btn-rounded" style="float: right;" href="{{ url('inpatient_consultation_and_services_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print') }}</a></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<?php
$ward_services_quantities_given = DB::table('ward_consultations_and_services')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
?>
@if(count($ward_services_quantities_given) > 0)
@foreach($ward_services_quantities_given as $record)
<div class="row" style="background-color: #dde4e6; padding: 5px; word-wrap: break-word;">
<div class="col-sm-8">
{{ $service_items[$record->service_id] ?? "" }}
</div>
<div class="col-sm-4">
<strong>{{ __('inpatient.quantity_given') }}</strong>
</div>
<div class="col-sm-8">
{{ __('inpatient.date') }}: {{ is_null($record->dispensation_date) ? streamline_date($record->created_at) : streamline_date($record->dispensation_date) }}
{{ __('inpatient.by') }}: <font color="blue">{{ get_full_name($record->created_by, "id", "first_name", "last_name", "users")}}</font>
</div>
<div class="col-sm-4">
{{ __('inpatient.quantity') }}:
{{ $record->quantity_given }}
</div>
<div class="col-sm-8" style="border-top:1px solid rgb(173 171 171);"><strong>{{ __('inpatient.total') }}</strong></div>
<div class="col-sm-4" style="border-top:1px solid rgb(173 171 171);"><strong>{{ $record->quantity_given }}</strong></div>
</div>
@endforeach
@endif
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</div>
</div>
</div>
@include('ward_management::inpatient.treatment_sheet_details')
<div class="modal fade" id="sundriesConsumptionDetails" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="sundriesConsumptionModalLabel1">{{ __('inpatient.sundries_consumption') }} <strong>{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }} ({{ $patient->number }})</strong> <a class="btn btn-info btn-rounded" style="float: right;" href="{{ url('inpatient_sundries_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print') }}</a></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<?php
$ward_sundry_quantities_given = DB::table('ward_sundry_dispensations')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->groupBy('sundry_id')->selectRaw('*, sum(quantity_given) as quantity_given')->get();
?>
@if(count($ward_sundry_quantities_given) > 0)
@foreach($ward_sundry_quantities_given as $record)
<div class="row" style="background-color: #dde4e6; padding: 5px; word-wrap: break-word;">
<div class="col-sm-8">
{{ $sundries[$record->sundry_id] ?? '' }}
</div>
<div class="col-sm-4">
<strong>{{ __('inpatient.quantity_given') }}</strong>
</div>
<?php
$dispensation_details = \Streamline\Models\WardSundryDispensation::where(['patient_id' => $patient_id, 'episode_id' => $episode_id, 'sundry_id' => $record->sundry_id])->get();
?>
@foreach($dispensation_details as $dispensation)
<div class="col-sm-8">
{{ __('inpatient.date') }}: {{ is_null($dispensation->dispensation_date) ? streamline_date($dispensation->created_at) : streamline_date($dispensation->dispensation_date) }}
{{ __('inpatient.by') }}: <font color="blue">{{ get_full_name($dispensation->created_by, "id", "first_name", "last_name", "users")}}</font>
</div>
<div class="col-sm-4">
{{ __('inpatient.quantity') }}:
{{ $dispensation->quantity_given }}
</div>
@endforeach
<div class="col-sm-8" style="border-top:1px solid rgb(173 171 171);"><strong>{{ __('inpatient.total') }}</strong></div>
<div class="col-sm-4" style="border-top:1px solid rgb(173 171 171);"><strong>{{ $record->quantity_given }}</strong></div>
</div>
@endforeach
@endif
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</div>
</div>
</div>
{{-- doctor comments modal --}}
<div class="modal fade" id="comments" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="comments">{{ __('inpatient.doctor_comments') }} <strong>{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }} ({{ $patient->number }})</strong> <a class="btn btn-info btn-rounded" style="float: right;" href="{{ url('inpatient_notes_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print') }}</a></h4>
</div>
<div class="modal-body">
<table class="table table-bordered">
<thead><th style="width: 30%"></th><th style="70%"></th></thead>
<?php
$sheet_comments = DB::table('ward_inpatient_sheet_comments')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
?>
@if(count($sheet_comments) > 0)
@foreach($sheet_comments as $comment_record)
<tr>
<td>
<font color="blue">{{ get_full_name($comment_record->created_by, "id", "first_name", "last_name", "users") }}</font>
{{ __('inpatient.on') }}
<font color="blue">{{ streamline_date_time_short($comment_record->created_at) }}</font>
<hr>
@if( Auth::user()->can('edit-doctor-ward-notes-from-inpatient-sheet') && (auth()->user()->id == $comment_record->created_by))
<a href="/edit_doctor_ward_notes/{{ $comment_record->id }}" type="button" class="btn btn-info btn-xs btn-rounded" data-toggle="modal" data-target="#edit_doctor_ward_notes{{ $comment_record->id }}" >Edit</a>
@endif
@if( Auth::user()->can('delete-doctor-ward-notes-from-inpatient-sheet') && (auth()->user()->id == $comment_record->created_by))
<a class="btn btn-danger btn-xs btn-rounded" href="/delete_doctor_notes/{{ $comment_record->id }}" onclick="return confirm('confirm to delete notes?')">{{ __('inpatient.delete_notes') }}</a>
@endif
</td>
<td>
{{ $comment_record->ward_comments }}
</td>
</tr>
{{-- doctor ward notes modal --}}
<div class="modal fade" id="edit_doctor_ward_notes{{ $comment_record->id }}" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><strong> Update Doctor's Progress Notes </strong></h4>
</div>
{{-- doctor ward notes form fields --}}
<form>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
{{-- pick dynamic id for doctors note to update --}}
<input type="hidden" name="doctor_ward_progress_notes" id="doctor_ward_progress_notes_{{ $comment_record->id }}" value="{{ $comment_record->id }}">
<div class="form-group">
<div class="mb-3">
<textarea class="form-control" name="ward_comments" id="ward_comments_{{ $comment_record->id }}" rows="10">{{ $comment_record->ward_comments ?? '' }}</textarea>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="javascript:void(0);" class="btn btn-success" onclick="updateDoctorProgressNotes({{ $comment_record->id }})">{{ __('inpatient.update') }}</a>
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</form>
</div>
</div>
</div>
{{-- end of doctor ward notes modal --}}
@endforeach
@endif
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="nurse_comments" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="nurse_comments">{{ __('inpatient.nurse_comments') }} <strong>{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }} ({{ $patient->number }})</strong> <a class="btn btn-info btn-rounded" style="float: right;" href="{{ url('inpatient_notes_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print') }}</a></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<thead ><th style="width: 30%"></th><th style="70%"></th></thead>
<?php
$sheet_comments = DB::table('ward_inpatient_sheet_nurse_comments')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
?>
@if(count($sheet_comments) > 0)
@foreach($sheet_comments as $comment_record)
<tr>
<td>
<font color="blue">{{ get_full_name($comment_record->created_by, "id", "first_name", "last_name", "users") }}</font>
{{ __('inpatient.on') }}
<font color="blue">{{ streamline_date_time_short($comment_record->created_at) }}</font>
<hr>
{{-- edit --}}
@if( Auth::user()->can('edit-nurse-ward-notes-from-inpatient-sheet') && (auth()->user()->id == $comment_record->created_by))
<a href="/edit_nurse_ward_inpatient_notes/{{ $comment_record->id }}" type="button" class="btn btn-info btn-xs btn-rounded" data-toggle="modal" data-target="#edit_nurse_ward_inpatient_notes{{ $comment_record->id }}" >Edit</a>
@endif
@if( Auth::user()->can('delete-nurse-ward-notes-from-inpatient-sheet') && (auth()->user()->id == $comment_record->created_by))
<a class="btn btn-danger btn-xs btn-rounded" href="/delete_nurse_notes/{{ $comment_record->id }}" onclick="return confirm('confirm to delete notes?')">{{ __('inpatient.delete_notes') }}</a>
@endif
</td>
<td>
{{ $comment_record->ward_comments }}
</td>
</tr>
{{-- nurse ward inpatient sheet notes --}}
<div class="modal fade" id="edit_nurse_ward_inpatient_notes{{ $comment_record->id }}" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><strong> Update Nurse's Progress Notes </strong></h4>
</div>
{{-- nurse ward notes form fields --}}
<form>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
{{-- pick dynamic id for nurse note to update --}}
<input type="hidden" name="nurse_ward_inpatient_notes" id="nurse_ward_inpatient_notes_{{ $comment_record->id }}" value="{{ $comment_record->id }}">
<div class="form-group">
<div class="mb-3">
<textarea class="form-control" name="ward_comments" id="ward_comments_{{ $comment_record->id }}" rows="10">{{ $comment_record->ward_comments ?? '' }}</textarea>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="javascript:void(0);" class="btn btn-success" onclick="updateNurseWardInpatientNotes({{ $comment_record->id }})">{{ __('inpatient.update') }}</a>
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</form>
</div>
</div>
</div>
{{-- end nurse ward inpatient sheet notes --}}
@endforeach
@endif
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="extrasConsumptionDetails" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="extrasConsumptionModalLabel1">{{ __('inpatient.extras_consumption') }} <strong>{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }} ({{ $patient->number }})</strong> <a class="btn btn-info btn-rounded" style="float: right;" href="{{ url('inpatient_extras_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print') }}</a></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<?php
$ward_extras_given = DB::table('ward_extras')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
?>
@if(count($ward_extras_given) > 0)
@php $total_extras_cost = 0; @endphp
@foreach($ward_extras_given as $extras_record)
<div class="row" style="background-color: #dde4e6; padding: 5px; word-wrap: break-word;">
<div class="col-sm-4">
{{ __('inpatient.date') }}: {{ is_null($extras_record->dispensation_date) ? streamline_date($extras_record->created_at) : streamline_date($extras_record->dispensation_date) }}
{{ __('inpatient.by') }}: <font color="blue">{{ get_full_name($extras_record->created_by, "id", "first_name", "last_name", "users")}}</font>
</div>
<div class="col-sm-4">
{{ __('inpatient.item') }}:
{{ $extras_record->extra_item }}
</div>
<div class="col-sm-4">
{{ __('inpatient.item_cost') }}:
{{ ugandan_shillings($extras_record->extra_cost) }}
@php $total_extras_cost += $extras_record->extra_cost; @endphp
</div>
</div>
@endforeach
<div class="row">
<div class="col-sm-6" style="border-top:1px solid rgb(173 171 171);"><strong>{{ __('inpatient.total') }}</strong></div>
<div class="col-sm-2"></div>
<div class="col-sm-4" style="border-top:1px solid rgb(173 171 171);"><strong>{{ ugandan_shillings($total_extras_cost) }}</strong></div>
</div>
@endif
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="proceduresConsumptionDetails" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="proceduresConsumptionModalLabel1">{{ __('inpatient.procedure_details') }} <strong>{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }} ({{ $patient->number }})</strong> <a class="btn btn-info btn-rounded" style="float: right;" href="{{ url('inpatient_procedures_print') }}/{{ $patient_id }}/{{ $episode_id }}" target="_blank">{{ __('inpatient.print') }}</a></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<?php
$ward_procedures = DB::table('ward_procedures')->whereNull('deleted_at')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
?>
@if(count($ward_procedures) > 0)
@php $total_modal_procedures_cost = 0; @endphp
@foreach($ward_procedures as $ward_procedure_record)
<div class="row" style="background-color: #dde4e6; padding: 5px; word-wrap: break-word;">
<div class="col-sm-3">
Recorded By: <font color="blue">{{ get_full_name($ward_procedure_record->created_by, "id", "first_name", "last_name", "users")}}</font>
{{ __('inpatient.on') }} <b>{{ is_null($ward_procedure_record->procedure_date) ? streamline_date($ward_procedure_record->created_at) : streamline_date($ward_procedure_record->procedure_date) }}</b>
</div>
<div class="col-sm-3">
{{ __('inpatient.name') }}:
{{ get_name($ward_procedure_record->procedure_id, "id", "name", "procedures") }}
@php
$single_procedure_cost = 0;
if($ward_procedure_record->hospital_fee || $ward_procedure_record->staff_fee){
$single_procedure_cost = $ward_procedure_record->hospital_fee + $ward_procedure_record->staff_fee;
}
@endphp
({{ __('inpatient.cost') }}: {{ugandan_shillings($single_procedure_cost) }})
</div>
<div class="col-sm-2">
{{ __('inpatient.hospital_fees') }}:{{ ugandan_shillings($ward_procedure_record->hospital_fee) }}
</div>
<div class="col-sm-2">
{{ __('inpatient.staff_fees') }}:{{ ugandan_shillings($ward_procedure_record->staff_fee) }}
</div>
<div class="col-sm-2">
{{ __('inpatient.performed_by') }}:
{{ get_full_name($ward_procedure_record->performed_by, "id", "first_name", "last_name", "users") }}
</div>
</div>
@php $total_modal_procedures_cost += $single_procedure_cost; @endphp
@endforeach
<div class="row">
<div class="col-sm-3" style="border-top:1px solid rgb(173 171 171);"><strong>{{ __('inpatient.total_cost_of_procedures') }}</strong></div>
<div class="col-sm-3" style="border-top:1px solid rgb(173 171 171);"><strong>{{ ugandan_shillings($total_modal_procedures_cost) }}</strong></div>
<div class="col-sm-6" style="border-top:1px solid rgb(173 171 171);"></div>
</div>
@endif
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('layout.close') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="diagnosisModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel1">{{ __('consultations.add_new_diagnosis') }}</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
{{ Form::label('diagnosis_name', __('diagnoses.diagnosis_name')) }}
{{ Form::text('diagnosis_name', '', ['class' => 'form-control compulsory', 'id'=>'diagnosis_name']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('icd10_code', __('diagnoses.icd_10_code')) }}
{{ Form::text('icd10_code', '', ['class' => 'form-control','id'=>'icd10_code']) }}
</div>
<div class="form-group">
{{ Form::label('hmis_no_outpatient', __('diagnoses.hmis_out_patient_number')) }}
{{ Form::text('hmis_no_outpatient', '', ['class'=>'form-control','id'=>'hmis_no_outpatient']) }}
</div>
<div class="form-group">
{{ Form::label('hmis_no_inpatient', __('diagnoses.hmis_inpatient_category')) }}
{{ Form::text('hmis_no_inpatient', '', ['class'=>'form-control','id'=>'hmis_no_inpatient']) }}
</div>
@php
$hmis_categories = DB::table('hmis_categories')->orderBy('title', 'asc')->pluck('title', 'id')->toArray();
$hmis_categories = ['' => '- select -'] + $hmis_categories;
@endphp
<div class="form-group">
{{ Form::label('hmis_category', __('diagnoses.hmis_category')) }}
{{ Form::select('hmis_category', $hmis_categories, '', ['class' => 'form-control','id'=>'hmis_category']) }}
</div>
</div>
<div class="col-sm-6">
@if ($is_eye_module_enabled && Auth::user()->can('view-patient-episode-primary-diagnoses'))
<div class="form-group">
{{ Form::label('diagnosis_category', __('diagnoses.diagnosis_category')) }}
{{ Form::select('diagnosis_category', $all_diagnosis_categories, '', ['class' => 'form-control compulsory','id'=>'diagnosis_category']) }}
</div>
@endif
<div class="form-group">
{{ Form::label('diagnosis_prompts', __('diagnoses.diagnosis_prompt')) }}
{{ Form::textArea('diagnosis_prompts', '', ['class'=>'form-control','id'=>'diagnosis_prompts', 'rows' => 5]) }}
</div>
<div class="form-group">
{{ Form::label('', __('diagnoses.chronic_status'), ["class"=>'col-md-12']) }}
&nbsp;{{ __('diagnoses.yes') }} {{ Form::radio('chronic_status', 1, false, ['class' => 'check', 'id' => 'chronic_yes']) }}
&nbsp;{{ __('diagnoses.no') }} {{ Form::radio('chronic_status', 0, false, ['class' => 'check', 'id' => 'chronic_no']) }}
<div class="help-block with-errors"></div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('consultations.cancel') }}</button>
<a class="btn btn-success" onclick="submitDiagnosis()">{{ __('consultations.add_diagnosis') }}</a>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script>
$('#select_vitals, .sec_d').select2({
placeholder: "Select",
width: "100%"
});
function submitDiagnosis(){
var diagnosis_name = $("#diagnosis_name").val();
var icd10_code = $("#icd10_code").val();
var hmis_no_outpatient = $("#hmis_no_outpatient").val();
var hmis_no_inpatient = $("#hmis_no_inpatient").val();
var hmis_category = $("#hmis_category").val();
var diagnosis_prompts = $("#diagnosis_prompts").val();
var chronic_yes = $("#chronic_yes").val();
var chronic_no = $("#chronic_no").val();
var diagnosis_category = $('#diagnosis_category').val();
var chronic_status = null;
var is_eye_module_enabled = {{ $is_eye_module_enabled ? 1 : 0 }};
if($('#chronic_yes').is(':checked')){
chronic_status = 1;
} else if($('#chronic_no').is(':checked')){
chronic_status = 0;
}
if ($("#diagnosis_name").val() === "" || !$("#diagnosis_name").val()) {
alert("Please make sure that you fill in a diagnosis name");
return false;
}
if(is_eye_module_enabled && ($("#diagnosis_category").val() === "" || !$("#diagnosis_category").val())){
alert("Please make sure that you select a diagnosis category");
return false;
}
var data = {'diagnosis_name':diagnosis_name, 'icd10_code': icd10_code, 'diagnosis_category':diagnosis_category, 'hmis_no_outpatient': hmis_no_outpatient, 'hmis_no_inpatient': hmis_no_inpatient, 'hmis_category': hmis_category, 'diagnosis_prompts': diagnosis_prompts, chronic_status: 'chronic_status'};
$.ajax({
method: 'POST',
url: '/consultation/add_diagnosis',
data: data,
success: function(response){
if(!isNaN(response)){
//response = last inserted id
$('#primary_diagnosis').append($('<option>', {
value: response,
text: diagnosis_name
})).val(response);//preselect the newly added referral
$('#diagnosisModal').modal('hide'); //manually hide the modal
} else {
alert("error occurred");
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
}
function showComplexLabResults(id, patient_id) {
$.ajax({
method: 'POST',
url: '/investigations/display_specialised_variables_pop_up',
data: {'id': id, 'patient_id': patient_id},
success: function(response){
let responseArray = JSON.parse(response);
$("#modal_table").html(responseArray["html"]);
$('#modal_show_lab_results').modal('show');
}
});
}
$('#primary_diagnosis').on('change', function () {
var data = 'diagnosis_id=' + $(this).val();
$.ajax({
type: "get",
url: "/diagnoses/get_diagnosis",
data: data,
cache: false,
success: function (result) {
var prompt_and_references = result.split('&&');
$('#primary_diagnosis_prompt').html(prompt_and_references[0]);
$('#primary_diagnosis_reference').html(prompt_and_references[1]);
}
});
});
let min_days = {{ $duration_in_days }};
var min_date = new Date();
min_date.setDate(min_date.getDate()-min_days);
$('#date_of_transfer,#follow_up_date,#followup_when').datepicker({
autoclose: true,
todayHighlight: true,
startDate: min_date,
format: 'dd/mm/yyyy',
});
$('#died_on').datepicker({
autoclose: true,
startDate: min_date,
endDate: new Date(),
todayHighlight: true,
format: 'yyyy-mm-dd',
});
$('#discharge_date').datepicker({
autoclose: true,
todayHighlight: true,
endDate: new Date(),
startDate: min_date,
format: 'dd/mm/yyyy',
});
//internal transfer request
$('#complete_transfer').click(function () {
let patient_id = <?php echo $patient->id ?>;
let from_ward = <?php echo $inpatient_info->ward_id ?>;
let to_ward = $('#to_ward').val();
let date_of_transfer = $('#date_of_transfer').val();
let transfer_comments = $('#transfer_comments').val();
let info_id = <?php echo $inpatient_info->id ?>;
if (to_ward == "") {
alert("<?php echo __('inpatient.select_new_ward');?>");
return false;
}
if (date_of_transfer == "") {
alert("<?php echo __('inpatient.select_transfer_date');?>");
return false;
}
//submit the details
$.ajax({
type: "POST",
url: "internal_ward_transfers",
data: {
patient_id: patient_id,
from_ward: from_ward,
to_ward: to_ward,
transfer_date: date_of_transfer,
transfer_comments: transfer_comments,
info_id: info_id
},
success: function (response) {
alert('<?php echo __('inpatient.ward_transfer_complete');?>');
$("#complete_transfer").hide();
location.reload();
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
});
// for procedures
let procedures_max_fields = 500;
let eye_module = {{ $is_eye_module_enabled ? 1 : 0 }};
let procedure_current_fields = <?php echo $procedures_counter; ?>
// for helping make an element pick select2 and make it auto searchable
function select2set(id) {
$('#'+id).select2();
}
$('.add_procedure_item').click(function () {
let can_edit_procedure_pricing = <?php echo $can_edit_procedure_pricing; ?>;
let readonly = '';
if (can_edit_procedure_pricing != 1) {
readonly = 'readonly';
}
if (procedure_current_fields < procedures_max_fields) {
if(eye_module == 1) $(".procedure_input_field").append("<div class='row' style='margin-top: 10px;'><div class='col-md-3'><select name='procedure_id[]' class='form-control select procedure_item' id='procedure_item_"+procedure_current_fields+"'><option value=''>-- select --</option><?php echo $options_procedures ?></select><br><br><label><b>Eye</b></label><select name='eye[]' class='form-control compulsory' required><option disabled selected value> -- Select -- </option><option value='0'>Left</option><option value='1'>Right</option><option value='2'>Both</option></select></div><div class='col-md-2'><input class='form-control performance_fee' id='procedure_hospital_fee_"+procedure_current_fields+"' name='procedure_hospital_fee[]' "+readonly+" type='number'></div><div class='col-md-2'><select name='procedure_done_by[]' class='form-control select' required id='procedure_done_by_"+procedure_current_fields+"'><option value=''>-- select --</option><?php echo $options_users ?></select></div><div class='col-md-2'><input class='form-control performance_fee' "+readonly+" name='procedure_performance_fee[]' value='0' type='number'></div><div class='col-md-2'><div class='input-group'><input class='form-control procedure_date' readonly='' name='procedure_date[]' type='text'><span class='input-group-addon'><i class='icon-calender'></i></span></div></div><div class='col-md-1'><a class='remove_field label label-danger' style='color: white;' title='Remove'><i class='fa fa-trash'></i></a></div></div>");
else $(".procedure_input_field").append("<div class='row' style='margin-top: 10px;'><div class='col-md-3'><select name='procedure_id[]' class='form-control select procedure_item' id='procedure_item_"+procedure_current_fields+"'><option value=''>-- select --</option><?php echo $options_procedures ?></select></div><div class='col-md-2'><input class='form-control performance_fee' id='procedure_hospital_fee_"+procedure_current_fields+"' name='procedure_hospital_fee[]' "+readonly+" type='number'></div><div class='col-md-2'><select name='procedure_done_by[]' class='form-control select' required id='procedure_done_by_"+procedure_current_fields+"'><option value=''>-- select --</option><?php echo $options_users ?></select></div><div class='col-md-2'><input class='form-control performance_fee' "+readonly+" name='procedure_performance_fee[]' value='0' type='number'></div><div class='col-md-2'><div class='input-group'><input class='form-control procedure_date' readonly='' name='procedure_date[]' type='text'><span class='input-group-addon'><i class='icon-calender'></i></span></div></div><div class='col-md-1'><a class='remove_field label label-danger' style='color: white;' title='Remove'><i class='fa fa-trash'></i></a></div></div>");
select2set('procedure_item_'+procedure_current_fields);
select2set('procedure_done_by_'+procedure_current_fields);
procedure_current_fields++;
} else {
alert("<?php echo __('inpatient.procedures_warning');?>");
}
});
// Removing added procedures
$(".procedure_input_field").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').remove();
procedure_current_fields--;
});
// Removing added sundries
$(".sundry_input_field").on("click", ".remove_field_sundries", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').remove();
});
//get procedure fees
$(".procedure_input_field").on("change", "[id^='procedure_item_']", function (e) {
//get the id by filtering to get only the digit from "id" attribute
let id = /\d+(?=\D*$)/.exec($(this).attr('id'));
let procedure_id = $("#procedure_item_" + id).val();
let patient_id = $('#patient_id').val();
let patient_insurance_status = $('#patient_insurance_status').val();
let ward_id = $('#ward_id').val();
$.ajax({
url: '/get_procedure_details',
data: {'procedure_id':procedure_id, 'patient_id':patient_id, 'ward_id':ward_id, 'patient_insurance_status': patient_insurance_status, 'is_inpatient': 1},
success: function(response){
let arr = JSON.parse(response);
$("#procedure_hospital_fee_"+id).val(arr["selling_price"]);
}
});
});
// for sundries
let sundry_max_fields = 500;
let sundry_current_fields = <?php echo $sundries_counter; ?>;
$('.add_sundry_item').click(function () {
let sundries_row_count = document.getElementById('sundries_info').rows.length;
if (sundry_current_fields < sundry_max_fields) {
// $(".sundry_input_field").append("<div class='row' style='margin-top: 10px;'><div class='col-md-6'><select name='sundry_id[]' class='form-control' id='sundry_"+sundry_current_fields+"'><option value=''>-- Select --</option><?php echo $options_sundries ?></select></div><div class='col-md-2'><div class='input-group'><input class='form-control sundry_date' readonly='' name='sundry_date[]' type='text'><span class='input-group-addon'><i class='icon-calender'></i></span></div></div><div class='col-md-2'><input type='number' name='sundry_quantity[]' placeholder='quantity' class='form-control'/></div><div class='col-md-2'><a class='remove_field label label-danger' style='color: white;'>Remove</a></div></div>");
$('#sundries_info').append(`
<tr>
<td>
{{ Form::select('sundry_id[]', $sundries, '', ['id'=>'sundry_${sundries_row_count}', 'class' =>'form-control select']) }}
</td>
<td>
<div class="input-group">
{{ Form::text('sundry_date[]','',['class' => 'form-control sundry_date','readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</td>
<td>
<div class="input-group">
{{ Form::number('sundry_quantity[]', '', ['class' => 'form-control', 'placeholder' => __('inpatient.quantity')]) }}
</div>
</td>
<td></td>
<td><button onclick="deleteRow(this)" class="btn btn-sm btn-rounded btn-danger" title="Delete this row" style="color: white;" type="button"><i class="fa fa-trash"></i></button></td>
</tr>
`);
select2set('sundry_'+sundries_row_count);
sundry_current_fields++;
} else {
alert("<?php echo __('inpatient.sundries_warning');?>");
}
});
// Removing added sundries
$(".sundry_input_field").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').remove();
sundry_current_fields--;
});
// for extras
let extras_max_fields = 500;
let extras_current_fields = <?php echo $extras_counter; ?>;
$('.add_extras_item').click(function () {
if (extras_current_fields < extras_max_fields) {
$(".extras_input_field").append("<div class='row' style='margin-top: 10px;'><div class='col-md-5'><input type='text' name='extra_name[]' class='form-control'/></div><div class='col-md-2'><input type='number' name='extra_cost[]' class='form-control'/></div><div class='col-md-2'><div class='input-group'><input class='form-control extra_date' readonly='' name='extra_date[]' type='text'><span class='input-group-addon'><i class='icon-calender'></i></span></div></div><div class='col-md-2'><a class='remove_field label label-danger' style='color: white;'>Remove</a></div></div>");
extras_current_fields++;
} else {
alert("<?php echo __('inpatient.extras_warning');?>");
}
});
// Removing added extras
$(".extras_input_field").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').remove();
extras_current_fields--;
});
// for ward treatment
let ward_treatment_max_fields = 500;
let ward_treatment_current_fields = <?php echo $ward_treatment_counter; ?>;
$('.add_ward_treatment_item').click(function () {
if (ward_treatment_current_fields < ward_treatment_max_fields) {
$(".ward_treatment_input_field").append("<div class='row' style='margin-top: 10px;'><div class='col-md-8'><select name='drugs[]' class='form-control' id='treatment_"+ward_treatment_current_fields+"'><option value=''>-- Select --</option><?php echo $options_drugs ?></select></div><div class='col-md-2'><input type='number' name='drugs_days[]' class='form-control'/></div><div class='col-md-2'><a class='remove_field label label-danger' style='color: white;'>Remove</a></div></div>");
select2set('treatment_'+ward_treatment_current_fields);
ward_treatment_current_fields++;
} else {
alert("<?php echo __('inpatient.drugs_warning');?>");
}
});
// Removing added ward treatments
$(".ward_treatment_input_field").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').remove();
ward_treatment_current_fields--;
});
$("#outcome").change(function () {
let outcome = $("#outcome").val();
if (outcome == 3) {
// Home with follow up
$("#follow_up_div").show();
$("#discharged_div").hide();
$("#referred_div").hide();
$('#died_div').hide();
$("#discharge_and_clinical_summaries").show();
} else if (outcome == 2) {
// Discharged
$("#discharged_div").show();
$('#died_div').hide();
$("#follow_up_div").hide();
$("#referred_div").hide();
$("#discharge_and_clinical_summaries").show();
} else if (outcome == 4) {
// Referred
$('#referred_div').show();
$('#died_div').hide();
$('#discharged_div').hide();
$('#follow_up_div').hide();
} else if (outcome == 5) {
// died
$('#died_div').show();
$('#referred_div').hide();
$('#discharged_div').hide();
$('#follow_up_div').hide();
} else {
// Died or referred or still admitted
$("#follow_up_div").hide();
$("#discharged_div").hide();
$('#referred_div').hide();
$('#died_div').hide();
}
});
/* start js used by the ward treatments section [id^=checked_bx_] */
$('[id^=checked_bx_]').change(function(){
var clickedChbxId = $(this).attr('id');
var idNumber = clickedChbxId.replace('checked_bx_','');
$('#checked_bx_' + idNumber).prop('checked') ? $("#given_date_div_"+idNumber).show() : $("#given_date_div_"+idNumber).hide();
});
/* end js used by the ward treatment section */
$("#submitInpatientButton,#submitInpatientBillButton").click(function (e) { // make sure that the corresponding outcome fields have been filled out
if (this.id === "submitInpatientButton" && $('#is_under_pdrm_monitoring').val() == 1) {
alert("Patient's post discharge risk of mortality is being monitored and you must fill in the required fields to continue");
$('#redirect_to_pdrm_monitoring').val(1);
}
var empty_compulsory_fields = [];
if ($("#outcome").val() == 2 && $("#discharge_date").val() == "") {
alert("<?php echo __('inpatient.discharge_date_warning');?>");
e.preventDefault();
return false;
}
if ($("#outcome").val() == 3 && $("#follow_up_date").val() == "") {
alert("<?php echo __('inpatient.follow_up_date_warning');?>");
e.preventDefault();
return false;
}
if ($("#outcome").val() == 4 && isNaN(parseInt($("#referral_id").val()))) {
alert("<?php echo __('inpatient.patient_referral_warning');?>");
e.preventDefault();
return false;
}
if ($("#outcome").val() == 5 && $("#died_on").val() == "") {
alert("<?php echo __('inpatient.death_date_warning');?>");
e.preventDefault();
return false;
}
});
// for services
let services_max_fields = 500;
let services_current_fields = <?php echo $services_counter; ?>;
$('.add_service_item').click(function () {
let can_edit_services_pricing = <?php echo $can_edit_services_pricing; ?>;
let readonly = '';
if (can_edit_services_pricing != 1) {
readonly = 'readonly';
}
if (services_current_fields < services_max_fields) {
$(".service_input_field").append("<br><div class='row'><div class='col-md-2'><select name='service_id[]' class='form-control' id='service_item_"+services_current_fields+"'><option value=''>-- Select --</option><?php echo $options_services ?></select></div><div class='col-md-2'><input type='number' name='service_unit_price[]' id='service_unit_price_"+services_current_fields+"' class='form-control'"+readonly+" placeholder='unit price'/></div><div class='col-md-2'><input type='number' name='service_staff_fee[]' id='service_staff_fee_"+services_current_fields+"' class='form-control'"+readonly+" placeholder='staff fee'></div><div class='col-md-2'><div class='input-group'><input class='form-control service_date' readonly='' name='service_date[]' type='text'><span class='input-group-addon'><i class='icon-calender'></i></span></div></div><div class='col-md-2'><input type='number' name='service_quantity[]' class='form-control' placeholder='Quantity'/></div><div class='col-md-2'><a class='remove_field label label-danger' style='color: white;'>Remove</a></div></div>");
select2set('service_item_'+services_current_fields);
services_current_fields++;
} else {
alert("<?php echo __('inpatient.services_warning');?>");
}
});
//get services fees
$(".service_input_field").on("change", "[id^='service_item_']", function (e) {
//get the id by filtering to get only the digit from "id" attribute
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
var service_id = $("#service_item_" + id).val();
let patient_id = $('#patient_id').val();
let patient_insurance_status = $('#patient_insurance_status').val();
let ward_id = $('#ward_id').val();
$.ajax({
url: '/get_inpatient_services_fees',
data: {'service_id':service_id, 'patient_id':patient_id, 'ward_id':ward_id,
'patient_insurance_status':patient_insurance_status},
success: function(response){
$("#service_unit_price_"+id).val(response[0]);
$("#service_staff_fee_"+id).val(response[1]);
}
});
});
// Removing added services
$(".service_input_field").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').remove();
services_current_fields--;
});
let bed_category_fields = <?php echo $bed_category_fields; ?>;
for (let i = 0; i < bed_category_fields; i++) {
add_date_picker(i);
}
$("#add_ward_bed_button").click(function(){
$(".bed_history_field").append("<tr><td>" +
"<input class='form-control' name='on_bed_number[]' type='text' required></td>" +
"<td><select class='form-control bed_category' id='bed_category_"+bed_category_fields+"' name='on_bed_bedcategory[]' required><option value=''>- select -</option><?php echo $options_bed_categories ?></select></td>" +
"<td><select class='form-control' name='bed_ward[]' required><option>- select ward-</option><?php echo $options_wards ?></select></td>" +
"<td><div class='input-group'><input class='form-control bed_dates' readonly name='on_bed_from[]' id='on_bed_from_"+bed_category_fields+"' type='text' required><span class='input-group-addon'><i class='icon-calender'></i></span></div></td>" +
"<td><div class='input-group'><input class='form-control bed_dates' readonly name='on_bed_upto[]' type='text' id='on_bed_upto_"+bed_category_fields+"' required><span class='input-group-addon'><i class='icon-calender'></i></span></div></td>" +
"<td><input type='number' name='bed_duration[]' class='form-control' id='bed_duration_"+bed_category_fields+"' required></td><td><input type='number' name='bed_rate[]' class='form-control' id='bed_rate_"+bed_category_fields+"' required></td>" +
"<td><a class='remove_field label label-danger' style='color: white;'>Remove</a></td></tr>");
add_date_picker(bed_category_fields);
bed_category_fields++;
});
function add_date_picker(id) {
$('#on_bed_from_' + id).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd'
});
$('#on_bed_upto_' + id).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd'
});
}
$(".bed_history_field").on("change", "[id^='on_bed_from_'],[id^='on_bed_upto_']", function (e) {
//get the id by filtering to get only the digit from "id" attribute
let id = /\d+(?=\D*$)/.exec($(this).attr('id'));
let startDate = $('#on_bed_from_'+id).val();
let endDate = $('#on_bed_upto_'+id).val();
let diffInMs = new Date(endDate) - new Date(startDate)
let diffInDays = diffInMs / (1000 * 60 * 60 * 24);
$('#bed_duration_'+id).val(diffInDays);
});
$(".bed_history_field").on("change", "[id^='bed_category_']", function (e) {
//get the id by filtering to get only the digit from "id" attribute
let id = /\d+(?=\D*$)/.exec($(this).attr('id'));
let selected_bed_category_id = $(this).val();
let patient_id = <?php echo $patient_id; ?>;
let patient_insurance_status = $('#patient_insurance_status').val();
$.ajax({
url: '/get_ward_bed_rate',
data: {'bed_category_id':selected_bed_category_id, 'patient_id':patient_id, 'patient_insurance_status':patient_insurance_status},
success: function(response){
$("#bed_rate_"+id).val(response);
}
});
});
$('#procedure_item_0').change(function() {
if($('#procedure_item_0').val()){
$("#eye_0").prop('required',true);
}
else $("#eye_0").prop('required',false);
});
$(".bed_history_field").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent().parent('tr').remove();
});
$(".upto_option").change(function() {
if($(this).val() == "selectDate"){
$(".upto_date").show();
$(".upto_option").hide();
}
});
$(".sundry_input_field").on("focus", ".sundry_date", function (e) {
$(this).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
});
$(".extras_input_field").on("focus", ".extra_date", function (e) {
$(this).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
});
$(".service_input_field").on("focus", ".service_date", function (e) {
$(this).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
});
$(".procedure_input_field").on("focus", ".procedure_date", function (e) {
$(this).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
});
var max_fields = 20; //maximum input boxes allowed
var right_wrapper = $(".right_input_fields_wrap"); //Fields wrapper
var left_wrapper = $(".left_input_fields_wrap"); //Fields wrapper
var right_add_button = $(".right_add_item"); //Add button ID
var left_add_button = $(".left_add_item"); //Add button ID
var count = {{ !empty($diagnosis_id_array)? count($diagnosis_id_array):0 }};
var x = count > 0 ? count :1; //initial text box count
$(right_add_button).click(function (e) { //on add input button click
e.preventDefault();
$('#Right_extra').show();
if (x < max_fields) { //max input box allowed
x++; //text box increment
$(right_wrapper).append("<div class='row' style='margin: 10px'>\n" +
" <div class='col-md-4'><select class='form-control select' id='right_diagnosis_category_"+ x +"' onchange='get_right_eye_diagnoses(this.value, "+ x +")'><?php echo $diagnosis_categories_options; ?></select></div>\n" +
" <div class='col-md-6'><select class='form-control select' name='right_eye_diagnosis[]' id='right_eye_diagnosis_"+ x +"'><option value=''>-select-</option></select></div>\n" +
" <div class='col-md-2'><button class='label label-danger remove_field' title='Delete this Diagnosis'><i class='fa fa-trash'></i></button></div>\n" +
" </div>"
); //add input box
$('#right_diagnosis_category_'+ x).select2();
$('#right_eye_diagnosis_'+ x).select2();
}
});
$(left_add_button).click(function (e) { //on add input button click
e.preventDefault();$('#left_extra').show();
if (x < max_fields) { //max input box allowed
x++; //text box increment
$(left_wrapper).append("<div class='row' style='margin: 10px'>\n" +
" <div class='col-md-4'><select class='form-control select' id='left_diagnosis_category_"+ x +"' onchange='get_left_eye_diagnoses(this.value, "+ x +")'><?php echo $diagnosis_categories_options; ?></select></div>\n" +
" <div class='col-md-6'><select class='form-control select' name='left_eye_diagnosis[]' id='left_eye_diagnosis_"+ x +"'><option value=''>-select-</option></select></div>\n" +
" <div class='col-md-2'><button class='label label-danger remove_field' title='Delete this Diagnosis'><i class='fa fa-trash'></i></button></div>\n" +
" </div>"
); //add input box
$('#left_diagnosis_category_'+ x).select2();
$('#left_eye_diagnosis_'+ x).select2();
}
});
function get_right_eye_diagnoses(value, id){
$.ajax({
method: 'GET',
cache : false,
url : '/diagnoses/get_diagnosis_by_category/'+value,
success: function (response) {
document.getElementById('right_eye_diagnosis_'+id).innerHTML = response;
},
error: function (error) {
console.log(error);
}
});
}
function get_left_eye_diagnoses(value, id){
$.ajax({
method: 'GET',
cache : false,
url : '/diagnoses/get_diagnosis_by_category/'+value,
success: function (response) {
document.getElementById('left_eye_diagnosis_'+id).innerHTML = response;
},
error: function (error) {
console.log(error);
}
});
}
function stopWardDrug(ward_prescription_id, drug_id){
$.ajax({
method: 'POST',
url: '/stop_ward_drug',
data: {'ward_prescription_id': ward_prescription_id, 'drug_id': drug_id},
success: function(response){
if (response == 1) {
alert("Drug has been stopped");
} else {
alert("Drug already stopped");
}
window.reload();
}
});
}
function resumeWardDrug(ward_prescription_id, drug_id){
$.ajax({
method: 'POST',
url: '/resume_ward_drug',
data: {'ward_prescription_id': ward_prescription_id, 'drug_id': drug_id},
success: function(response){
if (response == 1) {
alert("Drug has been resumed");
} else {
alert("Drug can not be resumed");
}
window.reload();
}
});
}
$(wrapper).on("click", ".remove_field", function (e) { //user click on remove text
e.preventDefault();
$(this).parent('div').parent('div').remove();
});
$('.select').select2({
placeholder: "-- select --"
});
let other_diagnosis = <?php echo count($other_diagnoses); ?>;
function add_diagnoses_row(){
if (other_diagnosis < 14) {
$('#other_diagnosis_table1').append("<tr>\
<tr><td style='width: 30%;'>\
<select name='other_diagnosis[]' class='form-control col-sm-12 sec_d' id='other_diagnosis_id_" + other_diagnosis + "' onchange='other_diagnosis_prompt(this.value, " + other_diagnosis + ")'required>@php echo $option_diagnoses; @endphp</select></td>\
<td style='width: 45%; color: #C85F6A;'><div class='well well-sm' id='secondary_diagnosis_prompt" + other_diagnosis + "'>&nbsp;</div></td>\
<td style='width: 24%'><div class='well well-sm' id='secondary_diagnosis_reference" + other_diagnosis + "'>&nbsp;</div></td>\
<td style='width: 1%;'><a class='remove_field btn btn-sm btn-rounded btn-danger' style='color: white;'><i class='fa fa-trash'></i></a></td>\
</tr>");
$('#other_diagnosis_id_'+other_diagnosis).select2();
other_diagnosis++;
}
}
function other_diagnosis_prompt(diagnosis_id, row_id) {
$.ajax({
type: "get",
url: "/diagnoses/get_diagnosis",
data: 'diagnosis_id=' + diagnosis_id,
cache: false,
success: function (result) {
var prompt_and_references = result.split('&&');
$('#secondary_diagnosis_prompt'+row_id).html(prompt_and_references[0]);
$('#secondary_diagnosis_reference'+row_id).html(prompt_and_references[1]);
}
});
}
/* This method will delete a row */
function deleteRow(ele){
ele.parentNode.parentNode.remove();
}
//update patient notes ward inpatients
function updateInpatientNotes(inpatientNotesId) {
// Use the dynamic IDs by appending the comment ID
var notes_id = $("#inpatient_notes_id_" + inpatientNotesId).val();
var history = $("#history_" + inpatientNotesId).val();
var result = $("#result_" + inpatientNotesId).val();
var vitals = $("#vitals_" + inpatientNotesId).val();
var impression = $("#impression_" + inpatientNotesId).val();
var plan = $("#plan_" + inpatientNotesId).val();
// Prepare the data object for submission
var data = {
'id': notes_id,
'history': history,
'result': result,
'vitals': vitals,
'impression': impression,
'plan': plan,
};
console.log("Updating inpatient notes", data);
$.ajax({
method: 'POST',
url: '/inpatient_sheet/patient_notes/update_inpatient_notes',
data: data,
success: function(response) {
if (response.success) {
alert("Inpatient notes updated successfully.");
// Reload the page after successful update
location.reload();
} else {
alert("An error occurred while updating the notes.");
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert("An error occurred: " + JSON.stringify(jqXHR));
console.log(jqXHR);
}
});
}
// update doctor ward notes
function updateDoctorProgressNotes(doctorNotesId){
var doctor_ward_progress_notes_id = $("#doctor_ward_progress_notes_" + doctorNotesId).val();
var ward_comments = $("#ward_comments_" + doctorNotesId).val();
var data = {
'id':doctor_ward_progress_notes_id,
'ward_comments': ward_comments,
}
//check if data reaches
console.log(data);
//send data to controller for processing
$.ajax({
method: 'POST',
url: '/inpatient_sheet/doctors_notes/update_doctor_ward_notes',
data: data,
success: function(response) {
if (response.success) {
alert(response.message);
// Reload the page after successful update
location.reload();
} else {
alert("An error occurred while updating the notes.");
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert("An error occurred: " + JSON.stringify(jqXHR));
console.log(jqXHR);
}
});
}
//nurse ward inpatient notes
function updateNurseWardInpatientNotes(nurseNotesId){
var nurse_ward_inpatient_notes = $("#nurse_ward_inpatient_notes_" + nurseNotesId).val();
var ward_comments = $("#ward_comments_" + nurseNotesId).val();
var data = {
'id':nurse_ward_inpatient_notes,
'ward_comments':ward_comments
}
console.log(data);
$.ajax({
method: 'POST',
url: '/inpatient_sheet/nurse_notes/update_nurse_ward_notes',
data: data,
success: function(response) {
if (response.success) {
alert(response.message);
// Reload the page after successful update
location.reload();
} else {
alert("An error occurred while updating the notes.");
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert("An error occurred: " + JSON.stringify(jqXHR));
console.log(jqXHR);
}
});
}
</script>
@endpush