fetchModules.js 12 KB

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