瀏覽代碼

Merge remote-tracking branch 'origin/dev/otherHis' into dev/new1

# Conflicts:
#	src/components/NumberUnitDrop/index.jsx
zhouna 6 年之前
父節點
當前提交
ff755df436

+ 1 - 0
src/common/components/InlineTag/index.less

@@ -18,6 +18,7 @@
 .free-in{
   display: inline-block;
   min-width: 30px;
+  vertical-align: top;
   /*border-bottom: 1px @placeholder-color solid;*/
   outline: none;
 }

+ 29 - 5
src/components/CheckBody/index.jsx

@@ -3,8 +3,11 @@ import style from './index.less';
 import {Button,InlineTag,ItemBox,EditableSpan,Notify} from '@commonComp';
 import chooseType from '@containers/eleType.js';
 import SearchDrop from '@components/SearchDrop';
-import {getPageCoordinate,windowEventHandler,isIE} from '@utils/tools';
+import {getPageCoordinate,windowEventHandler,isIE,filterDataArr} from '@utils/tools';
 import $ from "jquery";
+import showImg from "../../common/images/show.png";
+import hideImg from "../../common/images/close.png";
+import config from '@config/index';
 
 class CheckBody extends Component{
   constructor(props){
@@ -15,10 +18,12 @@ class CheckBody extends Component{
       boxTop:0,
       tmpScroll:0,
       tmpTop:0,
+      showAll:false
     };
     this.handleClick = this.handleClick.bind(this);
     this.handleSearchSelect = this.handleSearchSelect.bind(this);
     this.getData = this.getData.bind(this);
+    this.showHide = this.showHide.bind(this);
     //this.handleInput = this.handleInput.bind(this);
   }
   componentWillReceiveProps(nextProps){
@@ -27,9 +32,10 @@ class CheckBody extends Component{
   getLabels(){
     const {data,showArr,saveText,selecteds} = this.props;
     let arr = [],list=[];
-    const {boxMark} = this.state;
-    if(data){
-      list = data;
+    const {boxMark,showAll} = this.state;
+    const showData = showAll?[...data]:[...data].splice(0,config.showCheckNum*2+1);
+    if(showData){
+      list = showData;
       arr = list.map((it,i)=>{
         return chooseType({item:it,boxMark,i,showArr,saveText,selecteds});
       });
@@ -85,11 +91,29 @@ class CheckBody extends Component{
       this.props.getInit();
     }
   }
+  showHide(){
+    this.setState({
+      showAll:!this.state.showAll
+    });
+  }
+  componentWillUpdate(next){
+    if(!this.props.isEmpty&&next.isEmpty){
+      this.setState({
+        showAll:false
+      })
+    }
+  }
   render(){
-    const {searchData,totalHide,data,boxLeft,boxTop} = this.props;
+    const {searchData,totalHide,data,boxLeft,boxTop,saveText} = this.props;
+    const {showAll} = this.state;
+    const moreNum =config.showCheckNum*2+1;
+    const moreText = filterDataArr([...saveText].splice(moreNum));
+    const more = showAll?<span className={style['more']} onClick={this.showHide}>收起<img src={hideImg} /></span>:<span className={style['more']} onClick={this.showHide}>展开<img src={showImg} /></span>;
+    const showMoreBtn = data.length>moreNum&&!moreText;
     return  <div className={style['container']}>
       <ItemBox title='查体' handleClick={this.handleClick}>
         {this.getLabels()}
+        {showMoreBtn?more:''}
         {searchData && searchData.length>0?<SearchDrop data={searchData} show={!totalHide} left={boxLeft} top={boxTop} onSelect={this.handleSearchSelect}></SearchDrop>:''}
       </ItemBox>
     </div>

+ 14 - 0
src/components/CheckBody/index.less

@@ -0,0 +1,14 @@
+@import "~@less/variables.less";
+.more{
+  color:@blue;
+  font-size: 12px;
+  cursor: pointer;
+  white-space: nowrap;
+  /*float: right;*/
+  position: absolute;
+  right: 0;
+  img{
+    vertical-align: text-top;
+    width: 15px;
+  }
+}

+ 10 - 8
src/components/MultSpread/index.jsx

@@ -46,9 +46,10 @@ class MultSpread extends Component{
     const list = data.map((it,i)=>{
       inx=ikey+''+i;
       show = editable?false:showArr&&showArr[inx];
-      switch (+it.controlType){
-        case 0:
-        case 1:
+      switch (true){
+        case +it.tagType===8:
+          return it.name;
+        case +it.controlType===1:
           const list = it.questionDetailList&&it.questionDetailList.length>0?it.questionDetailList:it.questionMapping;
           return <RadioDrop data={list}
                             prefix={it.labelPrefix}
@@ -60,7 +61,7 @@ class MultSpread extends Component{
                             id={it.id}
                             patId = {copyId}
                             hideTag={true}></RadioDrop>;
-        case 5://带单位数字键盘
+        case +it.controlType===5://带单位数字键盘
         return <NumberUnitDrop prefix={it.labelPrefix}
                                suffix={it.labelSuffix}
                                placeholder={it.name}
@@ -70,26 +71,27 @@ class MultSpread extends Component{
                                ikey={inx}
                                value={it.value}
                                hideTag={true}></NumberUnitDrop>;
-        case 3:
-        case 6:
+        case +it.controlType===3:
+        case +it.controlType===6:
           return <InlineTag prefix={it.labelPrefix}
                             suffix={it.labelSuffix}
                             placeholder={it.name}
                             value={it.value}
                             id={it.id}
                             ikey={inx} hideTag={true}></InlineTag>;
-        case 7:
+        case +it.controlType===7:
           return <NumberDrop prefix={it.labelPrefix}
                              suffix={it.labelSuffix}
                              placeholder={it.name}
                              show={show}
+                             allClick={false}
                              ikey={inx}
                              id={it.id}
                              patId = {copyId}
                              value={it.value}
                              hideTag={true}></NumberDrop>;
         default:
-          return '';
+          return it.name;
       }
     });
     return list;

+ 51 - 15
src/components/NumberDrop/index.jsx

@@ -11,6 +11,7 @@ import {handleEnter,getPageCoordinate} from '@utils/tools.js';
  * placeholder:灰显文字
  * handleSelect: 选中事件
  * show: 是否显示下拉
+ * allClick:是否前后缀也可唤出数字键盘
  *
  * ***/
 class NumberDrop extends Component{
@@ -23,7 +24,8 @@ class NumberDrop extends Component{
       boxLeft:0,
       boxTop:0,
       tmpTop:0,
-      tmpScroll:0
+      tmpScroll:0,
+      placeholder:props.placeholder
     };
     this.$span = React.createRef();
     this.$pre = React.createRef();
@@ -36,6 +38,7 @@ class NumberDrop extends Component{
     this.handleNumFocus = this.handleNumFocus.bind(this);
     this.handleBlur = this.handleBlur.bind(this);
     this.changeToEdit = this.changeToEdit.bind(this);
+    this.handleKeyDowm = this.handleKeyDowm.bind(this);
   }
   select(text){        //选中键盘上数字事件
     const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
@@ -45,10 +48,19 @@ class NumberDrop extends Component{
     handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
   }
   handleNumFocus(e){       //数字框可编辑状态下聚集事件,处理是否显示下拉等
+    const {placeholder} = this.state;
+    const val = e.target.innerText.trim();
+    //console.log(33,e.target.innerText,placeholder,e.target.innerText.trim() == placeholder)
+    if(val!=''&&val == placeholder){
+      this.setState({
+        placeholder:''
+      });
+    }
     e.stopPropagation();
   }
-  handleNumClick(e){      //数字框不可编辑的状态时点击事件,点击将数字框变为可输入且下拉不再显示直到失焦后再次聚集
+  handleNumClick(e){     //数字框不可编辑的状态时点击事件,点击将数字框变为可输入且下拉不再显示直到失焦后再次聚集
     const {show,handleShow,ikey,id,patId,handleHide,value} = this.props;
+    this.$span.current.focus();
     if(show) {
       handleHide && handleHide();
       return;
@@ -81,16 +93,22 @@ class NumberDrop extends Component{
   }
   numInpBlur(e){        //数字框失焦,保存值到store中
     e.stopPropagation();
+    if(!e.target.innerText.trim()){
+      this.setState({
+        placeholder:this.props.placeholder
+      });
+    }
     if(this.props.show){      //修改清空后第一次点击键盘不触发click事件bug
       return;
     }
     this.setState({
       hasSelect:false
     });
-    const val = e.target.innerText?e.target.innerText.replace(/^\s*/,''):e.target.innerHTML.replace(/^\s*/,'');
-    const {handleSelect,ikey,suffix,prefix,mainSaveText,placeholder} = this.props;
+    const val = e.target.innerText.replace(/^\s*/,'');
+    const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
+    const {placeholder} = this.state;
     const text = val===placeholder?'':val;
-    e.target.innerText? (e.target.innerText = ''):(e.target.innerHTML='');      //避免出现重复输入值
+    e.target.innerText = '';      //避免出现重复输入值
     handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
   }
   handleSpanInp(e){   //数字框输入事件
@@ -98,10 +116,22 @@ class NumberDrop extends Component{
     const {handleHide} = this.props;
     handleHide&&handleHide();
   }
+  handleKeyDowm(e){
+    handleEnter();
+    //只能输入数字
+    const key = e.key;
+    const ctrlOn = e.ctrlKey;
+    const isCopyPaste = ctrlOn&&(key=='v'||key=='c');
+    if(!/[0-9|.|~|\/]/.test(key)&&key.length==1&&!isCopyPaste){
+      e.preventDefault();
+      return false;
+    }
+  }
   getClasses(){         //整个标签是否有值的状态
-    const {value,hideTag,placeholder} = this.props;
+    const {hideTag,placeholder,value} = this.props;
+    const val = this.$span.current&&this.$span.current.innerText.trim()||value;
     const blueBorder = this.state.editable?style['blue-border']:'';
-    const isSelected = value&&value!=placeholder?style['selected']:style['container'];
+    const isSelected = val&&val!=placeholder?style['selected']:style['container'];
     const noTag = hideTag?style['no-tag']:'';
     return className(isSelected,noTag,blueBorder);
   }
@@ -129,10 +159,10 @@ class NumberDrop extends Component{
     this.setState({
       editable: false
     });
-    let totalVal = e.target.innerText || e.target.innerHTML;
-    let changeVal = this.$span.current.innerText?this.$span.current.innerText.replace(/^\s*/,''):this.$span.current.innerHTML.replace(/^\s*/,'');//数字框值-修改后;去掉前空格避免多空格叠加
-    let prefix = this.$pre.current.innerText?this.$pre.current.innerText.replace(/^\s*/,''):this.$pre.current.innerHTML.replace(/^\s*/,''); //前缀值-修改后
-    let suffix = this.$suf.current.innerText?this.$suf.current.innerText.replace(/^\s*/,''):this.$suf.current.innerHTML.replace(/^\s*/,''); //后缀值-修改后
+    let totalVal = e.target.innerText;
+    let changeVal = this.$span.current.innerText.replace(/^\s*/,'');//数字框值-修改后;去掉前空格避免多空格叠加
+    let prefix = this.$pre.current.innerText.replace(/^\s*/,''); //前缀值-修改后
+    let suffix = this.$suf.current.innerText.replace(/^\s*/,''); //后缀值-修改后
     //console.log('数字框:'+changeVal,";全部:"+totalVal,";前缀:"+prefix+";后缀:"+suffix);
     handleLabelChange && handleLabelChange({ikey,changeVal,type:boxMark,totalVal,prefix,suffix});
   }
@@ -141,25 +171,31 @@ class NumberDrop extends Component{
     const cls = this.props.show?style['blued']:'';
     return cls;
   }
+  componentDidMount(){
+    //设置最小宽度避免输入后宽度跳动
+    const spanWidth = window.getComputedStyle(this.$span.current).width;
+    this.$span.current.style.minWidth=spanWidth;
+  }
   render(){
-    const {placeholder,prefix,suffix,show,value,handleHide} = this.props;
-    const {numEditable,editable,hasSelect,boxTop,boxLeft} = this.state;
+    const {prefix,suffix,show,value,handleHide,allClick} = this.props;
+    const {numEditable,placeholder,editable,hasSelect,boxTop,boxLeft} = this.state;
     return <div className={this.getClasses()}
                 ref={this.$cont}
                 onDoubleClick={this.changeToEdit}
+                onClick={allClick?this.handleNumClick:null}
                 contentEditable={editable}
                 onBlur={this.handleBlur}
                 onkeydown={handleEnter}>
       <span ref = {this.$pre}>&nbsp;{prefix}</span>
       <span onFocus={this.handleNumFocus}
-            onClick={this.handleNumClick}
+            onClick={allClick?null:this.handleNumClick}
             contentEditable={true}
             style={{minWidth:'10px',display:'inline-block'}}
             ref = {this.$span}
             onBlur={this.numInpBlur}
             onInput={this.handleSpanInp}
             className={this.getSpanClass()}
-            onkeydown={handleEnter}>&nbsp;{value||placeholder}</span>
+            onkeydown={this.handleKeyDowm}>&nbsp;{value||placeholder}</span>
       <span ref = {this.$suf}>&nbsp;{suffix}</span>
       <NumberPan handleSelect={(text)=>this.select(text)}
                  onClose={handleHide}

+ 0 - 2
src/components/OtherHistory/index.jsx

@@ -40,13 +40,11 @@ class OtherHistory extends Component{
   getData(){
     //第一次聚焦其他史时,主诉有数据则获取最近一次其他史记录(没有的话显示初始模板),主诉无数据则显示提示;其他时间其他史模板数据不调接口
     const {hasMain,type,setInitData,isEmpty} = this.props;
-    console.log(isEmpty)
     //无主诉提示在EditableSpan里
     //智能模式有主诉或者文本模式获取最近历史
     if((+type===0&&hasMain&&isEmpty!=false)||(+type===1&&isEmpty!=false)){
       setInitData();
     }
-
   }
   handleClick(e){//让搜索框跟随鼠标点击移动
     //e.stopPropagation();

+ 19 - 5
src/components/PreviewBody/index.jsx

@@ -1,6 +1,6 @@
 import React, { Component } from "react";
 import style from "./index.less";
-import { normalVal, filterDataArr,timestampToTime } from '@utils/tools';
+import { normalVal, filterDataArr, filterOtherDataArr,timestampToTime } from '@utils/tools';
 import Notify from '@commonComp/Notify';
 import $ from "jquery";
 
@@ -128,7 +128,7 @@ class PreviewBody extends Component {
       return <td style={{ width: '16%', fontSize: '12px' }}><span style={{ color: (val.value - 0).toString() == 'NaN' ? "red" : (val.maxValue || val.minValue) ? (val.value > val.maxValue || val.value < val.minValue ? "red" : null) : null }}>{val.value}</span> {val.labelSuffix}</td>
     }
   }
-  
+
   toTime(time){
     let tmpTim = time.split(',').join('')-0
     if(time && tmpTim.toString() != 'NaN'){
@@ -143,8 +143,8 @@ class PreviewBody extends Component {
   }
   render() {
     const { show, preInfo, dataJson, dataStr, baseObj, flg } = this.props;
-
-    return <div className={style['content']} style={{ width: flg ? '700' : '820' }}>
+    const other_yjs = filterOtherDataArr(JSON.parse(dataStr.other),dataJson.other);
+    return <div className={style['content']} style={{ width: flg ? '700' : '820' }}>1<sup><u>1</u></sup><sub>2</sub>
       <div className={style['contents']} id="content" style={{ margin: "0 auto", maxWidth: "600px" }}>
         <div ref={this.$content} style={{ clear: 'both', fontSize: '24px', margin: '0px 0px 30px 0px', textAlign: 'center' }}>{preInfo.hospitalName}</div>
         <table className={style['patInfo']} style={{ margin: '0px 0px 30px 0px', borderCollapse: 'collapse', width: "100%" }}>
@@ -182,7 +182,21 @@ class PreviewBody extends Component {
             <td style={{ textAlign: 'right', padding: '9px 5px 8px 0px', fontSize: '14px',width:'70px' }}>其他史:</td>
             <td style={{ fontSize: '14px', padding: '9px 0px 8px 0px', lineHeight: '20px',wordBreak:"break-word" }}>
               {
-                filterDataArr(JSON.parse(dataStr.other))
+                other_yjs.str1
+              }
+              {dataJson['yjs_1']||dataJson['yjs_2']||dataJson['yjs_3']||dataJson['yjs_4']?<table style={{textAlign:'center',verticalAlign: 'middle',display:'inline-block'}}>
+                <tr>
+                  <td rowSpan='2' style={{verticalAlign: 'middle'}}>月经史:(</td>
+                  <td rowSpan='2' style={{verticalAlign: 'middle'}}>{dataJson['yjs_1']||'初潮年龄'}</td>
+                  <td style={{borderBottom:'1px solid #000'}}>{dataJson['yjs_2']||'行经天数'}</td>
+                  <td rowSpan='2' style={{verticalAlign: 'middle'}}>{dataJson['yjs_4']||'停经时间'})</td>
+                </tr>
+                <tr>
+                  <td style={{textAlign:'center'}}>{dataJson['yjs_3']||'周期'}</td>
+                </tr>
+              </table>:''}
+              {
+                other_yjs.str2
               }
             </td>
           </tr>

+ 1 - 0
src/config/index.js

@@ -42,5 +42,6 @@ export default {
       year:"年",
       age:"岁",
     },
+    showCheckNum:16,        //查体默认展开非自由文本标签的个数
     Params
 };

+ 10 - 7
src/containers/OtherHistory.js

@@ -38,13 +38,16 @@ function mapDispatchToProps(dispatch,store){
     setInitData(){
       //先获取最近记录,没有的话显示模板
       dispatch((dispatch,getStore)=>{
-        const initData = getStore().homePage.initData;
-        const model = JSON.parse(JSON.stringify(initData.otherHisModel));
-        const arr = JSON.parse(JSON.stringify(initData.otherHis||null));
-        const arrSave = JSON.parse(JSON.stringify(initData.otherHisSave||null));
-        const selects = JSON.parse(JSON.stringify(initData.otherSelecteds||null));
-        const isHis = initData.otherIsHis;
-        const listObj = isHis?{newArr:arr,saveText:arrSave||[]}:fullfillText(model);
+        const state = getStore();
+        const initData = state.homePage.initData;
+        const mode = state.typeConfig.typeConfig;
+        const model = JSON.parse(JSON.stringify(initData.otherHisModel));     //查体模板
+        const arr = JSON.parse(JSON.stringify(initData.otherHis||null));        //最近其他史数据
+        const arrSave = JSON.parse(JSON.stringify(initData.otherHisSave||null));    //最近其他史saveText
+        const selects = JSON.parse(JSON.stringify(initData.otherSelecteds||null));  //其他史杂音类选中项
+        const isHis = initData.otherIsHis;     //是否是历史数据
+        const onlyOneText = arr.length==1&&arr[0].tagType==8&&!(arr[0].name||arr[0].value);    //是否只有一个自由文本标签
+        const listObj = isHis&&(mode==1||(!onlyOneText&&mode==0))?{newArr:arr,saveText:arrSave||[]}:fullfillText(model);
         dispatch({
           type:SETDATA,
           data:listObj.newArr,

+ 2 - 0
src/containers/eleType.js

@@ -57,6 +57,7 @@ export function singleRadio(params){
       return <NumberUnitDrop prefix={data.labelPrefix}
                          suffix={data.labelSuffix}
                          placeholder={data.name}
+                         formulaCode={data.formulaCode}
                          boxMark={boxMark}
                          id={data.id}
                          show={showArr&&showArr[showInx]}
@@ -76,6 +77,7 @@ export function singleRadio(params){
                          placeholder={data.name}
                          boxMark={boxMark}
                          id={data.id}
+                         allClick={true}
                          show={showArr&&showArr[showInx]}
                          ikey={showInx}
                          value={data.value}

+ 9 - 2
src/store/actions/otherHistory.js

@@ -105,6 +105,7 @@ export function setNumberValue(state,action){
   let res = Object.assign({},state);
   const param = action.params;
   const ikey = param.ikey;
+  const code = param.formulaCode;
   let labelInx = getLabelIndex(ikey);
   const subInx = ikey.substr(ikey.length-1);
   let item = res.data[labelInx];
@@ -122,6 +123,7 @@ export function setNumberValue(state,action){
     });
     res.saveText[labelInx] = hasValue?sub.join(''):'';
   }
+  res[code] = param.text;
   res.update = Math.random();
   return res;
 }
@@ -276,11 +278,16 @@ export const changeNumLabelVal = (state,action)=>{
 
 export function clearOtherHistory(state,action){       //清空数据
   let res = Object.assign({},state);
-  res.data = action.data;
+  for(let it in action){
+    if(it!='type'){
+      res[it] = action[it];
+    }
+  }
+  /*res.data = action.data;
   res.saveText = action.saveText;
   res.selecteds = action.selecteds;
   res.editClear = action.editClear;
-  res.isEmpty = action.isEmpty;
+  res.isEmpty = action.isEmpty;*/
   return res;
 }
 //文本模式下值保存

+ 65 - 10
src/utils/tools.js

@@ -8,6 +8,7 @@ import {clearAllLabel} from '@store/actions/inspect';
 import {CLEAR_ALL_DIAG} from '@store/types/diagnosticList';
 import {CLEAR_ALL_PUSH_MESSAGE, SET_TIPS} from '@store/types/pushMessage';
 import {ISREAD, SETREADDITEMS} from "../store/types/homePage";
+import {tabChange} from '@store/actions/tabTemplate';
 import config from '@config/index.js';
 
 /***
@@ -161,11 +162,17 @@ const getUrlArgObject = (parm) => {
 } 
 const getAllDataList =(baseList) =>{           //获取所有模块结构化的数据
     let jsonData = {};
+    //月经史公式
+    const other = baseList.otherHistory;
     jsonData.lis = {};
     jsonData.chief = baseList.mainSuit.data;      //主诉
     jsonData.present = baseList.currentIll.data;    //现病史
-    jsonData.other = baseList.otherHistory.data;      //其他史
-    jsonData.otherHistoryIsEmpty = baseList.otherHistory.isEmpty;
+    jsonData.other = other.data;      //其他史
+    jsonData.otherHistoryIsEmpty = other.isEmpty;
+    jsonData['yjs_1'] = other['yjs_1'];
+    jsonData['yjs_2'] = other['yjs_2'];
+    jsonData['yjs_3'] = other['yjs_3'];
+    jsonData['yjs_4'] = other['yjs_4'];
     jsonData.vital = baseList.checkBody.data;    //查体
     jsonData.checkBodyIsEmpty = baseList.checkBody.isEmpty;
     jsonData.lis.labelList = baseList.inspect.labelList;      //化验
@@ -257,9 +264,12 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
        // Notify.success('页面已清空')
     }else{
         if (whichSign == 0) {
+          let dataJson = JSON.parse(reData.dataJson);
+          //其他史data
+          const oData = dataJson.other;
+          const onlyOneText = oData.length==1&&oData[0].tagType==8&&!(oData[0].name||oData[0].value);
             if(type == 'template'){        //结构化模板回读
-                let dataJson = JSON.parse(reData.dataJson);
-                let dataJsonStr = JSON.parse(reData.preview);
+              let dataJsonStr = JSON.parse(reData.preview);
                 // console.log(dataJson,dataJsonStr,'结构化模板引用')
                 store.dispatch({
                     type: CLEAR_MAIN_SUIT,
@@ -278,8 +288,12 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
                 store.dispatch({
                     type: CLEAROTHERHISTORY,
                     data:dataJson.other,
+                    yjs_1:dataJson.yjs_1,
+                    yjs_2:dataJson.yjs_2,
+                    yjs_3:dataJson.yjs_3,
+                    yjs_4:dataJson.yjs_4,
                     selecteds:dataJson.otherHistorySelecteds?dataJson.otherHistorySelecteds:[],
-                    isEmpty:dataJson.otherHistoryIsEmpty,
+                    isEmpty:onlyOneText?true:false,//dataJson.otherHistoryIsEmpty,
                     saveText:JSON.parse(dataJsonStr.other),
                     editClear:dataJson.other.length>0?false:true
                 });
@@ -311,10 +325,12 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
                   type:SETREADDITEMS,
                   data:dataJson.addItems
                 });
+              //tab跳回辅助信息
+              store.dispatch(tabChange('0'));
             }else{    //结构化历史病历回读
-                let dataJson = JSON.parse(reData.dataJson);
+                /*let dataJson = JSON.parse(reData.dataJson);*/
                 let dataJsonStr = reData.detailList;
-                // console.log(dataJson.chief,dataJsonStr[0].content,'结构化历史病历回读')
+              // console.log(dataJson,dataJsonStr,'结构化历史病历回读')
                 // console.log(dataJson.mainSuitSelecteds,7887)
                 store.dispatch({
                     type: CLEAR_MAIN_SUIT,
@@ -333,9 +349,13 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
                 store.dispatch({
                     type: CLEAROTHERHISTORY,
                     data:dataJson.other,
+                    yjs_1:dataJson.yjs_1,
+                    yjs_2:dataJson.yjs_2,
+                    yjs_3:dataJson.yjs_3,
+                    yjs_4:dataJson.yjs_4,
                     selecteds:dataJson.otherHistorySelecteds?dataJson.otherHistorySelecteds:[],
                     saveText:dataJsonStr[2].content ? JSON.parse(dataJsonStr[2].content):[],
-                    isEmpty:dataJson.otherHistoryIsEmpty,
+                    isEmpty:onlyOneText?true:false,//dataJson.otherHistoryIsEmpty,回读回来后判断是否只有一个空标签,是的话要使用模板
                     editClear:dataJson.other.length>0?false:true
                 });
                 store.dispatch({
@@ -418,6 +438,8 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
                 type:SETREADDITEMS,
                 data:dataJson.addItems
               });
+              //tab跳回辅助信息
+              store.dispatch(tabChange('0'));
             }else{  //纯文本历史病历回读
                 let dataJson = JSON.parse(reData.dataJson);
                 let dataJsonStr = reData.detailList;
@@ -499,10 +521,42 @@ function filterDataArr(arrTmp){   //数据处理
       });
     });
 
-    return tmpArr.join('').replace(config.punReg,function(word){
+    return trimDots(tmpArr.join(''));      //去掉开头的标点符号,最后的标点保留第一个,中间连续的保留第一个
+}
+//其他史预览数据处理-月经史
+function filterOtherDataArr(arrTmp,jsonArr){
+  let tmpArr = [];
+  let index1 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_1';
+  });
+  let index2 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_2';
+  });
+  let index3 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_3';
+  });
+  let index4 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_4';
+  });
+  tmpArr = arrTmp.map((it,i)=>{     //连续的标点符号保留第一个
+    if(!it.match(config.punctuationReg)&&!arrTmp[i-1]||[index1,index2,index3,index4].includes(i)){        //只有标点符号或者前一个标签无值是(说明本标点灰显,不显示在预览中)
+      return '';
+    }
+    return it.replace(config.punReg,function(word){
       return word.substr(0,1);
-    }).replace(/^[,,.。::"“??”;;、!!]+/,'');      //去掉开头的标点符号,最后的标点保留第一个,中间连续的保留第一个
+    });
+  });
+  const str1 = [...tmpArr].splice(0,index1).join("");
+  const str2 = [...tmpArr].splice(index1).join("");
+  return {str1:trimDots(str1),str2:trimDots(str2),index:index1};
+}
+//去掉开头的标点符号,最后的标点保留第一个,中间连续的保留第一个
+function trimDots(str){
+  return str.replace(config.punReg,function(word){
+    return word.substr(0,1);
+  }).replace(/^[,,.。::"“??”;;、!!]+/,'');
 }
+
 // 取消默认行为
 function preventDefault(event) {
     if (event.preventDefault) {
@@ -653,6 +707,7 @@ module.exports = {
     pushAllDataList,
     filterArr,
     filterDataArr,
+    filterOtherDataArr,
     preventDefault,
     handleEnter,
     didPushParamChange,

+ 119 - 78
static/pages/diag_push.html

@@ -32,15 +32,19 @@
         tr{
             height: 30px;
         }
+        td{
+            vertical-align: top;
+        }
         .container label{
             display: inline-block;
             width: 80px;
             margin-left: 5px;
         }
-        .container a{
+        a{
             margin-right: 10px;
             color: blue;
             cursor: default;
+            cursor: pointer;
             text-decoration: underline;
         }
         a.info{
@@ -55,29 +59,6 @@
             text-decoration: none;
             margin-left: 3px;
         }
-
-        .origin td[rowspan="5"]{
-            width: 45px;
-            /*background: #deecfd;*/
-        }
-        .origin td:first-child{
-            border-right: 1px #828790 solid;
-            word-break: break-all;
-        }
-        .origin span{
-            float: left;
-        }
-        td:last-child{
-           /* width:560px;*/
-        }
-        .origin span:first-child{
-            margin-left:5px;
-        }
-        .origin .little{
-            font-size: 10px;
-            line-height: 12px;
-            margin-left: 5px;
-        }
         .hide{
             display: none!important;
         }
@@ -93,7 +74,9 @@
             border-radius: 3px;
             cursor: pointer;
         }
-
+        .item-box{
+            display: none;
+        }
         .clearfix{
             zoom: 1;
         }
@@ -104,60 +87,118 @@
             overflow: hidden;
             visibility: hidden;
         }
+        .vertical,.horizontal{
+            display: none;
+        }
+        .vertical .item-box{
+            margin-top:20px;
+        }
+        .vertical .title{
+            font-size: 14px;
+        }
+        .vertical .item-title{
+            font-weight: bold;
+            font-size: 14px;
+            line-height: 30px;
+            border-bottom: 1px #ccc solid;
+        }
+        .vertical .item-content{
+            font-size: 13px;
+            line-height: 30px;
+
+        }
     </style>
 </head>
 <body>
-    <table class="container" cellspacing="0">
-        <tbody>
-        <tr class="origin">
-            <td rowspan="5">
-                <div class="clearfix">
-                    <span>智<br/>能<br/>推<br/>送</span>
-                    <span class="little">︵<br/>仅<br/>供<br/>参<br/>考<br/>︶</span>
-                </div>
-            </td>
-            <td>
-                <label>>初步诊断:</label>
-            </td>
-            <td class="main-suit">
-            </td>
-        </tr>
-        <tr class="test">
-            <td>
-                <label>>建议化验:</label>
-            </td>
-            <td>
-                <div class="test-item item">
-                </div>
-            </td>
-        </tr>
-        <tr class="suggest">
-            <td>
-                <label>>建议辅检:</label>
-            </td>
-            <td>
-                <div class="sug-item item">
-                </div>
-            </td>
-        </tr>
-        <tr class="treat">
-            <td>
-                <label>>治疗建议:</label>
-            </td>
-            <td>
-                <div class="treatment item">
-                </div>
-            </td>
-        </tr>
-        <tr>
-            <td></td>
-            <td>
-                <p></p>
-            </td>
-        </tr>
-        </tbody>
-    </table>
-
-    <script src="./hisLib/jquery-1.9.1.min.js"></script>
-    <script  src="./hisLib/diag_push.js"></script>
+<table class="container horizontal" cellspacing="0">
+    <tbody>
+    <tr class="item-box box1">
+        <td rowspan="7">
+            <div class="clearfix">
+                <span>智<br/>能<br/>推<br/>送</span>
+                <span class="little">︵<br/>仅<br/>供<br/>参<br/>考<br/>︶</span>
+            </div>
+        </td>
+        <td>
+            <label>>伴随症状:</label>
+        </td>
+        <td class="item-content">
+        </td>
+    </tr>
+    <tr class="item-box box4">
+        <td>
+            <label>>查&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;体:</label>
+        </td>
+        <td>
+            <div class="item-content">
+            </div>
+        </td>
+    </tr>
+    <tr class="item-box box7">
+        <td>
+            <label>>初步诊断:</label>
+        </td>
+        <td>
+            <div class="item-content">
+            </div>
+        </td>
+    </tr>
+    <tr class="item-box box5">
+        <td>
+            <label>>建议化验:</label>
+        </td>
+        <td>
+            <div class="item-content">
+            </div>
+        </td>
+    </tr>
+    <tr class="item-box box6">
+        <td>
+            <label>>建议辅检:</label>
+        </td>
+        <td>
+            <div class="item-content">
+            </div>
+        </td>
+    </tr>
+    <tr class="item-box box">
+        <td style="vertical-align: text-bottom;">
+            <label>>治疗建议:</label>
+        </td>
+        <td>
+            <div class="item-content box">
+            </div>
+        </td>
+    </tr>
+    </tbody>
+</table>
+<div class="vertical">
+    <div class="title">智能推送(仅供参考)</div>
+    <div class="item-box box1">
+        <div class="item-title">伴随症状</div>
+        <div class="item-content"></div>
+    </div>
+    <div class="item-box box4">
+        <div class="item-title">查体</div>
+        <div class="item-content"></div>
+    </div>
+    <div class="item-box box7">
+        <div class="item-title">初步诊断</div>
+        <div class="item-content"></div>
+    </div>
+    <div class="item-box box5">
+        <div class="item-title">建议化验</div>
+        <div class="item-content"></div>
+    </div>
+    <div class="item-box box6">
+        <div class="item-title">建议辅检</div>
+        <div class="item-content"></div>
+    </div>
+    <div class="item-box box">
+        <div class="item-title">治疗建议</div>
+        <div class="item-content"></div>
+    </div>
+</div>
+<script src="./hisLib/jquery-1.3.1.js"></script>
+<script  src="./hisLib/diag_push.js"></script>
 </body>

+ 105 - 222
static/pages/hisLib/diag_push.js

@@ -1,228 +1,111 @@
 (function ($) {
-        var urls = {
-            url:{
-                'host':"/icss-web",
-                'start_drug': '/rule_controller/start_drug_title',
-                //His推送接口
-                'get_push_data':'/kl/diseaseinfo/get_data',
-                'recovery_index': '/at/inquiry_info/recover',
-                'get_patient_from_his': '/at/patientinfo/get_patient_from_his'
-            }
-        };
-        var urlSearch = parseUrl();
-        var isRecover = urlSearch.recover;
-        if(isRecover){
-            getRecover();
-        }else{
-            getPushData();
-        }
-        function parseUrl() {
-            var r = window.location.search.substr(1).split("&"),
-                obj = {};
-            $.each(r, function (i, v) {
-                if (v) {
-                    var arr = v.split("=");
-                    obj[arr[0]] = encodeURI(arr[1]);
-                }
-            });
-            return obj;
-        };
-        function getPushData(){
-            var url = urls.url.host + urls.url.get_push_data;
-            var code = urlSearch.diagnosis;
-            var hospitalCode = urlSearch.hospitalCode;
-            ajaxJsonGet(url,{code:code,hospitalCode:hospitalCode},function(response){
-                var data = response.data;
-                if(response.status=='OK'){
-                    fillPushData(data);
-                }
-            });
-        }
-        //获取历史数据
-        function getRecover(){
-            var patientNo = urlSearch.patientId;
-            var recordId = urlSearch.recordId;
-            var hospitalCode = urlSearch.hospitalId;//urls.url.host
-            var url =  urls.url.host + urls.url.recovery_index;
-            var pUrl = urls.url.host + urls.url.get_patient_from_his;
-            ajaxJsonGet(pUrl,{hospitalCode:hospitalCode,hisCode:patientNo},function(response){
-                var data = response.data;
-                if(data){
-                    $.get(url,{patientId:data.id,hospitalCode:hospitalCode,hisCode:recordId},function(response){
-                        var data = response.data;
-                        if(response.status=='OK'){
-                            parseRecoverData(data);
-                        }
-                    });
-                }else{
-                    console.warn("获取患者信息为空");
-                }
-            });
-
-        }
+  var urls = {
+    'host':"/icss-web",
+    //His推送接口
+    'get_push':'http://192.168.2.234:5008/push-web/algorithm/neural'
+  };
+  $.support.cors = true;
+  var config = {
+    width:'560px',      //推送内容显示的宽度
+    num:'11',         //每行显示的最大个数
+    mode:'horizontal',  //布局模式水平horizontal,垂直vertical,
+    models:[5,6,7]       //需要显示的推送模块,主诉-诊断1-7
+  };
+  var urlSearch = parseUrl();
+  handleConfig();
+  getPushData();
 
-        //解析recover数据
-        function parseTextRecoverData(data){
-            var json = JSON.parse(data[0].dataJson);
-            var items = json.structuredText.items;
-            var test = items[5].symptoms&&items[5].symptoms.split(",");
-            var sug = items[6].symptoms&&items[6].symptoms.split(",");
-            var treat = items[7].symptoms.split(",");
-            var drug = items[8].symptoms.split(",");
-            var treatStr='';
-            if(test.length==0){
-                test = json.hisPush.test.map((it) =>{
-                   return it.name;
-                });
-            }
-            if(sug.length==0){
-                sug = json.hisPush.assist.map((it) =>{
-                    return it.name;
-                });
-            }
-            for(var i=0; i<treat.length;i++){
-                if(i>3){
-                    treatStr += '<b class="hide">'+treat[i]+'</b>';
-                }else{
-                    treatStr += '<b>'+treat[i]+'</b>';
-                }
-            }
-            $(".main-suit").html(treatStr);
-            mapRecoverData(".test-item",test,true);
-            mapRecoverData(".sug-item",sug,true);
-            mapRecoverData(".treatment",drug,true);
-            var hide = $(".main-suit .hide")[0];
-            if(hide){
-                $("<a class='more'>...</a>").insertBefore(hide);
-                $(".more").click(function(e){
-                    $(e.target).siblings(".hide").removeClass("hide");
-                    $(e.target).hide();
-                })
-            }
-        }
-        function parseRecoverData(data){
-            if(!data[0]){
-                console.warn("获取的recover数据为空");
-                return ;
-            }
-            var json = JSON.parse(data[0].dataJson);
-            if(json.mode==2){
-                parseTextRecoverData(data);
-                return;
-            }
-            var items = json.structured.originalItems;
-            var test = items[5][''];
-            var sug = items[6][''];
-            var treat = items[7][''];
-            var drug = items[8][''];
-            var treatStr='',infoUrl;
-            test = test.length==0?json.hisPush.test:test;
-            sug = sug.length==0?json.hisPush.assist:sug;
-            //console.log(json)
-            for(var i=0; i<treat.length;i++){
-                infoUrl = "./case_info.html?diseaseId="+treat[i].id;   //文本模式保存的没有id
-                if(i>3){
-                    treatStr += '<b class="hide">'+treat[i].title+'</b><a class="info hide" href="'+infoUrl+'" target="_blank">i</a>';
-                }else{
-                    treatStr += '<b>'+treat[i].title+'</b><a class="info" href="'+infoUrl+'" target="_blank">i</a>';
-                }
-            }
-            $(".main-suit").html(treatStr);
-            mapRecoverData(".test-item",test);
-            mapRecoverData(".sug-item",sug);
-            mapRecoverData(".treatment",drug);
-            var hide = $(".main-suit .hide")[0];
-            if(hide){
-                $("<a class='more'>...</a>").insertBefore(hide);
-                $(".more").click(function(e){
-                    $(e.target).siblings(".hide").removeClass("hide");
-                    $(e.target).hide();
-                })
-            }
+  function parseUrl() {
+    var r = window.location.search.substr(1).split("&"),
+      obj = {};
+    $.each(r, function (i, v) {
+      if (v) {
+        var arr = v.split("=");
+        obj[arr[0]] = arr[1]?decodeURI(arr[1]):'';
+      }
+    });
+    return obj;
+  };
 
-        }
+  function handleConfig(){
+    $("tr td:last-child,.item-box").css({width:config.width});
+    $('.'+config.mode).show();
+    $('.item-box:visible:first td:first').attr('rowspan',config.models.length);
+    //显示对应项目
+    config.models.map((it)=>{
+      $('.'+config.mode+" .box"+it).show();
+    });
+  }
+  function getPushData(){
+    var url = urls.get_push;
+    var myParam = {
+      symptom: urlSearch.symptomJson||"",
+      past: urlSearch.pastJson||"",
+      other: urlSearch.otherJson||"",
+      vital: urlSearch.vitalsJson||"",
+      lis: urlSearch.labsJson||"",
+      pacs: urlSearch.pacsJson||"",
+      diag: urlSearch.disJson||"",
+      featureType: config.models.join(",")
+    };
 
-        function mapRecoverData(dom,data,isText){
-            var itemDom = "",item = data,temp;
-            if(!data.length>0){
-                console.warn("获取数据失败");
-                return ;
-            }
-            for(var i=0;i<item.length;i++){
-                if(isText){
-                    temp = item[i];
-                }else{
-                    temp = item[i].title||item[i].name;
-                }
-                if(i>7){
-                    itemDom += '<a href="##" class="hide">'+temp+'</a>';
-                }else{
-                    itemDom += '<a href="##">'+temp+'</a>';
-                }
-            }
-            $(dom).html(itemDom||"无");
-            var hide = $(dom).find(".hide")[0];
-            if(hide){
-                $("<a class='more'>...</a>").insertBefore(hide);
-                $(".more").click(function(e){
-                    $(e.target).siblings(".hide").removeClass("hide");
-                    $(e.target).hide();
-                })
-            }
-        }
-        //填入推送信息
-        function fillPushData(data){
-            if(!data||JSON.stringify(data)=='{}'){
-                console.warn("获取推送数据为空!");
-                return ;
-            }
-            var lis = data.lis;
-            var pacs = data.pacs;
-            var drug = data.drug;
-            var disease = data.disease;
-            var infoUrl,str='';
-
-            for(var i=0;i<disease.length;i++){
-                infoUrl="./case_info.html?diseaseId="+disease[i].id;
-                str += '<b>'+disease[i].name+'</b><a class="info" href="'+infoUrl+'" target="_blank">i</a>';
-            }
-            $(".main-suit").html(str);
-            mapItem(".test-item", lis);
-            mapItem(".sug-item", pacs);
-            mapItem(".drug-item", drug);
-
-        }
-        //遍历数据
-        function mapItem(dom,item){
-            var itemDom = '';
-            for(var i=0;i<item.length;i++){
-                if(i>5){
-                    itemDom += '<a href="##" class="hide">'+item[i]+'</a>';
-                }else{
-                    itemDom += '<a href="##">'+item[i]+'</a>';
-                }
-            }
-            $(dom).html(itemDom||"无");
-            var hide = $(dom).find(".hide")[0];
-            if(hide){
-                $("<a class='more'>...</a>").insertBefore(hide);
-                $(".more").click(function(e){
-                    $(e.target).siblings(".hide").removeClass("hide");
-                    $(e.target).hide();
-                })
-            }
-        }
-        function ajaxJsonGet(url, param, callback){
-            $.ajax({
-                url: url,
-                data:param,
-                contentType: 'application/json',
-                type:'get',
-                cache:false,
-                success:function(response){
-                    callback(response);
-                }
-            });
+    $.ajax({
+      url: url,
+      type:'post',
+      dataType: "json",
+      contentType:"application/json",
+      data:JSON.stringify(myParam),
+      success:function(response){
+        var data = response.data;
+        if(response.ret=='0'){
+          fillPushData(data);
         }
+      },
+      error:function(error){
+        console.log("error:"+error);
+      },
+      complete:function(){
+        console.log("complete")
+      }
+    });
+  }
 
-    })(jQuery);
+  //填入推送信息
+  function fillPushData(data){
+    var maps = {1:'symptom',4:'vitals',5:'labs',6:'pacs',7:'dis',};
+    if(!data||JSON.stringify(data)=='{}'){
+      console.warn("获取推送数据为空!");
+      return ;
+    }
+    var key='',modeClass='.'+config.mode;
+    config.models.map((it)=>{
+        key = maps[it];
+        var arr = [];
+      for(var n = 0;n <data[key].length; n++){
+        arr.push(data[key][n].featureName);
+      }
+      mapItem(modeClass+" .box"+it+' .item-content', arr);
+    });
+    //$(modeClass+" .box .item-content").html(str);         //治疗建议
+  }
+  //遍历数据
+  function mapItem(dom,item){
+    var itemDom = '';
+    for(var i=0;i<item.length;i++){
+      if(i>config.num-1){
+        itemDom += '<a href="##" class="hide">'+item[i]+'</a>';
+      }else{
+        itemDom += '<a href="##">'+item[i]+'</a>';
+      }
+    }
+    $(dom).html(itemDom||"无");
+    var hide = $(dom).find(".hide")[0];
+    if(hide){
+      $("<a class='more'>...</a>").insertBefore(hide);
+      $(".more").click(function(e){
+        $(e.target).siblings(".hide").removeClass("hide");
+        $(e.target).hide();
+      })
+    }
+  }
+})(jQuery);