fetchModules.js 8.9 KB

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