first commit
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
function clear_form(){
|
||||
$('#telephone').val('');
|
||||
$('#fio').val('');
|
||||
$('#dob').val('');
|
||||
$('#sex').val('');
|
||||
$('#complaints_input').val('');
|
||||
$('#anamnesis_input').val('');
|
||||
$('#short_endo_history').empty();
|
||||
$('#email').val('');
|
||||
$('#file_input').val(null);
|
||||
$('#imgs_preview').empty();
|
||||
}
|
||||
|
||||
function previewIMG(input, preview) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
$(preview).attr('src', e.target.result);
|
||||
}
|
||||
reader.readAsDataURL(input);
|
||||
}
|
||||
|
||||
$('#add_direction').click(
|
||||
function(){startLoad(null)}
|
||||
);
|
||||
|
||||
$("#file_input").change(function(){
|
||||
$('#imgs_preview').empty();
|
||||
$('#file-input-greenspan').html('');
|
||||
if ($(this)[0].files[0]) {
|
||||
$('#pre_load').hide();
|
||||
$('#file-input-greenspan').html('Загружено снимков: ' + $(this)[0].files.length);
|
||||
for(i=0;i<$(this)[0].files.length;i++)
|
||||
{
|
||||
if (($(this)[0].files[i].type.includes('image')))
|
||||
{
|
||||
div = document.createElement('div');
|
||||
div.setAttribute('class', 'col-3 p-1 m-0');
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('class', 'preview_img');
|
||||
previewIMG($(this)[0].files[i], $(img));
|
||||
div.appendChild(img);
|
||||
document.getElementById("imgs_preview").appendChild(div);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function update_select(profarea_update)
|
||||
{
|
||||
var lang = getUrlParameter('lang');
|
||||
var params = {
|
||||
clinic_id:$("#clinic_id").val(),
|
||||
profarea_id:$('#profarea_id').val(),
|
||||
lang:lang
|
||||
};
|
||||
var str_params = jQuery.param( params );
|
||||
$.ajax({
|
||||
type:'GET',
|
||||
url: '/get_doctors_profiles?' + str_params,
|
||||
processData: false, // tell jQuery not to process the data
|
||||
contentType: false, // tell jQuery not to set contentType
|
||||
success: (data) => {
|
||||
$('#user_id').empty();
|
||||
if(profarea_update==false)
|
||||
{
|
||||
$('#profarea_id').empty();
|
||||
if(lang=='en')
|
||||
$('#profarea_id').append('<option value="0">Profile</option>');
|
||||
else
|
||||
$('#profarea_id').append('<option value="0">Профиль</option>');
|
||||
for(pa_i in data['profareas'])
|
||||
$('#profarea_id').append('<option value="'+data['profareas'][pa_i]['id']+'">'+data['profareas'][pa_i]['name']+'</option>');
|
||||
}
|
||||
for(pa_i in data['users'])
|
||||
$('#user_id').append('<option value="'+data['users'][pa_i]['id']+'">'+data['users'][pa_i]['name']+'</option>');
|
||||
},
|
||||
error:function (jqXHR, exception) {
|
||||
after_error();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#clinic_id").change(function(){
|
||||
update_select(false);
|
||||
});
|
||||
|
||||
$("#profarea_id").change(function(){
|
||||
update_select(true);
|
||||
});
|
||||
|
||||
function getId(str)
|
||||
{
|
||||
return(str.replaceAll(' ','').replaceAll(',','').replaceAll('.','').replaceAll(';','').replaceAll(':','').replaceAll('(','').replaceAll(')','').replaceAll('-','').replaceAll('/','').replaceAll('\\',''))
|
||||
}
|
||||
|
||||
var getUrlParameter = function getUrlParameter(sParam) {
|
||||
var sPageURL = window.location.search.substring(1),
|
||||
sURLVariables = sPageURL.split('&'),
|
||||
sParameterName,
|
||||
i;
|
||||
|
||||
for (i = 0; i < sURLVariables.length; i++) {
|
||||
sParameterName = sURLVariables[i].split('=');
|
||||
|
||||
if (sParameterName[0] === sParam) {
|
||||
return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
function startLoad(nic_src){
|
||||
$('#start_rec').attr("disabled", true);
|
||||
$('#save_picture').attr("disabled", true);
|
||||
$('#request_waiting').show();
|
||||
$('#progress_text').html('Сохранение');
|
||||
var lang = getUrlParameter('lang');
|
||||
var fileList = document.getElementById('file_input').files;
|
||||
var formData = new FormData();
|
||||
var poll = null;
|
||||
var i = 0
|
||||
console.log($('#clinic_id').val())
|
||||
if ($('#clinic_id').val() == 0 || $('#clinic_id').val() == null){
|
||||
$('#exception').html('Укажите клинику для направления');
|
||||
$('#exception').slideDown(500);
|
||||
$('#exception').delay(2000).slideUp();
|
||||
return
|
||||
}
|
||||
if ($('#profarea_id').val() == 0 || $('#clinic_id').val() == null){
|
||||
$('#exception').html('Укажите профиль направления');
|
||||
$('#exception').slideDown(500);
|
||||
$('#exception').delay(2000).slideUp();
|
||||
return
|
||||
}
|
||||
if ($('#telephone').val() == '' && $('#fio').val() == '' && $('#email').val() == ''){
|
||||
$('#exception').html('Укажите данные пациента');
|
||||
$('#exception').slideDown(500);
|
||||
$('#exception').delay(2000).slideUp();
|
||||
return
|
||||
}
|
||||
for(i=0;i<fileList.length;i++)
|
||||
{
|
||||
if (fileList[i].type.includes('image'))
|
||||
{
|
||||
formData.append("files", fileList[i]);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
var params = {
|
||||
telephone:$('#telephone').val(),
|
||||
fio:$('#fio').val(),
|
||||
email:$('#email').val(),
|
||||
dob:$('#dob').val(),
|
||||
sex:$('#sex').val(),
|
||||
complaints:$('#complaints_input').val(),
|
||||
anamnesis:$('#anamnesis_input').val(),
|
||||
lang:lang,
|
||||
clinic_id:$('#clinic_id').val(),
|
||||
profarea_id:$('#profarea_id').val(),
|
||||
user_id:$('#user_id').val()
|
||||
};
|
||||
if (nic_src){
|
||||
params['src'] = nic_src;
|
||||
}
|
||||
var str_params = jQuery.param( params );
|
||||
|
||||
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
data: formData,
|
||||
url: '/save_direction?' + str_params,
|
||||
processData: false, // tell jQuery not to process the data
|
||||
contentType: false, // tell jQuery not to set contentType
|
||||
async: true,
|
||||
success: (data) => {
|
||||
$('#success').html('Направление отправлено');
|
||||
$('#success').slideDown(500);
|
||||
$('#success').delay(2000).slideUp();
|
||||
clear_form();
|
||||
},
|
||||
error:function (jqXHR, exception) {
|
||||
// after_error();
|
||||
$('#exception').html('Не удалось отправить направление');
|
||||
$('#exception').slideDown(500);
|
||||
$('#exception').delay(2000).slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getRandomInt(max) {
|
||||
return Math.floor(Math.random() * Math.floor(max));
|
||||
}
|
||||
|
||||
function makeid(length) {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user