add calculate additional benefit and finish text result
This commit is contained in:
parent
2e00a82db4
commit
32bd2ffac5
|
@ -155,12 +155,22 @@ $(document).ready(function(){
|
|||
$('.surgery_year').html($(this).html());
|
||||
$('#current_year').change();
|
||||
});
|
||||
for(var i = 0;i < $('#cancer_table_left_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");
|
||||
};
|
||||
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");
|
||||
};
|
||||
var treatmeny_method = result.responseJSON.treatmeny_method;
|
||||
$('tr.'+treatmeny_method[0]).addClass('tr_show')
|
||||
var lpv = [0,-0.8397,-0.4147,-0.3203,0.3321];
|
||||
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']
|
||||
var active_treatment = ['Surgery_only'];
|
||||
$('.'+active_treatment[0]+' .Overall_Survival').html(servive_ratio_arr[0]);
|
||||
var lpv_real = [result.responseJSON['lpv']];
|
||||
var lpv_dict={}
|
||||
var lpv_calc={1:-0.001476145,3:-0.01261639,5:-0.02519608}
|
||||
|
@ -170,16 +180,97 @@ $(document).ready(function(){
|
|||
var lpv_current = lpv_real[lpv_real.length-1]+lpv_dict[arguments[0]];
|
||||
lpv_real.push(lpv_current);
|
||||
var servive_ratio = (Math.exp(lpv_calc[year])**lpv_current)*100;
|
||||
var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.legnth - 1];
|
||||
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);
|
||||
$('tr.'+arguments[0]+' td.Additional_Benefit').html(benefit);
|
||||
console.log(servive_ratio_arr[servive_ratio_arr.legnth - 1]);
|
||||
$('tr.'+arguments[0]).css('display','table-row');
|
||||
$('tr.tr_show').eq(-1).after($('tr.'+arguments[0]));
|
||||
$('tr.'+arguments[0]).addClass('tr_show');
|
||||
console.log(servive_ratio_arr);
|
||||
if(this.length == 1){
|
||||
$('.addition').css('display','block');
|
||||
$('#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())
|
||||
};
|
||||
var add_choices_str = add_choices_transform.slice(0,add_choices_transform.length-1).join('、');
|
||||
if(add_choices_transform.length >= 2)
|
||||
add_choices_str += ('以及'+add_choices_transform[add_choices_transform.length-1])
|
||||
else
|
||||
add_choices_str = add_choices_transform[0];
|
||||
console.log(add_choices_transform);
|
||||
var new_text = '<p class="texts_show">'+'<a>100 位在術後有接受'+add_choices_str+'的婦女中,有 </a>'+'<a class="'+arguments[0]+' Overall_Survival">'+servive_ratio+'</a>'+'<a> 位婦女,術後 </a>'+'<a class="surgery_year">'+year+'</a>'+'<a>年仍為存活(多了</a>'+'<a class="'+arguments[0]+' Additional_Benefit">'+benefit+'</a><a>位)</a>'+'</p>';
|
||||
$('#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);
|
||||
}
|
||||
};
|
||||
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));
|
||||
};
|
||||
};
|
||||
};
|
||||
return result_array;
|
||||
};
|
||||
active_treatment.remove_item_from_array = function(){
|
||||
if(arguments.length == 1){
|
||||
var year = $('#current_year').attr('value');
|
||||
var lpv_current = lpv_real[lpv_real.length-1]+lpv_dict[arguments[0]];
|
||||
lpv_real.push(lpv_current);
|
||||
var servive_ratio = (Math.exp(lpv_calc[year])**lpv_current)*100;
|
||||
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);
|
||||
$('tr.'+arguments[0]+' td.Additional_Benefit').html(benefit);
|
||||
$('tr.'+arguments[0]).css('display','table-row');
|
||||
$('tr.tr_show').eq(-1).after($('tr.'+arguments[0]));
|
||||
$('tr.'+arguments[0]).addClass('tr_show');
|
||||
console.log(servive_ratio_arr);
|
||||
if(this.length == 1){
|
||||
$('.addition').css('display','block');
|
||||
$('#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())
|
||||
};
|
||||
var add_choices_str = add_choices_transform.slice(0,add_choices_transform.length-1).join('、');
|
||||
if(add_choices_transform.length >= 2)
|
||||
add_choices_str += ('以及'+add_choices_transform[add_choices_transform.length-1])
|
||||
else
|
||||
add_choices_str = add_choices_transform[0];
|
||||
console.log(add_choices_transform);
|
||||
var new_text = '<p class="texts_show">'+'<a>100 位在術後有接受'+add_choices_str+'的婦女中,有 </a>'+'<a class="'+arguments[0]+' Overall_Survival">'+servive_ratio+'</a>'+'<a> 位婦女,術後 </a>'+'<a class="surgery_year">'+year+'</a>'+'<a>年仍為存活(多了</a>'+'<a class="'+arguments[0]+' Additional_Benefit">'+benefit+'</a><a>位)</a>'+'</p>';
|
||||
$('#result_text_content .extra-text .texts_show').eq(-1).after(new_text)
|
||||
return Array.prototype.remove_item_from_array.apply(this, arguments);
|
||||
}else{
|
||||
return Array.prototype.remove_item_from_array.apply(this, arguments);
|
||||
};
|
||||
};
|
||||
for(var i = 0;i<treatmeny_method.length;i++){
|
||||
lpv_dict[treatmeny_method[i]] = lpv[i];
|
||||
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(1).click(function(){
|
||||
|
@ -188,6 +279,13 @@ $(document).ready(function(){
|
|||
console.log($(this).parent().attr('id'))
|
||||
}
|
||||
})
|
||||
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(0).click(function(){
|
||||
if(!active_treatment.includes($(this).parent().attr('id'))){
|
||||
//a.indexOf(3)
|
||||
active_treatment.push($(this).parent().attr('id'))
|
||||
console.log($(this).parent().attr('id'))
|
||||
}
|
||||
})
|
||||
}
|
||||
$('#current_year').change(function(){
|
||||
$('.surgery_year').html($(this).attr('value'));
|
||||
|
@ -198,8 +296,12 @@ $(document).ready(function(){
|
|||
servive_ratio_arr = [];
|
||||
for(var i = 0;i<active_treatment.length;i++){
|
||||
var servive_ratio = (Math.exp(lpv_calc[year])**lpv_real[i])*100;
|
||||
var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length-1];
|
||||
servive_ratio_arr.push(servive_ratio);
|
||||
$('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio);
|
||||
$('.'+active_treatment[i]+'.Overall_Survival').html(servive_ratio);
|
||||
$('tr.'+active_treatment[i]+' td.Additional_Benefit').html(benefit);
|
||||
$('.'+active_treatment[i]+'.Additional_Benefit').html(benefit);
|
||||
}
|
||||
$('.'+active_treatment[0]+'.Overall_Survival').html(servive_ratio_arr[0]);
|
||||
/*for(var i = 0;i<treatmeny_method.length;i++){
|
||||
|
|
|
@ -87,9 +87,8 @@ class CancerpredictsController < ApplicationController
|
|||
@years.each{|year| result['texts'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year+'</button>')}
|
||||
result['texts'] += '<a>年</a>,'
|
||||
@servive_ratio = (Math.exp(-0.001476145)**(result['lpv']))*100
|
||||
result['texts'] += ('<a>100 位只接受根除性手術的婦女中,有 '+ '<a class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</a>'+'<a> 位婦女,術後 </a>'+'<a class="surgery_year">'+@years[0].to_s+'</a>'+'<a>年仍為存活</a>')
|
||||
result['texts'] += '<div class="extra-text" style="display:none;"><a>'+',此外</a>'
|
||||
#@therapy_names[1...@therapy_names.length].each{|name| result['texts'] += '<p>'+'100 位在術後有接受''的婦女中,有 '+'</p>'}
|
||||
result['texts'] += ('<p class="show"><a>100 位只接受根除性手術的婦女中,有 '+ '<a class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</a>'+'<a> 位婦女,術後 </a>'+'<a class="surgery_year">'+@years[0].to_s+'</a>'+'<a>年仍為存活</a></p>')
|
||||
result['texts'] += '<a class="addition">'+',此外</a><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div>'
|
||||
result['texts'] += '</div>'
|
||||
result['servive_ratio'] = @servive_ratio
|
||||
result = result.merge(params)
|
||||
|
|
|
@ -217,6 +217,12 @@
|
|||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
#result_table_content table tbody tr{
|
||||
display: none;
|
||||
}
|
||||
#result_table_content table tbody tr:first-of-type{
|
||||
display: table-row;
|
||||
}
|
||||
.cancer_th{
|
||||
color: white;
|
||||
background-color: #003d79;
|
||||
|
@ -232,4 +238,22 @@
|
|||
display:block;
|
||||
font-size: 0.825em;
|
||||
}
|
||||
p.texts_show{
|
||||
display: list-item;
|
||||
margin-left: 1.5em;
|
||||
clear: both;
|
||||
}
|
||||
div.texts_show{
|
||||
display: block;
|
||||
margin-left: 0;
|
||||
}
|
||||
.addition{
|
||||
display: none;
|
||||
}
|
||||
#cancer_table_right_result .cancer_table_btn{
|
||||
padding: 0.25em 1em;
|
||||
}
|
||||
#cancer_table_left_result .cancer_table_btn{
|
||||
padding: 0.25em 1em;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue