treat.js 16 KB

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