新增自动开具处方。修改ca对接
This commit is contained in:
+70
-29
@@ -59,6 +59,13 @@ class CaService extends BaseService
|
||||
// 信用代码
|
||||
protected string $org_num;
|
||||
|
||||
// 处方pdf本地地址
|
||||
protected string $prescription_pdf_local_path;
|
||||
|
||||
// 处方pdf oss地址
|
||||
protected string $prescription_pdf_oss_path;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化类,此处会获取基础数据
|
||||
* @param array|object $order_prescription 处方表数据
|
||||
@@ -215,6 +222,12 @@ class CaService extends BaseService
|
||||
// 关闭channel通道
|
||||
$channel->close();
|
||||
}
|
||||
|
||||
// 处方pdf本地地址
|
||||
$this->prescription_pdf_local_path = "./runtime/file/prescription/" . $order_prescription_id . '.pdf';
|
||||
|
||||
// 处方pdf oss地址
|
||||
$this->prescription_pdf_oss_path = "applet/prescription/" . $order_prescription_id. '.pdf';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,8 +395,8 @@ class CaService extends BaseService
|
||||
// 上传处方图片至oss
|
||||
$oss = new Oss();
|
||||
$prescription_img_oss_filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'jpg';
|
||||
$prescription_img_url = $oss->putObject($prescription_img_oss_filename, $img_result);
|
||||
$prescription_img_url = '/' . $prescription_img_url;
|
||||
$prescription_img_oss_path = $oss->putObject($prescription_img_oss_filename, $img_result);
|
||||
$prescription_img_oss_path = '/' . $prescription_img_oss_path;
|
||||
|
||||
// 图片生成pdf
|
||||
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
|
||||
@@ -402,37 +415,78 @@ class CaService extends BaseService
|
||||
// 图片生成的处方pdf存储为本地文件 runtime目录下
|
||||
$pdf->Output($prescription_pdf_local_path . $prescription_pdf_local_filename, "F");
|
||||
|
||||
return $prescription_img_url;
|
||||
return $prescription_img_oss_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载医生开具的处方pdf
|
||||
* 下载Oss中处方pdf
|
||||
* 存在:当次发版内医生开具后,药师再去开具
|
||||
* 不存在:医生开具后,进行发版过,此时需重新下载
|
||||
* @param string $order_prescription_id
|
||||
* @param string $doctor_pdf_oss_path
|
||||
* @return void
|
||||
*/
|
||||
public function downDoctorPrescriptionPdf(string $order_prescription_id,string $doctor_pdf_oss_path): void
|
||||
public function downOssPdfToLocal(): void
|
||||
{
|
||||
$local_path = "./runtime/file/prescription/" . $order_prescription_id . '.' . 'pdf';
|
||||
$res = file_exists($local_path);
|
||||
$res = file_exists($this->prescription_pdf_local_path);
|
||||
if (!$res){
|
||||
// 去除第一个/ oss不识别
|
||||
$prescription_pdf_path = substr($doctor_pdf_oss_path, 1, strlen($doctor_pdf_oss_path) - 1);
|
||||
// $prescription_pdf_path = substr($doctor_pdf_oss_path, 1, strlen($doctor_pdf_oss_path) - 1);
|
||||
|
||||
$oss = new Oss();
|
||||
$oss->getObjectToLocal($prescription_pdf_path, $local_path);
|
||||
$oss->getObjectToLocal($this->prescription_pdf_oss_path, $this->prescription_pdf_local_path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载CA中pdf至本地文件
|
||||
* @param string $file_id
|
||||
* @param int $type 类型 1:用户 2:医院
|
||||
* @return void
|
||||
*/
|
||||
public function downCaPdfToLocal(string $file_id,int $type): void
|
||||
{
|
||||
$CaOnline = new CaOnline();
|
||||
if ($type == 1){
|
||||
// 用户
|
||||
$prescription_pdf_result = $CaOnline->getSignedFile($this->user_entity_id, $file_id);
|
||||
}else{
|
||||
// 医院
|
||||
$prescription_pdf_result = $CaOnline->getSignedFile($this->hospital_entity_id, $file_id);
|
||||
}
|
||||
|
||||
$file = fopen($this->prescription_pdf_local_path, "w");
|
||||
fwrite($file, $prescription_pdf_result);
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载CA中的pdf并上传至oss
|
||||
* @param string $file_id
|
||||
* @param int $type 类型 1:用户 2:医院
|
||||
* @return string oss地址
|
||||
*/
|
||||
public function downCaPdfToOss(string $file_id,int $type): string
|
||||
{
|
||||
$CaOnline = new CaOnline();
|
||||
|
||||
if ($type == 1){
|
||||
// 用户
|
||||
$prescription_pdf_result = $CaOnline->getSignedFile($this->user_entity_id, $file_id);
|
||||
}else{
|
||||
// 医院
|
||||
$prescription_pdf_result = $CaOnline->getSignedFile($this->hospital_entity_id, $file_id);
|
||||
}
|
||||
|
||||
// 上传oss
|
||||
$oss = new Oss();
|
||||
return $oss->putObject($this->prescription_pdf_oss_path, $prescription_pdf_result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 进行处方pdf签章
|
||||
* @param array|object $order_prescription
|
||||
* @param string $type 类型 1:医院 2:医生 3:药师
|
||||
* @return string 文件id
|
||||
*/
|
||||
public function addSignPdf(array|object $order_prescription,string $type): string
|
||||
public function addSignPdf(string $type): string
|
||||
{
|
||||
// 下载签名图片
|
||||
if ($type == 1){
|
||||
@@ -529,9 +583,9 @@ class CaService extends BaseService
|
||||
}
|
||||
|
||||
// 打开处方pdf文件
|
||||
$pdf_file = fopen("./runtime/file/prescription/" . $order_prescription['order_prescription_id'] . ".pdf", 'r');
|
||||
$pdf_file = fopen($this->prescription_pdf_local_path, 'r');
|
||||
if (!$pdf_file) {
|
||||
throw new BusinessException("处方图片打开失败");
|
||||
throw new BusinessException("处方pdf打开失败");
|
||||
}
|
||||
|
||||
// 处方pdf进行签章
|
||||
@@ -543,22 +597,9 @@ class CaService extends BaseService
|
||||
throw new BusinessException("处方签章失败");
|
||||
}
|
||||
|
||||
fclose($pdf_file);
|
||||
return $sign_pdf_result[0]['fileId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载签章pdf图片
|
||||
* @param string $file_id
|
||||
* @param string $order_prescription_id
|
||||
* @return void
|
||||
*/
|
||||
public function downCaPdf(string $file_id,string $order_prescription_id): void
|
||||
{
|
||||
$CaOnline = new CaOnline();
|
||||
$prescription_pdf_result = $CaOnline->getSignedFile($this->user_entity_id, $file_id);
|
||||
|
||||
$file = fopen("./runtime/file/prescription/" . $order_prescription_id . '.pdf', "w");
|
||||
fwrite($file, $prescription_pdf_result);
|
||||
fclose($file);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user