# 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 || [] locale = OrbitHelper.get_site_locale.to_s 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 0) result['table'] = '此分析微針對已接受手術後病人,下表為此病人分別在第1年、3及5年下,根據選定的術後治療所估計的存活率' result = result.merge(params) render :json=> result end def index uid = OrbitHelper.params[:uid] rescue "" tags = OrbitHelper.widget_tags categories = OrbitHelper.widget_categories || [] locale = OrbitHelper.get_site_locale.to_s if (OrbitHelper.params[:result] == nil rescue true) @table_str = '