pushMessage.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 scheme = advice.scheme || '';
  36. const assay = advice.assay || '';
  37. const check = advice.check || '';
  38. let AdviceStr = advice.AdviceStr || '';
  39. for (let i = 0; i < scheme.length; i++) {
  40. for (let j = 0; j < scheme[i].treatment.length; j++) {
  41. if(scheme[i].treatment[j].treatmentStr === '') {
  42. AdviceStr = AdviceStr + scheme[i].treatment[j].treatmentStr
  43. } else {
  44. AdviceStr = AdviceStr.substring(1, AdviceStr.length) + ', ' + scheme[i].treatment[j].treatmentStr
  45. }
  46. }
  47. }
  48. if(assay || check) {
  49. AdviceStr = assay + check +'; ' + AdviceStr;
  50. }
  51. return AdviceStr;
  52. }
  53. //治疗方案添加到医嘱
  54. export const addScheme = (state, action) => {
  55. const res = JSON.parse(JSON.stringify(state))
  56. const treatment = action.treatment;
  57. const treatItem = {};
  58. treatItem.name = action.title;
  59. const scheme = res.advice.scheme || [];
  60. let isRepeat = false;
  61. let RepeatIndex;
  62. for (let i = 0; i < treatment.length; i++) {
  63. let treatmentStr = '';
  64. for (let j = 0; j < treatment[i].medicitionsList.length; j++) {
  65. if(treatment[i].medicitionsList[j].selected) {
  66. treatmentStr = treatmentStr + treatment[i].medicitionsList[j].medicitionName + ', '
  67. }
  68. }
  69. treatment[i].treatmentStr = treatmentStr.substring(0,treatmentStr.length-2)
  70. }
  71. treatItem.treatment = treatment;
  72. for (let i = 0; i < scheme.length; i++) {
  73. if (scheme[i].name === treatItem.name) {
  74. isRepeat = true
  75. }
  76. }
  77. //判断医嘱中是否包含该诊断
  78. scheme.map((item, index) => {
  79. if(item.name === treatItem.name) {
  80. isRepeat = true
  81. RepeatIndex = index;
  82. }
  83. })
  84. if (isRepeat) {
  85. //将同类药添加到一起
  86. for (let i = 0; i < scheme[RepeatIndex].treatment.length; i++) {
  87. for (let j = 0; j < treatment.length; j++) {
  88. if (scheme[RepeatIndex].treatment[i].id === treatment[j].id && scheme[RepeatIndex].treatment[i].bigdrugsName === treatment[j].bigdrugsName) {
  89. for(let z = 0; z < treatment[j].medicitionsList.length; z++) {
  90. if(treatment[j].medicitionsList[z].selected) {
  91. if(scheme[RepeatIndex].treatment[i].treatmentStr !== '') {
  92. scheme[RepeatIndex].treatment[i].treatmentStr = scheme[RepeatIndex].treatment[i].treatmentStr + ', ' + treatment[j].medicitionsList[z].medicitionName
  93. } else {
  94. scheme[RepeatIndex].treatment[i].treatmentStr = scheme[RepeatIndex].treatment[i].treatmentStr + '' + treatment[j].medicitionsList[z].medicitionName
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101. // let repeatDiag = res.advice.scheme[RepeatIndex].treatment
  102. // for (let i = 0; i < repeatDiag.length; i++) {
  103. // for (let j = 0; j < action.treatment.length; j++) {
  104. // if(repeatDiag[i].id === action.treatment[j].id) {
  105. // repeatDiag[i].medicitionsList = repeatDiag[i].medicitionsList.concat(action.treatment[j].medicitionsList)
  106. // }
  107. // }
  108. // }
  109. // repeatDiag = repeatDiag.concat(action.treatment)
  110. } else {
  111. for (let i = 0; i < treatItem.treatment.length; i++) {
  112. for (let j = 0; j < treatItem.treatment[i].medicitionsList.length; j++) {
  113. if(treatItem.treatment[i].medicitionsList[j].selected) {
  114. res.advice.scheme = scheme.concat(treatItem)
  115. }
  116. }
  117. }
  118. }
  119. res.AdviceStr = getAdviceStr(res.advice)
  120. return res;
  121. }
  122. //设置提示信息
  123. export const setTips = (state, action) => {
  124. const res = Object.assign({}, state)
  125. res.tips = action.tips;
  126. return res;
  127. }
  128. //设置提示信息详情页
  129. export const setTipsDetails = (state, action) => {
  130. const res = Object.assign({}, state)
  131. res.tipsDetails = action.tipsDetails;
  132. return res;
  133. }
  134. export const setChangeAdviceTreatment = (state, action) => {
  135. const res = JSON.parse(JSON.stringify(state))
  136. const index = action.index; //诊断的下标
  137. const ii = action.ii //同类药下表
  138. const changeInput = action.changeInput;
  139. let scheme = res.advice.scheme;
  140. scheme[index].treatment[ii].treatmentStr = changeInput
  141. return res;
  142. }
  143. export const setChangeAdviceAssay = (state, action) => {
  144. const res = JSON.parse(JSON.stringify(state))
  145. res.advice.assay = action.changeInput;
  146. return res;
  147. }
  148. export const setChangeAdviceCheck = (state, action) => {
  149. const res = JSON.parse(JSON.stringify(state))
  150. res.advice.check = action.changeInput;
  151. return res;
  152. }
  153. export const addBilling = (state, action) => {
  154. const res = JSON.parse(JSON.stringify(state));
  155. const {assay,check} = action;
  156. res.assay = res.assay.map((item,index)=>{
  157. item.checked = false
  158. return item
  159. })
  160. res.check = res.check.map((item,index)=>{
  161. item.checked = false
  162. return item
  163. })
  164. res.advice.assay = res.advice.assay || '';
  165. res.advice.check = res.advice.check || '';
  166. for (let i = 0; i < assay.length; i++) {
  167. if ( res.advice.assay === '') { //如果最后一个,则不需要逗号
  168. res.advice.assay = res.advice.assay + assay[i].name
  169. } else {
  170. if( i === 0 && res.advice.check !== '') {
  171. res.advice.assay = res.advice.assay + assay[i].name
  172. } else {
  173. res.advice.assay = res.advice.assay + ', ' + assay[i].name
  174. }
  175. }
  176. }
  177. for (let i = 0; i < check.length; i++) {
  178. if ( res.advice.check === '') { //如果最后一个,则不需要逗号
  179. res.advice.check = res.advice.check + check[i].name
  180. } else {
  181. res.advice.check = res.advice.check + ', '+ check[i].name
  182. }
  183. }
  184. if(res.advice.assay && res.advice.check !== '') {
  185. if(res.advice.assay.substring(res.advice.assay.length-2,res.advice.assay.length-1) !== ',') {
  186. res.advice.assay = res.advice.assay + ', '
  187. }
  188. }
  189. res.AdviceStr = getAdviceStr(res.advice)
  190. return res;
  191. }
  192. export const clearAllPushMessage = (state, action) => {
  193. const res = JSON.parse(JSON.stringify(state));
  194. res.advice = action.data;
  195. res.AdviceStr = action.saveText;
  196. res.tips = {};
  197. res.vigilant = [];
  198. res.doubt = [];
  199. res.possible = [];
  200. res.determine = [];
  201. res.assay = [];
  202. res.check = [];
  203. return res;
  204. }
  205. export const showTipsDetails = (state, action) => {
  206. const res = Object.assign({}, state);
  207. res.showTipsDetails = true;
  208. return res;
  209. }
  210. export const hideTipsDetails = (state, action) => {
  211. const res = Object.assign({}, state);
  212. res.showTipsDetails = false;
  213. return res;
  214. }