pushMessage.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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) {
  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. export const setTips = (state, action) => {
  123. const res = Object.assign({}, state)
  124. res.tips = action.tips;
  125. return res;
  126. }
  127. export const setChangeAdviceTreatment = (state, action) => {
  128. const res = JSON.parse(JSON.stringify(state))
  129. const index = action.index; //诊断的下标
  130. const ii = action.ii //同类药下表
  131. const changeInput = action.changeInput;
  132. let scheme = res.advice.scheme;
  133. scheme[index].treatment[ii].treatmentStr = changeInput
  134. return res;
  135. }
  136. export const setChangeAdviceAssay = (state, action) => {
  137. const res = JSON.parse(JSON.stringify(state))
  138. res.advice.assay = action.changeInput;
  139. return res;
  140. }
  141. export const setChangeAdviceCheck = (state, action) => {
  142. const res = JSON.parse(JSON.stringify(state))
  143. res.advice.check = action.changeInput;
  144. return res;
  145. }
  146. export const addBilling = (state, action) => {
  147. const res = JSON.parse(JSON.stringify(state));
  148. const {assay,check} = action;
  149. res.assay = res.assay.map((item,index)=>{
  150. item.checked = false
  151. return item
  152. })
  153. res.check = res.check.map((item,index)=>{
  154. item.checked = false
  155. return item
  156. })
  157. res.advice.assay = res.advice.assay || '';
  158. res.advice.check = res.advice.check || '';
  159. for (let i = 0; i < assay.length; i++) {
  160. if ( res.advice.assay === '') { //如果最后一个,则不需要逗号
  161. res.advice.assay = res.advice.assay + assay[i].name
  162. } else {
  163. if( i === 0 && res.advice.check !== '') {
  164. res.advice.assay = res.advice.assay + assay[i].name
  165. } else {
  166. res.advice.assay = res.advice.assay + ', ' + assay[i].name
  167. }
  168. }
  169. }
  170. for (let i = 0; i < check.length; i++) {
  171. if ( res.advice.check === '') { //如果最后一个,则不需要逗号
  172. res.advice.check = res.advice.check + check[i].name
  173. } else {
  174. res.advice.check = res.advice.check + ', '+ check[i].name
  175. }
  176. }
  177. if(res.advice.assay && res.advice.check !== '') {
  178. if(res.advice.assay.substring(res.advice.assay.length-2,res.advice.assay.length-1) !== ',') {
  179. res.advice.assay = res.advice.assay + ', '
  180. }
  181. }
  182. res.AdviceStr = getAdviceStr(res.advice)
  183. return res;
  184. }
  185. export const clearAllPushMessage = (state, action) => {
  186. const res = JSON.parse(JSON.stringify(state));
  187. res.advice = action.data
  188. res.AdviceStr = action.saveText
  189. return res;
  190. }