fetchModules.js 13 KB

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