上报监管平台
Some checks are pending
Build Docker / build (push) Waiting to run

This commit is contained in:
haomingming 2026-01-06 09:11:55 +08:00
parent 90194053e0
commit e825269798

View File

@ -169,8 +169,16 @@ class ReportRegulatoryCommand extends HyperfCommand
if (empty($order_prescription)){ if (empty($order_prescription)){
$this->line("需上报复诊,但无处方数据"); $this->line("需上报复诊,但无处方数据");
}else{ }else{
//检测是否为抄方订单
$transferInquiryOrder = $this->checkTransferInquiryOrder($order_inquiry);
if($transferInquiryOrder){
// 获取上报数据-处方 // 获取上报数据-处方
$report_prescription_data = $this->getReportPrescriptionData($order_inquiry, $order_prescription); $report_prescription_data = $this->getReportPrescriptionData($order_inquiry, $order_prescription);
}else{
// 获取上报数据-处方 (抄方类型)
$report_prescription_data = $this->getReportTransferPrescriptionData($order_inquiry, $order_prescription);
}
// 上报处方 // 上报处方
$regulatoryPlatform = new regulatoryPlatform(); $regulatoryPlatform = new regulatoryPlatform();
@ -516,6 +524,170 @@ class ReportRegulatoryCommand extends HyperfCommand
return $data; return $data;
} }
/**
* 获取上报数据-处方 (抄方类型)
* @param array|object $order_inquiry
* @param array|object $order_prescription
* @return bool|array
*/
private function getReportTransferPrescriptionData(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_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;
}
// 获取医生ca数据
$params = array();
$params['user_id'] = $user_doctor['user_id'];
$params['type'] = 2;
$params['is_latest'] = 1;
$doctor_user_ca_cert = UserCaCert::getOne($params);
if (empty($doctor_user_ca_cert)){
$this->line("错误无医生ca数据");
return false;
}
// 获取药师ca数据
$params = array();
$params['user_id'] = $user_pharmacist['user_id'];
$params['type'] = 2;
$params['is_latest'] = 1;
$pharmacist_user_ca_cert = UserCaCert::getOne($params);
if (empty($pharmacist_user_ca_cert)){
$this->line("错误无药师ca数据");
return false;
}
$data = array();
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
$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'] = "成都金牛欣欣相照互联网医院"; // 药师执业机构
$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; // 费别 1自费 2医保
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
$data['recipeTime'] = $order_prescription['doctor_created_time']; // 处方日期
$data['recipeType'] = 2; // 处方类型 1中药 2西药 3成药(三医)
$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']; // 医师ca签名值
$data['pharmacistCaSign'] = $pharmacist_user_ca_cert['cert_base64']; // 药师ca签名值
$data['recipeNo'] = $order_prescription['order_prescription_id']; // 医院处方编号
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
return $data;
}
/** /**
* 获取处方商品数据 * 获取处方商品数据
* @param string $order_prescription_id * @param string $order_prescription_id