Test.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. namespace App\Model;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Pagination\LengthAwarePaginator;
  5. use Illuminate\Support\Facades\Request;
  6. class Test extends Model
  7. {
  8. private $host = "https://jm.jiankangche.cn/";
  9. public function paginate()
  10. {
  11. $page = Request::get('page' , 1);
  12. $perPage = Request::get('per_page', 10);
  13. $label = Request::get('label' , 'SickNess');
  14. $name = Request::get('name' , '');
  15. $start = ($page-1) * $perPage;
  16. $data = file_get_contents($this->host."neo4j/index?start=$start&perPage=$perPage&label=$label&name=$name");
  17. $data = json_decode($data , true);
  18. $movies = static::hydrate($data['list']);
  19. $total = $data['count'];
  20. $paginator = new LengthAwarePaginator($movies, $total, $perPage);
  21. $paginator->setPath(url()->current());
  22. return $paginator;
  23. }
  24. public static function with($relations)
  25. {
  26. return new static;
  27. }
  28. // 覆盖`orderBy`来收集排序的字段和方向
  29. public function orderBy($column, $direction = 'asc')
  30. {
  31. }
  32. // 覆盖`where`来收集筛选的字段和条件
  33. public function where($column, $operator = null, $value = null, $boolean = 'and')
  34. {
  35. }
  36. // 获取单项数据展示在form中
  37. public function findOrFail($id)
  38. {
  39. $data = file_get_contents($this->host."neo4j/detail?id=$id");
  40. $data = json_decode($data, true);
  41. return static::newFromBuilder($data);
  42. }
  43. // 获取lable
  44. public function getlabel($id)
  45. {
  46. $data = file_get_contents($this->host."neo4j/getlabels?id=$id");
  47. $labels = json_decode($data, true);
  48. return $labels[1];
  49. }
  50. // 保存提交的form数据
  51. public function save(array $options = [])
  52. {
  53. $attributes = $this->getAttributes();
  54. $id = $attributes['id'];
  55. $label = $this->getlabel($id);
  56. switch ($label) {
  57. case 'SickNess';
  58. // "tongueCondition" => "舌红苔燥"
  59. // "apparatus" => "心肺"
  60. // "kgid" => "4d839135f8627092b95602acf6dbb5237fadab9419bc88f2199ad7fe2d90ae31"
  61. // "therapeuticMethod" => "清解肺热"
  62. // "statedIn" => "cn_sickness"
  63. // "dateModified" => "2021-09-07T15:34:31"
  64. // "source" => "《丹溪心法》·卷之三(卷)·消渴(篇)"
  65. // "pulseCondition" => "脉洪"
  66. // "dietTherapy" => "益智仁"
  67. // "symptom" => "胸中烦燥,舌赤唇红,此渴引饮,常多,小便数而少。"
  68. // "pageRankScore" => "0.15"
  69. // "name" => "糖尿病(消渴)1"
  70. // "entityScore" => "15"
  71. // "department" => "内分泌科"
  72. // "graphId" => "sickness"
  73. // "acupuncturePoints" => "承浆 、 气舍 、 关冲 、 然谷"
  74. // "dialecticalName" => "心热移肺"
  75. // "id" => "401"
  76. $query = "match (n: SickNess) where id(n) = $id set n.tongueCondition='".$attributes['tongueCondition']."' ,n.apparatus='".$attributes['apparatus']."' , n.therapeuticMethod='".$attributes['therapeuticMethod']."' ,n.source='".$attributes['source']."' ,n.pulseCondition='".$attributes['name']."' ,n.dietTherapy='".$attributes['dietTherapy']."' ,n.symptom='".$attributes['symptom']."' , n.pageRankScore='".$attributes['pageRankScore']."' , n.name='".$attributes['name']."' ,n.entityScore='".$attributes['entityScore']."' ,n.department='".$attributes['department']."' ,n.acupuncturePoints='".$attributes['acupuncturePoints']."' ,n.dialecticalName='".$attributes['dialecticalName']."'RETURN n";
  77. break;
  78. case 'Thing':
  79. // "composition" => "黄芪15g,太子参15g,麦冬10g,五味子10g,丹参30g,佛手10g,香橼10g,瓜蒌15g,熟地黄10g 。"
  80. // "kgid" => "65d07143c55c128595b15c1aed5f92d245b2ab80d2cf1f35e1f6b67981e4c1d4"
  81. // "pageRankScore" => "0.1925"
  82. // "name" => "益气阴达目络经验方"
  83. // "statedIn" => "cn_sickness,Prescription"
  84. // "dateModified" => "2021-09-07T15:34:31"
  85. // "entityScore" => "19"
  86. // "graphId" => "sickness"
  87. // "id" => "0"
  88. $query = "match (n: Thing) where id(n) = $id set n.composition='".$attributes['composition']."' , n.name='".$attributes['name']."' , n.pageRankScore='".$attributes['pageRankScore']."' RETURN n";
  89. break;
  90. case 'CnMedicinalCrop':
  91. // "toxicity" => "小毒"
  92. // "indications" => "根,根茎:补脾益气,清热解毒,止咳润肺,调和诸药;叶:止血。"
  93. // "kgid" => "94f6afb2d4fd4ad6b1ee4232a8425a3608a1ff290037db636224d7a762a6d452"
  94. // "statedIn" => "Prescription,CnMedicinalCrop"
  95. // "dateModified" => "2021-09-07T15:34:27"
  96. // "source" => "本品为豆科植物甘草Glycyrrhiza uralensis Fisch.、胀果甘草Glycyrrhiza inflata Bat.或光果甘草Glycyrrhiza glabra L.的干燥根和根茎。春、秋二季采挖,除去须根,晒干。"
  97. // "medicineProperty" => "甘,平。归心,肺,脾,胃经。"
  98. // "includedIn" => "《全国中草药汇编》 《全国中草药名鉴》 《中国药材标准名录》 《世界药用植物速查辞典》 《中华本草》 《抗肿瘤中药药理与临床》 《中国药典2015》"
  99. // "pageRankScore" => "8.465131746031744"
  100. // "pharmacology" => "肾上腺皮质激素样作用,抗病毒及抗菌作用,对消化系统的作用,抗炎作用,对免疫功能的影响,"
  101. // "name" => "甘草"
  102. // "entityScore" => "846"
  103. // "graphId" => "sickness"
  104. // "id" => "101"
  105. $query = "match (n: CnMedicinalCrop) where id(n) = $id set n.toxicity='".$attributes['toxicity']."' , n.indications='".$attributes['indications']."' , n.source='".$attributes['source']."' , n.medicineProperty='".$attributes['medicineProperty']."' , n.includedIn='".$attributes['includedIn']."' , n.pageRankScore='".$attributes['pageRankScore']."' , n.pharmacology='".$attributes['pharmacology']."' , n.name='".$attributes['name']."'RETURN n";
  106. break;
  107. case 'CnPatentMedicine':
  108. $query = "match (n: CnPatentMedicine) where id(n) = $id set n.name='".$attributes['name']."' , n.pageRankScore='".$attributes['pageRankScore']."' return n";
  109. break;
  110. case 'Constitution':
  111. // "overallFeature" => "气机郁滞,以神情抑郁、忧虑脆弱等气郁表现为主要特征。"
  112. // "notEat" => "浓茶、咖啡"
  113. // "tendency" => "易患更年期综合征、乳腺增生、焦虑症、抑郁症或焦虑抑郁共病以及不孕症等。"
  114. // "kgid" => "14fbfe27a02d3ce6edf5d1f4e2f8d2b8d441e2ed7d90e05e56502db43add72db"
  115. // "exercise" => "增加户外活动和群体性活动,多跟朋友出门旅游,一起欣赏美景。 多听角音,如:《春风得意》、《江南好》、《春之声圆舞曲》、《蓝色多瑙河》、"
  116. // "statedIn" => "cn_sickness,Constitution"
  117. // "dateModified" => "2021-09-07T15:34:31"
  118. // "dietTherapy" => "多食能行气的食物, 米豆类:高粱、荞麦。 蔬菜类:蘑菇、柑橘、萝卜、洋葱、大蒜、苦瓜、丝瓜、黄花菜、海带、山楂、玫瑰花。"
  119. // "pageRankScore" => "0.17124999999999999"
  120. // "name" => "气郁质"
  121. // "psychologicalFeature" => "性格内向不稳定、敏感多虑。"
  122. // "commonPerformance" => "神情抑郁,情感脆弱,烦闷不乐,舌淡红,苔薄白,脉弦。"
  123. // "meridianHealth" => "可常点按内关穴、太冲穴调节气机,适当选用推拿、按摩、拔罐、刮痧等疗法。"
  124. // "medicineRegimen" => "可适量服用(加味)逍遥丸等行气解郁中成药制剂。"
  125. // "entityScore" => "17"
  126. // "graphId" => "sickness"
  127. // "id" => "235"
  128. $query = "match (n: Constitution) where id(n) = $id set n.overallFeature='".$attributes['overallFeature']."' , n.notEat='".$attributes['notEat']."' , n.tendency='".$attributes['tendency']."' , n.exercise='".$attributes['exercise']."', n.dietTherapy='".$attributes['dietTherapy']."' , n.pageRankScore='".$attributes['pageRankScore']."' , n.name='".$attributes['name']."', n.psychologicalFeature='".$attributes['psychologicalFeature']."' , n.commonPerformance='".$attributes['commonPerformance']."' , n.meridianHealth='".$attributes['meridianHealth']."' , n.medicineRegimen='".$attributes['medicineRegimen']."' return n";
  129. break;
  130. case 'Prescription':
  131. // "indications" => "胸膈满痛,得暖便轻,呕吐清水。"
  132. // "usageDosage" => "每服3钱,米汤送下。"
  133. // "composition" => "高良姜500g,香附(醋制)500g,炮制上二味,粉碎成细粉,过筛,混匀,用水泛丸,干燥,即得。口服3~6g,一日2次。"
  134. // "kgid" => "d6f4ebcdf584ede7ae1d5d9f4c5fc610cc7acd0229cc5bc46cc13a701c61e9eb"
  135. // "pageRankScore" => "0.20099999999999998"
  136. // "name" => "良附丸"
  137. // "statedIn" => "cn_sickness,Prescription"
  138. // "dateModified" => "2021-09-07T15:34:31"
  139. // "source" => "《实用方剂学》"
  140. // "entityScore" => "20"
  141. // "graphId" => "sickness"
  142. // "id" => "11"
  143. $query = "match (n: Prescription) where id(n) = $id set n.indications='".$attributes['indications']."' , n.usageDosage='".$attributes['usageDosage']."' , n.composition='".$attributes['composition']."' , n.pageRankScore='".$attributes['pageRankScore']."' , n.name='".$attributes['name']."', n.source='".$attributes['source']."' return n";
  144. break;
  145. case 'TonicDiet':
  146. // "composition" => "荸荠6枚,去皮洗净,打碎入锅,加清水煮汤,每日代茶饮用。30天为1个疗程"
  147. // "kgid" => "2b82850a3654c170f5dfab50a4f959bb214589f3d339a72b053f5c35f51a7201"
  148. // "pageRankScore" => "0.17124999999999999"
  149. // "name" => "荸荠汤"
  150. // "statedIn" => "cn_sickness,TonicDiet"
  151. // "dateModified" => "2021-09-07T15:34:31"
  152. // "entityScore" => "17"
  153. // "graphId" => "sickness"
  154. // "id" => "4"
  155. $query = "match (n: TonicDiet) where id(n) = $id set n.composition='".$attributes['composition']."' , n.pageRankScore='".$attributes['pageRankScore']."' , n.name='".$attributes['name']."' return n";
  156. break;
  157. case 'ChannelCollateral':
  158. $query = "match (n: ChannelCollateral) where id(n) = $id set n.name='".$attributes['name']."' , n.mechanismAnalysis='".$attributes['mechanismAnalysis']."' ,n.channelSymptom='".$attributes['channelSymptom']."',n.collateralSymptom='".$attributes['collateralSymptom']."',n.clinicalFeature='".$attributes['clinicalFeature']."' ,n.source='".$attributes['source']."' RETURN n";
  159. break;
  160. }
  161. $result = file_get_contents($this->host."neo4j/setNode?query=$query");
  162. if("{}" == $result) {
  163. return url()->previous();
  164. } else {
  165. return url()->previous();
  166. }
  167. }
  168. }