From e2486d80472fee02aafbd588d1061ccf7e49e737 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 23 Mar 2023 16:14:38 +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=94=A8=E8=8D=AF=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/PatientFamilyController.php | 3 -- app/Model/OrderProduct.php | 53 ++++++++++++++++++++++ app/Model/PatientFamily.php | 5 -- app/Request/PatientFamilyRequest.php | 3 -- app/Services/PatientFamilyService.php | 28 ++++++++++-- 5 files changed, 78 insertions(+), 14 deletions(-) diff --git a/app/Controller/PatientFamilyController.php b/app/Controller/PatientFamilyController.php index 3a5b302..a1c150c 100644 --- a/app/Controller/PatientFamilyController.php +++ b/app/Controller/PatientFamilyController.php @@ -210,9 +210,6 @@ class PatientFamilyController extends AbstractController */ public function getFamilyProductRecord(): ResponseInterface { - $request = $this->container->get(PatientFamilyRequest::class); - $request->scene('getFamilyProductRecordList')->validateResolved(); - $patientFamilyService = new PatientFamilyService(); $data = $patientFamilyService->getFamilyProductRecord(); return $this->response->json($data); diff --git a/app/Model/OrderProduct.php b/app/Model/OrderProduct.php index faad5eb..1c16e2c 100644 --- a/app/Model/OrderProduct.php +++ b/app/Model/OrderProduct.php @@ -74,6 +74,30 @@ class OrderProduct extends Model return $this->HasMany(OrderProductItem::class, 'order_product_id','order_product_id'); } + /** + * 关联订单-处方表 + */ + public function OrderPrescription(): HasOne + { + return $this->hasOne(OrderPrescription::class, 'order_prescription_id','order_prescription_id'); + } + + /** + * 关联患者家庭成员信息表-基本信息 + */ + public function PatientFamily(): HasOne + { + return $this->hasOne(PatientFamily::class, 'family_id','family_id'); + } + + /** + * 关联处方关联疾病表 + */ + public function OrderPrescriptionIcd(): HasMany + { + return $this->HasMany(OrderPrescriptionIcd::class, 'order_prescription_id','order_prescription_id'); + } + /** * 获取信息-单条 * @param array $params @@ -162,4 +186,33 @@ class OrderProduct extends Model { return self::create($data); } + + + /** + * 患者用药记录查询 + * @param array $params + * @param array $fields + * @param int|null $page + * @param int|null $per_page + * @return array + */ + public static function getProductRecordPage(array $params,array $fields = ["*"], int $page = null, ?int $per_page = 10): array + { + $result = self::with([ + "OrderProductItem:product_item_id,order_product_id,product_id,product_name,amount,manufacturer,product_cover_img,product_spec", + "OrderPrescriptionIcd:prescription_icd_id,order_prescription_id,icd_id,icd_name", + "PatientFamily:family_id,card_name_mask,sex,age", + ]) + ->where($params) + ->paginate($per_page, $fields, "page", $page); + + $data = array(); + $data['current_page'] = $result->currentPage();// 当前页码 + $data['total'] = $result->total();// 数据总数 + $data['data'] = $result->items();// 数据 + $data['per_page'] = $result->perPage();// 每页个数 + $data['last_page'] = $result->lastPage();// 最后一页 + + return $data; + } } diff --git a/app/Model/PatientFamily.php b/app/Model/PatientFamily.php index d827bb0..ac46baa 100644 --- a/app/Model/PatientFamily.php +++ b/app/Model/PatientFamily.php @@ -54,11 +54,6 @@ class PatientFamily extends Model */ protected array $fillable = ['family_id', 'patient_id', 'relation', 'status', 'is_default', 'card_name', 'card_name_mask', 'mobile', 'mobile_mask', 'type', 'id_number', 'id_number_mask', 'sex', 'age', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'height', 'weight', 'marital_status', 'nation_id', 'nation_name', 'job_id', 'job_name', 'created_at', 'updated_at']; - /** - * The attributes that should be cast to native types. - */ - protected array $casts = ['family_id' => 'string', 'patient_id' => 'string', 'relation' => 'integer', 'status' => 'integer', 'is_default' => 'integer', 'type' => 'integer', 'sex' => 'integer', 'age' => 'integer', 'province_id' => 'integer', 'city_id' => 'integer', 'county_id' => 'integer', 'marital_status' => 'integer', 'nation_id' => 'integer', 'job_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime']; - protected string $primaryKey = "family_id"; /** diff --git a/app/Request/PatientFamilyRequest.php b/app/Request/PatientFamilyRequest.php index 05eafcc..741a2de 100644 --- a/app/Request/PatientFamilyRequest.php +++ b/app/Request/PatientFamilyRequest.php @@ -87,9 +87,6 @@ class PatientFamilyRequest extends FormRequest 'diagnosis_hospital',//确诊医院 'drugs_name', // 家族病史 ], - 'getFamilyProductRecord' => [ // 获取家庭成员用药记录列表 - 'family_id', - ], ]; /** diff --git a/app/Services/PatientFamilyService.php b/app/Services/PatientFamilyService.php index 87fbcca..9a3add0 100644 --- a/app/Services/PatientFamilyService.php +++ b/app/Services/PatientFamilyService.php @@ -6,6 +6,7 @@ use App\Constants\HttpEnumCode; use App\Model\BasicJob; use App\Model\BasicNation; use App\Model\DiseaseClass; +use App\Model\OrderProduct; use App\Model\PatientFamily as PatientFamilyModel; use App\Model\PatientFamilyHealth; use App\Model\PatientFamilyPersonal as PatientFamilyPersonalModel; @@ -859,16 +860,37 @@ class PatientFamilyService extends BaseService { $user_info = $this->request->getAttribute("userInfo"); - $family_id = $this->request->input('family_id'); + $family_id = $this->request->input('family_id',0); $page = $this->request->input('page', 1); $per_page = $this->request->input('per_page', 10); $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + if ($family_id != 0){ + $params['family_id'] = $user_info['family_id']; + } + $params['order_product_status'] = 4;// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消) + $params['pay_status'] = 2;// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + $fields = [ + 'order_product_id', + 'order_inquiry_id', + 'order_prescription_id', + 'family_id', + ]; - - return success(); + $result = OrderProduct::getProductRecordPage($params,$fields,$page,$per_page); + if (!empty($result['data'])){ + foreach ($result['data'] as &$item){ + if (!empty($item['OrderProductItem'])){ + foreach ($item['OrderProductItem'] as &$order_product_item){ + $order_product_item['product_cover_img'] = addAliyunOssWebsite($order_product_item['product_cover_img']); + } + } + } + } + return success($result); } } \ No newline at end of file