Browse Source

治疗方案接口对接

zhangxc 6 years ago
parent
commit
64d5cbd10c
3 changed files with 90 additions and 89 deletions
  1. 1 1
      src/components/Treat/DrugTreat/index.jsx
  2. 2 2
      src/containers/Treat.js
  3. 87 86
      src/store/async-actions/treat.js

+ 1 - 1
src/components/Treat/DrugTreat/index.jsx

@@ -55,7 +55,7 @@ class DrugTreat extends Component {
     }
     setDrugInfo(item) {
         const { setDrugInfo } = this.props;
-        setDrugInfo && setDrugInfo(item, 8, 5);
+        setDrugInfo && setDrugInfo({name: item.medicitionName, type: 8, position: 5});
     }
     getImg() {
     }

+ 2 - 2
src/containers/Treat.js

@@ -50,8 +50,8 @@ function mapDispatchToProps(dispatch) {
             //推荐依据不展示
             // dispatch(getRecommendBasic(item))
         },
-        setDrugInfo: (item, type, position) => {
-            dispatch(getInstroduce(item, type, position));
+        setDrugInfo: (item) => {
+            dispatch(getInstroduce(item));
         },
         hideTreat: () => {
             dispatch({

+ 87 - 86
src/store/async-actions/treat.js

@@ -41,7 +41,7 @@ export const addDiagnostic = (item) => {
                 "age": emrData.age,
                 "featureType": "8",
                 "diag": diag,
-                "diseaseId":  item.id,
+                "diseaseName":  item.name,
                 "lis": emrData.lis,
                 "other": emrData.other,
                 "pacs": emrData.pacs,
@@ -49,6 +49,9 @@ export const addDiagnostic = (item) => {
                 "symptom": emrData.current + emrData.main,
                 "vital": emrData.vital,
                 "patientId": emrData.patientId,
+                "hosCode": emrData.hosCode,
+                "adverseReactions": "string",
+                "scaleName": "string",
             };
             //判断是否走慢病系统
             const isChronic = state.diagnosticList.chronicMagItem && state.diagnosticList.chronicMagItem.name||state.mainSuit.chronicDesease && state.mainSuit.chronicDesease.name;
@@ -87,7 +90,7 @@ export const addDiagnostic = (item) => {
 function hasTreatment(dispatch, state,item,url, params) {
     json(url, params).then((data) =>{
         if (data.data.data) {
-            item.treat = data.data.data.treat
+            item.treat = data.data.data
             dispatch({
                 type: ADD_DIAGNOSTIC,
                 item: item
@@ -116,10 +119,8 @@ export const getTreatResult = (item) =>{
             treatItem: item
         })
         const state = getState();
-        let url = api.push;
-        if(+state.typeConfig.confirmType===1){
-            url=api.textPush;
-        }
+        let url = api.pushTreatment;
+        
 
         const emrData = getEMRParams();
         const diagnosticList = state.diagnosticList.diagnosticList;
@@ -138,7 +139,7 @@ export const getTreatResult = (item) =>{
             "age": emrData.age,
             "featureType": "8",
             "diag": diag,
-            "diseaseId":  item.id,
+            "diseaseName":  item.name,
             "lis": emrData.lis,
             "other": emrData.other,
             "pacs": emrData.pacs,
@@ -146,6 +147,7 @@ export const getTreatResult = (item) =>{
             "symptom": emrData.current + emrData.main,
             "vital": emrData.vital,
             "patientId": emrData.patientId,
+            "hosCode": emrData.hosCode
         };
         // const params = {
         //         "age": 20,
@@ -194,86 +196,86 @@ export const getTreatResult = (item) =>{
 //获取治疗方案
 function getTreatment(item, dispatch, state,url,params, isChronic) {
     json(url, params).then((data) =>{
-        dispatch({type:MODI_LOADING,flag:false});
-        dispatch({type: SHOW_TREAT})
-        let treat;
-        if(data.data.data) {
-             treat = data.data.data.treat || {}
-        }
-        if(treat) {
-           let { treatment, commonTreatment, surgeryTreatment, drugHistory, adverseReactions, followUp} = 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.id == allAdversReactionList[i].id) {    //判断是否存过不良反应
-                            for (let j = 0; j < adverseReactions.length; j++) { //判断不良反应是否有相同的不良反应,如果有,替换
-                                for(let z = 0; z < allAdversReactionList[i].adversReactionList.length; z++) {
-                                    if(adverseReactions[j].id == allAdversReactionList[i].adversReactionList[z].id) {
-                                        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<chronicList.length; i++){
-                    if(chronicList[i].id==item.id&&chronicList[i].name==item.name){ //判断某个病是否为慢病
-                        followUp = '2周';
-                    }
-                }
-                
+        if(data.data.code == '0') {
+            dispatch({type:MODI_LOADING,flag:false});
+            dispatch({type: SHOW_TREAT})
+            let treat;
+            if(data.data.data) {
+                treat = data.data.data || {}
             }
-            if(followUp) {  
-                const followUpList = state.treat.followUpList
-                if(followUpList) {  //判断之前有没有保存过的回访时间,如果有替换掉
-                    for(let i = 0; i < followUpList.length; i++) {
-                        if(item.id == followUpList[i].id) {
-                            followUp = followUpList[i].followUp
-                        }
-                    }
-                }
-                dispatch({
-                    type: SET_FOLLOW_UP,
-                    // followUp: treat.followUp,
-                    followUp: followUp,
-                    hasFollowUp: true
-                })
-            } else {
+            if(treat) {
+                let { treatment, commonTreatment, surgeryTreatment, drugHistory, adverseReactions, followUp} = treat
                 dispatch({
-                    type: DEL_FOLLOW_UP,
-                    delItem: item,
-                })
+                     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.id == allAdversReactionList[i].id) {    //判断是否存过不良反应
+                                 for (let j = 0; j < adverseReactions.length; j++) { //判断不良反应是否有相同的不良反应,如果有,替换
+                                     for(let z = 0; z < allAdversReactionList[i].adversReactionList.length; z++) {
+                                         if(adverseReactions[j].id == allAdversReactionList[i].adversReactionList[z].id) {
+                                             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<chronicList.length; i++){
+                         if(chronicList[i].id==item.id&&chronicList[i].name==item.name){ //判断某个病是否为慢病
+                             followUp = '2周';
+                         }
+                     }
+                     
+                 }
+                 if(followUp) {  
+                     const followUpList = state.treat.followUpList
+                     if(followUpList) {  //判断之前有没有保存过的回访时间,如果有替换掉
+                         for(let i = 0; i < followUpList.length; i++) {
+                             if(item.id == followUpList[i].id) {
+                                 followUp = followUpList[i].followUp
+                             }
+                         }
+                     }
+                     dispatch({
+                         type: SET_FOLLOW_UP,
+                         // followUp: treat.followUp,
+                         followUp: followUp,
+                         hasFollowUp: true
+                     })
+                 } else {
+                     dispatch({
+                         type: DEL_FOLLOW_UP,
+                         delItem: item,
+                     })
+                 }
+                 dispatch({
+                     type: SET_ADVERSE_REACTIONS,
+                     adversReactionList: adverseReactions
+                 })
             }
-            dispatch({
-                type: SET_ADVERSE_REACTIONS,
-                adversReactionList: adverseReactions
-            })
-           
         }
-        
-}).catch((e) =>{
-    console.log(e)
-})
+    }).catch((e) =>{
+        console.log(e)
+    })
 }
 
 //保存全部不良反应
@@ -312,10 +314,9 @@ export const getInstroduce = (item, type, position)=>{
     return (dispatch, getState) =>{
         const url = '/conceptDetail/getConceptDetail';
         const params = {
-            questionId: item.id,
             name: item.name,
-            type: type,
-            position: position
+            type: item.type,
+            position: item.position
         }
         json(url, params)
         .then((data)=>{