2022-01-26 06:05:57 +00:00
|
|
|
|
Array.prototype.get_nearest_value = function(goal){
|
|
|
|
|
var nearest_value = this.reduce(function(prev, curr) {
|
|
|
|
|
return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev);
|
|
|
|
|
});
|
|
|
|
|
return nearest_value;
|
|
|
|
|
}
|
|
|
|
|
function change_object_variables(obj1,obj2,operator="-",target="new"){
|
|
|
|
|
var obj_new = {};
|
|
|
|
|
var obj_keys = Object.keys(obj1);
|
|
|
|
|
obj_keys.forEach(function(k){
|
|
|
|
|
if(obj2[k] == undefined){
|
|
|
|
|
if( target == "new"){
|
|
|
|
|
obj_new[k] = obj1[k];
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(operator == "-"){
|
|
|
|
|
if( target == "new"){
|
|
|
|
|
obj_new[k] = obj1[k] - obj2[k];
|
|
|
|
|
}else{
|
|
|
|
|
obj1[k] = obj1[k] - obj2[k];
|
|
|
|
|
}
|
|
|
|
|
}else if(operator == "+"){
|
|
|
|
|
if( target == "new"){
|
|
|
|
|
obj_new[k] = obj1[k] + obj2[k];
|
|
|
|
|
}else{
|
|
|
|
|
obj1[k] = obj1[k] + obj2[k];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if( target == "new"){
|
|
|
|
|
return obj_new;
|
|
|
|
|
}else{
|
|
|
|
|
return obj1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-23 09:49:18 +00:00
|
|
|
|
$(document).ready(function(){
|
2020-01-12 05:14:58 +00:00
|
|
|
|
var head_data = $.post("/cancerpredictResult",{"header":1,locale:I18n.locale});
|
|
|
|
|
var data = {};
|
2020-01-12 13:47:55 +00:00
|
|
|
|
if(I18n.locale == 'en'){
|
|
|
|
|
var window_width = $(window).width();
|
|
|
|
|
if(window_width < 520){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','');
|
|
|
|
|
}else if(window_width < 768){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'});
|
|
|
|
|
}else if(window_width < 860){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','30%');
|
|
|
|
|
}else if(window_width < 1130){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','33%');
|
|
|
|
|
}else{
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','39%');
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
function round(num,Digit=0){
|
2020-01-28 10:24:52 +00:00
|
|
|
|
return Math.round(Number(num)*(10**Digit))/(10**Digit);
|
|
|
|
|
};
|
2020-01-12 05:14:58 +00:00
|
|
|
|
head_data.done(function(){
|
2022-01-26 06:05:57 +00:00
|
|
|
|
// $('.header-nav').html(head_images.responseJSON['head_images']);
|
|
|
|
|
// $('.navbar-brand').html(head_images.responseJSON['title'])
|
2020-01-12 05:14:58 +00:00
|
|
|
|
data['danger_texts'] = head_data.responseJSON['danger_texts'];
|
|
|
|
|
$('head title').text(head_data.responseJSON['page_title'])
|
2019-12-15 13:08:41 +00:00
|
|
|
|
});
|
2022-01-26 06:05:57 +00:00
|
|
|
|
var mapping_data = $.post("/cancerpredictResult",{"get_mapping_data_from_csv":1,locale:I18n.locale});
|
|
|
|
|
mapping_data.done(function(){
|
|
|
|
|
// $('.header-nav').html(head_images.responseJSON['head_images']);
|
|
|
|
|
// $('.navbar-brand').html(head_images.responseJSON['title'])
|
|
|
|
|
window.mapping_data_from_csv = mapping_data.responseJSON['mapping_data_from_csv'];
|
|
|
|
|
});
|
2019-12-08 16:38:40 +00:00
|
|
|
|
Array.prototype.remove_item_from_array = function(){
|
|
|
|
|
var result_array = this;
|
|
|
|
|
for(var i=0;i<arguments.length;i++){
|
|
|
|
|
if(Array.isArray(arguments[i])){
|
|
|
|
|
for(var j=0;j<arguments.length;j++){
|
|
|
|
|
var index = result_array.indexOf(arguments[i][j]);
|
|
|
|
|
if(index == -1)
|
|
|
|
|
continue;
|
|
|
|
|
else{
|
|
|
|
|
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
var index = result_array.indexOf(arguments[i]);
|
|
|
|
|
if(index == -1)
|
|
|
|
|
continue;
|
|
|
|
|
else{
|
|
|
|
|
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
result_array.push = this.push;
|
|
|
|
|
result_array.remove_item_from_array = this.remove_item_from_array;
|
|
|
|
|
return result_array;
|
|
|
|
|
};
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$('input#lymph_nodes_examined').data('range_new' , $('input#lymph_nodes_examined').data('range'));
|
|
|
|
|
$('input#lymph_nodes_positive').data('range_new' , $('input#lymph_nodes_positive').data('range'));
|
|
|
|
|
$('.num_only').on('input', function() {
|
|
|
|
|
$(this).siblings('.num_only_value').val($(this).val());
|
|
|
|
|
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
|
|
|
|
|
$(this).css('color','#f24a69');
|
|
|
|
|
$(this).addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).css('color','#333');
|
|
|
|
|
$(this).removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
$('input#lymph_nodes_positive').off('input').on('input',function(){
|
|
|
|
|
$(this).siblings('.num_only_value').val($(this).val());
|
|
|
|
|
if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){
|
|
|
|
|
$(this).css('color','#f24a69');
|
|
|
|
|
$(this).addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).css('color','#333');
|
|
|
|
|
$(this).removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
$('input#lymph_nodes_examined').off('input').on('input',function(){
|
|
|
|
|
$(this).siblings('.num_only_value').val($(this).val());
|
|
|
|
|
if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){
|
|
|
|
|
$(this).css('color','#f24a69');
|
|
|
|
|
$(this).addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).css('color','#333');
|
|
|
|
|
$(this).removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
2019-11-23 09:49:18 +00:00
|
|
|
|
$('.cancer_help_btn').off("click").on('click',function(){
|
|
|
|
|
var modal_head = "";
|
2020-01-13 08:15:21 +00:00
|
|
|
|
try{ modal_head = $(this).parent().find(">label").html()}catch(e){};
|
2019-11-23 09:49:18 +00:00
|
|
|
|
var modal_body = "";
|
2020-01-13 08:15:21 +00:00
|
|
|
|
try{ modal_body = $(this).parent().find(">input.help_texts").attr('value')}catch(e){};
|
2019-11-23 09:49:18 +00:00
|
|
|
|
$('#show_help_modal').html("<div class='modal-dialog'><div class='modal-content'><div class='modal-header'><button type='button' aria-hidden='true' class='close'>×</button><h4 class='modal-title'>"+modal_head+"</h4>"+
|
|
|
|
|
"</div><div class='modal-body'>"+modal_body+"</div><div class='modal-footer'><button type='button' class='btn btn-default'>Close</button></div></div></div>")
|
|
|
|
|
$('#show_help_modal').modal('show');
|
|
|
|
|
$('#show_help_modal .close').off("click").on('click',function(){
|
|
|
|
|
$('#show_help_modal').modal('hide');
|
|
|
|
|
});
|
|
|
|
|
$('#show_help_modal .modal-footer button').off("click").on('click',function(){
|
|
|
|
|
$('#show_help_modal').modal('hide');
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-12-03 13:17:09 +00:00
|
|
|
|
$('.btn-add').click(function(){
|
|
|
|
|
$(this).parent().find('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
if($(this).parent().find('.num_only').val()!=""){
|
|
|
|
|
var input_value = Number($(this).parent().find('.num_only').val());
|
|
|
|
|
if(Array.isArray($(this).parent().find('.num_only').data('range'))){
|
|
|
|
|
var compare_value = $(this).parent().find('.num_only').data('range')[1];
|
|
|
|
|
if(compare_value != undefined){
|
|
|
|
|
if(input_value+1 <= Number(compare_value))
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value+1);
|
|
|
|
|
else{
|
|
|
|
|
input_value = $(this).parent().find('.num_only').data('range')[0];
|
|
|
|
|
if(input_value != undefined)
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value);
|
|
|
|
|
};
|
|
|
|
|
}else{
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value+1);
|
|
|
|
|
};
|
2019-12-09 01:47:53 +00:00
|
|
|
|
compare_value = $(this).parent().find('.num_only').data('range')[0];
|
|
|
|
|
if(compare_value != undefined){
|
|
|
|
|
if($(this).parent().find('.num_only').val() >= compare_value){
|
|
|
|
|
$(this).parent().find('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).parent().find('.num_only').css('color','#333');
|
|
|
|
|
};
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
}else{
|
|
|
|
|
$(this).parent().find('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).parent().find('.num_only').css('color','#333');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-12-03 13:17:09 +00:00
|
|
|
|
};
|
|
|
|
|
}else{
|
|
|
|
|
try{
|
|
|
|
|
var input_value = $(this).parent().find('.num_only').data('range')[0];
|
|
|
|
|
if(input_value != undefined)
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value);
|
2020-01-13 08:15:21 +00:00
|
|
|
|
}catch(e){
|
2019-12-03 13:17:09 +00:00
|
|
|
|
$(this).parent().find('.num_only').val(0);
|
|
|
|
|
};
|
2019-12-09 01:47:53 +00:00
|
|
|
|
if($(this).parent().find('.num_only').val() != ""){
|
|
|
|
|
$(this).parent().find('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).parent().find('.num_only').css('color','#333');
|
|
|
|
|
};
|
2019-12-03 13:17:09 +00:00
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
$('.btn-sub').click(function(){
|
|
|
|
|
if($(this).parent().find('.num_only').val()!=""){
|
|
|
|
|
var input_value = Number($(this).parent().find('.num_only').val());
|
|
|
|
|
if(Array.isArray($(this).parent().find('.num_only').data('range'))){
|
|
|
|
|
var compare_value = $(this).parent().find('.num_only').data('range')[0];
|
|
|
|
|
if(compare_value != undefined){
|
|
|
|
|
if(input_value-1 >= Number(compare_value))
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value-1);
|
|
|
|
|
else{
|
|
|
|
|
input_value = $(this).parent().find('.num_only').data('range')[1];
|
|
|
|
|
if(input_value != undefined)
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value);
|
|
|
|
|
};
|
|
|
|
|
}else{
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value-1);
|
|
|
|
|
};
|
2019-12-09 01:47:53 +00:00
|
|
|
|
compare_value = $(this).parent().find('.num_only').data('range')[1];
|
|
|
|
|
if(compare_value != undefined){
|
|
|
|
|
if($(this).parent().find('.num_only').val() <= compare_value){
|
|
|
|
|
$(this).parent().find('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).parent().find('.num_only').css('color','#333');
|
|
|
|
|
};
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
}else{
|
|
|
|
|
$(this).parent().find('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).parent().find('.num_only').css('color','#333');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-12-03 13:17:09 +00:00
|
|
|
|
};
|
|
|
|
|
}else{
|
|
|
|
|
try{
|
|
|
|
|
var input_value = $(this).parent().find('.num_only').data('range')[1];
|
2019-12-09 01:47:53 +00:00
|
|
|
|
if(input_value != undefined){
|
2019-12-03 13:17:09 +00:00
|
|
|
|
$(this).parent().find('.num_only').val(input_value);
|
2019-12-09 01:47:53 +00:00
|
|
|
|
}else{
|
|
|
|
|
input_value = $(this).parent().find('.num_only').data('range')[0];
|
|
|
|
|
if(input_value != undefined)
|
|
|
|
|
$(this).parent().find('.num_only').val(input_value);
|
|
|
|
|
}
|
2020-01-13 08:15:21 +00:00
|
|
|
|
}catch(e){
|
2019-12-03 13:17:09 +00:00
|
|
|
|
$(this).parent().find('.num_only').val(0);
|
|
|
|
|
};
|
2019-12-09 01:47:53 +00:00
|
|
|
|
if($(this).parent().find('.num_only').val() != ""){
|
|
|
|
|
$(this).parent().find('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).parent().find('.num_only').css('color','#333');
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
2019-12-03 13:17:09 +00:00
|
|
|
|
};
|
|
|
|
|
});
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('.cancer_table_btn').off('click').on('click',function(){
|
2019-12-03 13:17:09 +00:00
|
|
|
|
var index = $(this).index()/2;
|
2019-12-07 13:01:52 +00:00
|
|
|
|
try{
|
|
|
|
|
$(this).parent().find('>input').attr('value',0);
|
|
|
|
|
$(this).parent().find('>input').eq(index).attr('value',1);
|
|
|
|
|
$(this).parent().find('>button').removeClass('active');
|
|
|
|
|
$(this).parent().removeClass('cancertable_empty');
|
2019-12-09 01:47:53 +00:00
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
2020-01-13 08:15:21 +00:00
|
|
|
|
}catch(e){};
|
2019-12-03 13:17:09 +00:00
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
});
|
|
|
|
|
$('#cancer_table_reset').click(function(){
|
|
|
|
|
$('.cancer_table_btn').removeClass('active');
|
|
|
|
|
$('.cancer-btn-group input').attr('value',0);
|
|
|
|
|
$('.num_only').val('');
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$('.num_only_value').val('');
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('#cancer_table .cancer_form_field').removeClass('cancertable_empty');
|
2019-12-09 13:25:59 +00:00
|
|
|
|
$('#cancer_predict_result_block').css('display','none');
|
2019-12-10 11:33:28 +00:00
|
|
|
|
$('#danger_texts').remove();
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$('select.select_num').val('');
|
2019-12-03 13:17:09 +00:00
|
|
|
|
});
|
2019-12-13 08:54:46 +00:00
|
|
|
|
function get_input_data(){
|
2019-12-07 04:12:33 +00:00
|
|
|
|
var flag;
|
|
|
|
|
flag = 1;
|
2019-12-07 13:01:52 +00:00
|
|
|
|
for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){
|
|
|
|
|
if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only')){
|
2020-01-12 13:47:55 +00:00
|
|
|
|
if($('#cancer_table .cancer_form_field').eq(i).val()==""){
|
2019-12-03 13:17:09 +00:00
|
|
|
|
flag = 0;
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty');
|
2020-01-12 13:47:55 +00:00
|
|
|
|
}else if($('#cancer_table .cancer_form_field').eq(i).val() != "" && !$('#cancer_table .cancer_form_field').eq(i).hasClass('cancertable_empty')){
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty');
|
2019-12-03 13:17:09 +00:00
|
|
|
|
};
|
|
|
|
|
}else{
|
2019-12-07 13:01:52 +00:00
|
|
|
|
if($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').length == 0){
|
2019-12-03 13:17:09 +00:00
|
|
|
|
flag = 0;
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty');
|
2019-12-03 13:17:09 +00:00
|
|
|
|
}else{
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty');
|
2019-12-03 13:17:09 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2019-12-28 09:57:13 +00:00
|
|
|
|
};
|
|
|
|
|
if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) < Number($('input#lymph_nodes_positive').siblings('.num_only_value').val())){
|
|
|
|
|
$('input#lymph_nodes_positive').addClass('cancertable_empty');
|
|
|
|
|
$('input#lymph_nodes_positive').css('color','rgb(242, 74, 105)');
|
|
|
|
|
};
|
2019-12-09 01:47:53 +00:00
|
|
|
|
if($('.cancertable_empty').length != 0){
|
|
|
|
|
flag = 0;
|
2020-01-12 05:14:58 +00:00
|
|
|
|
($('#danger_texts').length == 0) ? $('#cancer_table_submit').parent().before('<a id="danger_texts" style="color:red;">'+data['danger_texts']+'</a>') : null;
|
2019-12-09 01:47:53 +00:00
|
|
|
|
$('#danger_texts').css('margin-left',$(window).width()/2-$('#danger_texts').width()/2);
|
|
|
|
|
}else{
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
2019-12-03 13:17:09 +00:00
|
|
|
|
if(flag == 1){
|
|
|
|
|
var post_json= {};
|
2019-12-07 13:01:52 +00:00
|
|
|
|
for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){
|
|
|
|
|
var name = $('#cancer_table .cancer_form_field').eq(i).attr('id')
|
|
|
|
|
if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only'))
|
2022-01-26 06:05:57 +00:00
|
|
|
|
post_json[name] = Number($('#cancer_table .cancer_form_field').eq(i).siblings('.num_only_value').val());
|
2019-12-03 13:17:09 +00:00
|
|
|
|
else{
|
2019-12-07 13:01:52 +00:00
|
|
|
|
var index = ($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').index()+1)/2;
|
2019-12-03 13:17:09 +00:00
|
|
|
|
post_json[name] = index;
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-01-12 05:14:58 +00:00
|
|
|
|
if( post_json["ER_status"] == 2 && post_json["PR_status"] == 2 ){
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$('#hormone_therapy .cancer_table_btn').attr('disabled','disabled');
|
|
|
|
|
$('[for="hormone_therapy"]').css('color','rgb(204, 204, 204)');
|
|
|
|
|
}else{
|
|
|
|
|
$('#hormone_therapy .cancer_table_btn').removeAttr('disabled');
|
|
|
|
|
$('[for="hormone_therapy"]').css('color','');
|
2020-01-12 05:14:58 +00:00
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
/*disable_condition start*/
|
|
|
|
|
if(post_json["ER_status"] == 2 && post_json["PR_status"] == 2){
|
|
|
|
|
$('#hormone_therapy .cancer_table_btn').attr('disabled','disabled');
|
|
|
|
|
$('[for="hormone_therapy"]').css('color','rgb(204, 204, 204)');
|
|
|
|
|
}else{
|
|
|
|
|
$('#hormone_therapy .cancer_table_btn').removeAttr('disabled');
|
|
|
|
|
$('[for="hormone_therapy"]').css('color','');
|
|
|
|
|
}
|
|
|
|
|
if(post_json["HER2_status"] != 1){
|
|
|
|
|
$('#Targeted_therapy .cancer_table_btn').attr('disabled','disabled');
|
|
|
|
|
$('[for="Targeted_therapy"]').css('color','rgb(204, 204, 204)');
|
|
|
|
|
}else{
|
|
|
|
|
$('#Targeted_therapy .cancer_table_btn').removeAttr('disabled');
|
|
|
|
|
$('[for="Targeted_therapy"]').css('color','');
|
|
|
|
|
}
|
|
|
|
|
/*disable_condition end*/
|
2019-12-13 08:54:46 +00:00
|
|
|
|
return post_json;
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
function set_result(result){
|
|
|
|
|
if(result.responseJSON.lpv != "error"){
|
2020-01-12 05:14:58 +00:00
|
|
|
|
$('#choice_fields .cancer_table_btn').removeClass('active');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
var load_heml = $('#result_table_content').html(result.responseJSON.table);
|
|
|
|
|
load_heml.ready(function(){
|
2022-01-26 06:05:57 +00:00
|
|
|
|
$('#result_table_content .cancer_years').eq(0).addClass('active');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
for(var i = 0;i < $('#result_table_content .cancer_years').length;i++){
|
|
|
|
|
$('#result_table_content .cancer_years').eq(i).attr('index',i)
|
|
|
|
|
};
|
|
|
|
|
$('#result_table_content .cancer_years').off('click').on('click',function(){
|
|
|
|
|
try{
|
|
|
|
|
$(this).parent().find('.cancer_years').removeClass('active');
|
2020-01-13 08:15:21 +00:00
|
|
|
|
}catch(e){};
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
$('#current_year').attr('index',$(this).attr('index'));
|
|
|
|
|
$('#current_year').attr('value',$(this).html());
|
|
|
|
|
$('#current_year').change();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
load_heml = $('#result_text_content').html(result.responseJSON.texts);
|
|
|
|
|
load_heml.ready(function(){
|
2022-01-26 06:05:57 +00:00
|
|
|
|
$('#result_text_content .cancer_years').eq(0).addClass('active');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
for(var i = 0;i < $('#result_text_content .cancer_years').length;i++){
|
|
|
|
|
$('#result_text_content .cancer_years').eq(i).attr('index',i)
|
|
|
|
|
};
|
|
|
|
|
$('#current_year').off('change');
|
|
|
|
|
$('#result_text_content .cancer_years').off('click')
|
|
|
|
|
$('#result_text_content .cancer_years').click(function(){
|
|
|
|
|
try{
|
|
|
|
|
$(this).parent().find('.cancer_years').removeClass('active');
|
2020-01-13 08:15:21 +00:00
|
|
|
|
}catch(e){};
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
$('#current_year').attr('value',$(this).html());
|
|
|
|
|
$('#current_year').attr('index',$(this).attr('index'));
|
|
|
|
|
$('.surgery_year').html($(this).html());
|
|
|
|
|
$('#current_year').change();
|
2019-12-07 13:01:52 +00:00
|
|
|
|
});
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$('#cancer_table_right_result .cancer-btn-group .cancer_table_btn').removeClass('active');
|
|
|
|
|
$('#cancer_table_right_result .cancer-btn-group >input').attr('value',"0");
|
|
|
|
|
for(var i = 0;i < $('#cancer_table_left_result .cancer-btn-group').length;i++){
|
2019-12-21 15:50:17 +00:00
|
|
|
|
$('#cancer_table_left_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active');
|
|
|
|
|
$('#cancer_table_left_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1");
|
2019-12-13 08:54:46 +00:00
|
|
|
|
};
|
|
|
|
|
for(var i = 0;i < $('#cancer_table_right_result .cancer-btn-group').length;i++){
|
|
|
|
|
$('#cancer_table_right_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active');
|
|
|
|
|
$('#cancer_table_right_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1");
|
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
var treatment_method = result.responseJSON.treatment_method;
|
|
|
|
|
var treatment_method_active_indices = result.responseJSON.treatment_method_active_indices;
|
|
|
|
|
$('tr.'+treatment_method[0]).addClass('tr_show');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
var servive_ratio_arr = [result.responseJSON.servive_ratio]
|
|
|
|
|
var yes = (I18n.locale=="zh_tw") ? "是" : "yes";
|
|
|
|
|
var year = $('#current_year').attr('value');
|
|
|
|
|
var active_treatment = ['Surgery_only'];
|
|
|
|
|
$('tr.'+active_treatment[0]+' .Overall_Survival').html(servive_ratio_arr[0]+'%');
|
2022-01-26 06:05:57 +00:00
|
|
|
|
$('span.'+active_treatment[0]+'.Overall_Survival').html(Math.round(servive_ratio_arr[0]));
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$('#cancer_predict_result_block').css('display','block');
|
2022-01-26 06:05:57 +00:00
|
|
|
|
var lpv_real = [result.responseJSON['lpv_variable']];
|
|
|
|
|
var lpv = /*therapy_lpv start*/[0, -0.8397, -0.4147, -0.3203, -0.4687];/*therapy_lpv end*/;
|
|
|
|
|
var lpv_dict={};
|
|
|
|
|
var lpv_calc=/*lpv_calc_formula_start*/{"1":"Math.exp(-0.001476145)**( Math.exp(lpv_current) )","3":"Math.exp(-0.01261639)**( Math.exp(lpv_current) )","5":"Math.exp(-0.02519608)**( Math.exp(lpv_current) )"};/*lpv_calc_formula_end*/
|
2019-12-13 08:54:46 +00:00
|
|
|
|
active_treatment.push = function() {
|
|
|
|
|
if(arguments.length == 1){
|
|
|
|
|
var year = $('#current_year').attr('value');
|
2022-01-26 06:05:57 +00:00
|
|
|
|
console.log(lpv_real);
|
|
|
|
|
console.log(lpv_dict[arguments[0]])
|
|
|
|
|
var lpv_current = change_object_variables(lpv_real[lpv_real.length-1],{"lpv": lpv_dict[arguments[0]]},'+');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
lpv_real.push(lpv_current);
|
2022-01-26 06:05:57 +00:00
|
|
|
|
lpv_current = lpv_current['lpv'];
|
|
|
|
|
var servive_ratio = round(eval(lpv_calc[year])*100,2);
|
2019-12-13 08:54:46 +00:00
|
|
|
|
var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length - 1];
|
|
|
|
|
servive_ratio_arr.push(servive_ratio);
|
|
|
|
|
$('tr.'+arguments[0]+' td.Overall_Survival').html(servive_ratio+'%');
|
2020-01-28 10:24:52 +00:00
|
|
|
|
$('tr.'+arguments[0]+' td.Additional_Benefit').html(round(benefit,2)+'%');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$('tr.'+arguments[0]).css('display','table-row');
|
|
|
|
|
$('tr.tr_show').eq(-1).after($('tr.'+arguments[0]));
|
|
|
|
|
$('tr.'+arguments[0]).addClass('tr_show');
|
|
|
|
|
if(this.length == 1){
|
2020-01-12 05:14:58 +00:00
|
|
|
|
$('.addition').css('display','inline-block');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$('#result_text_content .extra-text').css('display','inline-block');
|
|
|
|
|
}
|
|
|
|
|
var add_choices = this.slice(1,this.length);
|
|
|
|
|
add_choices.push(arguments[0]);
|
|
|
|
|
var add_choices_transform = [];
|
|
|
|
|
for(var i = 0;i<add_choices.length;i++){
|
|
|
|
|
add_choices_transform.push($('[for="'+add_choices[i]+'"]').html())
|
|
|
|
|
};
|
2020-01-12 05:14:58 +00:00
|
|
|
|
var add_choices_str = (I18n.locale == 'en' ? add_choices_transform.slice(0,add_choices_transform.length-1).join(', ') : add_choices_transform.slice(0,add_choices_transform.length-1).join('、'));
|
2019-12-13 08:54:46 +00:00
|
|
|
|
if(add_choices_transform.length >= 2)
|
2020-01-12 05:14:58 +00:00
|
|
|
|
add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1])
|
2019-12-13 08:54:46 +00:00
|
|
|
|
else
|
|
|
|
|
add_choices_str = add_choices_transform[0];
|
2020-01-12 05:14:58 +00:00
|
|
|
|
var extra_therapy_texts = result.responseJSON['extra_therapy_texts'];
|
|
|
|
|
extra_therapy_texts = extra_therapy_texts.replace('{{extra_therapy}}','</span><span class="'+arguments[0]+' choices">'+add_choices_str+'</span><span>');
|
2020-01-28 10:24:52 +00:00
|
|
|
|
extra_therapy_texts = extra_therapy_texts.replace('{{survival_num}}','</span><span class="'+arguments[0]+' Overall_Survival">'+Math.round(servive_ratio)+'</span><span>');
|
2020-01-12 05:14:58 +00:00
|
|
|
|
extra_therapy_texts = extra_therapy_texts.replace('{{surgery_year}}','</span><span class="surgery_year">'+year+'</span><span>');
|
2020-01-28 10:24:52 +00:00
|
|
|
|
extra_therapy_texts = extra_therapy_texts.replace('{{Additional_Benefit}}','</span><span class="'+arguments[0]+' Additional_Benefit">'+Math.round(benefit)+'</span><span>');
|
2020-01-12 05:14:58 +00:00
|
|
|
|
var new_text = '<p class="texts_show"><span>';
|
|
|
|
|
new_text += (extra_therapy_texts+'</span></p>');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$('#result_text_content .extra-text .texts_show').eq(-1).after(new_text)
|
|
|
|
|
return Array.prototype.push.apply(this, arguments);
|
|
|
|
|
}else{
|
|
|
|
|
return Array.prototype.push.apply(this, arguments);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
active_treatment.remove_item_from_array = function(){
|
|
|
|
|
if(arguments.length == 1 && !Array.isArray(arguments[0])){
|
|
|
|
|
var index = this.indexOf(arguments[0])
|
|
|
|
|
var year = $('#current_year').attr('value');
|
|
|
|
|
if(index < this.length - 1){
|
|
|
|
|
for(var i = index + 1;i < this.length; i++){
|
2022-01-26 06:05:57 +00:00
|
|
|
|
change_object_variables(lpv_real[i] , {"lpv": lpv_dict[arguments[0]]} , '-' , 'self');
|
|
|
|
|
var lpv_current = lpv_real[i];
|
|
|
|
|
lpv_current = lpv_current['lpv'];
|
|
|
|
|
var servive_ratio = round(eval(lpv_calc[year])*100,2);
|
2019-12-13 08:54:46 +00:00
|
|
|
|
servive_ratio_arr[i] = servive_ratio;
|
|
|
|
|
var benefit = servive_ratio - ((i == index+1) ? servive_ratio_arr[index - 1] : servive_ratio_arr[i - 1]);
|
|
|
|
|
$('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
2020-01-28 10:24:52 +00:00
|
|
|
|
$('.'+active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
|
|
|
|
|
$('tr.'+active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
|
|
|
|
|
$('.'+active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
|
2019-12-13 08:54:46 +00:00
|
|
|
|
};
|
|
|
|
|
var add_choices = [];
|
|
|
|
|
for(var i = 1;i < this.length; i++){
|
|
|
|
|
if(i != index){
|
|
|
|
|
add_choices.push(this[i]);
|
|
|
|
|
var add_choices_transform = [];
|
|
|
|
|
for(var j = 0;j<add_choices.length;j++){
|
|
|
|
|
add_choices_transform.push($('[for="'+add_choices[j]+'"]').html())
|
|
|
|
|
};
|
2020-01-28 10:24:52 +00:00
|
|
|
|
var add_choices_str = (I18n.locale == 'en' ? add_choices_transform.slice(0,add_choices_transform.length-1).join(', ') : add_choices_transform.slice(0,add_choices_transform.length-1).join('、'));
|
2019-12-13 08:54:46 +00:00
|
|
|
|
if(add_choices_transform.length >= 2)
|
2020-01-28 10:24:52 +00:00
|
|
|
|
add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1])
|
2019-12-13 08:54:46 +00:00
|
|
|
|
else
|
|
|
|
|
add_choices_str = add_choices_transform[0];
|
|
|
|
|
$('.'+active_treatment[i]+'.choices').html(add_choices_str);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
$('tr.'+arguments[0]+' td.Overall_Survival').html('-');
|
|
|
|
|
$('tr.'+arguments[0]+' td.Additional_Benefit').html('-');
|
|
|
|
|
$('tr.'+arguments[0]).css('display','none');
|
|
|
|
|
$('tr.'+arguments[0]).removeClass('tr_show');
|
2020-01-28 10:24:52 +00:00
|
|
|
|
$('span.'+arguments[0]).eq(0).parent().remove();
|
2019-12-13 08:54:46 +00:00
|
|
|
|
lpv_real = lpv_real.remove_item_from_array(lpv_real[index]);
|
|
|
|
|
servive_ratio_arr = servive_ratio_arr.remove_item_from_array(servive_ratio_arr[index]);
|
|
|
|
|
if(this.length == 2){
|
|
|
|
|
$('.addition').css('display','none');
|
|
|
|
|
$('#result_text_content .extra-text').css('display','none');
|
|
|
|
|
};
|
|
|
|
|
return Array.prototype.remove_item_from_array.apply(this, arguments);
|
|
|
|
|
}else{
|
|
|
|
|
return Array.prototype.remove_item_from_array.apply(this, arguments);
|
2019-12-08 05:32:03 +00:00
|
|
|
|
};
|
2019-12-13 08:54:46 +00:00
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
for(var i = 0;i<treatment_method.length;i++){
|
|
|
|
|
lpv_dict[treatment_method[i]] = lpv[i];
|
2019-12-13 08:54:46 +00:00
|
|
|
|
var click_flag=false;
|
2022-01-26 06:05:57 +00:00
|
|
|
|
$('#'+treatment_method[i]+' .cancer_table_btn').off('click').click(function(){
|
2019-12-13 08:54:46 +00:00
|
|
|
|
var index = $(this).index()/2;
|
2019-12-07 13:01:52 +00:00
|
|
|
|
try{
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$(this).parent().find('>input').attr('value',0);
|
|
|
|
|
$(this).parent().find('>input').eq(index).attr('value',1);
|
|
|
|
|
$(this).parent().find('>button').removeClass('active');
|
|
|
|
|
$(this).parent().removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
2020-01-13 08:15:21 +00:00
|
|
|
|
}catch(e){};
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$(this).addClass('active');
|
2019-12-13 08:54:46 +00:00
|
|
|
|
if(!click_flag){
|
2022-01-26 06:05:57 +00:00
|
|
|
|
if(active_treatment.includes($(this).parent().attr('id'))){
|
2019-12-13 08:54:46 +00:00
|
|
|
|
click_flag = true;
|
2022-01-26 06:05:57 +00:00
|
|
|
|
active_treatment = active_treatment.remove_item_from_array($(this).parent().attr('id'));
|
2019-12-13 08:54:46 +00:00
|
|
|
|
click_flag = false;
|
2019-12-08 12:21:32 +00:00
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
};
|
2019-12-13 08:54:46 +00:00
|
|
|
|
});
|
2022-01-26 06:05:57 +00:00
|
|
|
|
$('#'+treatment_method[i]+' .cancer_table_btn').eq(treatment_method_active_indices[i]).off('click').click(function(){
|
2019-12-13 08:54:46 +00:00
|
|
|
|
var index = $(this).index()/2;
|
|
|
|
|
try{
|
|
|
|
|
$(this).parent().find('>input').attr('value',0);
|
|
|
|
|
$(this).parent().find('>input').eq(index).attr('value',1);
|
|
|
|
|
$(this).parent().find('>button').removeClass('active');
|
|
|
|
|
$(this).parent().removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
2019-12-08 12:21:32 +00:00
|
|
|
|
};
|
2020-01-13 08:15:21 +00:00
|
|
|
|
}catch(e){};
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
if(!click_flag){
|
2022-01-26 06:05:57 +00:00
|
|
|
|
if(!active_treatment.includes($(this).parent().attr('id'))){
|
2019-12-13 08:54:46 +00:00
|
|
|
|
click_flag = true;
|
2022-01-26 06:05:57 +00:00
|
|
|
|
active_treatment.push($(this).parent().attr('id'));
|
2019-12-13 08:54:46 +00:00
|
|
|
|
click_flag = false;
|
2019-12-08 12:21:32 +00:00
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
}
|
2019-12-07 13:01:52 +00:00
|
|
|
|
});
|
2019-12-13 08:54:46 +00:00
|
|
|
|
};
|
|
|
|
|
$('#current_year').change(function(){
|
|
|
|
|
year = $(this).attr('value');
|
|
|
|
|
$('.surgery_year').html(year);
|
|
|
|
|
$('.cancer_years').removeClass('active');
|
|
|
|
|
$('#result_text_content .cancer_years').eq($(this).attr("index")).addClass('active');
|
|
|
|
|
$('#result_table_content .cancer_years').eq($(this).attr("index")).addClass('active');
|
|
|
|
|
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
|
|
|
|
|
calculate_and_change_result_value(obj);
|
|
|
|
|
servive_ratio_arr = obj.servive_ratio_arr;
|
|
|
|
|
active_treatment = obj.active_treatment;
|
|
|
|
|
lpv_real = obj.lpv_real;
|
|
|
|
|
lpv_calc = obj.lpv_calc;
|
|
|
|
|
year = obj.year;
|
2019-12-07 13:01:52 +00:00
|
|
|
|
});
|
2019-12-13 08:54:46 +00:00
|
|
|
|
$('#cancer_table .cancer_form_field').off('change').on('change',function(){
|
|
|
|
|
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
|
|
|
|
|
after_submit_change_func(obj);
|
|
|
|
|
servive_ratio_arr = obj.servive_ratio_arr;
|
|
|
|
|
active_treatment = obj.active_treatment;
|
|
|
|
|
lpv_real = obj.lpv_real;
|
|
|
|
|
lpv_calc = obj.lpv_calc;
|
|
|
|
|
year = obj.year;
|
|
|
|
|
});
|
|
|
|
|
$('#cancer_table .cancer_form_field').click(function(){
|
|
|
|
|
$(this).change();
|
|
|
|
|
});
|
|
|
|
|
$('select.select_num').off('click').on('click',function(){
|
|
|
|
|
$(this).change();
|
|
|
|
|
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
|
|
|
|
|
after_submit_change_func(obj);
|
|
|
|
|
servive_ratio_arr = obj.servive_ratio_arr;
|
|
|
|
|
active_treatment = obj.active_treatment;
|
|
|
|
|
lpv_real = obj.lpv_real;
|
|
|
|
|
lpv_calc = obj.lpv_calc;
|
|
|
|
|
year = obj.year;
|
|
|
|
|
});
|
|
|
|
|
$('.num_only').on('input', function() {
|
|
|
|
|
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
|
|
|
|
|
$(this).css('color','#f24a69');
|
|
|
|
|
$(this).addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).css('color','#333');
|
|
|
|
|
$(this).removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year};
|
|
|
|
|
after_submit_change_func(obj);
|
|
|
|
|
servive_ratio_arr = obj.servive_ratio_arr;
|
|
|
|
|
active_treatment = obj.active_treatment;
|
|
|
|
|
lpv_real = obj.lpv_real;
|
|
|
|
|
lpv_calc = obj.lpv_calc;
|
|
|
|
|
year = obj.year;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
function after_submit_change_func(obj){
|
|
|
|
|
var post_json = get_input_data();
|
|
|
|
|
if(post_json != null){
|
2022-01-26 06:05:57 +00:00
|
|
|
|
var new_lpv = calculate_first_lpv(post_json)['lpv_variable'];
|
2019-12-13 08:54:46 +00:00
|
|
|
|
var old_lpv = obj.lpv_real[0];
|
2022-01-26 06:05:57 +00:00
|
|
|
|
obj.lpv_real = obj.lpv_real.map(original_value=>(change_object_variables(original_value,change_object_variables(new_lpv,old_lpv,'-'),'+')));
|
2019-12-13 08:54:46 +00:00
|
|
|
|
calculate_and_change_result_value(obj);
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
/* auto add start */
|
|
|
|
|
function calculate_first_lpv(result_json){
|
|
|
|
|
result = {};
|
|
|
|
|
var map_values , mapping_hash , temp_index ,temp_value , index , closest_value;
|
|
|
|
|
result['age'] = Number(result_json['age']);
|
|
|
|
|
result['size'] = Number(result_json['size']);
|
|
|
|
|
result['lymph_nodes_examined'] = Number(result_json['lymph_nodes_examined']);
|
|
|
|
|
result['lymph_nodes_positive'] = Number(result_json['lymph_nodes_positive']);
|
|
|
|
|
result['grade'] = Number(result_json['grade']);
|
|
|
|
|
result['ER_status'] = Number(result_json['ER_status']);
|
|
|
|
|
result['PR_status'] = Number(result_json['PR_status']);
|
|
|
|
|
result['HER2_status'] = Number(result_json['HER2_status']);
|
|
|
|
|
result['Distant_Metastasis'] = Number(result_json['Distant_Metastasis']);
|
|
|
|
|
result['micrometastasis'] = Number(result_json['micrometastasis']);
|
|
|
|
|
result['tumor_direct_extension'] = Number(result_json['tumor_direct_extension']);
|
|
|
|
|
result['lvi'] = Number(result_json['lvi']);
|
|
|
|
|
result['hormone_therapy'] = Number(result_json['hormone_therapy']);
|
|
|
|
|
result['Chemotherapy'] = Number(result_json['Chemotherapy']);
|
|
|
|
|
result['Radiotherapy'] = Number(result_json['Radiotherapy']);
|
|
|
|
|
result['Targeted_therapy'] = Number(result_json['Targeted_therapy']);
|
|
|
|
|
|
|
|
|
|
Object.keys(result).forEach(function(k){
|
|
|
|
|
if(Number.isNaN(result[k])){
|
|
|
|
|
result[k] = 0;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
age1 = (result["age"] / 100.0) ** (0.5);
|
|
|
|
|
age2 = age1 * Math.log(result["age"] / 100.0);
|
|
|
|
|
size1 = Math.log(result["size"] / 10.0);
|
|
|
|
|
ratio = (result["lymph_nodes_examined"] == 0 ? 0 : (1.0 * result["lymph_nodes_positive"] / result["lymph_nodes_examined"]));
|
|
|
|
|
ratio = (ratio > 1 ? 1 : ratio);
|
|
|
|
|
T4 = (result["tumor_direct_extension"] == 1);
|
|
|
|
|
T1 = !T4 && (result["size"] <= 20);
|
|
|
|
|
T2 = !T4 && !T1 && (result["size"] > 20 && result["size"] <= 50);
|
|
|
|
|
T = (T4 ? 'T4' : (T1 ? 'T1' : (T2 ? 'T2' : 'T3')));
|
|
|
|
|
N0 = (result["lymph_nodes_positive"] == 0);
|
|
|
|
|
N1_or_N1mi = !N0 && (result["lymph_nodes_positive"] >= 1 && result["lymph_nodes_positive"] <= 3);
|
|
|
|
|
N1 = N1_or_N1mi && result["micrometastasis"] != 1;
|
|
|
|
|
N1mi = N1_or_N1mi && result["micrometastasis"] == 1;
|
|
|
|
|
N2 = !N0 && !N1_or_N1mi && (result["lymph_nodes_positive"] <= 9);
|
|
|
|
|
N = (N0 ? 'N0' : (N1 ? 'N1' : (N1mi ? 'N1mi' : (N2 ? 'N2' : 'N3'))));
|
|
|
|
|
M = (result["Distant_Metastasis"] != 1) ? 'M0' : 'M1';
|
|
|
|
|
pstage = (M == 'M1' ? 4 : ((T == 'T1' && (N == 'N0' || N == 'N1mi')) ? 1 : (((T == 'T2' || T == 'T3') && (N == 'N0')) || ((T == 'T1' || T == 'T2') && (N == 'N1')) ? 2 : 3)) );
|
|
|
|
|
nposit = ((ratio + 0.1) / 0.1) ** 0.5;
|
|
|
|
|
grade_2 = (result["grade"] == 2 || result["grade"] == 4) ? 1 : 0;
|
|
|
|
|
grade_3 = (result["grade"] == 3) ? 1 : 0;
|
|
|
|
|
subtype_1 = (result["ER_status"] != 2 || result["PR_status"] != 2) && (result["HER2_status"] != 1);
|
|
|
|
|
subtype_2 = !subtype_1 && (result["HER2_status"] == 1);
|
|
|
|
|
subtype_3 = !subtype_1 && !subtype_2 && (result["ER_status"] == 2 && result["PR_status"] == 2 && result["HER2_status"] != 1);
|
|
|
|
|
subtype_HER2 = subtype_2 ? 1 : 0;
|
|
|
|
|
subtype_triple = subtype_3 ? 1 : 0;
|
|
|
|
|
pstage_2 = (pstage == 2) ? 1 : 0;
|
|
|
|
|
pstage_3 = (pstage == 3) ? 1 : 0;
|
|
|
|
|
pstage_4 = (pstage == 4) ? 1 : 0;
|
|
|
|
|
lvi_yes = (result["lvi"] == 1) ? 1 : 0;
|
|
|
|
|
chemo = (result["Chemotherapy"] == 2) ? 1 : 0;
|
|
|
|
|
radio = (result["Radiotherapy"] == 2) ? 1 : 0;
|
|
|
|
|
hormone = (result["hormone_therapy"] == 2) ? 1 : 0;
|
|
|
|
|
target = (result["Targeted_therapy"] == 2) ? 1 : 0;
|
|
|
|
|
try{
|
|
|
|
|
lpv = ((age1-0.7276655)*(-10.87)+(age2+0.4540707)*8.968+(size1-0.643632)*0.7678+(nposit-1.346932)*0.5339+ grade_2*0.4795+grade_3*0.818+subtype_HER2*0.1806+subtype_triple*0.6457+pstage_2*0.5311+ pstage_3*1.134+pstage_4*2.172+lvi_yes*0.3321-0.04+chemo*(-0.4147)+radio*(-0.3203)+hormone*(-0.8397)+target*(-0.4687)
|
|
|
|
|
)
|
|
|
|
|
}catch(e){console.log(e)};
|
|
|
|
|
result['lpv_variable'] = {};
|
|
|
|
|
result['lpv_variable']['lpv'] = lpv;
|
|
|
|
|
result['lpv'] = lpv;
|
|
|
|
|
result['lpv_variable']['lpv'] = result['lpv'];
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
function calculate_and_change_result_value(obj){
|
|
|
|
|
obj.servive_ratio_arr = [];
|
|
|
|
|
for(var i = 0;i<obj.active_treatment.length;i++){
|
|
|
|
|
var servive_ratio = round(calculate_servive_ratio(obj.year,obj.lpv_real[i])*100,2);
|
|
|
|
|
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
|
|
|
|
|
obj.servive_ratio_arr.push(servive_ratio);
|
|
|
|
|
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
|
|
|
|
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
|
|
|
|
|
if(i != 0){
|
|
|
|
|
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
|
|
|
|
|
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function calculate_servive_ratio(year,obj){
|
|
|
|
|
var servive_ratio;
|
|
|
|
|
var lpv = obj['lpv'];
|
|
|
|
|
switch(year) {
|
|
|
|
|
case '1':
|
|
|
|
|
servive_ratio = Math.exp(-0.001476145)**( Math.exp(lpv) );
|
|
|
|
|
break;
|
|
|
|
|
case '3':
|
|
|
|
|
servive_ratio = Math.exp(-0.01261639)**( Math.exp(lpv) );
|
|
|
|
|
break;
|
|
|
|
|
case '5':
|
|
|
|
|
servive_ratio = Math.exp(-0.02519608)**( Math.exp(lpv) );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
console.log('not found year.');
|
|
|
|
|
}
|
|
|
|
|
return servive_ratio;
|
|
|
|
|
}
|
|
|
|
|
/* auto add end */
|
2019-12-13 08:54:46 +00:00
|
|
|
|
function submit_fcn(){
|
|
|
|
|
var post_json = get_input_data();
|
|
|
|
|
if(post_json != null){
|
|
|
|
|
post_json['locale'] = I18n.locale;
|
|
|
|
|
var result = $.post("/cancerpredictResult",{"data":post_json});
|
|
|
|
|
result.done(function(){
|
2020-01-12 05:14:58 +00:00
|
|
|
|
console.log(result.responseJSON);
|
2019-12-13 08:54:46 +00:00
|
|
|
|
set_result(result);
|
2020-01-12 05:14:58 +00:00
|
|
|
|
window.location.hash = '';
|
|
|
|
|
window.location.hash = '#cancer_predict_result_block';
|
2019-12-13 08:54:46 +00:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
$('#cancer_table_submit').click(function(){
|
|
|
|
|
submit_fcn();
|
2019-12-03 13:17:09 +00:00
|
|
|
|
});
|
2019-12-07 04:12:33 +00:00
|
|
|
|
for(var i = 0;i < $('.result_tab').length;i++){
|
|
|
|
|
$('.result_tab').eq(i).attr('index',i)
|
|
|
|
|
};
|
|
|
|
|
for(var i = 0;i < $('.result_content').length;i++){
|
|
|
|
|
$('.result_content').eq(i).attr('index',i)
|
|
|
|
|
};
|
|
|
|
|
$('.result_tab').click(function(){
|
|
|
|
|
var index = $(this).attr('index');
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('.result_tab').removeClass('active');
|
|
|
|
|
$(this).addClass('active');
|
2019-12-07 04:12:33 +00:00
|
|
|
|
$('.result_content').css('display','none');
|
|
|
|
|
$('.result_content[index="'+index+'"]').css('display','block');
|
|
|
|
|
})
|
2019-12-07 13:01:52 +00:00
|
|
|
|
$('.num_only').keypress(function(event){
|
|
|
|
|
return event.keyCode>=48&&event.keyCode<=57||(this.value.indexOf('.')<0?event.keyCode==46:false);
|
|
|
|
|
});
|
2019-12-10 11:33:28 +00:00
|
|
|
|
$('.float_num').off('keyup').on('keyup',function(){
|
|
|
|
|
this.value = this.value.replace(/[^\d.]/g,'');
|
|
|
|
|
});
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$('.num_only').blur(function() {
|
2019-12-10 11:33:28 +00:00
|
|
|
|
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
|
2019-12-09 01:47:53 +00:00
|
|
|
|
$(this).css('color','#f24a69');
|
|
|
|
|
$(this).addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).css('color','#333');
|
|
|
|
|
$(this).removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
2019-12-10 11:33:28 +00:00
|
|
|
|
};
|
|
|
|
|
});
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$('select.select_num').off('click').on('click',function(){
|
|
|
|
|
$(this).change();
|
|
|
|
|
});
|
|
|
|
|
$('select.select_num').change(function(){
|
|
|
|
|
if(this.selectedIndex != 0){
|
|
|
|
|
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
|
|
|
|
|
$(this).siblings('input.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).siblings('input.num_only').css('color','#333');
|
2019-12-10 11:33:28 +00:00
|
|
|
|
}else{
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$(this).siblings('input.num_only').addClass('cancertable_empty');
|
|
|
|
|
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
|
|
|
|
|
$(this).siblings('input.num_only').val($(this).val());
|
|
|
|
|
}
|
|
|
|
|
$(this).siblings('input.num_only_value').val($(this).val());
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
$('input#lymph_nodes_examined').siblings('select.select_num').off('change').on('change',function(){
|
|
|
|
|
var range = $('input#lymph_nodes_positive').data('range');
|
|
|
|
|
range[1] = Number($(this).val());
|
|
|
|
|
$('input#lymph_nodes_positive').data('range_new', range);
|
|
|
|
|
if(this.selectedIndex != 0){
|
|
|
|
|
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
|
|
|
|
|
$(this).siblings('input.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).siblings('input.num_only').css('color','#333');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).siblings('input.num_only').addClass('cancertable_empty');
|
|
|
|
|
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
|
|
|
|
|
$(this).siblings('input.num_only').val($(this).val());
|
|
|
|
|
}
|
|
|
|
|
$(this).siblings('input.num_only_value').val($(this).val());
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
$(this).siblings('.num_only_value').val($(this).val());
|
|
|
|
|
if( Number($('input#lymph_nodes_positive').siblings('.num_only_value').val()) <= Number($(this).val()) ){
|
|
|
|
|
$('input#lymph_nodes_positive').css('color','#333');
|
|
|
|
|
$('input#lymph_nodes_positive').removeClass('cancertable_empty');
|
|
|
|
|
};
|
|
|
|
|
if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){
|
|
|
|
|
$(this).siblings('.num_only').css('color','#f24a69');
|
|
|
|
|
$(this).siblings('.num_only').addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).siblings('.num_only').css('color','#333');
|
|
|
|
|
$(this).siblings('.num_only').removeClass('cancertable_empty');
|
2019-12-10 11:33:28 +00:00
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$('input#lymph_nodes_positive').siblings('select.select_num').off('change').on('change',function(){
|
|
|
|
|
var range = $('input#lymph_nodes_examined').data('range');
|
|
|
|
|
range[0] = Number($(this).val());
|
|
|
|
|
$('input#lymph_nodes_examined').data('range_new', range);
|
|
|
|
|
if(this.selectedIndex != 0){
|
|
|
|
|
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
|
|
|
|
|
$(this).siblings('input.num_only').removeClass('cancertable_empty');
|
|
|
|
|
$(this).siblings('input.num_only').css('color','#333');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).siblings('input.num_only').addClass('cancertable_empty');
|
|
|
|
|
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
|
|
|
|
|
$(this).siblings('input.num_only').val($(this).val());
|
|
|
|
|
}
|
|
|
|
|
$(this).siblings('input.num_only_value').val($(this).val());
|
2019-12-10 11:33:28 +00:00
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
2019-12-28 09:57:13 +00:00
|
|
|
|
$(this).siblings('.num_only_value').val($(this).val());
|
|
|
|
|
if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) >= Number($(this).val()) ){
|
|
|
|
|
$('input#lymph_nodes_examined').css('color','#333');
|
|
|
|
|
$('input#lymph_nodes_examined').removeClass('cancertable_empty');
|
|
|
|
|
};
|
|
|
|
|
if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){
|
|
|
|
|
$(this).siblings('.num_only').css('color','#f24a69');
|
|
|
|
|
$(this).siblings('.num_only').addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).siblings('.num_only').css('color','#333');
|
|
|
|
|
$(this).siblings('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
$('select.select_num').blur(function() {
|
|
|
|
|
if( Number($(this).siblings('.num_only_value').val()) < $(this).siblings('.num_only').data('range')[0] || $(this).siblings('.num_only_value').val() == "" || (Number($(this).siblings('.num_only_value').val()) > $(this).siblings('.num_only').data('range')[1] && $(this).siblings('.num_only').data('range')[1] != undefined) ){
|
|
|
|
|
$(this).siblings('.num_only').css('color','#f24a69');
|
|
|
|
|
$(this).siblings('.num_only').addClass('cancertable_empty');
|
|
|
|
|
}else{
|
|
|
|
|
$(this).siblings('.num_only').css('color','#333');
|
|
|
|
|
$(this).siblings('.num_only').removeClass('cancertable_empty');
|
|
|
|
|
if($('.cancertable_empty').length == 0){
|
|
|
|
|
$('#danger_texts').remove();
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-12-10 11:33:28 +00:00
|
|
|
|
});
|
2019-12-14 04:21:09 +00:00
|
|
|
|
if($(window).width() < 768)
|
|
|
|
|
$('#cancer_predict_result').attr('style','');
|
|
|
|
|
});
|
|
|
|
|
$(window).resize(function(){
|
|
|
|
|
if($(window).width() > 768){
|
|
|
|
|
if($('.cancer_table_right_result').length != 0)
|
|
|
|
|
$('#cancer_predict_result').css('float','right');
|
|
|
|
|
}else{
|
|
|
|
|
$('#cancer_predict_result').attr('style','');
|
|
|
|
|
};
|
2020-01-12 13:47:55 +00:00
|
|
|
|
if(I18n.locale == 'en'){
|
|
|
|
|
var window_width = $(window).width();
|
|
|
|
|
if(window_width < 520){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','');
|
|
|
|
|
}else if(window_width < 768){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'});
|
|
|
|
|
}else if(window_width < 860){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','30%');
|
|
|
|
|
}else if(window_width < 1130){
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','33%');
|
|
|
|
|
}else{
|
|
|
|
|
$('#cancer_table .cencer_table_name').css('max-width','39%');
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-01-26 06:05:57 +00:00
|
|
|
|
});
|