print.js 7.9 KB

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