print.js 12 KB

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