香洲二院小程序
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.
 
 
 
mini_xzey/app/Services/HisSoap/Client.php

393 lines
13 KiB

<?php
declare(strict_types = 1);
namespace App\Services\HisSoap;
use App\Dictionary\Patient\CardType;
use App\Dictionary\Patient\Sex;
use App\Exceptions\GeneralException;
use App\Utils\Traits\Logger;
use App\Utils\Transfer\HisSoapClient\ClientFactory;
use App\Utils\Transfer\SoapTransferAbstract;
use Exception;
use Symfony\Component\HttpFoundation\Response;
class Client
{
use Logger;
private string $user_id = 'MINI';
// his服务
private SoapTransferAbstract $service;
public function __construct()
{
$his_name = 'his_soap';
$this->service = ClientFactory::getClientTransfer($his_name);
$this->setChannel($his_name);
}
/**
* 请求
* @param string $class_name
* @param string $method_name
* @param array $params
* @return mixed
* @throws GeneralException
*/
protected function requestHandle(string $class_name, string $method_name, array $params): mixed
{
try {
return $this->service->transferClass($class_name)
->transferMethod($method_name, array_values($params))
->getResult();
} catch (Exception $e) {
$err_msg = "{$e->getMessage()} ON {$e->getFile()}:{$e->getLine()}";
$this->error('调用soap接口失败, 错误消息:' . $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('Create', 'CreateCardPatInfo', [
'CARDNO' => $card_no,
'CARDTYPE' => $card_type->value,
'PATIENTNAME' => $patient_name,
'SEX' => $sex->value,
'BIRTHDAY' => $birthday,
'IDCARDNO' => $id_card_no,
'MOBILE' => $mobile,
'ADDRESS' => $address,
'USERID' => $this->user_id,
]);
}
/**
* 获取患者信息
* @param string $register_area 挂号区域(默认为 01)
* @param string $card_no 卡号
* @param CardType $card_type 卡类型
* @param string $name 姓名
* @return mixed
* @throws GeneralException
*/
public function getPatientInfo(string $register_area, string $card_no, CardType $card_type, string $name): mixed
{
// 默认挂号区域为 "01",如果提供了挂号区域,则使用提供的区域
$register_area = empty($register_area) ? '01' : $register_area;
// 调用请求处理方法
return $this->requestHandle('Get', 'GetCardInfo', [
'REGISTERAREA' => $register_area,
'CARDNO' => $card_no,
'CARDTYPE' => $card_type->value,
'NAME' => $name,
'USERID' => $this->user_id,
]);
}
// 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 getDepLists(
string $type_id,
string $type_name,
string $register_area = '01', // 默认挂号区域为 01
string $date = '', // 默认日期为空,表示查询所有科室
string $rank_id = '' // 默认班次为空,表示查询所有班次
): mixed {
// 调用请求处理方法
return $this->requestHandle('Get', 'GetDepType', [
'TYPEID' => $type_id,
'TYPENAME' => $type_name,
'REGISTERAREA' => $register_area,
'USERID' => $this->user_id,
'DATE' => $date,
'RANKID' => $rank_id,
]);
}
/**
* 查询医生排班信息
* @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('Get', 'GetDoctList', [
'DEPID' => $dept_id,
'ISTODAYREGIST' => $is_today,
'RANKID' => $rank_id,
'DATE' => $date,
'USERID' => $this->user_id,
]);
}
/**
* 查询挂号记录便于就诊
* @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('Get', 'GetGHMXList', [
'PATIENTID' => $patient_id,
'DATE' => $start_date,
'EDATE' => $end_date,
'TYPE' => $type,
'USERID' => $this->user_id,
]);
}
/**
* 检查挂号是否可以取消
* @param string $visit_no 挂号流水号
* @return mixed
* @throws GeneralException
*/
public function checkRefundRegisterStatus(string $visit_no): mixed
{
// 调用请求处理方法
return $this->requestHandle('GH', 'GHCancelCheck', [
'VISITNO' => $visit_no,
'USERID' => $this->user_id, // 假设用户 ID 来自当前实例
]);
}
/**
* 确认挂号取消(退号)
* @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('GH', 'GHCancelConfirm', [
'VISITNO' => $visit_no,
'ORDERID' => $order_id,
'BANKTRANDATE' => $bank_tran_date,
'BANKTRANTIME' => $bank_tran_time,
'BANKTRANAMT' => $bank_tran_amt,
'USERID' => $this->user_id,
]);
}
// Registration Module End
// Outpatient Module Start
/**
* 获取待缴费列表
* @param string $patient_id
* @return mixed
* @throws GeneralException
*/
public function getPendingLists(string $patient_id): mixed
{
return $this->requestHandle('List', 'ListVisitRec ', [
'PATIENTID' => $patient_id,
'USERID' => $this->user_id,
]);
}
/**
* 查询就诊记录中的所有诊疗单据
* @param string $cf_ids 处方号,多个处方号使用逗号分隔
* @param string $jz_xh 就诊序号,必填
* @param string $user_id 自助设备编码,必填
* @param string $reg_id 号源编码,可选
* @return mixed
* @throws GeneralException
*/
public function getPendingDetails(
string $cf_ids,
string $jz_xh,
string $user_id,
string $reg_id = ''
): mixed {
// 调用请求处理方法
return $this->requestHandle('List', 'ListRecipe', [
'CFID' => $cf_ids,
'JZXH' => $jz_xh,
'USERID' => $user_id,
'REGID' => $reg_id,
]);
}
/**
* 获取门诊费用清单列表
* @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('Outpatient', 'OutpatientExpenseRecord', [
'PATIENTID' => $patient_id,
'BEGINDATE' => $begin_date,
'ENDDATE' => $end_date,
]);
}
/**
* 获取门诊费用清单详情
* @param string $receipt_id
* @return mixed
* @throws GeneralException
*/
public function getPaidDetails(string $receipt_id): mixed {
return $this->requestHandle('Outpatient', 'OutpatientDetailRecord', [
'Rcptid' => $receipt_id
]);
}
// Outpatient Module End
// Electron Module Start
/**
* 主动调用接口生成电子发票
* @param string $trea_id 就诊编码(结算序号)
* @return mixed
* @throws GeneralException
*/
public function createElectronInvoice(string $trea_id)
{
return $this->requestHandle('Create', 'CreateOutpatientinvoiceEBill', [
'TREAID' => $trea_id
]);
}
/**
* 发送电子票据信息给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('Send', '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('Get', 'GetDictionary', []);
}
/**
* 获取收费项目详情
* @param int $type_id 类别ID
* @return mixed
* @throws GeneralException
*/
public function getDictionaryDetails(int $type_id): mixed
{
return $this->requestHandle('Get', 'GetChargeList', [
'TYPEID' => $type_id
]);
}
// Dictionary Module End
}