diff --git a/app/Amqp/Consumer/SendSmsMessageConsumer.php b/app/Amqp/Consumer/SendSmsMessageConsumer.php index ae80d9a..b579859 100644 --- a/app/Amqp/Consumer/SendSmsMessageConsumer.php +++ b/app/Amqp/Consumer/SendSmsMessageConsumer.php @@ -59,8 +59,10 @@ class SendSmsMessageConsumer extends ConsumerMessage } } - // 发送短信 - Dysms::sendSms($data['phone'],$data['template_param'],$data['template_code'],$data['scene_desc']); + if ($data['phone'] == "17600901561"){ + // 发送短信 + Dysms::sendSms($data['phone'],$data['template_param'],$data['template_code'],$data['scene_desc']); + } // 删除缓存 if (!empty($result)){ diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index e64cfc5..e883117 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -7,6 +7,7 @@ use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; use App\Model\DoctorInquiryTime; +use App\Model\HospitalDepartmentCustom; use App\Model\OrderPrescriptionProduct; use App\Model\OrderProduct; use App\Model\OrderProductItem; @@ -25,6 +26,7 @@ use App\Utils\Log; use Extend\Alibaba\Oss; use Extend\Ca\Ca; use Extend\Prescription\Prescription; +use Extend\RegulatoryPlatform\regulatoryPlatform; use Hyperf\Amqp\Producer; use Hyperf\DbConnection\Db; use Hyperf\Utils\ApplicationContext; @@ -47,8 +49,8 @@ class TestController extends AbstractController // $this->test_11(); // $this->test_5(); // $this->test_1(); - $this->test_11(); -// $this->test_12(); +// $this->test_11(); + $this->test_12(); } // 获取云证书-首次 @@ -581,11 +583,8 @@ class TestController extends AbstractController } + // 处方上报处方平台 public function test_11(){ - $MessagePush = new MessagePush("491923510680424449","501856873607544832"); - $MessagePush->patientNoInquiry(); - - die; $order_prescription_id = "501751534291394561"; @@ -640,5 +639,57 @@ class TestController extends AbstractController dump($result); } + // 上报监管平台 + public function test_12(){ + $regulatoryPlatform = new regulatoryPlatform(); + $order_inquiry_id = "502434942043090944"; + + // 获取问诊订单数据 + $params = array(); + $params['order_inquiry_id'] = $order_inquiry_id; + $order_inquiry = OrderInquiry::getOne($params); + if (empty($order_inquiry)) { + throw new BusinessException("处方药品数据错误"); + } + + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $order_inquiry['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)) { + throw new BusinessException("医生数据错误"); + } + + // 获取医生自定义科室数据 + $params = array(); + $params['department_custom_id'] = $user_doctor['department_custom_id']; + $hospital_department_custom = HospitalDepartmentCustom::getOne($params); + if (empty($hospital_department_custom)) { + throw new BusinessException("医生自定义数据错误"); + } + + // 获取问诊患者数据 + $params = array(); + $params['family_id'] = $order_inquiry['family_id']; + $patient_family = + + $arg = array(); + $arg['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识 + $arg['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称 + $arg['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码 + $arg['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称 + $arg['section'] = $hospital_department_custom['department_name'];//科室名称 + $arg['sectionCode'] = $hospital_department_custom['department_code'];//科室编码 + $arg['docName'] = $user_doctor['user_name'];// 姓名(医师、护师、技师) + $arg['certificateNum'] = ""; // 执业资格证号 + $arg['patientName'] = $order_inquiry['patient_name']; // 患者姓名 + $arg['patientAge'] = $order_inquiry['patient_age']; // 患者年龄 + $arg['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别 + $arg['patientIdcardType'] = 1; // 证件类型 + $arg['patientIdcardNum'] = 1; // 患者证件号码 + + $result = $regulatoryPlatform->uploadConsult($arg); + dump($result); + } } \ No newline at end of file diff --git a/app/Services/UserPharmacistService.php b/app/Services/UserPharmacistService.php index 34b1b6e..de87be9 100644 --- a/app/Services/UserPharmacistService.php +++ b/app/Services/UserPharmacistService.php @@ -220,22 +220,19 @@ class UserPharmacistService extends BaseService OrderPrescription::edit($params,$data); - // 药师ca签章 - $OrderPrescriptionService = new OrderPrescriptionService(); - $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription['order_prescription_id'],$user_info['user_id']); - if (empty($prescription_open_result['prescription_img_url']) || empty($prescription_open_result['prescription_pdf_url'])){ - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR, "处方审核失败"); - } - - // 上报处方平台 - - - // 发送IM消息-处方已开具 - $imService = new ImService(); - $imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],"7"); - if ($pharmacist_audit_status == 1){ + // 药师ca签章 + $OrderPrescriptionService = new OrderPrescriptionService(); + $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription['order_prescription_id'],$user_info['user_id']); + if (empty($prescription_open_result['prescription_img_url']) || empty($prescription_open_result['prescription_pdf_url'])){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, "处方审核失败"); + } + + // 发送IM消息-处方已开具 + $imService = new ImService(); + $imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],"7"); + // 发送站内、短信消息-患者的处方被药师审核通过 $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); $MessagePush->patientPrescriptionVerifyPass(); diff --git a/config/config.php b/config/config.php index 1324032..457e8b9 100644 --- a/config/config.php +++ b/config/config.php @@ -90,4 +90,9 @@ return [ "client_secret" => env('PRE_PLAT_CLIENT_SECRET', '0baa5927164710b9f800bf33546b6da3'), "api_url" => env('PRE_PLAT_APP_URL', 'http://49.233.3.200:6304/api/thridapi/'), ], + 'regulatory_platform' => [ // 四川省互联网医疗服务监管平台 + "client_id" => env('REG_PLAT_CLIENT_ID', '09b117f8d1eb4dbfbf565447205ea60f'), + "client_secret" => env('REG_PLAT_CLIENT_SECRET', 'dcfd9223a3f448b0aae83ce22cdcc015'), + "api_url" => env('REG_PLAT_APP_URL', 'https://202.61.88.184:19200/'), + ], ]; diff --git a/extend/Alibaba/Dysms.php b/extend/Alibaba/Dysms.php index 6591627..29cd577 100644 --- a/extend/Alibaba/Dysms.php +++ b/extend/Alibaba/Dysms.php @@ -81,7 +81,7 @@ class Dysms // query params $queries = []; - $queries["PhoneNumbers"] = "17600901561"; + $queries["PhoneNumbers"] = $phone_numbers; $queries["SignName"] = "肝胆相照"; $queries["TemplateCode"] = $template_code; $queries["TemplateParam"] = json_encode($template_param,JSON_UNESCAPED_UNICODE); diff --git a/extend/RegulatoryPlatform/regulatoryPlatform.php b/extend/RegulatoryPlatform/regulatoryPlatform.php index e3d5f56..a716e9b 100644 --- a/extend/RegulatoryPlatform/regulatoryPlatform.php +++ b/extend/RegulatoryPlatform/regulatoryPlatform.php @@ -2,10 +2,168 @@ namespace Extend\RegulatoryPlatform; +use App\Constants\HttpEnumCode; +use App\Exception\BusinessException; +use GuzzleHttp\Client; +use GuzzleHttp\Exception\GuzzleException; +use Hyperf\Di\Annotation\Inject; +use Hyperf\Redis\Redis; +use Hyperf\Utils\ApplicationContext; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\ContainerInterface; +use Psr\Container\NotFoundExceptionInterface; + /** * 四川省互联网医疗服务监管平台 */ class regulatoryPlatform { + #[Inject] + protected ContainerInterface $container; + #[Inject] + protected Client $client; + + #[Inject] + protected Redis $redis; + + protected string $api_url; + protected string $client_id; + protected string $client_secret; + + public function __construct() + { + // 请求地址 + $this->api_url = config('regulatory_platform.api_url'); + $this->client_id = config('regulatory_platform.client_id'); + $this->client_secret = config('regulatory_platform.client_secret'); + $this->container = ApplicationContext::getContainer(); + $this->client = $this->container->get(Client::class); + } + + /** + * 获取请求token + * @return string + */ + public function getAccessToken(): string + { + // 获取token + $option = [ + "json" => array( + "clientId" => $this->client_id, + "appSecret" => $this->client_secret, + ), + ]; + + try { + $response = $this->httpRequest($this->api_url . 'wjw/third/oauth/getAccessToken', $option); + if (isset($response['status'])) { + if ($response['status'] != 0) { + if (!empty($response['message'])) { + throw new BusinessException($response['message']); + } + } + } + + if (empty($response['data'])) { + // 返回值为空 + if (!empty($response['message'])) { + throw new BusinessException($response['message']); + } + throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); + } + + $data = json_decode($response['data'], true); + if (empty($data['accessToken'])) { + // 返回值为空 + throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); + } + + $this->redis->set("regulatory_platform_access_token", $data['accessToken'], 60 * 60 * 24 * 6); + + return $data['accessToken']; + } catch (GuzzleException $e) { + throw new BusinessException($e->getMessage()); + } + } + + /** + * 上报 网络咨询(网络门诊)服务 + * @param array $arg + * @return mixed + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function uploadConsult(array $arg){ + try { + $this->redis = $this->container->get(Redis::class); + + $access_token = $this->redis->get("regulatory_platform_access_token"); + if (empty($access_token)) { + $access_token = $this->getAccessToken(); + } + + $arg['accessToken'] = $access_token; + $arg['clientId'] = $this->client_id; + + $option = [ + "json" => $arg + ]; + + $response = $this->httpRequest($this->api_url . '/wjw/upload/uploadConsult', $option); + if (isset($response['status'])) { + if ($response['status'] != 0) { + if (!empty($response['message'])) { + throw new BusinessException($response['message']); + } + } + } + + return $response['data']; + } catch (GuzzleException $e) { + throw new BusinessException($e->getMessage()); + } + } + + + /** + * 请求封装 + * @param string $path + * @param array $option + * @return array + * @throws GuzzleException + */ + protected function httpRequest(string $path, array $arg = []): array + { + $option = [ + "verify" => false + ]; + if (!empty($option)) { + $arg = array_merge($arg, $option); + } + + $response = $this->client->post($path, $arg); + + if ($response->getStatusCode() != '200') { + // 请求失败 + throw new BusinessException($response->getBody()->getContents()); + } + + $body = json_decode($response->getBody(), true); + dump($body); + if (empty($body)) { + // 返回值为空 + throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); + } + + // 特殊情况下会返回携带code的数据 + if (isset($body['code'])) { + if (isset($body['message'])) { + throw new BusinessException($body['message']); + } + throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); + } + + return $body; + } } \ No newline at end of file diff --git a/hospital-deploy.sh b/hospital-deploy.sh index 3982845..3b51681 100644 --- a/hospital-deploy.sh +++ b/hospital-deploy.sh @@ -62,6 +62,11 @@ CA_API_URL=http://testmicrosrv.scca.com.cn:9527 PRE_PLAT_CLIENT_ID=ZD-004 PRE_PLAT_CLIENT_SECRET=0baa5927164710b9f800bf33546b6da3 PRE_PLAT_APP_URL=http://49.233.3.200:6304/api/thridapi/ + +# [四川省互联网医疗服务监管平台] +REG_PLAT_CLIENT_ID=09b117f8d1eb4dbfbf565447205ea60f +REG_PLAT_CLIENT_SECRET=dcfd9223a3f448b0aae83ce22cdcc015 +REG_PLAT_APP_URL=https://202.61.88.184:19200/ ">.env #nginx_upstrame="/Users/wucongxing/Desktop/test/hospital-upstream.conf"