You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
293 lines
9.8 KiB
293 lines
9.8 KiB
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\HisMedicalHttp;
|
|
|
|
use App\Dictionary\Medical\PatientProperty;
|
|
use App\Dictionary\Medical\PayType as MedicalPayType;
|
|
use App\Dictionary\Medical\SettleType;
|
|
use App\Exceptions\GeneralException;
|
|
use App\Utils\Traits\Logger;
|
|
use App\Utils\Transfer\HisMedicalHttpClient\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_medical_http';
|
|
$this->service = ClientFactory::getClientTransfer($his_name);
|
|
$this->setChannel($his_name);
|
|
}
|
|
|
|
/**
|
|
* 公共入参
|
|
* @return array
|
|
*/
|
|
protected function commonRequestData(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* 请求
|
|
* @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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 医保定点签约
|
|
* @param string $cert_type
|
|
* @param string $cert_no
|
|
* @return mixed
|
|
* @throws GeneralException
|
|
*/
|
|
public function medicalDesignated(string $cert_type, string $cert_no): mixed
|
|
{
|
|
// 调用请求处理方法
|
|
return $this->requestHandle('POST', 'HospRedesignated', [
|
|
'json' => [
|
|
'ApplicationId' => '',
|
|
'ApplicationSecret' => '',
|
|
'Parameter' => [
|
|
'mdtrt_cert_type' => $cert_type,
|
|
'mdtrt_cert_no' => $cert_no
|
|
]
|
|
]
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 挂号预结算
|
|
* @param string $patient_number 门诊号码
|
|
* @param string $patient_name 患者名称
|
|
* @param string $total_fee 挂号总金额
|
|
* @param string $fee_code 费用代码
|
|
* @param string $reg_id 挂号号源ID
|
|
* @param PatientProperty $patient_property 病人性质
|
|
* @param string $pay_auth_no 支付授权码
|
|
* @param string $lat_lnt 经纬度信息
|
|
* @return mixed
|
|
* @throws GeneralException
|
|
*/
|
|
public function registrationPreSettle(
|
|
string $patient_number,
|
|
string $patient_name,
|
|
string $total_fee,
|
|
string $fee_code,
|
|
string $reg_id,
|
|
PatientProperty $patient_property,
|
|
string $pay_auth_no,
|
|
string $lat_lnt,
|
|
): mixed
|
|
{
|
|
// 调用请求处理方法
|
|
return $this->requestHandle('POST', 'GetPrecalculatedFeeGh', [
|
|
'json' => [
|
|
'ApplicationId' => '',
|
|
'ApplicationSecret' => '',
|
|
'Parameter' => [
|
|
'PatientId' => $patient_number,
|
|
'PatientName' => $patient_name,
|
|
'TotalFee' => $total_fee,
|
|
'FeeCode' => $fee_code,
|
|
'RegId' => $reg_id,
|
|
'Brxz' => $patient_property->value,
|
|
'PayAuthNo' => $pay_auth_no,
|
|
'UldLatlnt' => $lat_lnt,
|
|
]
|
|
// 'hospitalId' => '',
|
|
// 'PatientId' => $patient_number,
|
|
// 'PatientName' => $patient_name,
|
|
// 'TotalFee' => '01',
|
|
// 'FeeCode' => $fee_code,
|
|
// 'RegId' => $reg_id,
|
|
// 'Brxz' => $patient_property,
|
|
// 'PayAuthNo' => $pay_auth_no,
|
|
// 'UldLatlnt' => $lat_lnt,
|
|
// ... $this->commonRequestData()
|
|
]
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 查询就诊记录中的所有诊疗单据
|
|
* @param string $patient_number 就诊卡号
|
|
* @param string $start_date 查询开始日期 yyyy-MM-dd
|
|
* @param string $end_date 查询结束日期 yyyy-MM-dd
|
|
* @return mixed
|
|
* @throws GeneralException
|
|
*/
|
|
public function getMedicalPendingLists(
|
|
string $patient_number,
|
|
string $start_date,
|
|
string $end_date
|
|
): mixed
|
|
{
|
|
// 调用请求处理方法
|
|
return $this->requestHandle('POST', 'GetUnpayedList', [
|
|
'json' => [
|
|
'ApplicationId' => '',
|
|
'ApplicationSecret' => '',
|
|
'Parameter' => [
|
|
'BeginDate' => $start_date,
|
|
'EndDate' => $end_date,
|
|
'CardType' => '01',
|
|
'CardId' => $patient_number
|
|
]
|
|
|
|
// 'hospitalId' => '',
|
|
// 'beginDate' => $start_date,
|
|
// 'endDate' => $end_date,
|
|
// 'cardType' => '01',
|
|
// 'cardId' => $patient_number,
|
|
// ... $this->commonRequestData()
|
|
]
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 门诊缴费预结算
|
|
* @param string $patient_number 门诊号码
|
|
* @param string $patient_name 患者名称
|
|
* @param string $pay_auth_no 支付授权码
|
|
* @param string $lat_lnt 经纬度信息
|
|
* @param SettleType $settle_type 结算类型(是否使用个账)
|
|
* @param MedicalPayType $pay_type 医保支付类型
|
|
* @param array $fee_records 处方数组集合 [0 => ["FeeNo"=>"", "FeeTypeCode"=>""], 1 => ...]
|
|
* @return mixed
|
|
* @throws GeneralException
|
|
*/
|
|
public function outpatientPreSettle(
|
|
string $patient_number,
|
|
string $patient_name,
|
|
string $pay_auth_no,
|
|
string $lat_lnt,
|
|
SettleType $settle_type,
|
|
MedicalPayType $pay_type,
|
|
array $fee_records
|
|
): mixed
|
|
{
|
|
// 调用请求处理方法
|
|
return $this->requestHandle('POST', 'GetPrecalculatedFee', [
|
|
'json' => [
|
|
'ApplicationId' => '',
|
|
'ApplicationSecret'=> '',
|
|
'Parameter'=> [
|
|
'HospitalId' => '',
|
|
'PatientId'=> $patient_number,
|
|
'PatientName'=> $patient_name,
|
|
'PayAuthNo'=> $pay_auth_no,
|
|
'UldLatlnt'=> $lat_lnt,
|
|
'IsInsSelfPay'=> $settle_type->value,
|
|
'YbPayType'=> $pay_type->value,
|
|
'FeeRecords'=> $fee_records
|
|
]
|
|
// 'hospitalId' => '',
|
|
// 'patientId' => $patient_number,
|
|
// 'patientName' => $patient_name,
|
|
// 'payAuthNo' => $pay_auth_no,
|
|
// 'uldLatlnt' => $lat_lnt,
|
|
// 'isInsSelfPay' => $settle_type->value,
|
|
// 'ybPayType' => $pay_type->value,
|
|
// 'payType' => '03',
|
|
// 'feeRecord' => $fee_records,
|
|
// ... $this->commonRequestData()
|
|
]
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 确认医保缴费
|
|
* @param string $patient_number 门诊号码
|
|
* @param string $patient_name 患者名称
|
|
* @param string $trade_no 订单唯一标识
|
|
* @param string $precal_id 预结算ID
|
|
* @param string $trade_date 支付时间 yyyy-MM-dd HH:mm:ss
|
|
* @param string $total_amount 总金额 单位元
|
|
* @param string $medicare_amount 统筹金额 单位元
|
|
* @param string $pay_amount 现金金额 单位元
|
|
* @param string $account_amount 个帐金额 单位元
|
|
* @param MedicalPayType $pay_type 医保支付类型
|
|
* @param array $fee_records 处方数组集合 [0 => ['FeeNo"=>"", "FeeTypeCode"=>""], 1 => ...]
|
|
* @return mixed
|
|
* @throws GeneralException
|
|
*/
|
|
public function confirmMedicalOutpatient(
|
|
string $patient_number,
|
|
string $patient_name,
|
|
string $trade_no,
|
|
string $precal_id,
|
|
string $trade_date,
|
|
string $total_amount,
|
|
string $medicare_amount,
|
|
string $pay_amount,
|
|
string $account_amount,
|
|
MedicalPayType $pay_type,
|
|
array $fee_records
|
|
): mixed
|
|
{
|
|
return $this->requestHandle('POST', 'NotifyPayed', [
|
|
'json' => [
|
|
'ApplicationId' => '',
|
|
'ApplicationSecret'=> '',
|
|
'Parameter'=> [
|
|
'HospitalId' => '',
|
|
'PatientId'=> $patient_number,
|
|
'PatientName'=> $patient_name,
|
|
'TradeNo' => $trade_no,
|
|
'PrecalId' => $precal_id,
|
|
'TradeDate' => $trade_date,
|
|
'TotalAmount' => $total_amount,
|
|
'MedicareAmount' => $medicare_amount,
|
|
'PayAmount' => $pay_amount,
|
|
'AccountAmount' => $account_amount,
|
|
'YbPayType' => $pay_type->value,
|
|
'PayType' => '03',
|
|
'FeeRecord' => $fee_records,
|
|
]
|
|
// 'hospitalId' => '',
|
|
// 'patientId' => $patient_number,
|
|
// 'patientName' => $patient_name,
|
|
// 'tradeNo' => $trade_no,
|
|
// 'precalId' => $precal_id,
|
|
// 'tradeDate' => $trade_date,
|
|
// 'totalAmount' => $total_amount,
|
|
// 'medicareAmount' => $medicare_amount,
|
|
// 'payAmount' => $pay_amount,
|
|
// 'accountAmount' => $account_amount,
|
|
// 'ybPayType' => $pay_type->value,
|
|
// 'payType' => '03',
|
|
// 'feeRecord' => $fee_records,
|
|
// ... $this->commonRequestData()
|
|
]
|
|
]);
|
|
}
|
|
}
|
|
|