import { json } from "@utils/ajax"; // import { SET_TREAT } from '@store/types/diagnosticList'; import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR,SET_TREAT,SHOW_LOADING,ADD_TREAT} from '@store/types/diagnosticList'; import { SET_COMMONTREATMENT } from '@store/types/pushMessage' 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'; import {storageLocal,getEMRParams} from '@utils/tools'; import { isAddMainSuit } from '@store/async-actions/diagnosticList'; import { SAVE_FOLLOW_UP } from "@store/types/pushMessage"; import {MODI_LOADING} from '@store/types/homePage.js'; import { SHOW_TREAT} from '@store/types/treat.js'; import Notify from '@commonComp/Notify'; const api={ pushTreatment:'/push/pushTreatment', getConceptDetail:'/conceptDetail/getConceptDetail' } // export const addDiagnostic = (item) => { // return (dispatch, getState) => { // const state = getState(); // let url = api.pushTreatment; // const emrData = getEMRParams(); // const diagnosticList = state.diagnosticList.diagnosticList; // let diag = ''; // if(diagnosticList) { // for (let i = 0; i < diagnosticList.length; i++ ) { // if(i ===0 ) { // diag = diag + diagnosticList[i].name; // } else { // diag = diag + ',' + diagnosticList[i].name; // } // } // } // if (item.type === 1) { // diag = diag + ',' + item.name // } else { // diag = diag + ',' + item.name // } // const params = { // "age": emrData.age, // "featureType": "8", // "diag": diag, // "diseaseName": item.name, // "lis": emrData.lis, // "other": emrData.other, // "pacs": emrData.pacs, // "sex": emrData.sex, // "symptom": emrData.current + emrData.main, // "vital": emrData.vital, // "patientId": emrData.patientId, // "hosCode": emrData.hosCode, // "adverseReactions": "string", // "scaleName": "string", // }; // //判断是否走慢病系统 // const isChronic = state.diagnosticList.chronicMagItem ||state.mainSuit.chronicDesease; // // const isChronic = true // if (isChronic) { // let chronicList = JSON.parse(storageLocal.get('chronic')); // if(!chronicList){ // getChronic().then(() =>{ // chronicList = JSON.parse(storageLocal.get('chronic')); // for(let i=0; i{ // if (data.data.data) { // itemTreat.treat = data.data.data // dispatch({ // type: ADD_TREAT, // item: itemTreat // }) // } else { // item.treat = null // dispatch({ // type: ADD_TREAT, // item: itemTreat // }) // } // }).catch((e) =>{ // console.log(e) // }) // } export const getTreatResult = (item) =>{ return (dispatch, getState) => { dispatch({ type: SET_TREAT_INFO, treatItem: item }) const state = getState(); let url = api.pushTreatment; const emrData = getEMRParams(); const diagnosticList = state.diagnosticList.diagnosticList; let diag = ''; if(diagnosticList) { for (let i = 0; i < diagnosticList.length; i++ ) { if(i === 0 ) { diag = diag + diagnosticList[i].name; } else { diag = diag + ',' + diagnosticList[i].name; } } } const params = { "age": emrData.age, "featureType": "8", "diag": diag, "diseaseName": item.name, "lis": emrData.lis, "other": emrData.other, "pacs": emrData.pacs, "sex": emrData.sex, "symptom": emrData.current + emrData.main, "vital": emrData.vital, "patientId": emrData.patientId, "hosCode": emrData.hosCode }; // const params = { // "age": 20, // "diag": ",糖尿病", // "disType": 1, // "diseaseId":21773, // "featureType": "8", // "lis": [ // ], // "sex": 3, // "symptom": "恶心,呕吐", // "vital": "" // } const isChronic = state.diagnosticList.chronicMagItem ||state.mainSuit.chronicDesease; // const isChronic = true if (isChronic) { let chronicList = JSON.parse(storageLocal.get('chronic')); if(!chronicList){ getChronic().then(() =>{ chronicList = JSON.parse(storageLocal.get('chronic')); for(let i=0; i{ if(data.data.code == '0') { // dispatch({type:MODI_LOADING,flag:false}); // dispatch({type:SHOW_LOADING,flag:false}); let treat; if(data.data.data) { treat = data.data.data || {} } if(treat) { let { treatment, commonTreatment, surgeryTreatment, drugHistory, adverseReactions, followUp} = treat if(!(commonTreatment || surgeryTreatment || ( treatment &&treatment.length >0 || drugHistory&&drugHistory.length >0 || adverseReactions&&adverseReactions.length >0 || !!followUp ||treatment&&treatment.length >0))) { Notify.info('暂无数据'); return } dispatch({type: SHOW_TREAT}) dispatch({ type: SET_TREATMENT, treatment: treatment, generalTreat: commonTreatment, surgeryTreat: surgeryTreatment, drugHistory: drugHistory, }) if (adverseReactions) { //如何之前存过不良反应,则替换成之前的不良反应 const allAdversReactionList = state.treat.allAdversReactionList if(allAdversReactionList) { for(let i = 0; i < allAdversReactionList.length; i++) { if(item.conceptId == allAdversReactionList[i].conceptId) { //判断是否存过不良反应 for (let j = 0; j < adverseReactions.length; j++) { //判断不良反应是否有相同的不良反应,如果有,替换 for(let z = 0; z < allAdversReactionList[i].adversReactionList.length; z++) { if(adverseReactions[j].conceptId == allAdversReactionList[i].adversReactionList[z].conceptId && adverseReactions[j].name == allAdversReactionList[i].adversReactionList[z].name) { for(let x = 0; x < allAdversReactionList[i].adversReactionList[z].details.length; x++) { for(let y = 0; y < adverseReactions[j].details.length; y++) {//判断每一项是否选择过 if(allAdversReactionList[i].adversReactionList[z].details[x].name == adverseReactions[j].details[y].name && allAdversReactionList[i].adversReactionList[z].details[x].select) { adverseReactions[j].details[y].select = allAdversReactionList[i].adversReactionList[z].details[x].select } } } } } } } } } } else { adverseReactions = [] } if(isChronic) { let chronicList = JSON.parse(storageLocal.get('chronic')); for(let i=0; i{ console.log(e) }) } //保存全部不良反应 export const saveAllAdverseReactions = (item) => { return (dispatch, getState) => { const state = getState() const adversReactionList = state.treat.adversReactionList dispatch({ type: SET_ALL_ADVERSE_REACTIONS, adversReactionList: { 'conceptId': item.conceptId, 'adversReactionList': adversReactionList } }) } } //保存全部诊断的回访时间 export const setAllFollowUp = (item) => { return (dispatch, getState) => { const state = getState() const followUp = state.treat.followUp dispatch({ type: SET_ALL_FOLLOW_UP, followUp: { 'conceptId': item.conceptId, 'followUp': followUp } }) } } export const getInstroduce = (item, type, position)=>{ console.log(item,type) return (dispatch, getState) =>{ const params = { name: item.name, type: item.type, position: item.position } json(api.getConceptDetail, params) .then((data)=>{ if(data.data.code == '0') { dispatch({ type: SET_DRUG_INFO, instroduce: data.data.data.introduceDetailList, name: item.name, tagType: item.type }) } else { dispatch({ type: SET_DRUG_INFO, instroduce: [], name: item.name, tagType: item.type }) } }).catch((e) => { console.log(e) }) } } // export const getInstroduceMore = (drugIdList) =>{ // return (dispatch, getState) =>{ // let drugInfoList = []; // for (let i = 0; i < drugIdList.drugIdList.length; i++ ) { // const url = '/conceptDetail/getConceptDetail'; // const params = { // questionId: drugIdList.drugIdList[i], // type: 8, // position: 5 // } // json(url, params) // .then((data)=>{ // if(data.data.data) { // drugInfoList.push(data.data.data) // dispatch({ // type: SET_DRUG_INFO_LIST, // drugInfoList: drugInfoList, // }) // } else { // drugInfoList.push([]) // dispatch({ // type: SET_DRUG_INFO_LIST, // drugInfoList: drugInfoList, // }) // } // }).catch((e) => { // console.log(e) // }) // } // } // } //一般治疗添加到医嘱 export const commonTreatAddToAdvice = () => { return (dispatch, getState) => { const state = getState(); const followUp = state.treat.followUp if(state.treat.treatItem.conceptId === state.diagnosticList.diagnosticList[0].conceptId && state.treat.isFirstMainDiag) { dispatch({ type: IS_FIRST_MAIN_DIAG }) dispatch({ type: SET_COMMONTREATMENT, commontreatment: state.treat.generalTreat&&state.treat.generalTreat.content }) if(followUp) { dispatch({ type: SAVE_FOLLOW_UP, followUp: followUp, hasFollowUp: true }) } if(state.treat.generalTreat&&state.treat.generalTreat.content || followUp) { //如果一般治疗和回访时间存在,定位到医嘱 document.getElementById("adviceBox").scrollIntoView(true) } } else { return } } } //其他推荐推荐依据不用展示 // export const getRecommendBasic = (item)=>{ // return (dispatch, getState) =>{ // const url = '/api/icss/introduceInfo/getByQuestionId'; // const params = { // questionId: item.id, // type: 9, // position: 2 // } // json(url, params) // .then((data)=>{ // if (data.status === 200) { // if(data.data.data) { // dispatch({ // type: SET_RECOMMEND_BASIC, // recommendBasic: data.data.data.introduceDetailList, // }) // } else { // dispatch({ // type: SET_RECOMMEND_BASIC, // recommendBasic: [], // }) // } // } // }).catch((e) => { // console.log(e) // }) // } // }