新增处方平台推送数据

This commit is contained in:
2023-05-08 17:44:31 +08:00
parent bb4b7295cf
commit d09f53fd49
9 changed files with 1186 additions and 30 deletions
@@ -105,11 +105,13 @@ class regulatoryPlatform
$access_token = $this->getAccessToken();
}
$arg['accessToken'] = $access_token;
$arg['clientId'] = $this->client_id;
foreach ($arg as &$item){
$item['accessToken'] = $access_token;
$item['clientId'] = $this->client_id;
}
$option = [
"json" => [$arg]
"json" => $arg
];
$response = $this->httpRequest($this->api_url . '/wjw/upload/uploadConsult', $option);
@@ -144,8 +146,10 @@ class regulatoryPlatform
$access_token = $this->getAccessToken();
}
$arg['accessToken'] = $access_token;
$arg['clientId'] = $this->client_id;
foreach ($arg as &$item){
$item['accessToken'] = $access_token;
$item['clientId'] = $this->client_id;
}
$option = [
"json" => $arg
@@ -166,6 +170,47 @@ class regulatoryPlatform
}
}
/**
* 上报 电子处方服务
* @param array $arg
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function uploadRecipe(array $arg): array
{
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();
}
foreach ($arg as &$item){
$item['accessToken'] = $access_token;
$item['clientId'] = $this->client_id;
}
$option = [
"json" => $arg
];
$response = $this->httpRequest($this->api_url . '/wjw/upload/uploadRecipe', $option);
if (isset($response['status'])) {
if ($response['status'] != 0) {
if (!empty($response['message'])) {
throw new BusinessException($response['message']);
}
}
}
return $response;
} catch (GuzzleException $e) {
throw new BusinessException($e->getMessage());
}
}
/**
* 请求封装
@@ -192,7 +237,7 @@ class regulatoryPlatform
}
$body = json_decode($response->getBody(), true);
dump($body);
Log::getInstance()->info(json_encode($body,JSON_UNESCAPED_UNICODE));
if (empty($body)) {
// 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));