fetchModules.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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} from '@utils/tools.js';
  7. import {Notify} from '@commonComp';
  8. import {SETOTHERHISTORY} from "../types/homePage";
  9. import {SAVE_TABLE_RESULT} from "../types/pushMessage";
  10. import config from "@config/index";
  11. const api={
  12. getSpreadModule:'/questionInfo/getByIds',
  13. getModule:'/questionInfo/getById',
  14. searchURL: '/retrieval/getTagInfos',
  15. getOtherHisRecord: '/inquiryInfo/getLastOther',
  16. getBigPush:'/push/pushInner',
  17. saveMode:'/doctorPageMode/saveDoctorPageModes',
  18. getSymptomFeature:'/feature/getSymptomFeature',
  19. getAssess:'/evaluationModuleMapping/getEvaluationModules', //获取管理评估-慢病
  20. getIndexData:'/indexData/getIndexDatas', //获取指标数据-图表-慢病
  21. getFormulaResult:'/push/calculate', // 计算接口
  22. };
  23. export const getFeature = (item)=>{
  24. const datas = json(api.getSymptomFeature+'?text='+item,{});
  25. return datas;
  26. }
  27. //获取模板,多个
  28. export const getModules = (ids)=>{
  29. const {patInfo} = store.getState();
  30. const param = {
  31. "age": patInfo.message.patientAge,
  32. "ids": ids,
  33. "sexType": patInfo.message.sex
  34. };
  35. const modules = json(api.getSpreadModule,param);
  36. return modules;
  37. };
  38. //获取单个模板
  39. export const getModule = (id)=>{
  40. const {patInfo} = store.getState();
  41. const param = {
  42. "age": patInfo.message.patientAge,
  43. "id": id,
  44. "sexType": patInfo.message.sex
  45. };
  46. return json(api.getModule,param);
  47. };
  48. //搜索接口
  49. export const getSearch = (param)=>{
  50. const {patInfo} = store.getState();
  51. const {inpStr,boxMark,mainIds,itemType} = param;
  52. let params = {};
  53. if(itemType==0){//主诉,仅限症状
  54. params = {
  55. "age": patInfo.message.patientAge,
  56. "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
  57. "inputStr": inpStr.trim(),
  58. "sexType": patInfo.message.sex,
  59. "type": boxMark, //1为主诉现病史
  60. "itemType":itemType
  61. };
  62. }else{
  63. params = {
  64. "age": patInfo.message.patientAge,
  65. "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
  66. "inputStr": inpStr.trim(),
  67. // "inputStr": inpStr,
  68. "sexType": patInfo.message.sex,
  69. "type": boxMark //1为搜症状
  70. };
  71. }
  72. return json(api.searchURL,params);
  73. };
  74. //其他史最近记录获取
  75. export const getOtherHisRecord = ()=>{
  76. return (dispatch,getStore)=>{
  77. const state = getStore();
  78. const {message} =state.patInfo;
  79. const mode = state.typeConfig.typeConfig;
  80. const param = {
  81. hospitalCode:message.hospitalCode,
  82. patientCode:message.patientCode,
  83. sign:mode
  84. };
  85. json(api.getOtherHisRecord,param).then((res)=>{
  86. if(res.data.code=='0'){
  87. const data = res.data.data;
  88. const obj = JSON.parse(data.dataJson||'{}');
  89. const objStr = JSON.parse(data.otherStr||'[]');
  90. let arr = [];//console.log(obj)
  91. if((!obj||!obj.other||obj.other.length==0)&&!objStr[0]){ //无其他史历史记录用默认模板
  92. if(mode=='1'){ //文本模式
  93. dispatch({
  94. type:SETOTHERHISTORY,
  95. data:[],
  96. selecteds:[],
  97. save:[]
  98. });
  99. }
  100. //console.log('其他史最近数据无')
  101. //arr = state.homePage.initData.otherHis;
  102. }else{
  103. arr = obj.other;
  104. if(mode =='1'){ //文本模式
  105. dispatch({
  106. type:SETOTHERHISTORY,
  107. data:[],
  108. selecteds:[],
  109. save:[objStr[0]]
  110. });
  111. }else{
  112. dispatch({
  113. type:SETOTHERHISTORY,
  114. data:arr,
  115. period:{
  116. yjs_1: obj.yjs_1,
  117. yjs_2: obj.yjs_2,
  118. yjs_3: obj.yjs_3,
  119. yjs_4: obj.yjs_4,
  120. },
  121. selecteds:obj.otherHistorySelecteds,
  122. save:objStr
  123. });
  124. }
  125. }
  126. }
  127. });
  128. }
  129. };
  130. //查体模板数据获取
  131. export function getInitData(){
  132. return (dispatch)=>{
  133. const emrData = getEMRParams();
  134. const param = {
  135. age: emrData.age,
  136. featureType: "1,4,7",
  137. diag: emrData.dis,
  138. lis: emrData.lis,
  139. other: emrData.other,
  140. pacs: emrData.pacs,
  141. sex: emrData.sex,
  142. vital:emrData.vital,
  143. symptom: emrData.current+emrData.main
  144. };
  145. json(api.getBigPush,param).then((res)=>{
  146. if(+res.data.code === 0){
  147. const data = res.data.data&&res.data.data.vital;
  148. //const str = JSON.stringify(data);
  149. //const arr = fullfillText(JSON.parse(str),false,false,false).newArr;
  150. dispatch({
  151. type:SET,
  152. data:[...data],
  153. isEmpty:false
  154. });
  155. }else{
  156. const block = Object.assign(JSON.parse(config.textLabel),{full:true}); //无数据时保留一个自由文本标签可输入
  157. dispatch({
  158. type:SET,
  159. data:[block],
  160. isEmpty:true
  161. });
  162. Notify.error(res.data.msg);
  163. }
  164. });
  165. }
  166. }
  167. //保存切换模式
  168. export function saveMode(mode){
  169. return (dispatch,getStore)=>{
  170. const {patInfo} = getStore();
  171. const param = {
  172. doctorId:patInfo.message.doctorId,
  173. modeClassify:0,
  174. modeValue:mode
  175. };
  176. return json(api.saveMode,param);
  177. }
  178. }
  179. //慢病-获取管理评估
  180. export function getAssessData(){
  181. return (dispatch,getStore)=>{
  182. const {patInfo} = getStore();
  183. const param = {
  184. diseaseId:21773,
  185. disType:1,
  186. diag:'糖尿病',
  187. featureType:11,
  188. lis:[],
  189. sex:patInfo.message.sex,
  190. age:patInfo.message.patientAge
  191. };
  192. return json(api.getAssess,param);
  193. }
  194. }
  195. export function getIndexData(range){
  196. return (dispatch,getStore)=>{
  197. const {patInfo} = getStore();
  198. const param = {
  199. diseaseId:21773,
  200. startTime:range[0],
  201. endTime:range[1],
  202. patientId:1001,//patInfo.message.patientId,
  203. };
  204. return json(api.getIndexData,param);
  205. }
  206. }
  207. // 计算接口
  208. export const getFormulaResult = (item)=>{
  209. // type:1-量表 11-计算公式
  210. const type = item.type;
  211. const id = item.id;//计算量表的id
  212. let param;
  213. if(type==1){
  214. param = {
  215. type:type,
  216. scale:item.content
  217. }
  218. }else if(type==11){
  219. param = {
  220. type:type,
  221. formula:item.content
  222. }
  223. }
  224. return (dispatch) => {
  225. json(api.getFormulaResult,param).then((res)=>{
  226. if(+res.data.code==0){
  227. dispatch({
  228. type:SAVE_TABLE_RESULT,
  229. id:id, //外层疾病id
  230. data:{
  231. data:item.content, //量表内容
  232. // id:item.scaleId, //量表id
  233. type:type,
  234. result:res.data.data, //计算结果
  235. }
  236. })
  237. }else{
  238. console.log(res.msg)
  239. }
  240. })
  241. }
  242. }