diagnosticSearch.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { json } from "@utils/ajax";
  2. import { GET_SEARCH_RESULT, SHOWNODATATEXT } from '@store/types/diagnosticSearch';
  3. import { GET_SEARCH } from '@store/types/emergencyHis';
  4. import { Notify } from '@commonComp';
  5. import { formatFormParmas } from '@utils/tools';
  6. import store from '@store';
  7. export const getSearchList = (val,flag) => {
  8. const state = store.getState();
  9. //console.log(state)
  10. const showTcm = state.diagnosticSearch.showTcm;
  11. const showSym = state.diagnosticSearch.showSym;
  12. if(val.trim() == ''){
  13. // const data = [];
  14. if(flag){
  15. return (dispatch) => dispatch({
  16. type: GET_SEARCH,
  17. searchResult: []
  18. })
  19. }
  20. return (dispatch) => dispatch({
  21. type: GET_SEARCH_RESULT,
  22. searchResult: []
  23. })
  24. }
  25. return (dispatch, getState) => {
  26. const state = getState();
  27. let baseList = state;
  28. const diagnosticList = flag?state.emergencyHis.searchData:state.diagnosticList.diagnosticList;
  29. let noIds = []
  30. for(let i = 0; i < diagnosticList.length; i++) {
  31. if(diagnosticList[i].conceptId) {
  32. noIds.push(diagnosticList[i].conceptId)
  33. }
  34. }
  35. json('/demo/retrieval/index',{
  36. "type":showTcm?'12':(showSym?'13':'4'),
  37. "age": formatFormParmas('patientAge',state.patInfo.patInfoData),
  38. "inputStr": val.trim(),
  39. "sex": formatFormParmas('patientSex',state.patInfo.patInfoData),
  40. "hospitalId":baseList.homePage.curHos.hosId
  41. })
  42. .then((res)=>{
  43. if(res.data.code==0){
  44. const data = res.data.data;let curDate=[];
  45. let arr = data[showTcm?'tcmdiseaseNames':(showSym?'tcmsyndromeNames':'diseaseNames')]||[];
  46. for(let i = 0;i < arr.length;i++){
  47. let tmp = arr[i]
  48. let obj = {}
  49. obj['name'] = tmp.name;
  50. obj['uniqueName'] = tmp.name;
  51. obj['conceptId'] = '';
  52. obj['icd10Code'] = tmp.icd10Code||tmp.code;
  53. //obj['code'] = tmp.code;
  54. curDate.push(obj)
  55. }
  56. if(flag){
  57. dispatch({
  58. type: GET_SEARCH,
  59. searchResult: curDate
  60. })
  61. }else{
  62. dispatch({
  63. type: GET_SEARCH_RESULT,
  64. searchResult: curDate
  65. })
  66. // 是否进行过搜索
  67. dispatch({
  68. type: SHOWNODATATEXT,
  69. isShowNoDataInfo: true
  70. });
  71. }
  72. }else{
  73. Notify.error(res.data.msg)
  74. }
  75. })
  76. }
  77. };