删除自动开方时增加上报处方数据。增加自动结束时上报处方数据,修改上报处方脚本
This commit is contained in:
@@ -54,44 +54,142 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
}
|
||||
|
||||
foreach ($report_regulatorys as $report_regulatory){
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $report_regulatory['order_prescription_id'];
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
// 无处方数据,不处理
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
// 无处方数据,不处理
|
||||
continue;
|
||||
}
|
||||
|
||||
$order_inquiry = $order_inquiry->toArray();
|
||||
|
||||
$res = $this->checkInquiryOrder($order_inquiry);
|
||||
if (!$res) {
|
||||
// 问诊订单数据不符合条件,不执行
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->line("开始:" . $report_regulatory['report_regulatory_id']);
|
||||
|
||||
// 上报问诊
|
||||
if ($report_regulatory['report_inquiry_status'] != 1){
|
||||
$this->line("信息:上报问诊");
|
||||
$this->reportRegulatoryInquiry($report_regulatory,$order_inquiry,$order_prescription);
|
||||
try {
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $report_regulatory['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
// 问诊订单数据错误
|
||||
$this->line("问诊订单数据错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
$order_inquiry = $order_inquiry->toArray();
|
||||
|
||||
// 检测问诊订单
|
||||
$res = $this->checkInquiryOrder($order_inquiry);
|
||||
if (!$res) {
|
||||
continue;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line($e->getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
// 上报网络咨询
|
||||
try {
|
||||
if ($report_regulatory['report_consult_status'] != 1 && $report_regulatory['report_consult_int'] < 5){
|
||||
$this->line("上报网络咨询");
|
||||
|
||||
// 获取上报数据-网络咨询
|
||||
$consult_data = $this->getConsultData($order_inquiry);
|
||||
|
||||
// 上报网络咨询
|
||||
$regulatoryPlatform = new regulatoryPlatform();
|
||||
$result = $regulatoryPlatform->uploadConsult([$consult_data]);
|
||||
|
||||
$this->line("上报网络咨询成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 修改上报状态-网络咨询
|
||||
$res = $this->modifyReportConsultStatus($report_regulatory, 1);
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("上报成功,存储记录失败");
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line("上报网络咨询失败" . $e->getMessage());
|
||||
|
||||
// 上报失败
|
||||
$res = $this->modifyReportConsultStatus($report_regulatory, 2, $e->getMessage());
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("上报网络咨询失败,存储记录失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 上报复诊
|
||||
try {
|
||||
if ($report_regulatory['is_further_consult'] == 1){
|
||||
if ($report_regulatory['report_further_consult_status'] != 1 && $report_regulatory['report_further_consult_int'] < 5) {
|
||||
$this->line("上报复诊");
|
||||
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $report_regulatory['order_prescription_id'];
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
$this->line("需上报复诊,但无处方数据");
|
||||
}else{
|
||||
// 获取上报数据-复诊
|
||||
$further_consult_data = $this->getFurtherConsultData($order_inquiry,$order_prescription);
|
||||
|
||||
// 上报复诊
|
||||
$regulatoryPlatform = new regulatoryPlatform();
|
||||
$result = $regulatoryPlatform->uploadFurtherConsult([$further_consult_data]);
|
||||
$this->line("上报复诊成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 修改上报状态-复诊
|
||||
$res = $this->modifyReportFurtherConsultStatus($report_regulatory, 1);
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("上报成功,存储记录失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line("上报复诊失败" . $e->getMessage());
|
||||
|
||||
// 上报失败
|
||||
$res = $this->modifyReportFurtherConsultStatus($report_regulatory, 2, $e->getMessage());
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("上报复诊失败,存储记录失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 上报处方
|
||||
if ($report_regulatory['report_prescription_status'] != 1){
|
||||
$this->line("信息:上报处方");
|
||||
$this->reportRegulatoryPrescription($report_regulatory,$order_inquiry,$order_prescription);
|
||||
try {
|
||||
$this->line("上报处方");
|
||||
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $report_regulatory['order_prescription_id'];
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
$this->line("需上报复诊,但无处方数据");
|
||||
}else{
|
||||
// 获取上报数据-处方
|
||||
$report_prescription_data = $this->getReportPrescriptionData($order_inquiry, $order_prescription);
|
||||
|
||||
// 上报处方
|
||||
$regulatoryPlatform = new regulatoryPlatform();
|
||||
$result = $regulatoryPlatform->uploadRecipe([$report_prescription_data]);
|
||||
|
||||
$this->line("上报处方成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 上报成功
|
||||
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 1);
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("上报处方失败,存储记录失败");
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line("上报处方失败" . $e->getMessage());
|
||||
|
||||
// 上报失败
|
||||
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 2, $e->getMessage());
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("上报复诊失败,存储记录失败");
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
$this->line("结束:" . $report_regulatory['report_regulatory_id']);
|
||||
@@ -106,11 +204,7 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
*/
|
||||
private function getNotReportRegulatory(): array
|
||||
{
|
||||
$params = array();
|
||||
$params[] = ['report_inquiry_int','<',5];
|
||||
$params[] = ['report_prescription_int','<',5];
|
||||
|
||||
$report_regulatory = ReportRegulatory::getNotReportList($params,['*']);
|
||||
$report_regulatory = ReportRegulatory::getNotReportList();
|
||||
if (empty($report_regulatory)){
|
||||
return [];
|
||||
}else{
|
||||
@@ -119,48 +213,13 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测执行次数
|
||||
* @param string $key
|
||||
* @return bool
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function checkHandleNumber(string $key): bool
|
||||
{
|
||||
try {
|
||||
$redis = $this->container->get(Redis::class);
|
||||
|
||||
$redis_key = "ReportRegulatoryInquiry" . $key;
|
||||
$redis_value = $redis->get($redis_key);
|
||||
if (empty($redis_value)) {
|
||||
$redis->set($redis_key, 1, 60 * 60 * 24 * 10);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 执行次数过多
|
||||
if ($redis_value > 5) {
|
||||
// 加入短信队列,通知管理员
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$redis->incr($redis_key);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改上报问诊数据
|
||||
* 修改上报状态-网络咨询
|
||||
* @param array|object $report_regulatory
|
||||
* @param int $report_inquiry_status 问诊上报状态(0:未上报 1:已上报 2:上报失败)
|
||||
* @param int $report_inquiry_type 问诊上报类型(1:网络初诊 2:网络复诊)
|
||||
* @param string $report_inquiry_fail_reason 问诊上报失败原因
|
||||
* @param int $report_consult_status 上报网络咨询状态(0:未上报 1:已上报 2:上报失败)
|
||||
* @param string $report_consult_fail_reason 网络咨询上报失败原因
|
||||
* @return bool
|
||||
*/
|
||||
private function modifyReportRegulatoryInquiry(array|object $report_regulatory, int $report_inquiry_status, int $report_inquiry_type, string $report_inquiry_fail_reason = ""): bool
|
||||
private function modifyReportConsultStatus(array|object $report_regulatory, int $report_consult_status,string $report_consult_fail_reason = ""): bool
|
||||
{
|
||||
try {
|
||||
// 修改
|
||||
@@ -168,14 +227,41 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
$params['report_regulatory_id'] = $report_regulatory['report_regulatory_id'];
|
||||
|
||||
$data = array();
|
||||
$data['report_inquiry_status'] = $report_inquiry_status;
|
||||
$data['report_inquiry_int'] = $report_regulatory['report_inquiry_int'] + 1;
|
||||
$data['report_inquiry_type'] = $report_inquiry_type;
|
||||
$data['report_inquiry_time'] = date('Y-m-d H:i:s', time());
|
||||
$data['report_inquiry_fail_reason'] = $report_inquiry_fail_reason;
|
||||
$data['report_consult_status'] = $report_consult_status;
|
||||
$data['report_consult_int'] = $report_regulatory['report_consult_int'] + 1;
|
||||
$data['report_consult_time'] = date('Y-m-d H:i:s', time());
|
||||
$data['report_consult_fail_reason'] = $report_consult_fail_reason;
|
||||
ReportRegulatory::edit($params, $data);
|
||||
} catch (\Exception $e) {
|
||||
$this->line("失败:" . $e->getMessage());
|
||||
$this->line($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改上报状态-复诊
|
||||
* @param array|object $report_regulatory
|
||||
* @param int $report_further_consult_status 上报网络复诊状态(0:未上报 1:已上报 2:上报失败)
|
||||
* @param string $report_further_consult_fail_reason 网络复诊上报失败原因
|
||||
* @return bool
|
||||
*/
|
||||
private function modifyReportFurtherConsultStatus(array|object $report_regulatory, int $report_further_consult_status,string $report_further_consult_fail_reason = ""): bool
|
||||
{
|
||||
try {
|
||||
// 修改
|
||||
$params = array();
|
||||
$params['report_regulatory_id'] = $report_regulatory['report_regulatory_id'];
|
||||
|
||||
$data = array();
|
||||
$data['report_further_consult_status'] = $report_further_consult_status;
|
||||
$data['report_further_consult_int'] = $report_regulatory['report_further_consult_int'] + 1;
|
||||
$data['report_further_consult_time'] = date('Y-m-d H:i:s', time());
|
||||
$data['report_further_consult_fail_reason'] = $report_further_consult_fail_reason;
|
||||
ReportRegulatory::edit($params, $data);
|
||||
} catch (\Exception $e) {
|
||||
$this->line($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -228,7 +314,7 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
|
||||
// 已取消状态,查看是否完成后取消的
|
||||
if ($order_inquiry['inquiry_status'] == 7 && $order_inquiry['cancel_reason'] != 4 && empty($order_inquiry['complete_time'])) {
|
||||
$this->line("信息:订单为取消的未完成订单,不执行");
|
||||
$this->line("信息:订单未取消的未完成订单,不执行");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -236,291 +322,7 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测患者是否首次问诊-是否开具过处方
|
||||
* @param string $patient_id
|
||||
* @param string $order_prescription_id
|
||||
* @return bool true:首次 false:复诊
|
||||
*/
|
||||
private function checkPatientFirstInquiry(string $patient_id, string $order_prescription_id): bool
|
||||
{
|
||||
$params = array();
|
||||
$params['patient_id'] = $patient_id;
|
||||
$params['pharmacist_audit_status'] = 1;
|
||||
|
||||
$prescription_status_params = [2, 3, 4];
|
||||
$order_prescriptions = OrderPrescription::getStatusList($params, $prescription_status_params);
|
||||
if (empty($order_prescriptions)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($order_prescriptions as $item) {
|
||||
if ($item['order_prescription_id'] == $order_prescription_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 开具过处方
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上报监管数据-问诊
|
||||
* @param array|object $order_inquiry
|
||||
* @param array|object $order_prescription
|
||||
* @param bool $is_first 是否首次问诊 true:是 1:否
|
||||
* @return bool|array
|
||||
*/
|
||||
private function getReportInquiryData(array|object $order_inquiry, array|object $order_prescription, bool $is_first = true): bool|array
|
||||
{
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
$this->line("错误:医生数据错误");
|
||||
return false;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['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;
|
||||
}
|
||||
|
||||
if ($is_first) {
|
||||
$this->line("信息:患者首次问诊");
|
||||
// 初诊
|
||||
// 网络咨询(网络门诊)服务
|
||||
$data = array();
|
||||
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
||||
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
||||
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
||||
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
||||
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
||||
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
||||
$data['docName'] = $user_doctor['user_name'];// 姓名(医师、护师、技师)
|
||||
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
||||
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
||||
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
||||
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
||||
$data['patientIdcardType'] = 1; // 证件类型
|
||||
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
||||
$data['serviceType'] = 1; // 服务类型 1网络咨询 2网络门诊
|
||||
$data['consultNo'] = $order_inquiry['inquiry_no']; // 网络咨询或网络门诊编号 订单编号
|
||||
$data['consultType'] = 1; // 咨询类别 1、图文咨询 2语音咨询3、视频咨询
|
||||
$data['consultApplyTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['created_at'])); // 咨询申请时间
|
||||
$data['consultStartTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['reception_time'])); // 咨询开始时间
|
||||
$data['consultEndTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['complete_time'])); // 咨询结束时间
|
||||
$data['feeType'] = 1; // 费别 1自费 2医保
|
||||
$data['price'] = $order_inquiry['payment_amount_total']; // 咨询价格 元
|
||||
$data['isReply'] = 1; //咨询是否回复 0未回复 1已回复
|
||||
$data['patientEvaluate'] = 1; //患者满意度 1-5 1代表非常满意 5代表非常不满意
|
||||
$data['complainInfo'] = "无"; //投诉举报信息
|
||||
$data['disposeResult'] = "无"; //处理结果信息
|
||||
$data['isRiskWarn'] = 1; //是否进行诊前风险提示 0否 1是
|
||||
$data['isPatientSign'] = 1; //是否确认患者为签约对象 0否 1是
|
||||
$data['uploadTime'] = date('Y-m-d H:i:s', time()); //上传时间
|
||||
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
||||
$data['docAdvice'] = $order_prescription['doctor_advice'] ?? "无"; // 医生建议描述 医嘱
|
||||
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
||||
$data['isMark'] = 1;//是否留痕 1:代表留痕;0代表未留痕
|
||||
} else {
|
||||
$this->line("信息:患者复诊");
|
||||
// 获取患者首次问诊病例数据
|
||||
$params = array();
|
||||
$params['patient_id'] = $order_inquiry['patient_id'];
|
||||
$params['pharmacist_audit_status'] = 1;
|
||||
|
||||
$prescription_status_params = [2, 3, 4];
|
||||
$first_order_prescription = OrderPrescription::getStatusOne($params, $prescription_status_params);
|
||||
if (empty($first_order_prescription)) {
|
||||
// 复诊,但是未找到复诊处方单
|
||||
$this->line("错误:无初诊处方单");
|
||||
return false;
|
||||
}
|
||||
|
||||
$first_order_prescription = $first_order_prescription->toArray();
|
||||
|
||||
// 获取患者初诊疾病诊断数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $first_order_prescription['order_prescription_id'];
|
||||
$first_order_prescription_icd = OrderPrescriptionIcd::getList($params);
|
||||
if (empty($first_order_prescription_icd)) {
|
||||
// 复诊,但是未找到关联疾病
|
||||
$this->line("错误:无初诊疾病诊断数据");
|
||||
return false;
|
||||
}
|
||||
|
||||
$first_icd_name_data = array_column($first_order_prescription_icd->toArray(), 'icd_name');
|
||||
if (empty($first_icd_name_data)){
|
||||
// 复诊,但是未找到关联疾病
|
||||
$this->line("错误:无初诊疾病诊断数据");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count($first_icd_name_data) > 1) {
|
||||
$first_icd_name = implode('|', $first_icd_name_data);
|
||||
} else {
|
||||
$first_icd_name = $first_icd_name_data[0];
|
||||
}
|
||||
|
||||
// 获取患者复诊疾病诊断数据
|
||||
$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];
|
||||
}
|
||||
}
|
||||
|
||||
// icd编码
|
||||
$icd_code_data = array_column($order_prescription_icd->toArray(), 'icd_code');
|
||||
if (!empty($icd_code_data)) {
|
||||
if (count($icd_code_data) > 1) {
|
||||
$icd_code = implode('|', $icd_code_data);
|
||||
} else {
|
||||
$icd_code = $icd_code_data[0];
|
||||
}
|
||||
}
|
||||
|
||||
// 网络复诊服务
|
||||
$data = array();
|
||||
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
||||
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
||||
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
||||
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
||||
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
||||
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
||||
$data['docName'] = $user_doctor['user_name'];// 复诊医师姓名
|
||||
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
||||
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
||||
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
||||
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
||||
$data['patientIdcardType'] = 1; // 证件类型
|
||||
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
||||
$data['furtherConsultNo'] = $order_inquiry['order_inquiry_id']; // 网络复诊编号
|
||||
$data['furtherConsulType'] = "1"; // 复诊类别 1、图文诊疗 2、语音诊疗 3、视频诊疗
|
||||
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
||||
$data['consultDiagnosisType'] = 1; // 首诊诊断类型
|
||||
$data['consultDiagnosis'] = $first_icd_name; // 首诊诊断 复诊患者在首诊医院的诊断,如有多条,使用“|”进行分隔;当传图片时,需要传图片的base64字符串
|
||||
$data['consultTime'] = date('Y-m-d H:i:s',strtotime($first_order_prescription['doctor_created_time'])); // 首诊时间
|
||||
$data['consultOrg'] = "成都金牛欣欣相照互联网医院"; // 首诊机构
|
||||
$data['furtherConsultApplyTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['created_at'])); // 复诊申请时间
|
||||
$data['furtherConsulStartTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['reception_time'])); // 复诊开始时间
|
||||
$data['furtherConsulEndTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['complete_time'])); // 复诊结束时间
|
||||
$data['furtherConsulIsReply'] = 1; // 复诊是否回复 0未回复 1已回复
|
||||
$data['feeType'] = 1; // 费别 1自费 2医保
|
||||
$data['furtherConsultDiagnosis'] = $icd_name; // 复诊诊断 复诊患者在实体医院的诊断名称,如有多条,使用“|”进行分隔
|
||||
$data['furtherConsultDiagnosisNo'] = $icd_code; // 复诊icd诊断编码
|
||||
$data['furtherConsultPrice'] = $order_inquiry['payment_amount_total']; // 复诊价格
|
||||
$data['patientEvaluate'] = 1; // 患者满意度 1-5 1代表非常满意 5代表非常不满意
|
||||
$data['complainInfo'] = "无"; // 投诉举报信息
|
||||
$data['disposeResult'] = "无"; // 处理结果信息
|
||||
$data['isRiskWarn'] = 1; // 是否进行诊前风险提示 0否 1是
|
||||
$data['isPatientSign'] = 1; // 是否确认患者为签约对象 0否 1是
|
||||
$data['isPrescription'] = 1; // 是否开具处方 0否 1是
|
||||
$data['uploadTime'] = date('Y-m-d H:i:s', time()); // 上传时间
|
||||
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
||||
$data['isMark'] = 1;//是否留痕 1:代表留痕;0代表未留痕
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报问诊
|
||||
* @param array|object $report_regulatory
|
||||
* @param array|object $order_inquiry
|
||||
* @param array|object $order_prescription
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function reportRegulatoryInquiry(array|object $report_regulatory,array|object $order_inquiry,array|object $order_prescription): void
|
||||
{
|
||||
if($report_regulatory['report_inquiry_int'] >= 5){
|
||||
$this->line("错误:超出最大执行次数,本条不执行");
|
||||
return ;
|
||||
}
|
||||
|
||||
// 检测患者是否首次问诊
|
||||
$is_first = $this->checkPatientFirstInquiry($order_prescription['patient_id'], $order_prescription['order_prescription_id']);
|
||||
|
||||
try {
|
||||
// 获取上报监管数据-问诊
|
||||
$report_inquiry_data = $this->getReportInquiryData($order_inquiry, $order_prescription, $is_first);
|
||||
|
||||
// 上报监管平台-问诊
|
||||
$regulatoryPlatform = new regulatoryPlatform();
|
||||
if ($is_first) {
|
||||
$result = $regulatoryPlatform->uploadConsult([$report_inquiry_data]);
|
||||
} else {
|
||||
$result = $regulatoryPlatform->uploadFurtherConsult([$report_inquiry_data]);
|
||||
}
|
||||
|
||||
$this->line("信息:上报成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 上报成功
|
||||
$res = $this->modifyReportRegulatoryInquiry($report_regulatory, 1, $is_first ? 1 : 2);
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("错误:上报成功,存储记录失败");
|
||||
return;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->line("错误:" . $e->getMessage());
|
||||
// 上报失败
|
||||
$res = $this->modifyReportRegulatoryInquiry($report_regulatory, 2, $is_first ? 1 : 2, $e->getMessage());
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("错误:上报失败,存储记录失败");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上报监管数据-处方
|
||||
* 获取上报数据-处方
|
||||
* @param array|object $order_inquiry
|
||||
* @param array|object $order_prescription
|
||||
* @return bool|array
|
||||
@@ -659,51 +461,6 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报处方
|
||||
* @param array|object $report_regulatory
|
||||
* @param array|object $order_inquiry
|
||||
* @param array|object $order_prescription
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function reportRegulatoryPrescription(array|object $report_regulatory,array|object $order_inquiry,array|object $order_prescription): void
|
||||
{
|
||||
if ($report_regulatory['report_prescription_int'] >= 5){
|
||||
// 修改为上报失败
|
||||
$this->line("错误:超出最大执行次数,本条不执行");
|
||||
return ;
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取上报监管数据-处方
|
||||
$report_prescription_data = $this->getReportPrescriptionData($order_inquiry, $order_prescription);
|
||||
|
||||
// 上报监管平台-处方
|
||||
$regulatoryPlatform = new regulatoryPlatform();
|
||||
$result = $regulatoryPlatform->uploadRecipe([$report_prescription_data]);
|
||||
$this->line("信息:上报成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 上报成功
|
||||
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 1);
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("错误:上报成功,存储记录失败");
|
||||
return ;
|
||||
}
|
||||
}catch (\Exception $e){
|
||||
$this->line("错误:" . $e->getMessage());
|
||||
// 上报失败
|
||||
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 2, $e->getMessage());
|
||||
if (!$res) {
|
||||
// 记录失败
|
||||
$this->line("错误:上报失败,存储记录失败");
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取处方商品数据
|
||||
* @param string $order_prescription_id
|
||||
@@ -778,4 +535,214 @@ class ReportRegulatoryCommand extends HyperfCommand
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上报数据-网络咨询
|
||||
* @param array|object $order_inquiry
|
||||
* @return array
|
||||
*/
|
||||
private function getConsultData(array|object $order_inquiry): array
|
||||
{
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
$this->line("错误:医生数据错误");
|
||||
return [];
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (empty($user_doctor_info)) {
|
||||
$this->line("错误:医生详情数据错误");
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取医生自定义科室数据
|
||||
$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 [];
|
||||
}
|
||||
|
||||
// 获取问诊患者数据
|
||||
$params = array();
|
||||
$params['family_id'] = $order_inquiry['family_id'];
|
||||
$patient_family = PatientFamily::getOne($params);
|
||||
if (empty($patient_family)) {
|
||||
$this->line("错误:问诊患者数据错误");
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取患者问诊病例
|
||||
$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 [];
|
||||
}
|
||||
|
||||
// 网络咨询(网络门诊)服务
|
||||
$data = array();
|
||||
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
||||
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
||||
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
||||
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
||||
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
||||
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
||||
$data['docName'] = $user_doctor['user_name'];// 姓名(医师、护师、技师)
|
||||
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
||||
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
||||
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
||||
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
||||
$data['patientIdcardType'] = 1; // 证件类型
|
||||
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
||||
$data['serviceType'] = 1; // 服务类型 1网络咨询 2网络门诊
|
||||
$data['consultNo'] = $order_inquiry['inquiry_no']; // 网络咨询或网络门诊编号 订单编号
|
||||
$data['consultType'] = 1; // 咨询类别 1、图文咨询 2语音咨询3、视频咨询
|
||||
$data['consultApplyTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['created_at'])); // 咨询申请时间
|
||||
$data['consultStartTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['reception_time'])); // 咨询开始时间
|
||||
$data['consultEndTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['complete_time'])); // 咨询结束时间
|
||||
$data['feeType'] = 1; // 费别 1自费 2医保
|
||||
$data['price'] = $order_inquiry['payment_amount_total']; // 咨询价格 元
|
||||
$data['isReply'] = 1; //咨询是否回复 0未回复 1已回复
|
||||
$data['patientEvaluate'] = 1; //患者满意度 1-5 1代表非常满意 5代表非常不满意
|
||||
$data['complainInfo'] = "无"; //投诉举报信息
|
||||
$data['disposeResult'] = "无"; //处理结果信息
|
||||
$data['isRiskWarn'] = 1; //是否进行诊前风险提示 0否 1是
|
||||
$data['isPatientSign'] = 1; //是否确认患者为签约对象 0否 1是
|
||||
$data['uploadTime'] = date('Y-m-d H:i:s', time()); //上传时间
|
||||
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
||||
$data['docAdvice'] = $order_prescription['doctor_advice'] ?? "无"; // 医生建议描述 医嘱
|
||||
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
||||
$data['isMark'] = 1;//是否留痕 1:代表留痕;0代表未留痕
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上报数据-复诊
|
||||
* @param array|object $order_inquiry
|
||||
* @param array|object $order_prescription
|
||||
* @return array
|
||||
*/
|
||||
private function getFurtherConsultData(array|object $order_inquiry,array|object $order_prescription): array
|
||||
{
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
$this->line("医生数据错误");
|
||||
return [];
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (empty($user_doctor_info)) {
|
||||
$this->line("医生详情数据错误");
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取医生自定义科室数据
|
||||
$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 [];
|
||||
}
|
||||
|
||||
// 获取问诊患者数据
|
||||
$params = array();
|
||||
$params['family_id'] = $order_inquiry['family_id'];
|
||||
$patient_family = PatientFamily::getOne($params);
|
||||
if (empty($patient_family)) {
|
||||
$this->line("问诊患者数据错误");
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取患者问诊病例
|
||||
$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 [];
|
||||
}
|
||||
|
||||
// 获取患者复诊疾病诊断数据
|
||||
$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 [];
|
||||
}
|
||||
|
||||
$icd_name_data = array_column($order_prescription_icd->toArray(), 'icd_name');
|
||||
if (count($icd_name_data) > 1) {
|
||||
$icd_name = implode('|', $icd_name_data);
|
||||
} else {
|
||||
$icd_name = $icd_name_data[0];
|
||||
}
|
||||
|
||||
$icd_code_data = array_column($order_prescription_icd->toArray(), 'icd_code');
|
||||
if (count($icd_code_data) > 1) {
|
||||
$icd_code = implode('|', $icd_code_data);
|
||||
} else {
|
||||
$icd_code = $icd_code_data[0];
|
||||
}
|
||||
|
||||
// 网络复诊服务
|
||||
$data = array();
|
||||
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
||||
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
||||
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
||||
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
||||
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
||||
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
||||
$data['docName'] = $user_doctor['user_name'];// 复诊医师姓名
|
||||
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
||||
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
||||
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
||||
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
||||
$data['patientIdcardType'] = 1; // 证件类型
|
||||
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
||||
$data['furtherConsultNo'] = $order_inquiry['order_inquiry_id']; // 网络复诊编号
|
||||
$data['furtherConsulType'] = "1"; // 复诊类别 1、图文诊疗 2、语音诊疗 3、视频诊疗
|
||||
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
||||
$data['consultDiagnosisType'] = 1; // 首诊诊断类型
|
||||
$data['consultDiagnosis'] = $order_inquiry_case['disease_class_name']; // 首诊诊断 复诊患者在首诊医院的诊断,如有多条,使用“|”进行分隔;当传图片时,需要传图片的base64字符串
|
||||
$data['consultTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry_case['diagnosis_date'])); // 首诊时间(使用确诊时间)
|
||||
$data['consultOrg'] = "成都金牛欣欣相照互联网医院"; // 首诊机构
|
||||
$data['furtherConsultApplyTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['created_at'])); // 复诊申请时间
|
||||
$data['furtherConsulStartTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['reception_time'])); // 复诊开始时间
|
||||
$data['furtherConsulEndTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['complete_time'])); // 复诊结束时间
|
||||
$data['furtherConsulIsReply'] = 1; // 复诊是否回复 0未回复 1已回复
|
||||
$data['feeType'] = 1; // 费别 1:自费 2:医保
|
||||
$data['furtherConsultDiagnosis'] = $icd_name; // 复诊诊断 复诊患者在实体医院的诊断名称,如有多条,使用“|”进行分隔
|
||||
$data['furtherConsultDiagnosisNo'] = $icd_code; // 复诊icd诊断编码
|
||||
$data['furtherConsultPrice'] = $order_inquiry['payment_amount_total']; // 复诊价格
|
||||
$data['patientEvaluate'] = 1; // 患者满意度 1-5 1:代表非常满意 5:代表非常不满意
|
||||
$data['complainInfo'] = "无"; // 投诉举报信息
|
||||
$data['disposeResult'] = "无"; // 处理结果信息
|
||||
$data['isRiskWarn'] = 1; // 是否进行诊前风险提示 0否 1是
|
||||
$data['isPatientSign'] = 1; // 是否确认患者为签约对象 0否 1是
|
||||
$data['isPrescription'] = 1; // 是否开具处方 0否 1是
|
||||
$data['uploadTime'] = date('Y-m-d H:i:s', time()); // 上传时间
|
||||
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
||||
$data['isMark'] = 1;//是否留痕 1:代表留痕;0:代表未留痕
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user