fetchModules.js 12 KB

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