fetchModules.js 5.1 KB

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