treat.js 17 KB

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