fetchModules.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. import {json} from '@utils/ajax.js';
  2. import {SET,PRESET} from '@types/checkBody.js';
  3. import {SETDATA} from '@store/types/otherHistory';
  4. import store from '@store';
  5. import {getEMRParams,didPushParamChange,inspectAndAssist,fullfillText} from '@utils/tools.js';
  6. import {Notify} from '@commonComp';
  7. import {billing} from '@store/async-actions/pushMessage';
  8. import {SETOTHERHISTORY,ISREAD} from "../types/homePage";
  9. import {SAVE_TABLE_RESULT,SET_CHRONIC_PUSHS} from "../types/pushMessage";
  10. import config from "@config/index";
  11. import {CURRENT_CHRONIC} from '@store/types/currentIll';
  12. import {MODI_LOADING} from '@store/types/homePage.js';
  13. const api={
  14. // getSpreadModule:'/questionInfo/getByIds',
  15. getSpreadModule:'/questionInfo/getByIds2',//优化
  16. getModule:'/questionInfo/getById',
  17. searchURL: '/retrieval/getTagInfos',
  18. getOtherHisRecord: '/inquiryInfo/getLastOther',
  19. getBigPush:'/push/pushInner',
  20. saveMode:'/doctorPageMode/saveDoctorPageModes',
  21. getSymptomFeature:'/feature/getSymptomFeature',
  22. getAssess:'/evaluationModuleMapping/getEvaluationModules', //获取管理评估-慢病
  23. getIndexData:'/indexData/getIndexDatas', //获取指标数据-图表-慢病
  24. // getFormulaResult:'/push/calculate', // 计算接口
  25. getFormulaResult:'/calc/calculate', // 计算接口
  26. getAssessHis:'/inquiryInfo/getEvaluations', //历史评估记录
  27. };
  28. export const getFeature = (item)=>{
  29. const datas = json(api.getSymptomFeature+'?text='+item,{});
  30. return datas;
  31. }
  32. //获取模板,多个
  33. export const getModules = (ids)=>{
  34. const {patInfo} = store.getState();
  35. const param = {
  36. "age": patInfo.message.patientAge,
  37. "ids": ids,
  38. "sexType": patInfo.message.sex
  39. };
  40. const modules = json(api.getSpreadModule,param);
  41. return modules;
  42. };
  43. //获取单个模板
  44. export const getModule = (id)=>{
  45. const {patInfo} = store.getState();
  46. const param = {
  47. "age": patInfo.message.patientAge,
  48. "id": id,
  49. "sexType": patInfo.message.sex
  50. };
  51. return json(api.getModule,param);
  52. };
  53. //搜索接口
  54. export const getSearch = (param)=>{
  55. const {patInfo} = store.getState();
  56. const {inpStr,boxMark,mainIds,itemType} = param;
  57. let params = {};
  58. if(itemType==0){//主诉,仅限症状
  59. params = {
  60. "age": patInfo.message.patientAge,
  61. "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
  62. "inputStr": inpStr.trim(),
  63. "sexType": patInfo.message.sex,
  64. "type": boxMark, //1为主诉现病史
  65. "itemType":itemType
  66. };
  67. }else{
  68. params = {
  69. "age": patInfo.message.patientAge,
  70. "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
  71. "inputStr": inpStr.trim(),
  72. // "inputStr": inpStr,
  73. "sexType": patInfo.message.sex,
  74. "type": boxMark //1为搜症状
  75. };
  76. }
  77. return json(api.searchURL,params);
  78. };
  79. //其他史最近记录获取
  80. export const getOtherHisRecord = ()=>{
  81. return (dispatch,getStore)=>{
  82. const state = getStore();
  83. const {message} =state.patInfo;
  84. const mode = state.typeConfig.typeConfig;
  85. const param = {
  86. hospitalCode:message.hospitalCode,
  87. patientCode:message.patientCode,
  88. sign:mode
  89. };
  90. json(api.getOtherHisRecord,param).then((res)=>{
  91. if(res.data.code=='0'){
  92. const data = res.data.data;
  93. const obj = JSON.parse(data.dataJson||'{}');
  94. const objStr = JSON.parse(data.otherStr||'[]');
  95. let arr = [];//console.log(obj)
  96. if((!obj||!obj.other||obj.other.length==0)&&!objStr[0]){ //无其他史历史记录用默认模板
  97. if(mode=='1'){ //文本模式
  98. dispatch({
  99. type:SETOTHERHISTORY,
  100. data:[],
  101. selecteds:[],
  102. save:[]
  103. });
  104. }
  105. //console.log('其他史最近数据无')
  106. //arr = state.homePage.initData.otherHis;
  107. }else{
  108. arr = obj.other;
  109. if(mode =='1'){ //文本模式
  110. dispatch({
  111. type:SETOTHERHISTORY,
  112. data:[],
  113. selecteds:[],
  114. save:[objStr[0]]
  115. });
  116. }else{
  117. dispatch({
  118. type:SETOTHERHISTORY,
  119. data:arr,
  120. period:{
  121. yjs_1: obj.yjs_1,
  122. yjs_2: obj.yjs_2,
  123. yjs_3: obj.yjs_3,
  124. yjs_4: obj.yjs_4,
  125. },
  126. selecteds:obj.otherHistorySelecteds,
  127. save:objStr
  128. });
  129. }
  130. }
  131. }
  132. });
  133. }
  134. };
  135. //预取查体模板数据-现病史触发推送时获取
  136. export function pregetCheckbodyData(flag){ //flag=true获取到数据后立即显示
  137. return (dispatch)=>{
  138. if(flag){
  139. dispatch({type:MODI_LOADING,flag:true});
  140. }
  141. const emrData = getEMRParams();
  142. const param = {
  143. age: emrData.age,
  144. featureType: "1,4,7",
  145. diag: emrData.dis,
  146. lis: emrData.lis,
  147. other: emrData.other,
  148. pacs: emrData.pacs,
  149. sex: emrData.sex,
  150. vital:emrData.vital,
  151. symptom: emrData.current+emrData.main
  152. };
  153. json(api.getBigPush,param).then((res)=>{
  154. if(+res.data.code === 0){
  155. const data = res.data.data&&res.data.data.vital;
  156. dispatch({
  157. type:PRESET,
  158. data:data
  159. });
  160. if(flag){
  161. const arr = fullfillText(data,false,false,false).newArr;
  162. dispatch({
  163. type:SET,
  164. data:arr,
  165. isEmpty:false
  166. });
  167. dispatch({type:MODI_LOADING,flag:false});
  168. }
  169. }else{
  170. Notify.error(res.data.msg);
  171. }
  172. });
  173. }
  174. }
  175. //查体模板数据获取
  176. export function getInitData(){
  177. return (dispatch,getStore)=>{
  178. const state = getStore();
  179. const preData = [...state.checkBody.preData];
  180. if(!preData||preData.length==0){
  181. dispatch(pregetCheckbodyData(true));
  182. }
  183. const arr = fullfillText(preData,false,false,false).newArr;
  184. dispatch({
  185. type:SET,
  186. data:arr,
  187. isEmpty:false
  188. });
  189. }
  190. }
  191. //其他史模板填充-先取最近记录,无则用模板
  192. export function setOtherHisModule(){
  193. return (dispatch, getStore) => {
  194. const state = getStore();
  195. const initData = state.homePage.initData;
  196. const block = Object.assign(JSON.parse(config.textLabel),{full:true});
  197. const mode = state.typeConfig.typeConfig;
  198. const model = JSON.parse(JSON.stringify(initData.otherHisModel || null))||[block]; //查体模板
  199. const arr = JSON.parse(JSON.stringify(initData.otherHis || null)); //最近其他史数据
  200. const arrSave = JSON.parse(JSON.stringify(initData.otherHisSave || null)); //最近其他史saveText
  201. const selects = JSON.parse(JSON.stringify(initData.otherSelecteds || null)); //其他史杂音类选中项
  202. const isHis = initData.otherIsHis; //是否是历史数据
  203. const onlyOneText = arr && arr.length == 1 && arr[0].tagType == 8 && !arr[0].value; //是否只有一个自由文本标签
  204. const listObj = isHis && (mode == 1 || (!onlyOneText && mode == 0)) ? {
  205. newArr: arr,
  206. saveText: arrSave || []
  207. } : fullfillText(model);
  208. dispatch({
  209. type: SETDATA,
  210. data: listObj.newArr,
  211. selecteds: selects,
  212. period: initData.period,
  213. save: listObj.saveText,
  214. isEmpty: false
  215. });
  216. dispatch({
  217. type: ISREAD
  218. });
  219. //右侧推送
  220. setTimeout(function () { //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  221. if (didPushParamChange()) { //操作后内容有变化才推送
  222. dispatch(billing());
  223. }
  224. }, 500);
  225. }
  226. }
  227. //保存切换模式
  228. export function saveMode(mode){
  229. return (dispatch,getStore)=>{
  230. const {patInfo} = getStore();
  231. const param = {
  232. doctorId:patInfo.message.doctorId,
  233. modeClassify:0,
  234. modeValue:mode
  235. };
  236. return json(api.saveMode,param);
  237. }
  238. }
  239. //慢病-获取管理评估
  240. export function getAssessData(disId,disName){
  241. return ()=>{
  242. const emrData = getEMRParams();
  243. const param = {
  244. diseaseId:disId,
  245. disType:1,
  246. diag:disName,
  247. diseaseName:disName,
  248. featureType:11,
  249. lis:emrData.lis,
  250. sex:emrData.sex,
  251. age:emrData.age,
  252. symptom:emrData.current + emrData.main
  253. };
  254. return json(api.getAssess,param);
  255. }
  256. }
  257. //慢病-获取管理评估历史单条记录
  258. export function getAssessHis(id){
  259. return (dispatch,getStore)=>{
  260. const param = {
  261. inquiryId:id,
  262. };
  263. return json(api.getAssessHis,param);
  264. }
  265. }
  266. //获取评估中图表数据
  267. export function getIndexData(range){
  268. return (dispatch,getStore)=>{
  269. const {patInfo} = getStore();
  270. const param = {
  271. diseaseId:21773,
  272. startTime:range[0],
  273. endTime:range[1]+" 23:23:59",
  274. patientId:patInfo.message.patientId,
  275. };
  276. return json(api.getIndexData,param);
  277. }
  278. }
  279. // 计算接口
  280. /*export const getFormulaResult = (item)=>{
  281. // type:1-量表 2-计算公式
  282. const type = item.type;
  283. let param = {
  284. type:type,
  285. data:item.data
  286. }
  287. return (dispatch,getState) => {
  288. const state = getState();
  289. json(api.getFormulaResult,param).then((res)=>{
  290. if(+res.data.code==0){
  291. if(type==1){//量表
  292. dispatch({
  293. type:SAVE_TABLE_RESULT,
  294. // id:item.pId, //外层疾病id
  295. id:item.id, //量表id
  296. data:Object.assign({},res.data.data,{pIndex:item.pIndex})
  297. })
  298. }else if(type==2){//计算公式
  299. const data = state.pushMessage.chronicPushItems
  300. data[item.ppIndex].details[item.pIndex].content.result = res.data.data.result
  301. dispatch({
  302. type: SET_CHRONIC_PUSHS,
  303. data: JSON.parse(JSON.stringify(data))
  304. })
  305. console.log('resss', res)
  306. }
  307. }else{
  308. Notify.error(res.data.msg);
  309. }
  310. })
  311. }
  312. }*/
  313. export const getFormulaResult = (item)=>{
  314. // type:1-量表 2-计算公式
  315. const type = item.type;
  316. let param = {
  317. type:type,
  318. data:item.data
  319. }
  320. return json(api.getFormulaResult,param);
  321. }
  322. // 自动分发模板
  323. export function autoFillModules (){
  324. return (dispatch,getStore)=>{
  325. const state = getStore();
  326. const initData = state.homePage.initData;
  327. const block = Object.assign(JSON.parse(config.textLabel),{full:true});
  328. const cbody = initData.checkbody?[...initData.checkbody]:[block];
  329. dispatch({type: CURRENT_CHRONIC})//现病史
  330. //其他史模板填充-先去历史,无历史用模板
  331. inspectAndAssist()//化验辅检
  332. dispatch(setOtherHisModule());
  333. //查体模板填充
  334. dispatch({
  335. type: SET,
  336. data: cbody,
  337. isEmpty:false
  338. });
  339. }
  340. }