Browse Source

同步检查、报告

lgy 1 day ago
parent
commit
f14977cf5a

+ 10 - 3
server/application/api/controller/butt/ButtController.php

@@ -402,7 +402,6 @@ class ButtController extends ZskkDefaultApiController
     {
         $params = Request::param(false);
         $data = $this->getDecryptData($params['data']);
-        var_dump($data);die;
         if(is_array($data))
         {
             // todo
@@ -413,9 +412,17 @@ class ButtController extends ZskkDefaultApiController
         return $this->success('success');
     }
 
-    public function saveDmReport()
+    public function saveDmReport(ButtService $service)
     {
         $params = Request::param(false);
-
+        $data = $this->getDecryptData($params['data']);
+        if(is_array($data))
+        {
+            // todo
+            $service->saveDmReport($data);
+        }else{
+            $this->throwError($data,9001);
+        }
+        return $this->success('success');
     }
 }

+ 15 - 0
server/application/api/dao/butt/ButtDao.php

@@ -355,6 +355,21 @@ class ButtDao extends ZskkDefaultDao {
         return $id;
     }
 
+    public function getReportData($where, $field='*')
+    {
+        return $this->report->where($where)->field($field)->find();
+    }
+
+    public function insertReport($data)
+    {
+        return $this->report->insert($data)
+    }
+
+    public function updateReport($data,$where)
+    {
+        return $this->report->where($where)->update($data)
+    }
+
     public function getPrint($where)
     {
         $info = $this->report->getPrint($where);

+ 93 - 1
server/application/api/servies/butt/ButtService.php

@@ -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;
     }
 }

+ 2 - 3
server/application/api/servies/xz/XzService.php

@@ -291,11 +291,10 @@ class XzService extends ZskkDefaultService {
             return true;
         }*/
         $time1 = time();
-        if($params['institution_id'] == '43600001')
+        $exam = $this->xz->checkIsSet($params['study_id']);
+        if(empty($exam))
         {
             $exam = $this->xz->checkIsSet($params['study_id'],$params['studyuid'],$params['institution_id']);
-        }else{
-            $exam = $this->xz->checkIsSet($params['study_id']);
         }
         if($params['institution_id'] == '71900004')
         {