print.js 9.3 KB

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