Files
streamline-emr/docker/streamline-src/Modules/Patients/Resources/views/triage/create.blade.php
T

1151 lines
57 KiB
PHP
Executable File
Raw 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/select2/select2.min.css') }}" rel="stylesheet" />
<style>
.triage-grade li {
display: inline-block;
}
.wrapper {
border: 1px solid #00c292;
border-radius: 6px;
padding: 20px;
margin-bottom: 20px;
}
</style>
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('triage.create_triage') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('triage.dashboard') }}</a></li>
<li><a href="{{ route('patient_episodes.index') }}">{{ __('triage.patient_home') }}</a></li>
<li class="active">{{ __('triage.triage') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patients::allergies.header')
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box br-5" style="padding-top: 5px;">
<h5 class="page-title"><strong>{{ __('triage.triage') }} ({{ $age_group_display }})
{{ __('triage.for_episode') }} : <font color="blue">
{{ streamline_date(get_name($episode_id, 'id', 'created_at', 'patient_episodes')) }}</font>
</strong></h5>
<hr>
{{ Form::open(['route' => 'triage.store', 'data-toggle' => 'validator', 'id' => 'triageForm']) }}
{{ Form::hidden('episode_id', $episode_id, ['id' => 'episode_id']) }}
{{ Form::hidden('patient_id', $patient_id, ['id' => 'patient_id']) }}
{{ Form::hidden('age_diff_months', $age_diff_months, ['id' => 'age_diff_months']) }}
{{ Form::hidden('gender', get_name($patient_id, 'id', 'gender', 'patients'), ['id' => 'gender']) }}
@php
$age = 0;
$alert1 = '<div class="alert alert-warning "> <button type="button" class="close" data-dismiss="alert">×</button>' . __('triage.sick_children_warning') . '</div>';
$alert2 = '<div class="alert alert-warning "> <button type="button" class="close" data-dismiss="alert">×</button>' . __('triage.poison_warning') . '</div>';
@endphp
@php
$option_symptoms = '';
$option_symptoms_periods = '';
@endphp
@if (!are_symptoms_on_consultation())
<div class="table-responsive">
<table class="table table-hover color-table success-table table-bordered">
<thead>
<tr>
<th class="text-center">{{ __('triage.symptoms') }} @if (Auth::user()->can('symptom-create'))
<a data-toggle="modal" data-target="#symptomsmodal"
class="label labelRight label-info pull-right">{{ __('triage.add_new') }}</a>
@endif
</th>
<th class="text-center">{{ __('triage.duration') }}</th>
<th class="text-center">{{ __('triage.prompt') }}</th>
<th class="text-center">{{ __('triage.reference_text') }}</th>
<th></th>
</tr>
</thead>
@php
foreach ($symptoms as $key => $value) {
$option_symptoms .= "<option value='$key'>" . str_replace('"', '', $value) . '</option>';
}
foreach ($symptoms_periods as $key => $value) {
$option_symptoms_periods .= "<option value='$key'>$value</option>";
}
@endphp
<tbody class='symptoms_input_fields_wrap'>
<tr>
<td style='width: 20%;'>
<select name='symptoms[]' id='symptoms_0' class='form-control col-sm-12 compulsory' onchange='showPrompt(this.value, 0)' required>@php echo $option_symptoms; @endphp</select>
</td>
<td style='width: 21%'>
<div class='row'>
<div class='col-sm-3'>
<input type='text' style='display: block;' name='duration[]' id='symptoms_duration_0' class='col-sm-12 form-control' required>
</div>
<div class='col-sm-9'>
<select style='display: inline-block;' name='time[]' id='symptoms_time_0' class='col-sm-12 form-control' required>@php echo $option_symptoms_periods; @endphp</select>
</div>
</div>
</td>
<td id='symptoms_prompt_0' style='width: 30%'></td>
<td id='symptoms_reference_0'></td>
<td style='width: 1%;'></td>
</tr>
</tbody>
</table>
<a class="btn btn-success btn-xs" onclick="add_symptom_row()">{{ __('triage.add_row') }}</a>
<hr>
</div>
@endif
@if (is_tuberculosis_screening_enabled())
@include('patients::triage.tb_screening')
@endif
@if (is_hiv_and_gbv_screening_tool_enabled())
@include('patients::triage.hiv_gbv_screening')
@endif
@if (is_hiv_screening_tool_enabled())
@include('patients::triage.hiv_screening')
@endif
@if (is_gbv_screening_tool_enabled())
@include('patients::triage.gbv_screening')
@endif
<div class="row">
<div class="col-md-8">
<div class="table-responsive">
<table class="table table-hover table-striped color-table success-table table-bordered"
id="observations_table">
<thead>
<tr>
<th>{{ __('triage.observation') }}</th>
<th>{{ __('triage.value') }}</th>
<th>{{ __('triage.normal_range') }}</th>
@if ($age_group == 5)
<th>KEWS</th>
<th>NEWS</th>
@else
<th>KEWS</th>
@endif
</tr>
</thead>
<tbody>
@include('patients::triage.observations_changed')
</tbody>
</table>
</div>
<hr>
@if($triage_without_etat)
<div class="table-responsive">
<table class="table table-hover color-table success-table table-bordered">
<thead>
<tr>
<th colspan="5">{{ __('triage.choose_blood_group') }}</th>
<th colspan="3">{{ __('triage.rhesus_factor') }}</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 12.5%">
{{ Form::radio('blood_group', 'Unknown', false) }}
<label for="rdt_pos">{{ __('triage.unknown') }}</label>
</td>
<td style="width: 12.5%">
{{ Form::radio('blood_group', 'A', false) }}
<label for="rdt_pos">A</label>
</td>
<td style="width: 12.5%">
{{ Form::radio('blood_group', 'B', false) }}
<label for="rdt_neg">B</label>
</td>
<td style="width: 12.5%">
{{ Form::radio('blood_group', 'O', false) }}
<label for="rdt_pos">O</label>
</td>
<td style="width: 12.5%">
{{ Form::radio('blood_group', 'AB', false) }}
<label for="rdt_neg">AB</label>
</td>
<td style="width: 12.5%">
{{ Form::radio('rhesus_factor', 1, false) }}
<label for="rdt_pos">{{ __('triage.positive') }}</label>
</td>
<td style="width: 12.5%">
{{ Form::radio('rhesus_factor', 2, false) }}
<label for="rdt_neg">{{ __('triage.negative') }}</label>
</td>
<td style="width: 12.5%">
{{ Form::radio('rhesus_factor', 0, false) }}
<label for="rdt_neg">{{ __('triage.unknown') }}</label>
</td>
</tr>
</tbody>
</table>
</div>
@endif
@if (between($years, 16, 50) && !$triage_without_etat)
@include('patients::triage.family_planning_questions')
@endif
@if (between($years, 0, 12) && !$triage_without_etat)
@include('patients::triage.emergency_signs')
@php $age = 1 @endphp
@endif
@if (between($age_diff_months, 0, 5) && is_smart_discharge_enabled() && !$triage_without_etat)
<table class="table table-bordered">
<tr>
<td class="text-center" colspan="2">
<h4>Social Health Indicators</h4>
</td>
</tr>
<tr>
<td>{{ Form::label('child_with_proven_infection', 'Does the child have a proven or suspected infection e.g is the child having fever, cough, diarrhoea?') }}
</td>
<td>{{ Form::radio('child_with_proven_infection', 1, false, ['onclick' => 'show_proven_infection_questions()']) }}
Yes &nbsp&nbsp&nbsp
{{ Form::radio('child_with_proven_infection', 0, false, ['onclick' => 'hide_proven_infection_questions()']) }}
No</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>{{ Form::label('hospital_travel_duration', 'How long did it take you to travel to the hospital?') }}
</td>
<td>
{{ Form::select('hospital_travel_duration', ['' => '-- select --', '1' => '< 30 mins', '2' => '30 mins 1 hour', '3' => '1 - 4 hours', '4' => '> 4 hours'], null, ['class' => 'form-control']) }}
</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>{{ Form::label('illness_duration', 'What is the duration of the present illness at the time of admission?') }}
</td>
<td>
{{ Form::select('illness_duration', ['' => '-- select --', '1' => '< 48 hours', '2' => '48 hours - 7 days', '3' => '7 days - 1 month', '4' => 'More than a month'], null, ['class' => 'form-control']) }}
</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>{{ Form::label('tone_normal_6mo', 'Muscle Tone') }}</td>
<td>
{{ Form::select('tone_normal_6mo', ['' => '-- select --', '1' => 'Increased (Stiff)', '2' => 'Normal', '3' => 'Decreased (floppy)', '4' => 'Do not know'], null, ['class' => 'form-control']) }}
</td>
</tr>
</table>
@endif
@if (between($age_diff_months, 6, 60) && is_smart_discharge_enabled() && !$triage_without_etat)
<div></div>
<table class="table table-bordered">
<tr>
<td class="text-center" colspan="4">
<h4>Social Health Indicators</h4>
</td>
</tr>
<tr>
<td colspan="2">
{{ Form::label('child_with_proven_infection', 'Does the child have a proven or suspected infection e.g is the child having fever, cough, diarrhoea?') }}
</td>
<td>{{ Form::radio('child_with_proven_infection', 1, false, ['onclick' => 'show_proven_infection_questions()']) }}
Yes</td>
<td>{{ Form::radio('child_with_proven_infection', 0, false, ['onclick' => 'hide_proven_infection_questions()']) }}
No</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>
{{ Form::label('last_hospitalization', 'Time since last hospitalization') }}
</td>
<td>
{{ Form::select('last_hospitalization', ['' => '-- select --', '1' => 'Less than 7 days ago', '2' => '7 to 30 days ago', '3' => '30 days to 1 year ago', '4' => 'More than 1 year ago', '5' => 'Never'], null, ['class' => 'form-control']) }}
</td>
<td>
{{ Form::label('water_source', 'Primary water source for drinking water') }}
</td>
<td>
<select name="water_source" class="form-control">
<option value="">-- select --</option>
<option value="1">Protected spring</option>
<option value="2">Bore hole</option>
<option value="3">Municipal water</option>
<option value="4">Open source (unprotected, stagnant water, dam)</option>
<option value="5">Slow running water</option>
<option value="6">Fast running water</option>
</select>
</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>
{{ Form::label('safe_water', 'Do you boil, filter (good sand/ceramic) or disinfect (using bleach/waterguard) all drinking water?') }}
</td>
<td>
{{ Form::radio('safe_water', 1, false) }} Yes
{{ Form::radio('safe_water', 0, false) }} No
</td>
<td>{{ Form::label('child_mosquito_net', 'Does your child sleep under a mosquito net?') }}
</td>
<td>
{{ Form::select('child_mosquito_net', ['' => '-- select --', '1' => 'Never', '2' => 'Sometimes', '3' => 'Always'], null, ['class' => 'form-control']) }}
</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>{{ Form::label('mother_education_level', 'What is the education level of the childs mother?') }}
</td>
<td>
{{ Form::select('mother_education_level', ['' => '-- select --', '1' => 'No school', '2' => '<= P3', '3' => 'P4-P7', '4' => 'S1-S6', '5' => 'Post secondary (including post S4 technical school)', '6' => 'Do not know'], null, ['class' => 'form-control']) }}
</td>
<td>{{ Form::label('hospital_travel_duration', 'How long did it take you to travel to the hospital?') }}
</td>
<td>
{{ Form::select('hospital_travel_duration', ['' => '-- select --', '1' => '< 30 mins', '2' => '30 mins 1 hour', '3' => '1 - 4 hours', '4' => '> 4 hours'], null, ['class' => 'form-control']) }}
</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>{{ Form::label('maternal_hiv', 'Maternal HIV') }}</td>
<td>
<select name="maternal_hiv" class="form-control">
<option value="">-- select --</option>
<option value="2">HIV Positive</option>
<option value="1">HIV Negative</option>
<option value="3">HIV Unknown</option>
</select>
</td>
<td>{{ Form::label('child_hiv', 'Child HIV') }}</td>
<td>{{ Form::select('child_hiv', ['' => '-- select --', '1' => 'HIV Positive', '0' => 'HIV Negative / Unknown'], null, ['class' => 'form-control']) }}
</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>{{ Form::label('bcs_eye_movement', 'Eye movement') }}</td>
<td>{{ Form::select('bcs_eye_movement', ['' => '-- select --', '1' => 'Watches or follows', '0' => 'Fails to watch or follow'], null, ['class' => 'form-control']) }}
</td>
<td>{{ Form::label('bcs_best_mortal', 'Best motor response') }}</td>
<td>{{ Form::select('bcs_best_mortal', ['' => '-- select --', '0' => 'No response or inappropriate response', '1' => 'Withdraws limb from pain stimulus', '2' => 'Localizes painful stimulus'], null, ['class' => 'form-control']) }}
</td>
</tr>
<tr class="proven_infection_questions" style="display: none">
<td>{{ Form::label('bcs_best_verbal', 'Best verbal response') }}</td>
<td>{{ Form::select('bcs_best_verbal', ['' => '-- select --', '0' => 'No vocal response to pain', '1' => 'Moan or abnormal cry with pain', '2' => 'Cries appropriately with pain (or speaks if verbal)'], null, ['class' => 'form-control']) }}
</td>
<td>{{ Form::label('maternal_age', 'Mother\'s age') }}</td>
<td>{{ Form::number('maternal_age', 0, ['class' => 'form-control']) }}</td>
</tr>
</table>
@endif
</div>
<div class="col-md-4">
@if ($age_group == 1 || $age_group == 2)
<?php echo $alert2; ?>
<?php echo $alert1; ?>
@else
<?php echo $alert2; ?>
@endif
<br>
@if (!is_add_attendance_to_consultation_enabled())
<div class="table-responsive">
<table class="table table-hover color-table success-table table-bordered">
<thead>
<tr>
<th colspan="2" class="text-center">
{{ __('triage.patient_attendance') }}
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">
<font color="#C85F6A" class="text-center">{{ __('triage.re_attendance_or_new') }}</font>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="new_attendance" id="new_attendance" /> {{ __('triage.new_attendance') }}
</td>
<td>
<input type="checkbox" name="re_attendance" id="re_attendance"/> {{ __('triage.re_attendance') }}
</td>
</tr>
</tbody>
</table>
</div>
@endif
@if (between($years, 0, 12) && !$triage_without_etat)
@include('patients::triage.priority_signs')
@endif
<div style="background: #F5F5F5; padding: 10px;">
@if(is_smart_triage_enabled() && !$triage_without_etat)
<div id="smart_triage_div" style="display: none">
<h4 class="text-center">Smart Triage</h4>
<hr>
<div class="row">
<div class="col-md-4">
<img id="smart_triage_image" src="/uploads/streamline_images/emergency.png"
class="img-rounded img-responsive" />
</div>
<div class="col-md-8">
<h3 id="smart_triage_label"><b></b></h3>
<b id="smart_triage_complaint"></b>
<br><br>
<b id="smart_triage_score"></b>
<br><br>
<a href="#"data-toggle="modal" data-target="#smart_triage_modal">More
Details</a>
</div>
</div>
<hr>
</div>
@endif
<h4 class="text-center">{{ __('triage.triage_grade') }}</h4>
<hr>
<div class="row text-center">
<div class="col-md-4 br">
{{ Form::radio('triage_grade', 1, false, ['required', 'id' => 'triage_grade_green']) }}
<b style="color: #006400; font-weight: 900; font-size: 18;">{{ __('triage.green') }}
</b>
</div>
<div class="col-md-4">
{{ Form::radio('triage_grade', 2, false, ['required', 'id' => 'triage_grade_yellow']) }}
<b style="color: #FFC40C; font-weight: 900; font-size: 18; ">{{ __('triage.yellow') }}
</b>
</div>
<div class="col-md-4">
{{ Form::radio('triage_grade', 3, false, ['required', 'id' => 'triage_grade_red']) }}
<b style="color: #FF4500; font-weight: 900; font-size: 18;">{{ __('triage.red') }}</b>
</div>
</div>
</div>
<hr>
<h4 style="background: #F5F5F5; padding: 10px;">{{ __('triage.referral_clinic_allocation') }}</h4>
<div class="form-group">
{{ Form::label('referral_hospital', __('triage.referred_by')) }}
{{ Form::select('referral_hospital', $referral_hospitals, '1', ['class' => 'form-control compulsory', 'required', 'id' => 'referral_hospital']) }}
<a class="pull-right" style="font-size: x-small" data-toggle="modal"
data-target="#referralsmodal">{{ __('triage.add_new') }}</a>
</div>
<div class="form-group">
{{ Form::label('clinic_allocation', __('triage.clinic_allocation')) }}
@if(is_numeric(get_name($episode_id, 'id', 'clinic_id', 'patient_episodes')))
{{ Form::select('clinic_allocation', $clinics, get_name($episode_id, 'id', 'clinic_id', 'patient_episodes'), ['class' => 'form-control col-sm-12 compulsory clinic_allocation', 'required']) }}
@else
{{ Form::select('clinic_allocation', $clinics, '', ['class' => 'form-control col-sm-12 compulsory clinic_allocation', 'required']) }}
@endif
</div>
@if($triage_without_etat)
<h4 style="background: #F5F5F5; padding: 10px;">{{ __('triage.observation_notes') }}</h4>
<textarea name='observation_notes' class="col-sm-12" rows="5" placeholder="<?php echo __('triage.observation_notes_instru') ?>"></textarea>
<hr>
<h4 style="background: #F5F5F5; padding: 10px;">{{ __('triage.nursing_notes') }}</h4>
<textarea name='nursing_notes' class="col-sm-12" rows="5" placeholder="<?php echo __('triage.nursing_notes_instru') ?>"></textarea>
@else
<h4 style="background: #F5F5F5; padding: 10px;">{{ __('triage.comment') }}</h4>
<textarea name='comment' id="comment" class="col-sm-12" placeholder="<?php echo __('triage.type_comments_here') ?>"></textarea>
@endif
<br><br>
{{ Form::button(__('triage.submit_triage'), ['type' => 'submit', 'class' => 'btn btn-success col-sm-12', 'id' => 'submit_triage']) }}
<br><br>
{{ __('triage.triage_done_by') }} : <span
style="color: green; font-weight: bold;">{{ ucwords(Auth::user()->first_name) . ' ' . ucwords(Auth::user()->last_name) }}</span>
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
<div class="modal fade" id="symptomsmodal" tabindex="-1" role="dialog">
<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="exampleModalLabel1">{{ __('triage.add_new_symptom') }}</h4>
</div>
<div class="modal-body">
{{ Form::text('symptom_name', '', ['class' => 'form-control', 'id' => 'symptom_name', 'placeholder' => __('triage.symptom_name')]) }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">{{ __('triage.cancel') }}</button>
<a class="btn btn-success" onclick="submitSymptom()">{{ __('triage.add_symptom') }}</a>
</div>
</div>
</div>
</div>
<div class="modal fade" id="smart_triage_modal" tabindex="-1" role="dialog">
<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="smart_triage_modal_label">Triage Category Information</h4>
</div>
<div class="modal-body">
<h4><b>Factors contributing to a higher Score (predicted need for admission):</b></h4>
<ol id="smart_triage_factors">
<li>Age (older)</li>
<li>Pulse Rate (higher)</li>
<li>Temperature (higher)</li>
<li>MUAC (smaller)</li>
<li>SaO2 (lower)</li>
<li>Severe Respiratory Distress</li>
</ol>
<br><br><br>
<h4 id="smart_triage_score_info"></h4>
<b>Model Range</b>
<ol>
<li style="color: #006400;">Non-Urgent ≤ 8%</li>
<li style="color: #FFC40C;">Priority = 8% - 40%</li>
<li style="color: #FF4500;">Emergency > 40%</li>
</ol>
</div>
</div>
</div>
</div>
<div class="modal fade" id="referralsmodal" tabindex="-1" role="dialog">
<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="exampleModalLabel1">{{ __('triage.add_new_referral') }}</h4>
</div>
<div class="modal-body">
{{ Form::text('referral_name', '', ['class' => 'form-control', 'id' => 'referral_name', 'placeholder' => __('triage.referral_name')]) }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">{{ __('triage.cancel') }}</button>
<a class="btn btn-primary" onclick="submitReferral()">{{ __('triage.add_referral') }}</a>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script type="text/javascript">
let max_rows = 20;
let wrapper = $(".symptoms_input_fields_wrap");
let x = 1;
let smart_triage_variables = {};
// check if smart triage is enabled
let smart_triage_enabled = <?php echo is_smart_triage_enabled() ? 1 : 0; ?>;
let apply_triage_grade = <?php echo apply_triage_grade() ? 1 : 0; ?>;
$(wrapper).on("click", ".remove_field", function(e) {
e.preventDefault();
$(this).parent('td').parent('tr').remove();
x--;
});
function add_symptom_row() {
if (x < max_rows) {
$(wrapper).append("<tr>\
<td style='width: 20%;'>\
<select name='symptoms[]' id='symptoms_" + x + "' class='form-control col-sm-12 compulsory' onchange='showPrompt(this.value, " + x + ")' required>@php echo $option_symptoms; @endphp</select>\
</td>\
<td style='width: 21%'>\
<div class='row'>\
<div class='col-sm-3'>\
<input type='text' style='display: block;' name='duration[]' id='symptoms_duration_" + x + "' class='col-sm-12 form-control' required>\
</div>\
<div class='col-sm-9'>\
<select style='display: inline-block;' name='time[]' id='symptoms_time_" + x + "' class='col-sm-12 form-control' required>@php echo $option_symptoms_periods; @endphp</select>\
</div>\
</div>\
</td>\
<td id='symptoms_prompt_" + x + "' style='width: 30%'></td>\
<td id='symptoms_reference_" + x + "'></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>");
generalSelect2Set('symptoms_' + x);
$("#symptoms_" + x).load('/symptoms/get_symptoms');
x++;
}
}
function generalSelect2Set(id) {
$('#' + id).select2({
width: "100%"
});
}
function showPrompt(symptom_id, id) {
if (symptom_id == "") {
return;
}
$.ajax({
method: 'POST',
url: '/triage/get_prompt',
data: {
'symptom_id': symptom_id
},
success: function(response) {
let returnText = response.split('&&&&');
$('#symptoms_prompt_' + id).html('<p style="color: #C85F6A;">' + returnText[0] + '</p>');
$('#symptoms_reference_' + id).html(returnText[1]);
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
}
function submitSymptom() {
var symptom_name = $("#symptom_name").val();
$.ajax({
method: 'POST',
url: '/triage/add_symptom',
data: {
'symptom_name': symptom_name
},
success: function(response) {
if (response == 1) {
//reload all dropdowns
$(".1000").load('/symptoms/get_symptoms');
alert(symptom_name + ' symptom has been added.');
$('#symptomsmodal').modal('hide');
} else {
alert("<?php echo __('triage.adding_symptom_failed'); ?>");
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
}
function submitReferral() {
var name = $("#referral_name").val();
$.ajax({
method: 'POST',
url: '/triage/add_referral',
data: {
'name': name
},
success: function(response) {
if (!isNaN(response)) {
//response = last inserted id
$('#referral_hospital').append($('<option>', {
value: response,
text: name
}));
$('#referral_hospital').val(response); //preselect the newly added referral
$('#referralsmodal').modal('hide'); //manually hide the modal
} else {
alert("<?php echo __('triage.adding_referral_failed'); ?>");
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
}
$("#submit_triage").click(function (e) { // make sure that all compulsory fields have been filled out
var empty_compulsory_fields = [];
var age = {{ $age }};
if($("#tb_questions_yes").is(':checked')){
$("#TBActionModal").modal("show");
$('#triage_grade').prop('required', false);
$('.compulsory').prop('required', false);
if(age == 1) $('[name=severe_bleeding], [name=weak_fast_pulse], [name=cyanosis], [name=stridor], [name=severe_distress], [name=refill], [name=coma], [name=convulsing_now], [name=lethargy]').removeAttr('required');
$('.clinic_allocation option:contains("TB Clinic")').prop('selected', true);
$("#clinic_allocation").val($('.clinic_allocation').val());//TB Clinic
$('#triage_grade_red').prop('checked',true); //triage grade set to red.
setTimeout(function () {
$("#triageForm").submit();
}, 5000);
} else {
$(".compulsory").each(function () {
if ($(this).val() == "") {
var textname = $(this).attr('name');
$(this).focus();
empty_compulsory_fields.push(textname);
$(this).css('border','1px solid #F08080');
}
});
let cons_attendance = <?php echo is_add_attendance_to_consultation_enabled() ? 1 : 0 ?>;
if(cons_attendance == 0 && !$('#new_attendance').is(':checked') && !$('#re_attendance').is(':checked')){
alert('Please fill in Patient attendance.');
e.preventDefault();
return false;
$('#new_attendance, #re_attendance').css('border','1px solid #F08080');
}
/* check if the array containing empty compulsory fields is not empty then return false */
if (empty_compulsory_fields.length != 0) {
alert("<?php echo __('triage.compulsory_fields_warning') ?>");
console.log(empty_compulsory_fields);
e.preventDefault();
return false;
}
}
});
$('#muac, #sao2, #pulse, #respirations, #temperature, #oedema, #convulsions, #severe_pallor, #respiratory_distress, #referral_hospital,' +
'#severe_distress_0, #parent_concern, #burns, #severe_pain, #continuously_irritable, #lethargy_0, #refill_0, #convulsing_now_0, #convulsing_now_1,' +
'#coma_0, #weak_fast_pulse_0, #cyanosis_0, #stridor_0, #severe_distress_1, #lethargy_1, #refill_1, #coma_1, #weak_fast_pulse_1, #cyanosis_1, #stridor_1'
).change(function() {
if (smart_triage_enabled == 0) {
return;
}
let triage_grade = 0; // 0 - green, 1 - yellow, 2 - red
let age = <?php echo $age_diff_months; ?>;
age = Math.sqrt(age);
let muac = $('#muac').val() * 10; // cm -> mm
let oxygen_saturation = $('#sao2').val();
if (oxygen_saturation == '') {
oxygen_saturation = 0;
}
let transformed_oxygen_saturation = (70.103 * Math.log10(101.687 - oxygen_saturation)) - 55.833;
let oedema = 0;
let pallor = 0;
let lethargy = 0;
let convulsing = 0;
let burns = 0;
let coma = 0;
let severe_pain = 0;
let weak_fast_pulse = 0;
let trauma = 0;
let refill = 0;
let continuously_irritable = 0;
let stridor = 0;
let cyanosis = 0;
let respiratory_distress_value = $('#respiratory_distress').val();
let respiratory_distress = 0;
let pulse_rate = +$('#pulse').val();
let respirations = +$('#respirations').val();
let temperature = +$('#temperature').val();
let parent_concern = 0;
let smart_triage_factors =
"<li>Age (older)</li><li>Pulse Rate (higher)</li><li>Temperature (higher)</li>" +
"<li>MUAC (smaller)</li>";
let main_factor = "";
let parent_concern_value = $('#parent_concern').val();
if (muac == 0 || muac == '' || pulse_rate == 0 || pulse_rate == '' || respirations == 0 ||
oxygen_saturation == '' ||
respirations == '' || temperature == 0 || temperature == '' || respiratory_distress_value == 0 ||
respiratory_distress_value == '' || parent_concern_value == '') {
return;
}
if ($('#oedema').is(":checked")) {
oedema = 1;
smart_triage_factors += "<li>Oedema</li>";
}
if ($('#severe_pallor').is(":checked")) {
pallor = 1;
smart_triage_factors += "<li>Severe Pallor</li>";
}
if (respiratory_distress_value === 'Severe' || $('#severe_distress_0').is(":checked")) {
respiratory_distress = 1;
smart_triage_factors += "<li>Severe Respiratory Distress</li>";
}
if (!parent_concern_value.includes('not') && parent_concern_value != '') {
parent_concern = 1;
smart_triage_factors += "<li>Parent concern</li>";
}
if (transformed_oxygen_saturation < 0) {
transformed_oxygen_saturation = 0;
} else {
smart_triage_factors += "<li>Sa02 (lower)</li>";
}
let linear_predictor = -32.888 + (0.252 * age) + (0.016 * pulse_rate) + (0.819 * temperature) +
(-0.022 * muac) + (0.048 * transformed_oxygen_saturation) + (1.793 * parent_concern) +
(1.012 * respiratory_distress) + (1.814 * oedema) + (1.506 * pallor);
let risk_score = 1 / (1 + Math.exp(-linear_predictor));
if (!isNaN(risk_score)) {
if (risk_score > 0.08 && risk_score <= 0.4) {
// yellow
triage_grade = 1;
} else if (risk_score > 0.4) {
// red
triage_grade = 2;
}
let percentage_risk_score = Math.ceil(risk_score * 100);
if ($('#cyanosis_0').is(":checked")) {
triage_grade = 2;
cyanosis = 1;
main_factor = "Cyanosis";
}
if ($('#stridor_0').is(":checked")) {
triage_grade = 2;
stridor = 1;
main_factor = "Stridor / obstructed breathing/ choking";
}
if ($('#refill_0').is(":checked")) {
triage_grade = 2;
refill = 1;
main_factor = "Capillary refill > 3 seconds";
}
if ($('#weak_fast_pulse_0').is(":checked")) {
triage_grade = 2;
weak_fast_pulse = 1;
main_factor = "Weak/fast pulse";
}
if ($('#coma_0').is(":checked")) {
triage_grade = 2;
coma = 1;
main_factor = "Coma";
}
if ($('#convulsing_now_0').is(":checked")) {
triage_grade = 2;
convulsing = 1;
main_factor = "Convulsing Now";
}
if ($('#lethargy_0').is(":checked")) {
triage_grade = 2;
lethargy = 1;
main_factor = "Diarrhoea with Lethargy, sunken eyes or very slow skin pinch";
}
if (oxygen_saturation < 90) {
triage_grade = 2;
main_factor = "SaO2 (%) below 90%";
//smart_triage_factors += "<li>Sa02 below 90%</li>";
}
if (pulse_rate < 45) {
triage_grade = 2;
main_factor = "Pulse below 45 BPM";
}
if ($('#convulsions').val() === 'Convulsing') {
triage_grade = 2;
convulsing = 1;
main_factor = "Patient convulsing now";
}
if (triage_grade !== 2) {
if ($('#burns').is(":checked")) {
triage_grade = 1;
burns = 1;
}
if ($('#trauma').is(":checked")) {
triage_grade = 1;
trauma = 1;
}
if ($('#severe_pain').is(":checked")) {
triage_grade = 1;
severe_pain = 1;
}
if ($('#continuously_irritable').is(":checked")) {
triage_grade = 1;
continuously_irritable = 1;
}
if ($('#severe_distress_0').is(":checked")) {
triage_grade = 1;
}
if (temperature < 35) {
triage_grade = 1;
main_factor = "Temperature below 35";
}
if (temperature > 40) {
triage_grade = 1;
main_factor = "Temperature above 40";
}
if (respirations > 60) {
triage_grade = 1;
main_factor = "Respirations above 60";
}
if (respiratory_distress_value === 'Severe') {
triage_grade = 1;
main_factor = "Severe Respiratory Distress";
}
if ($('#convulsions').val() === 'Frequent Reported') {
triage_grade = 1;
}
if ($('#referral_hospital').val() != 1) {
triage_grade = 1;
}
}
smart_triage_variables = {
'age': age,
'pulse_rate': pulse_rate,
'temperature': temperature,
'muac': muac,
'respiratory_distress': respiratory_distress,
'parent_concern': parent_concern,
'transformed_oxygen_saturation': transformed_oxygen_saturation,
'oedema': oedema,
'pallor': pallor,
'risk_score': risk_score,
'linear_predictor': linear_predictor,
'triage_grade': triage_grade,
'oxygen_saturation': oxygen_saturation,
'respirations_rate': respirations,
'burns': burns,
'severe_pain': severe_pain,
'trauma': trauma,
'continously_irritable': continuously_irritable,
'lethargy': lethargy,
'convulsing': convulsing,
'coma': coma,
'weak_fast_pulse': weak_fast_pulse,
'refill': refill,
'stridor': stridor,
'cyanosis': cyanosis
}
if (triage_grade === 1) {
$('#smart_triage_label').html("<b>Priority (Yellow)</b>");
$("#smart_triage_image").attr("src", "/uploads/streamline_images/priority.png");
} else if (triage_grade === 2) {
$('#smart_triage_label').html("<b>Emergency (Red)</b>");
$("#smart_triage_image").attr("src", "/uploads/streamline_images/emergency.png");
} else {
$('#smart_triage_label').html("<b>Non-Urgent (Green)</b>");
$("#smart_triage_image").attr("src", "/uploads/streamline_images/nonurgent.png");
}
if (apply_triage_grade != 0) {
if (triage_grade === 1) {
$('#triage_grade_yellow').click();
} else if (triage_grade === 2) {
$('#triage_grade_red').click();
} else {
$('#triage_grade_green').click();
}
}
$('#smart_triage_factors').html(smart_triage_factors);
$('#smart_triage_score').text("Smart Triage Risk Score: " + percentage_risk_score + "%");
$('#smart_triage_score_info').html("<b>Smart Triage Risk Score: " + percentage_risk_score +
"%</b>");
if (main_factor !== '') {
$('#smart_triage_complaint').text("Main Factor: " + main_factor);
} else {
$('#smart_triage_complaint').text("");
}
$('#smart_triage_div').show();
} else {
$('#smart_triage_div').hide();
}
});
$('#triage_grade_red, #triage_grade_yellow, #triage_grade_green').change(function() {
if (smart_triage_enabled == 0) {
return;
}
let selected_triage_grade = 0;
let patient_id = $('#patient_id').val();
let episode_id = $('#episode_id').val();
if ($('#triage_grade_red').is(":checked")) {
selected_triage_grade = 2;
} else if ($('#triage_grade_yellow').is(":checked")) {
selected_triage_grade = 1;
}
smart_triage_variables["patient_id"] = patient_id;
smart_triage_variables["episode_id"] = episode_id;
smart_triage_variables["selected_triage_grade"] = selected_triage_grade;
$.ajax({
method: 'POST',
url: '/triage/save_smart_triage_score',
data: smart_triage_variables,
success: function(response) {
//
}
});
});
function get_nutritional_status() {
let age_diff_months = $("#age_diff_months").val();
let weight = $("#weight").val();
let height = $("#height").val();
let bmi = $("#bmi").val();
let gender = $("#gender").val();
let patient_id = $('#patient_id').val();
let episode_id = $('#episode_id').val();
let muac = $('#muac').val();
let oedema = 0;
if ($('#oedema').is(":checked")) {
oedema = 1;
}
$.ajax({
method: 'GET',
url: '/triage/get_nutrition_status',
data: {
'bmi': bmi,
'height': height,
'weight': weight,
'age_diff_months': age_diff_months,
'gender': gender,
'patient_id': patient_id,
'episode_id': episode_id,
'muac': muac,
'oedema': oedema
},
success: function(response) {
if (response !== "0") {
let split_response = response.split('&&&&');
$('#nutritional_status_text').text(split_response[0]).css('color', split_response[2]);
$('#nutritional_status_reason').text(split_response[1]).css('color', split_response[2]);
$('#nutritional_status_div').show();
}
}
});
}
$('#oedema, #muac').change(function() {
get_nutritional_status();
});
function show_proven_infection_questions() {
$('.proven_infection_questions').show();
}
function hide_proven_infection_questions() {
$('.proven_infection_questions').hide();
}
$(document).ready(function() {
$('.select-2').select2({
width: "100%"
});
generalSelect2Set("symptoms_0");
$("#child_feeling_unsafe_section").hide();
$("#tested_for_hiv_last_3_months_section").hide();
$(".hiv_positive_section").hide();
});
function hide_tested_for_hiv_last_3_months_questions() {
$("#tested_for_hiv_last_3_months_section").hide();
}
function show_tested_for_hiv_last_3_months_questions() {
$("#tested_for_hiv_last_3_months_section").show();
}
function show_feeling_unsafe_questions() {
$('#child_feeling_unsafe_section').show();
}
function hide_feeling_unsafe_questions() {
$('#child_feeling_unsafe_section').hide();
}
function show_hiv_positive_questions() {
$(".hiv_positive_section").show();
}
function hide_hiv_positive_questions() {
$(".hiv_positive_section").hide();
}
// below 15
$('input[type=radio][name=mother_hiv_positive]').change(function() {
if (this.value == '1') {
$('.child-hiv-status').removeClass('d-none').css('display', '');
$('.child-hiv-status-questions').removeClass('d-none').css('display', '');
} else if (this.value == '0') {
$('.child-hiv-status').addClass('d-none').css('display', 'none');
$('.child-hiv-status-questions').addClass('d-none').css('display', 'none');
$('.child-hiv-status-questions input[type=radio]').each(function() {
this.value('');
})
}
});
</script>
@endpush