print.js 8.1 KB

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