fetchModules.js 9.9 KB

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