treat.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. import { json } from "@utils/ajax";
  2. import { SET_TREAT } from '@store/types/diagnosticList';
  3. import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR} from '@store/types/diagnosticList';
  4. import { SET_COMMONTREATMENT } from '@store/types/pushMessage'
  5. import { SET_DRUG_INFO, SET_TREATMENT, SET_TREAT_INFO, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST, IS_FIRST_MAIN_DIAG, SET_ADVERSE_REACTIONS, SET_ALL_ADVERSE_REACTIONS, SET_FOLLOW_UP, DEL_FOLLOW_UP, SET_ALL_FOLLOW_UP } from '@store/types/treat';
  6. import {storageLocal,getEMRParams} from '@utils/tools';
  7. import { isAddMainSuit } from '@store/async-actions/diagnosticList';
  8. import { SAVE_FOLLOW_UP } from "@store/types/pushMessage";
  9. const api={
  10. push:'/push/pushInner',
  11. textPush:'/push/pushText'
  12. }
  13. export const addDiagnostic = (item) => {
  14. return (dispatch, getState) => {
  15. const state = getState();
  16. let url = api.push;
  17. if(+state.typeConfig.confirmType===1){
  18. url=api.textPush;
  19. }
  20. const emrData = getEMRParams();
  21. const diagnosticList = state.diagnosticList.diagnosticList;
  22. let diag = '';
  23. if(diagnosticList) {
  24. for (let i = 0; i < diagnosticList.length; i++ ) {
  25. if(i ===0 ) {
  26. diag = diag + diagnosticList[i].name;
  27. } else {
  28. diag = diag + ',' + diagnosticList[i].name;
  29. }
  30. }
  31. }
  32. if (item.type === 1) {
  33. diag = diag + ',' + item.name
  34. } else {
  35. diag = diag + ',' + item.name
  36. }
  37. const params = {
  38. "age": emrData.age,
  39. "featureType": "8",
  40. "diag": diag,
  41. "diseaseId": item.id,
  42. "lis": emrData.lis,
  43. "other": emrData.other,
  44. "pacs": emrData.pacs,
  45. "sex": emrData.sex,
  46. "symptom": emrData.current + emrData.main,
  47. "vital": emrData.vital,
  48. "patientId": emrData.patientId,
  49. };
  50. //判断是否走慢病系统
  51. const isChronic = state.diagnosticList.chronicMagItem && state.diagnosticList.chronicMagItem.name||state.mainSuit.chronicDesease && state.mainSuit.chronicDesease.name;
  52. // const isChronic = true
  53. if (isChronic) {
  54. let chronicList = JSON.parse(storageLocal.get('chronic'));
  55. if(!chronicList){
  56. getChronic().then(() =>{
  57. chronicList = JSON.parse(storageLocal.get('chronic'));
  58. for(let i=0; i<chronicList.length; i++){
  59. if(chronicList[i].id==item.id&&chronicList[i].name==item.name){ //判断某个病是否为慢病
  60. params.disType = 1
  61. }
  62. }
  63. hasTreatment(dispatch, state,item,url,params)
  64. });
  65. } else {
  66. for(let i=0; i<chronicList.length; i++){
  67. if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
  68. params.disType = 1
  69. }
  70. }
  71. hasTreatment(dispatch, state, item,url,params)
  72. }
  73. } else {
  74. hasTreatment(dispatch, state, item,url,params)
  75. }
  76. }
  77. }
  78. //判断是否存在治疗方案
  79. function hasTreatment(dispatch, state,item,url, params) {
  80. json(url, params).then((data) =>{
  81. if (data.data.data) {
  82. item.treat = data.data.data.treat
  83. dispatch({
  84. type: ADD_DIAGNOSTIC,
  85. item: item
  86. })
  87. } else {
  88. item.treat = null
  89. dispatch({
  90. type: ADD_DIAGNOSTIC,
  91. item: item
  92. })
  93. }
  94. dispatch({
  95. type: GET_DIAGNOSTIC_STR
  96. });
  97. dispatch(isAddMainSuit())
  98. }).catch((e) =>{
  99. console.log(e)
  100. })
  101. }
  102. export const getTreatResult = (item) =>{
  103. return (dispatch, getState) => {
  104. dispatch({
  105. type: SET_TREAT_INFO,
  106. treatItem: item
  107. })
  108. const state = getState();
  109. let url = api.push;
  110. if(+state.typeConfig.confirmType===1){
  111. url=api.textPush;
  112. }
  113. const emrData = getEMRParams();
  114. const diagnosticList = state.diagnosticList.diagnosticList;
  115. let diag = '';
  116. if(diagnosticList) {
  117. for (let i = 0; i < diagnosticList.length; i++ ) {
  118. if(i === 0 ) {
  119. diag = diag + diagnosticList[i].name;
  120. } else {
  121. diag = diag + ',' + diagnosticList[i].name;
  122. }
  123. }
  124. }
  125. const params = {
  126. "age": emrData.age,
  127. "featureType": "8",
  128. "diag": diag,
  129. "diseaseId": item.id,
  130. "lis": emrData.lis,
  131. "other": emrData.other,
  132. "pacs": emrData.pacs,
  133. "sex": emrData.sex,
  134. "symptom": emrData.current + emrData.main,
  135. "vital": emrData.vital,
  136. "patientId": emrData.patientId,
  137. };
  138. // const params = {
  139. // "age": 20,
  140. // "diag": ",糖尿病",
  141. // "disType": 1,
  142. // "diseaseId":21773,
  143. // "featureType": "8",
  144. // "lis": [
  145. // ],
  146. // "sex": 3,
  147. // "symptom": "恶心,呕吐",
  148. // "vital": ""
  149. // }
  150. const isChronic = state.diagnosticList.chronicMagItem && state.diagnosticList.chronicMagItem.name||state.mainSuit.chronicDesease && state.mainSuit.chronicDesease.name;
  151. // const isChronic = true
  152. if (isChronic) {
  153. let chronicList = JSON.parse(storageLocal.get('chronic'));
  154. if(!chronicList){
  155. getChronic().then(() =>{
  156. chronicList = JSON.parse(storageLocal.get('chronic'));
  157. for(let i=0; i<chronicList.length; i++){
  158. if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
  159. params.disType = 1
  160. }
  161. }
  162. getTreatment(item, dispatch, state, url,params, isChronic)
  163. });
  164. } else {
  165. for(let i=0; i<chronicList.length; i++){
  166. if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
  167. params.disType = 1
  168. }
  169. }
  170. getTreatment(item, dispatch, state,url,params, isChronic)
  171. }
  172. } else {
  173. getTreatment(item, dispatch, state,url,params, isChronic)
  174. }
  175. }
  176. }
  177. //获取治疗方案
  178. function getTreatment(item, dispatch, state,url,params, isChronic) {
  179. json(url, params).then((data) =>{
  180. let treat;
  181. if(data.data.data) {
  182. treat = data.data.data.treat || {}
  183. }
  184. if(treat) {
  185. let { treatment, commonTreatment, surgeryTreatment, drugHistory, adverseReactions, followUp} = treat
  186. dispatch({
  187. type: SET_TREATMENT,
  188. treatment: treatment,
  189. generalTreat: commonTreatment,
  190. surgeryTreat: surgeryTreatment,
  191. drugHistory: drugHistory,
  192. })
  193. if (adverseReactions) { //如何之前存过不良反应,则替换成之前的不良反应
  194. const allAdversReactionList = state.treat.allAdversReactionList
  195. if(allAdversReactionList) {
  196. for(let i = 0; i < allAdversReactionList.length; i++) {
  197. if(item.id == allAdversReactionList[i].id) { //判断是否存过不良反应
  198. for (let j = 0; j < adverseReactions.length; j++) { //判断不良反应是否有相同的不良反应,如果有,替换
  199. for(let z = 0; z < allAdversReactionList[i].adversReactionList.length; z++) {
  200. if(adverseReactions[j].id == allAdversReactionList[i].adversReactionList[z].id) {
  201. adverseReactions[j] = allAdversReactionList[i].adversReactionList[z]
  202. }
  203. }
  204. }
  205. }
  206. }
  207. }
  208. } else {
  209. adverseReactions = []
  210. }
  211. if(isChronic) {
  212. let chronicList = JSON.parse(storageLocal.get('chronic'));
  213. for(let i=0; i<chronicList.length; i++){
  214. if(chronicList[i].id==item.id&&chronicList[i].name==item.name){ //判断某个病是否为慢病
  215. followUp = '2周';
  216. }
  217. }
  218. }
  219. if(followUp) {
  220. const followUpList = state.treat.followUpList
  221. if(followUpList) { //判断之前有没有报存过的回访时间,如果有替换掉
  222. for(let i = 0; i < followUpList.length; i++) {
  223. if(item.id == followUpList[i].id) {
  224. followUp = followUpList[i].followUp
  225. }
  226. }
  227. }
  228. dispatch({
  229. type: SET_FOLLOW_UP,
  230. // followUp: treat.followUp,
  231. followUp: followUp,
  232. hasFollowUp: true
  233. })
  234. } else {
  235. dispatch({
  236. type: DEL_FOLLOW_UP,
  237. delItem: item,
  238. })
  239. }
  240. dispatch({
  241. type: SET_ADVERSE_REACTIONS,
  242. adversReactionList: adverseReactions
  243. })
  244. }
  245. }).catch((e) =>{
  246. console.log(e)
  247. })
  248. }
  249. //保存全部不良反应
  250. export const saveAllAdverseReactions = (item) => {
  251. return (dispatch, getState) => {
  252. const state = getState()
  253. const adversReactionList = state.treat.adversReactionList
  254. dispatch({
  255. type: SET_ALL_ADVERSE_REACTIONS,
  256. adversReactionList: {
  257. 'id': item.id,
  258. 'adversReactionList': adversReactionList
  259. }
  260. })
  261. }
  262. }
  263. //保存全部诊断的回访时间
  264. export const setAllFollowUp = (item) => {
  265. return (dispatch, getState) => {
  266. const state = getState()
  267. const followUp = state.treat.followUp
  268. dispatch({
  269. type: SET_ALL_FOLLOW_UP,
  270. followUp: {
  271. 'id': item.id,
  272. 'followUp': followUp
  273. }
  274. })
  275. }
  276. }
  277. export const getInstroduce = (item)=>{
  278. return (dispatch, getState) =>{
  279. const url = '/introduceInfo/getByQuestionId';
  280. const params = {
  281. questionId: item.id,
  282. type: 8,
  283. position: 5
  284. }
  285. json(url, params)
  286. .then((data)=>{
  287. if(data.data.data) {
  288. dispatch({
  289. type: SET_DRUG_INFO,
  290. instroduce: data.data.data.introduceDetailList,
  291. name: item.medicitionName
  292. })
  293. } else {
  294. dispatch({
  295. type: SET_DRUG_INFO,
  296. instroduce: [],
  297. name: item.medicitionName
  298. })
  299. }
  300. }).catch((e) => {
  301. console.log(e)
  302. })
  303. }
  304. }
  305. export const getInstroduceMore = (drugIdList) =>{
  306. return (dispatch, getState) =>{
  307. let drugInfoList = [];
  308. for (let i = 0; i < drugIdList.drugIdList.length; i++ ) {
  309. const url = '/introduceInfo/getByQuestionId';
  310. const params = {
  311. questionId: drugIdList.drugIdList[i],
  312. type: 8,
  313. position: 5
  314. }
  315. json(url, params)
  316. .then((data)=>{
  317. if(data.data.data) {
  318. drugInfoList.push(data.data.data)
  319. dispatch({
  320. type: SET_DRUG_INFO_LIST,
  321. drugInfoList: drugInfoList,
  322. })
  323. } else {
  324. drugInfoList.push([])
  325. dispatch({
  326. type: SET_DRUG_INFO_LIST,
  327. drugInfoList: drugInfoList,
  328. })
  329. }
  330. }).catch((e) => {
  331. console.log(e)
  332. })
  333. }
  334. }
  335. }
  336. //一般治疗添加到医嘱
  337. export const commonTreatAddToAdvice = () => {
  338. return (dispatch, getState) => {
  339. const state = getState();
  340. const followUp = state.treat.followUp
  341. if(state.treat.treatItem.id === state.diagnosticList.diagnosticList[0].id && state.treat.isFirstMainDiag) {
  342. dispatch({
  343. type: IS_FIRST_MAIN_DIAG
  344. })
  345. dispatch({
  346. type: SET_COMMONTREATMENT,
  347. commontreatment: state.treat.treatItem.treat.commonTreatment.text
  348. })
  349. console.log('state.treat.followUp', state.treat.followUp)
  350. dispatch({
  351. type: SAVE_FOLLOW_UP,
  352. followUp: state.treat.followUp
  353. })
  354. } else {
  355. return
  356. }
  357. }
  358. }
  359. //其他推荐推荐依据不用展示
  360. // export const getRecommendBasic = (item)=>{
  361. // return (dispatch, getState) =>{
  362. // const url = '/api/icss/introduceInfo/getByQuestionId';
  363. // const params = {
  364. // questionId: item.id,
  365. // type: 9,
  366. // position: 2
  367. // }
  368. // json(url, params)
  369. // .then((data)=>{
  370. // if (data.status === 200) {
  371. // if(data.data.data) {
  372. // dispatch({
  373. // type: SET_RECOMMEND_BASIC,
  374. // recommendBasic: data.data.data.introduceDetailList,
  375. // })
  376. // } else {
  377. // dispatch({
  378. // type: SET_RECOMMEND_BASIC,
  379. // recommendBasic: [],
  380. // })
  381. // }
  382. // }
  383. // }).catch((e) => {
  384. // console.log(e)
  385. // })
  386. // }
  387. // }