You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.7 KiB

<?php
namespace app\admin\controller;
use app\lib\exception\HtmlException;
use app\viewModel\PatientMedicalView;
use think\Request;
class PatientInfo extends BaseController
{
public function index(){
$map = [];
if (Request::instance()->isPost()) {
$input = Request::instance()->param();
}
else {
$input = Request::instance()->get();
}
if (!empty($input['code'])){
$map['code'] = $input['code'];
}
$patients = \app\admin\model\PatientInfo::viewQuery(PatientMedicalView::CLASS,"patientRegister")
->where($map)
->paginate(10,false,[
"query" => [
'code' => $map['code'],
]
]);
foreach ($patients as $patient){
if($patient['description'] == NULL){
$patient['description'] = "暂无记录" ;
}
}
$total = $patients->total();
$page = $patients->render();
$this->assign('page',$page);
$this->assign('total',$total);
$this->assign('code',$input['code']);
$this->assign('patients',$patients);
return $this->fetch();
}
//查看患者详情
public function check(){
$input = Request::instance()->param();
// p($input);die();
$patient = \app\admin\model\PatientInfo::where($input)->find();
if($patient['description'] == NULL){
$patient['description'] = "暂无记录" ;
}
$this->assign('patient',$patient);
return $this->fetch();
}
//填写诊断结果
public function write(){
$id = Request::instance()->param();
$patient = \app\admin\model\PatientInfo::where($id)->find();
// p($patient);die();
if(Request::instance()->isPost()) {
$input = Request::instance()->param();
// p($input);die();
if (empty($input['description'])) {
throw new HtmlException("请填写诊断结果!");
}
$patientInfo = \app\admin\model\PatientInfo::where(['id'=>$input['id']])->find();
// if (empty($patientInfo['description'])) {
$data = ['description' => $input['description']];
$patientInfo->save($data);
if ($patient['description'] === false)
return $this->error('添加失败');
return $this->success('添加成功');
// p($patientInfo);die();
// }
}
$this->assign('patient',$patient);
return $this->fetch();
}
}