报告详情接口,对接小程序加密解密

wenjuan
yanzai 1 year ago
parent 364d239fd2
commit 5cf5bd870d

@ -356,8 +356,8 @@ select combo_id as c_id,count(*) as count from orders where status in(2,4) group
'color' => '#EBF5FC'
];
}
$combo->tag=$tags;
$combo->tag[]=[
$combo->tags=$tags;
$combo->tags[]=[
'text' => $combo->item_count.'个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',

@ -9,95 +9,135 @@ use Illuminate\Support\Facades\DB;
class ReportController extends Controller
{
public function GetReportList(){
$openid =request('openid');
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)->get();
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
public function GetReportJieLunJianYi()
{
$YiBanJianChaList=[
['name'=>"身高(cm)",
'code'=>"SG"],
['name'=>"体重(kg)",
'code'=>"TZ"],
['name'=>"收缩压",
'code'=>"XY(SSY)"],
['name'=>"血红蛋白",
'code'=>"BXBSM"],
];
$tijian_num =request('tijian_num');
$report=DB::table('report_l1_records as a')->where(['a.体检号'=>$tijian_num])->first();
if(!!$report){
if($report->体检状态=='报告未出') return \Yz::echoError1("此报告暂时未出");
$items=DB::table('report_l2_items as b')->leftJoin('report_l3_base_items as c' ,'b.id','=','c.report_l2_id')->where(['b.reprort_l1_id'=>$report->id])->get();
$v_error_items=[];
$error_items=[];
$base_items=[];
foreach($items as $item){
foreach ($YiBanJianChaList as $ybitem) {
if($item->基础项目代码==$ybitem['code']){
$base_items[]=[
'name'=>$ybitem['name'],
'value'=>$item->结果值,
];
}
}
if($item->异常标识!=null and $item->异常标识!=''){
$error_items[]=$item;
public function GetReportList()
{
$openid = request('openid');
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)->get();
return \Yz::Return(true, "查询完成", ['list' => $list]);
}
public function GetReportJieLunJianYi()
{
$YiBanJianChaList = [
['name' => "身高(cm)",
'code' => "SG"],
['name' => "体重(kg)",
'code' => "TZ"],
['name' => "收缩压",
'code' => "XY(SSY)"],
['name' => "血红蛋白",
'code' => "BXBSM"],
];
$tijian_num = request('tijian_num');
$report = DB::table('report_l1_records as a')->where(['a.体检号' => $tijian_num])->first();
if (!!$report) {
if ($report->体检状态 == '报告未出') return \Yz::echoError1("此报告暂时未出");
$items = DB::table('report_l2_items as b')->leftJoin('report_l3_base_items as c', 'b.id', '=', 'c.report_l2_id')->where(['b.reprort_l1_id' => $report->id])->get();
$v_error_items = [];
$error_items = [];
$base_items = [];
foreach ($items as $item) {
foreach ($YiBanJianChaList as $ybitem) {
if ($item->基础项目代码 == $ybitem['code']) {
$base_items[] = [
'name' => $ybitem['name'],
'value' => $item->结果值,
];
}
}
$info=[];
$info['name']=$report->姓名;
$info['base_date']=$base_items;
$info['items']=[
'all_count'=>count($items),
'ipt_error_count'=>count($v_error_items),//重要异常数量
'error_count'=>count($error_items),//异常数量
];
$info['content']=$report->总检建议;
return \Yz::Return(true,"查询完成",['info'=>$info]);
}else{
return \Yz::echoError1("查询报告失败");
}
}
//完整报告中的列表
}
if ($item->异常标识 != null and $item->异常标识 != '') {
$error_items[] = $item;
}
}
$info = [];
$info['name'] = $report->姓名;
$info['base_date'] = $base_items;
$info['items'] = [
'all_count' => count($items),
'ipt_error_count' => count($v_error_items),//重要异常数量
'error_count' => count($error_items),//异常数量
];
$info['content'] = $report->总检建议;
return \Yz::Return(true, "查询完成", ['info' => $info]);
} else {
return \Yz::echoError1("查询报告失败");
}
}
//完整报告中的列表
public function GetReportDetaiList()
{
$tijian_num =request('tijian_num');
$report=DB::table('report_l1_records as a')->where(['a.体检号'=>$tijian_num])->first();
if(!$report) return \Yz::echoError1("查询报告失败");
if($report->体检状态=='报告未出') return \Yz::echoError1("此报告暂时未出");
$items=DB::table('report_l2_items as b')->leftJoin('report_l3_base_items as c' ,'b.id','=','c.report_l2_id')->where(['b.reprort_l1_id'=>$report->id])->get();
$list=[];
foreach($items as $item){
$tijian_num = request('tijian_num');
$report = DB::table('report_l1_records as a')->where(['a.体检号' => $tijian_num])->first();
if (!$report) return \Yz::echoError1("查询报告失败");
if ($report->体检状态 == '报告未出') return \Yz::echoError1("此报告暂时未出");
$items = DB::table('report_l2_items as b')->leftJoin('report_l3_base_items as c', 'b.id', '=', 'c.report_l2_id')->where(['b.reprort_l1_id' => $report->id])->get();
$list = [];
foreach ($items as $item) {
$ShouFeiName = $item->收费项目名称;
if (!isset($list[$ShouFeiName])) {
$error_count=0;
$list[$ShouFeiName] = ['id'=>$item->report_l2_id,'error_count'=>$error_count];
$error_count = 0;
$list[$ShouFeiName] = ['id' => $item->report_l2_id, 'error_count' => $error_count];
}
if($item->异常标识!=null and $item->异常标识!=''){
if ($item->异常标识 != null and $item->异常标识 != '') {
$error_count++;
}
$list[$ShouFeiName] = ['id'=>$item->report_l2_id,'error_count'=>$error_count];
$list[$ShouFeiName] = ['id' => $item->report_l2_id, 'error_count' => $error_count];
}
return \Yz::Return(true,"查询完成",['list'=>$list]);
return \Yz::Return(true, "查询完成", ['list' => $list]);
}
public function GetReportDetai(){
$id =request('id');
$items=DB::table('report_l3_base_items')->where(['report_l2_id'=>$id])->get();
foreach ($items as $item){
public function GetReportDetai()
{
$id = request('id');
$l2 = DB::table('report_l2_items')->where(['id' => $id])->first();
$items = DB::table('report_l3_base_items')->where(['report_l2_id' => $id])->orderBy('基础项目顺序')->get();
if ($l2->科室类型 == 'PACS') {
$suojian = [];
$zhenduan = [];
foreach ($items as $item) {
$suojian[] = $item->所见;
$jielun[] = $item->结论;
}
if (count($items) > 0) {
return \Yz::Return(true, "查询完成", ['is_pacs'=>true,'suojian' => $suojian,'jielun' => $jielun]);
} else {
return \Yz::echoError1('此项暂无内容');
}
} else {
$error_items = [];
foreach ($items as $item) {
if ($item->异常标识 != null and $item->异常标识 != '') {
$m = '';
if ($item->异常标识 == '↓') {
$m = '低';
}
if ($item->异常标识 == '↑') {
$m = '高';
}
$error_items[] = $item->基础项目名称 . $m;
}
}
if (count($items) > 0) {
return \Yz::Return(true, "查询完成", ['is_pacs'=>false,'list' => $items, 'error_items' => $error_items]);
} else {
return \Yz::echoError1('此项暂无内容');
}
}
}
}

@ -102,13 +102,15 @@ class UserController extends Controller
public function UpdatePersonList($openid)
{
$XCX=new XCXApiController();
$list=$XCX::Post('就诊人列表',['a'=>1]);
$data=[
'wxid'=>$openid
];
$list=$XCX::Post('就诊人列表',$data);
$ApiPersonList = [
[
'ghzid' => 'ghz11',
'id_number'=>'24324324322',
'name' => '测试1',
'id_number'=>'15210219920524154X',
'name' => '周京京',
'phone' => '11111111111',
'sex' => '1',
'birthday' => '1989-01-01',

@ -12,23 +12,55 @@ use Illuminate\Support\Facades\Schema;
class XCXApiController extends Controller
{
public static $request;
public static $appid = "13a159e438a742dd932c9bddbfaa41e5";
public static $signType = "OPENAPI-SHA256-RSA2048";
public static $privateKey = "-----BEGIN PRIVATE KEY-----\n"
. "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDGr/KoMftpabe/Mxqm0q6d8GYnNabPiMlPnr
3zQEGzeFSyNp5G8ZD5p6o6taj5Kmg6JPndR0WmNTXr0o5VD6vs3DfbV8wFfHKJDtPYijzUCHXWcef1XyMGOiBFf
ToLVYn+mCoD9dnOy+jBqWg6bQSTOTfX+Uo9/qcxbY5bDv+aPZ7gJYnW6IFN5f/vnw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iBjy+UMrfaXgoz6YTPGFHhGg4jeId2Z59lgUsF0ZxpyZvhxSUhmn2q4UfwG5lqnuw4ksIsYZolojDQdsRZ
M4Imnhp2ebSsMLNoxOYIYbD8qXxtRwcsJ/xkESOl4Ts4QKBgQDYMuU0lCiml1/z8VTpAX91O8gK61vczHZZarhJN
URYZLJgZCnJZXgS/f0BUIYdvhMHLdrHsGPS3HXHEn0oKJyZERbtSGM1UVK9It/Pb+IlWhAZYkajIlM+p5gn8SYorE
27sNjRqoKRKYyy4BfhVGvFSI+Ofyo1yPzhrnRTiSjBjQ==\n"
. "-----END PRIVATE KEY-----";
public static function Api($url_code)
{
$url = 'https://dqgatjzx-wx.sixinyun.com';
$api['就诊人列表'] = "{$url}/PEISCommon/QueryCombos/460107000001";
$url = 'https://xdfe-api.hnxdfe.com/hisminitest';
// $url = 'https://dqgatjzx-wx.sixinyun.com';
$api['就诊人列表'] = "{$url}/jeecg-boot/hospital/openapi/archive/list";
$api['订单支付'] = "{$url}/PEISCommon/QueryGroups";
$api['订单查询'] = "{$url}/PEISCommon/QueryCombos";
$api['订单查询'] = "{$url}/PEISCommon/QueryGroups/460107000001";
$api['订单退款'] = "{$url}/PEISCommon/QueryCombos";
return $api["{$url_code}"] ?? $url_code;
}
public static function Post($url_code, $data)
{
$url = self::Api($url_code);
self::RequestLog($url, $data, $url_code,'小程序接口');
$response = Http::post($url,$data);
self::RequestLog($url, $data, $url_code, '小程序接口');
$body_str = self::buildSortedQueryString($data);
$response = Http::withHeaders([
'Authorization' => self::BuildAuthorization('POST', "/jeecg-boot/hospital/openapi/archive/list", $body_str)
])->post($url, $data);
if ($response->successful()) {
// 处理成功的响应
$res_string = json_encode($response->json(),JSON_UNESCAPED_UNICODE);
$res_string = json_encode($response->json(), JSON_UNESCAPED_UNICODE);
dd($res_string);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
@ -36,13 +68,14 @@ class XCXApiController extends Controller
self::$request->response_data = $save_res;
self::$request->save();
} else {
// 处理失败的响应
self::$request->response_data = "请求失败";
self::$request->save();
}
}
public static function RequestLog($url, $post_data, $mark ,$code=0)
public static function RequestLog($url, $post_data, $mark, $code = 0)
{
self::CheckTableName();
foreach ($post_data as $key => $post_datum) {
@ -78,4 +111,38 @@ class XCXApiController extends Controller
self::$request = new \App\Models\PEISLog();
self::$request->setTable($table_name);
}
//构造请求报文主体 首先将请求报文的参数名按照字典序进行排序,然后用&拼接各个参数
public static function buildSortedQueryString($params)
{
// 1. 按照参数名排序
ksort($params);
// 2. 拼接参数名和参数值
$queryString = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
return $queryString;
}
//计算签名和 Authorization
public static function BuildAuthorization($method, $url, $body)
{
$currentTimestamp = time();
$nonce = md5(uniqid(rand(), true));
$SignStr = $method . '\n' . $url . '\n' . $currentTimestamp . '\n' . $nonce . '\n' . $body . '\n';
// 生成 SHA-256 哈希值
// $hashedData = hash('sha256', $SignStr, true); // true 表示返回二进制格式
// 使用私钥进行 RSA 签名
openssl_sign($SignStr, $signature, self::$privateKey, OPENSSL_ALGO_SHA256);
// 对签名结果进行 Base64 编码
$base64Signature = base64_encode($signature);
$signInfo = 'appid=' . self::$appid . ',nonce=' . $nonce . ',timestamp=' . $currentTimestamp . ',signature=' . $base64Signature;
return self::$signType . ' ' . $signInfo;
}
}

@ -59,6 +59,7 @@ Route::group(['prefix' => 'api/H5'], function () {
Route::post('/GetReportList', 'App\Http\Controllers\API\H5\ReportController@GetReportList');//获取关联的所有体检人报告列表
Route::post('/GetReportJieLunJianYi', 'App\Http\Controllers\API\H5\ReportController@GetReportJieLunJianYi');//获取报告结论建议页面数据
Route::post('/GetReportDetaiList', 'App\Http\Controllers\API\H5\ReportController@GetReportDetaiList');//完整报告中的列表
Route::post('/GetReportDetai', 'App\Http\Controllers\API\H5\ReportController@GetReportDetai');//完整报告某项详情

Loading…
Cancel
Save