patInfo.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import {get, post, json} from "../../utils/ajax";
  2. import {GET_PATIENT_MESSAGE} from "../types/patInfo";
  3. import {CONFIRM_TYPE} from "../types/typeConfig";
  4. import {getInfos} from '@store/actions/getInfoByUuid';
  5. import {getUrlArgObject,pushAllDataList} from '@utils/tools';
  6. import {getInitModules,getCommonList} from '@store/async-actions/homePage.js';
  7. import store from '@store'
  8. import {ISREAD,MODI_LOADING} from "../types/homePage";
  9. import { initItemList } from '@store/async-actions/tabTemplate';
  10. const api = {
  11. getPatInfo: '/patientInfo/getTopPatientInfo',
  12. getPatBaseInfo: '/patientInfo/getPatientInfo'
  13. };
  14. //参数转换
  15. export const initPersonInfo = (dispatch, getState) => {
  16. json('/tranFieldInfo/getInfoByUuid', {
  17. "uuid": getUrlArgObject('hospitalId'),
  18. }).then((res) => {
  19. const data = res.data;
  20. if (data.code == 0) {
  21. dispatch(getInfos(data.data));
  22. //console.log(data.data)
  23. getPatientMessage(dispatch, getState);
  24. } else {
  25. console.log(res)
  26. }
  27. })
  28. }
  29. //默认回读
  30. export const initHistoryDetails = (dispatch) => {
  31. let baseList = store.getState();
  32. let state = baseList.patInfo.message;
  33. return (dispatch) => {
  34. json('/inquiryInfo/readInquiry', {
  35. "doctorId": state.doctorId,
  36. "hospitalDeptId": state.hospitalDeptId,
  37. "hospitalId": state.hospitalId,
  38. "patientId": state.patientId, //患者id
  39. "inquiryCode": state.recordId,
  40. }).then((res) => {
  41. const data = res.data;
  42. if (data.code == 0) {
  43. const detail = data.data;
  44. pushAllDataList(detail.sign,'push',detail,'history');
  45. dispatch({
  46. type:ISREAD
  47. });
  48. // 设置初始模式
  49. if(detail.sign == 1 || detail.sign == 0){
  50. dispatch({
  51. type: CONFIRM_TYPE,
  52. confirmType: detail.sign
  53. })
  54. if(baseList.tabTemplate.items.length == 0){
  55. dispatch(initItemList()); //模板列表没有就获取模板列表用于保存时做数据对比是否保存过
  56. }
  57. }else{
  58. dispatch(initItemList(baseList.typeConfig.typeConfig))
  59. }
  60. dispatch({type:MODI_LOADING,flag:false});
  61. } else {
  62. dispatch({type:MODI_LOADING,flag:false});
  63. console.log(res)
  64. }
  65. })
  66. }
  67. }
  68. export const getPatientMessage = (dispatch, getState) => {
  69. const state = getState();
  70. const urlDatas = state.getInfoByUuid;
  71. const params = {
  72. hospitalCode:urlDatas.hospitalId,
  73. hospitalDeptCode: urlDatas.deptNo,
  74. doctorCode: urlDatas.doctorNo,
  75. patientCode:urlDatas.patientNo,
  76. recordId:urlDatas.recordId
  77. };
  78. // 获取医生,患者基本信息
  79. Promise.all([json(api.getPatInfo, params),json(api.getPatBaseInfo, params)])
  80. .then((data) => {
  81. let data1 = {},data2={};
  82. if(data[0].data.code=='0'){
  83. data1 = data[0].data.data;
  84. }
  85. if(data[1].data.code=='0'){
  86. data2 = data[1].data.data;
  87. }
  88. dispatch({
  89. type: GET_PATIENT_MESSAGE,
  90. data:Object.assign(data1,data2)
  91. });
  92. //设置初始模式
  93. dispatch({
  94. type: CONFIRM_TYPE,
  95. confirmType:data1.modeValue
  96. });
  97. dispatch(getInitModules); //确保病人信息获取以后再获取模板等数据,否则参数为空
  98. dispatch(getCommonList(5)); //获取常用化验标签列表
  99. dispatch(getCommonList(6)); //获取常用辅检标签列表
  100. // if(state.tabTemplate.items.length == 0){
  101. // dispatch(initItemList(data1.modeValue)); //模板列表没有就获取模板列表用于保存时做数据对比是否保存过
  102. // }
  103. })
  104. };