const view_medical_care = { section_contract: "section_contract", view_data_ready: false, init: function (_callback) { shared.ViewFunc.ScrollId('#section_header'); shared.CreateControl.FormCustom('#' + view_medical_care.section_contract); sha_control_checked.init(); sha_control_checked.init('health_protector_question', function (_this, _checked) { view_medical_care.question_answer_change(_this, _checked); }) sha_control_checked.init('div_benefit_check', function () { view_medical_care.premium(); }) sha_control_select.init('drl_year_buy', 0, function () { console.log('drl_year_buy') view_medical_care.premium(); }); sha_control_select.init('drl_package', 0, function () { console.log('drl_package') view_medical_care.premium(); }); sha_control_select.init('drl_kind_action', 0, function () { view_web_shared.change_kind_action(); }); sha_control_select.init('drl_kind_customer', 0, function () { view_web_shared.change_kind_customer(); }); sha_control_select.init('drl_buyer_city', 0, function (e) { view_web_shared.location_load_district('drl_buyer_district', e); }); sha_control_select.init('drl_insured_person_city', 0, function (e) { view_web_shared.location_load_district('drl_insured_person_district', e); }); sha_control_select.init('drl_beneficiary_city', 0, function (e) { view_web_shared.location_load_district('drl_beneficiary_district', e); }); sha_control_checked.init('chk_insured_person', function (_this, _checked) { view_medical_care.change_chk_insured_person(_checked); }); sha_control_checked.init('chk_beneficiary', function (_this, _checked) { view_medical_care.change_chk_beneficiary(_checked); }); if (_callback != null) _callback(); }, benefit_config: function (config, root_id) { //alert($('#DIv1 #TestId').val()); if (root_id != "") { root_id = '#' + root_id + ' '; } if (config != "") { config = JSON.parse(config); $(root_id + '#sp_accident_dead').text(config.BENEFIT.ACCIDENT_PERMANENT_INJURY); $(root_id + '#sp_accident_permanent_injury').text(config.BENEFIT.ACCIDENT_PERMANENT_INJURY); $(root_id + '#sp_accident_medical_cost').text(config.BENEFIT.ACCIDENT_MEDICAL_COST); $(root_id + '#sp_health_inpatient_treatment').text(config.BENEFIT.HEALTH_INPATIENT_TREATMENT); $(root_id + '#sp_health_hospital_fee').text(config.BENEFIT.HEALTH_HOSPITAL_FEE); $(root_id + '#sp_health_surgery_cost').text(config.BENEFIT.HEALTH_SURGERY_COST); $(root_id + '#sp_health_hospitalization_allowance').text(config.BENEFIT.HEALTH_HOSPITALIZATION_ALLOWANCE); $(root_id + '#sp_health_treatment_before_hospitalization').text(config.BENEFIT.HEALTH_TREATMENT_BEFORE_HOSPITALIZATION); $(root_id + '#sp_health_treatment_after_discharge').text(config.BENEFIT.HEALTH_TREATMENT_AFTER_DISCHARGE); $(root_id + '#sp_health_home_care_nurse').text(config.BENEFIT.HEALTH_HOME_CARE_NURSE); $(root_id + '#sp_health_funeral_allowance').text(config.BENEFIT.HEALTH_FUNERAL_ALLOWANCE); $(root_id + '#sp_health_pregnancy_complication').text(config.BENEFIT.HEALTH_PREGNANCY_COMPLICATION); $(root_id + '#sp_health_baby_care').text(config.BENEFIT.HEALTH_BABY_CARE); $(root_id + '#sp_health_outpatient_treatment').text(config.BENEFIT.HEALTH_OUTPATIENT_TREATMENT); $(root_id + '#sp_health_medical_examination').text(config.BENEFIT.HEALTH_MEDICAL_EXAMINATION); $(root_id + '#sp_health_physical_therapy').text(config.BENEFIT.HEALTH_PHYSICAL_THERAPY); $(root_id + '#sp_health_dental_care').text(config.BENEFIT.HEALTH_DENTAL_CARE); $(root_id + '#sp_health_death').text(config.BENEFIT.HEALTH_DEATH); $(root_id + '#sp_vaccine_inject').text(config.BENEFIT.VACCINE_INJECT); $(root_id + '#sp_vaccine_inpatient').text(config.BENEFIT.VACCINE_INPATIENT); $(root_id + '#sp_vaccine_hospital_fee').text(config.BENEFIT.VACCINE_HOSPITAL_FEE); $(root_id + '#sp_vaccine_hospitalization_allowance').text(config.BENEFIT.VACCINE_HOSPITALIZATION_ALLOWANCE); $(root_id + '#sp_accident_medical_cost_inpatient').text(config.BENEFIT.ACCIDENT_MEDICAL_COST_INPATIENT); $(root_id + '#sp_accident_medical_cost_outpatient').text(config.BENEFIT.ACCIDENT_MEDICAL_COST_OUTPATIENT); $(root_id + '#sp_health_hospital_fee_max').text(config.BENEFIT.HEALTH_HOSPITAL_FEE_MAX); $(root_id + '#sp_health_emergency_max').text(config.BENEFIT.HEALTH_EMERGENCY_MAX); $(root_id + '#sp_health_transport_max').text(config.BENEFIT.HEALTH_TRANSPORT_MAX); $(root_id + '#sp_health_pregnancy_complication_max').text(config.BENEFIT.HEALTH_PREGNANCY_COMPLICATION_MAX); $(root_id + '#sp_health_antenatal_check_up').text(config.BENEFIT.HEALTH_ANTENATAL_CHECK_UP); $(root_id + '#sp_health_hospitalization_allowance_public').text(config.BENEFIT.HEALTH_HOSPITALIZATION_ALLOWANCE_PUBLIC); } }, load: function () { let send_data = shared.GetInput.Div('section_para_url'); send_data = API.CreateDataSend('human/medical/care/load/data', send_data); API.POST(send_data, function (e) { $('#' + view_medical_care.section_contract).html(e); view_medical_care.init(function () { func_set_value_input(function () { view_web_shared.change_kind_action(); view_web_shared.change_kind_customer(); view_medical_care.view_data_ready = true; view_medical_care.premium(); }) }) Loading.Hide(); }); }, change_chk_insured_person: function (_checked) { let ll_input = [ ["buyer_fullname", "insured_person_fullname"], ["buyer_email", "insured_person_email"], ["buyer_phone", "insured_person_phone"], ["buyer_job", "insured_person_job"], ["buyer_identity_card", "insured_person_identity_card"], ["buyer_address", "insured_person_address"] ]; if (_checked) { for (let i = 0; i < ll_input.length; i++) { let dd_value = shared.Other.Input.GetValueByName(ll_input[i][0]); if (dd_value != null) { sha_control_input.set_val(ll_input[i][1], dd_value); } } sha_control_select.set_val('drl_insured_person_relationship', '05ce74e8-3f8b-4e23-baf5-9a088add5c11'); let buyer_gender = sha_control_select.get_val('drl_buyer_gender'); sha_control_select.set_val('drl_insured_person_gender', buyer_gender); let buyer_city = sha_control_select.get_val('drl_buyer_city'); let buyer_district = sha_control_select.get_val('drl_buyer_district'); sha_control_select.set_val('drl_insured_person_city', buyer_city); view_web_shared.location_load_district('drl_insured_person_district', buyer_city, buyer_district); let buyer_birthday = sha_control_datetime.get_value('buyer_birthday'); sha_control_datetime.set_value('insured_person_birthday', buyer_birthday) } else { for (var i = 0; i < ll_input.length; i++) { var dd_value = shared.Other.Input.GetValueByName(ll_input[i][1]); if (dd_value != null) { sha_control_input.clear_val(ll_input[i][1]); } } sha_control_select.clear_select_val('drl_insured_person_relationship'); sha_control_select.clear_select_val('drl_insured_person_gender'); sha_control_select.clear_select_val('drl_insured_person_city'); sha_control_select.clear_select_val('drl_insured_person_district'); sha_control_datetime.clear_val('insured_person_birthday'); } }, change_chk_beneficiary: function (_checked) { let ll_input = [ ["buyer_fullname", "beneficiary_fullname"], ["buyer_email", "beneficiary_email"], ["buyer_phone", "beneficiary_phone"], ["buyer_identity_card", "beneficiary_identity_card"], ["buyer_address", "beneficiary_address"] ]; if (_checked) { for (let i = 0; i < ll_input.length; i++) { let dd_value = shared.Other.Input.GetValueByName(ll_input[i][0]); if (dd_value != null) { sha_control_input.set_val(ll_input[i][1], dd_value); } } sha_control_select.set_val('drl_beneficiary_relationship', '05ce74e8-3f8b-4e23-baf5-9a088add5c11'); let buyer_gender = sha_control_select.get_val('drl_buyer_gender'); sha_control_select.set_val('drl_beneficiary_gender', buyer_gender); let buyer_city = sha_control_select.get_val('drl_buyer_city'); let buyer_district = sha_control_select.get_val('drl_buyer_district'); sha_control_select.set_val('drl_beneficiary_city', buyer_city); view_web_shared.location_load_district('drl_beneficiary_district', buyer_city, buyer_district); let buyer_birthday = sha_control_datetime.get_value('buyer_birthday'); sha_control_datetime.set_value('beneficiary_birthday', buyer_birthday) } else { for (var i = 0; i < ll_input.length; i++) { var dd_value = shared.Other.Input.GetValueByName(ll_input[i][1]); if (dd_value != null) { sha_control_input.clear_val(ll_input[i][1]); } } sha_control_select.clear_select_val('drl_beneficiary_relationship'); sha_control_select.clear_select_val('drl_beneficiary_gender'); sha_control_select.clear_select_val('drl_beneficiary_city'); sha_control_select.clear_select_val('drl_beneficiary_district'); sha_control_datetime.clear_val('beneficiary_birthday'); } }, question_answer_change: function (_this, _checked) { let dd_type = shared.GetInput.Attributes(_this, 'input-type'); let dd_other_id = '#' + shared.GetInput.Attributes(_this, 'input-other-id'); if (dd_type == 'RADIO_OTHER') $(dd_other_id).removeClass('d-none'); else $(dd_other_id).addClass('d-none'); }, premium: function (_callback) { if (!view_medical_care.view_data_ready && _callback == null) return; let send_data = shared.GetInput.Div('div_quote'); send_data = API.CreateDataSend('human/medical/care/premium', send_data, { loading: _callback != null }); API.POST(send_data, function (e) { $('#div_contain_premium').html(e); $("#div_contain_premium").removeClass("d-none"); $("#div_error").addClass("d-none"); if (_callback != null) _callback(); else { const year_buy = sha_control_select.get_text('drl_year_buy'); $("#sp_year_buy").text(year_buy); const drl_package = sha_control_select.get_text('drl_package'); $("#sp_package").text(drl_package); const premium_payment = $("#hdf_total_premium").val(); const premium_payment_text = Format.Number(premium_payment, 0, ",", "."); $("#sp_total_premium").text(premium_payment_text); //Format.FormatNumberCurrency("#sp_total_premium"); const kind_action = sha_control_select.get_text('drl_kind_action'); if (kind_action !== "" && kind_action != null) { $("#sp_kind_action").text(kind_action); } else { $("#sp_kind_action").text('Đăng ký mới'); } Loading.Hide(); } }, function (e) { $("#div_contain_premium").addClass("d-none"); $("#div_error").removeClass("d-none"); $("#p_error_info").text(e); if (_callback != null) func_notification.Error(e); }); }, install: function (_url, _callback) { let is_contract = $('#div_contract').hasClass("d-none"); if (is_contract) { $("#div_contract").removeClass("d-none"); shared.ViewFunc.ScrollId('#div_contract'); view_web_shared.change_active_date(); } else { let dd = shared.GetInput.Div(view_medical_care.section_contract); _url ??= 'human/medical/care/install'; dd = API.CreateDataSend(_url, dd); API.POST(dd, function (data) { view_medical_care.final(_callback, data); }, function (_mess, _value, _type) { if (_type === "yesno") { $('#hdf_sale_code').val(_value); func_notification.YesNo("Hồ sơ sức khoẻ của bạn sẽ cần BHV thẩm định. " + "Quý Khách vui lòng chờ thông báo từ BHV, " + "hoặc nhân viên của BHV sẽ liên hệ với Quý Khách. Cám ơn.", "Xác nhận", function (e) { if (e) { let dd = shared.GetInput.Div(view_medical_care.section_contract); dd.sale_code = $('#hdf_sale_code').val(); dd = API.CreateDataSend(_url, dd); API.POST(dd, function (data) { view_medical_care.final(_callback, data); }); } else { $('#hdf_sale_code').val(""); } }); } else func_notification.Info(_mess); if (_callback != null) _callback(false, _mess, _value, _type); else Loading.Hide(); }); } }, final: function (_callback, _data) { if (_callback != null) _callback(true, data); else { let title_info_final = 'Đăng ký thành công!'; let kind_action = sha_control_select.get_val('#drl_kind_action', 0); if (kind_action == "update") { title_info_final = 'Cập nhật thành công!'; } else if (kind_action == "renew") { title_info_final = 'Tái tục thành công!'; } $('#' + view_medical_care.section_contract).html(_data); $("#section_action").html(''); $("#section_action").addClass("d-none"); shared.ViewFunc.ScrollId('#' + view_medical_care.section_contract); $("#title_info_final").text(title_info_final); Loading.Hide(); } } };