print.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import {
  2. json
  3. } from "../../utils/ajax";
  4. import store from '@store';
  5. import {MODI_LOADING} from '@store/types/homePage.js';
  6. import Notify from '@commonComp/Notify';
  7. import {
  8. getAllDataList,
  9. getAllDataStringList,
  10. pushAllDataList,
  11. filterDataArr,
  12. filterOtherDataArr
  13. } from '@utils/tools';
  14. export const getConceptDetails = (bool) => {
  15. let baseList = store.getState();
  16. let disLis = baseList.diagnosticList.diagnosticList||[];
  17. let tmpLis = [];
  18. for(let i = 0;i < disLis.length;i++){
  19. let obj = {}
  20. obj.name = disLis[i].name
  21. obj.type = 7
  22. obj.position = 3
  23. tmpLis.push(obj)
  24. }
  25. json('/conceptDetail/getConceptDetails', {
  26. "conceptIntorduces": tmpLis
  27. }).then((res)=>{//conceptIntroduceDTO
  28. let data = res.data;
  29. if (data.code == 0) {
  30. realSaveData(bool,data.data)
  31. } else {
  32. console.log(res)
  33. realSaveData(bool)
  34. }
  35. }).catch((err)=>{
  36. realSaveData(bool)
  37. console.log(err)
  38. })
  39. }
  40. export const saveMessage=(bool)=>{
  41. store.dispatch({type:MODI_LOADING,flag:true});
  42. getConceptDetails(bool)
  43. }
  44. export const realSaveData = (bool,list) => {
  45. let baseList = store.getState();
  46. const dConfig = baseList.typeConfig;
  47. const readMode = dConfig.readMode; //回读模式
  48. let state = baseList.patInfo.message;
  49. //保存时保存当前的数据实际模式,不是系统模式,针对回读模式与系统模式不一致的情况处理
  50. let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
  51. const pushMessage = baseList.pushMessage;
  52. let jsonStr = getAllDataStringList(baseList);
  53. let jsonData = getAllDataList(baseList);
  54. const lisData = baseList.inspect.pushItem;
  55. const lisArr = transferIndexData(lisData);
  56. const haveAssess = Object.keys(baseList.assessResult.data).length>0;
  57. let otherData = {},pacsData={};
  58. const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
  59. const evaluation={
  60. htmlContent:haveAssess?JSON.stringify(getEvaluations(baseList.assessResult,pushMessage)):'{}',
  61. //scaleList:[]
  62. };//getEvaluation();
  63. //console.log(baseList)
  64. // console.log(jsonStr.diag,'保存历史病历')
  65. otherData['yjs_1']=jsonData['yjs_1']||''
  66. otherData['yjs_2']=jsonData['yjs_2']||''
  67. otherData['yjs_3']=jsonData['yjs_3']||''
  68. otherData['yjs_4']=jsonData['yjs_4']||''
  69. otherData['haveAssess']=haveAssess
  70. otherData['pfix']=jsonStr.other?filterOtherDataArr(JSON.parse(jsonStr.other),jsonData.other):''
  71. pacsData.pacs = jsonData.pacs
  72. pacsData.checkedListImport = jsonData.checkedListImport;
  73. json('/inquiryInfo/saveInquiry', {
  74. "doctorId": state.doctorId,
  75. "conceptIntroduceDTO":list||[],
  76. "hospitalDeptId": state.hospitalDeptId,
  77. "hospitalId": state.hospitalId,
  78. "patientId": state.patientId, //患者id
  79. "dataJson": JSON.stringify(Object.assign({haveAssess:haveAssess,docConfigs:docConfigs},jsonData)),
  80. "indexData":lisArr,
  81. "inquiryEvaluation":evaluation,
  82. "detailList": [{
  83. "content": jsonStr.chief,
  84. "contentValue":filterDataArr(JSON.parse(jsonStr.chief)),
  85. "contentJson":'',
  86. "type": 1
  87. }, {
  88. "content": jsonStr.present,
  89. "contentValue":filterDataArr(JSON.parse(jsonStr.present)),
  90. "contentJson":'',
  91. "type": 2
  92. }, {
  93. "content": jsonStr.other,
  94. "contentValue":filterDataArr(JSON.parse(jsonStr.other)),
  95. "contentJson":JSON.stringify(otherData),
  96. "type": 3
  97. }, {
  98. "content": jsonStr.vital,
  99. "contentValue":filterDataArr(JSON.parse(jsonStr.vital)),
  100. "contentJson":'',
  101. "type": 4
  102. }, {
  103. "content": jsonStr.lis,
  104. "contentValue":jsonStr.lis,
  105. "contentJson":JSON.stringify(jsonData.lis),
  106. "type": 5
  107. }, {
  108. "content": jsonStr.pacs,
  109. "contentValue":jsonStr.pacs,
  110. "contentJson":JSON.stringify(pacsData),
  111. "type": 6
  112. }, {
  113. "content": jsonStr.diag,
  114. "contentValue":jsonStr.diag,
  115. "contentJson":'',
  116. "type": 7
  117. }, {
  118. "content": jsonStr.advice,
  119. "contentValue":jsonStr.advice,
  120. "contentJson":JSON.stringify(jsonData.advice),
  121. "type": 8
  122. }],
  123. "sign": whichSign, //类型0结构化 1文本
  124. "diagnose": (jsonData.diag.length > 0 ? jsonData.diag[0].name : ''), //诊断
  125. "inquiryCode": state.recordId, //就诊序列号
  126. "drugList":baseList.pushMessage.advice.drugList || [],//药品列表
  127. // "regVisitedState": 0, //就诊状态
  128. // "type": 0,
  129. }).then((res) => {
  130. let data = res.data
  131. if (data.code == 0) {
  132. if(!bool){
  133. Notify.success('历史病历保存成功');
  134. }
  135. } else {
  136. Notify.info(data.msg);
  137. }
  138. store.dispatch({type:MODI_LOADING,flag:false});
  139. }).catch(function(){
  140. store.dispatch({type:MODI_LOADING,flag:false});
  141. Notify.info('保存失败,请稍后再试!');
  142. });
  143. if(bool){
  144. json('/printRecord/savePrintRecords', {
  145. "dataJson": JSON.stringify(getAllDataList(baseList)),
  146. "doctorId": state.doctorId,
  147. "hospitalDeptId": state.hospitalDeptId,
  148. "hospitalId": state.hospitalId,
  149. "inquiryCode": state.recordId, //就诊序列号
  150. "name": (jsonData.diag.length > 0 ? jsonData.diag[0].name : ''), //诊断
  151. "patientId": state.patientId, //患者id
  152. "type": whichSign, //类型0结构化 1文本
  153. "content": {
  154. "advice": jsonStr.advice,
  155. "chief": jsonStr.present,
  156. "diag": jsonStr.diag,
  157. "lis": jsonStr.lis,
  158. "other": jsonStr.other,
  159. "pacs": jsonStr.pacs,
  160. "present": jsonStr.present,
  161. "vital": jsonStr.vital
  162. },
  163. }).then((res) => {
  164. let data = res.data
  165. if (data.code == 0) {
  166. console.log('打印记录保存成功')
  167. } else {
  168. console.log(res)
  169. }
  170. })
  171. }
  172. };
  173. //转换化验指标保存需要的数据
  174. function transferIndexData(data) {
  175. const arr=[];
  176. data.map((it)=>{
  177. if(it.uniqueName&&it.value!=''){
  178. arr.push({
  179. creatTime:it.time+':00',
  180. indexUnique:it.uniqueName,
  181. indexUnit:it.units,
  182. indexValue:it.value,
  183. isAbnormal:(it.maxValue||it.minValue)?(it.value<it.minValue||it.value>it.maxValue?1:0):0
  184. });
  185. }
  186. });
  187. return arr;
  188. }
  189. function getEvaluations(base,pushMessage){
  190. let obj = [];
  191. Object.keys(base.wholeIndexs).map((i)=>{
  192. obj[i]=pushMessage.chronicPushItems[i];
  193. });
  194. return {
  195. data:base.data,
  196. chooseSelecteds:base.chooseSelecteds,
  197. indexTimeTypes:base.indexTimeTypes,
  198. wholeAssess:obj,
  199. wholeAssessText:base.wholeAssessText,
  200. wholeIndexs:base.wholeIndexs,
  201. scaleInfo:pushMessage.scaleInfo,
  202. scaleResult:pushMessage.formulaResult,
  203. wholeResults:base.wholeResults,
  204. calcuResult:base.calcuResult,
  205. calcuValues:base.calcuValues,
  206. scaleItems:base.wholeScaleItems,
  207. };
  208. }
  209. export const clearMessages = () => {
  210. let baseList = store.getState();
  211. let whichSign = baseList.typeConfig.mode;
  212. pushAllDataList(whichSign,'clear');
  213. };