print.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import {
  2. json
  3. } from "../../utils/ajax";
  4. import store from '@store';
  5. import Notify from '@commonComp/Notify';
  6. import {
  7. getAllDataList,
  8. getAllDataStringList,
  9. pushAllDataList,
  10. filterDataArr
  11. } from '@utils/tools';
  12. export const saveMessage = (bool) => {
  13. let baseList = store.getState();
  14. let state = baseList.patInfo.message;
  15. let whichSign = baseList.typeConfig.typeConfig;
  16. const pushMessage = baseList.pushMessage;
  17. let jsonStr = getAllDataStringList(baseList);
  18. let jsonData = getAllDataList(baseList);
  19. const lisData = baseList.inspect.pushItem;
  20. const lisArr = transferIndexData(lisData);
  21. const evaluation={
  22. htmlContent:JSON.stringify(getEvaluations(baseList.assessResult,pushMessage)),
  23. //scaleList:[]
  24. };//getEvaluation();
  25. //console.log(baseList)
  26. // console.log(jsonStr.diag,'保存历史病历')
  27. json('/inquiryInfo/saveInquiry', {
  28. "doctorId": state.doctorId,
  29. "hospitalDeptId": state.hospitalDeptId,
  30. "hospitalId": state.hospitalId,
  31. "patientId": state.patientId, //患者id
  32. "dataJson": JSON.stringify(getAllDataList(baseList)),
  33. "indexData":lisArr,
  34. "inquiryEvaluation":evaluation,
  35. "detailList": [{
  36. "content": jsonStr.chief,
  37. "contentValue":filterDataArr(JSON.parse(jsonStr.chief)),
  38. "type": 1
  39. }, {
  40. "content": jsonStr.present,
  41. "contentValue":filterDataArr(JSON.parse(jsonStr.present)),
  42. "type": 2
  43. }, {
  44. "content": jsonStr.other,
  45. "contentValue":filterDataArr(JSON.parse(jsonStr.other)),
  46. "type": 3
  47. }, {
  48. "content": jsonStr.vital,
  49. "contentValue":filterDataArr(JSON.parse(jsonStr.vital)),
  50. "type": 4
  51. }, {
  52. "content": jsonStr.lis,
  53. "contentValue":jsonStr.lis,
  54. "type": 5
  55. }, {
  56. "content": jsonStr.pacs,
  57. "contentValue":jsonStr.pacs,
  58. "type": 6
  59. }, {
  60. "content": jsonStr.diag,
  61. "contentValue":jsonStr.diag,
  62. "type": 7
  63. }, {
  64. "content": jsonStr.advice,
  65. "contentValue":jsonStr.advice,
  66. "type": 8
  67. }],
  68. "sign": whichSign, //类型0结构化 1文本
  69. "diagnose": (jsonData.diag.length > 0 ? jsonData.diag[0].name : ''), //诊断
  70. "inquiryCode": state.recordId, //就诊序列号
  71. "drugList":baseList.pushMessage.advice.drugList || [],//药品列表
  72. // "regVisitedState": 0, //就诊状态
  73. // "type": 0,
  74. }).then((res) => {
  75. let data = res.data
  76. if (data.code == 0) {
  77. if(!bool){
  78. Notify.success('历史病历保存成功');
  79. }
  80. } else {
  81. console.log(res)
  82. }
  83. })
  84. if(bool){
  85. json('/printRecord/savePrintRecords', {
  86. "dataJson": JSON.stringify(getAllDataList(baseList)),
  87. "doctorId": state.doctorId,
  88. "hospitalDeptId": state.hospitalDeptId,
  89. "hospitalId": state.hospitalId,
  90. "inquiryCode": state.recordId, //就诊序列号
  91. "name": (jsonData.diag.length > 0 ? jsonData.diag[0].name : ''), //诊断
  92. "patientId": state.patientId, //患者id
  93. "type": whichSign, //类型0结构化 1文本
  94. "content": {
  95. "advice": jsonStr.advice,
  96. "chief": jsonStr.present,
  97. "diag": jsonStr.diag,
  98. "lis": jsonStr.lis,
  99. "other": jsonStr.other,
  100. "pacs": jsonStr.pacs,
  101. "present": jsonStr.present,
  102. "vital": jsonStr.vital
  103. },
  104. }).then((res) => {
  105. let data = res.data
  106. if (data.code == 0) {
  107. console.log('打印记录保存成功')
  108. } else {
  109. console.log(res)
  110. }
  111. })
  112. }
  113. };
  114. //转换化验指标保存需要的数据
  115. function transferIndexData(data) {
  116. const arr=[];
  117. data.map((it)=>{
  118. if(it.uniqueName&&it.value!=''){
  119. arr.push({
  120. creatTime:it.time+':00',
  121. indexUnique:it.uniqueName,
  122. indexUnit:it.units,
  123. indexValue:it.value,
  124. isAbnormal:(it.maxValue||it.minValue)?(it.value<it.minValue||it.value>it.maxValue?1:0):0
  125. });
  126. }
  127. });
  128. return arr;
  129. }
  130. function getEvaluations(base,pushMessage){
  131. let obj = [];
  132. Object.keys(base.wholeIndexs).map((i)=>{
  133. obj[i]=pushMessage.chronicPushItems[i];
  134. });
  135. return {
  136. data:base.data,
  137. chooseSelecteds:base.chooseSelecteds,
  138. indexTimeTypes:base.indexTimeTypes,
  139. wholeAssess:obj,
  140. wholeAssessText:base.wholeAssessText,
  141. wholeIndexs:base.wholeIndexs,
  142. scaleInfo:pushMessage.scaleInfo,
  143. scaleResult:pushMessage.formulaResult,
  144. wholeResults:base.wholeResults
  145. };
  146. }
  147. export const clearMessages = () => {
  148. let baseList = store.getState();
  149. let whichSign = baseList.typeConfig.typeConfig;
  150. pushAllDataList(whichSign,'clear');
  151. };