Обработка заполнения формы
This commit is contained in:
@@ -604,21 +604,7 @@ def send_registration_request2():
|
||||
print("Полученные данные:", raw_data)
|
||||
|
||||
# Разделение ФИО
|
||||
fio = raw_data.get("patient_fio", "")
|
||||
parts = fio.split(" ")
|
||||
if len(parts) < 3:
|
||||
return jsonify({'success': False, "error": "ФИО должно содержать 3 слова"}), 400
|
||||
|
||||
pct_last_name = parts[0]
|
||||
pct_first_name = parts[1]
|
||||
pct_second_name = " ".join(parts[2:])
|
||||
|
||||
# Обработка даты рождения
|
||||
dob = raw_data.get("dob1", "")
|
||||
pct_birthday = ""
|
||||
if dob:
|
||||
date_obj = datetime.strptime(dob, "%Y-%m-%d")
|
||||
pct_birthday = date_obj.strftime("%Y-%m-%dT00:00:00.000Z")
|
||||
|
||||
# Определение документа
|
||||
if raw_data.get("passport1") and raw_data.get("passport_date1") and raw_data.get(
|
||||
@@ -660,6 +646,21 @@ def send_registration_request2():
|
||||
else:
|
||||
return jsonify({'success': False, "error": "Недостаточно данных для определения документа"}), 400
|
||||
|
||||
fio = raw_data.get("patient_fio", "")
|
||||
parts = fio.split(" ")
|
||||
if len(parts) < 3:
|
||||
return jsonify({'success': False, "error": "ФИО должно содержать 3 слова"}), 400
|
||||
|
||||
pct_last_name = parts[0]
|
||||
pct_first_name = parts[1]
|
||||
pct_second_name = " ".join(parts[2:])
|
||||
|
||||
# Обработка даты рождения
|
||||
dob = raw_data.get("dob1", "")
|
||||
if dob:
|
||||
date_obj = datetime.strptime(dob, "%Y-%m-%d")
|
||||
pct_birthday = date_obj.strftime("%Y-%m-%dT00:00:00.000Z")
|
||||
|
||||
# Данные родителей
|
||||
plc_fio = raw_data.get("fional", "")
|
||||
plc_status = raw_data.get("taxpayer_status_zapros", "")
|
||||
|
||||
@@ -978,6 +978,101 @@ $(document).ready(function(){
|
||||
$(this).attr("disabled", true);
|
||||
message = {}
|
||||
|
||||
if(!(validate_length($('#fio1').val(), 3)))
|
||||
{
|
||||
show_error('Введите ФИО пациента', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($('#dob1').val().length !== 10 || new Date().getFullYear() - new Date($('#dob1').val()).getFullYear() > 100) {
|
||||
show_error('Дата рождения пациента должна быть корректной и возраст не более 100 лет', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(validate_length($('#fional').val(), 3)))
|
||||
{
|
||||
show_error('Введите ФИО налогоплательщика', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($('#dobnal').val().length !== 10 || new Date().getFullYear() - new Date($('#dobnal').val()).getFullYear() > 100) {
|
||||
show_error('Дата рождения налогоплательщика должна быть корректной и возраст не более 100 лет', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(validate_length($('#innnal').val(), 12)))
|
||||
{
|
||||
show_error('Введите ИНН налогоплательщика', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(!(validate_length($('#passportnal').val(), 11)))
|
||||
{
|
||||
show_error('Введите серию и номер паспорта налогоплательщика', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($('#passport_datenal').val().length !== 10 || (new Date($('#passport_datenal').val()).getFullYear() - new Date($('#dobnal').val()).getFullYear()) < 13) {
|
||||
show_error('Проверьте дату выдачи паспорта, паспорт РФ может быть выдан с 14 лет', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(!(validate_length($('#postal_codenal').val(), 7)))
|
||||
{
|
||||
show_error('Введите код подразделения налогоплательщика', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($('#passport_issued_bynal').val() == null){
|
||||
show_error("Выберите кем выдан паспорт налогоплательщика");
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!(validateEmail($('#email1').val()))){
|
||||
show_error('Введите корректный Email', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($("input[name='god_zapros2']:checked").length === 0) {
|
||||
show_error("Выберите хотя бы один год запроса");
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let selectedYears = [];
|
||||
$("input[name='god_zapros2']:checked").each(function() {
|
||||
@@ -998,29 +1093,33 @@ $(document).ready(function(){
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
type: "POST",
|
||||
url: "/sending_patient2",
|
||||
processData: false, // tell jQuery not to process the data
|
||||
contentType: false, // tell jQuery not to set contentType
|
||||
async: true,
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(message),
|
||||
success: (data) => {
|
||||
if(data.success==true){
|
||||
if (data.success) {
|
||||
$('.primary-field').hide();
|
||||
$('.verification').hide();
|
||||
$('.verificationpacient').hide();
|
||||
$('.success_window').show();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
show_error(data.error);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
$("#code_submit2").children(".spinner-border").addClass('d-none');
|
||||
$("#code_submit2").removeAttr("disabled");
|
||||
}
|
||||
},
|
||||
error:function (jqXHR, exception) {
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
show_error('Что-то пошло не так', false)
|
||||
error: function (jqXHR) {
|
||||
$("#code_submit2").children(".spinner-border").addClass('d-none');
|
||||
$("#code_submit2").removeAttr("disabled");
|
||||
|
||||
// Попробуем получить сообщение об ошибке из ответа сервера
|
||||
let errorMessage = 'Что-то пошло не так';
|
||||
if (jqXHR.responseJSON && jqXHR.responseJSON.error) {
|
||||
errorMessage = jqXHR.responseJSON.error;
|
||||
}
|
||||
|
||||
show_error(errorMessage, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user