pushMessage.js 9.1 KB

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