print.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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 } } = 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. type: 11,
  145. },
  146. {
  147. content: tempPreview.advice,
  148. contentValue: tempPreview.advice,
  149. contentJson: JSON.stringify(tempPreview.advice),
  150. type: 12,
  151. },
  152. ];
  153. // let sex = formatFormParmas('patientSex', patInfoData) === '男' ? 1 : 0
  154. let params = {
  155. "age": formatFormParmas('patientAge', patInfoData),
  156. "cardNo": formatFormParmas('patientIdNo', patInfoData),
  157. "dataJson": JSON.stringify(Object.assign({}, jsonData)),
  158. "deptName": formatFormParmas('hospitalDeptName', patInfoData),
  159. "doctorName": formatFormParmas('doctorName', patInfoData),
  160. "inquiryCode": formatFormParmas('recordId', patInfoData),
  161. "inquiryDate": inquiryDate,
  162. "modeName": modeName,
  163. "patName": formatFormParmas('patientName', patInfoData),
  164. "preview": JSON.stringify(preview), // 左侧病历预览信息
  165. "sex": formatFormParmas('patientSex', patInfoData),
  166. }
  167. return new Promise((resolve,reject) =>{
  168. json('/demo/templateInfo/saveTemplateInfo', params).then(res => {
  169. let data = res.data;
  170. if (data.code == 0) {
  171. store.dispatch({ type: CLEARMEDICALNAME }); // 清除病历名称
  172. Notify.success('病历保存成功');
  173. resolve('ok')
  174. } else {
  175. reject(data.code);
  176. Notify.info(data.msg);
  177. }
  178. store.dispatch({ type: MODI_LOADING, flag: false });
  179. });
  180. })
  181. }
  182. // 保存病历信息
  183. export const realSaveData = (bool,list) => {
  184. let baseList = store.getState();
  185. const dConfig = baseList.typeConfig;
  186. const readMode = dConfig.readMode; //回读模式
  187. let state = baseList.patInfo.message;
  188. //保存时保存当前的数据实际模式,不是系统模式,针对回读模式与系统模式不一致的情况处理
  189. let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
  190. const pushMessage = baseList.pushMessage;
  191. let jsonStr = getAllDataStringList(baseList);
  192. let jsonData = getAllDataList(baseList);
  193. const lisData = baseList.inspect.pushItem;
  194. const lisArr = transferIndexData(lisData);
  195. //分出体征和非体征标签单独传
  196. const checkBody = baseList.checkBody.data;
  197. let vitalTags = [],unVitalTags=[];
  198. checkBody&&checkBody.map((it)=>{
  199. if(it.specFlag===4){
  200. vitalTags.push(it);
  201. }else{
  202. unVitalTags.push(it);
  203. }
  204. });
  205. const haveAssess = Object.keys(baseList.assessResult.data).length>0;
  206. let otherData = {},pacsData={};
  207. const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
  208. const evaluation={
  209. htmlContent:haveAssess?JSON.stringify(getEvaluations(baseList.assessResult,pushMessage)):'{}',
  210. //scaleList:[]
  211. };//getEvaluation();
  212. //console.log(baseList)
  213. // console.log(jsonStr.diag,'保存历史病历')
  214. otherData['yjs_1']=jsonData['yjs_1']||''
  215. otherData['yjs_2']=jsonData['yjs_2']||''
  216. otherData['yjs_3']=jsonData['yjs_3']||''
  217. otherData['yjs_4']=jsonData['yjs_4']||''
  218. otherData['haveAssess']=haveAssess
  219. otherData['pfix']=jsonStr.other?filterOtherDataArr(JSON.parse(jsonStr.other),jsonData.other):''
  220. pacsData.pacs = jsonData.pacs
  221. pacsData.checkedListImport = jsonData.checkedListImport;
  222. json('/inquiryInfo/saveInquiry', {
  223. "doctorId": state.doctorId,
  224. "conceptIntroduceDTO":list||[],
  225. "hospitalDeptId": state.hospitalDeptId,
  226. "hospitalId": state.hospitalId,
  227. "patientId": state.patientId, //患者id
  228. "dataJson": JSON.stringify(Object.assign({haveAssess:haveAssess,docConfigs:docConfigs},jsonData)),
  229. "indexData":lisArr,
  230. "inquiryEvaluation":evaluation,
  231. "vitalSigns":JSON.stringify(vitalTags||[]),
  232. "physicalExcVs":JSON.stringify(unVitalTags||[]),
  233. "detailList": [{
  234. "content": jsonStr.chief,
  235. "contentValue":filterDataArr(JSON.parse(jsonStr.chief)),
  236. "contentJson":'',
  237. "type": 1
  238. }, {
  239. "content": jsonStr.present,
  240. "contentValue":filterDataArr(JSON.parse(jsonStr.present)),
  241. "contentJson":'',
  242. "type": 2
  243. }, {
  244. "content": jsonStr.other,
  245. "contentValue":filterDataArr(JSON.parse(jsonStr.other)),
  246. "contentJson":JSON.stringify(otherData),
  247. "type": 3
  248. }, {
  249. "content": jsonStr.vital,
  250. "contentValue":filterDataArr(JSON.parse(jsonStr.vital)),
  251. "contentJson":'',
  252. "type": 4
  253. }, {
  254. "content": jsonStr.lis,
  255. "contentValue":jsonStr.lis,
  256. "contentJson":JSON.stringify(jsonData.lis),
  257. "type": 5
  258. }, {
  259. "content": JSON.stringify(jsonStr.pacs),
  260. "contentValue":JSON.stringify(jsonStr.pacs),
  261. "contentJson":JSON.stringify(pacsData),
  262. "type": 6
  263. }, {
  264. "content": jsonStr.diag,
  265. "contentValue":jsonStr.diag,
  266. "contentJson":'',
  267. "type": 7
  268. }, {
  269. "content": jsonStr.advice,
  270. "contentValue":jsonStr.advice,
  271. "contentJson":JSON.stringify(jsonData.advice),
  272. "type": 8
  273. }],
  274. "sign": whichSign, //类型0结构化 1文本
  275. "diagnose": (jsonData.diag.length > 0 ? jsonData.diag[0].name : ''), //诊断
  276. "inquiryCode": state.recordId, //就诊序列号
  277. "drugList":baseList.pushMessage.advice.drugList || [],//药品列表
  278. // "regVisitedState": 0, //就诊状态
  279. // "type": 0,
  280. }).then((res) => {
  281. let data = res.data
  282. if (data.code == 0) {
  283. if(!bool){
  284. Notify.success('历史病历保存成功');
  285. }
  286. } else {
  287. Notify.info(data.msg);
  288. }
  289. store.dispatch({type:MODI_LOADING,flag:false});
  290. }).catch(function(){
  291. store.dispatch({type:MODI_LOADING,flag:false});
  292. Notify.info('保存失败,请稍后再试!');
  293. });
  294. if(bool){
  295. json('/printRecord/savePrintRecords', {
  296. "dataJson": JSON.stringify(getAllDataList(baseList)),
  297. "doctorId": state.doctorId,
  298. "hospitalDeptId": state.hospitalDeptId,
  299. "hospitalId": state.hospitalId,
  300. "inquiryCode": state.recordId, //就诊序列号
  301. "name": (jsonData.diag.length > 0 ? jsonData.diag[0].name : ''), //诊断
  302. "patientId": state.patientId, //患者id
  303. "type": whichSign, //类型0结构化 1文本
  304. "content": {
  305. "advice": jsonStr.advice,
  306. "chief": jsonStr.present,
  307. "diag": jsonStr.diag,
  308. "lis": jsonStr.lis,
  309. "other": jsonStr.other,
  310. "pacs": jsonStr.pacs,
  311. "present": jsonStr.present,
  312. "vital": jsonStr.vital
  313. },
  314. }).then((res) => {
  315. let data = res.data
  316. if (data.code == 0) {
  317. console.log('打印记录保存成功')
  318. } else {
  319. console.log(res)
  320. }
  321. })
  322. }
  323. };
  324. //转换检验指标保存需要的数据
  325. function transferIndexData(data) {
  326. const arr=[];
  327. data.map((it)=>{
  328. if(it.uniqueName&&it.value!=''){
  329. arr.push({
  330. creatTime:it.dateValue,
  331. indexUnique:it.uniqueName,
  332. indexUnit:it.units,
  333. indexValue:it.value,
  334. isAbnormal:(it.maxValue||it.minValue)?(it.value<it.minValue||it.value>it.maxValue?1:0):0
  335. });
  336. }
  337. });
  338. return arr;
  339. }
  340. function getEvaluations(base,pushMessage){
  341. let obj = [];
  342. Object.keys(base.wholeIndexs).map((i)=>{
  343. obj[i]=pushMessage.chronicPushItems[i];
  344. });
  345. return {
  346. data:base.data,
  347. chooseSelecteds:base.chooseSelecteds,
  348. indexTimeTypes:base.indexTimeTypes,
  349. wholeAssess:obj,
  350. wholeAssessText:base.wholeAssessText,
  351. wholeIndexs:base.wholeIndexs,
  352. scaleInfo:pushMessage.scaleInfo,
  353. scaleResult:pushMessage.formulaResult,
  354. wholeResults:base.wholeResults,
  355. calcuResult:base.calcuResult,
  356. calcuValues:base.calcuValues,
  357. scaleItems:base.wholeScaleItems,
  358. };
  359. }
  360. export const clearMessages = () => {
  361. // let baseList = store.getState();
  362. // let whichSign = baseList.typeConfig.mode;
  363. // pushAllDataList(whichSign,'clear');
  364. delHistoryDataList()
  365. // store.dispatch(embedPush({
  366. // action: "patientia",
  367. // mode: 1
  368. // }))
  369. };