You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
6.8 KiB
PHP
165 lines
6.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\Admin\YeWu;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Admin\YeWu\AppointmentService;
|
|
use Illuminate\Http\Request;
|
|
use App\Services\Admin\YeWu\HealthCheckupService;
|
|
use App\Services\mH5\PersonService;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class HealthCheckupController extends Controller
|
|
{
|
|
//创建体检记录
|
|
public function CreateRecord(){
|
|
$CheckupInfo=request('checkup_info');
|
|
if(!$CheckupInfo) return \Yz::echoError1('检查信息为空');
|
|
if(!$CheckupInfo['name']) return \Yz::echoError1('姓名不能为空');
|
|
if(!isset($CheckupInfo['id_card_num'])) return \Yz::echoError1('id_card_num不能为空');
|
|
if(!isset($CheckupInfo['institution_sn'])) return \Yz::echoError1('体检机构编码institution_sn不能为空');
|
|
if(!isset($CheckupInfo['tijian_num'])) return \Yz::echoError1('体检号tijian_num不能为空');
|
|
if(!isset($CheckupInfo['tijian_time'])) return \Yz::echoError1('体检时间tijian_time不能为空');
|
|
if(!isset($CheckupInfo['report_content'])) return \Yz::echoError1('报告内容report_content不能为空');
|
|
if(!isset($CheckupInfo['issue_time'])) return \Yz::echoError1('发证时间issue_time不能为空');
|
|
if(!isset($CheckupInfo['expire_time'])) return \Yz::echoError1('证件到期时间expire_time不能为空');
|
|
|
|
if(!isset($CheckupInfo['sex'])) return \Yz::echoError1('性别sex不能为空');
|
|
|
|
$s=app()->make(HealthCheckupService::class);
|
|
return $s->CreateRecord($CheckupInfo);
|
|
}
|
|
//查询能否进行免费体检
|
|
public function CheckRequirements(){
|
|
$id_card_num=request('id_card_num');
|
|
$name=request('name');
|
|
$type=request('type');//体检类型 1,健康证2老年人
|
|
$s=app()->make(AppointmentService::class);
|
|
return $s->CheckAppointment($name,$id_card_num,$type);
|
|
}
|
|
|
|
//获取个人预约记录详情
|
|
public function GetAppointmentRecord(){
|
|
$id_card_num=request('id_card_num');
|
|
$s=app()->make(PersonService::class);
|
|
return $s->GetAppointmentRecord(['id_num'=>$id_card_num]);
|
|
}
|
|
|
|
//提交pdf文件
|
|
public function UploadFile(Request $request){
|
|
$file=request('file');
|
|
$id_card_num=request('id_card_num');
|
|
$tijian_num=request('tijian_num');
|
|
date_default_timezone_set('PRC');
|
|
$currentYear = date('Y');
|
|
$firstDay = date('Y-01-01', strtotime($currentYear));
|
|
$lastDay = date('Y-12-31', strtotime($currentYear));
|
|
|
|
$cha=DB::table('examination_records')->where(['id_card_num'=>$id_card_num,'tijian_num'=>$tijian_num])->whereBetween('created_at', [$firstDay, $lastDay])->get();
|
|
if(count($cha)==0) return \Yz::echoError1('未找到此用户对应的体检号记录,无法存储报告');
|
|
|
|
if ($file->isValid()) {
|
|
|
|
$s=app()->make(HealthCheckupService::class);
|
|
$save=$s->SaveFile(['file'=>$file]);
|
|
|
|
if(!$save['status']) return \Yz::echoError1('文件保持失败');
|
|
|
|
$u=DB::table('examination_records')->where(['id'=>$cha[0]->id])->update(['report_file'=>Storage::url($save['data'])]);
|
|
if($u>0){
|
|
return \Yz::Return(true,'上传成功',['file'=>$save['data']]);
|
|
}else{
|
|
return \Yz::echoError1('保存文件失败');
|
|
}
|
|
|
|
}else{
|
|
return \Yz::echoError1('获取文件失败');
|
|
}
|
|
|
|
}
|
|
|
|
//对外接口,创建体检记录 姓名、电话、身份证、体检机构编码、体检号、pdfs
|
|
public function CreateCheckupPdf()
|
|
{
|
|
$id_card_num=request('id_card_num');
|
|
$name=request('name');
|
|
$tel=request('tel');
|
|
$tijian_num=request('tijian_num');
|
|
$type=request('type');
|
|
$org_code=request('org_code');
|
|
$pdfs=request('pdfs');
|
|
if(!isset($tijian_num)) return \Yz::echoError1('体检号不能为空');
|
|
if(!isset($id_card_num)) return \Yz::echoError1('身份证不能为空');
|
|
if(!isset($pdfs)) return \Yz::echoError1('pdfs不能为空');
|
|
if(!isset($org_code)) return \Yz::echoError1('机构码不能为空');
|
|
$org_id=DB::table('medical_institution')->where('sn',$org_code)->first();
|
|
if(!$org_id) return \Yz::echoError1('机构码不存在');
|
|
|
|
//检查体检流水号是否存在,存在禁止再次插入。
|
|
$check_cunzai=DB::table('examination_records')->where('tijian_num',$tijian_num)->get();
|
|
if(count($check_cunzai)>0) return \Yz::echoError1('此体检号已经存在,禁止创建');
|
|
|
|
//HSM加密
|
|
$HSM_sfz =\App\Lib\HSM::HsmEncrypt($id_card_num);
|
|
if($HSM_sfz['status']!=true){
|
|
return \Yz::echoError1('调用HSM加密失败');
|
|
}
|
|
|
|
if(isset($tel)){
|
|
$HSM_tel =\App\Lib\HSM::HsmEncrypt($tel);
|
|
if($HSM_tel['status']!=true){
|
|
return \Yz::echoError1('调用HSM加密失败');
|
|
}
|
|
$tel=$HSM_tel['data'];
|
|
}
|
|
|
|
$id_card_num=$HSM_sfz['data'];
|
|
$Hmac=\App\Lib\HSM::Hmac($name.$id_card_num.$tel.$org_id->id);
|
|
if($Hmac['status']!=true){
|
|
return \Yz::echoError1('HMAC摘要失败');
|
|
}
|
|
|
|
$i=DB::table('examination_records')->insertGetId([
|
|
"name"=>$name,
|
|
"tel"=>$tel,
|
|
"id_card_num"=>$id_card_num,
|
|
"type"=>$type,
|
|
"institution_id"=>$org_id->id,
|
|
"tijian_num"=>$tijian_num,
|
|
"pdfs"=>isset($pdfs)?json_encode($pdfs,JSON_UNESCAPED_UNICODE):'',
|
|
'hmac'=>$Hmac['data'],
|
|
]);
|
|
if($i){
|
|
return \Yz::Return(true,'记录完成',["num"=>$tijian_num]);
|
|
}else{
|
|
return \Yz::echoError1("操作失败");
|
|
}
|
|
|
|
}
|
|
|
|
//根据身份证号码查询体检记录列表
|
|
public function GetPersonCheckUpList(){
|
|
$id_card_num=request('id_card_num');
|
|
$s=app()->make(HealthCheckupService::class);
|
|
return $s->GetPersonCheckUpList(['id_card_num'=>$id_card_num]);
|
|
}
|
|
//根据体检号查询体检详情
|
|
public function GetPersonCheckUpDetail(){
|
|
$tijian_num=request('tijian_num');
|
|
$s=app()->make(HealthCheckupService::class);
|
|
return $s->GetPersonCheckUpDetail(['tijian_num'=>$tijian_num]);
|
|
}
|
|
|
|
//admin后台获取体检记录列表
|
|
public function GetCheckUpList(Request $request){
|
|
$userid = $request->get('userid');//中间件产生的参数
|
|
$group = $request->get('role');//中间件产生的参数
|
|
$page =request('page');
|
|
$pageSize =request('pageSize');
|
|
$searchInfo=request('searchInfo');
|
|
$s=app()->make(HealthCheckupService::class);
|
|
return $s->GetCheckUpList(['userid'=>$userid,'group'=>$group,'page'=>$page,'pageSize'=>$pageSize,'searchInfo'=>$searchInfo]);
|
|
}
|
|
}
|