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.

51 lines
2.0 KiB
PHP

<?php
namespace App\Http\Controllers\API\Internal;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class AppointmentController extends Controller
{
//给第三的接口,查询预约记录
public function GetAppointmentRecord(){
date_default_timezone_set('PRC');
$sfz =request('id_card_num');
$org_sn =request('org_sn');
if(!isset($sfz)) return \Yz::echoError1('证件号不能为空');
if(!isset($org_sn)) return \Yz::echoError1('机构code不能为空');
$currentYear = date('Y');
$firstDay = date('Y-01-01', strtotime($currentYear));
$lastDay = date('Y-12-31', strtotime($currentYear));
$HSM=\App\Lib\HSM::HsmEncrypt($sfz);
if($HSM['status']!=true){
return \Yz::echoError1('调用HSM加密失败');
}
$sfz=$HSM['data'];
$infos=[];
if(isset($sfz)){
$info=DB::table('appointment_record as a')
->select('a.id','a.name','a.sex','a.tel','a.id_card_num','a.date','a.time','a.type','a.fee_type as free_type','a.doc_type_id','a.org_code as org_sn','a.org_name','a.doc_type_name','a.created_at','b.org_name')
->join('medical_institution as b','a.org_code','=','b.sn')
->where(['a.id_card_num'=>$sfz,'a.is_del'=>0,'a.org_code'=>$org_sn])
->whereBetween('a.created_at',[$firstDay,$lastDay])->orderBy('a.id','desc')->first();
if(!!$info){
//查询相关图片
$imgs=[];
$imgs=DB::table('appointment_img')->where(['appointment_record_id'=>$info->id])->get();
foreach ($imgs as $key=>$item){
$imgs[$key]->imgurl=env('APP_URL').$item->imgurl;
}
$info->files=$imgs;
$info->id_card_num=request('id_card_num');
$infos[]=$info;
}
return \Yz::Return(true,'查完完成',$infos);
}
}
}