diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/ReportController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/ReportController.php index 1f5ab2a..0feca08 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/ReportController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/ReportController.php @@ -40,25 +40,25 @@ class ReportController extends Controller $res = $peis::Post('体检报告查询', $hospital_id, $data); $res = $res['data'][0]; //根据体检号查询,获取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_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(); + 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(); + 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, + "体检类型" => 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['证件类型'], @@ -83,10 +83,48 @@ class ReportController extends Controller "团检" => $res['团检'], "支持下载报告文件" => $res['支持下载报告文件'], ]; - $insert_report_l1_records=DB::table('report_l1_records')->insert($r_data); - if($res['体检状态']=='报告已出'){ + $l1_id = DB::table('report_l1_records')->insertGetId($r_data); + if ($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['基础项目名称'], + "基础项目代码" => $l3_item['基础项目代码'], + "基础项目顺序" => $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, "操作完成", []); } }