|
@@ -62,6 +62,7 @@ export const setData = (state,action) =>{
|
|
|
const mainIds = action.info.mainIds;
|
|
|
res.symptomIds = JSON.parse(JSON.stringify(mainIds));
|
|
|
const num = action.info.num;//点击了几次添加病情变化
|
|
|
+ const symptomFeature = action.info.symptomFeature;//分词
|
|
|
// const useEmpty = action.info.useEmpty;
|
|
|
let useEmpty,mainData;
|
|
|
// let mainData = JSON.parse(JSON.stringify(action.info.mainData));//主诉模板数据
|
|
@@ -84,10 +85,9 @@ export const setData = (state,action) =>{
|
|
|
/*let mainLabelModuleArr = objToArr.filter((item)=>{
|
|
|
return item.questionMapping.length>0;
|
|
|
})*/
|
|
|
-
|
|
|
// 是否使用空模板:num=0时判断mainIds,num>=1,截取第一病程遍历是否有症状exist
|
|
|
if(num==0){
|
|
|
- useEmpty = mainIds.length>0?false:true;
|
|
|
+ useEmpty = mainIds.length>0 ? false:true;
|
|
|
mainData = mainModleData;
|
|
|
}else{
|
|
|
let sliceIdx;
|
|
@@ -102,36 +102,37 @@ export const setData = (state,action) =>{
|
|
|
})
|
|
|
useEmpty = existData&&existData.length>0?false:true;
|
|
|
}
|
|
|
-
|
|
|
+ // console.log(888,useEmpty);
|
|
|
if (useEmpty) {
|
|
|
// res.data = res.emptyData;
|
|
|
res.data = JSON.parse(JSON.stringify(res.emptyData));
|
|
|
} else {
|
|
|
- // 目前只需要将第一个主诉病程移植到现病史
|
|
|
- let tongYong = "";
|
|
|
- let main = [];//主症状
|
|
|
- let withs = [];//伴随
|
|
|
- let firstT = 0;
|
|
|
- for(let i=0; i<mainData.length; i++){
|
|
|
- if(mainData[i].id==config.tongYId && !mainData[i].pos){//第一个通用特征描述
|
|
|
- if(mainData[i].value){
|
|
|
- tongYong = mainData[i].value;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(mainData[i].exist){
|
|
|
- mainData[i].exist==1?main.push(mainData[i]):withs.push(mainData[i])
|
|
|
- }
|
|
|
-
|
|
|
- // 处理时间和主诉通用症状--现病史模板无“主诉通用症状” 1-7
|
|
|
- for(let j=0; j<current.length; j++){
|
|
|
- if(mainData[i].id==current[j].id && mainData[i].controlType==5){//处理时间,避免手动输入的值
|
|
|
- firstT++
|
|
|
- if(mainData[i].value && firstT==1){
|
|
|
- current[j] = {id:mainData[i].id,name:mainData[i].value,value:mainData[i].value,tagType:config.tagType}
|
|
|
+ if(mainData&&mainData.length>0){//主诉使用模板
|
|
|
+ // 目前只需要将第一个主诉病程移植到现病史
|
|
|
+ let tongYong = "";
|
|
|
+ let main = [];//主症状
|
|
|
+ let withs = [];//伴随
|
|
|
+ let firstT = 0;
|
|
|
+ for(let i=0; i<mainData.length; i++){
|
|
|
+ if(mainData[i].id==config.tongYId && !mainData[i].pos){//第一个通用特征描述
|
|
|
+ if(mainData[i].value){
|
|
|
+ tongYong = mainData[i].value;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
+ else if(mainData[i].exist){
|
|
|
+ mainData[i].exist==1?main.push(mainData[i]):withs.push(mainData[i])
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理时间和主诉通用症状--现病史模板无“主诉通用症状” 1-7
|
|
|
+ for(let j=0; j<current.length; j++){
|
|
|
+ if(mainData[i].id==current[j].id && mainData[i].controlType==5){//处理时间,避免手动输入的值
|
|
|
+ firstT++
|
|
|
+ if(mainData[i].value && firstT==1){
|
|
|
+ current[j] = {id:mainData[i].id,name:mainData[i].value,value:mainData[i].value,tagType:config.tagType}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
// 主症状添加tongYong标签选中文字
|
|
|
let tongYText = tongYong?{name:tongYong,value:tongYong,tagType:config.tagType}:'';
|
|
@@ -173,7 +174,8 @@ export const setData = (state,action) =>{
|
|
|
if(items.length==0){//没有尾巴时给症状后加逗号(3.5)
|
|
|
for(let j=0; j<newMainCopy.length; j++){
|
|
|
if(newMainCopy[j].id==mainCopy[k].id){
|
|
|
- newMainCopy[j].value = newMainCopy[j].name = mainCopy[k].value+',';
|
|
|
+ // newMainCopy[j].value = newMainCopy[j].name = mainCopy[k].value+',';
|
|
|
+ newMainCopy[j].value = newMainCopy[j].name = mainCopy[k].value||mainCopy[k].name+',';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -220,8 +222,9 @@ export const setData = (state,action) =>{
|
|
|
withLengArr[d] = items.length;
|
|
|
if(items.length==0){//没有尾巴时给症状后加逗号(3.5)
|
|
|
for(let j=0; j<newWiths.length; j++){
|
|
|
- if(newWiths[j].id==mainCopy[d].id){
|
|
|
- newWiths[j].value = newWiths[j].name = withs[d].value+',';
|
|
|
+ if(newWiths[j].id==withs[d].id){
|
|
|
+ // newWiths[j].value = newWiths[j].name = withs[d].value+',';
|
|
|
+ newWiths[j].value = newWiths[j].name = withs[d].value||withs[d].name+',';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -250,7 +253,52 @@ export const setData = (state,action) =>{
|
|
|
}
|
|
|
let currentData = JSON.parse(JSON.stringify(current));
|
|
|
res.data = fullfillText(currentData).newArr;
|
|
|
-
|
|
|
+ }else{//分词
|
|
|
+ if(symptomFeature&&symptomFeature.length>0){
|
|
|
+ let featureData = JSON.parse(JSON.stringify(symptomFeature));
|
|
|
+ let ind = 0;
|
|
|
+ let insertInd = 0;
|
|
|
+ let lengArr=[];
|
|
|
+ for(let k=0; k <symptomFeature.length;k++){
|
|
|
+ mainLabelModuleArr.map((v,i)=>{
|
|
|
+ if(symptomFeature[k].id==v.id){
|
|
|
+ ind++;
|
|
|
+ let items = v.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
+ })
|
|
|
+ lengArr[k] = items.length; //每一个主诉尾巴长度
|
|
|
+
|
|
|
+ if(items.length==0){//没有尾巴时给症状后加逗号(3.5)
|
|
|
+ for(let j=0; j<featureData.length; j++){
|
|
|
+ if(featureData[j].id==symptomFeature[k].id){
|
|
|
+ featureData[j].value = featureData[j].name = symptomFeature[k].value||symptomFeature[k].name+',';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(ind>1){
|
|
|
+ insertInd += lengArr[k-1];
|
|
|
+ }
|
|
|
+ featureData.splice(k+insertInd+1,0,...items);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //组装好的主症状和伴随症状插入现病史模板(flag=4前)
|
|
|
+ let endFeatureData = JSON.parse(JSON.stringify(featureData));
|
|
|
+ let insertIdx = null;
|
|
|
+ for(let j=0; j<current.length; j++){
|
|
|
+ if(current[j].flag && current[j].flag==4){
|
|
|
+ insertIdx = j;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for(let k=0; k<endFeatureData.length; k++){
|
|
|
+ let pos = insertIdx+k;
|
|
|
+ current.splice(pos,0,endFeatureData[k]);
|
|
|
+ }
|
|
|
+ let currentData = JSON.parse(JSON.stringify(current));
|
|
|
+ res.data = fullfillText(currentData).newArr;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
let resData = JSON.parse(JSON.stringify(res.data));
|
|
|
res.saveText = fullfillText(resData).saveText;
|
|
@@ -414,6 +462,47 @@ export function setRadioValue(state,action){
|
|
|
res.update = Math.random();
|
|
|
return res;
|
|
|
}
|
|
|
+//单选带输入值保存
|
|
|
+export const setRadioInputValue = (state,action)=>{
|
|
|
+ const res = Object.assign({},state);
|
|
|
+ const {ikey,values,id} = action.data;
|
|
|
+ const item = res.data[ikey];
|
|
|
+ let str='',temp='',obj=res.data[ikey].questionDetailList;
|
|
|
+ if(!values){ //清空
|
|
|
+ let sld=obj.find((item)=>{
|
|
|
+ return item.selected==true;
|
|
|
+ });
|
|
|
+ sld?sld.selected=false:'';
|
|
|
+ item.vals = null;
|
|
|
+ item.value = '';
|
|
|
+ res.saveText[ikey] = '';
|
|
|
+ res.update = Math.random();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ for(let i in values){
|
|
|
+ temp = values[i];
|
|
|
+ if(typeof temp=='object'){
|
|
|
+ str+=temp.value;
|
|
|
+ }else{
|
|
|
+ str+=temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //选中状态
|
|
|
+ if(id){
|
|
|
+ obj.map((its)=>{
|
|
|
+ if(its.id === id){
|
|
|
+ its.selected = true;
|
|
|
+ }else{
|
|
|
+ its.selected = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ item.vals = values;
|
|
|
+ item.value = str;
|
|
|
+ res.saveText[ikey] = str;
|
|
|
+ res.update = Math.random();
|
|
|
+ return res;
|
|
|
+}
|
|
|
|
|
|
//双击标签输入改变值
|
|
|
export const changeLabelVal = (state,action)=>{
|
|
@@ -538,8 +627,9 @@ export function insertLabelData(state,action){
|
|
|
const {index,data,isReplace,span}=action;
|
|
|
let id = data.id;
|
|
|
let searchData = action.name;
|
|
|
- res.symptomIds.push(id);
|
|
|
+ // res.symptomIds.push(id);
|
|
|
const text = Object.assign(JSON.parse(config.textLabel),{name:searchData},{id:id});
|
|
|
+ const textEmpty = Object.assign({},JSON.parse(config.textLabel));
|
|
|
let focusIndex = res.focusIndex;
|
|
|
let saveText = res.saveText;
|
|
|
let banIdx = saveText.indexOf("伴");
|
|
@@ -556,82 +646,95 @@ export function insertLabelData(state,action){
|
|
|
res.saveText[focusIndex] = searchData;
|
|
|
}else{
|
|
|
let resData;
|
|
|
- // res.data.splice(index,0,data);
|
|
|
const searchStr = res.searchStr;
|
|
|
let innerText = span.current.innerText || span.current.innerHTML;
|
|
|
let strIndex = innerText.indexOf(searchStr);
|
|
|
const value = innerText.replace(searchStr,"");
|
|
|
- // 没有伴展开主诉symptomType=0/1的尾巴,有伴一>第一个点选上去的伴为依据,伴前展开主诉,伴后展开伴随;多余的伴以及手动输入的伴不做处理(2-25)
|
|
|
- if(banIdx==-1){
|
|
|
- // if(strIndex <= 1){//前
|
|
|
- if(strIndex < 1){//前
|
|
|
- res.data.splice(focusIndex,0,text);
|
|
|
- res.saveText.splice(focusIndex,0,searchData);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })));
|
|
|
- }else{
|
|
|
- res.data.splice(focusIndex+1,0,text);
|
|
|
- res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- // +2是因为插入一个文本标签
|
|
|
- resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })));
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(focusIndex > banIdx){//伴后
|
|
|
+ const pText = Object.assign({},textEmpty,{value:value});
|
|
|
+ if(data.itemType==0){//症状
|
|
|
+ res.symptomIds.push(id);
|
|
|
+ // 没有伴展开主诉symptomType=0/1的尾巴,有伴一>第一个点选上去的伴为依据,伴前展开主诉,伴后展开伴随;多余的伴以及手动输入的伴不做处理(2-25)
|
|
|
+ if(banIdx==-1){
|
|
|
+ // if(strIndex <= 1){//前
|
|
|
if(strIndex < 1){//前
|
|
|
- res.data.splice(focusIndex,0,text);
|
|
|
- res.saveText.splice(focusIndex,0,searchData);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==2;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
+ })),pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(focusIndex+1,0,text);
|
|
|
- res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- // +2是因为插入一个文本标签
|
|
|
- resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==2;
|
|
|
+ res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
})));
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
}
|
|
|
- }else{//伴前
|
|
|
- if(strIndex < 1){//前
|
|
|
- res.data.splice(focusIndex,0,text);
|
|
|
- res.saveText.splice(focusIndex,0,searchData);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
+ }else{
|
|
|
+ if(focusIndex > banIdx){//伴后
|
|
|
+ if(strIndex < 1){//前
|
|
|
+ res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==2;
|
|
|
+ })),pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
+ }else{
|
|
|
+ res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==2;
|
|
|
})));
|
|
|
- }else{
|
|
|
- res.data.splice(focusIndex+1,0,text);
|
|
|
- res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- // +2是因为插入一个文本标签
|
|
|
- resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
+ }
|
|
|
+ }else{//伴前
|
|
|
+ if(strIndex < 1){//前
|
|
|
+ res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
+ })),pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
+ }else{
|
|
|
+ res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
})));
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ res.data = fullfillText(res.data).newArr;
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ }else{//标签
|
|
|
+ const spreadLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
|
|
|
+ if(strIndex < 1){//前
|
|
|
+ // 判断前一个是否为文本标签,是直接插入标签,不是则在前面插入一个空文本标签
|
|
|
+ const preItem = res.data[index-1];
|
|
|
+ if(preItem&&preItem.tagType==8){
|
|
|
+ res.data.splice(index,1,...spreadLabels,pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,...new Array(spreadLabels.length).fill(null),null);
|
|
|
+ }else{
|
|
|
+ res.data.splice(index,1,textEmpty,...spreadLabels,pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
|
|
|
+ }
|
|
|
+ // res.data.splice(focusIndex,0,data,textEmpty);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ // 后面插入 :判断后一个标签是否为文本标签,不是则插入一个空标签
|
|
|
+ const afterItem = res.data[index+1];
|
|
|
+ if(afterItem&&afterItem.tagType==8){
|
|
|
+ res.data.splice(index,1,pText,...spreadLabels);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null));
|
|
|
+ }else{
|
|
|
+ res.data.splice(index,1,pText,...spreadLabels,textEmpty);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- span.current.innerText?(span.current.innerText = value):(span.current.innerHTML = value);
|
|
|
- res.data = fullfillText(resData).newArr;
|
|
|
- res.saveText = fullfillText(resData).saveText;
|
|
|
}
|
|
|
res.searchData = []; //选中清空搜索内容(即关闭搜索弹窗)
|
|
|
- res.update = Math.random();//console.log(899,res,action);
|
|
|
+ res.update = Math.random();//console.log('现病史',res);
|
|
|
return res;
|
|
|
}
|
|
|
|