print.js 12 KB

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