print.js 13 KB

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