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