fetchModules.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import {json} from '@utils/ajax.js';
  2. import {SET} from '@types/checkBody.js';
  3. import {fullfillText,_fullfillText} from '@common/js/func';
  4. import {SETDATA} from '@store/types/otherHistory';
  5. import store from '@store';
  6. import {getEMRParams} from '@utils/tools.js';
  7. import {Notify} from '@commonComp';
  8. import {SETOTHERHISTORY} from "../types/homePage";
  9. import config from "@config/index";
  10. const api={
  11. getSpreadModule:'/api/icss/questionInfo/getByIds',
  12. getModule:'/api/icss/questionInfo/getById',
  13. searchURL: '/api/icss/retrieval/getTagInfos',
  14. getOtherHisRecord: '/api/icss/inquiryInfo/getLastOther',
  15. getBigPush:'/api/icss/push/pushInner',
  16. saveMode:'/api/icss/doctorPageMode/saveDoctorPageModes',
  17. };
  18. //获取模板,多个
  19. export const getModules = (ids)=>{
  20. const {patInfo} = store.getState();
  21. const param = {
  22. "age": patInfo.message.patientAge,
  23. "ids": ids,
  24. "sexType": patInfo.message.sex
  25. };
  26. const modules = json(api.getSpreadModule,param);
  27. return modules;
  28. };
  29. //获取单个模板
  30. export const getModule = (id)=>{
  31. const {patInfo} = store.getState();
  32. const param = {
  33. "age": patInfo.message.patientAge,
  34. "id": id,
  35. "sexType": patInfo.message.sex
  36. };
  37. return json(api.getModule,param);
  38. };
  39. //搜索接口
  40. export const getSearch = (param)=>{
  41. const {patInfo} = store.getState();
  42. const {inpStr,boxMark,mainIds} = param;
  43. const params = {
  44. "age": patInfo.message.patientAge,
  45. "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
  46. // "inputStr": inpStr.trim(),
  47. "inputStr": inpStr,
  48. "sexType": patInfo.message.sex,
  49. "type": boxMark //1为搜症状
  50. };
  51. return json(api.searchURL,params);
  52. };
  53. //其他史最近记录获取
  54. export const getOtherHisRecord = ()=>{
  55. return (dispatch,getStore)=>{
  56. const state = getStore();
  57. const {message} =state.patInfo;
  58. const mode = state.typeConfig.typeConfig;
  59. const param = {
  60. hospitalCode:message.hospitalCode,
  61. patientCode:message.patientCode,
  62. sign:mode
  63. };
  64. json(api.getOtherHisRecord,param).then((res)=>{
  65. if(res.data.code=='0'){
  66. const data = res.data.data;
  67. const obj = JSON.parse(data.dataJson||'{}');
  68. const objStr = JSON.parse(data.otherStr||'[]');
  69. let arr = [];
  70. if((!obj||!obj.other||obj.other.length==0)&&!objStr[0]){ //无其他史历史记录用默认模板
  71. //console.log('其他史最近数据无')
  72. //arr = state.homePage.initData.otherHis;
  73. }else{
  74. arr = obj.other;
  75. dispatch({
  76. type:SETOTHERHISTORY,
  77. data:arr,
  78. save:objStr
  79. });
  80. }
  81. }
  82. });
  83. }
  84. };
  85. //查体模板数据获取
  86. export function getInitData(){
  87. return (dispatch)=>{
  88. const emrData = getEMRParams();
  89. const param = {
  90. age: emrData.age,
  91. featureType: "1,4,7",
  92. diag: emrData.dis,
  93. lis: emrData.lis,
  94. other: emrData.other,
  95. pacs: emrData.pacs,
  96. sex: emrData.sex,
  97. vital:emrData.vital,
  98. symptom: emrData.current||emrData.main
  99. };
  100. json(api.getBigPush,param).then((res)=>{
  101. if(+res.data.code === 0){
  102. const data = res.data.data&&res.data.data.vital;
  103. const str = JSON.stringify(data);
  104. const arr = fullfillText(JSON.parse(str),false,false,false).newArr;
  105. dispatch({
  106. type:SET,
  107. data:[...arr],
  108. isEmpty:false
  109. });
  110. }else{
  111. const block = Object.assign(JSON.parse(config.textLabel),{full:true}); //无数据时保留一个自由文本标签可输入
  112. dispatch({
  113. type:SET,
  114. data:[block],
  115. isEmpty:false
  116. });
  117. Notify.error(res.data.msg);
  118. }
  119. });
  120. }
  121. }
  122. //保存切换模式
  123. export function saveMode(mode){
  124. return (dispatch,getStore)=>{
  125. const {patInfo} = getStore();
  126. const param = {
  127. doctorId:patInfo.message.doctorId,
  128. modeClassify:0,
  129. modeValue:mode
  130. };
  131. return json(api.saveMode,param);
  132. }
  133. }