对接报告推送,修改查询报告列表接口

wenjuan
yanzai 1 year ago
parent f545cfe73a
commit 6a9159d3fb

@ -13,24 +13,68 @@ class ReportController extends Controller
{
$openid = request('openid');
$tj_status = request('tj_status');
$hospital_id=request('hospital_id');
if (!isset($openid)) return \Yz::echoError1("openid不能为空");
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
$persons = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0])->pluck('id_number')->toArray();
$list = DB::table('report_l1_records')->select('姓名', '性别', '登记时间', '套餐名称', '体检号', '体检状态', 'is_read')->whereIn('证件号码', $persons);
if(isset($tj_status) and $tj_status!==0){
if($tj_status===1){
$tj_status='报告未出';
$report_list=[];
$peis = new PEISApiController();
foreach ($persons as $key => $id_number) {
$data = [
'电话号码' => "",
'证件号码' => $id_number,
'体检号' => ""
];
$reports = $peis::Post('体检报告查询', $hospital_id, $data);
if (count($reports['data']) > 0) {
$reports_detail_list = $reports['data'];
foreach ($reports_detail_list as $key => $reports_detail) {
$report_list[]=$reports_detail;
}
}
if($tj_status===2){
$tj_status='报告已出';
}
$list=[];
foreach ($report_list as $key => $report) {
$report_list[$key]['is_read']=0;
if($report['体检状态']=='报告已出' || $report['体检状态']=='总检完成'){
$cha=DB::table('report_l1_records')->where(['体检号' => $report['体检号']])->first();
if(!!$cha and $cha->is_read==1){
$report_list[$key]['is_read']=1;
}
}
$list=$list->where('体检状态', $tj_status);
if(isset($tj_status) and $tj_status!==0){
if($tj_status==1 and $report['体检状态']=='报告已出' || $report['体检状态']=='总检完成'){
$list[]= $report_list[$key];
}
if($tj_status==2 and $report['体检状态']=='报告未出'){
$list[]= $report_list[$key];
}
}
}
$list=$list->get();
return \Yz::Return(true, "查询完成", ['list' => $list]);
// $list = DB::table('report_l1_records')->select('姓名', '性别', '登记时间', '套餐名称', '体检号', '体检状态', 'is_read')->whereIn('证件号码', $persons);
// if(isset($tj_status) and $tj_status!==0){
// if($tj_status===1){
// $tj_status='报告未出';
// $list=$list->where('体检状态', $tj_status);
//
// }
// if($tj_status===2){
// $tj_status='报告已出';
// $list=$list->where('体检状态', $tj_status);
// $list = $list->where(function ($query) use ($tj_status) {
// $query->where('体检状态', '报告已出')->orWhere('体检状态', '总检完成');
// });
// }
//
// }
// $list=$list->get();
// return \Yz::Return(true, "查询完成", ['list' => $list]);
}
public function GetReportJieLunJianYi()

@ -3,6 +3,7 @@
namespace App\Http\Controllers\API\Internal;
use App\Http\Controllers\Controller;
use App\Services\ReportService;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@ -11,24 +12,35 @@ use Illuminate\Support\Facades\Schema;
class SiXinPushController extends Controller
{
public static $request;
public function PushInfo(Request $request){
$key = $request->query('key');
$code = $request->query('code');//推送类型 "UpdateInfo".套餐、项目、分组 信息变更 "report".报告推送 "pdf".推送pdf
$content = $request->post();
$codeMark=[
'updateInfo'=>'套餐项目分组',
'report'=>'报告',
'pdf'=>'pdf文件'
];
if (!array_key_exists($code, $codeMark)) return \Yz::echoError1("code不正确");
if(isset($key) && $key=="xFgq6WzWFNYL6QwKKLtxqYn2NfQnNu3a"){
self::RequestLog('',$content,$code,$codeMark[$code]);
return \Yz::Return(true,"接收完成",$code);
}else{
return \Yz::echoError1("密钥错误");
}
}
public function PushInfo(Request $request)
{
$key = $request->query('key');
$code = $request->query('code');//推送类型 "UpdateInfo".套餐、项目、分组 信息变更 "report".报告推送 "pdf".推送pdf
$content = $request->post();
$codeMark = [
'updateInfo' => '套餐项目分组',
'report' => '报告',
'pdf' => 'pdf文件'
];
if (!array_key_exists($code, $codeMark)) return \Yz::echoError1("code不正确");
if (isset($key) && $key == "xFgq6WzWFNYL6QwKKLtxqYn2NfQnNu3a") {
self::RequestLog('', $content, $code, $codeMark[$code]);
//如果推送的是报告
if ($code == 'report') {
$report = new ReportService();
return $report->Save($content);
}
//如果推送的是套餐、项目、分组
if ($code == 'updateInfo') {
}
return \Yz::Return(true, "接收完成", $code);
} else {
return \Yz::echoError1("密钥错误");
}
}
public static function RequestLog($url, $post_data, $code, $mark)
{
@ -51,7 +63,7 @@ class SiXinPushController extends Controller
$table->id();
$table->string('code', 50)->index();
$table->string('mark', 50)->index();
$table->text('post_data');
$table->longText('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 300);
$table->timestamps();

@ -0,0 +1,98 @@
<?php
namespace App\Services;
use Illuminate\Support\Facades\DB;
class ReportService
{
public function Save($res)
{
if(!isset($res['体检号'])) return \Yz::echoError1("数据非预期,缺失'体检号'");
//根据体检号查询获取id万一不小心有多个相同的体检号 所以返回数组正常就1个
$report_l1_records_ids = DB::table('report_l1_records')->where(['体检号' => $res['体检号']])->pluck('id')->toArray();
//查找对应的收费项目列表 获取id数组
$report_l2_items_ids = DB::table('report_l2_items')->whereIn('reprort_l1_id', $report_l1_records_ids)->pluck('id')->toArray();
//查找 基础项目列表 删除
$report_l3_base_items_del = DB::table('report_l3_base_items')->whereIn('report_l2_id', $report_l2_items_ids)->delete();
//删除report_l2_items表数据
DB::table('report_l2_items')->whereIn('id', $report_l2_items_ids)->delete();
//删除report_l1_records表数据
DB::table('report_l1_records')->whereIn('id', $report_l1_records_ids)->delete();
//删除完后,进行添加
$r_data = [
"体检类型" => isset($res['体检类型']) ? $res['体检类型'] : null,
"查询密码" => isset($res['查询密码']) ? $res['查询密码'] : null,
"审核时间" => isset($res['审核时间']) ? $res['审核时间'] : null,
"总检医生" => isset($res['总检医生']) ? $res['总检医生'] : null,
"总检结论" => isset($res['总检结论']) ? $res['总检结论'] : null,
"总检建议" => isset($res['总检建议']) ? $res['总检建议'] : null,
"病种列表" => isset($res['病种列表']) ? json_encode($res['病种列表'], JSON_UNESCAPED_UNICODE) : null,
"报告文件列表" => isset($res['报告文件列表']) ? json_encode($res['报告文件列表'], JSON_UNESCAPED_UNICODE) : null,
"卡号" => $res['卡号'],
"证件类型" => $res['证件类型'],
"证件号码" => $res['证件号码'],
"地址" => $res['地址'],
"电话号码" => $res['电话号码'],
"婚姻状态" => $res['婚姻状态'],
"单位名称" => $res['单位名称'],
"批次Id" => $res['批次Id'],
"批次名称" => $res['批次名称'],
"部门名称" => $res['部门名称'],
"分组名称" => $res['分组名称'],
"体检号" => $res['体检号'],
"姓名" => $res['姓名'],
"性别" => $res['性别'],
"出生日期" => $res['出生日期'],
"登记时间" => $res['登记时间'],
"检前签到时间" => $res['检前签到时间'],
"体检状态" => $res['体检状态'],
"报告日期" => $res['报告日期'],
"套餐名称" => $res['套餐名称'],
"团检" => $res['团检'],
"支持下载报告文件" => $res['支持下载报告文件'],
];
$l1_id = DB::table('report_l1_records')->insertGetId($r_data);
if ($res['体检状态'] == '报告已出' || $res['体检状态'] == '总检完成') {
foreach ($res['收费项目列表'] as $key => $l2_item) {
$r2_data = [
"reprort_l1_id" => $l1_id,
"科室类型" => $l2_item['科室类型'],
"科室名称" => $l2_item['科室名称'],
"科室顺序" => $l2_item['科室顺序'],
"收费项目名称" => $l2_item['收费项目名称'],
"收费项目顺序" => $l2_item['收费项目顺序'],
"检查医生" => $l2_item['检查医生'],
"审核医生" => $l2_item['审核医生'],
"最后保存时间" => $l2_item['最后保存时间'],
];
$l2_id = DB::table('report_l2_items')->insertGetId($r2_data);
if ($l2_id) {
$report_l3_base_items = [];
foreach ($l2_item['基础项目列表'] as $key2 => $l3_item) {
$r3_data = [
"report_l2_id" => $l2_id,
"基础项目名称" => $l3_item['基础项目名称'],
"基础项目代码" => isset($l3_item['基础项目代码'])?$l3_item['基础项目代码']:$l3_item['基础项目Id'],
"基础项目顺序" => $l3_item['基础项目顺序'],
"结果类型" => $l3_item['结果类型'],
"结果值" => $l3_item['结果值'],
"结果值单位" => $l3_item['结果值单位'],
"结果值范围" => $l3_item['结果值范围'],
"异常标识" => $l3_item['异常标识'],
"所见" => $l3_item['所见'],
"描述" => $l3_item['描述'],
"结论" => $l3_item['结论'],
];
$report_l3_base_items[] = $r3_data;
}
//批量插入l3
DB::table('report_l3_base_items')->insert($report_l3_base_items);
}
}
}
return \Yz::Return(true,"接收完成",'report');
}
}

@ -29,6 +29,7 @@ const gettjbgInfo = async (index) => {
console.log(tabIndex.value);
console.log($store, "store");
let obj = {
hospital_id:$store.config.hospital[0].id
tj_status: tabIndex.value
};
const response = await $api("GetReportList", obj);

Loading…
Cancel
Save