treat.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. import {getChronic} from '@store/async-actions/homePage.js';
  13. import config from "@config/index";
  14. const api={
  15. pushTreatment:'/push/pushTreatment',
  16. getConceptDetail:'/conceptDetail/getConceptDetail'
  17. }
  18. export const getTreatResult = (item) =>{
  19. return (dispatch, getState) => {
  20. dispatch({
  21. type: SET_TREAT_INFO,
  22. treatItem: item
  23. })
  24. const state = getState();
  25. let url = api.pushTreatment;
  26. const emrData = getEMRParams();
  27. const diagnosticList = state.diagnosticList.diagnosticList;
  28. let diag = '';
  29. if(diagnosticList) {
  30. for (let i = 0; i < diagnosticList.length; i++ ) {
  31. if(i === 0 ) {
  32. diag = diag + diagnosticList[i].name;
  33. } else {
  34. diag = diag + ',' + diagnosticList[i].name;
  35. }
  36. }
  37. }
  38. const params = {
  39. "age": emrData.age,
  40. "featureType": "8",
  41. "ruleType":config.ruleTypeMap["8"],
  42. "diag": diag,
  43. "diseaseName": item.name,
  44. "lis": emrData.lis,
  45. "other": emrData.other,
  46. "pacs": emrData.pacs,
  47. "sex": emrData.sex,
  48. "symptom": emrData.current + emrData.main,
  49. "vital": emrData.vital,
  50. "patientId": emrData.patientId,
  51. "hosCode": emrData.hosCode
  52. };
  53. // const params = {
  54. // "disType":"1",
  55. // "age":28,
  56. // "diag":"2型糖尿病性肾病,1型糖尿病,糖尿病肾病",
  57. // "diseaseName":"2型糖尿病",
  58. // "featureType":"8",
  59. // "hosCode":"A001",
  60. // "lis":[
  61. // {
  62. // "name":"糖化血红蛋白测定",
  63. // "detailName":"糖化血红蛋白(HbA1c)",
  64. // "uniqueName":"糖化血红蛋白测定--糖化血红蛋白(HbA1c)",
  65. // "source":"0",
  66. // "minValue":4,
  67. // "otherValue":"",
  68. // "maxValue":6,
  69. // "units":"%",
  70. // "value":"5"
  71. // },
  72. // {
  73. // "name":"空腹葡萄糖测定",
  74. // "detailName":"葡萄糖(GLU)",
  75. // "uniqueName":"空腹葡萄糖测定--葡萄糖(GLU)",
  76. // "source":"0",
  77. // "minValue":3.9,
  78. // "otherValue":"",
  79. // "maxValue":6.1,
  80. // "units":"mmol/L",
  81. // "value":"5"
  82. // },
  83. // {
  84. // "name":"肝功能测定",
  85. // "detailName":"谷丙转氨酶(ALT)",
  86. // "uniqueName":"肝功能测定--谷丙转氨酶(ALT)",
  87. // "source":"0",
  88. // "minValue":5,
  89. // "otherValue":"",
  90. // "maxValue":40,
  91. // "units":"U/L",
  92. // "value":"180"
  93. // }
  94. // ],
  95. // "lisOrder":"",
  96. // "lisString":"",
  97. // "other":"",
  98. // "otherOrder":"",
  99. // "pacs":"",
  100. // "pacsOrder":"",
  101. // "sex":1,
  102. // "symptom":"患者患有2型糖尿病近来出现泡沫尿",
  103. // "vital":"体温40℃"
  104. // }
  105. const isChronic = state.diagnosticList.chronicMagItem ||state.mainSuit.chronicDesease;
  106. // const isChronic = true
  107. if (isChronic) {
  108. let chronicList = JSON.parse(storageLocal.get('chronic'));
  109. if(!chronicList){
  110. getChronic().then(() =>{
  111. chronicList = JSON.parse(storageLocal.get('chronic'));
  112. for(let i=0; i<chronicList.length; i++){
  113. if(chronicList[i].conceptId==item.conceptId&&chronicList[i].name==item.name){
  114. params.disType = 1
  115. }
  116. }
  117. getTreatment(item, dispatch, state, url,params, isChronic)
  118. });
  119. } else {
  120. for(let i=0; i<chronicList.length; i++){
  121. if(chronicList[i].conceptId==item.conceptId&&chronicList[i].name==item.name){
  122. params.disType = 1
  123. }
  124. }
  125. getTreatment(item, dispatch, state,url,params, isChronic)
  126. }
  127. } else {
  128. getTreatment(item, dispatch, state,url,params, isChronic)
  129. }
  130. }
  131. }
  132. //获取治疗方案
  133. function getTreatment(item, dispatch, state,url,params, isChronic) {
  134. json(url, params).then((data) =>{
  135. if(data.data.code == '0') {
  136. // dispatch({type:MODI_LOADING,flag:false});
  137. // dispatch({type:SHOW_LOADING,flag:false});
  138. let treat;
  139. if(data.data.data) {
  140. treat = data.data.data || {}
  141. }
  142. if(treat) {
  143. let { treatmentPlan, commonTreatment, surgeryTreatment, drugHistory, adverseEvent, followUp} = treat
  144. if(!(commonTreatment || surgeryTreatment ||
  145. ( treatmentPlan &&treatmentPlan.length >0 ||
  146. drugHistory&&drugHistory.length >0 ||
  147. adverseEvent&&adverseEvent.length >0 ||
  148. !!followUp ||treatment&&treatment.length >0))) {
  149. Notify.info('暂无数据');
  150. return
  151. }
  152. dispatch({type: SHOW_TREAT})
  153. dispatch({
  154. type: SET_TREATMENT,
  155. treatment: treatmentPlan,
  156. generalTreat: commonTreatment,
  157. surgeryTreat: surgeryTreatment,
  158. drugHistory: drugHistory,
  159. })
  160. if (adverseEvent) { //如何之前存过不良反应,则替换成之前的不良反应
  161. const allAdversReactionList = state.treat.allAdversReactionList
  162. if(allAdversReactionList) {
  163. for(let i = 0; i < allAdversReactionList.length; i++) {
  164. if(item.conceptId == allAdversReactionList[i].conceptId) { //判断是否存过不良反应
  165. for (let j = 0; j < adverseEvent.length; j++) { //判断不良反应是否有相同的不良反应,如果有,替换
  166. for(let z = 0; z < allAdversReactionList[i].adversReactionList.length; z++) {
  167. if(adverseEvent[j].conceptId == allAdversReactionList[i].adversReactionList[z].conceptId && adverseEvent[j].name == allAdversReactionList[i].adversReactionList[z].name) {
  168. for(let x = 0; x < allAdversReactionList[i].adversReactionList[z].details.length; x++) {
  169. for(let y = 0; y < adverseEvent[j].details.length; y++) {//判断每一项是否选择过
  170. if(allAdversReactionList[i].adversReactionList[z].details[x].name == adverseEvent[j].details[y].name && allAdversReactionList[i].adversReactionList[z].details[x].select) {
  171. adverseEvent[j].details[y].select = allAdversReactionList[i].adversReactionList[z].details[x].select
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. } else {
  182. adverseEvent = []
  183. }
  184. if(isChronic) {
  185. let chronicList = JSON.parse(storageLocal.get('chronic'));
  186. for(let i=0; i<chronicList.length; i++){
  187. if(chronicList[i].conceptId==item.conceptId&&chronicList[i].name==item.name){ //判断某个病是否为慢病
  188. followUp = '2周';
  189. }
  190. }
  191. }
  192. if(followUp) {
  193. const followUpList = state.treat.followUpList
  194. if(followUpList) { //判断之前有没有保存过的回访时间,如果有替换掉
  195. for(let i = 0; i < followUpList.length; i++) {
  196. if(item.conceptId == followUpList[i].conceptId) {
  197. followUp = followUpList[i].followUp
  198. }
  199. }
  200. }
  201. dispatch({
  202. type: SET_FOLLOW_UP,
  203. // followUp: treat.followUp,
  204. followUp: followUp,
  205. hasFollowUp: true
  206. })
  207. } else {
  208. dispatch({
  209. type: DEL_FOLLOW_UP,
  210. delItem: item,
  211. })
  212. }
  213. dispatch({
  214. type: SET_ADVERSE_REACTIONS,
  215. adversReactionList: adverseEvent
  216. })
  217. } else {
  218. Notify.info('暂无数据');
  219. }
  220. }else {
  221. Notify.info('暂无数据');
  222. }
  223. }).catch((e) =>{
  224. console.log(e)
  225. })
  226. }
  227. //保存全部不良反应
  228. export const saveAllAdverseReactions = (item) => {
  229. return (dispatch, getState) => {
  230. const state = getState()
  231. const adversReactionList = state.treat.adversReactionList
  232. dispatch({
  233. type: SET_ALL_ADVERSE_REACTIONS,
  234. adversReactionList: {
  235. 'conceptId': item.conceptId,
  236. 'adversReactionList': adversReactionList
  237. }
  238. })
  239. }
  240. }
  241. //保存全部诊断的回访时间
  242. export const setAllFollowUp = (item) => {
  243. return (dispatch, getState) => {
  244. const state = getState()
  245. const followUp = state.treat.followUp
  246. dispatch({
  247. type: SET_ALL_FOLLOW_UP,
  248. followUp: {
  249. 'conceptId': item.conceptId,
  250. 'followUp': followUp
  251. }
  252. })
  253. }
  254. }
  255. export const getInstroduce = (item, type, position)=>{
  256. console.log(item,type)
  257. return (dispatch, getState) =>{
  258. const params = {
  259. name: item.name,
  260. type: item.type,
  261. position: item.position
  262. }
  263. json(api.getConceptDetail, params)
  264. .then((data)=>{
  265. if(data.data.code == '0') {
  266. dispatch({
  267. type: SET_DRUG_INFO,
  268. instroduce: data.data.data.introduceDetailList,
  269. name: item.name,
  270. tagType: item.type
  271. })
  272. } else {
  273. dispatch({
  274. type: SET_DRUG_INFO,
  275. instroduce: [],
  276. name: item.name,
  277. tagType: item.type
  278. })
  279. }
  280. }).catch((e) => {
  281. console.log(e)
  282. })
  283. }
  284. }
  285. // export const getInstroduceMore = (drugIdList) =>{
  286. // return (dispatch, getState) =>{
  287. // let drugInfoList = [];
  288. // for (let i = 0; i < drugIdList.drugIdList.length; i++ ) {
  289. // const url = '/conceptDetail/getConceptDetail';
  290. // const params = {
  291. // questionId: drugIdList.drugIdList[i],
  292. // type: 8,
  293. // position: 5
  294. // }
  295. // json(url, params)
  296. // .then((data)=>{
  297. // if(data.data.data) {
  298. // drugInfoList.push(data.data.data)
  299. // dispatch({
  300. // type: SET_DRUG_INFO_LIST,
  301. // drugInfoList: drugInfoList,
  302. // })
  303. // } else {
  304. // drugInfoList.push([])
  305. // dispatch({
  306. // type: SET_DRUG_INFO_LIST,
  307. // drugInfoList: drugInfoList,
  308. // })
  309. // }
  310. // }).catch((e) => {
  311. // console.log(e)
  312. // })
  313. // }
  314. // }
  315. // }
  316. //一般治疗添加到医嘱
  317. export const commonTreatAddToAdvice = () => {
  318. return (dispatch, getState) => {
  319. const state = getState();
  320. const followUp = state.treat.followUp
  321. if(state.treat.treatItem.conceptId === state.diagnosticList.diagnosticList[0].conceptId && state.treat.isFirstMainDiag) {
  322. dispatch({
  323. type: IS_FIRST_MAIN_DIAG
  324. })
  325. dispatch({
  326. type: SET_COMMONTREATMENT,
  327. commontreatment: state.treat.generalTreat&&state.treat.generalTreat.content
  328. })
  329. if(followUp) {
  330. dispatch({
  331. type: SAVE_FOLLOW_UP,
  332. followUp: followUp,
  333. hasFollowUp: true
  334. })
  335. }
  336. if(state.treat.generalTreat&&state.treat.generalTreat.content || followUp) { //如果一般治疗和回访时间存在,定位到医嘱
  337. document.getElementById("adviceBox").scrollIntoView(true)
  338. }
  339. } else {
  340. return
  341. }
  342. }
  343. }
  344. //其他推荐推荐依据不用展示
  345. // export const getRecommendBasic = (item)=>{
  346. // return (dispatch, getState) =>{
  347. // const url = '/api/icss/introduceInfo/getByQuestionId';
  348. // const params = {
  349. // questionId: item.id,
  350. // type: 9,
  351. // position: 2
  352. // }
  353. // json(url, params)
  354. // .then((data)=>{
  355. // if (data.status === 200) {
  356. // if(data.data.data) {
  357. // dispatch({
  358. // type: SET_RECOMMEND_BASIC,
  359. // recommendBasic: data.data.data.introduceDetailList,
  360. // })
  361. // } else {
  362. // dispatch({
  363. // type: SET_RECOMMEND_BASIC,
  364. // recommendBasic: [],
  365. // })
  366. // }
  367. // }
  368. // }).catch((e) => {
  369. // console.log(e)
  370. // })
  371. // }
  372. // }