|
@@ -100,18 +100,32 @@ class Cdss extends CommonTwoController
|
|
*/
|
|
*/
|
|
if (stripos($values, ',') !== false) {
|
|
if (stripos($values, ',') !== false) {
|
|
$symptoms = explode(',', $values);
|
|
$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)) {
|
|
if(empty($aboutDiseases)) {
|
|
|
|
|
|
$query = CdssXyDisease::where('1=1');
|
|
$query = CdssXyDisease::where('1=1');
|
|
@@ -135,14 +149,18 @@ class Cdss extends CommonTwoController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} 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)) {
|
|
if(empty($aboutDiseases)) {
|
|
$aboutDiseases = CdssXyDisease::whereLike('clinicalFeature', '%' . $values . '%')
|
|
$aboutDiseases = CdssXyDisease::whereLike('clinicalFeature', '%' . $values . '%')
|
|
->limit(200)
|
|
->limit(200)
|
|
@@ -223,7 +241,7 @@ class Cdss extends CommonTwoController
|
|
* 年龄筛选
|
|
* 年龄筛选
|
|
*/
|
|
*/
|
|
$ageAboutDiseases = $this->getAboutDiseasesByAge($aboutDiseases, $age);
|
|
$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) {
|
|
} elseif ($age >= 60) {
|
|
$count = count($oldAboutDiseasesKeyword);
|
|
$count = count($oldAboutDiseasesKeyword);
|
|
for ($i = 0; $i < $count; $i++) {
|
|
for ($i = 0; $i < $count; $i++) {
|
|
- if (stripos($v['name'], $oldAboutDiseasesKeyword[$i]) !== false) {
|
|
|
|
|
|
+ if (stripos($v['name'], $childAboutDiseasesKeyword[$i]) == false) {
|
|
$ageAboutDiseases[] = $v;
|
|
$ageAboutDiseases[] = $v;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -412,25 +430,26 @@ class Cdss extends CommonTwoController
|
|
* @param string $keyword
|
|
* @param string $keyword
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
- private function getAboutDiseasesByKeywordCount($aboutDiseases, $keyword): array
|
|
|
|
|
|
+ private function getAboutDiseasesByKeywordCount($aboutDiseases, $keyword,$disease): array
|
|
{
|
|
{
|
|
if (empty($aboutDiseases)) {
|
|
if (empty($aboutDiseases)) {
|
|
return [];
|
|
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);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|