patInfo.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import {get, post, json} from "../../utils/ajax";
  2. import {GET_PATIENT_MESSAGE,GET_HOSPITAL_MESSAGE} from "../types/patInfo";
  3. import {CONFIRM_TYPE} from "../types/typeConfig";
  4. import {getInfos} from '@store/actions/getInfoByUuid';
  5. import {getUrlArgObject,pushAllDataList,getAllDataList,storageLocal} from '@utils/tools';
  6. import {getInitModules,getCommonList} from '@store/async-actions/homePage.js';
  7. import store from '@store'
  8. import {ISREAD,MODI_LOADING,SETPRE,SETPREDATA} from "../types/homePage";
  9. import { initItemList } from '@store/async-actions/tabTemplate';
  10. import config from '@config/index';
  11. import {Notify} from '@commonComp';
  12. const api = {
  13. getPatInfo: '/patientInfo/getTopPatientInfo',
  14. getPatBaseInfo: '/patientInfo/getPatientInfo',
  15. getHospitalInfo:'/hospitalInfo/getHospitalInfo',
  16. getPreMsg:'/api/prec/inquiryInfo/getInquiryDetail',
  17. getDoctorConfig:'/doctorPageMode/getDoctorPageModes', //获取医生设置
  18. };
  19. //获取预问诊信息
  20. export const getPreMsg = (dispatch, getState) => {
  21. // let baseList = getState();
  22. // let state = baseList.patInfo.message;
  23. const inCode = config.preIcss.recordIdVal===-1?getUrlArgObject("recordId"):config.preIcss.recordIdVal;
  24. json(api.getPreMsg, {
  25. "hospitalCode": getUrlArgObject('hospitalId'),
  26. "inquiryCode":inCode,
  27. "patientCode": getUrlArgObject("patientNo"),
  28. "dayLimit":config.preIcss.deadline===-1?undefined:config.preIcss.deadline
  29. },true).then((res) => {
  30. const data = res.data;
  31. if (data.code == 0) {
  32. let result = data.data;
  33. let preIcss = {
  34. chief:result.chiefComplaint?new Array(result.chiefComplaint):[],
  35. current:result.xbs?new Array(result.xbs):[],
  36. other:result.qts?new Array(result.qts):[],
  37. checkBody:result.supplement?result.supplement:''
  38. }
  39. dispatch({type:SETPRE,show:true});
  40. dispatch({type:SETPREDATA,preData:preIcss});
  41. } else {
  42. // console.log(res)
  43. }
  44. })
  45. }
  46. //获取医院id
  47. export const initHospitalInfo = (dispatch, getState) => {
  48. let baseList = getState();
  49. let state = baseList.patInfo.message;
  50. json(api.getHospitalInfo, {
  51. "hospitalCode": getUrlArgObject('hospitalId'),
  52. }).then((res) => {
  53. const data = res.data;
  54. if (data.code == 0) {
  55. dispatch({
  56. type: GET_HOSPITAL_MESSAGE,
  57. data:data.data.sysSetInfoData||[]
  58. });
  59. } else {
  60. console.log(res)
  61. }
  62. })
  63. }
  64. //参数转换
  65. export const initPersonInfo = (dispatch, getState) => {
  66. json('/tranFieldInfo/getInfoByUuid', {
  67. "uuid": getUrlArgObject('hospitalId'),
  68. }).then((res) => {
  69. const data = res.data;
  70. if (data.code == 0) {
  71. dispatch(getInfos(data.data));
  72. getPatientMessage(dispatch, getState);
  73. } else {
  74. console.log(res)
  75. }
  76. })
  77. }
  78. //默认回读
  79. export const initHistoryDetails = (dispatch) => {
  80. let baseList = store.getState();
  81. let state = baseList.patInfo.message;
  82. storageLocal.remove('emrParam');
  83. return (dispatch) => {
  84. json('/inquiryInfo/readInquiry', {
  85. "doctorId": state.doctorId,
  86. "hospitalDeptId": state.hospitalDeptId,
  87. "hospitalId": state.hospitalId,
  88. "patientId": state.patientId, //患者id
  89. "inquiryCode": state.recordId,
  90. }).then((res) => {
  91. const data = res.data;
  92. if (data.code == 0) {
  93. const detail = data.data;
  94. if(detail.dataJson){
  95. pushAllDataList(detail.sign,'push',detail,'history');
  96. }else{
  97. let pre = baseList.homePage.sysConfig.connect_prec;
  98. (pre==1)&&getPreMsg(dispatch)
  99. // (pre==1)&&dispatch({type:SETPRE,show:true});
  100. }
  101. dispatch({
  102. type:ISREAD
  103. });
  104. dispatch(initItemList(1,'')); //模板列表没有就获取模板列表用于保存时做数据对比是否保存过
  105. dispatch({type:MODI_LOADING,flag:false});
  106. } else {
  107. dispatch({type:MODI_LOADING,flag:false});
  108. // console.log(res)
  109. }
  110. })
  111. }
  112. };
  113. //转换设置存值
  114. function parseDoctorCon(arr){
  115. let obj = {};
  116. let it;
  117. if(!arr){
  118. return null;
  119. }
  120. for(let i=0;i<arr.length;i++){
  121. it = arr[i];
  122. obj[it.modeClassify] = it.modeValue;
  123. }
  124. return obj;
  125. }
  126. //获取医生设置信息
  127. function getDoctorConfig(id,dispatch){
  128. json(api.getDoctorConfig,{doctorId:id}).then((res)=>{
  129. if(res.data.code==='0'){
  130. const configs = parseDoctorCon(res.data.data);
  131. if(!configs){
  132. return ;
  133. }
  134. dispatch({
  135. type:CONFIRM_TYPE,
  136. confirmType:configs
  137. })
  138. }else{
  139. Notify.info(res.data.msg);
  140. }
  141. });
  142. }
  143. //技术部需求,先获取第一个接口再去第二个
  144. export async function getPatientMessage(dispatch, getState){
  145. const state = getState();
  146. const urlDatas = state.getInfoByUuid;
  147. const params = {
  148. hospitalCode:urlDatas.hospitalId,
  149. hospitalDeptCode: urlDatas.deptNo,
  150. doctorCode: urlDatas.doctorNo,
  151. patientCode:urlDatas.patientNo,
  152. recordId:urlDatas.recordId
  153. };
  154. let res1 = await json(api.getPatInfo, params);
  155. /*console.log(res1);
  156. console.log(1);*/
  157. let res2 = await json(api.getPatBaseInfo, params);
  158. /*console.log(res2);
  159. console.log(2);*/
  160. let data1 = {},data2 = {};
  161. if(res1.data.code=='0'){
  162. data1 = res1.data.data;
  163. getDoctorConfig(data1.doctorId,dispatch);
  164. }
  165. if(res2.data.code=='0'){
  166. data2 = res2.data.data;
  167. }
  168. dispatch({
  169. type: GET_PATIENT_MESSAGE,
  170. data:Object.assign(data1,data2)
  171. });
  172. localStorage.removeItem('deletedTags');
  173. dispatch(getInitModules); //确保病人信息获取以后再获取模板等数据,否则参数为空
  174. dispatch(getCommonList(5)); //获取常用化验标签列表
  175. dispatch(getCommonList(6)); //获取常用辅检标签列表if(allModules.length == 0){//模板为空才回读
  176. dispatch(initHistoryDetails()); //历史病历回读
  177. // initHospitalInfo(dispatch, getState) //不需要的
  178. }