Files

276 lines
15 KiB
PHP
Executable File

@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/icheck/skins/all.css') }}" rel="stylesheet">
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
@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">{{ __('diagnoses.edit_diagnosis') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('diagnoses.dashboard') }}</a></li>
<li><a href="{{ route('diagnoses.index') }}">{{ __('diagnoses.diagnosis') }}</a></li>
<li class="active">{{ __('diagnoses.edit') }}</li>
</ol>
</div>
</div>
@include('clinical_data::diagnoses.menu')
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
{{ Form::model($diagnosis, ['method' => 'PUT', 'route' => ['diagnoses.update',$diagnosis], 'data-toggle' => 'validator']) }}
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('name', __('diagnoses.diagnosis_name')) }}
{{ Form::text('name', $diagnosis->name, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
@if (!empty($errors->get('name')))
<div class="help-block with-errors alert alert-danger">
@foreach ($errors->get('name') as $message)
{{ $message }}
@endforeach
</div>
@endif
</div>
<div class="form-group">
{{ Form::label('icd10_code', __('diagnoses.icd_10_code')) }}
{{ Form::text('icd10_code', $diagnosis->icd10_code, ['class' => 'form-control']) }}
</div>
<p> HMIS Outpatient Report (105) </p>
<div class="form-group">
{{ Form::label('outpatient_hmis_category', __('diagnoses.outpatient_hmis_category')) }}
{{ Form::select('outpatient_hmis_category', $outpatient_hmis_categories, $diagnosis->outpatient_hmis_category?? '', ['class' => 'form-control compulsory', 'id'=>'outpatient_hmis_category', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('outpatient_hmis_category_option', __('diagnoses.hmis_outpatient_category')) }}
{{ Form::select('outpatient_hmis_category_option', $outpatient_category_options, $diagnosis->outpatient_hmis_category_option?? '', ['class'=>'form-control', 'id'=>'outpatient_hmis_category_option', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group" id="outpatient_parent_dependent_option">
{{ Form::label('outpatient_dependent_option', 'Outpatient Dependent Option') }}
{{ Form::select('outpatient_dependent_option', $outpatient_dependent_options, $diagnosis->outpatient_dependent_option?? '', ['class'=>'form-control', 'id'=>'outpatient_dependent_option']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group" id="outpatient_district_code" style="display: none">
{{ Form::label('district_code', 'District Disease Code') }}
@php
$district_code = \Streamline\Models\HmisCategoryOptions::find($diagnosis->outpatient_dependent_option);
@endphp
{{ Form::text('district_code', $district_code->name?? '', ['class' => 'form-control', 'id'=>'district_code']) }}
{{ Form::hidden('district_code_id', $district_code->id?? '') }}
<div class="help-block with-errors"></div>
</div>
<p> HMIS Inpatient Report (108) </p>
<div class="form-group">
{{ Form::label('hmis_category', __('diagnoses.hmis_category')) }}
{{ Form::select('hmis_category', $inpatient_hmis_categories, $diagnosis->hmis_category, ['class' => 'form-control compulsory', 'id'=>'hmis_category_inpatient', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('hmis_no_inpatient', __('diagnoses.hmis_inpatient_category')) }}
{{ Form::select('hmis_no_inpatient', $inpatient_category_options, $diagnosis->hmis_no_inpatient?? '', ['class'=>'form-control', 'id'=>'hmis_category_inpatient_options', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group" id="dependent_option">
{{ Form::label('dependent_option', 'Dependent Option') }}
{{ Form::select('parent_dependent_option', $dependent_options, $diagnosis->dependent_option, ['class'=>'form-control', 'id'=>'parent_dependent_option']) }}
<div class="help-block with-errors"></div>
</div>
@if(is_chi_enabled())
<div class="form-group" id="drugs_dropdown">
{{ Form::label('insurance_tariffs', 'Insurance Tariffs') }}
{{ Form::select('insurance_tariffs[]', $insurance_tariffs, explode(",", $diagnosis->insurance_tariffs),['id'=>'insurance_tariffs', 'multiple', 'class' => 'form-control']) }}
</div>
@endif
</div>
<div class="col-md-6">
<div class="form-group">
{{ Form::label('prompts', __('diagnoses.diagnosis_prompt')) }}
{{ Form::textArea('prompts', $diagnosis->prompts, ['class'=>'form-control', 'rows' => 5]) }}
</div>
<div class="form-group">
{{ Form::label('', __('diagnoses.chronic_status'), ["class"=>'col-md-12']) }}
&nbsp;{{ __('diagnoses.yes') }} {{ Form::radio('chronic_status', 1, ($diagnosis->chronic_status) ? true : false, ["required", 'class' => 'check form-control', 'data-radio'=>'iradio_flat-green']) }}
&nbsp;{{ __('diagnoses.no') }} {{ Form::radio('chronic_status', 0, ($diagnosis->chronic_status) ? false : true, ["required", 'class' => 'check form-control', 'data-radio'=>'iradio_flat-green']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('available', __('diagnoses.is_diagnosis_available'), ["class"=>'col-md-12']) }}
&nbsp;{{ __('diagnoses.yes') }} {{ Form::radio('available', 1, $diagnosis->available == 1, ["required", 'class' => 'check form-control', 'data-radio'=>'iradio_flat-green']) }}
&nbsp;{{ __('diagnoses.no') }} {{ Form::radio('available', 0, $diagnosis->available == 0, ["required", 'class' => 'check form-control', 'data-radio'=>'iradio_flat-green']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('diagnosis_category', __('diagnoses.diagnosis_category')) }}
{{ Form::select('diagnosis_category', $diagnosis_categories, $diagnosis->diagnosis_category, ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('reference_areas', __('diagnoses.reference_areas')) }}
<?php
$reference_areas_array = array_filter(explode(",", $diagnosis->reference_areas));
$reference_names_array = array_filter(explode(",", $diagnosis->reference_names));
?>
@for ($x = 0; $x < count($reference_areas_array); $x++)
<div class="row input_fields_wrap copy" id="copy">
<br><br>
<div class="col-md-5">
{{ Form::text('reference_names[]', $reference_names_array ? $reference_names_array[$x] : '', ['class' => 'form-control', 'placeholder' => 'Reference name']) }}
</div>
<div class="col-md-6">
{{ Form::text('reference_areas[]', $reference_areas_array ? $reference_areas_array[$x] : '', ['class' => 'form-control', 'placeholder' => 'e.g. http://google.com']) }}
</div>
@if ($x > 0)
<a href="#" class="remove_field" style="color: maroon"><sup>X</sup></a>
@endif
</div>
@endfor
</div>
<a class="add_field btn btn-primary">{{ __('diagnoses.add_more')}}</a>
</div>
</div>
{{ Form::button(__('diagnoses.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
{{ Form::button(__('diagnoses.cancel'),['type'=>'reset','class'=>'btn btn-default waves-effect waves-light']) }}
{{ Form::close() }}
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script src="{{ asset('js/diagnosis/create.js') }}"></script>
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- icheck -->
<script src="{{ asset('elite/bower_components/icheck/icheck.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/icheck/icheck.init.js') }}"></script>
<script>
$('#insurance_tariffs').select2({
placeholder: "Select",
width: "100%"
});
$('#hmis_category_inpatient_options, #hmis_category_inpatient, #parent_dependent_option, #outpatient_hmis_category, #outpatient_hmis_category_option, #outpatient_dependent_option').select2();
var show = {!! json_encode($diagnosis->dependent_option) !!};
if(show == null) $('#dependent_option').hide();
var show2 = {!! json_encode($diagnosis->outpatient_dependent_option) !!};
var show3 = {!! json_encode($diagnosis->outpatient_hmis_category_option) !!};
console.log(show3);
if(show2 == null || show3 == '655') $('#outpatient_parent_dependent_option').hide();
if(show3 == '655') $('#outpatient_district_code').show();
$('#hmis_category_inpatient_options').change(function(e) {
var parent_id = $('#hmis_category_inpatient_options').val();
var div = 'parent_dependent_option';
const parents = Object.values(@json($parent_categories));
// console.log(parents.findIndex(check_options));
if (parents.findIndex(check_options) !== -1) {
dependent_category_options(parent_id, div);
$('#dependent_option').show();
}else if ($('#dependent_option').is(':visible')) {
$('#dependent_option').hide();
$('#parent_dependent_option').prop('selectedIndex',0);
$('#parent_dependent_option').prop('required',false);
}
});
$('#outpatient_hmis_category_option').change(function(){
var option = $('#outpatient_hmis_category_option').val();
var div = 'outpatient_dependent_option';
const parent_options = Object.values(@json($parent_categories));
if(option == '655'){
$('#outpatient_district_code').show();
$('#district_code').addClass('compulsory');
$('#district_code').prop('required', true);
}else{
if($('#district_code').is(':visible')) $('#district_code').val('');
if (parent_options.findIndex(check_option) !== -1) {
dependent_category_options(option, div);
$('#outpatient_parent_dependent_option').show();
}else if ($('#outpatient_parent_dependent_option').is(':visible')) {
$('#outpatient_parent_dependent_option').hide();
$('#outpatient_dependent_option').prop('selectedIndex',0);
$('#outpatient_dependent_option').prop('required',false);
}else if ($('#outpatient_district_code').is(':visible')) {
$('#district_code').prop('required', false);
$('#district_code').removeClass('compulsory');
$('#outpatient_district_code').hide();
}
}
});
function check_options(parent_id) {
return parent_id == $('#hmis_category_inpatient_options').val();
}
function check_option(parent_id) {
return parent_id == $('#outpatient_hmis_category_option').val();
}
$('#hmis_category_inpatient').change(function(e) {
category_options('hmis_category_inpatient');
});
$('#outpatient_hmis_category').change(function(e) {
category_options('outpatient_hmis_category');
});
function category_options(data){
let category = $('#'+data).val();
$.ajax({
type: "POST",
url: "/get_hmis_categories_options",
data: {hmis_category: category},
cache: false,
success: function (response) {
if(response == 'false'){
alert("<?php echo __('procedures.failed_options'); ?>");
} else {
var option = (data == 'hmis_category_inpatient')? 'hmis_category_inpatient_options':'outpatient_hmis_category_option';
$('#'+option).html(response);
}
}
});
}
function dependent_category_options(option, div){
let category = option;
$.ajax({
type: "POST",
url: "/get_dependent_hmis_category_options",
data: {parent_category: category},
cache: false,
success: function (response) {
if(response == 'false'){
alert("<?php echo __('procedures.failed_options'); ?>");
} else {
$('#' + div).html(response);
$('#' + div).prop('required',true);
}
}
});
}
</script>
@endpush