fetchModules.js 5.9 KB

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