parent
ecb35a99f1
commit
4ce8774ffd
@ -0,0 +1,63 @@ |
||||
<?php |
||||
declare(strict_types = 1); |
||||
|
||||
namespace App\Http\Controllers\Outpatient; |
||||
|
||||
use App\Exceptions\GeneralException; |
||||
use App\Http\Logics\Outpatient\RecordLogic; |
||||
use App\Http\Resources\Outpatient\Record\RecordDetailsResource; |
||||
use App\Http\Resources\Outpatient\Record\RecordListsResource; |
||||
use Illuminate\Http\JsonResponse; |
||||
use Illuminate\Http\Request; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
|
||||
class RecordController |
||||
{ |
||||
protected RecordLogic $record_logic; |
||||
|
||||
/** |
||||
* RecordController Construct. |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
$this->record_logic = new RecordLogic(); |
||||
} |
||||
|
||||
/** |
||||
* 获取缴费记录列表 |
||||
* @param Request $request |
||||
* @param string $patient_id |
||||
* @return JsonResponse |
||||
* @throws GeneralException |
||||
*/ |
||||
public function lists(Request $request, string $patient_id): JsonResponse |
||||
{ |
||||
$validated = $request->validate([ |
||||
'start_date' => 'date_format:Y-m-d', |
||||
'end_date' => 'date_format:Y-m-d|after:start_date', |
||||
], [ |
||||
'start_date.date_format' => '日期格式错误', |
||||
'end_date.date_format' => '日期格式错误', |
||||
'end_date.after' => '查询日期错误', |
||||
]); |
||||
|
||||
$response = $this->record_logic->getRecordLists($patient_id, $validated['start_date'] ?? '', $validated['end_date'] ?? ''); |
||||
|
||||
return jsonResponse(Response::HTTP_OK, 'success', RecordListsResource::make($response)->toArray()); |
||||
} |
||||
|
||||
/** |
||||
* 退号 |
||||
* @param Request $request |
||||
* @param string $patient_id |
||||
* @param string $serial_no |
||||
* @return JsonResponse |
||||
* @throws GeneralException |
||||
*/ |
||||
public function details(Request $request, string $patient_id, string $serial_no): JsonResponse |
||||
{ |
||||
$response = $this->record_logic->getRecordDetails($patient_id, $serial_no); |
||||
|
||||
return jsonResponse(Response::HTTP_OK, 'success.', RecordDetailsResource::make($response)->toArray()); |
||||
} |
||||
} |
@ -0,0 +1 @@ |
||||
<?php |
@ -0,0 +1,106 @@ |
||||
<?php |
||||
declare(strict_types = 1); |
||||
|
||||
namespace App\Http\Logics\Outpatient; |
||||
|
||||
use App\Exceptions\GeneralException; |
||||
use App\Models\Order; |
||||
use App\Models\RegistrationRecord; |
||||
use App\Services\HisSoap\Client; |
||||
use App\Utils\Traits\Logger; |
||||
use App\Utils\Traits\MiniProgramAuth; |
||||
use Illuminate\Auth\AuthenticationException; |
||||
use Illuminate\Support\Facades\Cache; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
|
||||
class RecordLogic |
||||
{ |
||||
use Logger; |
||||
use MiniProgramAuth; |
||||
|
||||
private Client $his_soap; |
||||
|
||||
/** |
||||
* RecordLogic Construct |
||||
* @throws AuthenticationException |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
$this->authInitialize(); |
||||
$this->his_soap = app('HisSoapService'); |
||||
} |
||||
|
||||
/** |
||||
* 获取挂号记录列表 |
||||
* @param string $patient_id |
||||
* @param string $start_date |
||||
* @param string $end_date |
||||
* @return array |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getRecordLists(string $patient_id, string $start_date, string $end_date): array |
||||
{ |
||||
$response = $this->his_soap->getPaidLists($patient_id, $start_date, $end_date); |
||||
|
||||
if (!isset($response['RESULTCODE']) || $response['RESULTCODE'] !== '0') { |
||||
throw new GeneralException($response['ERRORMSG'] ?? '暂无相关挂号记录!', Response::HTTP_SERVICE_UNAVAILABLE); |
||||
} |
||||
|
||||
// 缓存2小时 |
||||
Cache::set('Outpatient.Record.'. $this->open_id.'.'. $patient_id, json_encode($response, JSON_UNESCAPED_UNICODE), 2 * 60 * 60); |
||||
return $response; |
||||
} |
||||
|
||||
/** |
||||
* 获取挂号记录列表 |
||||
* @param string $patient_id |
||||
* @param string $serial_no |
||||
* @return array |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getRecordDetails(string $patient_id, string $serial_no): array |
||||
{ |
||||
$this->getCacheRecordInfo($patient_id, $serial_no); |
||||
|
||||
$response = $this->his_soap->getPaidDetails($serial_no); |
||||
|
||||
if (!isset($response['RESULTCODE']) || $response['RESULTCODE'] !== '0') { |
||||
throw new GeneralException($response['ERRORMSG'] ?? '暂无相关缴费详情!', Response::HTTP_SERVICE_UNAVAILABLE); |
||||
} |
||||
|
||||
return $response; |
||||
} |
||||
|
||||
/** |
||||
* 获取缓存里的记录详情 |
||||
* @param string $patient_id |
||||
* @param string $serial_no |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
protected function getCacheRecordInfo(string $patient_id, string $serial_no): mixed |
||||
{ |
||||
$cache_key = 'Outpatient.Record.'. $this->open_id.'.'. $patient_id; |
||||
|
||||
$record_info = Cache::get($cache_key); |
||||
if (empty($record_info)) { |
||||
throw new GeneralException($response['ERRORMSG'] ?? '查询不到缴费记录,请重新再试!', Response::HTTP_SERVICE_UNAVAILABLE); |
||||
} |
||||
$record_info = json_decode($record_info, true); |
||||
|
||||
// 获取具体的缴费详情 |
||||
$record_info = xmlArrayToListByKey($record_info, 'RECORD'); |
||||
foreach ($record_info['RECORD'] as $v) { |
||||
if ($v['RCPTID'] === $serial_no) { |
||||
$info = $v; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (empty($info)) { |
||||
throw new GeneralException('查询不到缴费记录,请重新再试!', Response::HTTP_SERVICE_UNAVAILABLE); |
||||
} |
||||
|
||||
return $info; |
||||
} |
||||
} |
@ -0,0 +1,61 @@ |
||||
<?php |
||||
declare(strict_types = 1); |
||||
|
||||
namespace App\Http\Resources\Outpatient\Record; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class RecordDetailsResource extends JsonResource |
||||
{ |
||||
/** |
||||
* Transform the resource into an array. |
||||
* |
||||
* @return array<string, mixed> |
||||
*/ |
||||
public function toArray(Request $request = null): array |
||||
{ |
||||
$info = [ |
||||
'date' => date('Y-m-d H:i:s', strtotime($this->resource['JSRQ'])), |
||||
'receipt_id' => $this->resource['TREAID'], |
||||
'receipt_no' => $this->resource['HOSTRANNO'], |
||||
'total_fee' => (float) $this->resource['COSTS'], |
||||
'self_fee' => (float) $this->resource['GRZF'] ?? 0, |
||||
'reduce_fee' => (float) $this->resource['JJZF'] ?? 0, |
||||
'exec_address' => $this->resource['PHYADDRESS'] ?: '', |
||||
'dept_name' => $this->resource['DEPNAME'], |
||||
'doctor_name' => $this->resource['DOCTNAME'], |
||||
'clinic_diagnosis' => $this->resource['CYZD'], |
||||
'charge_user' => $this->resource['CZGH'], |
||||
]; |
||||
|
||||
$this->resource['RECORD'] = xmlArrayToListByKey($this->resource['RECORD'], 'ITEMREC'); |
||||
|
||||
foreach ($this->resource['RECORD']['ITEMREC'] as $v) { |
||||
$info['item_lists'][] = [ |
||||
'visit_date' => $v['VISITDATE'], |
||||
'category_name' => $v['CLASSNAME'], |
||||
'item_name' => $v['ITEMNAME'], |
||||
'spec' => $v['ITEMSPEC'], |
||||
'unit' => $v['UNITS'], |
||||
'quantity' => (int) $v['AMOUNT'], |
||||
'price' => (float) $v['PRICE'], |
||||
'total_price' => (float) $v['COSTS'], |
||||
|
||||
// 冗余字段 |
||||
'package_name' => $v['ZTMC'] ?: '', |
||||
'dose_per_administration' => $v['YCJL'] ?: '', |
||||
'dose_unit' => $v['JLDW'] ?: '', |
||||
'days_of_use' => $v['YYTS'] ?: '', |
||||
'frequency_per_day' => $v['MRCS'] ?: '', |
||||
'dosage_schedule_name' => $v['PCMC'] ?: '', |
||||
'medical_insurance_code' => $v['YPBM'] ?: '', |
||||
'drug_registration_code' => $v['YJBM'] ?: '', |
||||
'medical_insurance_category' => $v['YBFL'] ?: '', |
||||
'employee_name' => $v['YGXM'] ?:'', |
||||
]; |
||||
} |
||||
|
||||
return $info; |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
<?php |
||||
declare(strict_types = 1); |
||||
|
||||
namespace App\Http\Resources\Outpatient\Record; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class RecordListsResource extends JsonResource |
||||
{ |
||||
/** |
||||
* Transform the resource into an array. |
||||
* |
||||
* @return array<string, mixed> |
||||
*/ |
||||
public function toArray(Request $request = null): array |
||||
{ |
||||
$this->resource = xmlArrayToListByKey($this->resource, 'RECORD'); |
||||
|
||||
$lists = []; |
||||
foreach ($this->resource['RECORD'] as $v) { |
||||
$lists[] = [ |
||||
'patient_id' => $v['PATIENTID'], |
||||
'patient_name' => $v['NAME'], |
||||
'sex' => $v['SEX'], |
||||
'charge_type' => $v['CHARGETYPE'], |
||||
'visit_date' => $v['VISITDATE'], |
||||
'receipt_id' => $v['RCPTID'], |
||||
'receipt_no' => $v['RCPTNO'], |
||||
'total_fee' => (float) $v['COSTS'], |
||||
'self_fee' => (float) $v['GRZF'] ?? 0, |
||||
'reduce_fee' => (float) $v['JJZF'] ?? 0, |
||||
]; |
||||
} |
||||
|
||||
return $lists; |
||||
} |
||||
} |
@ -0,0 +1,588 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Services\HisHttp; |
||||
|
||||
use App\Dictionary\Patient\CardType; |
||||
use App\Dictionary\Patient\Sex; |
||||
use App\Exceptions\GeneralException; |
||||
use App\Utils\Traits\Logger; |
||||
use App\Utils\Transfer\HisHttpClient\ClientFactory; |
||||
use App\Utils\Transfer\HttpTransferAbstract; |
||||
use Exception; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
|
||||
class Client |
||||
{ |
||||
use Logger; |
||||
|
||||
// his服务 |
||||
private HttpTransferAbstract $service; |
||||
|
||||
/** |
||||
* Client Construct |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
$his_name = 'his_api'; |
||||
$this->service = ClientFactory::getClientTransfer($his_name); |
||||
$this->setChannel($his_name); |
||||
} |
||||
|
||||
/** |
||||
* 公共入参 |
||||
* @return array |
||||
*/ |
||||
protected function commonRequestData(): array |
||||
{ |
||||
return [ |
||||
'mock' => 0, |
||||
'appKey' => '', |
||||
'atmName' => '', |
||||
'operatorId' => '', |
||||
'hospitalId' => '1', |
||||
'f1' => '', |
||||
'f2' => '', |
||||
'f3' => '' |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* 请求 |
||||
* @param string $method_name |
||||
* @param string $request_name |
||||
* @param array $params |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
protected function requestHandle(string $method_name, string $request_name, array $params): mixed |
||||
{ |
||||
try { |
||||
return $this->service |
||||
->transferMethod($method_name, $request_name, $params) |
||||
->getResult(); |
||||
|
||||
} catch (Exception $e) { |
||||
$err_msg = "{$e->getMessage()} ON {$e->getFile()}:{$e->getLine()}"; |
||||
$this->error('调用api接口失败, 错误消息:' . $err_msg, $params); |
||||
|
||||
throw new GeneralException($e->getMessage(), Response::HTTP_SERVICE_UNAVAILABLE); |
||||
} |
||||
} |
||||
|
||||
// Patient Module Start |
||||
|
||||
/** |
||||
* 建档 |
||||
* @param string $card_no 卡号 |
||||
* @param CardType $card_type 卡类型 |
||||
* @param string $patient_name 患者名称 |
||||
* @param Sex $sex 性别 |
||||
* @param string $birthday 出生日期 |
||||
* @param string $id_card_no 身份证件号码 |
||||
* @param string $mobile 手机号码 |
||||
* @param string $address 地址 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function registerCard(string $card_no, CardType $card_type, string $patient_name, Sex $sex, string $birthday, string $id_card_no, string $mobile, string $address): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'CreateCardPatInfo', [ |
||||
'json' => [ |
||||
'cardNo' => $card_no, |
||||
'cardType' => $card_type->value, |
||||
'patientName' => $patient_name, |
||||
'sex' => $sex->value, |
||||
'birthday' => $birthday, |
||||
'idCardNo' => $id_card_no, |
||||
'mobile' => $mobile, |
||||
'address' => $address, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 获取患者信息 |
||||
* @param string $register_area 挂号区域(默认为 01) |
||||
* @param string $card_no 卡号 |
||||
* @param CardType $card_type 卡类型 |
||||
* @param string $name 姓名 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getPatientInfo(string $card_no, CardType $card_type, string $name, string $register_area = '01'): mixed |
||||
{ |
||||
// 调用请求处理方法 |
||||
return $this->requestHandle('POST', 'GetCardInfo', [ |
||||
'json' => [ |
||||
'registerArea' => $register_area, |
||||
'cardNo' => $card_no, |
||||
'cardType' => $card_type->value, |
||||
'name' => $name, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
// Patient Module End |
||||
|
||||
// Registration Module Start |
||||
|
||||
/** |
||||
* 获取科室信息(校验身份证有效卡) |
||||
* @param string $type_id 科室大类编码(如 1 普通门诊,2 急诊门诊,3 专家门诊) |
||||
* @param string $type_name 科室大类名称(如 普通门诊,急诊门诊,专家门诊) |
||||
* @param string $register_area 挂号区域(默认为 01) |
||||
* @param string $date 挂号日期(格式为 yyyy-mm-dd) |
||||
* @param string $rank_id 班次(如 1 上午,2 下午,3 晚上,4 中午) |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getDepType( |
||||
string $type_id, |
||||
string $type_name, |
||||
string $register_area = '01', // 默认挂号区域为 01 |
||||
string $date = '', // 默认日期为空,表示查询所有科室 |
||||
string $rank_id = '' // 默认班次为空,表示查询所有班次 |
||||
): mixed |
||||
{ |
||||
// 调用请求处理方法 |
||||
return $this->requestHandle('POST', 'GetDepType', [ |
||||
'json' => [ |
||||
'typeId' => $type_id, |
||||
'typeName' => $type_name, |
||||
'registerArea' => $register_area, |
||||
'date' => $date, |
||||
'rankId' => $rank_id, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 查询医生排班信息 |
||||
* @param string $dept_id 科室编码 |
||||
* @param string $is_today 是否返回预约号源(0:当天挂号,1:返回预约明细号源,2:返回预约总号源,3:当天挂号加科室排班信息,4:返回当天挂号总号源,5:返回科室和医生排班信息) |
||||
* @param string $rank_id 班次(1:上午,2:下午,3:晚上,4:中午,默认返回所有班次) |
||||
* @param string $date 排班日期(格式为 yyyy-mm-dd,为空则返回当天以后的排班) |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getDoctorLists( |
||||
string $dept_id, |
||||
string $is_today = '0', // 默认返回当天挂号 |
||||
string $rank_id = '', // 默认返回所有班次 |
||||
string $date = '' // 默认返回当天及以后的排班 |
||||
): mixed |
||||
{ |
||||
// 调用请求处理方法 |
||||
return $this->requestHandle('POST', 'GetDoctList', [ |
||||
'json' => [ |
||||
'depId' => $dept_id, |
||||
'isTodayRegister' => $is_today, |
||||
'rankId' => $rank_id, |
||||
'date' => $date, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 锁号 |
||||
* @param string $type_id 科室类别ID |
||||
* @param string $dept_id 科室ID |
||||
* @param string $doctor_id 医生ID |
||||
* @param string $reg_id 号源ID |
||||
* @param string $rank_id 午别ID |
||||
* @param string $date 日期 yyyy-mm-dd |
||||
* @param string $register_area 挂号区域(默认为 01) |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function lockRegister( |
||||
string $type_id, |
||||
string $dept_id, |
||||
string $doctor_id, |
||||
string $reg_id, |
||||
string $rank_id, |
||||
string $date, |
||||
string $register_area = '01' |
||||
): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'LockRegist', [ |
||||
'json' => [ |
||||
'typeId' => $type_id, |
||||
'depId' => $dept_id, |
||||
'doctId' => $doctor_id, |
||||
'regId' => $reg_id, |
||||
'rankId' => $rank_id, |
||||
'date' => $date, |
||||
'registerArea' => $register_area, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 取消锁号 |
||||
* @param string $patient_id 患者ID |
||||
* @param string $type_id 科室类别ID |
||||
* @param string $dept_id 科室ID |
||||
* @param string $doctor_id 医生ID |
||||
* @param string $reg_id 号源ID |
||||
* @param string $shift_seq_id |
||||
* @param string $rank_id 午别ID |
||||
* @param string $date 日期 yyyy-mm-dd |
||||
* @param string $register_area 挂号区域(默认为 01) |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function unlockRegister( |
||||
string $patient_id, |
||||
string $type_id, |
||||
string $dept_id, |
||||
string $doctor_id, |
||||
string $reg_id, |
||||
string $shift_seq_id, |
||||
string $rank_id, |
||||
string $date, |
||||
string $register_area = '01' |
||||
): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'CancelLockRegist', [ |
||||
'json' => [ |
||||
'patientId' => $patient_id, |
||||
'typeId' => $type_id, |
||||
'depId' => $dept_id, |
||||
'doctId' => $doctor_id, |
||||
'regId' => $reg_id, |
||||
'shiftSeqId' => $shift_seq_id, |
||||
'rankId' => $rank_id, |
||||
'date' => $date, |
||||
'registerArea' => $register_area, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 挂号确认 |
||||
* @param string $patient_id 患者ID |
||||
* @param string $patient_name 患者名称 |
||||
* @param string $dept_id 科室ID |
||||
* @param string $doctor_id 医生ID |
||||
* @param string $reg_id 号源ID |
||||
* @param string $rank_id 午别ID |
||||
* @param string $date 挂号日期 |
||||
* @param string $tran_type 支付方式 12 银联 3 医保 88 微信 89 支付宝 |
||||
* @param string $order_id 交易流水号 |
||||
* @param string $bankTranNo 银行交易流水号 |
||||
* @param string $bankTranDate 银行交易日期 yyyy-mm-dd |
||||
* @param string $bankTranTime 银行交易时间 hh:ii:ss |
||||
* @param string $bankTranAmt 银行交易金额 |
||||
* @param string $fee 总金额 |
||||
* @param string $bankCardNo 银行卡号 |
||||
* @param string $register_area 挂号区域(默认为 01) |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function registerConfirm( |
||||
string $patient_id, |
||||
string $patient_name, |
||||
string $dept_id, |
||||
string $doctor_id, |
||||
string $reg_id, |
||||
string $rank_id, |
||||
string $date, |
||||
string $tran_type, |
||||
string $order_id, |
||||
string $bankTranNo, |
||||
string $bankTranDate, |
||||
string $bankTranTime, |
||||
string $bankTranAmt, |
||||
string $fee, |
||||
string $bankCardNo, |
||||
string $register_area = '01' |
||||
): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'PayRegTrade', [ |
||||
'json' => [ |
||||
'patientID' => $patient_id, |
||||
'patientName' => $patient_name, |
||||
'depID' => $dept_id, |
||||
'doctID' => $doctor_id, |
||||
'regID' => $reg_id, |
||||
'rankID' => $rank_id, |
||||
'date' => $date, |
||||
'tranType' => $tran_type, |
||||
'orderID' => $order_id, |
||||
'bankTranNo' => $bankTranNo, |
||||
'bankTranDate' => $bankTranDate, |
||||
'bankTranTime' => $bankTranTime, |
||||
'bankTranAmt' => $bankTranAmt, |
||||
'fee' => $fee, |
||||
'bankCardNo' => $bankCardNo, |
||||
'registerArea' => $register_area, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 查询挂号记录便于就诊 |
||||
* @param string $patient_id 患者ID |
||||
* @param string $start_date 挂号开始日期,默认为空表示从今天起之后的所有挂号记录 |
||||
* @param string $end_date 挂号结束日期,默认为空表示等于开始日期 |
||||
* @param string $type 查询类型(1:当天挂号,2:预约取号),默认为空表示查询所有 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getRegisterRecordLists( |
||||
string $patient_id, |
||||
string $start_date = '', // 可为空,表示从今天起之后的所有挂号记录 |
||||
string $end_date = '', // 可为空,默认等于开始日期 |
||||
string $type = '' // 可为空,默认查询所有类型 |
||||
): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'GetGHMXList', [ |
||||
'json' => [ |
||||
'patientId' => $patient_id, |
||||
'date' => $start_date, |
||||
'eDate' => $end_date, |
||||
'type' => $type, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 检查挂号是否可以取消 |
||||
* @param string $visit_no 挂号流水号 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function checkRefundRegisterStatus(string $visit_no): mixed |
||||
{ |
||||
// 调用请求处理方法 |
||||
return $this->requestHandle('POST', 'GHCancelCheck', [ |
||||
'json' => [ |
||||
'visitNo' => $visit_no, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 确认挂号取消(退号) |
||||
* @param string $visit_no 挂号流水号 |
||||
* @param string $order_id 终端号(订单号) |
||||
* @param string $bank_tran_date 银行交易日期(格式:yyyy-mm-dd) |
||||
* @param string $bank_tran_time 银行交易时间(格式:hh24:mi:ss) |
||||
* @param string $bank_tran_amt 银行交易金额 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function refundRegister( |
||||
string $visit_no, |
||||
string $order_id, |
||||
string $bank_tran_date, |
||||
string $bank_tran_time, |
||||
string $bank_tran_amt |
||||
): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'GHCancelConfirm', [ |
||||
'json' => [ |
||||
'visitNo' => $visit_no, |
||||
'orderID' => $order_id, |
||||
'bankTranDate' => $bank_tran_date, |
||||
'bankTranTime' => $bank_tran_time, |
||||
'bankTranAmt' => $bank_tran_amt, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
// Registration Module End |
||||
|
||||
// Outpatient Module Start |
||||
|
||||
/** |
||||
* 获取待缴费列表 |
||||
* @param string $patient_id |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getPendingLists(string $patient_id): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'ListVisitRec ', [ |
||||
'patientID' => $patient_id, |
||||
'registerArea' => '', |
||||
... $this->commonRequestData() |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 查询就诊记录中的所有诊疗单据 |
||||
* @param string $cf_ids 处方号,多个处方号使用逗号分隔 |
||||
* @param string $jz_xh 就诊序号,必填 |
||||
* @param string $reg_id 号源编码,可选 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getPendingDetails( |
||||
string $cf_ids, |
||||
string $jz_xh, |
||||
string $reg_id = '' |
||||
): mixed |
||||
{ |
||||
// 调用请求处理方法 |
||||
return $this->requestHandle('POST', 'ListRecipe', [ |
||||
'json' => [ |
||||
'cfid' => $cf_ids, |
||||
'jzxh' => $jz_xh, |
||||
'regID' => $reg_id, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 获取门诊费用清单列表 |
||||
* @param string $patient_id 患者ID,必填 |
||||
* @param string $begin_date 开始日期,默认为当天(格式:yyyy-mm-dd) |
||||
* @param string $end_date 结束日期,默认为当天(格式:yyyy-mm-dd) |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getPaidLists( |
||||
string $patient_id, |
||||
string $begin_date = '', // 可为空,默认为当天 |
||||
string $end_date = '' // 可为空,默认为当天 |
||||
): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'OutpatientExpenseRecord', [ |
||||
'json' => [ |
||||
'patientID' => $patient_id, |
||||
'beginDate' => $begin_date, |
||||
'endDate' => $end_date, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 获取门诊费用清单详情 |
||||
* @param string $receipt_id |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getPaidDetails(string $receipt_id): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'OutpatientDetailRecord', [ |
||||
'json' => [ |
||||
'reptid' => $receipt_id, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
// Outpatient Module End |
||||
|
||||
// Electron Module Start |
||||
|
||||
|
||||
/** |
||||
* 主动调用接口生成电子发票 |
||||
* @param string $trea_id 就诊编码(结算序号) |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function createElectronInvoice(string $trea_id) |
||||
{ |
||||
return $this->requestHandle('POST', 'CreateOutpatientinvoiceEBill', [ |
||||
'json' => [ |
||||
'treaid' => $trea_id, |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 发送电子票据信息给his |
||||
* @param string $treat_id 就诊编码(结算序号),必填 |
||||
* @param string $bill_batch_code 电子票据代码,必填 |
||||
* @param string $bill_no 电子票据号码,必填 |
||||
* @param string $random 电子校验码,必填 |
||||
* @param string $create_time 电子票据生成时间,格式:YYYYMMDDHHMMSSSSS,必填 |
||||
* @param string $bill_qr_code 电子票据二维码图片数据(BASE64编码),必填 |
||||
* @param string $picture_url 电子票据H5页面URL,必填 |
||||
* @param string $picture_net_url 电子票据外网H5页面URL,必填 |
||||
* @param string $wx_card_url 微信插卡URL,必填 |
||||
* @param string $bus_no 业务流水号(机构内部唯一),必填 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function sendElectronInvoiceToHis( |
||||
string $treat_id, |
||||
string $bill_batch_code, |
||||
string $bill_no, |
||||
string $random, |
||||
string $create_time, |
||||
string $bill_qr_code, |
||||
string $picture_url, |
||||
string $picture_net_url, |
||||
string $wx_card_url, |
||||
string $bus_no |
||||
): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'SendOutpatientinvoiceEBill', [ |
||||
'TREAID' => $treat_id, |
||||
'BILLBATCHCODE' => $bill_batch_code, |
||||
'BILLNO' => $bill_no, |
||||
'RANDOM' => $random, |
||||
'CREATETIME' => $create_time, |
||||
'BILLQRCODE' => $bill_qr_code, |
||||
'PICTUREURL' => $picture_url, |
||||
'PICTURENETURL' => $picture_net_url, |
||||
'WXCARDURL' => $wx_card_url, |
||||
'BUSNO' => $bus_no |
||||
]); |
||||
} |
||||
|
||||
// Electron Module End |
||||
|
||||
// Dictionary Module Start |
||||
|
||||
/** |
||||
* 获取收费项目类别列表 |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getDictionaryLists(): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'GetDictionary', [ |
||||
... $this->commonRequestData() |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 获取收费项目详情 |
||||
* @param int $type_id 类别ID |
||||
* @return mixed |
||||
* @throws GeneralException |
||||
*/ |
||||
public function getDictionaryDetails(int $type_id): mixed |
||||
{ |
||||
return $this->requestHandle('POST', 'GetChargeList', [ |
||||
'json' => [ |
||||
'typeId' => $type_id, |
||||
'consumeName' => '', |
||||
... $this->commonRequestData() |
||||
] |
||||
]); |
||||
} |
||||
|
||||
// Dictionary Module End |
||||
} |
@ -0,0 +1,25 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Utils\Transfer\HisHttpClient; |
||||
|
||||
use App\Utils\Transfer\HttpTransferAbstract; |
||||
|
||||
class ClientFactory |
||||
{ |
||||
|
||||
/** |
||||
* Get Client Transfer Class |
||||
* @param string $name |
||||
* @return HttpTransferAbstract |
||||
*/ |
||||
public static function getClientTransfer(string $name): HttpTransferAbstract |
||||
{ |
||||
$is_mock = config('hisservice.'. $name. '.is_mock'); |
||||
|
||||
return match ($is_mock) { |
||||
false => new ClientHttpTransfer($name), |
||||
true => new ClientMockHttpTransfer($name), |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Utils\Transfer\HisHttpClient; |
||||
|
||||
use App\Utils\Transfer\HttpTransferAbstract; |
||||
use Exception; |
||||
use JsonException; |
||||
|
||||
class ClientHttpTransfer extends HttpTransferAbstract |
||||
{ |
||||
|
||||
/** |
||||
* MediWayTransfer Construct |
||||
* @param string $his_name |
||||
*/ |
||||
public function __construct(string $his_name = "") |
||||
{ |
||||
parent::__construct($his_name); |
||||
} |
||||
|
||||
/** |
||||
* 初始化 |
||||
*/ |
||||
public function initialize(): void |
||||
{ |
||||
parent::initialize(); |
||||
} |
||||
|
||||
/** |
||||
* 设置客户端选项 |
||||
* @return array |
||||
*/ |
||||
public function ClientHeaders(): array |
||||
{ |
||||
return []; |
||||
} |
||||
|
||||
/** |
||||
* 响应格式化 |
||||
* @param mixed $data |
||||
* @return mixed |
||||
*/ |
||||
public function responseFormat(mixed $data): mixed |
||||
{ |
||||
try { |
||||
return json_decode($data, true, JSON_THROW_ON_ERROR); |
||||
} catch (JsonException|Exception $e) { |
||||
return [ |
||||
'status' => 200, |
||||
'success' => false, |
||||
'msg' => '解析JSON失败', |
||||
'msgDev' => $e->getMessage(), |
||||
'response' => $data |
||||
]; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,271 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Utils\Transfer\HisHttpClient; |
||||
|
||||
use App\Exceptions\GeneralException; |
||||
use App\Utils\Transfer\HttpTransferAbstract; |
||||
use App\Utils\Transfer\SoapTransferAbstract; |
||||
use Exception; |
||||
|
||||
class ClientMockHttpTransfer extends HttpTransferAbstract |
||||
{ |
||||
/** |
||||
* ClientMockTransfer Construct |
||||
* @param string $his_name |
||||
*/ |
||||
public function __construct(string $his_name = "") |
||||
{ |
||||
parent::__construct($his_name); |
||||
} |
||||
|
||||
/** |
||||
* 设置客户端选项 |
||||
* @return array |
||||
*/ |
||||
public function clientHeaders(): array |
||||
{ |
||||
return []; |
||||
} |
||||
|
||||
/** |
||||
* @param string $class_name |
||||
* @return $this |
||||
*/ |
||||
public function transferClass(string $class_name): static |
||||
{ |
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* @throws GeneralException |
||||
*/ |
||||
public function transferMethod(string $method_name, array $request_data = []): self |
||||
{ |
||||
// 使用 match 替代 switch |
||||
return match ($method_name) { |
||||
'CreateCardPatInfo' => $this->mockRegisterCard($request_data), |
||||
'GetCardInfo' => $this->mockGetPatientInfo($request_data), |
||||
'GetDepType' => $this->mockGetDepLists($request_data), |
||||
'GetDoctList' => $this->mockGetDoctorLists($request_data), |
||||
'GetGHMXList' => $this->mockGetRegisterRecordLists($request_data), |
||||
'GHCancelCheck' => $this->mockCheckRefundRegisterStatus($request_data), |
||||
'GHCancelConfirm' => $this->mockRefundRegister($request_data), |
||||
'ListVisitRec' => $this->mockGetPendingLists($request_data), |
||||
'ListRecipe' => $this->mockGetPendingDetails($request_data), |
||||
'OutpatientExpenseRecord' => $this->mockGetPaidLists($request_data), |
||||
'OutpatientDetailRecord' => $this->mockGetPaidDetails($request_data), |
||||
'CreateOutpatientinvoiceEBill' => $this->mockCreateElectronInvoice($request_data), |
||||
'SendOutpatientinvoiceEBill' => $this->mockSendElectronInvoiceToHis($request_data), |
||||
'GetDictionary' => $this->mockGetDictionaryLists($request_data), |
||||
'GetChargeList' => $this->mockGetChargeList($request_data), |
||||
default => throw new GeneralException("Method '{$method_name}' not found"), |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 响应格式化 |
||||
* @param mixed $data |
||||
* @return mixed |
||||
* @throws Exception |
||||
*/ |
||||
public function responseFormat(mixed $data): mixed |
||||
{ |
||||
try { |
||||
// 此处为json格式 |
||||
return json_decode((string)$data, true); |
||||
} catch (Exception $e) { |
||||
throw new Exception($e->getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取返回值 |
||||
* @param bool $is_format |
||||
* @return mixed |
||||
* @throws Exception |
||||
*/ |
||||
public function getResult(bool $is_format = true): mixed |
||||
{ |
||||
return $this->responseFormat($this->transfer_response); |
||||
} |
||||
|
||||
/** |
||||
* mockRegisterCard |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockRegisterCard(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>建卡成功</ERRORMSG><PATIENTID></PATIENTID></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockGetPatientInfo |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetPatientInfo(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG></ERRORMSG><PATIENTID>1104468</PATIENTID><CARDNO>452323193712153735</CARDNO><NAME>唐超积</NAME><SEX>1</SEX><BIRTHDAY>1937-12-15</BIRTHDAY><CARDSTATUS>0</CARDSTATUS><BRXZ>123</BRXZ><MZHM>299811204468</MZHM></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockGetDepLists |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetDepLists(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>Success</ERRORMSG><ITEM><DEPID>12345</DEPID><YBDEPID>67890</YBDEPID><DEPNAME>内科</DEPNAME><FEE>50.00</FEE><FEECODE>001</FEECODE><YSCOUNT>5</YSCOUNT><JZCOUNT>3</JZCOUNT><REGISTERAREA>1</REGISTERAREA><INTRODUCE>内科专注于诊治呼吸、消化、心血管等系统疾病。</INTRODUCE><KSGHXE>5</KSGHXE><KSYGRS>20</KSYGRS><KSKGRS>10</KSKGRS><YSGHXE>10</YSGHXE><YSYGRS>15</YSYGRS><YSKGRS>25</YSKGRS><KYYYSCOUNT>2</KYYYSCOUNT></ITEM><ITEM><DEPID>23456</DEPID><YBDEPID>78901</YBDEPID><DEPNAME>外科</DEPNAME><FEE>60.00</FEE><FEECODE>002</FEECODE><YSCOUNT>8</YSCOUNT><JZCOUNT>4</JZCOUNT><REGISTERAREA>2</REGISTERAREA><INTRODUCE>外科提供专业的手术治疗服务,包括创伤、整形及器官移植。</INTRODUCE><KSGHXE>6</KSGHXE><KSYGRS>30</KSYGRS><KSKGRS>15</KSKGRS><YSGHXE>12</YSGHXE><YSYGRS>20</YSYGRS><YSKGRS>30</YSKGRS><KYYYSCOUNT>3</KYYYSCOUNT></ITEM><ITEM><DEPID>34567</DEPID><YBDEPID>89012</YBDEPID><DEPNAME>儿科</DEPNAME><FEE>40.00</FEE><FEECODE>003</FEECODE><YSCOUNT>6</YSCOUNT><JZCOUNT>2</JZCOUNT><REGISTERAREA>1</REGISTERAREA><INTRODUCE>儿科为0-18岁儿童提供专业的诊疗与健康管理服务。</INTRODUCE><KSGHXE>4</KSGHXE><KSYGRS>25</KSYGRS><KSKGRS>8</KSKGRS><YSGHXE>8</YSGHXE><YSYGRS>10</YSYGRS><YSKGRS>18</YSKGRS><KYYYSCOUNT>4</KYYYSCOUNT></ITEM><ITEM><DEPID>45678</DEPID><YBDEPID>90123</YBDEPID><DEPNAME>皮肤科</DEPNAME><FEE>30.00</FEE><FEECODE>004</FEECODE><YSCOUNT>4</YSCOUNT><JZCOUNT>1</JZCOUNT><REGISTERAREA>1</REGISTERAREA><INTRODUCE>皮肤科诊治常见皮肤病、性病及皮肤美容问题。</INTRODUCE><KSGHXE>3</KSGHXE><KSYGRS>15</KSYGRS><KSKGRS>7</KSKGRS><YSGHXE>6</YSGHXE><YSYGRS>5</YSYGRS><YSKGRS>11</YSKGRS><KYYYSCOUNT>1</KYYYSCOUNT></ITEM></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockGetDoctorLists |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetDoctorLists(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>Success</ERRORMSG><ITEM><DOCTID>10001</DOCTID><YBDOCTID>20001</YBDOCTID><DOCTNAME>张三</DOCTNAME><DEPLOCATION>内科一诊室</DEPLOCATION><TYPENAME>主任医师</TYPENAME><ISKSDOC>1</ISKSDOC><SHIFT><DOCTID>10001</DOCTID><REGID>30001</REGID><FDATE>2024-12-27</FDATE><RANKID>1</RANKID><RANKNAME>上午班</RANKNAME><STARTTIME>08:00</STARTTIME><ENDTIME>12:00</ENDTIME><FEE>50.00</FEE><FEECODE>001</FEECODE><REGCOUNT>20</REGCOUNT><JZCOUNT>15</JZCOUNT></SHIFT><SHIFT><DOCTID>10001</DOCTID><REGID>30002</REGID><FDATE>2024-12-28</FDATE><RANKID>2</RANKID><RANKNAME>下午班</RANKNAME><STARTTIME>14:00</STARTTIME><ENDTIME>18:00</ENDTIME><FEE>55.00</FEE><FEECODE>002</FEECODE><REGCOUNT>18</REGCOUNT><JZCOUNT>12</JZCOUNT></SHIFT><SHIFT><DOCTID>10001</DOCTID><REGID>30003</REGID><FDATE>2024-12-29</FDATE><RANKID>3</RANKID><RANKNAME>夜班</RANKNAME><STARTTIME>20:00</STARTTIME><ENDTIME>00:00</ENDTIME><FEE>60.00</FEE><FEECODE>003</FEECODE><REGCOUNT>10</REGCOUNT><JZCOUNT>8</JZCOUNT></SHIFT><XMBH>XM001</XMBH><GJMLBM>1234567890</GJMLBM><XMMC>挂号诊查费</XMMC><JG>50</JG><MCYL>10</MCYL><JE>500</JE></ITEM><ITEM><DOCTID>10002</DOCTID><YBDOCTID>20002</YBDOCTID><DOCTNAME>李四</DOCTNAME><DEPLOCATION>外科二诊室</DEPLOCATION><TYPENAME>副主任医师</TYPENAME><ISKSDOC>0</ISKSDOC><SHIFT><DOCTID>10002</DOCTID><REGID>30004</REGID><FDATE>2024-12-27</FDATE><RANKID>1</RANKID><RANKNAME>上午班</RANKNAME><STARTTIME>08:00</STARTTIME><ENDTIME>12:00</ENDTIME><FEE>60.00</FEE><FEECODE>004</FEECODE><REGCOUNT>25</REGCOUNT><JZCOUNT>20</JZCOUNT></SHIFT><SHIFT><DOCTID>10002</DOCTID><REGID>30005</REGID><FDATE>2024-12-28</FDATE><RANKID>2</RANKID><RANKNAME>下午班</RANKNAME><STARTTIME>14:00</STARTTIME><ENDTIME>18:00</ENDTIME><FEE>65.00</FEE><FEECODE>005</FEECODE><REGCOUNT>20</REGCOUNT><JZCOUNT>18</JZCOUNT></SHIFT><XMBH>XM002</XMBH><GJMLBM>0987654321</GJMLBM><XMMC>挂号诊查费</XMMC><JG>100</JG><MCYL>15</MCYL><JE>1500</JE></ITEM></RESPONSE> |
||||
'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockGetRegisterRecordLists |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetRegisterRecordLists(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>成功</ERRORMSG><ITEM><VISITNO>3405227</VISITNO><FTYPE>当天挂号</FTYPE><STATUS>0</STATUS><WAITNUM>143</WAITNUM><TREAID>600240002968</TREAID><GHDATE>2021-07-17</GHDATE><PATIENTID>1103903</PATIENTID><PATIENTNAME>杨尧</PATIENTNAME><RANKID>2</RANKID><RANKNAME>下午</RANKNAME><OPPATNO>600005001000</OPPATNO><DEPLOCATION>门诊一楼</DEPLOCATION><TRANSNUM>0</TRANSNUM><ORDERTYPE>线上预约</ORDERTYPE><PAYFEE>17</PAYFEE><DEPID>16</DEPID><DEPNAME>急诊科</DEPNAME></ITEM><ITEM><VISITNO>3405228</VISITNO><FTYPE>预约挂号</FTYPE><STATUS>1</STATUS><WAITNUM>58</WAITNUM><TREAID>600240002969</TREAID><GHDATE>2021-07-18</GHDATE><PATIENTID>1103904</PATIENTID><PATIENTNAME>李梅</PATIENTNAME><RANKID>1</RANKID><RANKNAME>上午</RANKNAME><OPPATNO>600005001001</OPPATNO><DEPLOCATION>门诊二楼</DEPLOCATION><TRANSNUM>1</TRANSNUM><ORDERTYPE>现场挂号</ORDERTYPE><PAYFEE>25</PAYFEE><DEPID>20</DEPID><DEPNAME>内科</DEPNAME></ITEM><ITEM><VISITNO>3405229</VISITNO><FTYPE>当天挂号</FTYPE><STATUS>0</STATUS><WAITNUM>23</WAITNUM><TREAID>600240002970</TREAID><GHDATE>2021-07-19</GHDATE><PATIENTID>1103905</PATIENTID><PATIENTNAME>张强</PATIENTNAME><RANKID>3</RANKID><RANKNAME>夜间</RANKNAME><OPPATNO>600005001002</OPPATNO><DEPLOCATION>急诊大厅</DEPLOCATION><TRANSNUM>2</TRANSNUM><ORDERTYPE>电话预约</ORDERTYPE><PAYFEE>30</PAYFEE><DEPID>18</DEPID><DEPNAME>儿科</DEPNAME></ITEM><ITEM><VISITNO>3405230</VISITNO><FTYPE>预约挂号</FTYPE><STATUS>1</STATUS><WAITNUM>78</WAITNUM><TREAID>600240002971</TREAID><GHDATE>2021-07-20</GHDATE><PATIENTID>1103906</PATIENTID><PATIENTNAME>王丽</PATIENTNAME><RANKID>1</RANKID><RANKNAME>上午</RANKNAME><OPPATNO>600005001003</OPPATNO><DEPLOCATION>门诊三楼</DEPLOCATION><TRANSNUM>0</TRANSNUM><ORDERTYPE>线上预约</ORDERTYPE><PAYFEE>45</PAYFEE><DEPID>22</DEPID><DEPNAME>眼科</DEPNAME></ITEM></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockCheckRefundRegisterStatus |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockCheckRefundRegisterStatus(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>可退号</ERRORMSG></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockRefundRegister |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockRefundRegister(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>退号成功</ERRORMSG></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
private function mockGetPendingLists(array $params) |
||||
{ |
||||
return [ |
||||
'status' => 'success', |
||||
'message' => 'Pending list retrieved successfully.', |
||||
'data' => [ |
||||
[ |
||||
'visit_no' => '12345', |
||||
'patient_id' => $params['PATIENTID'], |
||||
'amount' => '100.00' |
||||
] |
||||
] |
||||
]; |
||||
} |
||||
|
||||
private function mockGetPendingDetails(array $params) |
||||
{ |
||||
return [ |
||||
'status' => 'success', |
||||
'message' => 'Pending details retrieved successfully.', |
||||
'data' => [ |
||||
'cf_ids' => $params['CFID'], |
||||
'jz_xh' => $params['JZXH'], |
||||
'details' => 'Detailed description of the treatment.' |
||||
] |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* mockGetPaidLists |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetPaidLists(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG></ERRORMSG><RECORD><PATIENTID>D00589351</PATIENTID><NAME>叶子璐</NAME><SEX>女</SEX><CHARGETYPE>自费</CHARGETYPE><VISITDATE>2012-08-21</VISITDATE><RCPTID>1111</RCPTID><RCPTNO >9-0001</RCPTNO><COSTS>251.59</COSTS><COSTS>251.59</COSTS><GRZF>251.59</GRZF><JJZF>0</JJZF><ISPRINTED>0</ISPRINTED></RECORD><RECORD><PATIENTID>D00589351</PATIENTID><NAME>叶子璐</NAME><SEX>女</SEX><CHARGETYPE>自费</CHARGETYPE><VISITDATE>2012-08-21</VISITDATE><RCPTID>1111</RCPTID><RCPTNO >9-0001</RCPTNO><COSTS>251.59</COSTS><COSTS>251.59</COSTS><GRZF>251.59</GRZF><JJZF>0</JJZF><ISPRINTED>0</ISPRINTED></RECORD></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockGetPaidDetails |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetPaidDetails(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG></ERRORMSG><JSRQ>2021-07-1715:22:31</JSRQ><TREAID>3324497</TREAID><HOSTRANNO>0000986299</HOSTRANNO><COSTS>65.9</COSTS><GRZF>65.9</GRZF><JJZF></JJZF><PHYADDRESS>智能药房</PHYADDRESS><DEPNAME>急诊科</DEPNAME><DOCTNAME>梁锦胜</DOCTNAME><CYZD>1.慢性喘息性支气管炎急性发作</CYZD><CZGH>818</CZGH><RECORD><ITEMREC><VISITDATE>2021-07-1715:13:32</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>0.9%氯化钠注射液</ITEMNAME><ITEMSPEC>100ML</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>2.42</PRICE><COSTS>2.42</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>ML</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B002</YPBM><YJBM>86902763001266</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:14:45</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>复方甘草酸苷片</ITEMNAME><ITEMSPEC>20mg</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>15.50</PRICE><COSTS>15.50</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>片</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B003</YPBM><YJBM>86902763001267</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:15:02</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>头孢克肟胶囊</ITEMNAME><ITEMSPEC>250mg</ITEMSPEC><UNITS>盒</UNITS><AMOUNT>1</AMOUNT><PRICE>18.30</PRICE><COSTS>18.30</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>粒</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B004</YPBM><YJBM>86902763001268</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:16:10</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>氯氮平片</ITEMNAME><ITEMSPEC>25mg</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>22.00</PRICE><COSTS>22.00</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>片</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B005</YPBM><YJBM>86902763001269</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:17:25</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>安定片</ITEMNAME><ITEMSPEC>5mg</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>13.40</PRICE><COSTS>13.40</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>片</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B006</YPBM><YJBM>86902763001270</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:18:42</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>阿莫西林胶囊</ITEMNAME><ITEMSPEC>500mg</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>8.00</PRICE><COSTS>8.00</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>粒</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B007</YPBM><YJBM>86902763001271</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:19:10</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>双氯芬酸钠胶囊</ITEMNAME><ITEMSPEC>50mg</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>16.80</PRICE><COSTS>16.80</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>粒</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B008</YPBM><YJBM>86902763001272</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:19:45</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>利血平片</ITEMNAME><ITEMSPEC>25mg</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>12.30</PRICE><COSTS>12.30</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>片</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B009</YPBM><YJBM>86902763001273</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC><ITEMREC><VISITDATE>2021-07-1715:20:10</VISITDATE><CLASSNAME>西药费</CLASSNAME><ITEMNAME>依普利酮片</ITEMNAME><ITEMSPEC>25mg</ITEMSPEC><UNITS>瓶</UNITS><AMOUNT>1</AMOUNT><PRICE>30.00</PRICE><COSTS>30.00</COSTS><ZTMC></ZTMC><YCJL>100</YCJL><JLDW>片</JLDW><YYTS>1</YYTS><MRCS>1</MRCS><PCMC>QD</PCMC><YPBM>X-B05XA-L211-B010</YPBM><YJBM>86902763001274</YJBM><YBFL>甲类</YBFL><YGXM>梁锦胜</YGXM></ITEMREC></RECORD></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
private function mockCreateElectronInvoice(array $params) |
||||
{ |
||||
return [ |
||||
'status' => 'success', |
||||
'message' => 'Electron invoice created successfully.', |
||||
'data' => $params |
||||
]; |
||||
} |
||||
|
||||
private function mockSendElectronInvoiceToHis(array $params) |
||||
{ |
||||
return [ |
||||
'status' => 'success', |
||||
'message' => 'Electron invoice sent successfully.', |
||||
'data' => $params |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* mockGetDictionaryLists |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetDictionaryLists(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG></ERRORMSG><ITEM><TYPEID>1</TYPEID><TYPENAME>手术费</TYPENAME></ITEM><ITEM><TYPEID>2</TYPEID><TYPENAME>治疗费</TYPENAME></ITEM><ITEM><TYPEID>3</TYPEID><TYPENAME>中药费</TYPENAME></ITEM><ITEM><TYPEID>4</TYPEID><TYPENAME>西药费</TYPENAME></ITEM><ITEM><TYPEID>5</TYPEID><TYPENAME>检查费</TYPENAME></ITEM><ITEM><TYPEID>6</TYPEID><TYPENAME>诊查费</TYPENAME></ITEM><ITEM><TYPEID>7</TYPEID><TYPENAME>护理费</TYPENAME></ITEM></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* mockGetChargeList |
||||
* @param array $params |
||||
* @return self |
||||
*/ |
||||
private function mockGetChargeList(array $params): self |
||||
{ |
||||
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG></ERRORMSG><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>苯巴比妥片</COSTNAME><UNIT>片</UNIT><COSTSPEC>30MG</COSTSPEC><CDNAME>上海信谊药厂</CDNAME><PRICE>0.097</PRICE><REMARK></REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>阿莫西林胶囊</COSTNAME><UNIT>粒</UNIT><COSTSPEC>500MG</COSTSPEC><CDNAME>华北制药厂</CDNAME><PRICE>0.12</PRICE><REMARK>用于治疗细菌感染</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>复方氯噻吨片</COSTNAME><UNIT>片</UNIT><COSTSPEC>0.25G</COSTSPEC><CDNAME>长春药业</CDNAME><PRICE>0.15</PRICE><REMARK>缓解高血压症状</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>洛伐他汀片</COSTNAME><UNIT>片</UNIT><COSTSPEC>20MG</COSTSPEC><CDNAME>中科院制药</CDNAME><PRICE>0.25</PRICE><REMARK>降低血脂</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>维生素C片</COSTNAME><UNIT>片</UNIT><COSTSPEC>500MG</COSTSPEC><CDNAME>美国善格</CDNAME><PRICE>0.05</PRICE><REMARK>增强免疫力</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>布洛芬片</COSTNAME><UNIT>片</UNIT><COSTSPEC>200MG</COSTSPEC><CDNAME>华药集团</CDNAME><PRICE>0.1</PRICE><REMARK>缓解轻度疼痛</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>氯氮平片</COSTNAME><UNIT>片</UNIT><COSTSPEC>25MG</COSTSPEC><CDNAME>南京医药</CDNAME><PRICE>0.3</PRICE><REMARK>用于治疗精神分裂症</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>头孢克肟胶囊</COSTNAME><UNIT>粒</UNIT><COSTSPEC>500MG</COSTSPEC><CDNAME>石药集团</CDNAME><PRICE>0.18</PRICE><REMARK>抗菌药物</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>硝苯地平片</COSTNAME><UNIT>片</UNIT><COSTSPEC>10MG</COSTSPEC><CDNAME>国药集团</CDNAME><PRICE>0.2</PRICE><REMARK>用于治疗高血压</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>美托洛尔片</COSTNAME><UNIT>片</UNIT><COSTSPEC>25MG</COSTSPEC><CDNAME>拜耳制药</CDNAME><PRICE>0.22</PRICE><REMARK>用于治疗心脏病</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>甲硝唑片</COSTNAME><UNIT>片</UNIT><COSTSPEC>250MG</COSTSPEC><CDNAME>南京同仁堂</CDNAME><PRICE>0.12</PRICE><REMARK>用于治疗感染</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>阿托伐他汀片</COSTNAME><UNIT>片</UNIT><COSTSPEC>10MG</COSTSPEC><CDNAME>默沙东</CDNAME><PRICE>0.3</PRICE><REMARK>调节血脂</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>硫酸氢氯噻吨片</COSTNAME><UNIT>片</UNIT><COSTSPEC>12.5MG</COSTSPEC><CDNAME>齐鲁制药</CDNAME><PRICE>0.15</PRICE><REMARK>用于治疗水肿</REMARK></ITEM><ITEM><TYPENAME>西药费</TYPENAME><COSTNAME>兰索拉唑胶囊</COSTNAME><UNIT>粒</UNIT><COSTSPEC>30MG</COSTSPEC><CDNAME>百时美施贵宝</CDNAME><PRICE>0.18</PRICE><REMARK>治疗胃酸过多</REMARK></ITEM></RESPONSE>'; |
||||
|
||||
return $this; |
||||
} |
||||
} |
@ -1,24 +0,0 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Utils\Transfer\HisSoap; |
||||
use App\Utils\Transfer\TransferAbstract; |
||||
|
||||
class ClientFactory |
||||
{ |
||||
|
||||
/** |
||||
* Get Client Transfer Class |
||||
* @param string $name |
||||
* @return TransferAbstract |
||||
*/ |
||||
public static function getClientTransfer(string $name): TransferAbstract |
||||
{ |
||||
$is_mock = config('hisservice.'. $name. '.is_mock'); |
||||
|
||||
return match ($is_mock) { |
||||
false => new ClientTransfer($name), |
||||
true => new ClientMockTransfer($name), |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Utils\Transfer\HisSoapClient; |
||||
use App\Utils\Transfer\SoapTransferAbstract; |
||||
|
||||
class ClientFactory |
||||
{ |
||||
|
||||
/** |
||||
* Get Client Transfer Class |
||||
* @param string $name |
||||
* @return SoapTransferAbstract |
||||
*/ |
||||
public static function getClientTransfer(string $name): SoapTransferAbstract |
||||
{ |
||||
$is_mock = config('hisservice.'. $name. '.is_mock'); |
||||
|
||||
return match ($is_mock) { |
||||
false => new ClientSoapTransfer($name), |
||||
true => new ClientMockSoapTransfer($name), |
||||
}; |
||||
} |
||||
} |
@ -1,13 +1,13 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Utils\Transfer\HisSoap; |
||||
namespace App\Utils\Transfer\HisSoapClient; |
||||
|
||||
use App\Utils\Transfer\TransferAbstract; |
||||
use App\Utils\Transfer\SoapTransferAbstract; |
||||
use Exception; |
||||
use WsdlToPhp\PackageBase\SoapClientInterface; |
||||
|
||||
class ClientTransfer extends TransferAbstract |
||||
class ClientSoapTransfer extends SoapTransferAbstract |
||||
{ |
||||
|
||||
/** |
@ -0,0 +1,196 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Utils\Transfer; |
||||
|
||||
use Exception; |
||||
use GuzzleHttp\Exception\GuzzleException; |
||||
use Illuminate\Support\Facades\Config; |
||||
use GuzzleHttp\Client; |
||||
use Psr\Http\Message\ResponseInterface; |
||||
|
||||
abstract class HttpTransferAbstract |
||||
{ |
||||
// HTTP 客户端 |
||||
private Client $client; |
||||
|
||||
// His接口配置数据 |
||||
private array $his_config; |
||||
|
||||
// 调用方法 |
||||
public string $transfer_method; |
||||
|
||||
// 调用接口名称 |
||||
public string $transfer_name; |
||||
|
||||
// 调用接口参数 |
||||
public mixed $transfer_parameter; |
||||
|
||||
// 调用返回结果 |
||||
public ResponseInterface $transfer_response; |
||||
|
||||
// 运行时间 |
||||
public array $request_time; |
||||
|
||||
/** |
||||
* HttpTransferAbstract constructor. |
||||
* @param string $his_name |
||||
*/ |
||||
public function __construct(string $his_name) |
||||
{ |
||||
$config = Config::get('hisservice.'. $his_name); |
||||
|
||||
// 获取配置文件中的接口配置信息 |
||||
$this->his_config = $config; |
||||
$this->his_config['his_name'] = $his_name; |
||||
|
||||
$this->initialize(); |
||||
} |
||||
|
||||
/** |
||||
* 初始化 |
||||
*/ |
||||
public function initialize(): void |
||||
{ |
||||
$headers = $this->clientHeaders(); |
||||
$this->client = new Client([ |
||||
'base_uri' => $this->his_config['url'], |
||||
'headers' => $headers, |
||||
... $this->his_config['options'] |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 获取配置 |
||||
* @param string $key |
||||
* @return mixed|null |
||||
*/ |
||||
public function getHisConfigByKey(string $key): mixed |
||||
{ |
||||
if (isset($this->his_config[$key])) { |
||||
return $this->his_config[$key]; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* 设置客户端 Header 头 |
||||
* @return array |
||||
*/ |
||||
abstract public function clientHeaders(): array; |
||||
|
||||
/** |
||||
* 需要调用的方法 |
||||
* @param string $method |
||||
* @param string $request_name |
||||
* @param array $request_data |
||||
* @return $this |
||||
* @throws Exception |
||||
*/ |
||||
public function transferMethod(string $method, string $request_name, array $request_data = []): self |
||||
{ |
||||
// 记录调用的接口名称和参数 |
||||
$this->transfer_method = $method; |
||||
$this->transfer_name = $request_name; |
||||
$this->transfer_parameter = $request_data; |
||||
|
||||
try { |
||||
// 发送 HTTP 请求 |
||||
$this->request_time['start_time'] = microtime(true); |
||||
$this->transfer_response = $this->client->request($method, $this->transfer_name, $this->transfer_parameter); |
||||
$this->request_time['end_time'] = microtime(true); |
||||
} catch (GuzzleException|Exception $e) { |
||||
!isset($this->request_time['end_time']) && $this->request_time['end_time'] = microtime(true); |
||||
$this->recordLog(); |
||||
throw new Exception("{$e->getFile()}:{$e->getLine()}:{$e->getMessage()}"); |
||||
} |
||||
|
||||
// 记录日志 |
||||
$this->recordLog(); |
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 获取返回值 |
||||
* @param bool $is_format |
||||
* @return mixed |
||||
* @throws Exception |
||||
*/ |
||||
public function getResult(bool $is_format = true): mixed |
||||
{ |
||||
if ($is_format) { |
||||
return $this->responseFormat($this->transfer_response); |
||||
} |
||||
|
||||
return $this->transfer_response; |
||||
} |
||||
|
||||
/** |
||||
* 响应格式化 |
||||
* @param mixed $data |
||||
* @return mixed |
||||
*/ |
||||
abstract public function responseFormat(mixed $data): mixed; |
||||
|
||||
/** |
||||
* 魔术方法实现动态调用方法 |
||||
* @param $function |
||||
* @param $args |
||||
* @return $this |
||||
* @throws Exception |
||||
*/ |
||||
public function __call($function, $args): self |
||||
{ |
||||
if (method_exists($this, $function)) { |
||||
throw new Exception(__CLASS__ . '类的"'. $function .'"方法不存在'); |
||||
} |
||||
|
||||
$this->client = call_user_func($function, ...$args); |
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 记录日志 |
||||
*/ |
||||
public function recordLog(): void |
||||
{ |
||||
// 判断“是否设置日志参数”和“当前调用的方法是否记录到日志” |
||||
if (!empty($this->transfer_name)) { |
||||
$run_time = sprintf("%.6f", ($this->request_time['end_time'] - $this->request_time['start_time'])); |
||||
|
||||
if ( |
||||
empty($this->his_config['not_log_arr']) || |
||||
!in_array($this->transfer_name, $this->his_config['not_log_arr']) |
||||
) { |
||||
// 记录入参和结果 |
||||
$content = '[METHOD NAME] '. $this->transfer_method. '|'. $this->transfer_name. PHP_EOL. |
||||
'[REQUEST PARAM] '. json_encode($this->transfer_parameter, JSON_UNESCAPED_UNICODE). PHP_EOL. |
||||
'[RESPONSE PARAM] '. json_encode($this->transfer_response, JSON_UNESCAPED_UNICODE). PHP_EOL. |
||||
'[RUN TIME] '. $run_time . "/s"; |
||||
$this->recordRequestLog($this->his_config['his_name'], $content); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 保存日志记录 |
||||
* @param string $his_name |
||||
* @param string $content |
||||
*/ |
||||
protected function recordRequestLog(string $his_name, string $content): void |
||||
{ |
||||
date_default_timezone_set("Asia/Shanghai"); |
||||
|
||||
$dirname = $this->his_config['his_name']; |
||||
$path = app()->storagePath(). DIRECTORY_SEPARATOR. $dirname. DIRECTORY_SEPARATOR; |
||||
$file_path = $path. $his_name. 'Log'. DIRECTORY_SEPARATOR. date('Ym'). DIRECTORY_SEPARATOR; |
||||
$file_name = date('d'). ".log"; |
||||
|
||||
!is_dir($file_path) && mkdir($file_path, 0755, true); |
||||
|
||||
$msg = "[".date('Y-m-d H:i:s')."]". PHP_EOL . $content . PHP_EOL . PHP_EOL; |
||||
|
||||
file_put_contents( $file_path. $file_name, $msg, FILE_APPEND); |
||||
} |
||||
} |
@ -1,14 +1,28 @@ |
||||
<?php |
||||
|
||||
return [ |
||||
// HIS SOAP 服务 |
||||
'his_soap' => [ |
||||
'url' => '', |
||||
'location' => '', |
||||
'service_type_namespace' => 'HisSoapService\ServiceType\\', |
||||
'struct_type_namespace' => 'HisSoapService\StructType\\', |
||||
// 不记录日志的数组请求 |
||||
// 不记录日志的请求数组 |
||||
'not_log_arr' => [], |
||||
// 是否模拟数据 |
||||
'is_mock' => true, |
||||
], |
||||
// HIS API服务 -- 方鼎中间件转发 |
||||
'his_api' => [ |
||||
// 测试地址 |
||||
'url' => 'http://192.168.61.45:8809/api/WeChatDomain/', |
||||
// 不记录日志的请求数组 |
||||
'not_log_arr' => [''], |
||||
// 是否模拟数据 |
||||
'is_mock' => true, |
||||
// guzzle/client options |
||||
'options' => [ |
||||
'timeout' => 60 |
||||
] |
||||
] |
||||
]; |
||||
|
Loading…
Reference in new issue