XyzskController.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Http\Controllers\Controller;
  4. use App\Model\Xyzsk;
  5. use Encore\Admin\Show;
  6. use Encore\Admin\Form;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Facades\Admin;
  9. use Encore\Admin\Layout\Content;
  10. use Encore\Admin\Controllers\ModelForm;
  11. use Illuminate\Support\Facades\Request;
  12. class XyzskController extends Controller
  13. {
  14. use ModelForm;
  15. public function index()
  16. {
  17. return Admin::content(function (Content $content) {
  18. $content->header('西医知识库');
  19. $content->description('列表');
  20. $content->body($this->grid());
  21. });
  22. }
  23. public function create()
  24. {
  25. return Admin::content(function (Content $content) {
  26. $content->header('西医知识库');
  27. $content->description('新增');
  28. $content->body($this->form());
  29. });
  30. }
  31. public function edit($id)
  32. {
  33. return Admin::content(function (Content $content) use ($id) {
  34. $content->header('西医知识库');
  35. $content->description();
  36. $content->body($this->form($id)->edit($id));
  37. });
  38. }
  39. protected function show($id)
  40. {
  41. $xyzsk = new Xyzsk();
  42. $show = new Show($xyzsk->findOrFail($id));
  43. $show->field('name' , '名称');
  44. $label = $xyzsk->getlabel($id);
  45. switch ($label) {
  46. case 'SickNess':
  47. $show->field('alias' , '疾病别名');
  48. $show->field('ICD10' , 'ICD10');
  49. $show->field('department' , '疾病类别');
  50. $show->field('introduction' , '疾病概述');
  51. $show->field('epidemiology' , '流行病学');
  52. $show->field('suitableFood' , '宜吃食物');
  53. $show->field('notEat' , '忌吃食物');
  54. $show->field('diagnostiCtriage' , '诊断鉴别');
  55. $show->field('precaution' , '预防');
  56. $show->field('nursingInfo' , '护理信息');
  57. $show->field('warmPrompt' , '温馨提示');
  58. $show->field('recommendedRecipe' , '推荐食谱');
  59. $show->field('treatmentOverview' , '治疗概述');
  60. $show->field('pathogenesis' , '病因');
  61. $show->field('basicKnowledgel' , '基本常识');
  62. $show->field('dietHealth' , '饮食保健');
  63. $show->field('symptom' , '证型');
  64. $show->field('complicationsOverview', '并发症概述');
  65. $show->field('treatmentInfo' , '治疗信息');
  66. break;
  67. case 'Disease':
  68. $show->field('nameEn' , '英文名称');
  69. $show->field('alias' , '疾病别名');
  70. $show->field('icd' , 'ICD号');
  71. $show->field('department' , '疾病类别');
  72. $show->field('epidemiology' , '流行病学');
  73. $show->field('sickOverview' , '疾病概述');
  74. $show->field('clinicalFeature' , '临床表现');
  75. $show->field('diagnosis' , '诊断');
  76. $show->field('treatment' , '治疗');
  77. $show->field('pathogenesis' , '发病机制');
  78. $show->field('inspection' , '相关检查');
  79. $show->field('laboratoryInspection' , '实验室检查');
  80. $show->field('b' , '病因');
  81. $show->field('auxiliaryExamination' , '其他辅助检查');
  82. $show->field('prognosis' , '预后');
  83. $show->field('complicationsOverview', '并发症概述');
  84. $show->field('precaution' , '预防');
  85. break;
  86. case 'Medicine':
  87. $show->field('pinyi' , '汉语拼音');
  88. $show->field('oldUse' , '老人用药');
  89. $show->field('chilldUse' , '儿童用药');
  90. $show->field('medicinePregnant' , '孕妇及哺乳期妇女用药');
  91. $show->field('usageDosage' , '用法用量');
  92. $show->field('notes' , '注意事项');
  93. $show->field('periodValidity' , '有效期');
  94. $show->field('indication' , '适应症');
  95. $show->field('storage' , '贮藏');
  96. $show->field('character' , '性状');
  97. $show->field('contraindication' , '禁忌');
  98. $show->field('pharmacologyToxicology' , '药理毒理');
  99. $show->field('specification' , '规格');
  100. $show->field('approvalNumber' , '批准号');
  101. $show->field('productionEnterprise' , '生产企业');
  102. $show->field('relateSick' , '相关疾病');
  103. $show->field('untowardEffect' , '不良反应');
  104. $show->field('majorConstituent' , '主要成分');
  105. break;
  106. case 'Inspection':
  107. $show->field('overview' , '概述');
  108. $show->field('annotation' , '附注');
  109. $show->field('principle' , '原理');
  110. $show->field('normalValue' , '正常值');
  111. $show->field('clinicalSignificance' , '临床意义');
  112. $show->field('reagent' , '试剂');
  113. $show->field('operation' , '操作方法');
  114. break;
  115. case 'Document':
  116. $show->field('abstract' , '摘要');
  117. $show->field('year' , '年份');
  118. break;
  119. case 'Guide':
  120. $show->field('enTitle' , '英文标题');
  121. $show->field('abstract' , '摘要');
  122. $show->field('source' , '数据来源');
  123. $show->field('constitutor' , '制定者');
  124. $show->field('year' , '年份');
  125. break;
  126. }
  127. $show->field('dateModified' , '日期');
  128. return $show;
  129. }
  130. /**
  131. * store resource
  132. */
  133. public function store()
  134. {
  135. $data = Request::except(['_token' , '_previous_' , 's']);
  136. foreach ($data as $key => $value)
  137. {
  138. if($data[$key])
  139. {
  140. if($data[$key] != strip_tags($data[$key])) {
  141. $data[$key] = htmlspecialchars($data[$key]);
  142. }
  143. }
  144. }
  145. $url = "https://zskweb.jiankangche.cn/neo4j/create_node";
  146. $ch = curl_init();
  147. $header = array(
  148. 'Content-Type:'.'application/json; charset=UTF-8'
  149. );
  150. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  151. curl_setopt($ch, CURLOPT_URL, $url);
  152. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  153. curl_setopt($ch, CURLOPT_POST, 1);
  154. curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($data));
  155. $result = curl_exec($ch);
  156. curl_close($ch);
  157. $result = json_decode($result , true);
  158. //dd($result);
  159. if(0 == $result['code']) {
  160. admin_success('消息提示', '保存成功!');
  161. return back();
  162. } else {
  163. admin_error('消息提示', '保存失败!');
  164. return back();
  165. }
  166. }
  167. public function update($id)
  168. {
  169. $data = Request::except(['_token' , '_previous_' , 's']);
  170. foreach ($data as $key => $value)
  171. {
  172. if($data[$key])
  173. {
  174. if($data[$key] != strip_tags($data[$key])) {
  175. $data[$key] = htmlspecialchars($data[$key]);
  176. }
  177. }
  178. }
  179. $data['id'] = $id;
  180. $result = (new xyzsk())->save($data);
  181. if('failure' === $result) {
  182. admin_error('消息提示', '保存失败!');
  183. return back();
  184. } else {
  185. admin_success('消息提示', '保存成功!');
  186. return back();
  187. }
  188. }
  189. protected function form($id = '')
  190. {
  191. if($id) {
  192. $label = (new xyzsk())->getlabel($id);
  193. // 编辑
  194. switch ($label) {
  195. case 'SickNess':
  196. return Admin::form(Xyzsk::class, function (Form $form) {
  197. $form->text('name' , '名称');
  198. $form->text('alias' , '疾病别名');
  199. $form->text('ICD10' , 'ICD10');
  200. $form->text('department' , '疾病类别');
  201. $form->editor('introduction' , '疾病概述');
  202. $form->editor('epidemiology' , '流行病学');
  203. $form->editor('suitableFood' , '宜吃食物');
  204. $form->editor('notEat' , '忌吃食物');
  205. $form->editor('diagnostiCtriage' , '诊断鉴别');
  206. $form->editor('precaution' , '预防');
  207. $form->editor('nursingInfo' , '护理信息');
  208. $form->editor('warmPrompt' , '温馨提示');
  209. $form->editor('recommendedRecipe' , '推荐食谱');
  210. $form->editor('treatmentOverview' , '治疗概述');
  211. $form->editor('pathogenesis' , '病因');
  212. $form->editor('basicKnowledgel' , '基本常识');
  213. $form->editor('dietHealth' , '饮食保健');
  214. $form->editor('symptom' , '证型');
  215. $form->editor('complicationsOverview', '并发症概述');
  216. $form->editor('treatmentInfo' , '治疗信息');
  217. });
  218. break;
  219. case 'Disease';
  220. return Admin::form(Xyzsk::class, function (Form $form) {
  221. $form->text('name' , '名称');
  222. $form->text('nameEn' , '英文名称');
  223. $form->text('alias' , '疾病别名');
  224. $form->text('icd' , 'ICD号');
  225. $form->text('department' , '疾病类别');
  226. $form->editor('epidemiology' , '流行病学');
  227. $form->editor('sickOverview' , '疾病概述');
  228. $form->editor('clinicalFeature' , '临床表现');
  229. $form->editor('diagnosis' , '诊断');
  230. $form->editor('treatment' , '治疗');
  231. $form->editor('pathogenesis' , '发病机制');
  232. $form->editor('inspection' , '相关检查');
  233. $form->editor('laboratoryInspection' , '实验室检查');
  234. $form->editor('etiology' , '病因');
  235. $form->editor('auxiliaryExamination' , '其他辅助检查');
  236. $form->editor('prognosis' , '预后');
  237. $form->editor('complicationsOverview' , '并发症概述');
  238. $form->editor('precaution' , '预防');
  239. });
  240. break;
  241. case 'Medicine';
  242. return Admin::form(Xyzsk::class, function (Form $form) {
  243. $form->text('name' , '名称');
  244. $form->text('pinyi' , '汉语拼音');
  245. $form->text('oldUse' , '老人用药');
  246. $form->text('chilldUse' , '儿童用药');
  247. $form->text('medicinePregnant' , '孕妇及哺乳期妇女用药');
  248. $form->text('usageDosage' , '用法用量');
  249. $form->text('notes' , '注意事项');
  250. $form->text('periodValidity' , '有效期');
  251. $form->text('indication' , '适应症');
  252. $form->text('storage' , '贮藏');
  253. $form->text('character' , '性状');
  254. $form->text('contraindication' , '禁忌');
  255. $form->text('pharmacologyToxicology' , '药理毒理');
  256. $form->text('specification' , '规格');
  257. $form->text('approvalNumber' , '批准号');
  258. $form->text('productionEnterprise' , '生产企业');
  259. $form->text('relateSick' , '相关疾病');
  260. $form->text('untowardEffect' , '不良反应');
  261. $form->text('majorConstituent' , '主要成分');
  262. });
  263. break;
  264. case 'Inspection':
  265. return Admin::form(Xyzsk::class, function (Form $form) {
  266. $form->text('name' , '名称');
  267. $form->text('annotation' , '附注');
  268. $form->text('principle' , '原理');
  269. $form->text('normalValue' , '正常值');
  270. $form->text('clinicalSignificance' , '临床意义');
  271. $form->text('reagent' , '试剂');
  272. $form->text('operation' , '操作方法');
  273. });
  274. break;
  275. case 'Document';
  276. return Admin::form(Xyzsk::class, function (Form $form) {
  277. $form->text('abstract' , '摘要');
  278. $form->text('year' , '年份');
  279. });
  280. break;
  281. case 'Guide';
  282. return Admin::form(Xyzsk::class, function (Form $form) {
  283. $form->text('name' , '名称');
  284. //$form->text('enTitle' , '英文标题');
  285. $form->textarea('abstract' , '摘要');
  286. $form->textarea('source' , '数据来源');
  287. $form->textarea('constitutor' , '制定者');
  288. $form->text('year' , '年份');
  289. });
  290. break;
  291. case 'Symptom':
  292. return Admin::form(Xyzsk::class, function (Form $form) {
  293. $form->text('name' , '名称');
  294. $form->text('identify' , '识别');
  295. $form->text('abstract' , '摘要');
  296. $form->text('precaution' , '预防措施');
  297. $form->text('inspection' , '检查');
  298. $form->text('etiology' , '病理');
  299. });
  300. break;
  301. }
  302. } else {
  303. if(stripos($url = $_SERVER['HTTP_REFERER'] , 'label') !== false) {
  304. $urlDeail = parse_url($url);
  305. $query = $urlDeail['query'];
  306. $queryArr = explode('=', $query);
  307. $label = $queryArr[1];
  308. return Admin::form(Xyzsk::class, function (Form $form) use ($label) {
  309. $form->select('label' , '标签')->options([$label => $label])->required();
  310. switch ($label) {
  311. case 'SickNess':
  312. $form->text('name' , '名称');
  313. $form->text('alias' , '疾病别名');
  314. $form->text('ICD10' , 'ICD10');
  315. $form->text('department' , '疾病类别');
  316. $form->editor('introduction' , '疾病概述');
  317. $form->editor('epidemiology' , '流行病学');
  318. $form->editor('suitableFood' , '宜吃食物');
  319. $form->editor('notEat' , '忌吃食物');
  320. $form->editor('diagnostiCtriage' , '诊断鉴别');
  321. $form->editor('precaution' , '预防');
  322. $form->editor('nursingInfo' , '护理信息');
  323. $form->editor('warmPrompt' , '温馨提示');
  324. $form->editor('recommendedRecipe' , '推荐食谱');
  325. $form->editor('treatmentOverview' , '治疗概述');
  326. $form->editor('pathogenesis' , '病因');
  327. $form->editor('basicKnowledgel' , '基本常识');
  328. $form->editor('dietHealth' , '饮食保健');
  329. $form->editor('symptom' , '证型');
  330. $form->editor('complicationsOverview', '并发症概述');
  331. $form->editor('treatmentInfo' , '治疗信息');
  332. break;
  333. case 'Disease':
  334. $form->text('name' , '名称');
  335. $form->text('nameEn' , '英文名称');
  336. $form->text('alias' , '疾病别名');
  337. $form->text('icd' , 'ICD号');
  338. $form->text('department' , '疾病类别');
  339. $form->editor('sickOverview' , '疾病概述');
  340. $form->editor('epidemiology' , '流行病学');
  341. $form->editor('clinicalFeature' , '临床表现');
  342. $form->editor('diagnosis' , '诊断');
  343. $form->editor('treatment' , '治疗');
  344. $form->editor('pathogenesis' , '发病机制');
  345. $form->editor('inspection' , '相关检查');
  346. $form->editor('laboratoryInspection' , '实验室检查');
  347. $form->editor('etiology' , '病因');
  348. $form->editor('auxiliaryExamination' , '其他辅助检查');
  349. $form->editor('prognosis' , '预后');
  350. $form->editor('complicationsOverview' , '并发症概述');
  351. $form->editor('precaution' , '预防');
  352. break;
  353. case 'Medicine':
  354. $form->text('name' , '名称');
  355. $form->text('pinyi' , '汉语拼音');
  356. $form->text('oldUse' , '老人用药');
  357. $form->text('chilldUse' , '儿童用药');
  358. $form->text('medicinePregnant' , '孕妇及哺乳期妇女用药');
  359. $form->text('usageDosage' , '用法用量');
  360. $form->text('notes' , '注意事项');
  361. $form->text('periodValidity' , '有效期');
  362. $form->text('indication' , '适应症');
  363. $form->text('storage' , '贮藏');
  364. $form->text('character' , '性状');
  365. $form->text('contraindication' , '禁忌');
  366. $form->text('pharmacologyToxicology' , '药理毒理');
  367. $form->text('specification' , '规格');
  368. $form->text('approvalNumber' , '批准号');
  369. $form->text('productionEnterprise' , '生产企业');
  370. $form->text('relateSick' , '相关疾病');
  371. $form->text('untowardEffect' , '不良反应');
  372. $form->text('majorConstituent' , '主要成分');
  373. break;
  374. case 'Inspection':
  375. $form->text('name' , '名称');
  376. $form->text('annotation' , '附注');
  377. $form->text('principle' , '原理');
  378. $form->text('normalValue' , '正常值');
  379. $form->text('clinicalSignificance' , '临床意义');
  380. $form->text('reagent' , '试剂');
  381. $form->text('operation' , '操作方法');
  382. break;
  383. case 'Document':
  384. $form->text('abstract' , '摘要');
  385. $form->text('year' , '年份');
  386. break;
  387. case 'Guide':
  388. $form->text('name' , '名称');
  389. $form->text('enTitle' , '英文标题');
  390. $form->text('abstract' , '摘要');
  391. $form->text('source' , '数据来源');
  392. $form->text('constitutor' , '制定者');
  393. $form->text('year' , '年份');
  394. break;
  395. case 'Symptom':
  396. $form->text('name' , '名称');
  397. $form->text('identify' , '识别');
  398. $form->text('abstract' , '摘要');
  399. $form->text('precaution' , '预防措施');
  400. $form->text('inspection' , '检查');
  401. $form->text('etiology' , '病理');
  402. break;
  403. }
  404. });
  405. }
  406. }
  407. }
  408. // Grid
  409. protected function grid()
  410. {
  411. return Admin::grid(Xyzsk::class, function (Grid $grid) {
  412. $label = request('label') ?? 'SickNess';
  413. //$grid->id('Id')->setAttributes(['style' => 'font-family:PMingLiU;']);
  414. $grid->name('名称')->setAttributes(['style' => 'font-family:PMingLiU;']);
  415. switch ($label) {
  416. case 'SickNess':
  417. $grid->alias('疾病别名')->setAttributes(['style' => 'font-family:PMingLiU;']);
  418. $grid->ICD10('ICD10')->setAttributes(['style' => 'font-family:PMingLiU;']);
  419. $grid->department('疾病类别')->setAttributes(['style' => 'font-family:PMingLiU;']);
  420. break;
  421. case 'Disease':
  422. $grid->alias('疾病别名')->setAttributes(['style' => 'font-family:PMingLiU;']);
  423. $grid->icd('icd')->setAttributes(['style' => 'font-family:PMingLiU;']);
  424. $grid->department('疾病类别')->setAttributes(['style' => 'font-family:PMingLiU;']);
  425. break;
  426. case 'Medicine':
  427. $grid->pinyi('汉语拼音')->setAttributes(['style' => 'font-family:PMingLiU;']);
  428. $grid->indication('适应症')->setAttributes(['style' => 'font-family:PMingLiU;']);
  429. $grid->majorConstituent('主要成分')->setAttributes(['style' => 'font-family:PMingLiU;']);
  430. break;
  431. case 'Inspection':
  432. $grid->overview('概述')->setAttributes(['style' => 'font-family:PMingLiU;']);
  433. $grid->annotation('附注')->setAttributes(['style' => 'font-family:PMingLiU;']);
  434. $grid->operation('操作方法')->setAttributes(['style' => 'font-family:PMingLiU;']);
  435. break;
  436. case 'Document':
  437. $grid->abstract('摘要')->setAttributes(['style' => 'font-family:PMingLiU;']);
  438. $grid->year('年份')->setAttributes(['style' => 'font-family:PMingLiU;']);
  439. break;
  440. case 'Guide':
  441. $grid->enTitle('英文标题')->setAttributes(['style' => 'font-family:PMingLiU;']);
  442. $grid->year('年份')->setAttributes(['style' => 'font-family:PMingLiU;']);
  443. break;
  444. case 'Symptom':
  445. $grid->identify('识别');
  446. $grid->abstract('摘要');
  447. $grid->precaution('预防措施');
  448. $grid->inspection('检查');
  449. $grid->etiology('病理');
  450. break;
  451. }
  452. $grid->dateModified('日期')->setAttributes(['style' => 'font-family:PMingLiU;']);
  453. //$grid->classification();
  454. $grid->paginate(20);
  455. //$grid->disableCreateButton();
  456. // 禁用导出数据按钮
  457. $grid->actions(function ($actions) {
  458. // $actions->disableView();
  459. // $actions->disableEdit();
  460. $actions->disableDelete();
  461. //$actions->add(new Update());
  462. //dd($actions->row);
  463. });
  464. $grid->disableExport();
  465. $grid->filter(function ($filter) {
  466. $filter->disableIdFilter();
  467. $filter->like('name' , '输入搜索名称');
  468. });
  469. });
  470. }
  471. }