treat.js 15 KB

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