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 $settle_type 结算类型 0 自费,1 门诊统筹 * @param string $settle_date 结算日期 yyyy-mm-dd * @param string $prescription_ids 处方号,多张处方用,隔开 * @param string $reg_id 就诊序号 * @param string $reg_type 就诊类别 * @param string $order_id 交易流水号 * @param string $tran_type 支付方式 12 银联 3 医保 88 微信 89 支付宝 * @param string $total_fee 本次医疗费用 * @param string $self_fee 个人自付总额 * @param string $register_area 挂号区域 * @return mixed * @throws GeneralException */ public function confirmOutpatient( string $patient_id, string $settle_type, string $settle_date, string $prescription_ids, string $reg_id, string $reg_type, string $order_id, string $tran_type, string $total_fee, string $self_fee, string $register_area = '01' ): mixed { // 调用请求处理方法 return $this->requestHandle('POST', 'PayBillTrade', [ 'json' => [ 'patientID' => $patient_id, 'settleType' => $settle_type, 'jsrq' => $settle_date, 'cfid' => $prescription_ids, 'jzxh' => $reg_id, 'jzlb' => $reg_type, 'orderId' => $order_id, 'tranType' => $tran_type, 'ylfyze' => $total_fee, 'grzfje' => $self_fee, 'registerArea' => $register_area, ... $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 }