监管平台更新接口 V2
Build Docker / build (push) Has been cancelled

This commit is contained in:
haomingming
2026-05-12 14:49:47 +08:00
parent f9ba59aa55
commit 012984f636
15 changed files with 1773 additions and 204 deletions
@@ -261,7 +261,12 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
}
// 修改处方文件表,添加prescription_pdf_oss_path字段
$this->modifyOrderPrescriptionFile($data['prescription_file_id'],$prescription_pdf_oss_path,$prescription_open_result['file_id']);
$this->modifyOrderPrescriptionFile(
$data['prescription_file_id'],
$prescription_pdf_oss_path,
$prescription_open_result['file_id'],
$prescription_open_result
);
// 修改处方表为通过
$this->modifyOrderPrescription($data['order_prescription_id'],1);
@@ -438,7 +443,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
* @param string $hospital_ca_file_id 医院签章文件id
* @return void
*/
protected function modifyOrderPrescriptionFile(string $prescription_file_id,string $prescription_pdf_oss_path,string $hospital_ca_file_id): void
protected function modifyOrderPrescriptionFile(string $prescription_file_id,string $prescription_pdf_oss_path,string $hospital_ca_file_id,array $pharmacist_ca_data = []): void
{
try {
$params = array();
@@ -447,6 +452,11 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
$data = array();
$data['hospital_ca_file_id'] = $hospital_ca_file_id;
$data['prescription_pdf_oss_path'] = $prescription_pdf_oss_path;
$data['pharmacist_ca_supplier'] = $pharmacist_ca_data['ca_supplier'] ?? "";
$data['pharmacist_ca_sign_type'] = $pharmacist_ca_data['ca_sign_type'] ?? "";
$data['pharmacist_ca_sign_originaltext'] = $pharmacist_ca_data['ca_sign_originaltext'] ?? "";
$data['pharmacist_ca_sign_text'] = $pharmacist_ca_data['ca_sign_text'] ?? "";
$data['pharmacist_ca_sign_time'] = $pharmacist_ca_data['ca_sign_time'] ?? "";
OrderPrescriptionFile::edit($params,$data);
}catch(\Exception $e){
+312 -13
View File
@@ -9,12 +9,12 @@ use App\Model\HospitalDepartmentCustom;
use App\Model\OrderInquiry;
use App\Model\OrderInquiryCase;
use App\Model\OrderPrescription;
use App\Model\OrderPrescriptionFile;
use App\Model\OrderPrescriptionIcd;
use App\Model\OrderPrescriptionProduct;
use App\Model\PatientFamily;
use App\Model\Product;
use App\Model\ReportRegulatory;
use App\Model\UserCaCert;
use App\Model\UserDoctor;
use App\Model\UserDoctorInfo;
use App\Model\UserPharmacist;
@@ -188,7 +188,7 @@ class ReportRegulatoryCommand extends HyperfCommand
}else{
$this->line("C-2、检测处方(抄方)数据");
// 获取上报数据-处方 (抄方类型)
$report_prescription_data = $this->getReportTransferPrescriptionData($order_inquiry, $order_prescription);
$report_prescription_data = $this->getReportTransferPrescriptionDataV2($order_inquiry, $order_prescription);
}
$this->line("C-3、上报处方");
@@ -198,6 +198,17 @@ class ReportRegulatoryCommand extends HyperfCommand
$this->line("C-4、上报处方成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
$report_prescription_detail_data = $this->getReportPrescriptionDetailData(
$order_prescription,
$report_prescription_data
);
if (empty($report_prescription_detail_data)) {
throw new BusinessException("处方明细数据错误");
}
$result = $regulatoryPlatform->uploadRecipeDetail($report_prescription_detail_data);
$this->line("C-4-1、上报处方明细成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
// 上报成功
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 1);
if (!$res) {
@@ -474,7 +485,7 @@ class ReportRegulatoryCommand extends HyperfCommand
$params['user_id'] = $user_doctor['user_id'];
$params['type'] = 2;
$params['is_latest'] = 1;
$doctor_user_ca_cert = UserCaCert::getOne($params);
$doctor_user_ca_cert = $this->buildLegacyCaCertPayload($order_prescription['order_prescription_id'], 'doctor');
if (empty($doctor_user_ca_cert)){
$this->line("错误:无医生ca数据");
return false;
@@ -485,7 +496,7 @@ class ReportRegulatoryCommand extends HyperfCommand
$params['user_id'] = $user_pharmacist['user_id'];
$params['type'] = 2;
$params['is_latest'] = 1;
$pharmacist_user_ca_cert = UserCaCert::getOne($params);
$pharmacist_user_ca_cert = $this->buildLegacyCaCertPayload($order_prescription['order_prescription_id'], 'pharmacist');
if (empty($pharmacist_user_ca_cert)){
$this->line("错误:无药师ca数据");
return false;
@@ -533,6 +544,13 @@ class ReportRegulatoryCommand extends HyperfCommand
$data['recipeNo'] = $order_prescription['order_prescription_id']; // 医院处方编号
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
$pharmacist_ca_data = $this->getStoredPrescriptionCaData($order_prescription['order_prescription_id'], 'pharmacist');
$data['caSupplier'] = $pharmacist_ca_data['caSupplier'] ?? "";
$data['caSignType'] = $pharmacist_ca_data['caSignType'] ?? "";
$data['caSignTime'] = $pharmacist_ca_data['caSignTime'] ?? "";
$data['caSignOriginaltext'] = $pharmacist_ca_data['caSignOriginaltext'] ?? "";
$data['caSignText'] = $pharmacist_ca_data['caSignText'] ?? "";
return $data;
}
@@ -544,6 +562,7 @@ class ReportRegulatoryCommand extends HyperfCommand
*/
private function getReportTransferPrescriptionData(array|object $order_inquiry, array|object $order_prescription): bool|array
{
return $this->getReportTransferPrescriptionDataV2($order_inquiry, $order_prescription);
// 获取医生数据
$params = array();
$params['doctor_id'] = $order_prescription['doctor_id'];
@@ -638,7 +657,7 @@ class ReportRegulatoryCommand extends HyperfCommand
$params['user_id'] = $user_doctor['user_id'];
$params['type'] = 2;
$params['is_latest'] = 1;
$doctor_user_ca_cert = UserCaCert::getOne($params);
$doctor_user_ca_cert = $this->buildLegacyCaCertPayload($order_prescription['order_prescription_id'], 'doctor');
if (empty($doctor_user_ca_cert)){
$this->line("错误:无医生ca数据");
return false;
@@ -649,7 +668,7 @@ class ReportRegulatoryCommand extends HyperfCommand
$params['user_id'] = $user_pharmacist['user_id'];
$params['type'] = 2;
$params['is_latest'] = 1;
$pharmacist_user_ca_cert = UserCaCert::getOne($params);
$pharmacist_user_ca_cert = $this->buildLegacyCaCertPayload($order_prescription['order_prescription_id'], 'pharmacist');
if (empty($pharmacist_user_ca_cert)){
$this->line("错误:无药师ca数据");
return false;
@@ -697,6 +716,160 @@ class ReportRegulatoryCommand extends HyperfCommand
$data['recipeNo'] = $order_prescription['order_prescription_id']; // 医院处方编号
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
$pharmacist_ca_data = $this->getStoredPrescriptionCaData($order_prescription['order_prescription_id'], 'pharmacist');
$data['caSupplier'] = $pharmacist_ca_data['caSupplier'] ?? "";
$data['caSignType'] = $pharmacist_ca_data['caSignType'] ?? "";
$data['caSignTime'] = $pharmacist_ca_data['caSignTime'] ?? "";
$data['caSignOriginaltext'] = $pharmacist_ca_data['caSignOriginaltext'] ?? "";
$data['caSignText'] = $pharmacist_ca_data['caSignText'] ?? "";
return $data;
}
private function getReportTransferPrescriptionDataV2(array|object $order_inquiry, array|object $order_prescription): bool|array
{
$params = array();
$params['doctor_id'] = $order_prescription['doctor_id'];
$user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)) {
$this->line("閿欒锛氬尰鐢熸暟鎹敊璇?");
return false;
}
$params = array();
$params['doctor_id'] = $order_prescription['doctor_id'];
$user_doctor_info = UserDoctorInfo::getOne($params);
if (empty($user_doctor_info)) {
$this->line("閿欒锛氬尰鐢熻鎯呮暟鎹敊璇?");
return false;
}
$params = array();
$params['department_custom_id'] = $user_doctor['department_custom_id'];
$hospital_department_custom = HospitalDepartmentCustom::getOne($params);
if (empty($hospital_department_custom)) {
$this->line("閿欒锛氬尰鐢熻嚜瀹氫箟鏁版嵁閿欒");
return false;
}
$params = array();
$params['family_id'] = $order_inquiry['family_id'];
$patient_family = PatientFamily::getOne($params);
if (empty($patient_family)) {
$this->line("閿欒锛氶棶璇婃偅鑰呮暟鎹敊璇?");
return false;
}
$params = array();
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
$params['status'] = 1;
$order_inquiry_case = OrderInquiryCase::getOne($params);
if (empty($order_inquiry_case)) {
$this->line("閿欒锛氭偅鑰呴棶璇婄梾渚嬮敊璇?");
return false;
}
$params = array();
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
$user_pharmacist = UserPharmacist::getOne($params);
if (empty($user_pharmacist)) {
$this->line("閿欒锛氳嵂甯堟暟鎹敊璇?");
return false;
}
$params = array();
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
if (empty($user_pharmacist_info)) {
$this->line("閿欒锛氳嵂甯堣鎯呮暟鎹敊璇?");
return false;
}
$params = array();
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
$order_prescription_icd = OrderPrescriptionIcd::getList($params);
if (empty($order_prescription_icd)) {
$this->line("閿欒锛氭棤澶嶈瘖鐤剧梾璇婃柇鏁版嵁");
return false;
}
$icd_name = "";
$icd_name_data = array_column($order_prescription_icd->toArray(), 'icd_name');
if (!empty($icd_name_data)) {
if (count($icd_name_data) > 1) {
$icd_name = implode('|', $icd_name_data);
} else {
$icd_name = $icd_name_data[0];
}
}
$order_prescription_product = $this->getPreProductData($order_prescription['order_prescription_id']);
if (empty($order_prescription_product)) {
$this->line("閿欒锛氭棤澶勬柟鍟嗗搧鏁版嵁");
return false;
}
$doctor_user_ca_cert = $this->buildLegacyCaCertPayload($order_prescription['order_prescription_id'], 'doctor');
if (empty($doctor_user_ca_cert)) {
$this->line("閿欒锛氭棤鍖荤敓ca鏁版嵁");
return false;
}
$pharmacist_user_ca_cert = $this->buildLegacyCaCertPayload($order_prescription['order_prescription_id'], 'pharmacist');
if (empty($pharmacist_user_ca_cert)) {
$this->line("閿欒锛氭棤鑽笀ca鏁版嵁");
return false;
}
$data = array();
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id'];
$data['orgName'] = "鎴愰兘閲戠墰娆f鐩哥収浜掕仈缃戝尰闄?";
$data['orgCode'] = "MA6CGUDA251010619D2112";
$data['section'] = $hospital_department_custom['department_name'];
$data['sectionCode'] = $hospital_department_custom['department_code'];
$data['docName'] = $user_doctor['user_name'];
$data['docCertificateNum'] = $user_doctor_info['qualification_cert_num'];
$data['pharmacistName'] = $user_pharmacist_info['card_name'];
$data['pharmacistOrg'] = "鎴愰兘閲戠墰娆f鐩哥収浜掕仈缃戝尰闄?";
$data['pharmacistCertificateNum'] = $user_pharmacist_info['qualification_cert_num'];
$data['furtherConsultNo'] = $order_inquiry['order_inquiry_id'];
$data['furtherConsultDiagnosis'] = $icd_name;
$data['patientName'] = $order_inquiry['patient_name'];
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1;
$data['patientAge'] = (int) $order_inquiry['patient_age'];
$data['patientIdcardType'] = 1;
$data['patientIdcardNum'] = $patient_family['id_number'];
$data['feeType'] = 1;
$data['medicalHistory'] = $order_inquiry_case['disease_desc'];
$data['recipeTime'] = $order_prescription['doctor_created_time'];
$data['recipeType'] = 2;
$data['reviewTime'] = $order_prescription['pharmacist_verify_time'];
$data['recipeUnitPrice'] = $order_prescription_product['amount_total'];
$data['drugName'] = $order_prescription_product['drug_name'];
$data['drugCode'] = $order_prescription_product['drug_code'];
$data['drugCommonName'] = $order_prescription_product['drug_common_name'];
$data['specification'] = $order_prescription_product['specification'];
$data['frequency'] = $order_prescription_product['frequency'];
$data['usage'] = $order_prescription_product['usage'];
$data['doseUnit'] = $order_prescription_product['dose_unit'];
$data['doseEachTime'] = $order_prescription_product['dose_each_time'];
$data['medicationDays'] = $order_prescription_product['medication_days'];
$data['quantity'] = $order_prescription_product['quantity'];
$data['drugPackage'] = $order_prescription_product['drug_package'];
$data['recipeAllPrice'] = $order_prescription_product['amount_total'];
$data['uploadTime'] = date("Y-m-d H:i:s", time());
$data['docCaSign'] = $doctor_user_ca_cert['cert_base64'];
$data['pharmacistCaSign'] = $pharmacist_user_ca_cert['cert_base64'];
$data['recipeNo'] = $order_prescription['order_prescription_id'];
$data['cityId'] = "510100";
$pharmacist_ca_data = $this->getStoredPrescriptionCaData($order_prescription['order_prescription_id'], 'pharmacist');
$data['caSupplier'] = $pharmacist_ca_data['caSupplier'] ?? "";
$data['caSignType'] = $pharmacist_ca_data['caSignType'] ?? "";
$data['caSignTime'] = $pharmacist_ca_data['caSignTime'] ?? "";
$data['caSignOriginaltext'] = $pharmacist_ca_data['caSignOriginaltext'] ?? "";
$data['caSignText'] = $pharmacist_ca_data['caSignText'] ?? "";
return $data;
}
@@ -736,9 +909,9 @@ class ReportRegulatoryCommand extends HyperfCommand
$specification = $item['product_spec']; // 规格
$frequency = $item['frequency_use']; // 使用频度
$usage = $item['single_use']; // 用法
$dose_unit = $product['single_unit']; // 剂量单位
$dose_each_time = $product['single_unit']; // 每次剂量
$medication_days = (double)$product['available_days']; // 用药天数
$dose_unit = $item['single_unit']; // 剂量单位
$dose_each_time = $item['single_unit']; // 每次剂量
$medication_days = (double)$item['available_days']; // 用药天数
$quantity = (double)$item['prescription_product_num']; // 数量
$drug_package = $item['packaging_unit']; // 药品包装
} else {
@@ -748,14 +921,22 @@ class ReportRegulatoryCommand extends HyperfCommand
$specification = $specification . "|" . $item['product_spec']; // 规格
$frequency = $frequency . "|" . $item['frequency_use']; // 使用频度
$usage = $usage . "|" . $item['single_use']; // 用法
$dose_unit = $dose_unit . "|" . $product['single_unit']; // 剂量单位
$dose_each_time = $dose_each_time . "|" . $product['single_unit']; // 每次剂量
$medication_days = $medication_days . "|" . (double)$product['available_days']; // 用药天数
$dose_unit = $dose_unit . "|" . $item['single_unit']; // 剂量单位
$dose_each_time = $dose_each_time . "|" . $item['single_unit']; // 每次剂量
$medication_days = $medication_days . "|" . (double)$item['available_days']; // 用药天数
$quantity = $quantity . "|" . (double)$item['prescription_product_num']; // 数量
$drug_package = $drug_package . "|" . $item['packaging_unit']; // 药品包装
}
$amount_total += $item['product_price'] * $item['prescription_product_num'];
$amount_total = bcadd(
(string) $amount_total,
bcmul(
(string) ($item['product_price'] ?? $product['product_price'] ?? 0),
(string) $item['prescription_product_num'],
2
),
2
);
}
$result = array();
@@ -775,11 +956,121 @@ class ReportRegulatoryCommand extends HyperfCommand
return $result;
}
private function getPreProductDetailData(string $order_prescription_id): array
{
$params = array();
$params['order_prescription_id'] = $order_prescription_id;
$order_prescription_product = OrderPrescriptionProduct::getList($params);
if (empty($order_prescription_product)) {
$this->line("错误:无处方药品数据");
return [];
}
$result = [];
foreach ($order_prescription_product as $item) {
$params = array();
$params['product_id'] = $item['product_id'];
$product = Product::getWithAmountOne($params);
if (empty($product)) {
$this->line("错误:无药品数据");
return [];
}
$amount_total = bcmul(
(string) ($item['product_price'] ?? $product['product_price'] ?? 0),
(string) $item['prescription_product_num'],
2
);
$result[] = [
'drug_name' => (string) ($item['product_name'] ?? ''),
'drug_code' => (string) ($product['product_pharmacy_code'] ?? ''),
'drug_common_name' => (string) ($product['common_name'] ?? ''),
'specification' => (string) ($item['product_spec'] ?? ''),
'frequency' => (string) ($item['frequency_use'] ?? ''),
'usage' => (string) ($item['single_use'] ?? ''),
'dose_unit' => (string) ($item['single_unit'] ?? $product['single_unit'] ?? ''),
'dose_each_time' => (string) ($item['single_unit'] ?? $product['single_unit'] ?? ''),
'medication_days' => (string) ($item['available_days'] ?? $product['available_days'] ?? ''),
'quantity' => (string) $item['prescription_product_num'],
'drug_package' => (string) ($item['packaging_unit'] ?? ''),
'product_price' => (string) ($item['product_price'] ?? $product['product_price'] ?? 0),
'amount_total' => $amount_total,
];
}
return $result;
}
private function getReportPrescriptionDetailData(
array|object $order_prescription,
array $report_prescription_data
): array {
$product_details = $this->getPreProductDetailData((string) $order_prescription['order_prescription_id']);
if (empty($product_details)) {
return [];
}
$result = [];
foreach ($product_details as $detail) {
$row = $report_prescription_data;
$row['recipeUnitPrice'] = $detail['product_price'];
$row['drugName'] = $detail['drug_name'];
$row['drugCode'] = $detail['drug_code'];
$row['drugCommonName'] = $detail['drug_common_name'];
$row['specification'] = $detail['specification'];
$row['frequency'] = $detail['frequency'];
$row['usage'] = $detail['usage'];
$row['doseUnit'] = $detail['dose_unit'];
$row['doseEachTime'] = $detail['dose_each_time'];
$row['medicationDays'] = $detail['medication_days'];
$row['quantity'] = $detail['quantity'];
$row['drugPackage'] = $detail['drug_package'];
$row['recipeAllPrice'] = $detail['amount_total'];
$row['uploadTime'] = date("Y-m-d H:i:s", time());
$result[] = $row;
}
return $result;
}
/**
* 获取上报数据-网络咨询
* @param array|object $order_inquiry
* @return array
*/
private function getStoredPrescriptionCaData(string|int $order_prescription_id, string $role): array
{
$params = array();
$params['order_prescription_id'] = $order_prescription_id;
$order_prescription_file = OrderPrescriptionFile::getOne($params);
if (empty($order_prescription_file)) {
return [];
}
$prefix = $role === 'doctor' ? 'doctor' : 'pharmacist';
return [
'caSupplier' => (string) ($order_prescription_file[$prefix . '_ca_supplier'] ?? ''),
'caSignType' => (string) ($order_prescription_file[$prefix . '_ca_sign_type'] ?? ''),
'caSignTime' => (string) ($order_prescription_file[$prefix . '_ca_sign_time'] ?? ''),
'caSignOriginaltext' => (string) ($order_prescription_file[$prefix . '_ca_sign_originaltext'] ?? ''),
'caSignText' => (string) ($order_prescription_file[$prefix . '_ca_sign_text'] ?? ''),
];
}
private function buildLegacyCaCertPayload(string|int $order_prescription_id, string $role): array
{
$ca_data = $this->getStoredPrescriptionCaData($order_prescription_id, $role);
if (empty($ca_data['caSignText'])) {
return [];
}
return [
'cert_base64' => $ca_data['caSignText'],
];
}
private function getConsultData(array|object $order_inquiry): array
{
// 获取医生数据
@@ -836,6 +1127,7 @@ class ReportRegulatoryCommand extends HyperfCommand
$data['section'] = $hospital_department_custom['department_name'];//科室名称
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
$data['docName'] = $user_doctor['user_name'];// 姓名(医师、护师、技师)
$data['doc_idcard'] = $user_doctor_info['card_num']; // 医生身份证号
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
@@ -992,6 +1284,13 @@ class ReportRegulatoryCommand extends HyperfCommand
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
$data['isMark'] = 1;//是否留痕 1:代表留痕;0:代表未留痕
$doctor_ca_data = $this->getStoredPrescriptionCaData($order_prescription['order_prescription_id'], 'doctor');
$data['caSupplier'] = $doctor_ca_data['caSupplier'] ?? "";
$data['caSignType'] = $doctor_ca_data['caSignType'] ?? "";
$data['caSignTime'] = $doctor_ca_data['caSignTime'] ?? "";
$data['caSignOriginaltext'] = $doctor_ca_data['caSignOriginaltext'] ?? "";
$data['caSignText'] = $doctor_ca_data['caSignText'] ?? "";
return $data;
}
}
+1 -1
View File
@@ -33,7 +33,7 @@ class OrderPrescriptionFile extends Model
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['prescription_file_id', 'order_prescription_id', 'doctor_ca_file_id', 'hospital_ca_file_id', 'prescription_img_oss_path', 'prescription_pdf_oss_path', 'is_converted_pdf', 'created_at', 'updated_at'];
protected array $fillable = ['prescription_file_id', 'order_prescription_id', 'doctor_ca_file_id', 'doctor_ca_supplier', 'doctor_ca_sign_type', 'doctor_ca_sign_originaltext', 'doctor_ca_sign_text', 'doctor_ca_sign_time', 'pharmacist_ca_supplier', 'pharmacist_ca_sign_type', 'pharmacist_ca_sign_originaltext', 'pharmacist_ca_sign_text', 'pharmacist_ca_sign_time', 'hospital_ca_file_id', 'prescription_img_oss_path', 'prescription_pdf_oss_path', 'is_converted_pdf', 'created_at', 'updated_at'];
protected string $primaryKey = "prescription_file_id";
+1 -1
View File
@@ -40,7 +40,7 @@ class OrderPrescriptionProduct extends Model
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['prescription_product_id', 'order_prescription_id', 'product_id', 'use_status', 'prescription_product_num', 'product_name', 'product_spec', 'license_number', 'manufacturer', 'single_unit', 'single_use', 'packaging_unit', 'frequency_use', 'available_days', 'created_at', 'updated_at'];
protected array $fillable = ['prescription_product_id', 'order_prescription_id', 'product_id', 'use_status', 'prescription_product_num', 'product_name', 'product_price', 'product_spec', 'license_number', 'manufacturer', 'single_unit', 'single_use', 'packaging_unit', 'frequency_use', 'available_days', 'created_at', 'updated_at'];
protected string $primaryKey = "prescription_product_id";
+29 -2
View File
@@ -56,6 +56,8 @@ class CaService extends BaseService
// 处方pdf oss地址
protected string $prescription_pdf_oss_path;
protected array $sign_result = [];
/**
* 初始化类,此处会获取基础数据
* @param array|object $order_prescription 处方表数据
@@ -254,13 +256,33 @@ class CaService extends BaseService
$data['product'][] = $product;
}
dump($this->entity_id);
$cert_sign_result = $CaOnline->getCertSign($this->entity_id, $this->entity_id, $data);
// 验证云证书签名 验证无需处理,只要不返回错误即可
$CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data);
$this->cert_serial_number = $cert_sign_result['certSerialnumber'];
$sign_originaltext = hash_hmac("sha1", json_encode($data, JSON_UNESCAPED_UNICODE), config('ca.online.secret'));
$timestamp_sign = "";
try {
$timestamp_result = $CaOnline->getTimestampSign($sign_originaltext);
if (is_array($timestamp_result)) {
$timestamp_sign = $timestamp_result['signedData'] ?? "";
} elseif (is_string($timestamp_result)) {
$timestamp_sign = $timestamp_result;
}
} catch (\Throwable $throwable) {
$timestamp_sign = "";
}
$this->sign_result = [
'ca_supplier' => (string) config('regulatory_platform.ca_supplier', '2'),
'ca_sign_type' => (string) config('regulatory_platform.ca_sign_type', '1'),
'ca_sign_originaltext' => $sign_originaltext,
'ca_sign_text' => $cert_sign_result['signP7'] ?? "",
'ca_sign_time' => $timestamp_sign,
'cert_serial_number' => $cert_sign_result['certSerialnumber'] ?? "",
];
}
/**
@@ -268,6 +290,11 @@ class CaService extends BaseService
* @param array|object $order_prescription
* @return string
*/
public function getSignResult(): array
{
return $this->sign_result;
}
public function createPrescriptionImgPdf(array|object $order_prescription): string
{
// 打开基础处方图片
@@ -542,4 +569,4 @@ class CaService extends BaseService
return $sign_pdf_result[0]['fileId'];
}
}
}
+7 -2
View File
@@ -152,7 +152,6 @@ class OrderPrescriptionService extends BaseService
throw new BusinessException("医生开方日期错误");
}
dump($user_id);
$CaService = new CaService($order_prescription,$type,$user_id);
// 获取云证书签名+验证云证书签名
@@ -167,9 +166,15 @@ class OrderPrescriptionService extends BaseService
// 进行处方pdf签章
$file_id = $CaService->addSignPdf($type);
$sign_result = $CaService->getSignResult();
$result = array();
$result['prescription_img_oss_path'] = $prescription_img_oss_path ?? "";
$result['file_id'] = $file_id;
$result['ca_supplier'] = $sign_result['ca_supplier'] ?? "";
$result['ca_sign_type'] = $sign_result['ca_sign_type'] ?? "";
$result['ca_sign_originaltext'] = $sign_result['ca_sign_originaltext'] ?? "";
$result['ca_sign_text'] = $sign_result['ca_sign_text'] ?? "";
$result['ca_sign_time'] = $sign_result['ca_sign_time'] ?? "";
return $result;
} catch (\Throwable $e) {
@@ -570,4 +575,4 @@ class OrderPrescriptionService extends BaseService
return $promotion;
}
}
}
+7 -1
View File
@@ -1730,6 +1730,7 @@ class UserDoctorService extends BaseService
$data['product_id'] = $item['product_id'];
$data['prescription_product_num'] = $item['prescription_product_num'];
$data['product_name'] = $product['product_name'];
$data['product_price'] = $product['product_price'];
$data['product_spec'] = $product['product_spec'];
$data['license_number'] = $product['license_number'];
$data['manufacturer'] = $product['manufacturer'];
@@ -1799,6 +1800,11 @@ class UserDoctorService extends BaseService
$data = array();
$data['order_prescription_id'] = $order_prescription->order_prescription_id;
$data['doctor_ca_file_id'] = $prescription_open_result['file_id'];
$data['doctor_ca_supplier'] = $prescription_open_result['ca_supplier'] ?? "";
$data['doctor_ca_sign_type'] = $prescription_open_result['ca_sign_type'] ?? "";
$data['doctor_ca_sign_originaltext'] = $prescription_open_result['ca_sign_originaltext'] ?? "";
$data['doctor_ca_sign_text'] = $prescription_open_result['ca_sign_text'] ?? "";
$data['doctor_ca_sign_time'] = $prescription_open_result['ca_sign_time'] ?? "";
$data['prescription_img_oss_path'] = $prescription_open_result['prescription_img_oss_path'];
$order_prescription_file = OrderPrescriptionFile::addOrderPrescriptionFile($data);
if (empty($order_prescription_file)){
@@ -3159,4 +3165,4 @@ class UserDoctorService extends BaseService
return $multi_point_enable;
}
}
}
+2 -2
View File
@@ -25,8 +25,8 @@ class Log
self::getInstance()->{$name}(...$arguments);
}
public static function getInstance(string $name = 'app'): LoggerInterface
public static function getInstance(string $name = 'app', string $group = 'default'): LoggerInterface
{
return ApplicationContext::getContainer()->get(LoggerFactory::class)->get($name);
return ApplicationContext::getContainer()->get(LoggerFactory::class)->get($name, $group);
}
}