513 lines
28 KiB
PHP
513 lines
28 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => "Form"])
|
|
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
|
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<div id="pageloader">
|
|
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
|
</div>
|
|
<body class="loading">
|
|
<div class="account-pages">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
|
|
<div class="card bg-pattern">
|
|
<div class="card-body p-3 row">
|
|
|
|
@if(Session::has('error'))<div class="alert alert-danger">{{Session::get('error')}}</div>
|
|
<br>@endif
|
|
@if(session('success'))<div class=" alert alert-success">{{ session('success') }}
|
|
</div>
|
|
<br>@endif
|
|
<div class="col-8">
|
|
<h4 class="page-title">{{$form->title}}</h4>
|
|
</div>
|
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
|
<div class="col-4">
|
|
@if($form->link_type == 'form')
|
|
<a href="/form/history" class="float-end pt-1">View History</a>
|
|
@else
|
|
<a href="{{url()->previous()}}" class="float-end pt-1">Back</a>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
@if(isset($form->user_info))
|
|
<div class="col-12">
|
|
<h6>Submitted By: {{$form->user_info->name}}</h6>
|
|
</div>
|
|
@endif
|
|
<div class="form-container" id="form_score_questions">
|
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
|
<input type="hidden" name="form_id" value="{{$form_id}}">
|
|
@csrf
|
|
@if($id)
|
|
<input type="hidden" name="id" value="{{$id}}">
|
|
@endif
|
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
|
<div class="col-md-12 mb-2">
|
|
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
|
|
<select class="form-control" id="field-user_id" name="user_id" required>
|
|
<option value=""> -- Select -- </option>
|
|
@foreach($form->users as $option)
|
|
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
|
@endforeach
|
|
</select>
|
|
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
|
</div>
|
|
@endif
|
|
|
|
@foreach($questions as $question)
|
|
@if($question->code == "q1_sneezing")
|
|
<div class="py-2">
|
|
<label class="form-label">In the past 12 months, have you had a problem apart from cold or flu?</label>
|
|
</div>
|
|
@endif
|
|
<div class="col-md-12 mb-2">
|
|
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!} </label>
|
|
|
|
@switch($question->type)
|
|
@case('hidden')
|
|
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
|
@break
|
|
@case('text')
|
|
@case('email')
|
|
@case('tel')
|
|
@case('date')
|
|
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
|
|
@break
|
|
@case('number')
|
|
<input type="{{$question->type}}" min="0" max="9999999999" step="1" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
|
@break
|
|
@case('textarea')
|
|
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
|
@break
|
|
@case('dropdown')
|
|
<select class="form-control" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
|
|
<option value=""> -- Select -- </option>
|
|
@foreach($question->options as $option)
|
|
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
|
@endforeach
|
|
</select>
|
|
@break
|
|
@case('checkbox')
|
|
<div class="d-flex align-items-center flex-wrap">
|
|
@foreach($question->options as $option)
|
|
<div class="form-check mb-2 form-check-primary me-2">
|
|
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
|
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@break
|
|
@case('radio')
|
|
<div class="d-flex align-items-center flex-wrap">
|
|
@foreach($question->options as $option)
|
|
<div class="form-check mb-2 form-check-primary me-2">
|
|
<input class="form-check-input" type="radio" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
|
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@break
|
|
@case('file')
|
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
|
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" {{$question->required == 'yes'?'required':'' }}>
|
|
@elseif(isset($question->value))
|
|
<img src="{{$question->value}}" class="img-fluid">
|
|
@endif
|
|
|
|
@break
|
|
@case('multitextbox')
|
|
<div class="row">
|
|
@foreach($question->options as $option)
|
|
<div class="col-6">{{$option->display}}</div>
|
|
<div class="col-6 mb-1">
|
|
<input type="number" id="field-{{$option->value}}" name="{{$option->value}}" class="form-control" required value="{{isset($option->val)?$option->val:0}}">
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@break
|
|
@endswitch
|
|
|
|
</div>
|
|
@endforeach
|
|
|
|
<div id="form_error" class="p-2 py-1 bg-danger text-white rounded-1">Please select all fields before submitting!</div>
|
|
|
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
|
<div class="text-center d-grid mt-3">
|
|
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
|
</div>
|
|
@endif
|
|
</form>
|
|
</div>
|
|
<div class="score-container py-2" id="score_container">
|
|
<div class="score-content" id="score_content">
|
|
<h5 class="mb-3">Score for Allergic Rhinitis:</h5>
|
|
|
|
<div class="p-2 mb-3 d-flex align-items-center bg-light" style="color:#343a40;">
|
|
<div class="fw-bold">Patient Name: </div>
|
|
<div class="ps-1" id="pname">User</div>
|
|
</div>
|
|
|
|
<table class="table table-hover table-bordered">
|
|
<thead class="table-light" style="vertical-align: top;">
|
|
<tr>
|
|
<th>Description</th>
|
|
<th class="text-center">Your Score</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>Nasal symptoms (blocked, runny nose, and or sneezing) in the past year</td>
|
|
<td id="result_row1" class="text-center">3</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Months of the year</td>
|
|
<td id="result_row2" class="text-center">4</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Itchy eyes</td>
|
|
<td id="result_row3" class="text-center">6</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Triggers</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Pollens, house-dust mites, and / or dust</td>
|
|
<td id="result_row4" class="text-center">8</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Epithelia (cats and /or dogs)</td>
|
|
<td id="result_row5" class="text-center">9</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Perceived allergic status</td>
|
|
<td id="result_row6" class="text-center">11</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Previous positive allergic tests</td>
|
|
<td id="result_row7" class="text-center">13</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Previous medical diagnosis of allergy</td>
|
|
<td id="result_row8" class="text-center">14</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Familial history of allergy</td>
|
|
<td id="result_row9" class="text-center">16</td>
|
|
</tr>
|
|
</tbody>
|
|
<tfoot class="table-light fw-bold">
|
|
<tr>
|
|
<td>TOTAL: </td>
|
|
<td id="result_row_total" class="text-center">16</td>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-center pt-2">
|
|
<button type="button" id="download_result_btn" class="btn btn-success">
|
|
Download Result
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
</div> <!-- end card-body -->
|
|
</div>
|
|
<!-- end card -->
|
|
|
|
<!-- end row -->
|
|
|
|
</div> <!-- end col -->
|
|
</div>
|
|
<!-- end row -->
|
|
</div>
|
|
<!-- end container -->
|
|
</div>
|
|
<!-- end page -->
|
|
<style type="text/css">
|
|
#pageloader {
|
|
background: rgba( 255, 255, 255, 0.8 );
|
|
display: none;
|
|
height: 100%;
|
|
position: fixed;
|
|
width: 100%;
|
|
z-index: 9999;
|
|
}
|
|
|
|
#pageloader img {
|
|
left: 50%;
|
|
margin-left: -32px;
|
|
margin-top: -32px;
|
|
position: absolute;
|
|
top: 50%;
|
|
}
|
|
</style>
|
|
@include('layouts.shared/footer-script')
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js" integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
|
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
$('#field-user_id').change(function(){
|
|
let hierarchy = $('option:selected', this).attr('hierarchy');
|
|
$('#field-hierarchy_id').val(hierarchy)
|
|
event.preventDefault();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function( data ) {
|
|
$("#pageloader").fadeOut();
|
|
$('#field-contact_id').html('')
|
|
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
|
for(let itm of data) {
|
|
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display));
|
|
}
|
|
},
|
|
});
|
|
|
|
console.log(hierarchy)
|
|
})
|
|
|
|
//form container
|
|
const form_container = $('#form_score_questions');
|
|
// result / score container
|
|
const score_container = $('#score_container');
|
|
|
|
//At first hide result container
|
|
$(score_container).fadeOut(50);
|
|
$(form_container).fadeIn(50);
|
|
$('#form_error').fadeOut(50);
|
|
|
|
$('#report-form').on('submit', function(event){
|
|
event.preventDefault();
|
|
// console.log("report-form executed...", event.target.nose_problem_occur.value)
|
|
|
|
console.log("report-form executed event...", event)
|
|
$("#pageloader").fadeIn();
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/form/ajaxsubmit',
|
|
data: new FormData($('#report-form')[0]),
|
|
processData: false,
|
|
contentType: false,
|
|
success: function( data ) {
|
|
$("#pageloader").fadeOut();
|
|
if(data.status == 'success') {
|
|
Swal.fire({
|
|
title: 'Great!',
|
|
text: 'Your data is successfully submitted!',
|
|
icon: 'success'
|
|
})
|
|
$('#report-form').trigger("reset");
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
});
|
|
|
|
//Form controls
|
|
console.log("Form submitted = ",)
|
|
|
|
//Score calculation
|
|
let form_obj = event.target;
|
|
let dr_name = "";
|
|
let patient_name = "";
|
|
let mobile_no = "";
|
|
let gender = "";
|
|
let age = "";
|
|
let place = "";
|
|
let state = "";
|
|
let q1_option1_val = "";
|
|
let q1_option2_val = ""
|
|
let q1_option3_val = "";
|
|
let itchy_eyes_val = "";
|
|
let month_val = [];
|
|
let alternate_season_val = "";
|
|
let triggering_val = [];
|
|
let allergic_val = "";
|
|
let allergy_tested = "";
|
|
let isPositive = "";
|
|
let isDiagnosed = "";
|
|
let family = [];
|
|
let isAsthma = "";
|
|
let isEczema = "";
|
|
let isRhinitis = "";
|
|
let isFormValid = false;
|
|
|
|
let new_month_values = $("input[name='nose_problem_occur[]']:checked").map(function(){
|
|
return $(this).val();
|
|
}).get();
|
|
console.log("new_month_values = ",new_month_values)
|
|
|
|
let new_triggering_val = $("input[name='nose_problem[]']:checked").map(function(){
|
|
return $(this).val();
|
|
}).get();
|
|
console.log("new_triggering_val = ",new_triggering_val)
|
|
|
|
let new_family = $("input[name='family_who_suffers[]']:checked").map(function(){
|
|
return $(this).val();
|
|
}).get();
|
|
console.log("new_family = ",new_family)
|
|
|
|
|
|
|
|
//check form is valid or not
|
|
// if(form_obj.patient_name !== "" && form_obj.q1_sneezing.value !== "" && form_obj.q1_runny_nose.value !== "" && form_obj.q1_blocked_nose.value !== "" && form_obj.itchy_watery_eyes.value !== "" && (new_month_values.length > 0 || form_obj.q_alternatively.value !== "") && new_triggering_val.length > 0 && form_obj.think_you_are_allergic.value !== "" && (form_obj.tested_for_allergy.value !== "" && form_obj.were_positive.value) && form_obj.already_diagnosed.value !== "" && new_family.length > 0 && form_obj.asthma.value !== "" && form_obj.eczema.value !== "" && form_obj.allergic_rhinitis.value !== "") {
|
|
// patient_name = form_obj.patient_name.value;
|
|
// mobile_no = form_obj.mobile_no.value;
|
|
// gender = form_obj.gender.value;
|
|
// age = form_obj.age.value;
|
|
q1_option1_val = form_obj.q1_sneezing.value;
|
|
q1_option2_val = form_obj.q1_runny_nose.value;
|
|
q1_option3_val = form_obj.q1_blocked_nose.value;
|
|
itchy_eyes_val = form_obj.itchy_watery_eyes.value;
|
|
month_val = new_month_values;
|
|
alternate_season_val = form_obj.q_alternatively.value
|
|
triggering_val = new_triggering_val;
|
|
allergic_val = form_obj.think_you_are_allergic.value;
|
|
allergy_tested = form_obj.tested_for_allergy.value;
|
|
isPositive = form_obj.were_positive.value;
|
|
isDiagnosed = form_obj.already_diagnosed.value;
|
|
family = new_family;
|
|
isAsthma = form_obj.asthma.value;
|
|
isEczema = form_obj.eczema.value;
|
|
isRhinitis = form_obj.allergic_rhinitis.value
|
|
|
|
//set isFormvalid to true
|
|
isFormValid = true;
|
|
|
|
console.log("FORM is valid", isFormValid);
|
|
|
|
// } else {
|
|
// isFormValid = false;
|
|
// console.log("FORM is Invalid", isFormValid);
|
|
// }
|
|
|
|
//Calculate Score
|
|
let tot_q1_score = 0;
|
|
if(q1_option1_val && q1_option2_val && q1_option3_val) {
|
|
let val1 = 0;
|
|
let val2 = 0;
|
|
let val3 = 0;
|
|
if(q1_option1_val === 'yes') {
|
|
val1 = 1;
|
|
}
|
|
if(q1_option2_val === 'yes') {
|
|
val2 = 1;
|
|
}
|
|
if(q1_option3_val === 'yes') {
|
|
val3 = 1;
|
|
}
|
|
tot_q1_score = val1 + val2 + val3;
|
|
}
|
|
|
|
let month_of_year_score = month_val.length > 0 || alternate_season_val !== "" ? 1 : 0;
|
|
let itchy_eyes_score = itchy_eyes_val === 'yes' ? 2 : 0;
|
|
let triggering_epithelia_score = triggering_val.includes('animals') ? 1 : 0;
|
|
let triggering_others_score = triggering_val.includes('animals') ? triggering_val.length - 1 : triggering_val.length;
|
|
let perceived_allergic_status_score = allergic_val === 'yes' ? 2 : 0;
|
|
let previous_positive_allergic_tests = (allergy_tested === 'yes' && isPositive === 'yes') ? 2 : 0;
|
|
let previous_medical_diagnosis = isDiagnosed === 'yes' ? 1 : 0;
|
|
let family_score = 0;
|
|
|
|
if(family.length > 0) {
|
|
family_score = (isAsthma === 'yes' || isEczema === 'yes' || isRhinitis === 'yes') ? 1 : 0
|
|
}
|
|
|
|
let total_result_score = tot_q1_score + month_of_year_score + itchy_eyes_score + triggering_epithelia_score + triggering_others_score + perceived_allergic_status_score + previous_positive_allergic_tests + previous_medical_diagnosis + family_score;
|
|
|
|
|
|
console.log("Before setTimeout isFormValid = ", isFormValid);
|
|
|
|
//Simulation of Form submission
|
|
setTimeout(() => {
|
|
// isFormValid = true
|
|
$("#pageloader").fadeOut();
|
|
if(isFormValid) {
|
|
$(form_container).fadeOut(200);
|
|
$('#pname').parent().removeClass('d-none');
|
|
if (patient_name !== "") {
|
|
$('#pname').html(patient_name);
|
|
} else {
|
|
let parent = $('#pname').parent();
|
|
console.log("Parent = ",parent)
|
|
$('#pname').parent().addClass('d-none');
|
|
}
|
|
$('#result_row1').html(tot_q1_score)
|
|
$('#result_row2').html(month_of_year_score)
|
|
$('#result_row3').html(itchy_eyes_score)
|
|
$('#result_row4').html(triggering_others_score)
|
|
$('#result_row5').html(triggering_epithelia_score)
|
|
$('#result_row6').html(perceived_allergic_status_score)
|
|
$('#result_row7').html(previous_positive_allergic_tests)
|
|
$('#result_row8').html(previous_medical_diagnosis)
|
|
$('#result_row9').html(family_score)
|
|
$('#result_row_total').html(total_result_score);
|
|
$('#form_error').fadeOut(100);
|
|
$(score_container).fadeIn(400);
|
|
|
|
} else {
|
|
$(form_container).fadeIn(200);
|
|
$(score_container).fadeOut(50);
|
|
$('#form_error').fadeIn(100);
|
|
}
|
|
|
|
}, 1000)
|
|
|
|
|
|
|
|
});
|
|
|
|
//add click handler for download result button
|
|
let download_btn = document.getElementById('download_result_btn');
|
|
$(download_btn).on('click', function(e) {
|
|
console.log("download_btn clicked = ",e)
|
|
let element = document.getElementById('score_content');;
|
|
console.log("Element = ",element)
|
|
let pdf_file_name = `generated-score-${(new Date().toJSON().slice(0,10))}.pdf`;
|
|
//Option..
|
|
let opt = {
|
|
margin: [40, 40],
|
|
filename: pdf_file_name,
|
|
pagebreak: { mode: ['avoid-all', 'css', 'legacy'] },
|
|
image: { type: 'png', quality: 0.98 },
|
|
html2canvas: { scrollX: 0, scrollY: 0, dpi: 300,
|
|
letterRendering: true, },
|
|
jsPDF: {
|
|
// unit: 'px', hotfixes: ["px_scaling"],
|
|
format: "a4",
|
|
orientation: "p",
|
|
}
|
|
};
|
|
//Call html2pdf
|
|
html2pdf(element, opt);
|
|
console.log("Executed after html2pdf calledd...")
|
|
})
|
|
|
|
var today =new Date();
|
|
var dd = String(today.getDate()).padStart(2, '0');
|
|
var mm = String(today.getMonth() + 1).padStart(2, '0');
|
|
var yyyy = today.getFullYear();
|
|
today = yyyy + '-' + mm + '-' + dd;
|
|
|
|
var plandateField = document.getElementById('field-record_date');
|
|
|
|
plandateField.setAttribute('max', today);
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |