220 lines
9.1 KiB
PHP
220 lines
9.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Server\H5;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Server\HealthCheck;
|
|
use App\Models\Server\TouristOrder;
|
|
|
|
class HealthController extends Controller
|
|
{
|
|
|
|
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 = [];
|
|
foreach($symptom as $key => $item){
|
|
$s[$key] = json_decode($item, true);
|
|
}
|
|
$info->symptom = $s;
|
|
$info->check = json_decode($info->check);
|
|
return $this->success('ok', $info);
|
|
}else{
|
|
return $this->failure('请先购买相应的服务');
|
|
}
|
|
} catch (\Exception $e){
|
|
$this->getError($e);
|
|
return $this->failure('服务器休息中,请稍后再试');
|
|
}
|
|
}
|
|
|
|
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->sex ?? 1; //默认是男性
|
|
$egg = $request->egg ?? 1; //默认是可以吃鸡蛋的
|
|
|
|
$base = [
|
|
'sex' => $sex,
|
|
'birthday' => $birthday,
|
|
'period' => $period,
|
|
'height' => $height,
|
|
'weight' => $weight,
|
|
'vegtarian' => $vegtarian,
|
|
'egg' => $egg,
|
|
];
|
|
HealthCheck::where('m_user_id', $request->merchant_user_id)
|
|
->where('m_order_id', $request->order_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('m_user_id', $request->merchant_user_id)
|
|
->where('m_order_id', $request->order_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) {
|
|
$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 ,
|
|
];
|
|
|
|
HealthCheck::where('m_user_id', $request->merchant_user_id)
|
|
->where('m_order_id', $request->order_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 checkHealthCheckOrder($request) {
|
|
$result = false;
|
|
$merchant_user_id = $request->merchant_user_id ?? 0;
|
|
$order_id = $request->order_id ?? 0;
|
|
$order = TouristOrder::find($order_id);
|
|
if(!empty($order)){
|
|
$result = HealthCheck::where('m_order_id', $order_id)
|
|
->where('m_user_id', $merchant_user_id)
|
|
->select('id', 'm_user_phone','m_user_id','m_order_id','base','symptom','check')->first();
|
|
}
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
|
|
|