|
|
@@ -2202,7 +2202,99 @@ class ButtService extends ZskkDefaultService {
|
|
|
|
|
|
public function saveDmExam($data)
|
|
|
{
|
|
|
- $arr = $this->makeExamData($data);
|
|
|
+ $arr = $this->makeDmExamData($data);
|
|
|
+ $where = ['studyuid'=>$arr['studyuid'],'institution_id'=>$arr['institution_id']];
|
|
|
+ $exam = $this->butt->getExam($where,'*');
|
|
|
+ if(empty($exam))
|
|
|
+ {
|
|
|
+ $info = $this->butt->getExam(['imagenumber'=>$arr['imagenumber'],'institution_id'=>$arr['institution_id']],'*');
|
|
|
+ if(empty($info))
|
|
|
+ {
|
|
|
+ $arr['id'] = UUIDUtils::uuid();
|
|
|
+ $this->butt->insertExam($arr);
|
|
|
+ $id = $arr['id'];
|
|
|
+ }else{
|
|
|
+ $this->butt->updateExam($arr,$info['id']);
|
|
|
+ $id = $info['id'];
|
|
|
+ }
|
|
|
|
|
|
+ }else{
|
|
|
+ $this->butt->updateExam($arr,$exam['id']);
|
|
|
+ $id = $exam['id'];
|
|
|
+ }
|
|
|
+ $report = $this->butt->getReportData(['exam_id'=>null,'imagenumber'=>$arr['imagenumber']]);
|
|
|
+ if(!empty($report))
|
|
|
+ {
|
|
|
+ $this->butt->updateReport(['exam_id'=>null,'imagenumber'=>$arr['imagenumber']],['exam_id'=>$id]);
|
|
|
+ $this->butt->updateExam(['exam_status'=>9],$id);
|
|
|
+ }
|
|
|
+ return 'success';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function makeDmExamData($data)
|
|
|
+ {
|
|
|
+ $sexArr = ['1'=>'M','2'=>'F'];
|
|
|
+ $arr = [];
|
|
|
+ $arr['name'] = $data['A']['AA'];
|
|
|
+ $arr['card_num'] = $data['A']['AC'];
|
|
|
+ $arr['sex'] = $sexArr[$data['A']['AD']] ?? 'O';
|
|
|
+ $arr['birthday'] = $data['A']['AE'];
|
|
|
+ $arr['phone'] = $data['A']['AF'];
|
|
|
+ $arr['patient_num'] = $data['B']['BB'];
|
|
|
+ $arr['imagenumber'] = $data['B']['BD'];
|
|
|
+ $arr['application_department'] = $data['B']['BF'];
|
|
|
+ $arr['application_doctor'] = $data['B']['BG'];
|
|
|
+ $arr['age'] = $data['B']['BJ'];
|
|
|
+ $arr['institution_id'] = $data['B']['BK'];
|
|
|
+ $arr['clin_diag'] = $data['B']['BM'];
|
|
|
+ $arr['exam_class'] = $data['C']['CC'];
|
|
|
+ $arr['exam_project'] = $data['C']['CD'];
|
|
|
+ $arr['body_part'] = $data['C']['CF'];
|
|
|
+ $arr['exam_datetime'] = date('Ymd',strtotime($data['C']['CI']));
|
|
|
+ $arr['studyuid'] = $data['C']['CM'];
|
|
|
+ $arr['exam_status'] = 3;
|
|
|
+ return $arr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function saveDmReport($data)
|
|
|
+ {
|
|
|
+ $where = ['imagenumber'=>$data['B']['BD'],'institution_id'=>$data['B']['BJ']];
|
|
|
+ $exam = $this->butt->getExam($where,'*');
|
|
|
+ $report = $this->makeReportData($data);
|
|
|
+ if(empty($exam))
|
|
|
+ {
|
|
|
+ $report['id'] = UUIDUtils::uuid();
|
|
|
+ $this->butt->insertReport($report);
|
|
|
+ return '';
|
|
|
+ }else{
|
|
|
+ $report['exam_id'] = $exam['id'];
|
|
|
+ $old = $this->butt->getReportData(['exam_id'=>$exam['id'],'type'=>1],'*');
|
|
|
+ if(empty($old))
|
|
|
+ {
|
|
|
+ //
|
|
|
+ $report['id'] = UUIDUtils::uuid();
|
|
|
+ $this->butt->insertReport($report);
|
|
|
+ }else{
|
|
|
+ $this->butt->updateReport($report,['id'=>$old['id']]);
|
|
|
+ }
|
|
|
+ $this->butt->updateExam(['exam_status'=>9],$exam['id']);
|
|
|
+ return 'success';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function makeReportData($data)
|
|
|
+ {
|
|
|
+ $report = [];
|
|
|
+ $report['description'] = $data['C']['CD'];
|
|
|
+ $report['impression'] = $data['C']['CE'];
|
|
|
+ $report['report_result'] = ($data['C']['CF'] == 9) ? null : $data['C']['CF'];
|
|
|
+ $report['report_doctor_name'] = $data['C']['CH'];
|
|
|
+ $report['review_doctor_name'] = $data['C']['CI'];
|
|
|
+ $report['confirm_doctor_name'] = $data['C']['CI'];
|
|
|
+ $report['report_datetime'] = $data['C']['CJ'];
|
|
|
+ $report['review_datetime'] = $data['C']['CK'];
|
|
|
+ $report['confirm_datetime'] = $data['C']['CK'];
|
|
|
+ $report['imagenumber'] = $data['B']['BD'];
|
|
|
+ return $report;
|
|
|
}
|
|
|
}
|