diff --git a/app/Controller/InquiryController.php b/app/Controller/InquiryController.php index 371f352..2912507 100644 --- a/app/Controller/InquiryController.php +++ b/app/Controller/InquiryController.php @@ -3,9 +3,7 @@ namespace App\Controller; use App\Request\InquiryRequest; -use App\Request\OrderInquiryRequest; use App\Services\InquiryService; -use App\Services\OrderInquiryService; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Psr\Http\Message\ResponseInterface; @@ -40,4 +38,15 @@ class InquiryController extends AbstractController $data = $InquiryService->addInquiryOrder(); return $this->response->json($data); } + + /** + * 获取患者问诊病例 + * @return ResponseInterface + */ + public function getPatientInquiryCase(): ResponseInterface + { + $InquiryService = new InquiryService(); + $data = $InquiryService->getPatientInquiryCase(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Controller/UserDoctorController.php b/app/Controller/UserDoctorController.php index e7cd30b..34df461 100644 --- a/app/Controller/UserDoctorController.php +++ b/app/Controller/UserDoctorController.php @@ -223,4 +223,15 @@ class UserDoctorController extends AbstractController $data = $UserDoctorService->getDoctorCret(); return $this->response->json($data); } + + /** + * 获取处方详情 + * @return ResponseInterface + */ + public function getPrescriptionInfo(): ResponseInterface + { + $UserDoctorService = new UserDoctorService(); + $data = $UserDoctorService->getPrescriptionInfo(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Model/PatientFamily.php b/app/Model/PatientFamily.php index 2b70e47..d827bb0 100644 --- a/app/Model/PatientFamily.php +++ b/app/Model/PatientFamily.php @@ -57,7 +57,7 @@ class PatientFamily extends Model /** * The attributes that should be cast to native types. */ - protected array $casts = ['family_id' => 'integer', 'patient_id' => 'integer', '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 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/Model/PatientFamilyHealth.php b/app/Model/PatientFamilyHealth.php new file mode 100644 index 0000000..327dd80 --- /dev/null +++ b/app/Model/PatientFamilyHealth.php @@ -0,0 +1,60 @@ +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); + } +} diff --git a/app/Model/PatientFamilyPersonal.php b/app/Model/PatientFamilyPersonal.php new file mode 100644 index 0000000..67b483d --- /dev/null +++ b/app/Model/PatientFamilyPersonal.php @@ -0,0 +1,68 @@ +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); + } +} diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index 6d484ac..6996216 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -10,6 +10,8 @@ use App\Model\OrderInquiry; use App\Model\OrderInquiryCase; use App\Model\OrderInquiryCoupon; use App\Model\PatientFamily; +use App\Model\PatientFamilyHealth; +use App\Model\PatientFamilyPersonal; use App\Model\Product; use App\Model\UserDoctor; use App\Utils\PcreMatch; @@ -257,6 +259,83 @@ class InquiryService extends BaseService return success($result); } + /** + * 获取患者问诊病例 + * @return array + */ + public function getPatientInquiryCase(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + $inquiry_case_id = $this->request->route('inquiry_case_id'); + + // 获取病例信息 + $params = array(); + $params['inquiry_case_id'] = $inquiry_case_id; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)){ + return fail(); + } + + // 获取患者家庭成员信息表-基本信息 + $params = array(); + $params['family_id'] = $order_inquiry_case['family_id']; + $patient_family = PatientFamily::getOne($params); + $order_inquiry_case['height'] = $order_inquiry_case['height'] ?: $patient_family['height'] ?: NULL; + $order_inquiry_case['weight'] = $order_inquiry_case['weight'] ?: $patient_family['weight'] ?: NULL; + $order_inquiry_case['job_name'] = $patient_family['job_name'] ?? ""; + $order_inquiry_case['nation_name'] = $patient_family['nation_name'] ?? ""; + + // 获取患者家庭成员信息表-健康情况 + $params = array(); + $params['family_id'] = $order_inquiry_case['family_id']; + $patient_family_health = PatientFamilyHealth::getOne($params); + $order_inquiry_case['diagnosis_hospital'] = $patient_family_health['diagnosis_hospital'] ?? ""; + + // 获取患者家庭成员信息表-个人情况 + $params = array(); + $params['family_id'] = $order_inquiry_case['family_id']; + $patient_family_personal = PatientFamilyPersonal::getOne($params); + $order_inquiry_case['drink_wine_status'] = $patient_family_personal['drink_wine_status'] ?? 1; + $order_inquiry_case['smoke_status'] = $patient_family_personal['smoke_status'] ?? 1; + $order_inquiry_case['chemical_compound_status'] = $patient_family_personal['chemical_compound_status'] ?? 1; + $order_inquiry_case['chemical_compound_describe'] = $patient_family_personal['chemical_compound_describe'] ?? ""; + $order_inquiry_case['is_operation'] = $patient_family_personal['is_operation'] ?? 0; + $order_inquiry_case['operation'] = $patient_family_personal['operation'] ?? ""; + + // 获取用药意向 + $product = []; + $fields = [ + 'inquiry_case_id', + 'product_id', + 'case_product_num', + ]; + $params = array(); + $params['inquiry_case_id'] = $order_inquiry_case['inquiry_case_id']; + $inquiry_case_product = InquiryCaseProduct::getWithProductList($params,$fields); + if (!empty($inquiry_case_product)){ + foreach ($inquiry_case_product as &$item){ + if (!empty($item['Product'])){ + $product[] = $item['Product']['product_name'] . ' ' . $item['Product']['product_spec'] . '(' . $item['case_product_num'] . $item['Product']['packaging_unit'] . ')'; + } + } + } + + $order_inquiry_case['product'] = $product; + unset($inquiry_case_product); + + // 复诊凭证 + if (!empty($order_inquiry_case['diagnose_images'])){ + $diagnose_images = explode(',',$order_inquiry_case['diagnose_images']); + foreach ($diagnose_images as &$item){ + $item = addAliyunOssWebsite($item); + } + + $order_inquiry_case['diagnose_images'] = $diagnose_images; + } + + return success($order_inquiry_case->toArray()); + } + /** * 获取医生未接诊订单数量 * @param string $doctor_id 医生id diff --git a/app/Services/PatientCaseService.php b/app/Services/PatientCaseService.php index f3238fe..da87dcc 100644 --- a/app/Services/PatientCaseService.php +++ b/app/Services/PatientCaseService.php @@ -49,17 +49,17 @@ class PatientCaseService extends BaseService $inquiry_case_product = InquiryCaseProduct::getWithProductList($params); if (!empty($inquiry_case_product)){ foreach ($inquiry_case_product as &$item){ - if (!empty($item['product'])){ - $item['product_name'] = $item['product']['product_name']; - $item['product_price'] = $item['product']['product_price']; - $item['product_type'] = $item['product']['product_type']; - $item['product_cover_img'] = addAliyunOssWebsite($item['product']['product_cover_img']); - $item['product_spec'] = $item['product']['product_spec']; - $item['license_number'] = $item['product']['license_number']; - $item['manufacturer'] = $item['product']['manufacturer']; - $item['packaging_unit'] = $item['product']['packaging_unit']; + if (!empty($item['Product'])){ + $item['product_name'] = $item['Product']['product_name']; + $item['product_price'] = $item['Product']['product_price']; + $item['product_type'] = $item['Product']['product_type']; + $item['product_cover_img'] = addAliyunOssWebsite($item['Product']['product_cover_img']); + $item['product_spec'] = $item['Product']['product_spec']; + $item['license_number'] = $item['Product']['license_number']; + $item['manufacturer'] = $item['Product']['manufacturer']; + $item['packaging_unit'] = $item['Product']['packaging_unit']; - unset($item['product']); + unset($item['Product']); } } } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 4d42d3f..71ed4ce 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -783,6 +783,18 @@ class UserDoctorService extends BaseService return success($result); } + /** + * 获取处方详情 + * @return array + */ + public function getPrescriptionInfo(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_prescription_id = $this->request->route('order_prescription_id'); + + + } /** * 检测医生身份认证 diff --git a/config/config.php b/config/config.php index d7ba018..fae908f 100644 --- a/config/config.php +++ b/config/config.php @@ -47,7 +47,7 @@ return [ "patient" => [ "app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'), "mchid" => env('PATIENT_WECHAT_MCH_ID', '1636644248'), - "secret" => env('PATIENT_WECHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'), + "apiv3_secret" => env('PATIENT_WECHAT_APIv3_SECRET', 'gdxz292sjSOadN3m2pCda03NfCsmNadY'), ], ] ], diff --git a/config/routes.php b/config/routes.php index f9738b8..921a532 100644 --- a/config/routes.php +++ b/config/routes.php @@ -73,7 +73,7 @@ Router::addGroup('/doctor', function () { Router::put('/config', [UserDoctorController::class, 'putInquiryConfig']); // 获取患者问诊病例 - Router::get('/case', [InquiryController::class, 'getPatientInquiryCase']); + Router::get('/case/{inquiry_case_id:\d+}', [InquiryController::class, 'getPatientInquiryCase']); }); @@ -132,6 +132,9 @@ Router::addGroup('/doctor', function () { Router::addGroup('/prescription', function () { // 获取处方列表 Router::get('', [UserDoctorController::class, 'getPrescriptionList']); + + // 获取处方详情 + Router::get('/{order_prescription_id:\d+}', [UserDoctorController::class, 'getPrescriptionInfo']); }); // 常用语