From e047f4971c491d49f5157c79ad35ba4f099f2724 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Wed, 1 Mar 2023 15:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8E=B7=E5=8F=96=E5=A4=84?= =?UTF-8?q?=E6=96=B9=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/UserDoctorController.php | 16 ++++++++++ app/Model/OrderPrescriptionIcd.php | 38 ++++++++++++++++++++--- app/Model/OrderPrescriptionProduct.php | 30 ++++++++++++++++-- app/Model/Product.php | 20 ++++++++++++ app/Request/UserDoctorRequest.php | 4 +++ app/Services/BasicDataService.php | 6 ++-- app/Services/OrderPrescriptionService.php | 15 +++++---- app/Services/UserDoctorService.php | 25 ++++++++++++++- config/routes.php | 4 ++- 9 files changed, 138 insertions(+), 20 deletions(-) diff --git a/app/Controller/UserDoctorController.php b/app/Controller/UserDoctorController.php index 6d4a19e..e1a306c 100644 --- a/app/Controller/UserDoctorController.php +++ b/app/Controller/UserDoctorController.php @@ -239,4 +239,20 @@ class UserDoctorController extends AbstractController $data = $UserDoctorService->getPrescriptionInfo(); return $this->response->json($data); } + + /** + * 修改处方 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function putPrescription(): ResponseInterface + { + $request = $this->container->get(UserDoctorRequest::class); + $request->scene('putPrescription')->validateResolved(); + + $UserDoctorService = new UserDoctorService(); + $data = $UserDoctorService->putPrescription(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Model/OrderPrescriptionIcd.php b/app/Model/OrderPrescriptionIcd.php index f277949..2fdd38d 100644 --- a/app/Model/OrderPrescriptionIcd.php +++ b/app/Model/OrderPrescriptionIcd.php @@ -6,6 +6,7 @@ namespace App\Model; +use Hyperf\Database\Model\Collection; use Hyperf\Snowflake\Concern\Snowflake; /** @@ -31,10 +32,37 @@ class OrderPrescriptionIcd extends Model */ protected array $fillable = ['prescription_icd_id', 'order_prescription_id', 'icd_id', 'icd_name', 'icd_code', 'created_at', 'updated_at']; - /** - * The attributes that should be cast to native types. - */ - protected array $casts = ['prescription_icd_id' => 'integer', 'order_prescription_id' => 'integer', 'icd_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime']; - protected string $primaryKey = "prescription_icd_id"; + + /** + * 获取信息-单条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getOne(array $params, array $fields = ['*']): object|null + { + return self::where($params)->first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 获取是否存在 + * @param array $params + * @return bool + */ + public static function getExists(array $params): bool + { + return self::where($params)->exists(); + } } diff --git a/app/Model/OrderPrescriptionProduct.php b/app/Model/OrderPrescriptionProduct.php index f64eed4..3762851 100644 --- a/app/Model/OrderPrescriptionProduct.php +++ b/app/Model/OrderPrescriptionProduct.php @@ -15,8 +15,18 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property int $order_prescription_id 订单-处方id * @property int $product_id 商品id * @property int $prescription_product_num 商品数量 + * @property string $product_name 商品名称 + * @property string $product_spec 商品规格 + * @property string $license_number 批准文号 + * @property string $manufacturer 生产厂家 + * @property string $single_unit 单次剂量(例:1次1包) + * @property string $single_use 单次用法(例:口服) + * @property string $packaging_unit 基本包装单位(例:盒/瓶) + * @property string $frequency_use 使用频率(例:1天3次) + * @property int $available_days 可用天数(3) * @property \Carbon\Carbon $created_at 创建时间 * @property \Carbon\Carbon $updated_at 修改时间 + * @property-read Product $Product */ class OrderPrescriptionProduct extends Model { @@ -30,7 +40,7 @@ class OrderPrescriptionProduct extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['prescription_product_id', 'order_prescription_id', 'product_id', 'prescription_product_num', 'created_at', 'updated_at']; + protected array $fillable = ['prescription_product_id', 'order_prescription_id', 'product_id', '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 string $primaryKey = "prescription_product_id"; /** @@ -75,16 +85,32 @@ class OrderPrescriptionProduct extends Model /** * 获取数据-关联商品表 + * 限制数量 * @param array $params * @param array $fields * @return Collection|array */ - public static function getWithProductList(array $params = [], array $fields = ['*']): Collection|array + public static function getWithProductLimit(array $params = [], array $fields = ['*']): Collection|array { return self::with([ "Product" ]) ->where($params) + ->limit(10) + ->get($fields); + } + + /** + * 获取数据 + * 限制数量 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getLimit(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params) + ->limit(10) ->get($fields); } } diff --git a/app/Model/Product.php b/app/Model/Product.php index 0a82844..c2745ce 100644 --- a/app/Model/Product.php +++ b/app/Model/Product.php @@ -93,4 +93,24 @@ class Product extends Model { return self::where($params)->get($fields); } + + /** + * 获取关键字搜索列表 + * @param array $params + * @param string $keyword + * @param array $fields + * @return Collection|array + */ + public static function getSearchKeywordList(array $params = [],string $keyword = '',array $fields = ['*']): Collection|array + { + return self::when($keyword, function ($query, $keyword) { + $query->where(function ($query) use ($keyword) { + $query->orwhere("product_name", 'like', '%' . $keyword . '%'); + $query->orwhere("common_name", 'like', '%' . $keyword . '%'); + $query->orwhere("mnemonic_code", 'like', '%' . $keyword . '%'); + }); + }) + ->where($params) + ->get($fields); + } } diff --git a/app/Request/UserDoctorRequest.php b/app/Request/UserDoctorRequest.php index 3c88fdd..c9ac080 100644 --- a/app/Request/UserDoctorRequest.php +++ b/app/Request/UserDoctorRequest.php @@ -58,6 +58,10 @@ class UserDoctorRequest extends FormRequest 'order_inquiry_id', 'order_prescription_id', // 处方id(非必须) ], + 'putPrescription' => [ // 修改处方 + 'order_prescription_id', + 'order_prescription_id', + ], ]; /** diff --git a/app/Services/BasicDataService.php b/app/Services/BasicDataService.php index b367a7f..02d46fa 100644 --- a/app/Services/BasicDataService.php +++ b/app/Services/BasicDataService.php @@ -212,10 +212,10 @@ class BasicDataService extends BaseService 'frequency_use', 'available_days', ]; - $params = array(); - $params[] = ['product_name', 'like', '%' . $product_keyword . '%']; - $product = Product::getList($params, $fields); + $params = array(); + + $product = Product::getSearchKeywordList($params, $product_keyword,$fields); if (empty($product)) { return success(); } diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index d85e676..2e8cd9e 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -70,7 +70,7 @@ class OrderPrescriptionService extends BaseService $params = array(); $params['order_inquiry_id'] = $order_inquiry_id; $params['order_prescription_id'] = $order_prescription_id; - $order_prescription_products = OrderPrescriptionProduct::getWithProductList($params); + $order_prescription_products = OrderPrescriptionProduct::getLimit($params); if(empty($order_prescription_products)){ return []; } @@ -82,13 +82,12 @@ class OrderPrescriptionService extends BaseService $data['prescription_product_id'] = $order_prescription_product['prescription_product_id']; $data['product_id'] = $order_prescription_product['product_id']; $data['prescription_product_num'] = $order_prescription_product['prescription_product_num']; - $data['product_name'] = $order_prescription_product['Product']['product_name']; - $data['product_cover_img'] = addAliyunOssWebsite($order_prescription_product['Product']['product_cover_img']); - $data['product_spec'] = $order_prescription_product['Product']['product_spec']; - $data['single_unit'] = $order_prescription_product['Product']['single_unit']; - $data['single_use'] = $order_prescription_product['Product']['single_use']; - $data['packaging_unit'] = $order_prescription_product['Product']['packaging_unit']; - $data['frequency_use'] = $order_prescription_product['Product']['frequency_use']; + $data['product_name'] = $order_prescription_product['product_name'] ?? ""; + $data['product_spec'] = $order_prescription_product['product_spec'] ?? ""; + $data['single_unit'] = $order_prescription_product['single_unit'] ?? ""; + $data['single_use'] = $order_prescription_product['single_use'] ?? ""; + $data['packaging_unit'] = $order_prescription_product['packaging_unit'] ?? ""; + $data['frequency_use'] = $order_prescription_product['frequency_use'] ?? ""; $result[] = $data; } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index d0ad601..57bab37 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -18,6 +18,7 @@ use App\Model\OrderEvaluation; use App\Model\OrderInquiry; use App\Model\OrderInquiryCase; use App\Model\OrderPrescription; +use App\Model\OrderPrescriptionIcd; use App\Model\OrderProductItem; use App\Model\User; use App\Model\UserDoctor; @@ -851,17 +852,39 @@ class UserDoctorService extends BaseService $order_prescription_product = $OrderPrescriptionService->getproductList($order_inquiry_id,$order_prescription_id); // 获取处方关联疾病表 + $fields = [ + 'prescription_icd_id', + 'icd_id', + 'icd_name', + ]; + $params = array(); + $params['order_prescription_id'] = $order_prescription_id; + $order_prescription_icd = OrderPrescriptionIcd::getList($params,$fields); } $result = array(); $result['inquiry_case_product'] = $inquiry_case_product;// 用药意向 - $result['order_prescription_product'] = $order_prescription_product ?? [];// 开方药品 + $result['prescription_product'] = $order_prescription_product ?? [];// 开方药品 $result['case'] = $order_inquiry_case;// 病例数据 + $result['prescription_icd'] = $order_prescription_icd ?? [];// 处方诊断疾病 $result['prescription']['doctor_advice'] = $order_prescription['doctor_advice'] ?? "";// 医嘱 return success($result); } + /** + * 修改处方 + * @return array + */ + public function putPrescription(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_inquiry_id = $this->request->input('order_inquiry_id'); + $order_prescription_id = $this->request->input('order_prescription_id'); + return success(); + } + /** * 检测医生身份认证 * @param object|array $user_doctor 医生表数据 diff --git a/config/routes.php b/config/routes.php index 0ed2db1..cb808bf 100644 --- a/config/routes.php +++ b/config/routes.php @@ -18,7 +18,6 @@ use App\Controller\IndexController; use App\Controller\InquiryController; use App\Controller\LoginController; use App\Controller\CodeController; -use App\Controller\OrderInquiryController; use App\Controller\PatientCaseController; use App\Controller\PatientCenterController; use App\Controller\PatientDoctorController; @@ -135,6 +134,9 @@ Router::addGroup('/doctor', function () { // 获取处方详情 Router::get('/info', [UserDoctorController::class, 'getPrescriptionInfo']); + + // 修改处方 + Router::put('', [UserDoctorController::class, 'putPrescription']); }); // 常用语