123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- namespace App\Model;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Pagination\LengthAwarePaginator;
- use Illuminate\Support\Facades\Request;
- class Test extends Model
- {
- private $host = "https://jm.jiankangche.cn/";
- public function paginate()
- {
- $page = Request::get('page' , 1);
- $perPage = Request::get('per_page', 10);
- $label = Request::get('label' , 'SickNess');
- $name = Request::get('name' , '');
- $start = ($page-1) * $perPage;
- $data = file_get_contents($this->host."neo4j/index?start=$start&perPage=$perPage&label=$label&name=$name");
- $data = json_decode($data , true);
- $movies = static::hydrate($data['list']);
- $total = $data['count'];
- $paginator = new LengthAwarePaginator($movies, $total, $perPage);
- $paginator->setPath(url()->current());
- return $paginator;
- }
- public static function with($relations)
- {
- return new static;
- }
- // 覆盖`orderBy`来收集排序的字段和方向
- public function orderBy($column, $direction = 'asc')
- {
- }
- // 覆盖`where`来收集筛选的字段和条件
- public function where($column, $operator = null, $value = null, $boolean = 'and')
- {
- }
- // 获取单项数据展示在form中
- public function findOrFail($id)
- {
- $data = file_get_contents($this->host."neo4j/detail?id=$id");
- $data = json_decode($data, true);
- return static::newFromBuilder($data);
- }
- // 获取lable
- public function getlabel($id)
- {
- $data = file_get_contents($this->host."neo4j/getlabels?id=$id");
- $labels = json_decode($data, true);
- return $labels[1];
- }
- // 保存提交的form数据
- public function save(array $options = [])
- {
- $attributes = $this->getAttributes();
- $id = $attributes['id'];
- $label = $this->getlabel($id);
- switch ($label) {
- case 'SickNess';
- // "tongueCondition" => "舌红苔燥"
- // "apparatus" => "心肺"
- // "kgid" => "4d839135f8627092b95602acf6dbb5237fadab9419bc88f2199ad7fe2d90ae31"
- // "therapeuticMethod" => "清解肺热"
- // "statedIn" => "cn_sickness"
- // "dateModified" => "2021-09-07T15:34:31"
- // "source" => "《丹溪心法》·卷之三(卷)·消渴(篇)"
- // "pulseCondition" => "脉洪"
- // "dietTherapy" => "益智仁"
- // "symptom" => "胸中烦燥,舌赤唇红,此渴引饮,常多,小便数而少。"
- // "pageRankScore" => "0.15"
- // "name" => "糖尿病(消渴)1"
- // "entityScore" => "15"
- // "department" => "内分泌科"
- // "graphId" => "sickness"
- // "acupuncturePoints" => "承浆 、 气舍 、 关冲 、 然谷"
- // "dialecticalName" => "心热移肺"
- // "id" => "401"
- $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";
- break;
- case 'Thing':
- // "composition" => "黄芪15g,太子参15g,麦冬10g,五味子10g,丹参30g,佛手10g,香橼10g,瓜蒌15g,熟地黄10g 。"
- // "kgid" => "65d07143c55c128595b15c1aed5f92d245b2ab80d2cf1f35e1f6b67981e4c1d4"
- // "pageRankScore" => "0.1925"
- // "name" => "益气阴达目络经验方"
- // "statedIn" => "cn_sickness,Prescription"
- // "dateModified" => "2021-09-07T15:34:31"
- // "entityScore" => "19"
- // "graphId" => "sickness"
- // "id" => "0"
- $query = "match (n: Thing) where id(n) = $id set n.composition='".$attributes['composition']."' , n.name='".$attributes['name']."' , n.pageRankScore='".$attributes['pageRankScore']."' RETURN n";
- break;
- case 'CnMedicinalCrop':
- // "toxicity" => "小毒"
- // "indications" => "根,根茎:补脾益气,清热解毒,止咳润肺,调和诸药;叶:止血。"
- // "kgid" => "94f6afb2d4fd4ad6b1ee4232a8425a3608a1ff290037db636224d7a762a6d452"
- // "statedIn" => "Prescription,CnMedicinalCrop"
- // "dateModified" => "2021-09-07T15:34:27"
- // "source" => "本品为豆科植物甘草Glycyrrhiza uralensis Fisch.、胀果甘草Glycyrrhiza inflata Bat.或光果甘草Glycyrrhiza glabra L.的干燥根和根茎。春、秋二季采挖,除去须根,晒干。"
- // "medicineProperty" => "甘,平。归心,肺,脾,胃经。"
- // "includedIn" => "《全国中草药汇编》 《全国中草药名鉴》 《中国药材标准名录》 《世界药用植物速查辞典》 《中华本草》 《抗肿瘤中药药理与临床》 《中国药典2015》"
- // "pageRankScore" => "8.465131746031744"
- // "pharmacology" => "肾上腺皮质激素样作用,抗病毒及抗菌作用,对消化系统的作用,抗炎作用,对免疫功能的影响,"
- // "name" => "甘草"
- // "entityScore" => "846"
- // "graphId" => "sickness"
- // "id" => "101"
- $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";
- break;
- case 'CnPatentMedicine':
- $query = "match (n: CnPatentMedicine) where id(n) = $id set n.name='".$attributes['name']."' , n.pageRankScore='".$attributes['pageRankScore']."' return n";
- break;
- case 'Constitution':
- // "overallFeature" => "气机郁滞,以神情抑郁、忧虑脆弱等气郁表现为主要特征。"
- // "notEat" => "浓茶、咖啡"
- // "tendency" => "易患更年期综合征、乳腺增生、焦虑症、抑郁症或焦虑抑郁共病以及不孕症等。"
- // "kgid" => "14fbfe27a02d3ce6edf5d1f4e2f8d2b8d441e2ed7d90e05e56502db43add72db"
- // "exercise" => "增加户外活动和群体性活动,多跟朋友出门旅游,一起欣赏美景。 多听角音,如:《春风得意》、《江南好》、《春之声圆舞曲》、《蓝色多瑙河》、"
- // "statedIn" => "cn_sickness,Constitution"
- // "dateModified" => "2021-09-07T15:34:31"
- // "dietTherapy" => "多食能行气的食物, 米豆类:高粱、荞麦。 蔬菜类:蘑菇、柑橘、萝卜、洋葱、大蒜、苦瓜、丝瓜、黄花菜、海带、山楂、玫瑰花。"
- // "pageRankScore" => "0.17124999999999999"
- // "name" => "气郁质"
- // "psychologicalFeature" => "性格内向不稳定、敏感多虑。"
- // "commonPerformance" => "神情抑郁,情感脆弱,烦闷不乐,舌淡红,苔薄白,脉弦。"
- // "meridianHealth" => "可常点按内关穴、太冲穴调节气机,适当选用推拿、按摩、拔罐、刮痧等疗法。"
- // "medicineRegimen" => "可适量服用(加味)逍遥丸等行气解郁中成药制剂。"
- // "entityScore" => "17"
- // "graphId" => "sickness"
- // "id" => "235"
- $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";
- break;
- case 'Prescription':
- // "indications" => "胸膈满痛,得暖便轻,呕吐清水。"
- // "usageDosage" => "每服3钱,米汤送下。"
- // "composition" => "高良姜500g,香附(醋制)500g,炮制上二味,粉碎成细粉,过筛,混匀,用水泛丸,干燥,即得。口服3~6g,一日2次。"
- // "kgid" => "d6f4ebcdf584ede7ae1d5d9f4c5fc610cc7acd0229cc5bc46cc13a701c61e9eb"
- // "pageRankScore" => "0.20099999999999998"
- // "name" => "良附丸"
- // "statedIn" => "cn_sickness,Prescription"
- // "dateModified" => "2021-09-07T15:34:31"
- // "source" => "《实用方剂学》"
- // "entityScore" => "20"
- // "graphId" => "sickness"
- // "id" => "11"
- $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";
- break;
- case 'TonicDiet':
- // "composition" => "荸荠6枚,去皮洗净,打碎入锅,加清水煮汤,每日代茶饮用。30天为1个疗程"
- // "kgid" => "2b82850a3654c170f5dfab50a4f959bb214589f3d339a72b053f5c35f51a7201"
- // "pageRankScore" => "0.17124999999999999"
- // "name" => "荸荠汤"
- // "statedIn" => "cn_sickness,TonicDiet"
- // "dateModified" => "2021-09-07T15:34:31"
- // "entityScore" => "17"
- // "graphId" => "sickness"
- // "id" => "4"
- $query = "match (n: TonicDiet) where id(n) = $id set n.composition='".$attributes['composition']."' , n.pageRankScore='".$attributes['pageRankScore']."' , n.name='".$attributes['name']."' return n";
- break;
- case 'ChannelCollateral':
- $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";
- break;
- }
- $result = file_get_contents($this->host."neo4j/setNode?query=$query");
- if("{}" == $result) {
- return url()->previous();
- } else {
- return url()->previous();
- }
- }
- }
|