From 45e4fa886b3d15933b4d19c3914e1f55f5c84f88 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Tue, 21 Nov 2023 10:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AE=B6=E5=BA=AD=E6=88=90=E5=91=98=E7=97=85=E6=83=85=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatientPathographyController.php | 17 +++- app/Request/PatientPathographyRequest.php | 2 +- app/Services/PatientPathographyService.php | 96 ++++++++++++++++++- config/routes.php | 5 +- 4 files changed, 113 insertions(+), 7 deletions(-) diff --git a/app/Controller/PatientPathographyController.php b/app/Controller/PatientPathographyController.php index 46cb092..a885951 100644 --- a/app/Controller/PatientPathographyController.php +++ b/app/Controller/PatientPathographyController.php @@ -33,7 +33,7 @@ class PatientPathographyController extends AbstractController * 获取家庭成员病情记录列表-分页 * @return ResponseInterface */ - public function getFamilyPathographyList(): ResponseInterface + public function getFamilyPathographyPage(): ResponseInterface { try { $request = $this->container->get(PatientPathographyRequest::class); @@ -41,12 +41,21 @@ class PatientPathographyController extends AbstractController return $this->response->json(fail()); } - $request->scene('getFamilyPathographyList')->validateResolved(); + $request->scene('getFamilyPathographyPage')->validateResolved(); $PatientPathographyService = new PatientPathographyService(); - $data = $PatientPathographyService->getFamilyPathographyList(); + $data = $PatientPathographyService->getFamilyPathographyPage(); return $this->response->json($data); + } - + /** + * 获取家庭成员病情记录详情 + * @return ResponseInterface + */ + public function getFamilyPathographyInfo(): ResponseInterface + { + $PatientPathographyService = new PatientPathographyService(); + $data = $PatientPathographyService->getFamilyPathographyInfo(); + return $this->response->json($data); } } \ No newline at end of file diff --git a/app/Request/PatientPathographyRequest.php b/app/Request/PatientPathographyRequest.php index 41cc22c..5688039 100644 --- a/app/Request/PatientPathographyRequest.php +++ b/app/Request/PatientPathographyRequest.php @@ -11,7 +11,7 @@ class PatientPathographyRequest extends FormRequest 'existFamilyPathography' => [ // 检测家庭成员是否存在病情记录 'family_id', ], - 'getFamilyPathographyList' => [ // 获取家庭成员病情记录列表-分页 + 'getFamilyPathographyPage' => [ // 获取家庭成员病情记录列表-分页 'family_id', ], ]; diff --git a/app/Services/PatientPathographyService.php b/app/Services/PatientPathographyService.php index 41a313e..a610c81 100644 --- a/app/Services/PatientPathographyService.php +++ b/app/Services/PatientPathographyService.php @@ -3,8 +3,14 @@ namespace App\Services; use App\Constants\HttpEnumCode; +use App\Model\OrderPrescription; +use App\Model\OrderPrescriptionIcd; +use App\Model\OrderPrescriptionProduct; use App\Model\OrderProduct; use App\Model\PatientPathography; +use App\Model\PatientPathographyProduct; +use App\Model\Product; +use App\Utils\PcreMatch; /** * 家庭成员病情记录 @@ -40,7 +46,7 @@ class PatientPathographyService extends BaseService * 获取家庭成员病情记录列表-分页 * @return array */ - public function getFamilyPathographyList(): array + public function getFamilyPathographyPage(): array { $user_info = $this->request->getAttribute("userInfo") ?? []; $family_id = $this->request->input('family_id'); @@ -63,4 +69,92 @@ class PatientPathographyService extends BaseService return success($patient_pathographys); } + + /** + * 获取家庭成员病情记录详情 + * @return array + */ + public function getFamilyPathographyInfo(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + $pathography_id = $this->request->route('pathography_id'); + + $params = array(); + $params['user_id'] = $user_info['user_id']; + $params['patient_id'] = $user_info['client_user_id']; + $params['pathography_id'] = $pathography_id; + $patient_pathography = PatientPathography::getOne($params); + if (empty($patient_pathography)){ + return success(null); + } + + $result = $patient_pathography->toArray(); + $result['order_prescription'] = null; // 处方数据 + $result['patient_pathography_product'] = array(); // 用药意向 + $result['diagnose_images'] = array(); // 复诊凭证 + + // 获取处方数据 + if (!empty($patient_pathography['order_prescription_id'])){ + $params = array(); + $params['order_prescription_id'] = $patient_pathography['order_prescription_id']; + $params['patient_id'] = $patient_pathography['patient_id']; + $params['family_id'] = $patient_pathography['family_id']; + $order_prescription = OrderPrescription::getOne($params); + if (!empty($order_prescription)){ + // 获取处方疾病数据 + $params = array(); + $params['order_prescription_id'] = $order_prescription['order_prescription_id']; + $order_prescription_icds = OrderPrescriptionIcd::getList($params); + if (empty($order_prescription_icds)){ + return fail(); + } + + $icd_name = array_column($order_prescription_icds->toArray(),"icd_name"); + $result['order_prescription']['icd_name'] = implode(";",$icd_name); + + // 获取处方药品名称 + $params = array(); + $params['order_prescription_id'] = $order_prescription['order_prescription_id']; + $order_prescription_products = OrderPrescriptionProduct::getList($params); + if (empty($order_prescription_products)){ + return fail(); + } + + $result["order_prescription"]["product"] = $order_prescription_products->toArray(); + } + } + + // 获取用药意向 + $params = array(); + $params['pathography_id'] = $patient_pathography['pathography_id']; + $patient_pathography_products = PatientPathographyProduct::getList($params); + if (!empty($patient_pathography_products)){ + foreach ($patient_pathography_products as $patient_pathography_product){ + // 获取商品数据 + $params =array(); + $params['product_id'] = $patient_pathography_product['product_id']; + $product = Product::getOne($params); + if (empty($product)){ + return fail(); + } + + $item = array(); + $item['product_cover_img'] = addAliyunOssWebsite($product['product_cover_img']); + $item['product_name'] = $product['product_name']; // 名称 + $item['product_spec'] = $product['product_spec']; // 商品规格 + $item['packaging_unit'] = $product['packaging_unit']; // 基本包装单位(例:盒/瓶) + $item['case_product_num'] = $patient_pathography_product['case_product_num']; // 药品数量 + + $result['patient_pathography_product'][] = $item; + } + } + + // 复诊凭证 + if (!empty($patient_pathography['diagnose_images'])){ + $diagnose_images = implode(',', $patient_pathography['diagnose_images']); + $result['diagnose_images'] = PcreMatch::pregRemoveOssWebsite($diagnose_images); + } + + return success($result); + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 00ffcd3..c55ac89 100644 --- a/config/routes.php +++ b/config/routes.php @@ -388,7 +388,10 @@ Router::addGroup('/patient', function () { Router::get('/exist', [PatientPathographyController::class, 'existFamilyPathography']); // 获取家庭成员病情记录列表-分页 - Router::get('', [PatientPathographyController::class, 'getFamilyPathographyList']); + Router::get('', [PatientPathographyController::class, 'getFamilyPathographyPage']); + + // 获取家庭成员病情记录详情 + Router::get('/{pathography_id:\d+}', [PatientPathographyController::class, 'getFamilyPathographyInfo']); }); });