<?
viewPlugins("bootstrap","jqui","layer","qgGrid");
viewLoad("public/header");
?>
<style>
legend{font-size:1rem;color:#069}
.ui-slider-horizontal {
    height: 0.8em;
}
.ulleft li{float:left;padding-right:1rem}
.form-select{font-size:14px}
</style>
<form>
  <fieldset>
      <legend class="mt-4">检测项目</label></legend>
      <select class="form-select" id="select_cate">
          <option></option>
          <? foreach($bigCates as $bigname):?>
            <option value="<?=$bigname?>"><?=$bigname?></option>
          <? endforeach;?>
      </select>
  </fieldset>
  <fieldset>
      <legend class="mt-4">检测设备</label></legend>
      <select class="form-select" id="select_device">
          <option></option>
          <? foreach($devices as $device):?>
            <option value="<?=$device['mead_id']?>"><?=$device['mead_name']?></option>
          <? endforeach;?>
      </select>
  </fieldset>
</form>

<br>
<br>
<div id="result">
<div class="card border-primary mb-6" style="max-width: 20rem;">
  <div class="card-header">结论</div>
  <div class="card-body">
    <h4 class="card-title"></h4>
  </div>
</div>
</div>
<script>
$(function() {
    $('#select_cate').change(getReport);
    $('#select_device').change(getReport);
}); 

function getReport(){
    let bigCate = $('#select_cate').val();
    let device = $('#select_device').val();
    if(empty(bigCate) || empty(device)){
        return ;
    }
    $.ajax({
		url: HOST+'/doctor/tool/getMeasureReport',
		type: 'post',
		data: {'bigCate':bigCate,'device':device},
		dataType: 'json',
		async: false,
		success: function (res) {
		    let data = res.rows;
		    let html = '';
		    if(data.hasData==1){
		        data.intercept *= -1;
		        if(data.intercept>=0){
		            html = '医院值 = ' + floatRound(data.intercept,2) + ' + ' + floatRound(data.slope,2) + ' x ' + '设备值';
		        }else{
		            html = '医院值 = ' + floatRound(data.slope,2) + ' * ' + '设备值 - ' + floatRound(data.intercept*-1,2);
		        }
		        html += '<br>相关性: ' + floatRound(data.correlation_coefficient,2);
		        let subHtml = '';
		        if(data.correlation_coefficient>0.8){
		            subHtml = '高度线性正相关';
		        }else if(data.correlation_coefficient>=0.6){
		            subHtml = '中度线性正相关';
		        }else if(data.correlation_coefficient>=0.4){
		            subHtml = '低度线性正相关';
		        }else{
		            subHtml = '线性相关性较弱';
		        }
		        html += '<br>' + subHtml;
		    }else{
		        html = '数据不全，无法得出结论';
		    }
	        $('#result').find('h4').html(html);
		},
	});    
}
</script>
<? viewLoad("public/footer") ?>