zhangxc il y a 6 ans
Parent
commit
ab1c6dc824

+ 2 - 1
src/components/DiagnosticList/index.jsx

@@ -51,8 +51,9 @@ class DiagnosticList extends Component {
     }
     deleteItem() {
         const { delItem } = this.state;
-        const { delDiagnostic } = this.props;
+        const { delDiagnostic, delReact } = this.props;
         delDiagnostic && delDiagnostic(delItem);
+        delReact && delReact(delItem)
         this.setState({
             visible: false,
         })

+ 2 - 2
src/components/Treat/index.jsx

@@ -67,8 +67,8 @@ class Treat extends Component {
 
                     <div className={style['treat-inner-box']}>
                         <GeneralTreat icon={generalIcon} title='一般治疗'   generalTreat={generalTreat}></GeneralTreat>
-                        <LastTreat icon={generalIcon} title='上次用药情况' lastTreat={lastTreat}  showDrugInfo = {showDrugInfo} setDrugInfo={ setDrugInfo }></LastTreat>
-                        <AdverseReactions icon={generalIcon} title='不良反应' adversReactionList = {adversReactionList} changeReact = {changeReact}></AdverseReactions>
+                        { lastTreat && lastTreat.chronicDisMedica &&lastTreat. chronicDisMedica.length > 0 && lastTreat.commonDisMedica && lastTreat.commonDisMedica.length > 0 &&<LastTreat icon={generalIcon} title='上次用药情况' lastTreat={lastTreat}  showDrugInfo = {showDrugInfo} setDrugInfo={ setDrugInfo }></LastTreat>}
+                        {adversReactionList&&adversReactionList.length>0&&<AdverseReactions icon={generalIcon} title='不良反应' adversReactionList = {adversReactionList} changeReact = {changeReact}></AdverseReactions>}
                         <DrugTreat treatment={ treatment } 
                                 selectDrug={selectDrug} 
                                 setOtherRecommend={ setOtherRecommend } 

+ 7 - 1
src/containers/DiagnosticList.js

@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
 import DiagnosticList from '@components/DiagnosticList';
 import { ADD_DIAGNOSTIC,  DEL_DIAGNOSTIC, UP_DIAGNOSTIC, DOWN_DIAGNOSTIC, GET_DIAGNOSTIC_STR, GET_IS_FIRST, HIDE_REFER_RECORD, SHOW_HISTORY_CASE,HIDE_HISTORY_CASE } from '@store/types/diagnosticList'; 
 import { getTreatResult } from '@store/async-actions/treat';
-import { SHOW_TREAT } from '../store/types/treat';
+import { SHOW_TREAT, DEL_REACT } from '@store/types/treat.js';
 import {billing, getTips} from '../store/async-actions/pushMessage';
 import {keepPushData} from '@store/actions/tabTemplate';
 import { showHistory,sortHistory,activeHistory,visibleHistory } from '@store/actions/historyTemplates'
@@ -35,6 +35,12 @@ function mapDispatchToProps(dispatch) {
                 type: GET_DIAGNOSTIC_STR
             });
         },
+        delReact: (item) => {
+            dispatch({
+                type: DEL_REACT,
+                item: item
+            })
+        },
         upDiagnostic: (index, id) => {
             dispatch({
                 type: UP_DIAGNOSTIC,

+ 2 - 1
src/containers/Treat.js

@@ -1,7 +1,7 @@
 import React from 'react';
 import { connect } from 'react-redux';
 import Treat from '@components/Treat';
-import { SELECT_DRUG, SET_OTHER_DRUG, SET_DRUG_INFO, CLEAR_DRUG_INFO,HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO, CHANGE_REACT, SET_ALL_ADVERSE_REACTIONS } from '@store/types/treat.js';
+import { SELECT_DRUG, SET_OTHER_DRUG, SET_DRUG_INFO, CLEAR_DRUG_INFO,HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO, CHANGE_REACT,  DEL_REACT } from '@store/types/treat.js';
 import { getInstroduce, getRecommendBasic, getInstroduceMore, commonTreatAddToAdvice, saveAllAdverseReactions } from '@store/async-actions/treat';
 import { ADD_SCHEME } from '@store/types/pushMessage.js'
 import { showDrugInfo } from '../store/actions/treat';
@@ -29,6 +29,7 @@ function mapDispatchToProps(dispatch) {
         changeReact: (it, index) => {
             dispatch({type: CHANGE_REACT, it, index})
         },
+      
         selectDrug: (index, ii)=>{
             dispatch ({
                 type: SELECT_DRUG,

+ 15 - 2
src/store/actions/treat.js

@@ -138,9 +138,9 @@ export const setALLAdverseReactions =(state, action) => {
     return res;
 }
 
-
+//改变不良反应选中状态
 export const changeReact=(state,action)=>{
-    const res=Object.assign({},state);
+    const res = JSON.parse(JSON.stringify(state));
     const index = action.index
     res.adversReactionList[index].details = res.adversReactionList[index].details.map(item => {
       if(item.name == action.it.name){
@@ -150,3 +150,16 @@ export const changeReact=(state,action)=>{
     })
     return res;
   };
+
+// 删除该疾病不良反应
+export const delReact = (state, action) => {
+    const res = JSON.parse(JSON.stringify(state));
+    let allAdversReactionList = res.allAdversReactionList
+    for( let i = 0; i < allAdversReactionList.length; i++) {
+        if (action.item.id == allAdversReactionList[i].id) {
+            allAdversReactionList.splice(i, 1)
+        } 
+    }
+    res.allAdversReactionList = allAdversReactionList;
+    return res;
+}

+ 114 - 70
src/store/async-actions/treat.js

@@ -39,7 +39,6 @@ export const addDiagnostic = (item) => {
             const params = {
                 "age": emrData.age,
                 "featureType": "8",
-                "disType": 1,
                 "diag": diag,
                 "diseaseId":  item.id,
                 "lis": emrData.lis,
@@ -49,31 +48,61 @@ export const addDiagnostic = (item) => {
                 "symptom": emrData.current + emrData.main,
                 "vital": emrData.vital
             };
+            //判断是否走慢病系统
+            const isChronic = state.diagnosticList.chronicMagItem && state.diagnosticList.chronicMagItem.name||state.mainSuit.chronicDesease && state.mainSuit.chronicDesease.name;
+            if (isChronic) {
+                let chronicList = JSON.parse(storageLocal.get('chronic'));
+                if(!chronicList){
+                    getChronic().then(() =>{
+                    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){ //判断某个病是否为慢病
+                                params.disType = 1
+                            }
+                        }
+                        hasTreatment(dispatch, state,item,url,params)
 
-            json(url, params).then((data) =>{
-                if (data.data.data) {
-                    item.treat = data.data.data.treat
-                    dispatch({
-                        type: ADD_DIAGNOSTIC,
-                        item: item
-                    })
+                    });
                 } else {
-                    item.treat = null
-                    dispatch({
-                        type: ADD_DIAGNOSTIC,
-                        item: item
-                    })
+                    for(let i=0; i<chronicList.length; i++){
+                        if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
+                            params.disType = 1
+                        }
+                    }
+                    hasTreatment(dispatch, state, item,url,params)
                 }
-                dispatch({
-                    type: GET_DIAGNOSTIC_STR
-                });
-                dispatch(isAddMainSuit())
+            } else {
+                hasTreatment(dispatch, state, item,url,params)
+            }
+            
+            
+        }
 
-            }).catch((e) =>{
-                console.log(e)
+}
+
+function hasTreatment(dispatch, state,item,url, params) {
+    json(url, params).then((data) =>{
+        if (data.data.data) {
+            item.treat = data.data.data.treat
+            dispatch({
+                type: ADD_DIAGNOSTIC,
+                item: item
+            })
+        } else {
+            item.treat = null
+            dispatch({
+                type: ADD_DIAGNOSTIC,
+                item: item
             })
         }
+        dispatch({
+            type: GET_DIAGNOSTIC_STR
+        });
+        dispatch(isAddMainSuit())
 
+    }).catch((e) =>{
+        console.log(e)
+    })
 }
 
 export const getTreatResult = (item) =>{
@@ -89,18 +118,6 @@ export const getTreatResult = (item) =>{
         }
 
         const emrData = getEMRParams();
-        // const params = {
-        //     "age": emrData.age,
-        //     "featureType": "8",
-        //     "dis": emrData.dis,
-        //     "diseaseId": emrData.diseaeId,
-        //     "lis": emrData.lis,
-        //     "other": emrData.other,
-        //     "pacs": emrData.pacs,
-        //     "sex": emrData.sex,
-        //     "symptom": emrData.current||emrData.main,
-        //     "vital": emrData.vital
-        // };
         const diagnosticList = state.diagnosticList.diagnosticList;
         let diag = '';
         if(diagnosticList) {
@@ -118,7 +135,6 @@ export const getTreatResult = (item) =>{
             "featureType": "8",
             "diag": diag,
             "diseaseId":  item.id,
-            "disType": 1,
             "lis": emrData.lis,
             "other": emrData.other,
             "pacs": emrData.pacs,
@@ -139,52 +155,80 @@ export const getTreatResult = (item) =>{
         //         "symptom": "恶心,呕吐",
         //         "vital": ""
         // }
-        
-        json(url, params).then((data) =>{
-                let treat;
-                if(data.data.data) {
-                     treat = data.data.data.treat || {}
+        const isChronic = state.diagnosticList.chronicMagItem && state.diagnosticList.chronicMagItem.name||state.mainSuit.chronicDesease && state.mainSuit.chronicDesease.name;
+        if (isChronic) {
+            let chronicList = JSON.parse(storageLocal.get('chronic'));
+            if(!chronicList){
+                getChronic().then(() =>{
+                    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){
+                            params.disType = 1
+                        }
+                    }
+                    getTreatment(item, dispatch, state, url,params)
+
+                });
+            } else {
+                for(let i=0; i<chronicList.length; i++){
+                    if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
+                        params.disType = 1
+                    }
                 }
-                if(treat) {
-                   let adverseReactions = treat.adverseReactions
-                   dispatch({
-                        type: SET_TREATMENT,
-                        treatment: treat.treatment,
-                        generalTreat: treat.commonTreatment,
-                        surgeryTreat: treat.surgeryTreatment,
-                    })
-                    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) {
-                                                
-                                                adverseReactions[j] = allAdversReactionList[i].adversReactionList[z]
-                                            }
-                                        }
+                getTreatment(item, dispatch, state,url,params)
+            }
+        } else {
+            getTreatment(item, dispatch, state,url,params)
+        }
+        
+    }
+    
+} 
+
+function getTreatment(item, dispatch, state,url,params) {
+    json(url, params).then((data) =>{
+        let treat;
+        if(data.data.data) {
+             treat = data.data.data.treat || {}
+        }
+        if(treat) {
+           let adverseReactions = treat.adverseReactions
+           dispatch({
+                type: SET_TREATMENT,
+                treatment: treat.treatment,
+                generalTreat: treat.commonTreatment,
+                surgeryTreat: treat.surgeryTreatment,
+            })
+            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) {
+                                        
+                                        adverseReactions[j] = allAdversReactionList[i].adversReactionList[z]
                                     }
                                 }
                             }
                         }
-                        
-                    } else {
-                        adverseReactions = []
                     }
-                    dispatch({
-                        type: SET_ADVERSE_REACTIONS,
-                        adversReactionList: adverseReactions
-                    })
                 }
                 
-        }).catch((e) =>{
-            console.log(e)
-        })
-    }
-    
-} 
+            } else {
+                adverseReactions = []
+            }
+            dispatch({
+                type: SET_ADVERSE_REACTIONS,
+                adversReactionList: adverseReactions
+            })
+        }
+        
+}).catch((e) =>{
+    console.log(e)
+})
+}
 
 export const saveAllAdverseReactions = (item) => {
     return (dispatch, getState) => {

+ 24 - 22
src/store/reducers/treat.js

@@ -1,5 +1,5 @@
-import { SELECT_DRUG, SET_TREAT_INFO, SET_OTHER_DRUG, SET_DRUG_INFO, CLEAR_DRUG_INFO,SHOW_TREAT, HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO, SET_GENERAL_TREAT, SET_TREATMENT, SET_SURGERY_TREAT, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST,IS_FIRST_MAIN_DIAG,CLEAR_FIRST_MAIN_DIAG ,SET_ADVERSE_REACTIONS, SET_ALL_ADVERSE_REACTIONS,CHANGE_REACT } from '../types/treat'
-import { selectDrug, setTreatInfo, setOtherDrug, setDrugInfo, clearDrugInfo, showTreat, hideTreat, clearTreat, showDrugInfo, hideDrugInfo, setTreatment, setGeneralTreat, setSurgeryTreat, setRecommendBasic, setDrugInfoList, isFirstMainDiag, clearFirstMainDiag, setAdverseReactions, setALLAdverseReactions, changeReact  } from '../actions/treat'
+import { SELECT_DRUG, SET_TREAT_INFO, SET_OTHER_DRUG, SET_DRUG_INFO, CLEAR_DRUG_INFO,SHOW_TREAT, HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO, SET_GENERAL_TREAT, SET_TREATMENT, SET_SURGERY_TREAT, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST,IS_FIRST_MAIN_DIAG,CLEAR_FIRST_MAIN_DIAG ,SET_ADVERSE_REACTIONS, SET_ALL_ADVERSE_REACTIONS,CHANGE_REACT, DEL_REACT } from '../types/treat'
+import { selectDrug, setTreatInfo, setOtherDrug, setDrugInfo, clearDrugInfo, showTreat, hideTreat, clearTreat, showDrugInfo, hideDrugInfo, setTreatment, setGeneralTreat, setSurgeryTreat, setRecommendBasic, setDrugInfoList, isFirstMainDiag, clearFirstMainDiag, setAdverseReactions, setALLAdverseReactions, changeReact ,delReact } from '../actions/treat'
 const initState = {
     show: false, //治疗方案显示隐藏
     showDrugInfo: false, //药品信息显示隐藏
@@ -69,26 +69,26 @@ const initState = {
     //     }
     // ],
     lastTreat: {
-        commonDisMedica: [
-            {
-                medicitionName: '泮托拉唑',
-                id: 145
-            },
-            {
-                medicitionName: '奥美拉唑',
-                id: 341
-            }
-        ],
-        chronicDisMedica: [
-            {
-                medicitionName: '兰索拉唑',
-                id: 342
-            },
-            {
-                medicitionName: '山莨菪碱',
-                id: 344
-            }
-        ],
+        // commonDisMedica: [
+        //     {
+        //         medicitionName: '泮托拉唑',
+        //         id: 145
+        //     },
+        //     {
+        //         medicitionName: '奥美拉唑',
+        //         id: 341
+        //     }
+        // ],
+        // chronicDisMedica: [
+        //     {
+        //         medicitionName: '兰索拉唑',
+        //         id: 342
+        //     },
+        //     {
+        //         medicitionName: '山莨菪碱',
+        //         id: 344
+        //     }
+        // ],
     },
     adversReactionList:[
         // {
@@ -309,6 +309,8 @@ export default function(state=initState, action){
             return setALLAdverseReactions(state, action);
         case CHANGE_REACT: 
             return changeReact(state, action);
+        case DEL_REACT:
+            return delReact(state, action);
         default:
             return state
     }

+ 1 - 0
src/store/types/treat.js

@@ -18,3 +18,4 @@ export const CLEAR_FIRST_MAIN_DIAG = 'CLEAR_FIRST_MAIN_DIAG' //回读清空是
 export const SET_ADVERSE_REACTIONS = 'SET_ADVERSE_REACTIONS'    //设置不良反应
 export const SET_ALL_ADVERSE_REACTIONS = 'SET_ALL_ADVERSE_REACTIONS'    //设置所有不良反应
 export const CHANGE_REACT = 'CHANGE_REACT'  //改变不良反应状态
+export const DEL_REACT = 'DEL_REACT'  //改变不良反应状态