802 lines
31 KiB
PHP
802 lines
31 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Controllers\Server\Admin;
|
||
|
||
use Illuminate\Http\Request;
|
||
use App\Http\Controllers\Controller;
|
||
use App\Models\Server\HealthCheck;
|
||
use App\Models\Server\HealthCheckProbe;
|
||
use App\Models\Server\TouristOrder;
|
||
|
||
class HealthController extends Controller
|
||
{
|
||
|
||
/**
|
||
* @merchant_user_id 当前用户的商家用户ID
|
||
* @order_id toursit_order中的订单ID
|
||
*/
|
||
|
||
public function getInfo(Request $request){
|
||
try {
|
||
$health_check = $this->checkHealthCheckOrder($request);
|
||
if($health_check) {
|
||
$info = $health_check;
|
||
$info->base = json_decode($info->base, true);
|
||
$symptom = json_decode($info->symptom, true);
|
||
$s = [];
|
||
if(is_array($symptom)){
|
||
foreach($symptom as $key => $item){
|
||
$s[$key] = json_decode($item, true);
|
||
}
|
||
}
|
||
$info->symptom = $s;
|
||
$info->check = json_decode($info->check);
|
||
$treatment = json_decode($info->treatment, true);
|
||
$info->treatment = is_array($treatment) ? array_values($treatment) : [];
|
||
return $this->success('ok', $info);
|
||
}else{
|
||
|
||
$info = $this->initHealthCheck($request);
|
||
return $this->success('ok', $info);
|
||
}
|
||
} catch (\Exception $e){
|
||
$this->getError($e);
|
||
return $this->failure('服务器休息中,请稍后再试');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @merchant_user_id
|
||
* @m_order_id
|
||
*/
|
||
private function initHealthCheck($request){
|
||
$init = [
|
||
'm_user_id' => $request->merchant_user_id,
|
||
'm_order_id' => $request->m_order_id,
|
||
'm_user_phone' => $this->getTouristOrderPhone($request->m_order_id),
|
||
'created_at' => time()
|
||
];
|
||
|
||
$init['id'] = HealthCheck::insertGetId($init);
|
||
return $init;
|
||
}
|
||
|
||
private function getTouristOrderPhone($order_id){
|
||
$phone = "";
|
||
$order = TouristOrder::find($order_id);
|
||
if($order->id > 0){
|
||
$phone = $order->mobile;
|
||
}
|
||
return $phone;
|
||
}
|
||
|
||
|
||
public function generateTreatment(Request $request){
|
||
$health_check = $this->checkHealthCheckOrder($request);
|
||
if(!$health_check){
|
||
return $this->failure('找不到相应的订单信息');
|
||
}
|
||
if($health_check->base == '' || $health_check->symptom == '' || $health_check->check == '' ){
|
||
return $this->failure('请先完善用户信息');
|
||
}
|
||
$health_check->base = json_decode($health_check->base, true);
|
||
$symptom = json_decode($health_check->symptom, true);
|
||
$s = [];
|
||
foreach($symptom as $key => $item){
|
||
$s[$key] = json_decode($item, true);
|
||
}
|
||
$health_check->symptom = $s;
|
||
$health_check->check = json_decode($health_check->check, 1);
|
||
|
||
$treatment = json_decode('{"echinacoside":{"label":"松果菊苷","val":0,"daily":70,"duration":30,"unit":"mg"},"flavonoids":{"label":"总黄胴素","val":0,"daily":26.6,"duration":30,"unit":"mg"},"lecithin":{"label":"卵磷脂","val":0,"daily":940,"duration":30,"unit":"mg"},"anthocyanidin":{"label":"厚花青素","val":0,"daily":2,"duration":30,"unit":""},"protein":{"label":"蛋白质","val":1,"daily":30,"duration":30,"unit":"g"},"cellulose":{"label":"纤维素","val":1,"daily":5,"duration":30,"unit":"g"},"epa":{"label":"不饱和脂肪酸EPA","val":0,"daily":360,"duration":30,"unit":"mg"},"dha":{"label":"不饱和脂肪酸DHA","val":0,"daily":360,"duration":30,"unit":"mg"},"ppt":{"label":"茶多酚","val":0,"daily":2,"duration":30,"unit":""},"theaflavin":{"label":"茶黄素","val":0,"daily":2,"duration":30,"unit":""},"fos":{"label":"低聚果糖","val":0,"daily":2,"duration":30,"unit":"g"},"gla":{"label":"γ-亚麻酸","val":0,"daily":250,"duration":30,"unit":"mg"},"glucosamine":{"label":"葡萄糖胺","val":0,"daily":1.5,"duration":30,"unit":"g"},"inulin":{"label":"菊粉","val":0,"daily":2,"duration":30,"unit":""},"q10":{"label":"辅酶Q10","val":0,"daily":2,"duration":30,"unit":""},"gaba":{"label":"γ-氨基丁酸","val":0,"daily":100,"duration":30,"unit":"mg"},"jujuboside":{"label":"酸枣仁苷A,B","val":0,"daily":417.6,"duration":20,"unit":"μg"},"ca":{"label":"菊苣酸","val":0,"daily":750,"duration":20,"unit":"gg"},"v_a":{"label":"维生素A","val":1,"daily":1250,"duration":30,"unit":"IU"},"v_c":{"label":"维生素C","val":1,"daily":225,"duration":30,"unit":"mg"},"v_d3":{"label":"维生素D3","val":1,"daily":165,"duration":30,"unit":"IU"},"v_e":{"label":"维生素E","val":1,"daily":17.5,"duration":30,"unit":"IU"},"v_b":{"label":"β-胡萝卜素","val":1,"daily":2250,"duration":30,"unit":"IU"},"v_b1":{"label":"维生素B1","val":1,"daily":5.5,"duration":30,"unit":"mg"},"v_b2":{"label":"维生素B2","val":1,"daily":5.5,"duration":30,"unit":"mg"},"v_b6":{"label":"维生素B6","val":1,"daily":5.5,"duration":30,"unit":"mg"},"v_12":{"label":"维生素B12","val":1,"daily":3.75,"duration":30,"unit":"μg"},"v_1":{"label":"叶酸","val":1,"daily":150,"duration":30,"unit":"μg"},"v_2":{"label":"烟酸","val":1,"daily":12.5,"duration":30,"unit":"mg"},"v_3":{"label":"泛酸","val":1,"daily":10,"duration":30,"unit":"mg"},"v_4":{"label":"生物素","val":1,"daily":90,"duration":30,"unit":"μg"},"e_1":{"label":"钙","val":1,"daily":323,"duration":30,"unit":"μg"},"e_2":{"label":"镁","val":1,"daily":144,"duration":30,"unit":"mg"},"e_3":{"label":"硒","val":1,"daily":6.5,"duration":30,"unit":"μg"},"e_4":{"label":"铬","val":1,"daily":17.5,"duration":30,"unit":"μg"},"e_5":{"label":"锰","val":1,"daily":2,"duration":30,"unit":"mg"},"e_6":{"label":"铜","val":1,"daily":0.75,"duration":30,"unit":"mg"},"e_7":{"label":"铁","val":1,"daily":2.15,"duration":30,"unit":"mg"},"e_8":{"label":"锌","val":1,"daily":7.5,"duration":30,"unit":"mg"},"e_9":{"label":"肌醇","val":1,"daily":20,"duration":30,"unit":"mg"}}', true);
|
||
|
||
$symptom_list = array(
|
||
'problem_women' => ['gla'],
|
||
'problem_stamach' => ['fos'],
|
||
'problem_heart' => ['q10'],
|
||
'problem_sleep' => ['gaba', 'jujuboside'],
|
||
'problem_immune' => ['ca'],
|
||
);
|
||
foreach($symptom_list as $s_key => $s_item){
|
||
$check_item = is_array($health_check->symptom[$s_key])?$health_check->symptom[$s_key]:[];
|
||
if(array_sum($check_item)){
|
||
foreach($s_item as $item){
|
||
$treatment[$item]['val'] = 1;
|
||
}
|
||
}
|
||
}
|
||
$check_list = json_decode('[
|
||
{
|
||
"label":"血压",
|
||
"target":[
|
||
""
|
||
],
|
||
"children":[
|
||
{
|
||
"abbr":"sbp",
|
||
"label":"收缩压",
|
||
"val":null,
|
||
"min":90,
|
||
"max":140,
|
||
"type":"number",
|
||
"unit":"mmHg",
|
||
"error":"高血压"
|
||
},
|
||
{
|
||
"abbr":"dbp",
|
||
"label":"舒张压",
|
||
"val":null,
|
||
"min":60,
|
||
"max":90,
|
||
"type":"number",
|
||
"unit":"mmHg",
|
||
"error":"高血压"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label":"糖检测",
|
||
"target":[
|
||
""
|
||
],
|
||
"children":[
|
||
{
|
||
"abbr":"fbg",
|
||
"label":"空腹血糖",
|
||
"val":null,
|
||
"min":3.9,
|
||
"max":6.1,
|
||
"type":"number",
|
||
"unit":"mmol/L"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label":"肾功能检测",
|
||
"target":[
|
||
"echinacoside",
|
||
"flavonoids"
|
||
],
|
||
"children":[
|
||
{
|
||
"abbr":"urea",
|
||
"label":"尿素",
|
||
"val":null,
|
||
"min":2.9,
|
||
"max":8.2,
|
||
"type":"number",
|
||
"unit":"mmol/L"
|
||
},
|
||
{
|
||
"abbr":"cre",
|
||
"label":"肌酐",
|
||
"val":null,
|
||
"min":53,
|
||
"max":97,
|
||
"type":"number",
|
||
"unit":"umol/L"
|
||
},
|
||
{
|
||
"abbr":"ua",
|
||
"label":"尿酸",
|
||
"val":null,
|
||
"min":208,
|
||
"max":428,
|
||
"type":"number",
|
||
"unit":"umol/L"
|
||
},
|
||
{
|
||
"abbr":"cvsc",
|
||
"label":"胱抑素C",
|
||
"val":null,
|
||
"min":0.63,
|
||
"max":1.25,
|
||
"type":"number",
|
||
"unit":"mg/L"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label":"血脂四项检查",
|
||
"target":[
|
||
"ppt",
|
||
"theaflavin",
|
||
"lecithin"
|
||
],
|
||
"children":[
|
||
{
|
||
"abbr":"tc",
|
||
"label":"总胆固醇",
|
||
"val":null,
|
||
"min":3.1,
|
||
"max":5.23,
|
||
"type":"number",
|
||
"unit":"mmol/L"
|
||
},
|
||
{
|
||
"abbr":"tg",
|
||
"label":"甘油三脂",
|
||
"val":null,
|
||
"min":0.56,
|
||
"max":1.47,
|
||
"type":"number",
|
||
"unit":"mmol/L"
|
||
},
|
||
{
|
||
"abbr":"hdl",
|
||
"label":"高密度脂蛋白",
|
||
"val":null,
|
||
"min":0.91,
|
||
"max":2.06,
|
||
"type":"number",
|
||
"unit":"mmol/L"
|
||
},
|
||
{
|
||
"abbr":"ldl",
|
||
"label":"低密度脂蛋白",
|
||
"val":null,
|
||
"min":0,
|
||
"max":3.36,
|
||
"type":"number",
|
||
"unit":"mmol/L"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label":"五分类血常规",
|
||
"target":[
|
||
""
|
||
],
|
||
"children":[
|
||
{
|
||
"abbr":"wbc",
|
||
"label":"白细胞计数",
|
||
"val":null,
|
||
"min":3.5,
|
||
"max":9.5,
|
||
"type":"number",
|
||
"unit":"10^9/L"
|
||
},
|
||
{
|
||
"abbr":"rbc",
|
||
"label":"红细胞计数",
|
||
"val":null,
|
||
"min":4.3,
|
||
"max":5.8,
|
||
"type":"number",
|
||
"unit":"10^12/L"
|
||
},
|
||
{
|
||
"abbr":"hgb",
|
||
"label":"血红蛋白",
|
||
"val":null,
|
||
"min":130,
|
||
"max":175,
|
||
"type":"number",
|
||
"unit":"g/L"
|
||
},
|
||
{
|
||
"abbr":"hct",
|
||
"label":"红细胞比积",
|
||
"val":null,
|
||
"min":0.4,
|
||
"max":0.5,
|
||
"type":"number",
|
||
"unit":""
|
||
},
|
||
{
|
||
"abbr":"mcv",
|
||
"label":"平均RBC体积",
|
||
"val":null,
|
||
"min":82,
|
||
"max":100,
|
||
"type":"number",
|
||
"unit":"fl"
|
||
},
|
||
{
|
||
"abbr":"mch",
|
||
"label":"平均RBC血红蛋白量",
|
||
"val":null,
|
||
"min":27,
|
||
"max":34,
|
||
"type":"number",
|
||
"unit":"pg"
|
||
},
|
||
{
|
||
|
||
"abbr":"mchc",
|
||
"label":"平均RBC血红蛋白浓度",
|
||
"val":null,
|
||
"min":316,
|
||
"max":354,
|
||
"type":"number",
|
||
"unit":"g/L"
|
||
},
|
||
{
|
||
"abbr":"rdw",
|
||
"label":"RBC分布宽度标准差",
|
||
"val":null,
|
||
"min":37,
|
||
"max":54,
|
||
"type":"number",
|
||
"unit":"fL"
|
||
},
|
||
{
|
||
"abbr":"rdwcv",
|
||
"label":"RBC分布宽度变异系数",
|
||
"val":null,
|
||
"min":0.11,
|
||
"max":0.16,
|
||
"type":"number",
|
||
"unit":""
|
||
},
|
||
{
|
||
"abbr":"plt",
|
||
"label":"血小板计数",
|
||
"val":null,
|
||
"min":125,
|
||
"max":350,
|
||
"type":"number",
|
||
"unit":"10^9/L"
|
||
},
|
||
{
|
||
"abbr":"mpv",
|
||
"label":"平均血小板体积",
|
||
"val":null,
|
||
"min":9.4,
|
||
"max":12.5,
|
||
"type":"number",
|
||
"unit":"fL"
|
||
},
|
||
{
|
||
"abbr":"pdw",
|
||
"label":"血小板体积分布宽带",
|
||
"val":null,
|
||
"min":10,
|
||
"max":18,
|
||
"type":"number",
|
||
"unit":"fL"
|
||
},
|
||
{
|
||
"abbr":"plcr",
|
||
"label":"大血小板比率",
|
||
"val":null,
|
||
"min":0.13,
|
||
"max":0.43,
|
||
"type":"number",
|
||
"unit":""
|
||
},
|
||
{
|
||
"abbr":"pct",
|
||
"label":"血小板比积",
|
||
"val":null,
|
||
"min":0.11,
|
||
"max":0.28,
|
||
"type":"number",
|
||
"unit":"%"
|
||
},
|
||
{
|
||
"abbr":"gr",
|
||
"label":"中性粒细胞计数",
|
||
"val":null,
|
||
"min":1.8,
|
||
"max":6.3,
|
||
"type":"number",
|
||
"unit":"10^9/L"
|
||
},
|
||
{
|
||
"abbr":"gr_p",
|
||
"label":"中性粒细胞比值",
|
||
"val":null,
|
||
"min":40,
|
||
"max":75,
|
||
"type":"number",
|
||
"unit":"%"
|
||
},
|
||
{
|
||
"abbr":"ly",
|
||
"label":"淋巴细胞计数",
|
||
"val":null,
|
||
"min":1.1,
|
||
"max":3.2,
|
||
"type":"number",
|
||
"unit":"10^9/L"
|
||
},
|
||
{
|
||
"abbr":"ly_p",
|
||
"label":"淋巴细胞比值",
|
||
"val":null,
|
||
"min":20,
|
||
"max":50,
|
||
"type":"number",
|
||
"unit":"%"
|
||
},
|
||
{
|
||
"abbr":"mono",
|
||
"label":"单核细胞计数",
|
||
"val":null,
|
||
"min":3,
|
||
"max":10,
|
||
"type":"number",
|
||
"unit":"10^9/L"
|
||
},
|
||
{
|
||
"abbr":"mono_p",
|
||
"label":"单核细胞比值",
|
||
"val":null,
|
||
"min":3,
|
||
"max":10,
|
||
"type":"number",
|
||
"unit":"%"
|
||
},
|
||
{
|
||
"abbr":"eos",
|
||
"label":"嗜酸粒细胞计数",
|
||
"val":null,
|
||
"min":0.02,
|
||
"max":0.52,
|
||
"type":"number",
|
||
"unit":"10^9/L"
|
||
},
|
||
{
|
||
"abbr":"eos_p",
|
||
"label":"嗜酸睡粒细胞比值",
|
||
"val":null,
|
||
"min":0.4,
|
||
"max":8,
|
||
"type":"number",
|
||
"unit":"%"
|
||
},
|
||
{
|
||
"abbr":"baso",
|
||
"label":"嗜碱性粒细胞计数",
|
||
"val":null,
|
||
"min":0,
|
||
"max":0.06,
|
||
"type":"number",
|
||
"unit":"10^9/L"
|
||
},
|
||
{
|
||
"abbr":"baso_p",
|
||
"label":"嗜碱性粒细胞比值",
|
||
"val":null,
|
||
"min":0,
|
||
"max":1,
|
||
"type":"number",
|
||
"unit":"%"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label":"肝功三项",
|
||
"target":[
|
||
"anthocyanidin"
|
||
],
|
||
"children":[
|
||
{
|
||
"abbr":"tbil",
|
||
"label":"谷丙转氨酶",
|
||
"val":null,
|
||
"min":0,
|
||
"max":100,
|
||
"type":"number",
|
||
"unit":"U/L"
|
||
},
|
||
{
|
||
"abbr":"dbil",
|
||
"label":"谷草转氨酶",
|
||
"val":null,
|
||
"min":15,
|
||
"max":40,
|
||
"type":"number",
|
||
"unit":"U/L"
|
||
},
|
||
{
|
||
"abbr":"alt",
|
||
"label":"总胆红素",
|
||
"val":null,
|
||
"min":0,
|
||
"max":100,
|
||
"type":"number",
|
||
"unit":"umol/L"
|
||
},
|
||
{
|
||
"abbr":"ast",
|
||
"label":"直接胆红素",
|
||
"val":null,
|
||
"min":0,
|
||
"max":100,
|
||
"type":"number",
|
||
"unit":"umol/L"
|
||
}
|
||
]
|
||
}
|
||
]', true);
|
||
$c_list = $health_check->check;
|
||
foreach($check_list as $check){
|
||
foreach($check['children'] as $check_item){
|
||
$val = isset($c_list[$check_item['abbr']])?$c_list[$check_item['abbr']]: '';
|
||
if($val){
|
||
if($val < $check_item['min'] || $val > $check_item['max']){
|
||
|
||
foreach($check['target'] as $target){
|
||
if($target){
|
||
$treatment[$target]['val'] = 1;
|
||
}
|
||
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
$bmi = $this->getBMI($health_check->base['weight'], $health_check->base['height']);
|
||
if($bmi['lecithin']){
|
||
$treatment['lecithin']['val'] = 1;
|
||
}
|
||
|
||
$update = HealthCheck::where('id', $health_check->id)->update(['treatment' => json_encode($treatment)]);
|
||
return $this->success('ok', $treatment);
|
||
}
|
||
|
||
|
||
private function getBMI($weight, $height){
|
||
$lecithin = 0;
|
||
$status = 0;
|
||
$label = '偏瘦';
|
||
$base = pow(number_format(($height / 100.0), 2), 2);
|
||
$bmi =number_format(($weight / $base), 1);
|
||
if ($bmi >= 18.5 && $bmi < 23.9) {
|
||
$label = "正常";
|
||
$status = 1;
|
||
} else if ($bmi >= 23.9 && $bmi < 27.9) {
|
||
$label = "超重";
|
||
$status = 2;
|
||
} else if ($bmi >= 27.9 && $bmi < 30) {
|
||
$label = "肥胖";
|
||
$status = 3;
|
||
} else if ($bmi >= 30 && $bmi < 40) {
|
||
$label = "重度肥胖";
|
||
$status = 4;
|
||
} else if ($bmi > 40) {
|
||
$label = "极重度肥胖";
|
||
$status = 5;
|
||
}
|
||
if ($status > 1) {
|
||
$lecithin = 1;
|
||
}
|
||
return [
|
||
'status' => $status,
|
||
'label' => $label,
|
||
'lecithin' => $lecithin,
|
||
'bmi' => $bmi,
|
||
];
|
||
}
|
||
|
||
public function saveInfoBase(Request $request){
|
||
try {
|
||
|
||
$health_check = $this->checkHealthCheckOrder($request);
|
||
if($health_check) {
|
||
$sex = $request->sex ?? 1; //默认是男性
|
||
$birthday = $request->birthday; //默认格式为 yyyy-mm-dd
|
||
$period = $request->period ?? 0; //默认是无
|
||
$height = $request->height; //默认是0
|
||
$weight = $request->weight ?? 1; //默认是0
|
||
$vegtarian = $request->vegtarian ?? 0; //默认是男性
|
||
$egg = $request->egg ?? 1; //默认是可以吃鸡蛋的
|
||
$money = $request->money ?? 0; //默认是可以吃鸡蛋的
|
||
|
||
$base = [
|
||
'sex' => $sex,
|
||
'birthday' => $birthday,
|
||
'period' => $period,
|
||
'height' => $height,
|
||
'weight' => $weight,
|
||
'vegtarian' => $vegtarian,
|
||
'egg' => $egg,
|
||
'money' => $money,
|
||
];
|
||
HealthCheck::where('id', $health_check->id)
|
||
->update(['base' => json_encode($base)]);
|
||
return $this->success('ok', $base);
|
||
}else{
|
||
return $this->failure('请先购买相应的服务');
|
||
}
|
||
} catch (\Exception $e){
|
||
$this->getError($e);
|
||
return $this->failure('服务器休息中,请稍后再试');
|
||
}
|
||
}
|
||
|
||
public function saveInfoSymptom(Request $request){
|
||
try {
|
||
$health_check = $this->checkHealthCheckOrder($request);
|
||
if($health_check) {
|
||
$problem_women = $request->problem_women ?? '';
|
||
$problem_stamach = $request->problem_stamach ?? '';
|
||
$problem_heart = $request->problem_heart ?? '';
|
||
$problem_sleep = $request->problem_sleep ?? '';
|
||
$problem_immune = $request->problem_immune ?? '';
|
||
$symptom = [
|
||
'problem_women' => json_encode($problem_women),
|
||
'problem_stamach' => json_encode($problem_stamach),
|
||
'problem_heart' => json_encode($problem_heart),
|
||
'problem_sleep' => json_encode($problem_sleep),
|
||
'problem_immune' => json_encode($problem_immune),
|
||
];
|
||
HealthCheck::where('id', $health_check->id)
|
||
->update(['symptom' => json_encode($symptom)]);
|
||
return $this->success('ok', $symptom);
|
||
}else{
|
||
return $this->failure('请先购买相应的服务');
|
||
}
|
||
} catch (\Exception $e){
|
||
$this->getError($e);
|
||
return $this->failure('服务器休息中,请稍后再试');
|
||
}
|
||
}
|
||
|
||
public function saveInfoCheck(Request $request){
|
||
try {
|
||
$health_check = $this->checkHealthCheckOrder($request);
|
||
if($health_check) {
|
||
$check = $this->getHealthCheckCheckInfo($request);
|
||
HealthCheck::where('id', $health_check->id)
|
||
->update(['check' => json_encode($check)]);
|
||
return $this->success('ok', $check);
|
||
}else{
|
||
return $this->failure('请先购买相应的服务');
|
||
}
|
||
} catch (\Exception $e){
|
||
$this->getError($e);
|
||
return $this->failure('服务器休息中,请稍后再试');
|
||
}
|
||
}
|
||
|
||
function getHealthCheckCheckInfo($request) {
|
||
|
||
$sbp = $request->sbp ?? 0; //默认是收缩压
|
||
$dbp = $request->dbp ?? 0; //默认是舒张压
|
||
$fbg = $request->fbg ?? 0; //默认是空腹血糖
|
||
|
||
$urea = $request->urea ?? 0; //默认是尿素
|
||
$ua = $request->ua ?? 0; //默认是尿酸
|
||
$cre = $request->cre ?? 0; //默认是肌酐
|
||
$cvsc =$request->cvsc ??0; //默认是 胱抑素C
|
||
|
||
$tc = $request->tc ?? 0; //默认是 总胆固醇
|
||
$tg = $request->tg ?? 0; //默认是 甘油三脂
|
||
$hdl = $request->hdl ?? 0; //默认是 高密度脂蛋白
|
||
$ldl = $request->ldl ?? 0; //默认是 低密度脂蛋白
|
||
|
||
$tbil = $request->tbil ?? 0; //默认是总胆红素
|
||
$dbil = $request->dbil ?? 0; //默认是 直接胆红素
|
||
$alt = $request->alt ?? 0; //默认是 谷丙转氨酶
|
||
$ast = $request->ast ?? 0; //默认是 谷草转氨酶
|
||
|
||
|
||
$wbc = $request->wbc ?? 0; // 白细胞计数
|
||
$rbc = $request->rbc ?? 0; // 红细胞计数
|
||
$hgb = $request->hgb ?? 0; // 血红蛋白
|
||
$hct = $request->hct ?? 0; // 红细胞比积
|
||
$mcv = $request->mcv ?? 0; // 平均RBC体积
|
||
$mch = $request->mch ?? 0; // 平均RBC血红蛋白量
|
||
$mchc = $request->mchc ?? 0; // 平均RBC血红蛋白浓度
|
||
$rdw = $request->rdw ?? 0; // RBC分布宽度标准差
|
||
$rdwcv = $request->rdwcv ?? 0; //RBC分布宽度变异系数
|
||
$plt = $request->plt ?? 0; // 血小板计数
|
||
$mpv = $request->mpv ?? 0; // 平均血小板体积
|
||
$pdw = $request->pdw ?? 0; // 血小板体积分布宽带
|
||
$plcr = $request->plcr ?? 0; // 大血小板比率
|
||
$pct = $request->pct ?? 0; // 血小板比积
|
||
$gr = $request->gr ?? 0; // 中性粒细胞计数
|
||
$gr_p = $request->gr_p ?? 0; // 中性粒细胞比值
|
||
$ly = $request->ly ?? 0; // 淋巴细胞计数
|
||
$ly_p = $request->ly_p ?? 0; // 淋巴细胞比值
|
||
$mono = $request->mono ?? 0; // 单核细胞计数
|
||
$mono_p = $request->mono_p ?? 0; // 单核细胞比值
|
||
$eos = $request->eos ?? 0; // 嗜酸粒细胞计数
|
||
$eos_p = $request->eos_p ?? 0; // 嗜酸睡粒细胞比值
|
||
$baso = $request->baso ?? 0; // 嗜碱性粒细胞计数
|
||
$baso_p = $request->baso_p ?? 0; // 嗜碱性粒细胞比值
|
||
|
||
$check = [
|
||
'sbp' => $sbp,
|
||
'dbp' => $dbp,
|
||
'fbg' => $fbg,
|
||
'urea' => $urea,
|
||
'ua'=> $ua ,
|
||
'cre' => $cre,
|
||
'cvsc' => $cvsc,
|
||
'tc'=> $tc,
|
||
'tg'=> $tg,
|
||
'hdl' => $hdl ,
|
||
'ldl' => $ldl ,
|
||
'tbil' => $tbil ,
|
||
'dbil' => $dbil ,
|
||
'alt' => $alt ,
|
||
'ast' => $ast ,
|
||
'wbc' => $wbc ,
|
||
'rbc' => $rbc ,
|
||
'hgb' => $hgb ,
|
||
'hct' => $hct ,
|
||
'mcv' => $mcv ,
|
||
'mch' => $mch ,
|
||
'mchc' => $mchc ,
|
||
'rdw' => $rdw ,
|
||
'rdwcv' => $rdwcv ,
|
||
'plt' => $plt ,
|
||
'mpv' => $mpv ,
|
||
'pdw' => $pdw ,
|
||
'plcr' => $plcr ,
|
||
'pct' => $pct,
|
||
'gr'=> $gr ,
|
||
'gr_p' => $gr_p ,
|
||
'ly'=> $ly ,
|
||
'ly_p' => $ly_p ,
|
||
'mono'=> $mono ,
|
||
'mono_p' => $mono_p ,
|
||
'eos' => $eos ,
|
||
'eos_p' => $eos_p ,
|
||
'baso' => $baso ,
|
||
'baso_p' => $baso_p ,
|
||
];
|
||
return $check;
|
||
}
|
||
|
||
function checkHealthCheckOrder($request) {
|
||
$result = false;
|
||
$merchant_user_id = $request->merchant_user_id ?? 0;
|
||
$m_order_id = $request->m_order_id ?? 0;
|
||
//$order = TouristOrder::find($m_order_id);
|
||
$result = HealthCheck::where('m_order_id', $m_order_id)
|
||
->where('m_user_id', $merchant_user_id)
|
||
->select('id','m_user_phone','m_user_id','m_order_id','base','symptom','check', 'treatment')->first();
|
||
|
||
return empty($result)?false: $result;
|
||
}
|
||
|
||
|
||
public function syncHealthCheck(Request $request) {
|
||
$mobile = $request->mobile;
|
||
$order = TouristOrder::where('mobile', $mobile)->where('type', 'community')
|
||
->where('type_id', 1475)->select('id','merchant_id', 'account_id')->first();
|
||
if(!empty($order)){
|
||
$health_check = HealthCheck::where('m_order_id', $order->id)->where('m_user_id', $order->account_id)->first();
|
||
if(empty($health_check)){
|
||
$health_check = new HealthCheck;
|
||
$health_check->m_user_id = $order->account_id;
|
||
$health_check->m_order_id = $order->id;
|
||
$health_check->m_user_phone = $mobile;
|
||
$health_check->save();
|
||
}
|
||
$check = $this->getHealthCheckCheckInfo($request);
|
||
|
||
HealthCheck::where('id', $health_check->id)
|
||
->update(['check' => json_encode($check)]);
|
||
return $this->success('ok', '请返回后台查看用户信息');
|
||
}else{
|
||
return $this->failure('找不到相应的订单信息');
|
||
}
|
||
|
||
|
||
}
|
||
|
||
public function getProbleList(Request $request){
|
||
$m_user_id = $request->m_user_id;
|
||
$m_order_id = $request->m_order_id;
|
||
$nopage = $request->nopage;
|
||
$probe_list = HealthCheckProbe::where('m_user_id', $m_user_id)->where('m_order_id',$m_order_id);
|
||
if($nopage){
|
||
$probe_list = $probe_list ->orderby('local_updated_at', 'asc')->get();
|
||
}else{
|
||
$probe_list = $probe_list ->orderby('local_updated_at', 'desc')->paginate();
|
||
}
|
||
return $this->success('ok', $probe_list);
|
||
}
|
||
}
|
||
|
||
|