finish add overall_servival
This commit is contained in:
parent
6b1d72e54a
commit
2e00a82db4
|
@ -118,35 +118,94 @@ $(document).ready(function(){
|
|||
post_json[name] = index;
|
||||
};
|
||||
};
|
||||
post_json['locale'] = I18n.locale;
|
||||
var result = $.post("/cancerpredictResult",{"data":post_json});
|
||||
result.done(function(){
|
||||
var load_heml = $('#result_table_content').html(result.responseJSON.table);
|
||||
load_heml.ready(function(){
|
||||
$('#result_table_content .cancer_years').eq(0).addClass('active');
|
||||
$('.cancer_table_btn').off('click').on('click',function(){
|
||||
var index = $(this).index()/2;
|
||||
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('>input').attr('value',0);
|
||||
$(this).parent().find('>input').eq(index).attr('value',1);
|
||||
$(this).parent().find('>button').removeClass('active');
|
||||
$(this).parent().removeClass('cancertable_empty');
|
||||
$(this).parent().find('.cancer_years').removeClass('active');
|
||||
//$('#result_text_content .cancer_years').eq($(this).attr('index')).click();
|
||||
}catch{};
|
||||
$(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(){
|
||||
$('#result_text_content .cancer_years').eq(0).addClass('active');
|
||||
$('.cancer_table_btn').off('click').on('click',function(){
|
||||
var index = $(this).index()/2;
|
||||
for(var i = 0;i < $('#result_text_content .cancer_years').length;i++){
|
||||
$('#result_text_content .cancer_years').eq(i).attr('index',i)
|
||||
};
|
||||
$('#result_text_content .cancer_years').off('click').on('click',function(){
|
||||
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');
|
||||
$(this).parent().find('.cancer_years').removeClass('active');
|
||||
//$('#result_table_content .cancer_years').eq($(this).attr('index')).click();
|
||||
}catch{};
|
||||
$(this).addClass('active');
|
||||
$('#current_year').attr('value',$(this).html());
|
||||
$('#current_year').attr('index',$(this).attr('index'));
|
||||
$('.surgery_year').html($(this).html());
|
||||
$('#current_year').change();
|
||||
});
|
||||
var treatmeny_method = result.responseJSON.treatmeny_method;
|
||||
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 lpv_real = [result.responseJSON['lpv']];
|
||||
var lpv_dict={}
|
||||
var lpv_calc={1:-0.001476145,3:-0.01261639,5:-0.02519608}
|
||||
active_treatment.push = 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.legnth - 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]);
|
||||
return Array.prototype.push.apply(this, arguments);
|
||||
}else{
|
||||
return Array.prototype.push.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(){
|
||||
if(!active_treatment.includes($(this).parent().attr('id'))){
|
||||
active_treatment.push($(this).parent().attr('id'))
|
||||
console.log($(this).parent().attr('id'))
|
||||
}
|
||||
})
|
||||
}
|
||||
$('#current_year').change(function(){
|
||||
$('.surgery_year').html($(this).attr('value'));
|
||||
$('.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 year = $(this).attr('value');
|
||||
servive_ratio_arr = [];
|
||||
for(var i = 0;i<active_treatment.length;i++){
|
||||
var servive_ratio = (Math.exp(lpv_calc[year])**lpv_real[i])*100;
|
||||
servive_ratio_arr.push(servive_ratio);
|
||||
$('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio);
|
||||
}
|
||||
$('.'+active_treatment[0]+'.Overall_Survival').html(servive_ratio_arr[0]);
|
||||
/*for(var i = 0;i<treatmeny_method.length;i++){
|
||||
$('.'+treatmeny_method[i]+'["name='+yes+'"]').attr('value') == 1
|
||||
}*/
|
||||
$('.survive_person').html(servive_ratio);
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
|
@ -10,6 +10,8 @@ class CancerpredictsController < ApplicationController
|
|||
tags = OrbitHelper.widget_tags
|
||||
categories = OrbitHelper.widget_categories || []
|
||||
create_first_field
|
||||
locale = params['data']['locale'].to_s rescue 'zh_tw'
|
||||
locale = 'zh_tw' if locale == 'zh_cn'
|
||||
result = {:result=>"123"}
|
||||
result['age1'] = -(params['data']['age'].to_f/100)**(-0.5)
|
||||
result['age2'] = -(params['data']['age'].to_f/100)**(-0.5)*Math.log(params['data']['age'].to_f/100,10)
|
||||
|
@ -58,37 +60,38 @@ class CancerpredictsController < ApplicationController
|
|||
result['lpv'] = ((result['age1']-0.7276655)*(-10.87)+(result['age2']-0.4540707)*8.968+(result['size1']-0.643632)*0.7678+(result['nposit']-1.346932)*0.5339+
|
||||
result['grade_2']*0.4795+result['grade_3']*0.818+result['subtype_HER2']*0.1806+result['subtype_triple']*0.6457+result['pstage_2']*0.5311+
|
||||
result['pstage_3']*1.134+result['pstage_4']*2.172+result['lvi_yes']*0.3321-0.04 rescue 'error')
|
||||
result['table'] = '<p id="cancer_table_texts">此分析微針對已接受手術後病人,下表為此病人分別在第1年、3及5年下,根據選定的術後治療所估計的存活率</p>'
|
||||
result['table'] += '<a>第</a>'
|
||||
@years = ['1','3','5']
|
||||
result['table'] = '<input id="current_year" type="hidden" value="'+@years[0]+'" index="0"/><p id="cancer_table_texts">此分析微針對已接受手術後病人,下表為此病人分別在第1年、3及5年下,根據選定的術後治療所估計的存活率</p>'
|
||||
result['table'] += '<a>第</a>'
|
||||
result['years'] = @years
|
||||
@years.each{|year| result['table'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year+'</button>')}
|
||||
result['table'] += '<a>年</a>'
|
||||
@table_head = (I18n.locale.to_s == "zh_tw") ? ['治療','額外治療效益','總生存率(%)'] :['Treatment','Additional Benefit','Overall Survival(%)']
|
||||
@therapy_choices = (I18n.locale.to_s == "zh_tw") ? ['純手術'] :['Treatment']
|
||||
@form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][I18n.locale.to_s]}
|
||||
@therapy_names = ['Treatment']
|
||||
@table_head = (locale == "zh_tw") ? ['治療','額外治療效益','總生存率(%)'] :['Treatment','Additional Benefit','Overall Survival(%)']
|
||||
@head_name = ['Treatment','Additional_Benefit','Overall_Survival']
|
||||
@therapy_choices = (locale == "zh_tw") ? ['純手術'] :['Surgery only']
|
||||
@form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]}
|
||||
@therapy_names = ['Surgery_only']
|
||||
@form_to_show.form_show_in_result.values.each{|choice| @therapy_names.push choice["variable"]}
|
||||
result['treatmeny_method'] = @therapy_names
|
||||
result['table'] += '<table><thead><tr>'
|
||||
@table_head.each_with_index{|head,index| result['table'] += ('<th class="cancer_th">' + head + '</th>')}
|
||||
@table_head.each_with_index{|head,index| result['table'] += ('<th class="cancer_th '+@head_name[index]+'">' + head + '</th>')}
|
||||
result['table'] += '</tr></thead><tbody>'
|
||||
@therapy_choices.each_with_index do |choice,i|
|
||||
result['table'] += '<tr>'
|
||||
result['table'] += '<tr class="'+@therapy_names[i].to_s+'">'
|
||||
@table_head.each_with_index do |head,index|
|
||||
if index == 0
|
||||
result['table'] += ('<td class="cancer_td '+@therapy_names[i].to_s+'">' + choice + '</td>')
|
||||
else
|
||||
result['table'] += ('<td class="cancer_td">' + '-' + '</td>')
|
||||
end
|
||||
result['table'] += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? choice : '-') + '</td>')
|
||||
end
|
||||
result['table'] += '</tr>'
|
||||
end
|
||||
result['texts'] = '<a>此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,</a>'+'<div style="clear:both;"></div>'+'<a>在術後第</a>'
|
||||
@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)**(Math.exp((result['lpv'])))
|
||||
result['texts'] += ('<a>100 位只接受根除性手術的婦女中,有 '+ '<a class="survive_person">'+@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></div>'
|
||||
@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'] += '</div>'
|
||||
result['servive_ratio'] = @servive_ratio
|
||||
result = result.merge(params)
|
||||
render :json=> result
|
||||
end
|
||||
|
@ -119,17 +122,17 @@ class CancerpredictsController < ApplicationController
|
|||
@table_str_left += '</label>'
|
||||
if @field_property["comment_text"] != ""
|
||||
@table_str_left += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"></button>'
|
||||
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'></input>'
|
||||
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
|
||||
else
|
||||
@table_str_left += '<div style="margin-right: 2.125em;"></div>'
|
||||
end
|
||||
if @field_property["is_num"] == 1
|
||||
@table_str_left += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"></input><button class="btn-sub"></button><button class="btn-add"></button>'
|
||||
@table_str_left += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/><button class="btn-sub"></button><button class="btn-add"></button>'
|
||||
else
|
||||
@table_str_left += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
||||
@field_property["choice_fields"].each do |create_choice|
|
||||
@table_str_left += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
|
||||
@table_str_left += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
|
||||
@table_str_left += '<input type="hidden" value="0" name="'+create_choice+'"/>'
|
||||
end
|
||||
@table_str_left += '</div>'
|
||||
end
|
||||
|
@ -145,17 +148,17 @@ class CancerpredictsController < ApplicationController
|
|||
@table_str_right += '</label>'
|
||||
if @field_property["comment_text"] != ""
|
||||
@table_str_right += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"></button>'
|
||||
@table_str_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'></input>'
|
||||
@table_str_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
|
||||
else
|
||||
@table_str_right += '<div style="margin-right: 2.125em;"></div>'
|
||||
end
|
||||
if @field_property["is_num"] == 1
|
||||
@table_str_right += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"></input><button class="btn-sub"></button><button class="btn-add"></button>'
|
||||
@table_str_right += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/><button class="btn-sub"></button><button class="btn-add"></button>'
|
||||
else
|
||||
@table_str_right += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
||||
@field_property["choice_fields"].each do |create_choice|
|
||||
@table_str_right += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
|
||||
@table_str_right += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
|
||||
@table_str_right += '<input type="hidden" value="0" name="'+create_choice+'"/>'
|
||||
end
|
||||
@table_str_right += '</div>'
|
||||
end
|
||||
|
|
|
@ -82,9 +82,19 @@
|
|||
top: -0.3em;
|
||||
padding: 0;
|
||||
}
|
||||
.cancer_table_btn:focus{
|
||||
color: #5d7ca2 !important;
|
||||
background-color: #9dc3e6 !important;
|
||||
border-color: #8c8c8c !important;
|
||||
}
|
||||
.cancer_table_btn:hover{
|
||||
color: #5d7ca2 !important;
|
||||
background-color: #9dc3e6 !important;
|
||||
border-color: #8c8c8c !important;
|
||||
}
|
||||
.cancer_table_btn.active{
|
||||
color: #333;
|
||||
background-color: #e6e6e6;
|
||||
color: #5d7ca2;
|
||||
background-color: #9dc3e6;
|
||||
border-color: #8c8c8c;
|
||||
}
|
||||
.cancertable_empty{
|
||||
|
@ -204,6 +214,8 @@
|
|||
#result_table_content table{
|
||||
clear: both;
|
||||
width:100%;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.cancer_th{
|
||||
color: white;
|
||||
|
|
Loading…
Reference in New Issue