Finish version 2.(lpv calculation is editable)

This commit is contained in:
BoHung Chiu 2022-01-26 14:05:57 +08:00
parent 9f3f337dec
commit 137e13ad1b
18 changed files with 1410 additions and 1075 deletions

View File

@ -1,3 +1,39 @@
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;
}
}
$(document).ready(function(){
var head_data = $.post("/cancerpredictResult",{"header":1,locale:I18n.locale});
var data = {};
@ -15,15 +51,21 @@ $(document).ready(function(){
$('#cancer_table .cencer_table_name').css('max-width','39%');
};
};
function round(num,Digit){
function round(num,Digit=0){
return Math.round(Number(num)*(10**Digit))/(10**Digit);
};
head_data.done(function(){
$('.header-nav').html(head_data.responseJSON['head_images']);
$('.navbar-brand').html(head_data.responseJSON['title']);
// $('.header-nav').html(head_images.responseJSON['head_images']);
// $('.navbar-brand').html(head_images.responseJSON['title'])
data['danger_texts'] = head_data.responseJSON['danger_texts'];
$('head title').text(head_data.responseJSON['page_title'])
});
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'];
});
Array.prototype.remove_item_from_array = function(){
var result_array = this;
for(var i=0;i<arguments.length;i++){
@ -267,7 +309,7 @@ $(document).ready(function(){
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'))
post_json[name] = $('#cancer_table .cancer_form_field').eq(i).siblings('.num_only_value').val();
post_json[name] = Number($('#cancer_table .cancer_form_field').eq(i).siblings('.num_only_value').val());
else{
var index = ($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').index()+1)/2;
post_json[name] = index;
@ -280,13 +322,22 @@ $(document).ready(function(){
$('#hormone_therapy .cancer_table_btn').removeAttr('disabled');
$('[for="hormone_therapy"]').css('color','');
};
/*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*/
return post_json;
}else{
return null;
@ -297,7 +348,7 @@ $(document).ready(function(){
$('#choice_fields .cancer_table_btn').removeClass('active');
var load_heml = $('#result_table_content').html(result.responseJSON.table);
load_heml.ready(function(){
$('#result_table_content .cancer_years').eq(-1).addClass('active');
$('#result_table_content .cancer_years').eq(0).addClass('active');
for(var i = 0;i < $('#result_table_content .cancer_years').length;i++){
$('#result_table_content .cancer_years').eq(i).attr('index',i)
};
@ -313,7 +364,7 @@ $(document).ready(function(){
});
load_heml = $('#result_text_content').html(result.responseJSON.texts);
load_heml.ready(function(){
$('#result_text_content .cancer_years').eq(-1).addClass('active');
$('#result_text_content .cancer_years').eq(0).addClass('active');
for(var i = 0;i < $('#result_text_content .cancer_years').length;i++){
$('#result_text_content .cancer_years').eq(i).attr('index',i)
};
@ -339,24 +390,29 @@ $(document).ready(function(){
$('#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.4687];
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');
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]+'%');
$('span.'+active_treatment[0]+'.Overall_Survival').html(Math.round(servive_ratio_arr[0]));
$('#cancer_predict_result_block').css('display','block');
var lpv_real = [result.responseJSON['lpv']];
var lpv_dict={}
var lpv_calc={1:-0.001476145,3:-0.01261639,5:-0.02519608}
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*/
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]];
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]]},'+');
lpv_real.push(lpv_current);
var servive_ratio = round((Math.exp(lpv_calc[year])**Math.exp(lpv_current))*100,2);
lpv_current = lpv_current['lpv'];
var servive_ratio = round(eval(lpv_calc[year])*100,2);
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+'%');
@ -398,8 +454,10 @@ $(document).ready(function(){
var year = $('#current_year').attr('value');
if(index < this.length - 1){
for(var i = index + 1;i < this.length; i++){
lpv_real[i] -= lpv_dict[arguments[0]];
var servive_ratio = round((Math.exp(lpv_calc[year])**Math.exp(lpv_real[i]))*100,2);
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);
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+'%');
@ -435,39 +493,15 @@ $(document).ready(function(){
$('.addition').css('display','none');
$('#result_text_content .extra-text').css('display','none');
};
console.log(this)
return Array.prototype.remove_item_from_array.apply(this, arguments);
}else{
console.log(this)
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];
for(var i = 0;i<treatment_method.length;i++){
lpv_dict[treatment_method[i]] = lpv[i];
var click_flag=false;
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(1).off('click');
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(1).click(function(){
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();
};
}catch(e){};
$(this).addClass('active');
if(!click_flag){
if(!active_treatment.includes($(this).parent().attr('id'))){
click_flag = true;
active_treatment.push($(this).parent().attr('id'));
click_flag = false;
};
}
});
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(0).off('click');
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(0).click(function(){
$('#'+treatment_method[i]+' .cancer_table_btn').off('click').click(function(){
var index = $(this).index()/2;
try{
$(this).parent().find('>input').attr('value',0);
@ -487,6 +521,26 @@ $(document).ready(function(){
};
};
});
$('#'+treatment_method[i]+' .cancer_table_btn').eq(treatment_method_active_indices[i]).off('click').click(function(){
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();
};
}catch(e){};
$(this).addClass('active');
if(!click_flag){
if(!active_treatment.includes($(this).parent().attr('id'))){
click_flag = true;
active_treatment.push($(this).parent().attr('id'));
click_flag = false;
};
}
});
};
$('#current_year').change(function(){
year = $(this).attr('value');
@ -546,10 +600,88 @@ $(document).ready(function(){
});
};
};
function after_submit_change_func(obj){
var post_json = get_input_data();
if(post_json != null){
var new_lpv = calculate_first_lpv(post_json)['lpv_variable'];
var old_lpv = obj.lpv_real[0];
obj.lpv_real = obj.lpv_real.map(original_value=>(change_object_variables(original_value,change_object_variables(new_lpv,old_lpv,'-'),'+')));
calculate_and_change_result_value(obj);
};
};
/* 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((Math.exp(obj.lpv_calc[obj.year])**Math.exp(obj.lpv_real[i]))*100,2);
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+'%');
@ -559,110 +691,28 @@ $(document).ready(function(){
$('.'+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 after_submit_change_func(obj){
var post_json = get_input_data();
if(post_json != null){
var new_lpv = calculate_first_lpv(post_json)['lpv'];
var old_lpv = obj.lpv_real[0];
obj.lpv_real = obj.lpv_real.map(original_value=>(original_value+new_lpv-old_lpv));
calculate_and_change_result_value(obj);
};
};
function calculate_first_lpv(result_json){
result = {}
result['age1'] = Math.pow((Number(result_json['age'])/100),0.5);
result['age2'] = Math.pow((Number(result_json['age'])/100),0.5)*Math.log(result_json['age']/100);
result['size1'] = Math.log(Number(result_json['size'])/10);
if(Number(result_json['lymph_nodes_examined']) != 0)
try{result['ratio'] = Number(result_json['lymph_nodes_positive'])/Number(result_json['lymph_nodes_examined'])}catch(e){result['ratio'] = 0}
else
result['ratio'] = 0
if(result['ratio'] > 1)
result['ratio'] = 1
result['nposit'] = Math.pow(((Number(result['ratio'])+0.1)/0.1),0.5);
var T = '';
if(Number(result_json['tumor_direct_extension']) != 1){
if(Number(result_json['size']) <= 20)
T = 'T1';
else if(Number(result_json['size']) > 20 && Number(result_json['size']) <= 50)
T = 'T2';
else if(Number(result_json['size']) > 50)
T = 'T3';
}else{
T = 'T4';
};
var N = '';
if(Number(result_json['lymph_nodes_positive']) == 0)
N = 'N0';
else if(Number(result_json['lymph_nodes_positive']) >= 1 && Number(result_json['lymph_nodes_positive']) <= 3 && Number(result_json['micrometastasis']) != 1)
N = 'N1';
else if(Number(result_json['lymph_nodes_positive']) >= 1 && Number(result_json['lymph_nodes_positive']) <= 3 && Number(result_json['micrometastasis']) == 1)
N = 'N1mi';
else if(Number(result_json['lymph_nodes_positive']) >= 4 && Number(result_json['lymph_nodes_positive']) <= 9)
N = 'N2';
else if(Number(result_json['lymph_nodes_positive']) >= 10)
N = 'N3';
M = '';
if(Number(result_json['Distant_Metastasis']) != 1)
M = 'M0';
else
M = 'M1';
if(Number(M == 'M0'))
if(T == 'T1' && (N == 'N0' || N == 'N1mi'))
result['pstage'] = 1;
else if(((T == 'T2' || T == 'T3') && (N == 'N0')) || ((T == 'T1' || T == 'T2') && (N == 'N1')))
result['pstage'] = 2;
else if((T == 'T4' && N == 'N0') || ((T == 'T3' || T == 'T4') && N == 'N1') || (N == 'N2' || N == 'N3'))
result['pstage'] = 3;
else
result['pstage'] = 4
if((Number(result_json['ER_status']) != 2 || Number(result_json['PR_status']) != 2) && (Number(result_json['HER2_status']) != 1))
result['subtype'] = 1;
else if(Number(result_json['HER2_status']) == 1)
result['subtype'] = 2;
else if(Number(result_json['ER_status']) == 2 && Number(result_json['PR_status']) == 2 && (Number(result_json['HER2_status']) != 1))
result['subtype'] = 3;
if( Number(result_json['grade']) == 2 || Number(result_json['grade']) == 4)
result['grade_2'] = 1;
else
result['grade_2'] = 0;
if( Number(result_json['grade']) == 3)
result['grade_3'] = 1;
else
result['grade_3'] = 0;
if( Number(result['subtype']) == 2)
result['subtype_HER2'] = 1;
else
result['subtype_HER2'] = 0;
if( Number(result['subtype']) == 3)
result['subtype_triple'] = 1;
else
result['subtype_triple'] = 0;
if( Number(result['pstage']) == 2)
result['pstage_2'] = 1;
else
result['pstage_2'] = 0;
if( Number(result['pstage']) == 3)
result['pstage_3'] = 1;
else
result['pstage_3'] = 0;
if( Number(result['pstage']) == 4)
result['pstage_4'] = 1;
else
result['pstage_4'] = 0;
if( Number(result_json['lvi']) == 1)
result['lvi_yes'] = 1;
else
result['lvi_yes'] = 0;
try{
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);
}catch(e){result['lpv'] = "error"};
return result;
//$('.'+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 */
function submit_fcn(){
var post_json = get_input_data();
if(post_json != null){

View File

@ -385,8 +385,6 @@ div.texts_show{
margin-top: 1em;
}
}
@media print {
* {
-webkit-print-color-adjust: exact !important;
}
.print_only{
display: none;
}

View File

@ -60,7 +60,7 @@ div.num_group{
.cencer_table_name{
display: inline-block;
vertical-align: middle;
color:#5d7ca2;
color:#5d7ca2 !important;
}
#cancer_table .cencer_table_name{
width: 16.25em;
@ -68,10 +68,18 @@ div.num_group{
#cancer_predict_result_block .cencer_table_name{
width: 5em;
}
.cancer_help_btn{
background-color: rgb(210, 106, 2) !important;
border-color: rgb(210, 106, 2) !important;
color: white !important;
}
.cancer_help_btn i:before {
color: white !important;
}
.cancer_table_btn{
margin-right: 0.5em;
color:#5d7ca2;
border-color: #5d7ca2;
color:#5d7ca2 !important;
border-color: #5d7ca2 !important;
font-weight: 600;
}
.cancer_table_btn::last-of-type{
@ -81,6 +89,7 @@ div.num_group{
font-size:0.825em;
color:#5d7ca2;
}
@media print{
#cancer_table_top{
padding-bottom: 4em;
}
@ -120,7 +129,7 @@ input.num_only{
border-left: 0.125em solid rgb(221, 221, 221);
text-align: center;
font-size: 0.875em;
background-color: rgb(255, 255, 255);
background-color: rgb(255, 255, 255) !important;
height: 2.25em;
position: absolute;
left:0.625em;
@ -137,8 +146,8 @@ input.float_num{
#cancer_table_submit{
margin-left: 1em;
float: right;
background-color: rgb(210, 105, 0);
color: white;
background-color: rgb(210, 105, 0) !important;
color: white !important;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
@ -146,8 +155,8 @@ input.float_num{
}
#cancer_table_reset{
float: right;
background-color: rgb(210, 105, 0);
color: white;
background-color: rgb(210, 105, 0) !important;
color: white !important;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
@ -186,9 +195,9 @@ input.float_num{
border-color: #8c8c8c !important;
}
.cancer_table_btn.active{
color: #5d7ca2;
background-color: #9dc3e6;
border-color: #8c8c8c;
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancertable_empty{
border: 0.25em solid pink !important;
@ -196,8 +205,8 @@ input.float_num{
padding: 0.125em !important;
}
.result_title{
background-color: rgb(210, 105, 0);
color: white;
background-color: rgb(210, 105, 0) !important;
color: white !important;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
@ -205,8 +214,8 @@ input.float_num{
float: left;
}
.result_tab{
background: #023d79;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0);
background: #023d79 !important;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0) !important;
border: none;
float:right;
padding: 0.5em 0.125em 0.5em 0.5em;
@ -230,30 +239,28 @@ input.float_num{
margin-left: -0.5em;
}
.result_tab.active{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
background: #d16801 !important;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0) !important;
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab > a{
writing-mode: vertical-lr;
-webkit-writing-mode: vertical-lr;
color: white;
writing-mode: vertical-lr !important;
-webkit-writing-mode: vertical-lr !important;
color: white !important;
}
.result_tab_group{
width: 15%;
margin: 0;
float: left;
display: none;
}
.result_content_group{
width: 85%;
width: 100%;
margin: 0;
float: right;
float: none;
}
.result_content{
display: none;
display: block;
min-height: 25em;
border: 0.125em solid #c0cbdd;
border: 0.125em solid #c0cbdd !important;
padding: 0.5em;
}
.result_content:first-of-type{
@ -315,13 +322,13 @@ input.float_num{
color:white;
}
.cancer_th{
color: white;
background-color: #003d79;
color: white !important;
background-color: #003d79 !important;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
.cancer_td {
background-color: #e9eaf5;
background-color: #e9eaf5 !important;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
@ -384,8 +391,10 @@ float: left;
.result_title{
margin-top: 1em;
}
@media print {
* {
-webkit-print-color-adjust: exact !important;
}
.layout-content{
background: #fff !important;
}
}

View File

@ -4,6 +4,7 @@ class Admin::CancerpredictsController < OrbitAdminController
require 'rubyXL'
require 'fileutils'
require "axlsx"
require "csv"
#include Admin::CancerpredictsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :create_first_field
@ -27,13 +28,52 @@ class Admin::CancerpredictsController < OrbitAdminController
@head_new_image = Headimages.new(:cancerpredictfields_id => @form_to_show.id)
end
def edit
other_in_use_locales = Site.first.in_use_locales.map{|l| l.to_s}
other_in_use_locales.delete(params[:locale])
if !(params["cancerpredictfields"].nil?)
org_nums = @form_to_show.form_show_was.keys
remain_org_nums = params["cancerpredictfields"]["form_show"].values.map{|property| property["old_num"]}.select{|n| n.present?}
delete_nums = org_nums - remain_org_nums
if !delete_nums.blank?
delete_nums.each do |delete_num|
@form_to_show.form_show.delete(delete_num)
end
end
params["cancerpredictfields"]["form_show"].each do |num,property|
property.each do |key,value|
if value != "0" && value != "1"
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
if value[:id].nil?
mapping_file = CancerPredictMappingFile.create(value)
else
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.temp_file = value[:temp_file]
mapping_file.save
end
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
elsif key.include?("_file")
if value[:_destroy] == "1"
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.destroy
@form_to_show.form_show[num.to_s][key.to_s] = ""
end
end
next if key.include?("_file")
if (key != "old_num")
if key != params[:locale]
if @form_to_show.form_show[num.to_s][key.to_s].class != Array
@form_to_show.form_show[num.to_s] = {} if @form_to_show.form_show[num.to_s].nil?
type = Cancerpredictfields::FIELDINFO[key.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
if @form_to_show.form_show[num.to_s][key.to_s].class != Array && type != Array
if type == Fixnum
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i rescue 0
elsif type == Float
@form_to_show.form_show[num.to_s][key.to_s] = value.to_f rescue 0.0
else
@form_to_show.form_show[num.to_s][key.to_s] = value
end
else
if value.length > 2
@form_to_show.form_show[num.to_s][key.to_s] = YAML.load(value)
@ -43,8 +83,20 @@ class Admin::CancerpredictsController < OrbitAdminController
end
else
value.each do |sub_property,sub_value|
if @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array
type = Cancerpredictfields::FIELDINFO[sub_property.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
@form_to_show.form_show[ num.to_s ][ sub_property ] = {} if @form_to_show.form_show[num.to_s][ sub_property ].nil?
if @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array && type != Array
if type == Fixnum
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_i rescue 0
elsif type == Float
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_f rescue 0.0
else
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
end
else
if sub_value.length > 2
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
@ -52,19 +104,66 @@ class Admin::CancerpredictsController < OrbitAdminController
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
end
end
if(property["old_num"] != nil && property["old_num"] != num.to_s)
other_in_use_locales.each do |locale|
@form_to_show.form_show[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_was[ property["old_num"] ][ sub_property ][locale]
end
end
else
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i
end
end
end
end
end
largest_num = org_nums.map{|n| n.to_i}.sort.last
if (params["cancerpredictfields"]["form_show"].keys.last.to_i + 1 ) <= largest_num
( (params["cancerpredictfields"]["form_show"].keys.last.to_i + 1 ) .. (largest_num)).each do |i|
@form_to_show.form_show.delete i.to_s
end
end
if !params["cancerpredictfields"]["form_show_in_result"].nil?
org_nums = @form_to_show.form_show_in_result_was.keys
remain_org_nums = params["cancerpredictfields"]["form_show_in_result"].values.map{|property| property["old_num"]}.select{|n| n.present?}
delete_nums = org_nums - remain_org_nums
if !delete_nums.blank?
delete_nums.each do |delete_num|
@form_to_show.form_show_in_result.delete(delete_num)
end
end
params["cancerpredictfields"]["form_show_in_result"].each do |num,property|
property.each do |key,value|
if value != "0" && value != "1"
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
if value[:id].nil?
mapping_file = CancerPredictMappingFile.create(value)
else
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.temp_file = value[:temp_file]
mapping_file.save
end
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
elsif key.include?("_file")
if value[:_destroy] == "1"
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.destroy
@form_to_show.form_show_in_result[num.to_s][key.to_s] = ""
end
end
next if key.include?("_file")
if (key != "old_num")
if key != params[:locale]
if @form_to_show.form_show_in_result[num.to_s][key.to_s].class != Array
@form_to_show.form_show_in_result[num.to_s] = {} if @form_to_show.form_show_in_result[num.to_s].nil?
type = Cancerpredictfields::FIELDINFO[key.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
if @form_to_show.form_show_in_result[num.to_s][key.to_s].class != Array && type != Array
if type == Fixnum
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i rescue 0
elsif type == Float
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_f rescue 0.0
else
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value
end
else
if value.length > 2
@form_to_show.form_show_in_result[num.to_s][key.to_s] = YAML.load(value)
@ -74,8 +173,20 @@ class Admin::CancerpredictsController < OrbitAdminController
end
else
value.each do |sub_property,sub_value|
if @form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array
type = Cancerpredictfields::FIELDINFO[sub_property.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ] = {} if @form_to_show.form_show[num.to_s][ sub_property ].nil?
if @form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array && type != Array
if type == Fixnum
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_i rescue 0
elsif type == Float
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_f rescue 0.0
else
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
end
else
if sub_value.length > 2
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
@ -83,18 +194,27 @@ class Admin::CancerpredictsController < OrbitAdminController
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = []
end
end
end
end
else
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i
if(property["old_num"] != nil && property["old_num"] != num.to_s)
other_in_use_locales.each do |locale|
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_was[ property["old_num"] ][ sub_property ][locale]
end
end
end
@create_items = ['title_texts','form_result_is_right','text_descibe','years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block']
end
end
end
end
largest_num = org_nums.map{|n| n.to_i}.sort.last
if (params["cancerpredictfields"]["form_show_in_result"].keys.last.to_i + 1 ) <= largest_num
( (params["cancerpredictfields"]["form_show_in_result"].keys.last.to_i + 1 ) .. (largest_num)).each do |i|
@form_to_show.form_show_in_result.delete i.to_s
end
end
end
@create_items = ['title_texts','form_result_is_right','text_descibe','years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block','prediction_formula','hidden_variables','advance_mode']
params_cancer = params.require("cancerpredictfields").permit!
@create_items.each do |item|
if (@form_to_show[item].class == BSON::Document) || (@form_to_show.send(item).class == Hash)
puts params_cancer[item]
item_hash = @form_to_show[item]
item_hash = item_hash.merge(params_cancer[item])
@form_to_show[item] = item_hash
@ -185,7 +305,18 @@ class Admin::CancerpredictsController < OrbitAdminController
Headimages.find_by(:id => @image_id ).destroy rescue next
@form_to_show.title_images_id.delete(@image_id)
end
file_ids = (@form_to_show.form_show.values + @form_to_show.form_show_in_result.values).map{|property| [property[:variable],property[:cancer_predict_mapping_file]]}.select{|k,f| f.present?}.to_h
mapping_data_from_csv = {}
if !file_ids.blank?
file_ids.each do |k,v|
mapping_data_from_csv[k] = read_mapping_file(v)
end
end
@form_to_show.mapping_data_from_csv = mapping_data_from_csv.to_json
@form_to_show.save
fork do
@form_to_show.auto_write_predict_js
end
end
@index = 0
Dir.chdir("public") do
@ -232,16 +363,18 @@ class Admin::CancerpredictsController < OrbitAdminController
@field_property = {}
property.each do |key,value|
@value= value
@disp_value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[current_locale] rescue ""
else
@disp_value = @value
end
@disp_value = "" if @disp_value.nil?
@field_property[key] = @disp_value
end
if @field_property['right'] == 0
next if @field_property["name"].blank?
@table_str_left += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_str_left += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str_left += @field_property["name"]
@table_str_left += '</label>'
@ -256,7 +389,7 @@ class Admin::CancerpredictsController < OrbitAdminController
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
if @field_property["comment_text"].present?
@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;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@ -304,7 +437,7 @@ class Admin::CancerpredictsController < OrbitAdminController
@table_str_right += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str_right += @field_property["name"]
@table_str_right += '</label>'
if @field_property["comment_text"] != ""
if @field_property["comment_text"].present?
@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;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@ -455,7 +588,7 @@ class Admin::CancerpredictsController < OrbitAdminController
end
def showSubmit
@page_num = params[:page] || 1
@results = Cancerpredictrecord.where("title"=>@app_title).asc(:id).page(@page_num).per(10)
@results = Cancerpredictrecord.where("title"=>@app_title).desc(:id).page(@page_num).per(10)
@variables = []
@names = []
@form_to_show.form_show.each do |num,property|
@ -489,7 +622,7 @@ class Admin::CancerpredictsController < OrbitAdminController
@pagination = create_pagination(@page_num.to_i)
end
def export_cancer_tool_record
@cancer_records = Cancerpredictrecord.where("title"=>@app_title).asc(:id)
@cancer_records = Cancerpredictrecord.where("title"=>@app_title).desc(:id)
dir_path = 'tmp/cancer_tool/'
#FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
@ -564,4 +697,21 @@ class Admin::CancerpredictsController < OrbitAdminController
end
pagination += (((page==all_page_num) ? '<li>['+I18n.t('cancerpredict.next_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page+1).to_s+'"> ['+I18n.t('cancerpredict.next_page')+'] </a></li>')+'</ol></div>')
end
def read_mapping_file(mapping_file_id)
mapping_file = CancerPredictMappingFile.find(mapping_file_id) rescue nil
if !mapping_file.nil?
csv_rows = CSV.read(mapping_file.temp_file.file.path)
titles = csv_rows[0]
infos = {}
titles.each_with_index do |title,i|
infos[title] = []
csv_rows[1..-1].each do |row|
infos[title] << row[i].to_f
end
end
return infos
else
return {}
end
end
end

View File

@ -1,16 +1,13 @@
# encoding: utf-8
require 'rubyXL'
require "json"
class CancerpredictsController < ApplicationController
def initialize
super
@app_title = "cancerpredict"
end
def calculate
uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
create_first_field
#begin
if params['header'].to_i == 1
locale = params['locale'].to_s rescue 'zh_tw'
locale = 'zh_tw' if locale == 'zh_cn'
@ -33,6 +30,9 @@ class CancerpredictsController < ApplicationController
result['danger_texts'] = (@form_to_show.danger_texts[locale] rescue '')
result['title'] = Hash[@head_images.sort].values.join('')
result['page_title'] = @form_to_show.title_texts[params[:locale]]
elsif params['get_mapping_data_from_csv'].to_i == 1
result = {}
result['mapping_data_from_csv'] = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {}
else
@record = Cancerpredictrecord.new
@record.title = @app_title
@ -40,7 +40,7 @@ class CancerpredictsController < ApplicationController
@choice_values = []
@choice_names = []
@form_to_show.form_show.values.each{|choice| @choice_keys.push choice[:variable]}
@form_to_show.form_show.values.each{|choice| @choice_values.push choice[:choice_fields]}
@form_to_show.form_show.values.each{|choice| @choice_values.push ((choice[:is_num] == 1) ? [] : choice[:choice_fields])}
@form_to_show.form_show.values.each{|choice| @choice_names.push choice[:name]}
@choice_keys.each_with_index{|key,i| @record.names[key] = @choice_names[i]}
@choice_keys.each_with_index{|key,i| @record.values[key] = @choice_values[i]}
@ -52,160 +52,96 @@ class CancerpredictsController < ApplicationController
locale = params['data']['locale'].to_s rescue 'zh_tw'
locale = 'zh_tw' if locale == 'zh_cn'
result = {}
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,Math.exp(1))
result['size1'] = Math.log(params['data']['size'].to_f/10,Math.exp(1))
if params['data']['lymph_nodes_examined'].to_i != 0
result['ratio'] = params['data']['lymph_nodes_positive'].to_f/params['data']['lymph_nodes_examined'].to_f rescue 0
mapping_data_from_csv = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {}
@form_to_show.all_variables.each do |v|
result[v] = 0
end
@form_to_show.form_show.each do |num,property|
@variable = property[:variable]
if @variable.present?
if property[:is_num] == 1
if property[:is_float] == 1
result[@variable] = params['data'][@variable].to_f rescue 0.0
else
result['ratio'] = 0
end
result['ratio'] = 1 if result['ratio'] > 1
result['nposit'] = ((result['ratio'].to_f+0.1)/0.1)**0.5
@T = ''
if params['data']['tumor_direct_extension'].to_i != 1
if params['data']['size'].to_i <= 20
@T = 'T1'
elsif params['data']['size'].to_i > 20 && params['data']['size'].to_i <= 50
@T = 'T2'
elsif params['data']['size'].to_i > 50
@T = 'T3'
result[@variable] = params['data'][@variable].to_i rescue 0
end
elsif property[:choice_fields].present?
if !(@form_to_show.advance_mode)
result[@variable] = params['data'][@variable].to_i rescue 0
else
@T = 'T4'
end
result['T'] = @T
@N = ''
if params['data']['lymph_nodes_positive'].to_i == 0
@N = 'N0'
elsif params['data']['lymph_nodes_positive'].to_i >= 1 && params['data']['lymph_nodes_positive'].to_i <= 3 && params['data']['micrometastasis'].to_i != 1
@N = 'N1'
elsif params['data']['lymph_nodes_positive'].to_i >= 1 && params['data']['lymph_nodes_positive'].to_i <= 3 && params['data']['micrometastasis'].to_i == 1
@N = 'N1mi'
elsif params['data']['lymph_nodes_positive'].to_i >= 4 && params['data']['lymph_nodes_positive'].to_i <= 9
@N = 'N2'
elsif params['data']['lymph_nodes_positive'].to_i >= 10
@N = 'N3'
end
result['N'] = @N
@M = ''
if params['data']['Distant_Metastasis'].to_i != 1
@M = 'M0'
if property[:need_map_values] == 1
result[@variable] = property[:map_values][params['data'][@variable].to_i - 1]
else
@M = 'M1'
end
result['M'] = @M
if @M == 'M0'
if @T == 'T1' && (@N == 'N0' || @N == 'N1mi')
result['pstage'] = 1
elsif ((@T == 'T2' || @T == 'T3') && (@N == 'N0')) || ((@T == 'T1' || @T == 'T2') && (@N == 'N1'))
result['pstage'] = 2
elsif (@T == 'T4' && @N == 'N0') || ((@T == 'T3' || @T == 'T4') && @N == 'N1') || (@N == 'N2' || @N == 'N3')
result['pstage'] = 3
end
if property[:revert_value] != 1
result[@variable] = params['data'][@variable].to_i - 1
else
result['pstage'] = 4
result[@variable] = ((property[:choice_fields].length - params['data'][@variable].to_i) rescue params['data'][@variable].to_i)
end
if (params['data']['ER_status'].to_i != 2 || params['data']['PR_status'].to_i != 2) && (params['data']['HER2_status'].to_i != 1)
result['subtype'] = 1
elsif params['data']['HER2_status'].to_i == 1
result['subtype'] = 2
elsif params['data']['ER_status'].to_i == 2 && params['data']['PR_status'].to_i == 2 && (params['data']['HER2_status'].to_i != 1)
result['subtype'] = 3
end
if params['data']['grade'].to_i == 2 || params['data']['grade'].to_i == 4
result['grade_2'] = 1
end
end
if @form_to_show.advance_mode && property[:cancer_predict_mapping_file].present?
if (mapping_data_from_csv != {})
mapping_hash = mapping_data_from_csv[@variable]
temp_index = 0
temp_value = result[@variable]
mapping_hash.each_with_index do |(k,v),i|
if i == 0
index_val = v.index(temp_value) rescue nil
if !index_val.nil?
temp_index = index_val
else
result['grade_2'] = 0
closest_value = v.min_by{|x| (temp_value-x).abs}
temp_index = v.index(closest_value)
end
if params['data']['grade'].to_i == 3
result['grade_3'] = 1
else
result['grade_3'] = 0
end
if result['subtype'].to_i == 2
result['subtype_HER2'] = 1
else
result['subtype_HER2'] = 0
result[k] = v[temp_index]
end
if result['subtype'].to_i == 3
result['subtype_triple'] = 1
else
result['subtype_triple'] = 0
end
if result['pstage'].to_i == 2
result['pstage_2'] = 1
else
result['pstage_2'] = 0
end
if result['pstage'].to_i == 3
result['pstage_3'] = 1
else
result['pstage_3'] = 0
end
if result['pstage'].to_i == 4
result['pstage_4'] = 1
else
result['pstage_4'] = 0
end
if params['data']['lvi'].to_i == 1
result['lvi_yes'] = 1
else
result['lvi_yes'] = 0
formula_variables = @form_to_show.tmp_lpv_variables
begin
eval_hidden_variables(result)
rescue => e
@form_to_show.generate_eval_formula
eval_hidden_variables(result)
end
begin
eval_formula(result)
rescue => e
@form_to_show.generate_eval_formula
eval_formula(result)
end
result['lpv'] = result[formula_variables.last]
result['lpv_variable'] = {}
formula_variables.each do |variable_name|
result['lpv_variable']["#{variable_name}"] = result[variable_name]
end
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')
@years = @form_to_show.years
result['table'] = '<input id="current_year" type="hidden" value="'+@years[-1].to_s+'" index="0"/><p id="cancer_table_texts">'+@form_to_show.table_above_texts[locale]+'</p>'
result['table'] += ('<a style="display: inline-block;">'+(locale == 'zh_tw' ? '第' : '')+'</a><a style="display: inline-block;">')
result['years'] = @years
@years.each{|year| result['table'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year.to_s+'</button>')}
result['table'] += ('</a><a style="display: inline-block;">'+(locale == 'zh_tw' ? '年' : '')+'</a>')
@table_head = (locale == "zh_tw") ? ['治療','額外治療效益','總生存率(%)'] :['Treatment','Additional Benefit','Overall Survival(%)']
@head_name = ['Treatment','Additional_Benefit','Overall_Survival']
@therapy_choices = (locale == "zh_tw") ? ['純手術'] :['Surgery only']
@therapy_choices = [I18n.t('cancerpredict.table.Surgeryonly')]
@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_name[index]+'">' + head + '</th>')}
result['table'] += '</tr></thead><tbody>'
@therapy_choices.each_with_index do |choice,i|
result['table'] += '<tr class="'+@therapy_names[i].to_s+'">'
@table_head.each_with_index do |head,index|
result['table'] += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '</td>')
end
result['table'] += '</tr>'
end
@texts = @form_to_show.text_above_texts[locale].gsub('<br/>','</span><br/><span>')
@texts = @texts.split('{{years}}')
@texts.delete('')
result['texts'] = '<span>'+@texts[0]
@years.each{|year| result['texts'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm" style="float:none;">'+year.to_s+'</button>')}
if @texts.count > 1
result['texts'] += (@texts[1]+'</span>') if @texts.count > 1
@therapy_names = @form_to_show.treatment_method
result['treatment_method'] = @therapy_names
result['treatment_method_active_indices'] = @form_to_show.treatment_method_active_indices
result['table'] = @form_to_show.result_table_translations[locale]
year = params['data']['year'] rescue nil
if year.nil?
year = @years.first.to_f
else
result['texts'] += '</span>'
year = year.to_f
end
@lpv_calc = [-0.001476145,-0.01261639,-0.02519608]
@servive_ratio = ((Math.exp(@lpv_calc[-1])**(Math.exp(result['lpv'])))*100).round(2)
@surgery_only_texts = @form_to_show.surgery_only_texts[locale]
@surgery_only_texts.insert(0,'<p class="show"><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</span><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{surgery_year}}','</span><span class="surgery_year">'+@years[-1].to_s+'</span><span>')
@surgery_only_texts += '</span>'
result['texts'] += @surgery_only_texts
result['texts'] += '<span class="addition">'+@form_to_show.extra_texts[locale]+'</span><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div></div></p>'
year_index = @years.index(year)
@servive_ratio = eval(@form_to_show.tmp_years_settings_for_ruby[year_index])
@servive_ratio = (@servive_ratio * 100).round(2)
result['texts'] = @form_to_show.result_text_translations[locale]
result['extra_therapy_texts'] = @form_to_show.extra_therapy_texts[locale] rescue @form_to_show.extra_therapy_texts['zh_tw']
result['servive_ratio'] = @servive_ratio
end
result = result.merge(params)
render :json=> result
# rescue
# render :json=> params
#end
end
def index
uid = OrbitHelper.params[:uid] rescue ""
@ -223,13 +159,13 @@ class CancerpredictsController < ApplicationController
categories = OrbitHelper.widget_categories || []
end
def create_first_field
if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
if Cancerpredictfields.where("title"=>(@app_title + "_back")).count == 0
@form_to_show = Cancerpredictfields.new()
@form_to_show.title = @app_title +"_back"
@form_to_show.save
end
@form_to_show
if Cancerpredictfields.where("title"=>@app_title).take_while{true}.count == 0
if Cancerpredictfields.where("title"=>@app_title).count == 0
@form_to_show = Cancerpredictfields.new()
@form_to_show.title=@app_title
@form_to_show.save
@ -238,4 +174,23 @@ class CancerpredictsController < ApplicationController
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first
end
end
def read_mapping_file(mapping_file)
if mapping_file.class != CancerPredictMappingFile
mapping_file = CancerPredictMappingFile.find(mapping_file_id) rescue nil
end
if !mapping_file.nil?
csv_rows = CSV.read(mapping_file.temp_file.file.path)
titles = csv_rows[0]
infos = {}
titles.each_with_index do |title,i|
infos[title] = []
csv_rows[1..-1].each do |row|
infos[title] << row[i].to_f
end
end
return infos
else
return {}
end
end
end

View File

@ -0,0 +1,12 @@
# encoding: utf-8
class CancerPredictMappingFile
require 'carrierwave/processing/mime_types'
include Mongoid::Document
include Mongoid::Timestamps
include CarrierWave::MimeTypes
mount_uploader :temp_file, HeadImagesUploader
def file_identifier
filename = self.temp_file.file.original_filename rescue ""
end
end

View File

@ -1,79 +1,456 @@
class Cancerpredictfields
require "pathname"
require 'json'
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitModel::Impression
# encoding: utf-8
include OrbitTag::Taggable
include OrbitCategory::Categorizable
Field_relations = {"number_field"=>"Fixnum","text_area"=>"String"}
FIELDINFO = {"variable"=>"String","name"=>"String","is_num"=>"Fixnum","hint"=>"String","comment_text"=>"String","choice_fields"=>"Array","range"=>"Array","right"=>"Fixnum","is_float"=>"Fixnum","revert_value"=>"Fixnum","map_values"=>"Array","cancer_predict_mapping_file"=>"String","lpv_impact"=>"Float","active_choice"=>"number_field","disable_condition"=>"text_area"}
NonLoclaized = ["variable","is_num","range","right","is_float","revert_value","map_values","cancer_predict_mapping_file","lpv_impact","active_choice","disable_condition"]
AdvanceFields = ["revert_value","map_values","cancer_predict_mapping_file"]
TherapyFields = ["variable","name","hint","comment_text","choice_fields","lpv_impact","active_choice","disable_condition"]
TherapyOnly = ["lpv_impact","active_choice","disable_condition"]
field :title ,type:String ,default:""
field :form_show , :type=> Hash ,default:{0=>{:variable=>"age",:name=>{"zh_tw"=>"年齡<br/>(Age)","en"=>"Age"},:is_num=>1, :hint=>{'zh_tw'=>'從 18 歲(含)開始至 93 歲','en'=>'Age must be between 18 and 93'} , :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡','en'=>'Age at diagnosis'}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[18,93],:right=>0,:is_float=>0},
1=>{:variable=>"size",:name=>{"zh_tw"=>"腫瘤大小<br/>(Tumor size)","en"=>"Tumor size"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>'The unit of tumor size is millimeter (mm)'}, :comment_text=>{'zh_tw'=>'若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤','en'=>'If there was more than one primary tumor, please enter the size of the largest one.'}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[1,230],:right=>0,:is_float=>0},
2=>{:variable=>"lymph_nodes_examined",:name=>{"zh_tw"=>"區域淋巴結檢查數目<br/>(Regional lymph nodes examined)","en"=>"Regional lymph nodes examined"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['未知'],"en"=>['unknown']},:range=>[0,90],:right=>0,:is_float=>0},
3=>{:variable=>"lymph_nodes_positive",:name=>{"zh_tw"=>"區域淋巴結侵犯數目<br/>(Regional lymph nodes positive)","en"=>"Regional lymph nodes positive"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'此變項為預測重要變數,若無此資訊預測容易失真。','en'=>'Regional lymph nodes positive is a key predictive variable. If this information is omitted, the prediction result would be biased.'}, :choice_fields=> {"zh_tw"=>['未知'],"en"=>['unknown']},:range=>[0,90],:right=>0,:is_float=>0},
4=>{:variable=>"grade",:name=>{"zh_tw"=>"腫瘤分化程度<br/>(Tumor grade)","en"=>"Tumor grade"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分化級數資訊,請選擇“未知”選項,將以級數 2 進行預測。','en'=>'The grade refers to how different the cancer cells are from normal cells. Please select “unknown” if there is no information about grade. The prediction model would use “grade 2” as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['1','2','3','未知'],"en"=>['1','2','3','unknown']},:range=>[],:right=>0,:is_float=>0},
5=>{:variable=>"ER_status",:name=>{"zh_tw"=>"ER 狀態<br/>(ER status)","en"=>"ER status"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'ER:雌激素受體,若無 ER 資訊請選擇未知,將以佔多數比例陽性作為後續預測。','en'=>'ER status describes the status of estrogen receptor. Please select “unknown” if there is no information about ER status. The prediction model would use “Positive” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['陽性','陰性','未知'],"en"=>['positive','negative','unknown']},:range=>[],:right=>0,:is_float=>0},
6=>{:variable=>"PR_status",:name=>{"zh_tw"=>"PR 狀態<br/>(PR status)","en"=>"PR status"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'PR:黃體素受體,若無 PR 資訊請選擇未知,將以佔多數比例陽性作為後續預測。','en'=>'PR status describes the status of progesterone receptor. Please select “unknown” if there is no information about PR status. The prediction model would use “Positive” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['陽性','陰性','未知'],"en"=>['positive','negative','unknown']},:range=>[],:right=>1,:is_float=>0},
7=>{:variable=>"HER2_status",:name=>{"zh_tw"=>"HER2 狀態<br/>(HER2 status)","en"=>"HER2 status"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'HER2:第二型人類上皮成長因子接受器蛋白,若無 HER2 資訊請選擇未知,將以佔多數比例陰性作為後續預測。','en'=>'HER2 status describes the status of human epidermal growth factor receptor 2. Please select “unknown” if there is no information about HER2 status. The prediction model would use “Negative” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['陽性','陰性','未知'],"en"=>['positive','negative','unknown']},:range=>[],:right=>1,:is_float=>0},
8=>{:variable=>"Distant_Metastasis",:name=>{"zh_tw"=>"遠端轉移<br/>(Distant Metastasis)","en"=>"Distant Metastasis"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無遠轉移資訊請選擇未知,將以佔多數比例未遠端轉移作為後續預測。','en'=>'Please select “unknown” if there is no information about distant Metastasis. The prediction model would use “No” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0},
9=>{:variable=>"micrometastasis",:name=>{"zh_tw"=>"淋巴結顯微轉移<br/>(Lymph nodes micrometastasis)","en"=>"Micrometastasis"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無顯微移資訊請選擇未知,將以無顯微轉移作為後續預測。','en'=>'Please select “unknown” if there is no information about lymph nodes micrometastasis. The prediction model would use “No” as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0},
10=>{:variable=>"tumor_direct_extension",:name=>{"zh_tw"=>"腫瘤浸潤至胸壁和/或皮膚<br/>(Tumor direct extension to the chest wall and/or to the skin)","en"=>"Tumor direct extension to the chest wall and/or to the skin"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無腫瘤浸潤至胸壁或皮膚資訊請選擇未知,將以佔多數比例無腫瘤浸潤至胸壁作為後續預測。','en'=>'Please select “unknown” if there is no information about tumor direct extension to the chest wall and/or to the skin. The prediction model would use “No” (the majority class) as the alternative variable'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0},
11=>{:variable=>"lvi",:name=>{"zh_tw"=>"淋巴管或血管侵犯<br/>(Lymph vessel or vascular invasion, LVI)","en"=>"Lymph vessel or vascular invasion, LVI"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>'Lymph vessel or vascular invasion'}, :comment_text=>{'zh_tw'=>'若無淋巴管或血管侵犯資訊,請選擇“未知”選項,將以佔多數比例的淋巴管或血管未侵犯進行預測','en'=>'Please select “unknown” if there is no information about Lymph vessel or vascular invasion. The prediction model would use “No” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0}
field :advance_mode, type: Boolean, default: false
field :form_show , :type=> Hash ,default:{
"0"=>{"variable"=>"age", "name"=>{"zh_tw"=>"年齡<br/>(Age)", "en"=>"Age"}, "is_num"=>1, "hint"=>{"zh_tw"=>"從 18 歲(含)開始至 93 歲", "en"=>"Age must be between 18 and 93"}, "comment_text"=>{"zh_tw"=>"年齡為該婦女於確診罹患乳癌時之年齡", "en"=>"Age at diagnosis"}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "range"=>[18, 93], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"1"=>{"variable"=>"size", "name"=>{"zh_tw"=>"腫瘤大小(單位:mm)<br/>(Tumor size)", "en"=>"Tumor size"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>"The unit of tumor size is millimeter (mm)"}, "comment_text"=>{"zh_tw"=>"若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤", "en"=>"If there was more than one primary tumor, please enter the size of the largest one."}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "range"=>[1, 300], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"2"=>{"variable"=>"lymph_nodes_examined", "name"=>{"zh_tw"=>"區域淋巴結檢查數目<br/>(Regional lymph nodes examined)", "en"=>"Regional lymph nodes examined"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"3"=>{"variable"=>"lymph_nodes_positive", "name"=>{"zh_tw"=>"區域淋巴結侵犯數目<br/>(Regional lymph nodes positive)", "en"=>"Regional lymph nodes positive"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"此變項為預測重要變數,若無此資訊預測容易失真。", "en"=>"Regional lymph nodes positive is a key predictive variable. If this information is omitted, the prediction result would be biased."}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"4"=>{"variable"=>"grade", "name"=>{"zh_tw"=>"腫瘤分化程度<br/>(Tumor grade)", "en"=>"Tumor grade"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分化級數資訊,請選擇“未知”選項,將以級數 2 進行預測。", "en"=>"The grade refers to how different the cancer cells are from normal cells. Please select “unknown” if there is no information about grade. The prediction model would use “grade 2” as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["1", "2", "3", "未知"], "en"=>["1", "2", "3", "unknown"]}, "range"=>[], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"5"=>{"variable"=>"ER_status", "name"=>{"zh_tw"=>"ER 狀態<br/>(ER status)", "en"=>"ER status"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"ER:雌激素受體,若無 ER 資訊請選擇未知,將以佔多數比例陽 性作為後續預測。", "en"=>"ER status describes the status of estrogen receptor. Please select “unknown” if there is no information about ER status. The prediction model would use “Positive” (the majority class) as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["陽性", "陰性", "未知"], "en"=>["positive", "negative", "unknown"]}, "range"=>[], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"6"=>{"variable"=>"PR_status", "name"=>{"zh_tw"=>"PR 狀態<br/>(PR status)", "en"=>"PR status"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"PR:黃體素受體, 若無 PR 資訊請選擇未知,將以佔多數比例陽性作為後續預測。", "en"=>"PR status describes the status of progesterone receptor. Please select “unknown” if there is no information about PR status. The prediction model would use “Positive” (the majority class) as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["陽性", "陰性", "未知"], "en"=>["positive", "negative", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"7"=>{"variable"=>"HER2_status", "name"=>{"zh_tw"=>"HER2 狀態<br/>(HER2 status)", "en"=>"HER2 status"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"HER2:第二型人類上皮成長因子接受器蛋白,若無 HER2 資訊請選擇未知,將以佔多數比例陰性作為後續預測。", "en"=>"HER2 status describes the status of human epidermal growth factor receptor 2. Please select “unknown” if there is no information about HER2 status. The prediction model would use “Negative” (the majority class) as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["陽性", "陰性", "未知"], "en"=>["positive", "negative", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"8"=>{"variable"=>"Distant_Metastasis", "name"=>{"zh_tw"=>"遠端轉移<br/>(Distant Metastasis)", "en"=>"Distant Metastasis"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"若無遠端轉移資訊請選擇未知,將以佔多數比例未遠端轉移作為後續預測。", "en"=>"Please select “unknown” if there is no information about distant Metastasis. The prediction model would use “No” (the majority class) as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["", "", "未知"], "en"=>["yes", "no", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"9"=>{"variable"=>"micrometastasis", "name"=>{"zh_tw"=>"淋巴結顯微轉移<br/>(Lymph nodes micrometastasis)", "en"=>"Micrometastasis"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"若無顯微移資訊請選擇未知,將以無顯微轉移作為後續預測。", "en"=>"Please select “unknown” if there is no information about lymph nodes micrometastasis. The prediction model would use “No” as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["", "", "未知"], "en"=>["yes", "no", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"10"=>{"variable"=>"tumor_direct_extension", "name"=>{"zh_tw"=>"腫瘤浸潤至胸壁和/或皮膚<br/>(Tumor direct extension to the chest wall and/or to the skin)", "en"=>"Tumor direct extension to the chest wall and/or to the skin"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"若無腫瘤浸潤至胸壁或皮膚資訊請選擇未知,將以佔多數比例無腫瘤浸潤至胸壁作為後續預測。", "en"=>"Please select “unknown” if there is no information about tumor direct extension to the chest wall and/or to the skin. The prediction model would use “No” (the majority class) as the alternative variable"}, "choice_fields"=>{"zh_tw"=>["", "", "未知"], "en"=>["yes", "no", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"11"=>{"variable"=>"lvi", "name"=>{"zh_tw"=>"淋巴管或血管侵犯<br/>(Lymph vessel or vascular invasion, LVI)", "en"=>"Lymph vessel or vascular invasion, LVI"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>"Lymph vessel or vascular invasion"}, "comment_text"=>{"zh_tw"=>"若無淋巴管或血管侵犯資訊,請選擇“未知”選項,將以佔多數比例的淋巴管或血管未侵犯進行預測", "en"=>"Please select “unknown” if there is no information about Lymph vessel or vascular invasion. The prediction model would use “No” (the majority class) as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["", "", "未知"], "en"=>["yes", "no", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]}
}
field :form_show_in_result , :type=> Hash ,default:{0=>{:variable=>"hormone_therapy",:name=>{"zh_tw"=>"賀爾蒙治療","en"=>"Hormone/Steroid therapy"},:is_num=>0, :hint=>{'zh_tw'=>'適用賀爾蒙受體陽性病人','en'=>'Hormone/ steroid therapy is available when ER status is positive'} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
1=>{:variable=>"Chemotherapy",:name=>{"zh_tw"=>"化學治療","en"=>"Chemotherapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
2=>{:variable=>"Radiotherapy",:name=>{"zh_tw"=>"放射治療","en"=>"Radiotherapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
3=>{:variable=>"Targeted_therapy",:name=>{"zh_tw"=>"標靶治療","en"=>"Targeted therapy"},:is_num=>0,:hint=>{'zh_tw'=>'抗HER2治療','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]}
field :form_show_in_result , :type=> Hash ,default: {
"0"=>{"variable"=>"hormone_therapy", "name"=>{"zh_tw"=>"賀爾蒙治療", "en"=>"Hormone/Steroid therapy"}, "is_num"=>0, "hint"=>{"zh_tw"=>"適用賀爾蒙受體陽性病人", "en"=>"Hormone/ steroid therapy is available when ER status is positive"}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", ""], "en"=>["No", "Yes"]}, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>0, "map_values"=>"", "active_choice"=>2, "disable_condition"=>"ER_status == 2 && PR_status == 2", "lpv_impact"=>-0.8397},
"1"=>{"variable"=>"Chemotherapy", "name"=>{"zh_tw"=>"化學治療", "en"=>"Chemotherapy"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", ""], "en"=>["No", "Yes"]}, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>0, "map_values"=>"", "active_choice"=>2, "disable_condition"=>"", "lpv_impact"=>-0.4147},
"2"=>{"variable"=>"Radiotherapy", "name"=>{"zh_tw"=>"放射治療", "en"=>"Radiotherapy"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", ""], "en"=>["No", "Yes"]}, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>0, "map_values"=>"", "active_choice"=>2, "disable_condition"=>"", "lpv_impact"=>-0.3203},
"3"=>{"variable"=>"Targeted_therapy", "name"=>{"zh_tw"=>"標靶治療", "en"=>"Targeted therapy"}, "is_num"=>0, "hint"=>{"zh_tw"=>"抗HER2治療", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", ""], "en"=>["No", "Yes"]}, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>0, "map_values"=>"", "active_choice"=>2, "disable_condition"=>"HER2_status != 1", "lpv_impact"=>-0.4687}
}
field :form_result_is_right , :type=> Integer ,default: 0
field :text_descibe ,type:Hash ,default:{"zh_tw"=>"歡迎使用台灣準備乳癌預後系統!<br/>本預測系統由台灣癌症登記資料庫2011至2015年間共90,841位乳癌病人所建立 <br/>若要開始 請在下方輸入相關資訊","en"=>"Welcome to the Taiwan Breast Cancer Prediction System!<br/>The prediction system is constructed using clinical data from 90,841 breast cancer patients in the Taiwan Cancer Registry database between 2011 to 2015, and validated using clinical data from 49,374 breast cancer patients in the U.S.-based Surveillance, Epidemiology and End Results (SEER) database. <br/>To start, please select the information below."}
field :text_descibe ,type:Hash ,default: {
"zh_tw"=>"歡迎使用台灣準備乳癌預後系統!<br />\r\n本預測系統由台灣癌症登記資料庫2011至2015年間共20,997位乳癌病人所建立<br />\r\n並驗證美國流行病學癌症資料庫59,271位病人所建立 。<br />\r\n若要開始 請在下方選擇相關資訊",
"en"=>"Welcome to the Taiwan Breast Cancer Prediction System!<br />\r\nThe prediction system is constructed using clinical data from 90,841 breast cancer patients in the Taiwan Cancer Registry database between 2011 to 2015, and validated using clinical data from 49,374 breast cancer patients in the U.S.-based Surveillance, Epidemiology and End Results (SEER) database.<br />\r\nTo start, please select the information below."
}
field :small ,type:Hash ,default:{'font_size'=>"0.825em",'active'=>0}
field :medium ,type:Hash ,default:{'font_size'=>"1em",'active'=>1}
field :large ,type:Hash ,default:{'font_size'=>"1.25em",'active'=>0}
field :head_images_id ,type:Array , default: [BSON::ObjectId('5df62cfc8cd8924e79000009'), BSON::ObjectId('5df745a58cd8924491000006'), BSON::ObjectId('5df745a58cd8924491000007'), BSON::ObjectId('5df745a58cd8924491000008'), BSON::ObjectId('5df745a58cd8924491000009')]
field :head_images_id ,type:Array , default: [BSON::ObjectId('5df62cfc8cd8924e79000009'), BSON::ObjectId('5df745a58cd8924491000006'), BSON::ObjectId('5e7848c98cd8924f8d00004a'), BSON::ObjectId('5ea8f3e48cd892760b000011')]
field :title_images_id ,type:Array , default: [BSON::ObjectId('5df87cd88cd8924491000036')]
field :title_texts ,type:Hash ,default:{'zh_tw'=>'華人癌症存活預測','en'=>'Asian breast cancer prediction'}
field :table_above_texts ,type:Hash ,default:{'zh_tw'=>"下表之分析為針對手術後病人根據選定的術後治療分別估計在第1年、3及5年的存活率。",'en'=>'The analysis is for women who had undergone surgery.The table shows the 1-, 3- and 5-year survival rates,based on the treatment you have selected.'}
field :text_above_texts ,type:Hash ,default:{'zh_tw'=>"此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,在術後<br/>第{{years}}年,",'en'=>'The analysis is for women who had undergone surgery. Base on the information and the treatment you have selected, the predictions of survival status<br/>{{years}}'}
field :surgery_only_texts ,type:Hash ,default:{'zh_tw'=>'100 位只接受根除性手術的婦女中,有{{Surgery_only}}位婦女,術後{{surgery_year}}年仍為存活','en'=>'after surgery are as follows:<br/>{{Surgery_only}} out of 100 women treated with surgery only are alive at {{surgery_year}} years.'}
field :extra_texts ,type:Hash ,default:{'zh_tw'=>',此外','en'=>''}
field :extra_therapy_texts ,type:Hash ,default:{'zh_tw'=>'100 位在術後有接受{{extra_therapy}}的婦女中,有{{survival_num}}位婦女,術後{{surgery_year}}年仍為存活(多了{{Additional_Benefit}}位)','en'=>'{{survival_num}} out of 100 women treated with {{extra_therapy}} are alive (an extra {{Additional_Benefit}})'}
field :danger_texts ,type:Hash ,default:{'zh_tw'=>'請注意紅框的輸入資料是否符合要求!','en'=>'Please check whether input data in red blocks are correct!'}
field :title_texts ,type:Hash ,default: {"zh_tw"=>"華人癌症存活預測", "en"=>"Asian breast cancer prediction"}
field :table_above_texts ,type:Hash ,default: {"zh_tw"=>"下表之分析為針對手術後病人根據選定的術後治療分別估計在第1年、3 及5年的存活率。", "en"=>"The analysis is for women who had undergone surgery.The table shows the 1-, 3- and 5-year survival rates,based on the treatment you have selected."}
field :text_above_texts ,type:Hash ,default: {"zh_tw"=>"此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,在術後<br/>第{{years}}年,", "en"=>"The analysis is for women who had undergone surgery. Base on the information and the treatment you have selected, the predictions of survival status<br/>{{years}}"}
field :surgery_only_texts ,type:Hash ,default: {"zh_tw"=>"100 位只接受根除性手術的婦女中,有{{Surgery_only}}位婦女,術後{{surgery_year}}年仍為存活", "en"=>"after surgery are as follows:<br/>{{Surgery_only}} out of 100 women treated with surgery only are alive at {{surgery_year}} years."}
field :extra_texts ,type:Hash ,default: {"zh_tw"=>",此外", "en"=>""}
field :extra_therapy_texts ,type:Hash ,default: {"zh_tw"=>"100 位在術後有接受{{extra_therapy}}的婦女中,有{{survival_num}}位婦女,術後{{surgery_year}}年仍為存活(多了{{Additional_Benefit}}位)", "en"=>"{{survival_num}} out of 100 women treated with {{extra_therapy}} are alive (an extra {{Additional_Benefit}})"}
field :danger_texts ,type:Hash ,default: {"zh_tw"=>"請注意紅框的輸入資料是否符合要求!", "en"=>"Please check whether input data in red blocks are correct!"}
field :years ,type:Array ,default:[1,3,5]
field :texts_between_Result_and_result_block ,type:Hash ,default:{'zh_tw'=>'如果欲將預測結果應用於臨床上,請務必與您的主治醫師討論後再做最後決定。','en'=>'Please note that the patients need to consult with their medical doctors before making any decision.'}
field :texts_between_Result_and_result_block ,type:Hash ,default: {"zh_tw"=>"如果欲將預測結果應用於臨床上,請務必與您的主治醫師討論後再做最後決定。", "en"=>"Please note that the patients need to consult with their medical doctors before making any decision."}
#field :image_uploader ,type:Object
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
scope :is_approved, ->{where(:approved => true)}
field :prediction_formula , type: String ,default: "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.3321)
)"
field :years_settings , type: Array , default: ["exp(-0.001476145)^( exp(lpv) )","exp(-0.01261639)^( exp(lpv) )","exp(-0.02519608)^( exp(lpv) )"]
field :tmp_years_settings , type: Array , default: []
field :tmp_years_settings_for_ruby , type: Array , default: []
field :hidden_variables, type: String, default: "age1 = (age / 100.0) ^ (0.5)
age2 = age1 * log(age / 100.0)
size1 = log(size / 10.0)
ratio = (lymph_nodes_examined == 0 ? 0 : (1.0 * lymph_nodes_positive / lymph_nodes_examined))
ratio = (ratio > 1 ? 1 : ratio)
T4 = (tumor_direct_extension == 1)
T1 = !T4 && (size <= 20)
T2 = !T4 && !T1 && (size > 20 && size <= 50)
T = (T4 ? 'T4' : (T1 ? 'T1' : (T2 ? 'T2' : 'T3')))
N0 = (lymph_nodes_positive == 0)
N1_or_N1mi = !N0 && (lymph_nodes_positive >= 1 && lymph_nodes_positive <= 3)
N1 = N1_or_N1mi && micrometastasis != 1
N1mi = N1_or_N1mi && micrometastasis == 1
N2 = !N0 && !N1_or_N1mi && (lymph_nodes_positive <= 9)
N = (N0 ? 'N0' : (N1 ? 'N1' : (N1mi ? 'N1mi' : (N2 ? 'N2' : 'N3'))))
M = (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 = (grade == 2 || grade == 4) ? 1 : 0
grade_3 = (grade == 3) ? 1 : 0
subtype_1 = (ER_status != 2 || PR_status != 2) && (HER2_status != 1)
subtype_2 = !subtype_1 && (HER2_status == 1)
subtype_3 = !subtype_1 && !subtype_2 && (ER_status == 2 && PR_status == 2 && 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 = (lvi == 1) ? 1 : 0
chemo = (Chemotherapy == 2) ? 1 : 0
radio = (Radiotherapy == 2) ? 1 : 0
hormone = (hormone_therapy == 2) ? 1 : 0
target = (Targeted_therapy == 2) ? 1 : 0
"
field :fix_hidden_variables, type: Array, default: []
field :tmp_hidden_variables_for_ruby, type: String, default: ""
field :tmp_hidden_variables_for_js, type: String, default: ""
field :lpv_calc, type: Hash, default: {} #for js code
field :tmp_lpv_ruby_code, type: String, default: ""
field :tmp_lpv_variables, type: Array, default: []
field :mapping_data_from_csv , type: String ,default: ""
field :all_variables, type: Array, default: []
field :treatment_method, type: Array, default: ['Surgery_only']
field :treatment_method_active_indices, type: Array, default: [1]
field :result_table, type: String, default: "", localize: true
field :result_text, type: String, default: "", localize: true
field :therapy_lpv, type: Array, default: [0]
#before_create :set_expire
def update_user
User.find(update_user_id) rescue nil
before_save do
self.form_show.each do |num,property|
property[:need_map_values] = (property[:map_values].class == Array && property[:choice_fields].class == Array && property[:map_values].length == property[:choice_fields].length) ? 1 : 0
end
def update_user=(user)
self.update_user_id = user.id
result_keys = []
self.form_show.each do |num,property|
variable_name = property[:variable]
if variable_name.present?
result_keys << variable_name
end
def email_members
MemberProfile.find(self.email_member_ids) rescue []
end
def email_addresses
addresses = self.email_members.collect{|member| member.email} rescue []
addresses = addresses +[self.other_mailaddress] if !self.other_mailaddress.blank?
addresses.flatten
self.form_show_in_result.each do |num,property|
variable_name = property[:variable]
if variable_name.present?
result_keys << variable_name
end
def email
mail = Email.find(self.email_id) rescue nil
end
def expired?
(self.deadline < Time.now) rescue false
mapping_data = JSON.parse(self.mapping_data_from_csv) rescue {}
if self.advance_mode && mapping_data.present?
mapping_data.each do |k,v|
result_keys += (v.keys rescue [])
end
def destroy_email
mail = Email.find(self.email_id) rescue nil
mail.destroy if !mail.nil?
end
def self.remove_expired_status
self.where(:is_top => true, :top_end_date.ne => nil, :top_end_date.lt => Time.now).each do |b|
b.is_top = false
b.top_end_date = nil
b.save
result_keys = result_keys.uniq
self.all_variables = result_keys
formula = text_to_math(self.prediction_formula)
tmp_hidden_variables = text_to_math(self.hidden_variables)
result_keys.each do |k|
formula = formula.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
tmp_hidden_variables = tmp_hidden_variables.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
end
self.tmp_hidden_variables_for_js = tmp_hidden_variables.rstrip.gsub(/\n\s+/,"\n ").gsub("\n",";\n") + ";"
self.fix_hidden_variables = []
self.tmp_hidden_variables_for_ruby = tmp_hidden_variables.split(/^([^=]+)=([^=])/).select{|s| s.present?}.each_slice(2).map do |a,b|
a = a.strip
self.fix_hidden_variables << a
if b
puts ("result[\"#{a}\"]=" + b)
("result[\"#{a}\"]=" + b)
else
a
end
end.join("\n")
self.fix_hidden_variables = self.fix_hidden_variables.uniq
formula = formula.split(/^([^=]+)=([^=])/).select{|s| s.present?}.each_slice(2).map do |a,b|
a = a.strip
if b
("result[\"#{a}\"]=" + b)
else
a
end
end.join("\n")
self.fix_hidden_variables.each do |v|
formula = formula.gsub(/(\A|[^\w\"])#{v}($|[^\w])/){|f| "#{$1}result[\"#{v.strip}\"]#{$2}"}
self.tmp_hidden_variables_for_ruby = self.tmp_hidden_variables_for_ruby.gsub(/(\A|[^\w\"])#{v}($|[^\w])/){|f| "#{$1}result[\"#{v.strip}\"]#{$2}"}
end
self.tmp_lpv_ruby_code = formula
formula_variables = formula.enum_for(:scan,/([^\=\(\)]+)?=[^=]/).map {|x| x[-1] }.compact.map{|s| s.strip[8..-3]}
self.tmp_lpv_variables = formula_variables
self.tmp_years_settings = self.years_settings.map do |s|
text_to_math(s)
end
self.tmp_years_settings_for_ruby = self.tmp_years_settings.clone
formula_variables.each do |variable_name|
self.tmp_years_settings_for_ruby = self.tmp_years_settings_for_ruby.map do |y|
y.gsub(variable_name,"result[\"#{variable_name}\"]")
end
end
self.treatment_method = ['Surgery_only']
self.form_show_in_result.values.each do |choice|
variable = choice["variable"]
if variable.present?
self.treatment_method << variable
end
end
tmp_table_translations = {}
tmp_text_translations = {}
@years = self.years
@head_name = ['Treatment','Additional_Benefit','Overall_Survival']
# @head_name = ['Treatment','Overall_Survival']
@table_head = @head_name.map{|name| I18n.t('cancerpredict.table.'+name)}
@therapy_names = self.treatment_method
I18n.available_locales.each do |locale|
I18n.with_locale(locale) do
@therapy_choices = [I18n.t('cancerpredict.table.Surgeryonly')]
self.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]}
tmp_table = "<span class=\"result_title print_only\">#{I18n.t("cancerpredict.table.table")}</span><div style=\"clear: both\"></div>"
tmp_table += '<input id="current_year" type="hidden" value="'+@years[-1].to_s+'" index="0"/><p id="cancer_table_texts">'+self.table_above_texts[locale].to_s+'</p>'
tmp_table += ('<a style="display: inline-block;">'+(locale.to_s == 'zh_tw' ? '第' : '')+'</a><a style="display: inline-block;">')
@years.each{|year| tmp_table += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year.to_s+'</button>')}
tmp_table += ('</a><a style="display: inline-block;">'+(locale == 'zh_tw' ? '年' : '')+'</a>')
tmp_table += '<table><thead><tr>'
@table_head.each_with_index{|head,index| tmp_table += ('<th class="cancer_th '+@head_name[index]+'">' + head + '</th>')}
tmp_table += '</tr></thead><tbody>'
@therapy_choices.each_with_index do |choice,i|
tmp_table += '<tr class="'+@therapy_names[i].to_s+'">'
@table_head.each_with_index do |head,index|
tmp_table += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '</td>')
end
tmp_table += '</tr>'
end
tmp_table_translations[locale] = tmp_table
@texts = self.text_above_texts[locale].to_s.gsub('<br/>','</span><br/><span>').gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival"></span>')
@texts = @texts.split('{{years}}')
@texts.delete('')
tmp_text = "<span class=\"result_title print_only\">#{I18n.t("cancerpredict.table.text")}</span><div style=\"clear: both\"></div>"
tmp_text += ('<span>'+@texts[0])
@years.each{|year| tmp_text += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm" style="float:none;">'+year.to_s+'</button>')}
if @texts.count > 1
tmp_text += (@texts[1]+'</span>') if @texts.count > 1
else
tmp_text += '</span>'
end
if !self.surgery_only_texts[locale].blank?
@surgery_only_texts = self.surgery_only_texts[locale]
@surgery_only_texts.insert(0,'<p class="show"><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival"></span><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{surgery_year}}','</span><span class="surgery_year">'+@years[-1].to_s+'</span><span>')
@surgery_only_texts += '</span>'
else
@surgery_only_texts = ''
end
tmp_text += @surgery_only_texts
tmp_text += '<span class="addition">'+self.extra_texts[locale]+'</span><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div></div></p>'
tmp_text_translations[locale] = tmp_text
end
end
self.result_table_translations = tmp_table_translations
self.result_text_translations = tmp_text_translations
self.treatment_method_active_indices = [1]
self.form_show_in_result.each do |num, property|
v = property[:active_choice]
if v.present?
self.treatment_method_active_indices << (v - 1)
else
self.treatment_method_active_indices << 1
end
end
self.lpv_calc = get_years_settings_dict
self.generate_eval_formula
end
def generate_eval_formula
eval_hidden_variables = "def eval_hidden_variables(result); #{self.tmp_hidden_variables_for_ruby}; end"
CancerpredictsController.module_eval(eval_hidden_variables)
eval_formula = "def eval_formula(result); #{self.tmp_lpv_ruby_code}; end"
CancerpredictsController.module_eval(eval_formula)
end
def generate_jscode
js_code = "var map_values , mapping_hash , temp_index ,temp_value , index , closest_value;\r\n"
mapping_data_from_csv = JSON.parse(self.mapping_data_from_csv) rescue {}
tmp_hash = self.form_show.values + self.form_show_in_result.values
tmp_hash.each do |property|
@variable = property[:variable]
if @variable.present?
if property[:is_num] == 1
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
elsif property[:choice_fields].present?
if !(self.advance_mode)
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
else
if property[:need_map_values] == 1
js_code += " map_values = #{property[:map_values]};\r\n"
js_code += " result['#{@variable}'] = map_values[Number(result_json['#{@variable}'']) - 1];\r\n"
else
if property[:revert_value] != 1
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']) - 1;\r\n"
else
js_code += " result['#{@variable}'] = (#{property[:choice_fields].length} - Number(result_json['#{@variable}']));\r\n"
end
end
end
end
if self.advance_mode && property[:cancer_predict_mapping_file].present?
if (mapping_data_from_csv != {} && !mapping_data_from_csv[@variable].blank?)
js_code += " mapping_hash = mapping_data_from_csv['#{@variable}'];\r\n"
js_code += " temp_index = 0;\r\n"
js_code += " temp_value = result[#{@variable}];\r\n"
js_code += " index = 0;
$.each(mapping_hash,function(k,v){
if( i == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});\r\n"
end
end
end
end
js_code += "\n Object.keys(result).forEach(function(k){
if(Number.isNaN(result[k])){
result[k] = 0;
}
})"
js_code += "\n #{self.tmp_hidden_variables_for_js}"
formula = text_to_math(self.prediction_formula)
self.all_variables.each do |k|
formula = formula.gsub(/#{k}?(-|\+|\*|\s|\=)/){ "result[\"#{k.strip}\"]#{$1}" }
end
formula_variables = self.tmp_lpv_variables.map{|v| v}
js_code = "\n function calculate_first_lpv(result_json){
result = {};
#{js_code}
try{
#{formula.gsub(/\s{2,10}/," ").gsub("\n","\n ")}
}catch(e){console.log(e)};
result['lpv_variable'] = {};
#{formula_variables.map{|v| "result['lpv_variable']['#{v}'] = #{v};"}.join("\n ") }
result['lpv'] = #{formula_variables.count == 0 ? 0 : formula_variables.last};
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]));
};"
@years = self.years
switch_texts = "
#{formula_variables.map{|v| "var #{v} = obj['#{v}'];"}.join("\n ")}
switch(year) {"
@years.each do |year|
year_index = @years.index(year)
switch_texts +=
"
case '#{year}':
servive_ratio = #{text_to_math(self.years_settings[year_index])};
break;"
end
switch_texts += "
default:
console.log('not found year.');
}"
js_code = js_code +"
function calculate_servive_ratio(year,obj){
var servive_ratio;#{switch_texts}
return servive_ratio;
}
"
return js_code
end
def text_to_math(text)
text.gsub("\r\n","\n").gsub('^','**').gsub('exp','Math.exp').gsub('log','Math.log')
end
def replace_str_with_idx(org_str,st, ed, replace_str)
org_str.slice!(st, ed - st + 1)
org_str.insert(st, replace_str)
org_str
end
def auto_write_predict_js
js_codes = generate_jscode
module_app_path = Pathname.new(File.expand_path(__dir__)).dirname.dirname.to_s
save_path = module_app_path + '/app/assets/javascripts/cancer_predict.js'
file_texts = File.read(save_path)
need_write = false
str1 = "/* auto add start */"
index1 = file_texts.index(str1)
str2 = "/* auto add end */"
index2 = file_texts.index(str2)
if (!index1.nil? && !index2.nil?)
file_texts = replace_str_with_idx(file_texts, index1 + str1.length, index2 - 1, js_codes)
need_write = true
end
str3 = "/*lpv_calc_formula_start*/"
index3 = file_texts.index(str3)
str4 = "/*lpv_calc_formula_end*/"
index4 = file_texts.index(str4)
if (!index3.nil? && !index4.nil?)
file_texts = replace_str_with_idx(file_texts, index3 + str3.length, index4 - 1, self.lpv_calc.to_json.gsub("@",".") + ';')
need_write = true
end
tmp_disable_jscodes = ""
str5 = "/*disable_condition start*/"
index5 = file_texts.index(str5)
str6 = "/*disable_condition end*/"
index6 = file_texts.index(str6)
self.form_show_in_result.each do |num,property|
if property[:disable_condition].present?
tmp = property[:disable_condition].clone
self.all_variables.each do |k|
tmp = tmp.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}post_json[\"#{k}\"]#{$2}" }
end
variable = property[:variable]
tmp_disable_jscodes += "\n if(#{tmp}){
$('##{variable} .cancer_table_btn').attr('disabled','disabled');
$('[for=\"#{variable}\"]').css('color','rgb(204, 204, 204)');
}else{
$('##{variable} .cancer_table_btn').removeAttr('disabled');
$('[for=\"#{variable}\"]').css('color','');
}"
end
end
if (!index5.nil? && !index6.nil?)
tmp_disable_jscodes += "\n\t\t\t"
file_texts = replace_str_with_idx(file_texts, index5 + str5.length, index6 - 1, tmp_disable_jscodes)
need_write = true
end
str7 = "/*therapy_lpv start*/"
index7 = file_texts.index(str7)
str8 = "/*therapy_lpv end*/"
index8 = file_texts.index(str8)
self.therapy_lpv = [0]
self.form_show_in_result.each do |num,property|
if property[:lpv_impact].present?
self.therapy_lpv << property[:lpv_impact]
else
self.therapy_lpv << 0
end
end
if (!index7.nil? && !index8.nil?)
file_texts = replace_str_with_idx(file_texts, index7 + str7.length, index8 - 1, self.therapy_lpv.to_s + ';')
need_write = true
end
if need_write
File.write(save_path,file_texts)
end
end
def get_years_settings_dict
lpv_variable_name = (prediction_formula.include?("=") ? prediction_formula.split("=")[0].strip : "" rescue "")
res = self.years.map.with_index do |y, i|
tmp_formula = self.tmp_years_settings[i]
if lpv_variable_name.present?
tmp_formula = tmp_formula.gsub(lpv_variable_name, "lpv_current")
else
tmp_formula = tmp_formula.gsub("lpv", "lpv_current")
end
[y.to_s.sub(".","@"), tmp_formula]
end
res.to_h
end
end

View File

@ -16,6 +16,10 @@ class Cancerpredictrecord
scope :is_approved, ->{where(:approved => true)}
before_save :set_submit_times
def set_submit_times
self.submit_time = Cancerpredictrecord.where(:title=> "cancerpredict").length + 1
self.submit_time = Cancerpredictrecord.all.count + 1
end
def check_missing_data
missing_keys = self.names.keys - self.result.keys rescue []
missing_keys.each{|k| self.result[k] = "" }
end
end

View File

@ -17,10 +17,11 @@ wb.add_worksheet(name: "school_class") do |sheet|
temp_row << result.created_at.to_s
result.result.each do |key,value|
if key != "locale"
if result.values[key][I18n.locale.to_s].length == 0
if (result.values[key][I18n.locale.to_s].length == 0 rescue true)
temp_row << value
else
temp_row << (result.values[key][I18n.locale.to_s][value.to_i-1] rescue value)
v = result.values[key][I18n.locale.to_s][value.to_i-1] rescue nil
temp_row << (v.nil? ? value : v)
end
end
end

View File

@ -1,472 +1,37 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#status" data-toggle="tab"><%= t(:status) %></a></li>
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
<li><a href="#mail-group" data-toggle="tab"><%= t('announcement.email_reminder')%></a></li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start_date) %></label>
<div class="controls">
<%= f.datetime_picker :postdate, :no_label => true, :new_record => @bulletin.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t(:end_date) %></label>
<div class="controls">
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @bulletin.new_record?, :data=>{"picker-type" => "range", "range" => "end"} %>
</div>
</div>
<div class="control-group">
<%= f.label :is_external_link, t("announcement.is_external_link"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :is_external_link %>
</div>
</div>
<div class="control-group" style="display: none;" id="external_link_box">
<%= f.label :external_link, t("announcement.external_link"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :external_link %>
<div class="hint"><%= t("announcement.external_link_hint") %></div>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @bulletin.is_top? || (!@bulletin.top_end_date.nil? && @bulletin.top_end_date > Time.now) %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
<div class="controls">
<% if !@bulletin.is_top? && !AnnouncementSetting.check_limit_for_user((@bulletin.new_record? ? current_user.id : @bulletin.create_user_id)) %>
<span>Top limit has been reached. The bulletin wont be marked as top even if you click on it.</span>
<% end %>
</div>
</div>
<div class="control-group <%= @bulletin.is_top? || (!@bulletin.top_end_date.nil? && @bulletin.top_end_date > Time.now) ? "" : "hide" %>" data-for="is_top">
<label for="" class="control-label muted">Top end time</label>
<div class="controls">
<%= f.datetime_picker :top_end_date, :no_label => true, :new_record => @bulletin.new_record? %>
</div>
</div>
</div>
<%# end %>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<%= select_tags(f, @module_app) %>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @bulletin.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @bulletin.image.file %>
<%= image_tag @bulletin.image %>
<tr>
<td class="remove_div">❌</td>
<td class="sort_div"></td>
<% keys.each do |key| %>
<td class="<%=key%>">
<% if key.include? "_file" %>
<%= render :partial => 'form_file', :object => (CancerPredictMappingFile.where(:id=> property[key]).first rescue nil), :locals => {:f => make_fields, :key=>key} %>
<% else %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% value = property[key] %>
<% value_type = Cancerpredictfields::FIELDINFO[key] %>
<% value = "[]" if property == {} && value_type == 'Array' %>
<% is_localized = Cancerpredictfields::NonLoclaized.exclude?(key) %>
<% @value= value %>
<% if is_localized %>
<% @disp_value = @value[I18n.locale.to_s] rescue "" %>
<%else%>
<% @disp_value = @value %>
<%end%>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :image %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_image %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :image_description_translations do |f| %>
<div class="control-group">
<label class="control-label muted" for="image_description_<%= locale.to_s %>"><%= t(:description) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_field locale, value: (@bulletin.image_description_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% field_type = ((value_type == 'String' || value_type == 'Array' || value_type == 'Float') ? "text_field" : value_type) %>
<% if value_type == 'Fixnum' %>
<% if @value == 1%>
<%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%>
<% else%>
<%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%>
<%end%>
<% elsif is_localized %>
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
<%= locale_fields.send(field_type, key,{:value=>@disp_value}) %>
<%end%>
<% else %>
<%= make_fields.send(field_type, key,{:value=>@disp_value})%>
<%end%>
<%end%>
</div>
<!-- Mail Group Module -->
<div class="tab-pane fade" id="mail-group">
<!-- Mail Group -->
<div class="control-group">
<label class="control-label muted"><%= t("announcement.email_to") %></label>
<div class="controls">
<label class="checkbox inline">
<%= check_box_tag('bulletin[email_sent]', '1', (!@bulletin.email_sent.blank? ? true : false), :id=>'remind-check') %><%= t('announcement.activate_email_reminder')%>
</label>
<div class="content-box">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'bulletin[email_member_ids][]', email_members: @bulletin.email_members} %>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label muted"></label>
<div class="controls">
<div class="content-box">
<span class="help-block"><%= "#{t("announcement.other_mailaddress")}(#{t("announcement.other_mailaddress_note")})"%> </span>
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
</div>
</div>
</div>
<div class="content-box">
<div class="control-group">
<label class="control-label muted"><%= t("announcement.email_sentdate") %></label>
<div class="controls">
<%= f.datetime_picker :email_sentdate, :no_label => true %>
</div>
</div>
</div>
<% if (@bulletin.email.is_sent rescue false) %>
<div class="content-box">
<div class="control-group">
<label class="control-label muted"><%= t("announcement.resend_mail") %></label>
<div class="controls">
<input type="checkbox" name="resend_mail" value="true">
</div>
</div>
</div>
<% end %>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@bulletin.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Sub Title -->
<div class="control-group input-subtitle">
<label class="control-label muted"><%= t(:subtitle) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :subtitle_translations do |f| %>
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@bulletin.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :text_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@bulletin.text_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_links.blank? %>
<div class="exist">
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
<%= render :partial => 'form_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_files.blank? %>
<div class="exist">
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
<%= render :partial => 'form_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= get_referer_url[:action] rescue "" %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %>
<%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %>
</div>
<span id='show_preview'>
<div class="modal hide fade in banner-preview" id="">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<iframe id="preview-iframe" src=""></iframe>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div>
</div>
</span>
<% if !@module_app.tags.empty? %>
<script type="text/javascript">
$("form.previewable").on("submit", function(){
if(!$("input[name='bulletin[tags][]']").is(":checked")){
if(!confirm("You have selected no tag, do you wish to continue?")){
return false;
}
}
})
</script>
<% end %>
<% content_for :page_specific_javascript do %>
<script>
function Appendzero(obj)
{
if(obj<10) return "0" +""+ obj;
else return obj;
}
$(function() {
if (location.pathname.substr(-3)=='new'){
var getDate = new Date();
var toDay = getDate.getFullYear()+"/"+ (Appendzero(getDate.getMonth()+1))+"/"+Appendzero(getDate.getDate())+" "+Appendzero(getDate.getHours())+":"+Appendzero(getDate.getMinutes());
$('input[name="bulletin[postdate]"]').val(toDay);
}
$("#main-wrap").after("");
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :bulletin_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :bulletin_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
$('#remind-check').prop('checked') ? '':$('.content-box').addClass('hide')
$('#remind-check').on('change', function() {
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
})
$('#button_for_preview').click(function(){
var method = $('.main-forms input[name="_method"]').val();
$('.main-forms input[name="_method"]').val("post");
for ( instance in CKEDITOR.instances )
CKEDITOR.instances[instance].updateElement();
var formData = new FormData( $('.main-forms')[0] );
formData.append("preview_type", ( (method==undefined) ? "new" : "edit" ));
formData.append("bulletin_id", '<%= @bulletin.id.to_s %>');
$.ajax({
type: "post",
url: '<%= admin_announcement_preview_path %>',
data : formData,
processData: false,
contentType: false
}).done(function(data){
if(window.location.protocol === "https:"){
data = data.replace("http:","https:");
}
$('.modal-body iframe').attr('src',data);
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
var slug = data.split('/')[(data.split('/').length-1)];
// $('#preview-iframe').on('load', function(){
// $.get('/admin/announcement/destroy_preview/'+slug,function(data){
// });
// });
});
$('.main-forms input[name="_method"]').val(method);
return false;
});
$("#bulletin_is_top").parent().on("click",function(){
setTimeout(function(){
if($("#bulletin_is_top").parent().hasClass("active")){
$("div[data-for=is_top]").removeClass("hide");
}else{
$("div[data-for=is_top]").addClass("hide");
$("div[data-for=is_top]").find("input[type=text]").val("");
}
},100)
})
$("#bulletin_is_external_link").on("click",function(){
if($(this).is(":checked")){
$("#external_link_box").show();
}else{
$("#external_link_box").hide();
}
})
});
</script>
</td>
<%end%>
<td><%= make_fields.hidden_field :old_num,:value=>num.to_s %></td>
</tr>

View File

@ -1,69 +1,33 @@
<% if form_file.new_record? %>
<% if form_file.nil? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.file.blank? %>
<% if form_file.temp_file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.temp_file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<%= f.fields_for key do |f|%>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
<%= f.file_field :temp_file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
<span class="fileupload-preview"><%= (form_file.nil? || form_file.temp_file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<span class="add-on btn-group btn" title="<%= t('archive.show_lang') %>">
<i class="icons-earth"></i> <span class="caret"></span>
<ul class="dropdown-menu">
<% @site_in_use_locales.each do |locale| %>
<li>
<label class="checkbox">
<%= check_box_tag "bulletin[bulletin_files_attributes][#{( form_file.new_record? ? 'new_bulletin_files' : "#{i}" )}][choose_lang][]", locale, form_file.choose_lang.include?(locale.to_s) %>
<%= t(locale.to_s) %>
</label>
</li>
<% end %>
</ul>
<%= hidden_field_tag 'bulletin[bulletin_files_attributes][0][choose_lang][]', '' %>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<% if !form_file.nil? %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<%= f.hidden_field :id,:value=>(form_file.id) %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>
<% end %>

View File

@ -1,5 +1,79 @@
<%= stylesheet_link_tag "lib/fileupload"%>
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
<%= stylesheet_link_tag "lib/togglebox"%>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%#= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%#= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<%= javascript_include_tag "form" %>
<% end %>
<style type="text/css">
.sort_div:before{
content: "\e096";
font-family: 'entypo';
cursor: pointer;
}
.sort_div{
padding: 1em;
}
.sort_table tbody td:last-child{
display: none;
}
.remove_div{
cursor: pointer;
}
.remove_div:hover{
font-size: 1.3em;
}
<% Cancerpredictfields::AdvanceFields.each do |field| %>
table .<%=field%>{
display: none;
}
table.advance_mode .<%=field%>{
display: block;
}
<% end%>
.solid_line_hr{
margin: 0.3em;
border-top: 0.2em dashed;
}
.sort_table input, .sort_table textarea{
font-family: sans-serif;
}
.advance_mode_help_btn{
float:left;
cursor: pointer;
padding: 0em 0.475em;
font-size: 1.25em;
border-radius: 1.5em;
background-color: rgb(210, 106, 2);
border-color: rgb(210, 106, 2);
color: white;
width: 1.8em;
height: 1.8em;
line-height: 1em;
}
</style>
<div id="show_advance_mode_modal" class="modal fade">
<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'>
<%= t("cancerpredict.module_mode") %>
</h4>
</div>
<div class="modal-body">
<%= t("cancerpredict.advance_mode_hint2").html_safe %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default">Close</button>
</div>
</div>
</div>
</div>
<div style="clear:both;"></div>
<%=form_for @form_to_show ,:url=>{:controller=>"cancerpredicts" ,:action=>"edit"} do |form|%>
<span class="show_span"><%= t('cancerpredict.title') %></span>
@ -154,13 +228,28 @@
<%end%>
<%end%>
<%end%>
<span class="show_span"><%= t('cancerpredict.module_mode') %></span>
<div style="clear:both;"></div>
<div class="control-group">
<label class="control-label" for="advance_mode" style="float: left; line-height: 30px;margin-right: 1em;">
<span style="float: left;"><%= t('cancerpredict.advance_mode') %></span>
<button type="button" class="advance_mode_help_btn" data-target="#show_advance_mode_modal"><i aria-hidden="true" class="fa fa-question"></i></button>
</label>
<div class="controls">
<input id="advance_mode" name="<%=form.object_name%>[advance_mode]" type="checkbox" class="toggle-check" data-disabled="<%=form.object.advance_mode == false%>">
</div>
</div>
<div style="clear:both;"></div>
<span class="show_span"><%= t('cancerpredict.Input_fields') %></span>
<div style="clear:both;"></div>
<table>
<table id="fields_table" class="sort_table <%=@form_to_show.advance_mode ? 'advance_mode' : '' %>">
<% keys = Cancerpredictfields::FIELDINFO.keys - Cancerpredictfields::TherapyOnly %>
<thead>
<tr>
<% @form_to_show.form_show.values[1].each do |key,vlaue|%>
<th><%=key%></th>
<th></th>
<th></th>
<% keys.each do |key|%>
<th class="<%=key%>"><%=t("cancerpredict.table.#{key}")%></th>
<%end%>
</tr>
</thead>
@ -168,34 +257,14 @@
<%= form.fields_for :form_show do |formfield|%>
<% @form_to_show.form_show.each do |num,property| %>
<%=formfield.fields_for num.to_s do |make_fields|%>
<tr>
<% property.each do |key,value|%>
<% @value= value %>
<% if @value.class == BSON::Document || @value.class == Hash %>
<% @disp_value = @value[I18n.locale.to_s] rescue "" %>
<%else%>
<% @disp_value = @value %>
<%end%>
<% if @value.class == Fixnum %>
<% if @value == 1%>
<td><%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%></td>
<% else%>
<td><%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%></td>
<%end%>
<% elsif @value.class == BSON::Document || @value.class == Hash %>
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
<td><%= locale_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<% else %>
<td><%= make_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<%end%>
</tr>
<%= render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>property,:num=>num,:keys => keys} %>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<button id="add_field" type="button" class="btn btn-primary"><%= t('cancerpredict.table.add_field') %></button>
<div style="clear:both;"></div>
<span class="show_span"><%=t('cancerpredict.table.Results')%></span>
<div style="clear:both;"></div>
<label for="form_result_is_right" style="float: left;"><%= t('cancerpredict.result_is_right') %></label>
@ -217,11 +286,14 @@
<% end %>
<div style="clear:both;"></div>
<% end %>
<table>
<table id="therapies_table" class="sort_table <%=@form_to_show.advance_mode ? 'advance_mode' : '' %>">
<thead>
<tr>
<% @form_to_show.form_show_in_result.values[1].each do |key,vlaue|%>
<th><%=key%></th>
<th></th>
<th></th>
<% keys = Cancerpredictfields::TherapyFields %>
<% keys.each do |key,vlaue|%>
<th class="<%=key%>"><%=t("cancerpredict.table.#{key}")%></th>
<%end%>
</tr>
</thead>
@ -229,40 +301,174 @@
<%= form.fields_for :form_show_in_result do |formfield|%>
<% @form_to_show.form_show_in_result.each do |num,property| %>
<%=formfield.fields_for num.to_s do |make_fields|%>
<tr>
<% property.each do |key,value|%>
<% @value= value %>
<% if @value.class == BSON::Document || @value.class == Hash %>
<% @disp_value = @value[I18n.locale.to_s] rescue "" %>
<%else%>
<% @disp_value = @value %>
<%end%>
<% if @value.class == Fixnum %>
<% if @value == 1%>
<td><%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%></td>
<% else%>
<td><%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%></td>
<%end%>
<% elsif @value.class == BSON::Document || @value.class == Hash %>
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
<td><%= locale_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<% else %>
<td><%= make_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<%end%>
</tr>
<%= render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>property,:num=>num,:keys => Cancerpredictfields::TherapyFields} %>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<button id="add_therapy" type="button" class="btn btn-primary"><%= t('cancerpredict.table.add_therapy') %></button>
<div style="clear:both;"></div>
<span class="show_span"><%=t('cancerpredict.table.calculate_settings')%></span>
<div style="clear:both;"></div>
<div class="control-group">
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
<label><%= t('cancerpredict.hidden_variables') %></label>
</div>
<div class="controls">
<%= form.text_area :hidden_variables, :rows=>"5", :style=> 'width: 100%;font-family: sans-serif;' %>
</div>
</div>
<div style="clear:both;"></div>
<div class="control-group">
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
<label><%= t('cancerpredict.table.prediction_formula') %></label>
</div>
<div class="controls">
<%= form.text_area :prediction_formula, :rows=>"5", :style=> 'width: 100%;font-family: sans-serif;' %>
</div>
</div>
<div id="years_settings">
<% years = @form_to_show.years %>
<% years.each_with_index do |year,i| %>
<div data-year="<%= year.to_s.strip %>">
<div class="control-label" style="float: left;margin-right: 1em;width: 13em;">
<label style="font-family: sans-serif;"><%=t("cancerpredict.Overall_Survival")%>(t=<%=year%> Year)</label>
</div>
<div class="controls">
<textarea name="<%= form.object_name %>[years_settings][]" style= "width: calc(100% - 16em);" value="<%= @form_to_show.years_settings[i] rescue '' %>"><%= @form_to_show.years_settings[i] rescue '' %></textarea>
</div>
</div>
<% end %>
</div>
<%=form.submit "#{t(:updatefont)}",{:id=>"updatebtn"}%>
<%end%>
<link href="/assets/admin/cancerpredict.css" media="screen" rel="stylesheet">
<script>
$(".advance_mode_help_btn").click(function(){
$("#show_advance_mode_modal").modal();
})
$("#show_advance_mode_modal button").click(function(){
$("#show_advance_mode_modal").modal("hide");
})
$("#advance_mode").click(function(){
if(window.confirm("<%=t('cancerpredict.advance_mode_hint1').gsub("\n","\\n")%>")){
$("#fields_table,#therapies_table").toggleClass("advance_mode");
}else{
return false;
}
})
$('.text_choice').click(function(){
$('.text_choice').prop('checked' , false);
$(this).prop('checked' , true);
});
$("#add_field").click(function(){
var index = $("#fields_table tbody tr").length.toString();
<%= fields_for :cancerpredictfields do |form|%>
<%= form.fields_for :form_show do |formfield|%>
<%=formfield.fields_for :new_index do |make_fields|%>
<% keys = Cancerpredictfields::FIELDINFO.keys - Cancerpredictfields::TherapyOnly %>
var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
$("#fields_table tbody").append(html.replaceAll('new_index',index));
<% end %>
<% end %>
<% end %>
$(".remove_div").off("click").on("click",function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
})
$("#add_therapy").click(function(){
var index = $("#therapies_table tbody tr").length.toString();
<%= fields_for :cancerpredictfields do |form|%>
<%= form.fields_for :form_show_in_result do |formfield|%>
<%=formfield.fields_for :new_index do |make_fields|%>
<% keys = Cancerpredictfields::TherapyFields %>
var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
$("#therapies_table tbody").append(html.replaceAll('new_index',index));
<% end %>
<% end %>
<% end %>
$(".remove_div").off("click").on("click",function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
})
function update_key(ele){
console.log($(ele))
var ui_child=$(ele).parent().find('> tr');
console.log(ui_child);
for (var i=0;i<ui_child.length;i++){
var now_ele = ui_child.eq(i);
var $inputs = now_ele.find('input');
$inputs.each(function(input_index,input){
var name = input.name;
name = $.map(name.split(/(\[|\])/),function(v,ii){
var vv = v;
var num = Number.parseInt(vv);
if(!Number.isNaN(num)){
vv = i.toString();
}
return vv;
}).join("");
console.log(name)
input.name = name;
})
}
}
$( ".sort_table > tbody" ).sortable({
axis: "y",
revert: true,
placeholder: "sortable-placeholder",
handle: ".sort_div",
update: function(event, ui) {
update_key($(ui.item[0]))
}
});
$(".remove_div").click(function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
$(".remove_existing_record").click(function(){
if(window.confirm("Are you sure want to remove this file?")){
$(this).find(".should_destroy").val("1");
$(this).parent().siblings(".file-link").remove();
}
})
$("#years").on('blur',function(){
var years = [];
try{
years = $(this).val().split(/\[|,|\]/).filter(function(aa){return aa !="" && aa != undefined}).map(function(aa){return aa.trim()});
}catch(e){};
var index = 0;
years.forEach(function(year){
if($("#years_settings [data-year='"+year+"']").length == 0){
var year_text = ('<div data-year="'+year+'">'+
'<div class="control-label" style="float: left;margin-right: 1em;width: 13em;">'+
'<label style="font-family: sans-serif;"><%=t("cancerpredict.Overall_Survival")%>(t='+year+' Year)</label>'+
'</div>'+
'<div class="controls">'+
'<textarea name="cancerpredictfields[years_settings][]" style= "width: calc(100% - 16em);"></textarea>'+
'</div>'+
'</div>');
if(index != 0){
$("#years_settings [data-year='"+years[index - 1]+"']").after(year_text);
}else{
$("#years_settings").html(year_text+$("#years_settings").html());
}
}
index++;
})
var all_years = $("#years_settings [data-year]").map(function(i,aa){return $(aa).attr("data-year").toString().trim() }).toArray();
all_years.forEach(function(a_year){
if(years.indexOf(a_year) == -1){
$("#years_settings [data-year='"+a_year+"']").remove()
}
})
})
</script>

View File

@ -36,7 +36,7 @@
<% if result.values[key][I18n.locale.to_s].length == 0 %>
<td><%= value.to_s %></td>
<% else %>
<td><%= result.values[key][I18n.locale.to_s][value.to_i-1] rescue value %></td>
<td><% v = result.values[key][I18n.locale.to_s][value.to_i-1] rescue nil %><%= v.nil? ? value : v %></td>
<% end %>
<% end %>
<%end%>

View File

@ -1,5 +1,7 @@
# -*- encoding: utf-8 -*-
# stub: cancerpredict 0.0.1 ruby lib
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
if bundle_update_flag
insert_flag = 0
app_path = File.expand_path(__dir__)
template_path = ENV['PWD'] + '/app/templates'
@ -35,6 +37,7 @@ all_template.each do |folder|
end
end
end
end
Gem::Specification.new do |s|
s.name = "cancerpredict"
s.version = "0.0.1"

View File

@ -2,7 +2,13 @@ en:
module_name:
cancerpredict: Predict Breast Cancer Tool
cancerpredict:
cancerpredict: adjust the predict breast cancer tool
hidden_variables: "Hidden Variables"
advance_mode_hint1: "After opening advance modecalculation will change!\nAre you sure switch to advance mode?"
advance_mode_hint2: "一般模式: 選項設定在計算時對應到的值由1開始。(例如: 選項設定為[\"是\",\"否\"],則\"是\"在計算時對應到1而\"否\"在計算時對應到2)。<br><hr class=\"solid_line_hr\">進階模式: 選項設定在計算時對應到的值由0開始。<br>而若開啟選項值從大到小則0對應到選項設定中的最後一項。<br>選項對應到的值的意思為當前述的計算值為0時則對應到定義的Array的第1個元素的值以此類推。<br>欄位對應檔案可上傳一個csv檔案在計算時會先依照csv中的第1直行找到對應的變數1(生成的變數名稱為csv中的第1列)的值,其餘生成的變數值則為對應之後的同一橫列的值。"
module_mode: Module Mode
advance_mode: Advance Mode
Overall_Survival: Overall Survival
cancerpredict: Adjust the predict breast cancer tool
submitResult: see submit results of the users
result_is_right: Is therapy choices in the right hand side of result block?
text_descibe: text descibe
@ -46,8 +52,9 @@ en:
no: no
unknown: unknown
Results: Results
AdditionalBenefit: Additional Benefit
OverallSurvival: Overall Survival(%)
Treatment: Treatment
Additional_Benefit: Additional Benefit
Overall_Survival: Overall Survival(%)
Surgeryonly: Surgery only
Hormonetherapy: Hormone therapy
Chemotherapy: Chemotherapy
@ -57,4 +64,6 @@ en:
curve: Curves
text: Texts
Therapy_choice: Treatment options
lpv_impact: "lpv Impact(Input: Float)"
active_choice: "Active choice(input 1 present choice 1 is regarded as therapy enable)"
disable_condition: "Disable Condition"

View File

@ -2,6 +2,12 @@ zh_tw:
module_name:
cancerpredict: 乳癌預測工具
cancerpredict:
hidden_variables: "隱藏的變數"
advance_mode_hint1: "開啟進階模式後,計算方式有差異。\n您確定要開啟進階模式?"
advance_mode_hint2: "一般模式: 選項設定在計算時對應到的值由1開始。(例如: 選項設定為[\"是\",\"否\"],則\"是\"在計算時對應到1而\"否\"在計算時對應到2)。<br><hr class=\"solid_line_hr\">進階模式: 選項設定在計算時對應到的值由0開始。<br>而若開啟選項值從大到小則0對應到選項設定中的最後一項。<br>選項對應到的值的意思為當前述的計算值為0時則對應到定義的Array的第1個元素的值以此類推。<br>欄位對應檔案可上傳一個csv檔案在計算時會先依照csv中的第1直行找到對應的變數1(生成的變數名稱為csv中的第1列)的值,其餘生成的變數值則為對應之後的同一橫列的值。"
module_mode: 模組模式
advance_mode: 進階模式
Overall_Survival: 總生存率
cancerpredict: 乳癌預測工具調整
submitResult: 查看用戶繳交表單結果
result_is_right: 治療選項在結果的右邊?
@ -47,8 +53,8 @@ zh_tw:
unknown: 未知
Results: 結果
Treatment: 治療
AdditionalBenefit: 額外治療效益
OverallSurvival: 總生存率(%)
Additional_Benefit: 額外治療效益
Overall_Survival: 總生存率(%)
Surgeryonly: 純手術
Hormonetherapy: 賀爾蒙治療
Chemotherapy: 化學治療
@ -58,3 +64,22 @@ zh_tw:
curve: 曲線
text: 文字
Therapy_choice: 治療選項
variable: 變數名稱
name: 名稱
is_num: 數字欄位
hint: 提示文字
comment_text: 說明文字
choice_fields: '選項設定([]代表無選項)'
range: '數字範圍設定([]代表無範圍限制)'
right: 顯示在右側
is_float: 可輸入小數
revert_value: 選項值從大到小(ex:有兩個選項則選項值依序為1和0)
map_values: 選項對應到的值(若無,則會使用初始值)
cancer_predict_mapping_file: 欄位對應檔案
calculate_settings: 計算設定
prediction_formula: 預測公式
add_field: 新增填寫欄位
add_therapy: 新增治療選項
lpv_impact: "lpv 影響(輸入浮點數)"
active_choice: "啟用治療選項(輸入1代表第1個選項視為啟用治療)"
disable_condition: "禁用條件"

View File

@ -1,5 +1,12 @@
Rails.application.routes.draw do
Thread.new do
c = Cancerpredictfields.last
if c
sleep(5)
c.save
c.auto_write_predict_js
end
end
locales = Site.first.in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do

View File

@ -3,5 +3,5 @@
<script type="text/javascript" src="/assets/cancer_predict.js"></script>
{{table}}
<link href="/assets/cancer_predict.scss" media="screen" rel="stylesheet">
<link href="/assets/bootstrap.min.print.css" media="print" rel="stylesheet">
<link href="/assets/cancer_predict_print.scss" media="print" rel="stylesheet">
<%= stylesheet_link_tag "bootstrap.min.print", media: "print" %>
<%= stylesheet_link_tag "cancer_predict_print", media: "print" %>