Files
streamline-emr/docker/_streamline-src/Modules/Patients/Resources/views/allergies/header.blade.php
T

524 lines
27 KiB
PHP
Executable File

@if (session()->has('patient_id') || session()->has('patients_id'))
@endif
@push('scripts')
<script src="{{ asset('js/allergies/scripts.js') }}"></script>
@endpush
@push('styles')
<style type="text/css">
/* Important part used by allergies */
.allergy-modal-dialog {
overflow-y: initial !important
}
.allergy-modal-body {
height: 250px;
overflow-y: auto;
}
@media (min-width: 768px) {
.allergy-modal-dialog {
width: 90%;
max-width: 1200px;
}
}
</style>
@endpush
<div class="row">
<div @if (is_smart_discharge_enabled()) class="col-sm-6" @else class="col-sm-8" @endif>
<div>
@php
$known_patient_allergies = \Streamline\Models\Allergy::where('patient_id', $patient->id)
->orderBy('created_at', 'desc')
->take(2)
->get();
$known_patient_alerts = \Streamline\Models\Alert::where('patient_id', $patient->id)
->orderBy('created_at', 'desc')
->take(2)
->get();
$categories = \Streamline\Models\PatientCategory::pluck('name', 'id');
$drug_categories_array = DB::table('drug_categories')->pluck('name', 'id');
$drug_categories = \Streamline\Models\DrugCategory::orderBy('name', 'asc')->get();
@endphp
<!-- <a href="#" class="btn-action fa fa-plus-square"><i></i></a> -->
<span class="count label label-inverse mx-4 px-4">
<strong>{{ __('allergies.category') }} :</strong>
{{ $categories[$patient->category_id] ?? 'N/A' }}
</span>
<div class="row consultation-pat-row">
<div class="col-sm-9 consultation-pat mb-2" style="overflow-x: auto; overflow-y: hidden;">
<div class="row consultation-pat-table h-100 align-items-stretch" style="flex-wrap: nowrap;">
<div class="col p-0">
<div class="card h-100 m-0">
<div class="card-header w-100">{{ __('allergies.patient_number') }}</div>
<div class="card-body">{{ $patient->number }}</div>
</div>
</div>
<div class="col p-0">
<div class="card h-100 m-0">
<div class="card-header w-100">{{ __('allergies.full_names') }}</div>
<div class="card-body">{!! insurance_flag($patient->id) !!}
@if (patient_insurance_status($patient->id) == 1)
<small style="color:#069">({{ __('patients.joined_chi_scheme') }}
{{ patient_duration_on_chi_sheme($patient->id) }})</small>
@endif
</div>
</div>
</div>
<div class="col p-0">
<div class="card h-100 m-0">
<div class="card-header w-100">{{ __('allergies.gender') }}</div>
<div class="card-body">
{{ $patient->gender == 1 ? __('allergies.male') : __('allergies.female') }}</div>
</div>
</div>
<div class="col p-0">
<div class="card h-100 m-0">
<div class="card-header w-100">{{ __('allergies.age') }}</div>
<div class="card-body">{{ get_patients_age($patient->date_of_birth) }}</div>
</div>
</div>
<div class="col p-0">
<div class="card h-100 m-0">
<div class="card-header w-100">{{ __('allergies.national_id') }}</div>
<div class="card-body">{!! $patient->national_id == null || $patient->national_id == ''
? "<span class='label label-info'>National ID Missing</span>"
: strtoupper($patient->national_id) !!}</div>
</div>
</div>
</div>
</div>
<div class="col-sm-3 mb-2">
<div class="button-box h-100">
<a class="img" href="#modal-photo" data-toggle="modal" style="color: whitesmoke">
<div class="center img-pat-profile"
style="height: 100%; width: 100%; background: url(@if (!is_null($patient->photo) && $patient->photo != '') {{ asset($patient->photo) }} @else {{ asset('/uploads/streamline_images/person-place-holder.jpg') }} @endif) center no-repeat; background-size: auto 100%; min-height: 110px; position: relative;">
<!-- img-rounded -->
<i class="fa fa-refresh"
style="display: none; position: absolute; right: -10px; top: -10px"></i>
</div>
</a>
</div>
<div class="modal fade" id="modal-photo" tabindex="-1" role="dialog"
aria-labelledby="modal-photoLabel1">
<div class="modal-dialog" 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="modal-photoLabel1">
{{ __('allergies.insured_patient_photo') }}</h4>
</div>
<div class="modal-body">
<div class="col-sm-12 text-center">
<img src="@if (!is_null($patient->photo) && $patient->photo != '') {{ asset($patient->photo) }} @else {{ asset('/uploads/streamline_images/person-place-holder.jpg') }} @endif"
class="img-rounded center" style="margin: auto" />
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-sm"
data-dismiss="modal">{{ __('allergies.close') }}</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-2">
<div class="row">
<div class="col-sm-12">
<div>
<div class="button-box">
<button type="button"
class="btn btn-danger btn-rounded btn-sm mb-1 d-flex justify-content-between align-items-center"
data-toggle="modal" data-target="#modal-allergies"
style="line-height: 10px; font-size: 11px; gap: 10px;">{{ __('allergies.allergies') }} <i
class="fa fa-plus-circle"></i></button>
</div>
<div class="modal fade" id="modal-allergies" tabindex="-1" role="dialog"
aria-labelledby="modal-allergiesLabel1">
<div class="modal-dialog modal-lg allergy-modal-dialog" 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="modal-allergiesLabel1">
{{ __('allergies.add_allergies_patient') }}</h4>
</div>
<div class="modal-body allergy-modal-body">
<div class="container-fluid">
<h4>{{ __('allergies.currently_known') }}</h4>
<div class="row">
@php $allergic_drugs_ids_array = []; @endphp
@if (count($known_patient_allergies) > 0)
@foreach ($known_patient_allergies as $allergy)
@php $allergic_drugs_ids_array = explode(',' , $allergy->names); @endphp
@endforeach
@php $chunked_allergy_array = array_chunk($allergic_drugs_ids_array, 1, true) @endphp
@foreach ($chunked_allergy_array as $items)
<div class="col-md-4">
@foreach ($items as $item)
@if (isset($drug_categories_array[$item]))
&#8226 {{ $drug_categories_array[$item] }} <br>
@endif
@endforeach
</div>
@endforeach
@endif
</div>
<br>
<div class="row">
<h4>{{ __('allergies.allergic_reactions') }}</h4>
@foreach ($drug_categories->chunk(9) as $chunk)
@foreach ($chunk as $drug_category)
<div class="col-md-4">
<!-- if it is a known allergy then check the checkbox -->
@if (in_array($drug_category->id, $allergic_drugs_ids_array))
<input class='patient_allergies' name='allergies[]'
type='checkbox' checked="true"
value='{{ $drug_category->id }}' />
{{ $drug_category->name }}
@else
<input class='patient_allergies' name='allergies[]'
type='checkbox'
value='{{ $drug_category->id }}' />
{{ $drug_category->name }}
@endif
<br />
</div>
@endforeach
@endforeach
<!-- <hr> -->
<input type="hidden" id="allergy_patient_id"
name="allergy_patient_id" value="<?php echo $patient->id; ?>" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="submit_allergies"
class="btn btn-success btn-sm">{{ __('allergies.submit_allergies') }}</button>
<button type="button" class="btn btn-danger btn-sm"
data-dismiss="modal">{{ __('allergies.close') }}</button>
</div>
</div>
</div>
</div>
<table class="table-bordered table-condensed table-striped w-100 mb-3 br-5"
id="allergies_drugs_table"
style="border-collapse: collapse; border-spacing: 0; border-spacing: 0;">
<tbody>
<tr style="border-spacing: 0;">
<td style="font-weight: normal; border-spacing: 0;">
<div id="patient_allergies_tab">
@if (count($allergic_drugs_ids_array) > 0)
@if (isset($allergic_drugs_ids_array[0]) && isset($drug_categories_array[$allergic_drugs_ids_array[0]]))
&#8226 <small
style="color: red;">{{ $drug_categories_array[$allergic_drugs_ids_array[0]] }}</small><br>
@endif
@if (isset($allergic_drugs_ids_array[1]) && isset($drug_categories_array[$allergic_drugs_ids_array[1]]))
&#8226 <small
style="color: red;">{{ $drug_categories_array[$allergic_drugs_ids_array[1]] }}</small><br>
@endif
@else
<small
style="color: blue;">{{ __('allergies.no_recorded_allergies') }}</small>
@endif
</div>
@if (count($allergic_drugs_ids_array) > 0)
<a href="/allergies">{{ __('allergies.view_all') }}</a>
@endif
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-sm-2">
<div class="row">
<div class="col-sm-12">
<div>
<div class="button-box">
<button type="button"
class="btn btn-danger btn-rounded btn-sm mb-1 d-flex justify-content-between align-items-center"
data-toggle="modal" data-target="#modal-alerts"
style="line-height: 10px; font-size: 11px; gap: 10px;">{{ __('allergies.alerts') }} <i
class="fa fa-plus-circle"></i></button>
</div>
<div class="modal fade" id="modal-alerts" tabindex="-1" role="dialog"
aria-labelledby="modal-alertsLabel1">
<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="modal-alertsLabel1">
{{ __('allergies.alerts_for_patient') }}</h4>
</div>
<div class="modal-body">
<div class="container-fluid">
<form>
<input type="hidden" id="alert_patient_id" name="alert_patient_id"
value="{{ $patient->id }}">
<div class="control-group">
<label for="alerts">{{ __('allergies.enter_alert') }}</label>
<div class="controls">
<textarea name="alerts" id="alerts" maxlength="150" class="form-control col-md-12"></textarea>
</div>
</div><br>
<div class="separator bottom"></div>
</form>
</div>
</div>
<div class="modal-footer">
<input type="submit" id="submit_alerts" class = "btn btn-success btn-sm"
value="{{ __('allergies.submit_alert') }}" />
<button type="button" class="btn btn-danger btn-sm"
data-dismiss="modal">{{ __('allergies.close') }}</button>
</div>
</div>
</div>
</div>
<table class="table-bordered table-condensed table-striped w-100 mb-3 br-5"
style="border-collapse: collapse; border-spacing: 0;">
<tbody>
<tr style="border-spacing: 0;">
<td style="font-weight: normal">
<div id="patient_alerts_tab">
@if (isset($known_patient_alerts) && count($known_patient_alerts) > 0)
@if (isset($known_patient_alerts[0]))
&#8226 <small
style="color: red;">{{ $known_patient_alerts[0]->alerts }}</small><br>
@endif
@if (isset($known_patient_alerts[1]))
&#8226 <small
style="color: red;">{{ $known_patient_alerts[1]->alerts }}</small><br>
@endif
@else
<small
style="color: blue;">{{ __('allergies.no_recorded_alerts') }}</small>
@endif
</div>
@if (isset($known_patient_alerts) && count($known_patient_alerts) > 0)
<a href="/alerts/view_alerts">View All</a>
@endif
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
@php
$date_of_birth = get_name($patient->id, 'id', 'date_of_birth', 'patients');
$dob = new Carbon\Carbon($date_of_birth);
$age_diff_months = $dob->diffInMonths(Carbon\Carbon::now());
@endphp
@if ($age_diff_months < 61 && is_smart_discharge_enabled())
<div class="col-sm-2">
<div class="button-box">
<a class="btn btn-danger btn-rounded btn-sm mb-1 d-flex justify-content-between align-items-center gap-2"
style="line-height: 10px; font-size: 11px; gap: 10px;">
Post Discharge Risk of Mortality
</a>
</div>
<table class="table-bordered table-condensed table-striped w-100 br-5">
<tbody class="br-5">
<tr class="br-5">
<td class="br-5">
@if (is_patient_currently_admitted($patient->id))
{!! get_post_discharge_mortality_risk($patient->id) !!}
@else
@php
// just generate the row without displaying anything
$disregard_this = get_post_discharge_mortality_risk($patient->id);
@endphp
Patient is not admitted
@endif
</td>
</tr>
</tbody>
</table>
</div>
@endif
</div>
<div id="saved_allergies_alert" class="myadmin-alert alert-success myadmin-alert-top-right"><a href="#"
class="closed">&times;</a>
<h4>{{ __('allergies.allergies_updated') }}</h4>
</div>
<div id="saved_alerts_alert" class="myadmin-alert alert-success myadmin-alert-top-right"><a href="#"
class="closed">&times;</a>
<h4>{{ __('allergies.alerts_updated') }}</h4>
</div>
<div class="modal fade" id="all_allergies_modal" tabindex="-1" role="dialog"
aria-labelledby="modal-successLabel1">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<ul class="row">
@php
$allergy_count = count($allergic_drugs_ids_array);
@endphp
@for ($i = 0; $i < $allergy_count; $i++)
<li class="col-sm-3">
<small>{{ isset($drug_categories_array[$allergic_drugs_ids_array[$i]]) ? $drug_categories_array[$allergic_drugs_ids_array[$i]] : '' }}</small>
</li>
@endfor
</ul>
</div>
</div>
<div class="modal-footer">
<div class="control-group" style="vertical-align: center;">
<div class="controls">
<button type="button" class="btn btn-success"
data-dismiss="modal">{{ __('allergies.ok') }}</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
@push('scripts')
<script type="text/javascript">
$(".myadmin-alert .closed").click(function(event) {
$(this).parents(".myadmin-alert").fadeToggle(350);
return false;
});
$('#submit_allergies').click(function(e) {
e.preventDefault();
$('#modal-allergies').modal('hide');
var patient_allergies = new Array();
//loop thru the checked allergies and push them into an array
$('input[name="allergies[]"]:checked').each(function() {
patient_allergies.push(this.value);
});
var allergy_patient_id = $('#allergy_patient_id').val();
$.ajax({
type: 'POST',
url: '/store_patient_allergies',
data: {
patient_allergies: patient_allergies,
allergy_patient_id: allergy_patient_id
},
cache: false,
success: function(response) {
//display success notification modal
$("#saved_allergies_alert").fadeToggle(350);
// update the view
let drug_categories_array = {!! json_encode($drug_categories_array) !!};
let patientAllergiesTabHtml = "";
if (typeof patient_allergies[0] !== 'undefined') {
patientAllergiesTabHtml += "&#8226 <small style=\"color: red;\">" +
drug_categories_array[patient_allergies[0]] + "</small><br>";
}
if (typeof patient_allergies[1] !== 'undefined') {
patientAllergiesTabHtml += "&#8226 <small style=\"color: red;\">" +
drug_categories_array[patient_allergies[1]] + "</small><br>";
}
$("#patient_allergies_tab").html(patientAllergiesTabHtml);
$('input[name="allergies[]"]').each(function() {
// loop through allergies and recheck values
if (jQuery.inArray(this.value, patient_allergies) !== -1) {
$(this).prop('checked', true);
} else {
$(this).prop('checked', false);
}
});
}
});
});
/* submit alert */
$('#submit_alerts').click(function(e) {
e.preventDefault();
$('#modal-alerts').modal('hide');
var alert_patient_id = $('#alert_patient_id').val();
var patient_alerts = $('#alerts').val(); //
$.ajax({
type: 'POST',
url: '/store_patient_alerts',
data: {
patient_alerts: patient_alerts,
alert_patient_id: alert_patient_id
},
cache: false,
success: function(response) {
//display success notification modal
$("#saved_alerts_alert").fadeToggle(350);
}
});
});
$(window).on('load', function() {
let def_view = true;
$('.img-pat-profile').hover(
function() {
$('.img-pat-profile i').css('display', '');
},
function() {
$('.img-pat-profile i').css('display', 'none');
});
$('.img-pat-profile i').on('click tap', function(e) {
e.preventDefault();
if (def_view) {
$('.img-pat-profile').css('background-size', '100% auto');
} else {
$('.img-pat-profile').css('background-size', ' auto 100%');
}
def_view = !def_view;
})
});
</script>
@endpush