patInfo.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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} from '@store/async-actions/homePage.js';
  7. import store from '@store'
  8. import {ISREAD} from "../types/homePage";
  9. import { initItemList } from '@store/async-actions/tabTemplate';
  10. const api = {
  11. getPatInfo: '/api/icss/patientInfo/getTopPatientInfo',
  12. getPatBaseInfo: '/api/icss/patientInfo/getPatientInfo'
  13. };
  14. //参数转换
  15. export const initPersonInfo = (dispatch, getState) => {
  16. json('/api/icss/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('/api/icss/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. }
  58. } else {
  59. console.log(res)
  60. }
  61. })
  62. }
  63. }
  64. export const getPatientMessage = (dispatch, getState) => {
  65. const state = getState();
  66. const urlDatas = state.getInfoByUuid;
  67. const params = {
  68. hospitalCode:urlDatas.hospitalId,
  69. hospitalDeptCode: urlDatas.deptNo,
  70. doctorCode: urlDatas.doctorNo,
  71. patientCode:urlDatas.patientNo,
  72. recordId:urlDatas.recordId
  73. };
  74. // 获取医生,患者基本信息
  75. Promise.all([json(api.getPatInfo, params),json(api.getPatBaseInfo, params)])
  76. .then((data) => {
  77. let data1 = {},data2={};
  78. if(data[0].data.code=='0'){
  79. data1 = data[0].data.data;
  80. }
  81. if(data[1].data.code=='0'){
  82. data2 = data[1].data.data;
  83. }
  84. dispatch({
  85. type: GET_PATIENT_MESSAGE,
  86. data:Object.assign(data1,data2)
  87. });
  88. //设置初始模式
  89. dispatch({
  90. type: CONFIRM_TYPE,
  91. confirmType:data1.modeValue
  92. });
  93. dispatch(getInitModules); //确保病人信息获取以后再获取模板等数据,否则参数为空
  94. if(state.tabTemplate.items.length == 0){
  95. dispatch(initItemList(data1.modeValue)); //模板列表没有就获取模板列表用于保存时做数据对比是否保存过
  96. }
  97. })
  98. };