diff --git a/app/Model/OrderPrescription.php b/app/Model/OrderPrescription.php index a15bdc2..ba52d43 100644 --- a/app/Model/OrderPrescription.php +++ b/app/Model/OrderPrescription.php @@ -7,6 +7,8 @@ namespace App\Model; use Hyperf\Contract\LengthAwarePaginatorInterface; +use Hyperf\Database\Model\Relations\HasMany; +use Hyperf\Database\Model\Relations\HasOne; use Hyperf\Snowflake\Concern\Snowflake; /** @@ -14,8 +16,6 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property int $order_inquiry_id 订单-问诊id * @property int $doctor_id 医生id * @property int $pharmacist_id 药师id - * @property int $icd_id 疾病id(icd) - * @property string $icd_name 疾病名称(icd) * @property int $prescription_status 处方状态(1:待审核 3:待使用 4:已失效 5:已使用) * @property int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回) * @property string $pharmacist_fail_reason 药师审核驳回原因 @@ -27,8 +27,6 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property string $patient_name 患者姓名-就诊人 * @property int $patient_sex 患者性别-就诊人(1:男 2:女) * @property int $patient_age 患者年龄-就诊人 - * @property string $drugs_info 药品数据 - * @property string $disease_desc 病情描述(主诉) * @property string $prescription_img 处方图片 * @property \Carbon\Carbon $created_at 创建时间 * @property \Carbon\Carbon $updated_at 修改时间 @@ -45,15 +43,18 @@ class OrderPrescription extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'pharmacist_id', 'icd_id', 'icd_name', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_reason', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'drugs_info', 'disease_desc', 'prescription_img', 'created_at', 'updated_at']; - - /** - * The attributes that should be cast to native types. - */ - protected array $casts = ['order_prescription_id' => 'integer', 'order_inquiry_id' => 'integer', 'doctor_id' => 'integer', 'pharmacist_id' => 'integer', 'icd_id' => 'integer', 'prescription_status' => 'integer', 'pharmacist_audit_status' => 'integer', 'platform_audit_status' => 'integer', 'is_delete' => 'integer', 'patient_sex' => 'integer', 'patient_age' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime']; + protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_reason', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'prescription_img', 'created_at', 'updated_at']; protected string $primaryKey = "order_prescription_id"; + /** + * 关联处方病例表 + */ + public function OrderPrescriptionIcd(): HasMany + { + return $this->HasMany(OrderPrescriptionIcd::class, 'order_prescription_id','order_prescription_id'); + } + /** * 获取是否存在 * @param array $params @@ -65,7 +66,7 @@ class OrderPrescription extends Model } /** - * 获取待审核处方列表-分页 + * 获取处方列表-分页 * @param array $params 条件 * @param array $fields 字段 * @param int|null $page 页码 @@ -85,5 +86,29 @@ class OrderPrescription extends Model return $data; } + /** + * 获取处方列表-分页 + * @param array $params 条件 + * @param array $fields 字段 + * @param int|null $page 页码 + * @param int|null $per_page 每页个数 + * @return array + */ + public static function getWithIcdPage(array $params, array $fields = ["*"], int $page = null, ?int $per_page = 10): array + { + $raw = self::with([ + 'OrderPrescriptionIcd' + ]) + ->where($params) + ->paginate($per_page, $fields, "page", $page); + $data = array(); + $data['current_page'] = $raw->currentPage();// 当前页码 + $data['total'] = $raw->total();//数据总数 + $data['data'] = $raw->items();//数据 + $data['per_page'] = $raw->perPage();//每页个数 + $data['last_page'] = $raw->lastPage();//最后一页 + + return $data; + } } diff --git a/app/Model/OrderPrescriptionIcd.php b/app/Model/OrderPrescriptionIcd.php new file mode 100644 index 0000000..f277949 --- /dev/null +++ b/app/Model/OrderPrescriptionIcd.php @@ -0,0 +1,40 @@ + 'integer', 'order_prescription_id' => 'integer', 'icd_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime']; + + protected string $primaryKey = "prescription_icd_id"; +} diff --git a/app/Services/BasicDataService.php b/app/Services/BasicDataService.php index 321f195..d4d5969 100644 --- a/app/Services/BasicDataService.php +++ b/app/Services/BasicDataService.php @@ -98,6 +98,11 @@ class BasicDataService extends BaseService */ public function getOperationManual(): array { + $fields = [ + 'manual_id', + 'title', + ]; + $params = array(); $params['status'] = 1; @@ -117,16 +122,11 @@ class BasicDataService extends BaseService { $manual_id = $this->request->route('manual_id'); - $fields = [ - 'manual_id', - 'title', - ]; - $params = array(); $params['manual_id'] = $manual_id; $params['status'] = 1; - $operation_manual = OperationManual::getOne($params,$fields); + $operation_manual = OperationManual::getOne($params); if (empty($operation_manual)){ return fail(); } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 13eb737..63da7c4 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -388,7 +388,7 @@ class UserDoctorService extends BaseService $params['doctor_id'] = $user_info['client_user_id']; $params['pharmacist_audit_status'] = $prescription_status; $params['is_delete'] = 0; - $order_prescriptions = OrderPrescription::getPage($params); + $order_prescriptions = OrderPrescription::getWithIcdPage($params); if (empty($order_prescriptions)) { return success($order_prescriptions); } @@ -419,17 +419,6 @@ class UserDoctorService extends BaseService // 病情描述 $data['disease_desc'] = $order_inquiry_case['disease_desc']; - // 获取icd诊断疾病信息 - $params = array(); - $params['icd_id'] = $order_prescription['icd_id']; - $disease_class_icd = DiseaseClassIcd::getOne($params); - if (empty($disease_class_icd)){ - return fail(HttpEnumCode::SERVER_ERROR); - } - - // 获取病情诊断名称,icd名称 - $data['icd_name'] = $disease_class_icd['icd_name']; - // 患病时长 if (empty($order_inquiry_case['diagnosis_date'])){ $data['diagnosis_date'] = "未知"; @@ -437,6 +426,8 @@ class UserDoctorService extends BaseService $data['diagnosis_date'] = date('Y-m-d',strtotime($order_inquiry_case['diagnosis_date'])); } + // 疾病信息 + $data['order_prescription_icd'] = $order_prescription['OrderPrescriptionIcd'] ?? []; $result[] = $data; }