# encoding: utf-8 require 'rubyXL' 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 locale = params['data']['locale'].to_s rescue 'zh_tw' locale = 'zh_tw' if locale == 'zh_cn' result = {:result=>"123"} result['age1'] = -(params['data']['age'].to_f/100)**(-0.5) result['age2'] = -(params['data']['age'].to_f/100)**(-0.5)*Math.log(params['data']['age'].to_f/100,10) result['size1'] = -Math.log(params['data']['size'].to_f/10,10) result['nposit'] = -((params['data']['ratio'].to_f+0.1)/0.1)**0.5 if params['data']['grade'].to_i == 2 result['grade_2'] = 1 else result['grade_2'] = 0 end if params['data']['grade'].to_i == 3 result['grade_3'] = 1 else result['grade_3'] = 0 end if params['data']['subtype'].to_i == 2 result['subtype_HER2'] = 1 else result['subtype_HER2'] = 0 end if params['data']['subtype'].to_i == 3 result['subtype_triple'] = 1 else result['subtype_triple'] = 0 end if params['data']['pstage'].to_i == 2 result['pstage_2'] = 1 else result['pstage_2'] = 0 end if params['data']['pstage'].to_i == 3 result['pstage_3'] = 1 else result['pstage_3'] = 0 end if params['data']['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 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 = ['1','3','5'] result['table'] = '
此分析微針對已接受手術後病人,下表為此病人分別在第1年、3及5年下,根據選定的術後治療所估計的存活率
' result['table'] += '第' result['years'] = @years @years.each{|year| result['table'] += ('')} result['table'] += '年' @table_head = (locale == "zh_tw") ? ['治療','額外治療效益','總生存率(%)'] :['Treatment','Additional Benefit','Overall Survival(%)'] @head_name = ['Treatment','Additional_Benefit','Overall_Survival'] @therapy_choices = (locale == "zh_tw") ? ['純手術'] :['Surgery only'] @form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]} @therapy_names = ['Surgery_only'] @form_to_show.form_show_in_result.values.each{|choice| @therapy_names.push choice["variable"]} result['treatmeny_method'] = @therapy_names result['table'] += '' + head + ' | ')} result['table'] += '
---|
' + ((index == 0) ? choice : '-') + ' | ') end result['table'] += '