韩盟盟 15 giờ trước cách đây
mục cha
commit
095810becb

+ 51 - 32
neo4jApi/app/controller/Cdss.php

@@ -100,18 +100,32 @@ class Cdss extends CommonTwoController
                  */
                 if (stripos($values, ',') !== false) {
                     $symptoms = explode(',', $values);
-			
-		            $symptomData = Symptom::field('disease')->where('1=1')->whereIn('name',$symptoms)->select()->toArray();
-
-                    if(!empty($symptomData)){
-                        $whereIn = [];
-                        foreach ($symptomData as $key => $val) {
-                            if(!empty($val) && $val != ''){
-                                $whereIn = array_merge($whereIn,explode('||',$val['disease']));
-                            }
+
+                    $disease_str = collect($symptoms)->reduce(function($_,$item){
+                        $disease = Symptom::where('1=1')->whereIn('name',$item)->value('disease');
+                        return $_.= empty($_) || !$disease ? $disease :'||'.$disease;
+                    });
+
+                    $diseases = array_flip(explode('||',$disease_str));
+
+                    //$symptomData = Symptom::field('disease')->where('1=1')->whereIn('name',$symptoms)->select()->toArray();
+
+                    //if(!empty($symptomData)){
+                    //    $whereIn = [];
+                    //    foreach ($symptomData as $key => $val) {
+                    //        if(!empty($val) && $val != ''){
+                    //            $whereIn = array_merge($whereIn,explode('||',$val['disease']));
+                    //        }
+                    //    }
+                    $aboutDiseases = CdssXyDisease::whereIn('name',explode('||',$disease_str))->limit(200)->select()->toArray();
+                    if($aboutDiseases){
+                        foreach($aboutDiseases as $key => $val){
+                            $aboutDiseases[$key]['sort'] = $diseases[$val['name']];
                         }
-                        $aboutDiseases = CdssXyDisease::whereIn('name',$whereIn)->limit(200)->select()->toArray();
+                        $sort = array_column($aboutDiseases, 'sort');
+                        array_multisort($sort,SORT_ASC,$aboutDiseases);
                     }
+                    //}
                     if(empty($aboutDiseases)) {
 
                         $query = CdssXyDisease::where('1=1');
@@ -135,14 +149,18 @@ class Cdss extends CommonTwoController
                         }
                     }
                 } else {
-                    $symptomData = Symptom::where('1=1')->where('name',$values)->value('disease');
-                    if(!empty($symptomData)){
-                        $whereIn = [];
-                            if(!empty($symptomData) && $symptomData != ''){
-                                $whereIn = array_merge($whereIn,explode('||',$symptomData));
-                            }
-                        $aboutDiseases = CdssXyDisease::whereIn('name',$whereIn)->limit(200)->select()->toArray();
+                    $disease_str = Symptom::where('1=1')->where('name',$values)->value('disease');
+                    $diseases = array_flip(explode('||',!empty($disease_str)?$disease_str:''));
+
+                    $aboutDiseases = CdssXyDisease::whereIn('name',explode('||',!empty($disease_str)?$disease_str:''))->limit(200)->select()->toArray();
+                    if($aboutDiseases){
+                        foreach($aboutDiseases as $key => $val){
+                            $aboutDiseases[$key]['sort'] = $diseases[$val['name']];
+                        }
+                        $sort = array_column($aboutDiseases, 'sort');
+                        array_multisort($sort,SORT_ASC,$aboutDiseases);
                     }
+
                     if(empty($aboutDiseases)) {
                         $aboutDiseases = CdssXyDisease::whereLike('clinicalFeature', '%' . $values . '%')
                             ->limit(200)
@@ -223,7 +241,7 @@ class Cdss extends CommonTwoController
          * 年龄筛选
          */
         $ageAboutDiseases = $this->getAboutDiseasesByAge($aboutDiseases, $age);
-        return $this->getAboutDiseasesByKeywordCount($ageAboutDiseases, $values);
+        return $this->getAboutDiseasesByKeywordCount($ageAboutDiseases, $values,$disease_str);
     }
 
     /**
@@ -386,7 +404,7 @@ class Cdss extends CommonTwoController
             } elseif ($age >= 60) {
                 $count = count($oldAboutDiseasesKeyword);
                 for ($i = 0; $i < $count; $i++) {
-                    if (stripos($v['name'], $oldAboutDiseasesKeyword[$i]) !== false) {
+                    if (stripos($v['name'], $childAboutDiseasesKeyword[$i]) == false) {
                         $ageAboutDiseases[] = $v;
                     }
                 }
@@ -412,25 +430,26 @@ class Cdss extends CommonTwoController
      * @param  string  $keyword
      * @return array
      */
-    private function getAboutDiseasesByKeywordCount($aboutDiseases, $keyword): array
+    private function getAboutDiseasesByKeywordCount($aboutDiseases, $keyword,$disease): array
     {
         if (empty($aboutDiseases)) {
             return [];
         }
-
-        if (stripos($keyword, ',') !== false) {
-            foreach ($aboutDiseases as $key => $value) {
-                $aboutDiseases[$key]['keyword_count'] = $this->getKeywordTotalCount($value['clinicalFeature'], $keyword);
-            }
-        } else {
-            foreach ($aboutDiseases as $key => $value) {
-                $aboutDiseases[$key]['keyword_count'] = !empty($value['clinicalFeature']) && !empty($keyword) ? substr_count($value['clinicalFeature'], $keyword) : 0;
+        if(!$disease) {
+            if (stripos($keyword, ',') !== false) {
+                foreach ($aboutDiseases as $key => $value) {
+                    $aboutDiseases[$key]['keyword_count'] = $this->getKeywordTotalCount($value['clinicalFeature'], $keyword);
+                }
+            } else {
+                foreach ($aboutDiseases as $key => $value) {
+                    $aboutDiseases[$key]['keyword_count'] = !empty($value['clinicalFeature']) && !empty($keyword) ? substr_count($value['clinicalFeature'], $keyword) : 0;
+                }
             }
-        }
 
-        if (count($aboutDiseases) > 1) {
-            $keyword_count = array_column($aboutDiseases, 'keyword_count');
-            array_multisort($keyword_count, SORT_DESC, $aboutDiseases);
+            if (count($aboutDiseases) > 1) {
+                $keyword_count = array_column($aboutDiseases, 'keyword_count');
+                array_multisort($keyword_count, SORT_DESC, $aboutDiseases);
+            }
         }
 
         /**

+ 1 - 0
neo4jApi/app/controller/PatientAuxiliary.php

@@ -99,6 +99,7 @@ class PatientAuxiliary extends CommonTwoController
         }
 
         try {
+            PatientAuxiliaryDiagnosis::where('zyh',$params['ZYH'])->delete();
             // 1. 辅助诊疗 - 只要有zszz和性别年龄就调用
             if (!empty($params['ZSZZ']) && !empty($params['XB']) && !empty($params['NL'])) {
                 try {