pushMessage.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. export const changeAssay=(state,action)=>{
  2. const res=Object.assign({},state);
  3. res.assay = res.assay.map(item => {
  4. if(item.id === action.item.id && item.name === action.item.name){
  5. item.checked = !item.checked
  6. }
  7. return item
  8. })
  9. return res;
  10. };
  11. export const changeCheck=(state,action)=>{
  12. const res=Object.assign({},state);
  13. res.check = res.check.map(item => {
  14. if(item.id === action.item.id && item.name === action.item.name){
  15. item.checked = !item.checked
  16. }
  17. return item
  18. })
  19. return res;
  20. };
  21. //获取右侧推送信息
  22. export const setAdvice=(state,action)=>{
  23. const res=Object.assign({},state);
  24. // res.determine = action.determine
  25. //不展示确诊,将确诊跟疑似诊断放在一起展示
  26. res.doubt = action.determine.concat(action.doubt);
  27. res.possible = action.possible;
  28. res.vigilant = action.vigilant;
  29. res.likely = action.likely;
  30. res.assay = action.lab;
  31. res.check = action.pacs;
  32. res.setPushEmergency = action.setPushEmergency;
  33. res.setPushEmergencyIdx=action.setPushEmergencyIdx
  34. return res;
  35. };
  36. //获取医嘱信息字符串
  37. function getAdviceStr(advice) {
  38. const commontreatment = advice.commontreatment
  39. const scheme = advice.scheme || '';
  40. const adviceInput = advice.adviceInput || '';
  41. const assay = advice.assay || '';
  42. const check = advice.check || '';
  43. const followUp = advice.followUp || '';
  44. let AdviceStr = advice.AdviceStr || '';
  45. if(assay || check) {
  46. AdviceStr = assay + check +'; ' + AdviceStr;
  47. }
  48. if(commontreatment) {
  49. AdviceStr = AdviceStr + commontreatment + ';';
  50. }
  51. if(followUp) {
  52. AdviceStr = AdviceStr + '回访时间:'+followUp + '后回访,不适随诊' + ';';
  53. }
  54. for (let i = 0; i < scheme.length; i++) {
  55. for (let j = 0; j < scheme[i].treatment.length; j++) {
  56. if(scheme[i].treatment[j].treatmentStr === '') {
  57. AdviceStr = AdviceStr + scheme[i].treatment[j].treatmentStr
  58. } else {
  59. AdviceStr = AdviceStr + scheme[i].treatment[j].treatmentStr + ', '
  60. }
  61. }
  62. }
  63. if(AdviceStr.slice(AdviceStr.length-2) == ', ') {
  64. AdviceStr = AdviceStr.slice(0, AdviceStr.length-2)
  65. }
  66. // if(commontreatment) {
  67. // AdviceStr = commontreatment +'; ' + AdviceStr;
  68. // }
  69. if(adviceInput) {
  70. AdviceStr = AdviceStr +'; ' + adviceInput;
  71. }
  72. let reg=/<[^>]+>/gim;
  73. AdviceStr = AdviceStr.replace(reg,"");
  74. return AdviceStr;
  75. }
  76. //治疗方案添加到医嘱
  77. export const addScheme = (state, action) => {
  78. const res = JSON.parse(JSON.stringify(state))
  79. const treatment = action.treatment;
  80. const treatItem = {};
  81. treatItem.name = action.title;
  82. const scheme = res.advice.scheme || [];
  83. let isRepeat = false;
  84. let RepeatIndex;
  85. let SelectedDrugNum = 0 //选中的药品数量
  86. for (let i = 0; i < treatment.length; i++) {
  87. let treatmentStr = '';
  88. let drugList = []
  89. for (let j = 0; j < treatment[i].medicitionsList.length; j++) {
  90. if(treatment[i].medicitionsList[j].selected) {
  91. treatmentStr = treatmentStr + treatment[i].medicitionsList[j].medicitionName + ', '
  92. drugList.push({conceptId: treatment[i].medicitionsList[j].conceptId, conceptName: treatment[i].medicitionsList[j].medicitionName })
  93. SelectedDrugNum++
  94. }
  95. }
  96. treatment[i].treatmentStr = treatmentStr.substring(0,treatmentStr.length-2)
  97. treatment[i].drugList = drugList
  98. }
  99. if(SelectedDrugNum > 0) { //如果有选中的药品,滚动到医嘱框
  100. document.getElementById("adviceBox").scrollIntoView(true)
  101. }
  102. treatItem.treatment = treatment;
  103. for (let i = 0; i < scheme.length; i++) {
  104. if (scheme[i].name === treatItem.name) {
  105. isRepeat = true
  106. }
  107. }
  108. //判断医嘱中是否包含该诊断
  109. scheme.map((item, index) => {
  110. if(item.name === treatItem.name) {
  111. isRepeat = true
  112. RepeatIndex = index;
  113. }
  114. })
  115. if (isRepeat) {
  116. //将同类药添加到一起
  117. for (let i = 0; i < scheme[RepeatIndex].treatment.length; i++) {
  118. for (let j = 0; j < treatment.length; j++) {
  119. if (scheme[RepeatIndex].treatment[i].id === treatment[j].id && scheme[RepeatIndex].treatment[i].bigdrugsName === treatment[j].bigdrugsName && scheme[RepeatIndex].treatment[i].subdrugsName === treatment[j].subdrugsName) {
  120. for(let z = 0; z < treatment[j].medicitionsList.length; z++) {
  121. if(treatment[j].medicitionsList[z].selected) {
  122. if(scheme[RepeatIndex].treatment[i].treatmentStr !== '') {
  123. scheme[RepeatIndex].treatment[i].treatmentStr = scheme[RepeatIndex].treatment[i].treatmentStr + ', ' + treatment[j].medicitionsList[z].medicitionName
  124. } else {
  125. scheme[RepeatIndex].treatment[i].treatmentStr = scheme[RepeatIndex].treatment[i].treatmentStr + '' + treatment[j].medicitionsList[z].medicitionName
  126. }
  127. scheme[RepeatIndex].treatment[i].drugList.push({conceptId: treatment[j].medicitionsList[z].conceptId, conceptName: treatment[j].medicitionsList[z].medicitionName })
  128. }
  129. }
  130. }
  131. }
  132. }
  133. // let repeatDiag = res.advice.scheme[RepeatIndex].treatment
  134. // for (let i = 0; i < repeatDiag.length; i++) {
  135. // for (let j = 0; j < action.treatment.length; j++) {
  136. // if(repeatDiag[i].id === action.treatment[j].id) {
  137. // repeatDiag[i].medicitionsList = repeatDiag[i].medicitionsList.concat(action.treatment[j].medicitionsList)
  138. // }
  139. // }
  140. // }
  141. // repeatDiag = repeatDiag.concat(action.treatment)
  142. } else {
  143. for (let i = 0; i < treatItem.treatment.length; i++) {
  144. for (let j = 0; j < treatItem.treatment[i].medicitionsList.length; j++) {
  145. if(treatItem.treatment[i].medicitionsList[j].selected) {
  146. res.advice.scheme = scheme.concat(treatItem)
  147. }
  148. }
  149. }
  150. }
  151. res.AdviceStr = getAdviceStr(res.advice)
  152. if (res.advice.scheme) {
  153. res.advice.drugList = getDrugList(res.advice.scheme)
  154. }
  155. return res;
  156. }
  157. //获取开单到医嘱的药品列表
  158. function getDrugList(scheme) {
  159. const drugList = [];
  160. for(let i = 0 ; i < scheme.length; i++) {
  161. for(let j = 0; j <scheme[i].treatment.length; j++ ) {
  162. for (let z = 0; z < scheme[i].treatment[j].drugList.length; z++) {
  163. drugList.push(scheme[i].treatment[j].drugList[z]);
  164. }
  165. }
  166. }
  167. return drugList
  168. }
  169. //设置提示信息
  170. export const setTips = (state, action) => {
  171. const res = Object.assign({}, state)
  172. res.tips = action.tips;
  173. res.tmpFlg = action.tmpFlg
  174. res.showPartName = action.showPartName
  175. return res;
  176. }
  177. //设置提示信息详情页
  178. export const setTipsDetails = (state, action) => {
  179. const res = Object.assign({}, state)
  180. res.tipsDetails = action.tipsDetails;
  181. res.showAllName = action.showAllName
  182. return res;
  183. }
  184. export const setChangeAdviceTreatment = (state, action) => {
  185. const res = JSON.parse(JSON.stringify(state))
  186. const index = action.index; //诊断的下标
  187. const ii = action.ii //同类药下表
  188. const changeInput = action.changeInput;
  189. let scheme = res.advice.scheme;
  190. scheme[index].treatment[ii].treatmentStr = changeInput
  191. return res;
  192. }
  193. export const setChangeAdviceAssay = (state, action) => {
  194. const res = JSON.parse(JSON.stringify(state))
  195. res.advice.assay = action.changeInput;
  196. return res;
  197. }
  198. export const setChangeAdviceCheck = (state, action) => {
  199. const res = JSON.parse(JSON.stringify(state))
  200. res.advice.check = action.changeInput;
  201. return res;
  202. }
  203. export const addBilling = (state, action) => {
  204. const res = JSON.parse(JSON.stringify(state));
  205. const {assay,check} = action;
  206. res.assay = res.assay.map((item,index)=>{
  207. item.checked = false
  208. return item
  209. })
  210. res.check = res.check.map((item,index)=>{
  211. item.checked = false
  212. return item
  213. })
  214. res.advice.assay = res.advice.assay || '';
  215. res.advice.check = res.advice.check || '';
  216. for (let i = 0; i < assay.length; i++) {
  217. if ( res.advice.assay === '') { //如果最后一个,则不需要逗号
  218. res.advice.assay = res.advice.assay + assay[i].name
  219. } else {
  220. if( i === 0 && res.advice.check !== '') {
  221. res.advice.assay = res.advice.assay + assay[i].name
  222. } else {
  223. res.advice.assay = res.advice.assay + ', ' + assay[i].name
  224. }
  225. }
  226. }
  227. for (let i = 0; i < check.length; i++) {
  228. if ( res.advice.check === '') { //如果最后一个,则不需要逗号
  229. res.advice.check = res.advice.check + check[i].name
  230. } else {
  231. res.advice.check = res.advice.check + ', '+ check[i].name
  232. }
  233. }
  234. if(res.advice.assay && res.advice.check !== '') {
  235. if(res.advice.assay.substring(res.advice.assay.length-2,res.advice.assay.length-1) !== ',') {
  236. res.advice.assay = res.advice.assay + ', '
  237. }
  238. }
  239. res.AdviceStr = getAdviceStr(res.advice)
  240. return res;
  241. }
  242. export const clearAllPushMessage = (state, action) => {
  243. const res = JSON.parse(JSON.stringify(state));
  244. res.advice = action.data;
  245. res.AdviceStr = action.saveText;
  246. res.tips = {};
  247. res.vigilant = [];
  248. res.doubt = [];
  249. res.possible = [];
  250. res.determine = [];
  251. res.assay = [];
  252. res.check = [];
  253. res.chronicPushItems = [];//量表
  254. res.formulaResult = {}; //量表计算结果
  255. res.scaleInfo = {}; //量表选中项
  256. res.drugList = []; //开单药品列表
  257. return res;
  258. }
  259. export const showTipsDetails = (state, action) => {
  260. const res = Object.assign({}, state);
  261. res.showTipsDetails = true;
  262. return res;
  263. }
  264. export const hideTipsDetails = (state, action) => {
  265. const res = Object.assign({}, state);
  266. res.showTipsDetails = false;
  267. return res;
  268. }
  269. //一般治疗添加到医嘱
  270. export const setCommontreatment = (state, action) => {
  271. const res = JSON.parse(JSON.stringify(state));
  272. res.advice.commontreatment = action.commontreatment;
  273. res.AdviceStr = getAdviceStr(res.advice)
  274. return res;
  275. }
  276. export const setAdviceInput = (state, action) => {
  277. const res = JSON.parse(JSON.stringify(state));
  278. res.advice.adviceInput = action.adviceInput;
  279. res.AdviceStr = getAdviceStr(res.advice)
  280. return res;
  281. }
  282. //保存回访时间
  283. export const saveFollowUp = (state, action) => {
  284. const res = JSON.parse(JSON.stringify(state));
  285. res.advice.followUp = action.followUp;
  286. if(action.hasFollowUp) {
  287. res.advice.hasFollowUp = action.hasFollowUp
  288. }
  289. return res;
  290. }
  291. //删除回访时间
  292. export const delFollowUp = (state, action) => {
  293. const res = JSON.parse(JSON.stringify(state));
  294. res.advice.follow = '';
  295. return res;
  296. }