CurrentIll.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import CurrentIll from '@components/CurrentIll';
  4. import {INSERT_PROCESS,SET_CURRENT_DATA,SETTEXTMODEVALUE,SET_LABEL_MODULE,SELECT_SEARCHDATA,CLEAR_CURRENT_EDIT,SAVE_CURR_FREE} from '@store/types/currentIll';
  5. import {pushMessage} from '../store/async-actions/pushContainer';
  6. import {getModules} from '../store/async-actions/fetchModules.js';
  7. import {HIDE,RESET,CLICKCOUNT,ISREAD,SETDROPSHOW} from '@store/types/homePage';
  8. import {billing} from '@store/async-actions/pushMessage';
  9. import {getModule} from '@store/async-actions/fetchModules';
  10. import {didPushParamChange,filterDataArr} from '@utils/tools';
  11. import {Notify} from '@commonComp';
  12. function mapStateToProps(state) {
  13. const {homePage,currentIll,mainSuit,diagnosticList,typeConfig} = state;
  14. const hasMain = filterDataArr(mainSuit.saveText);
  15. return {
  16. data:currentIll.data,//主诉模板
  17. emptyData:currentIll.emptyData,//空模板
  18. searchData:currentIll.searchDatas,//搜索结果
  19. focusIndex:currentIll.focusIndex,
  20. processModule:currentIll.processModule,//病程变化模板
  21. showArr:homePage.showDrop,
  22. span:currentIll.span,
  23. update:currentIll.update,//用于更新
  24. mainText:mainSuit.saveText,//主诉选中的数据
  25. mainData:mainSuit.data,//主诉使用的模板
  26. symptomFeature:mainSuit.symptomFeature,//主诉分词数据
  27. moduleNum:mainSuit.moduleNum,//主诉使用的模板
  28. type: typeConfig.typeConfig,
  29. mainIds:mainSuit.mainIds,//主诉症状选中的id(去重用)
  30. mainTailIds:mainSuit.mainTailIds,//主诉症状选中的id(去重用)
  31. totalHide: homePage.totalHide,
  32. saveText:currentIll.saveText,
  33. editClear:currentIll.editClear,
  34. symptomIds:currentIll.symptomIds,//症状id,去重用
  35. isRead:homePage.isRead,
  36. fuzhen:diagnosticList.mainSuitStr,//诊断第一个复诊值
  37. allModules:homePage.allModules,
  38. // isChronic:!!diagnosticList.chronicMagItem,
  39. isChronic:mainSuit.chronicDesease?mainSuit.chronicDesease:diagnosticList.chronicMagItem,
  40. readMode:typeConfig.readMode, //回读回来的模式(与当前模式并存)
  41. hasMain, //是否有主诉
  42. }
  43. }
  44. function mapDispatchToProps(dispatch) {
  45. return {
  46. insertProcess(obj,allModules){//点击病程变化
  47. // 埋点dispatch
  48. dispatch({
  49. type:CLICKCOUNT,
  50. data:{id:obj.id},
  51. clickType:'单击',
  52. num:1
  53. });
  54. dispatch({
  55. type:INSERT_PROCESS,
  56. });
  57. dispatch({
  58. type:ISREAD
  59. })
  60. },
  61. async setData(info){//设置现病史使用模板
  62. // let idsArr = info.mainIds;
  63. let idsArr = info.mainTailIds.filter((it,i)=>{return it});
  64. // let ids = idsArr.join(",");
  65. let labelModule = await getModules(idsArr);
  66. if(labelModule.data.code==0){//根据id获取标签模板
  67. dispatch({
  68. type:SET_LABEL_MODULE,
  69. data:labelModule.data.data
  70. })
  71. }
  72. dispatch({
  73. type:SET_CURRENT_DATA,
  74. info
  75. })
  76. //右侧推送
  77. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  78. if(didPushParamChange()){ //操作后内容有变化才推送
  79. dispatch(billing('',2)); //参数意义:点到现病史时查体无数据则提前获取查体模板,避免点查体时模板返回慢
  80. }
  81. },500);
  82. },
  83. pushMessage: (data) => {
  84. dispatch(() => pushMessage(data))
  85. },
  86. //文本模式下推送
  87. fetchPushInfos(){
  88. //调右侧推送
  89. if(didPushParamChange()) {
  90. dispatch(billing());
  91. }
  92. },
  93. handleInput(obj){ //文本模式值保存
  94. dispatch({
  95. type:SETTEXTMODEVALUE,
  96. text:obj.text
  97. })
  98. },
  99. fetchModules(param){
  100. const {id,name,index,span,conceptId} = param;
  101. getModule(id).then((res)=>{
  102. if(res.data.code=='0'){
  103. dispatch({
  104. type:SELECT_SEARCHDATA,
  105. index,
  106. name,
  107. data: res.data.data,
  108. span,
  109. isReplace:false,
  110. conceptId
  111. });
  112. dispatch({
  113. type:ISREAD
  114. });
  115. /*
  116. * 选中后推送的入参可能变了,如输入心率搜索出心率不齐,
  117. * 500ms内心率不齐标签未选中,系统会推送入参心率,
  118. * 此时推送结果可能影响查体高亮结果且并不准确,
  119. * 所以选中后要重新推送
  120. * */
  121. if(didPushParamChange()){ //操作后内容有变化才推送
  122. dispatch(billing());
  123. }
  124. }
  125. });
  126. },
  127. changeEditIll(bool){
  128. dispatch({
  129. type:CLEAR_CURRENT_EDIT,
  130. editClear:bool
  131. })
  132. },
  133. freeText(item){//自由输入
  134. dispatch({
  135. type: SAVE_CURR_FREE,
  136. data:item
  137. });
  138. //右侧推送
  139. setTimeout(function(){
  140. if(didPushParamChange()){
  141. dispatch(billing());
  142. }
  143. },500);
  144. }
  145. }
  146. }
  147. const CurrentIllContainer = connect(
  148. mapStateToProps,
  149. mapDispatchToProps
  150. )(CurrentIll);
  151. export default CurrentIllContainer;