(function(exports){ var curWwwPath = window.document.location.href; var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); var localhostPaht = curWwwPath.substring(0, pos); var projectName = pathName.substring(0, pathName.substr(1).indexOf('/')+1); var realPath = localhostPaht+projectName; var hcData ={};//宏定义 var proceData={ get : function(x){ return this.x; }, set : function(prop,x){ this[prop] = x } };//其他信息,如病程记录的信息 var eventData = { } var dataToJSONArray = function(data){ var returnData ={}; if(data instanceof Array){ var rowCount=data.length if(rowCount>0){ returnData.BorderVisible=true; returnData.RowCount=data.length; //这里可以根据医院的需求来设置显示多少列。默认全部取出 let cellsCount=Object.keys(data[0]).length; var rows=new Array(); for(let i=0;i TItemStyle.Null) { // 文本 if (vItem.IsElement){ console.log("数据元 Index:" + vItem.Index + " Text:" + vItem.Text,vItem.GetValue(TDeProp.Name),vItem.AllocValue); if(emrView._dataMark){ if(vItem.AllocValue){//已经赋值 emrView._dataStr+=vItem.Text; emrView._saveEmrData[emrView._currentDataGroup].dataStr += vItem.Text; } } let deElement = new Object(); deElement.Index = vItem.Index; deElement.Name = vItem.GetValue(TDeProp.Name); deElement.Text = vItem.Text; deElement.Code = vItem.Code; deElement.Value = ""; emrView._emrDataElement_wat.push(deElement); if(!vItem.AllocValue){ emrView._nullEmrDataArray.push(vItem.Index+"#"+vItem.Name); } } else{ console.log("自然文本 Text:" + vItem.Text); // 原生Item文本属性Text(大写T开始) if(emrView._dataMark){ emrView._dataStr+=vItem.Text; emrView._saveEmrData[emrView._currentDataGroup].dataStr += vItem.Text; } let deElement = new Object(); deElement.Index = vItem.Index; deElement.Name = vItem.GetValue(TDeProp.Name); deElement.Text = vItem.Text; deElement.Code = vItem.Code; deElement.Value = ""; emrView._emrDataElement_wat.push(deElement); } } else if (vItem.StyleNo == TItemStyle.CheckBox){ console.log("勾选框 Text:" + vItem.Text); if(emrView._dataMark){ emrView._dataStr+=vItem.Text; emrView._saveEmrData[emrView._currentDataGroup].dataStr += vItem.Text; } let deElement = new Object(); deElement.Index = vItem.Index; deElement.Name = vItem.GetValue(TDeProp.Name); deElement.Text = vItem.Text; deElement.Code = vItem.Code; deElement.Value = ""; emrView._emrDataElement_wat.push(deElement); } else if (vItem.StyleNo == TItemStyle.Combobox){ console.log("下拉框 Text" + vItem.Text); if(emrView._dataMark){ emrView._dataStr+=vItem.Text; emrView._saveEmrData[emrView._currentDataGroup].dataStr += vItem.Text; } let deElement = new Object(); deElement.Index = vItem.Index; deElement.Name = vItem.GetValue(TDeProp.Name); deElement.Text = vItem.Text; deElement.Code = vItem.Code; deElement.Value = ""; emrView._emrDataElement_wat.push(deElement); } else if (vItem.StyleNo == TItemStyle.Edit){ console.log("文本框 Text" + vItem.Text); if(emrView._dataMark){ emrView._dataStr+=vItem.Text; emrView._saveEmrData[emrView._currentDataGroup].dataStr += vItem.Text; } let deElement = new Object(); deElement.Index = vItem.Index; deElement.Name = vItem.GetValue(TDeProp.Name); deElement.Text = vItem.Text; deElement.Code = vItem.Code; deElement.Value = ""; emrView._emrDataElement_wat.push(deElement); } else if (vItem.StyleNo == TItemStyle.DateTimePicker){ console.log("日期时间 Text" + vItem.Text); if(emrView._dataMark){ emrView._dataStr+=vItem.Text; emrView._saveEmrData[emrView._currentDataGroup].dataStr += vItem.Text; } let deElement = new Object(); deElement.Index = vItem.Index; deElement.Name = vItem.GetValue(TDeProp.Name); deElement.Text = vItem.Text; deElement.Code = vItem.Code; deElement.Value = ""; emrView._emrDataElement_wat.push(deElement); } else if (vItem.StyleNo == TItemStyle.RadioGroup){ console.log("RadioGroup Text" + vItem.Text); let deElement = new Object(); deElement.Index = vItem.Index; deElement.Name = vItem.GetValue("Name"); deElement.Text = vItem.Text; deElement.Value = ""; deElement.ParentIndex = ""; let tList = vItem.FItems; for(let i =0 ;i0){ emrView.EditProcIndex = data.emrId; emrView.ScrollToProc(emrView.EditProcIndex); if(evData){ evData.forEach( (item) =>{emrView.SetProcDeGroupByText(emrView.EditProcIndex,item.Index, item.Text);} ) } }else{ if(evData){ evData.forEach( (item) =>{emrView.SetDeGroupByText(item.Index, item.Text);} ) } } } }finally{ if(data.type=="newrecord"){ //save病历 var sectionData =data.sectionData; for(prop in sectionData){ emrView.SetDeGroupByText(prop, sectionData[prop]); } var steamData = emrView.SaveToBytes(); var emrData = new EmrToWatData("B","saveEMRByte",steamData); window.parent.top.DxURLPage.action(GetQueryString('strwinid'),GetQueryString('strctrid'),JSON.stringify(emrData),true); } } }, "emrMZBaseInit":function(data){//初始化门诊病历首页 var index = layer.load(0, {shade: [0.1,'#ff0']}); try{ var type = data.type;//新建还是编辑 var _EmrEditor={}; _EmrEditor[EmrEditor.USER]=data._user;//非序列化属性【当前医生id】 _EmrEditor[EmrEditor.OPERATOR]=data._operator;//经治医师【elemr_patients】 _EmrEditor[EmrEditor.DIRECTOR]=data._director;//主治医师【elemr_patients】 _EmrEditor[EmrEditor.LEADER]=data._leader;//主任医师【elemr_patients】 _EmrEditor[EmrProp.EditorType]=data.editortype;//当前操作员是护士还是医生 _EmrEditor[EmrEditor.QCR] = data.qcr;//病历书写人 _EmrEditor[EmrEditor.USERNAME]=data._username; var _Emr ={}; _Emr[EmrProp.OPERATORSIGN]=data.operatorsign; _Emr[EmrProp.DIRECTORSIGN]=data.directorsign; _Emr[EmrProp.LEADERSIGN]=data.leadersign; emrView._EmrEditor=_EmrEditor; emrView._Emr=_Emr; hcData =data.hcData; var dataByte = new Uint8Array(data.emrContent); if(dataByte.length==0){ }else{ emrView.ReadOnly=false; emrView.LoadFromBytes(dataByte);//LoadFromBytes } //设置emrView.InnerView.FPropertys,必须在字节流加载完成之后,切记 if(type=="new"){ proceData.set("DE09.00.053.00",data.operatortime); emrView.InnerView.SetValue(EmrProp.EmrId, data.emrId);//病历附加属性[病历id] emrView.InnerView.SetValue(EmrProp.QCR, data.qcr);//新建病历的人【起草人】 emrView.InnerView.SetValue(EmrProp.Choscode, data.choscode);//医院编码 emrView.InnerView.SetValue(EmrProp.EditorType, data.editortype);//护士还是医生写的。 } //医生未签名是,设置辅助检查结果等信息 if("1"!=emrView._Emr[EmrProp.OPERATORSIGN]){ var inSpection = data.inspection; console.log(inSpection); var meDicalTreatment = data.meDicalTreatment; var inSpectionData = dataToJSONArray(inSpection); var meDicalTreatmentData = dataToJSONArray(meDicalTreatment); var westDrug = data.westDrug; var westDrugData = dataToJSONArray(westDrug); var diagnoseInfo = data.diagnoseInfo var chineseDrug = data.chineseDrug; var chineseDrugData = dataToJSONArray(chineseDrug); let evData =data.eventData if(evData){ evData.forEach((item) =>{ emrView.SetDeGroupByText(item.Index, item.Text); }) } if (emrView.InnerView.SetCaretToPageDeGroupStart("S4513")){ if(inSpection){//检验检查 if(inSpection instanceof Array){ emrView.SetDeGroupByText("S4513", ""); emrView.InsertDeTable( inSpectionData ); } } } if(emrView.InnerView.SetCaretToPageDeGroupStart("S5561")){ if(meDicalTreatment){//项目 if(meDicalTreatment instanceof Array){ emrView.SetDeGroupByText("S5561", ""); emrView.InsertDeTable( meDicalTreatmentData ); } } } if(emrView.InnerView.SetCaretToPageDeGroupStart("S5560")){ if(westDrug){//药品 if(westDrug instanceof Array){ emrView.SetDeGroupByText("S5560", ""); emrView.InsertDeTable( westDrugData ); } } } if(emrView.InnerView.SetCaretToPageDeGroupStart("S5559")){ if(chineseDrug){ if(chineseDrug instanceof Array){ emrView.SetDeGroupByText("S5559", ""); emrView.InsertDeTable( chineseDrugData ); } } } if(emrView.InnerView.SetCaretToPageDeGroupStart("S5558")){//诊断 if(diagnoseInfo){ if(diagnoseInfo instanceof Array){ emrView.SetDeGroupByText("S5558", ""); let diagStr =""; for(let i =0;i0){ var dataByte = new Uint8Array(data.emrContent); emrView.LoadFromBytes(dataByte); emrView.ReadOnly=true; }else{ emrView.Clear(); } }, "emrProcessInit":function(data){//初始化病程 // console.log("emrInit:"+JSON.stringify(data)); // console.log(data.emrContent); try{ var _EmrEditor={}; var _Emr ={}; emrView._EmrEditor=_EmrEditor; emrView._Emr=_Emr; var dataByte = new Uint8Array(data.emrContent); hcData =data.hcData; if (dataByte.length > 0) { // 模板有内容,创建病历 emrView.BeginUpdate(); // 开启批量更新,提高效率 try { emrView.ReadOnly = false; // 取消只读 emrView.Clear(); let vFirstProc = emrView.ProcCount == 0; // 插入的病程是不是病历第一个病程 var vPropertys = ""; // emrView.InsertProc(data.emrId, vPropertys, ""); // 插入病程标识 emrView.EditProcIndex = data.emrId; // 当前可编辑病程为新病程的唯一ID(字符型) proceData.set("DE09.00.053.00",data.operatortime); if (vFirstProc) { // 是病历首次新建内容,需要加载页眉页脚 emrView.LoadHeaderFromBytes(dataByte, true); // true加载纸张大小和页边距 emrView.LoadFooterFromBytes(dataByte, false); } emrView.SetProcByFileSteam(emrView.EditProcIndex, dataByte); // 设置新建的病程内容 emrView.ClearUndo(); // 清除撤销恢复记录,防止新建后用户撤销 emrView.InnerView.ResetActiveSectionMargin(); // 重新格式化 } finally { emrView.EndUpdate(); } emrView.ScrollToProc(emrView.EditProcIndex); // 滚动到新建的病程位置,便于书写 } //save病历 var sectionData =data.sectionData; for(prop in sectionData){ emrView.SetDeGroupByText(prop, sectionData[prop]); } var consultation = data.consultation; for(prop in consultation){ emrView.SetDeGroupByText(prop, consultation[prop]); } }finally{ //save病历 // var steamData = emrView.SaveToBytes(); // var emrData = new EmrToWatData("B","saveEMRByte",steamData); // return window.parent.top.DxURLPage.action(GetQueryString('strwinid'),GetQueryString('strctrid'),JSON.stringify(emrData),false); } }, "emrLiteInit" :function(data){//初始化关键词 if(data.emrContent==undefined){ }else{ // emrView.InnerView.Clear(); var dataByte = new Uint8Array(data.emrContent); if(dataByte.length>0){ emrView.InsertLiteBytes(dataByte); }else{ alert("当前文档不存在"); } } }, "insertDeItem":function(data){ console.log("InsertDeItem:"+data); console.log("InsertDeItem:"+JSON.stringify(data)); emrView.InsertDeItem(data); }, "insertDeGroup":function(data){ console.log("insertDeGroup:"+JSON.stringify(data)); emrView.InsertDeGroup(data); }, "insertDeDateTime":function(data){//插入日期时间 console.log("insertDeDateTime:"+JSON.stringify(data)); emrView.InsertDeItem(data); }, "insertText":function(data){ console.log("insertText:"+JSON.stringify(data)); console.log("insertText:"+data.text); emrView.InsertText(data.text); }, "insertDeRadioGroup":function(data){ console.log("insertDeRadioGroup:"+JSON.stringify(data)); emrView.InsertDeRadioGroup(data); }, "insertDeCheckBox":function(data){ console.log("insertDeCheckBox:"+JSON.stringify(data)); emrView.InsertDeCheckBox(data); }, "insertDeCheckBoxList":function(data){ console.log("insertDeCheckBox:"+JSON.stringify(data)); if(data instanceof Array){ data.forEach(function(item,i){ console.log(item.event); if(item.event =="insertDeRadioGroup"){ console.log(item.data); emrView.InsertDeRadioGroup(item.data); } }); } }, "insertDeEdit": function(data) {//插入Edit控件 let edit = emrView.InsertDeEdit(data); edit.PrintOnlyText = false; edit.BorderSides.remove(1 << 1); edit.BorderSides.remove(1 << 2); edit.BorderSides.remove(1); // emrView.InnerView.ActiveSection.ReFormatActiveItem(); // emrView.InnerView.EndUpdate(); }, "insertDeImage":function(data){//插入签名图片 console.log("insertDeImage:"+JSON.stringify(data)); emrView.InsertDeImage(data); }, "insertProc":function(data){//插入病程 try{ console.log("insertProc:"+JSON.stringify(data)); var bytes =new Uint8Array(data.emrContent); console.log(bytes); if (bytes.length == 0) return; // 病程时间,实际业务应该取服务端时间 var vDate = new Date(); var vDateTime = data.operatortime; // 病程属性,可添加病程控制相关的属性,每个属性是一个键值对,多个属性以\r\n分隔 var vPropertys = ""+EmrProp.OPERATOR+"="+data._operator+"\r\n"+EmrProp.OPERATORTIME+"=" + vDateTime+"\r\n"+EmrProp.OPERATORSIGN+"=" +data.operatorsign+"\r\n"+EmrProp.Choscode+"="+data.choscode+"\r\n"+EmrProp.QCR+"="+data.qcr; // 用户jt,日期vDateTime //设置病程的属性。 proceData.set("DE02.01.039.00",data._operator); proceData.set("DE09.00.053.00",vDateTime); // 病程唯一ID,这里使用了当前时间,实际业务使用时可换为业务里的病程唯一ID生成规则 var vProcIndex = data.emrId; // 在指定的病程(ID为vBeforProcIndex)前面插入新病程,如为""表示在最后插入病程 var vBeforProcIndex = data.preEmrProcessId;//通过后台计算得到的preEmrProcessId // 当前病历是否没有病程,即要插入的病程是否为整个病历的第一个病程 var vFirstProc = emrView.ProcCount == 0; emrView.ReadOnly = false; // 病历切换为非只读 emrView.InsertProcing = true; // 插入病程正在进行中 try { // 插入病程标识 if (emrView.InsertProc(vProcIndex, vPropertys, vBeforProcIndex)) { // 插入病程标识成功 console.log("插入病程,标识为:" + vProcIndex); emrView.EditProcIndex = vProcIndex; // 当前编辑的病程为新插入的病程 emrView.SetProcBytes(vProcIndex, bytes); // 设置当前病程的内容s if (vFirstProc) { // 是整个病历的第一个病程 emrView.BeginUpdate(); // 开启批量更新,提高效率 try { emrView.LoadHeaderFromBytes(bytes); // 加载页眉 emrView.LoadFooterFromBytes(bytes); // 加载页脚 } finally { emrView.EndUpdate(); } } } } finally { emrView.InsertProcing = false; // 病程插入完成了 //插入病程完成后,初始化会诊意见相关的数据组。 var consultationOpinionsData = data.consultationOpinionsData; for(prop in consultationOpinionsData){ emrView.SetDeGroupByText(prop, consultationOpinionsData[prop]); } } emrView.ClearUndo(); // 清空撤销记录,防止用户把新插入的病程撤销了 }finally{ //save病历 var steamData = emrView.SaveToBytes(); var emrData = new EmrToWatData("B","saveEMRByte",steamData); return window.parent.top.DxURLPage.action(GetQueryString('strwinid'),GetQueryString('strctrid'),JSON.stringify(emrData),false); } }, "delCaretProcInfo":function(data){//删除病程 console.log("删除病程记录id:"+data.emrId); try{ // emrView.DeleteProc(data.emrId); emrView.ReadOnly=false; emrView.EditProcIndex = emrView.CaretProcInfo.Index; emrView.DeleteProc(emrView.CaretProcInfo.Index); }finally{ //删除病程之后需要调保存病历 var steamData = emrView.SaveToBytes(); var emrData = new EmrToWatData("B","saveEMRByte",steamData); return window.parent.top.DxURLPage.action(GetQueryString('strwinid'),GetQueryString('strctrid'),JSON.stringify(emrData),false); } }, "locationEmrId":function(data){ console.log("定位病程记录Id:"+data.emrId); emrView.ScrollToProc(data.emrId); }, "cancelSignatureGraphic":function(data){ try{ console.log("取消签名:"+data.emrId); //取消签名后将病程图片清除掉,要修改病程自带的属性。 if(""!=emrView.CaretProcInfo.Index){//病程 emrView.SetProcProperty(data.emrId, EmrProp.OPERATORSIGN, data.operatorSign);// }else{ emrView._Emr[EmrProp.OPERATORSIGN]=data.operatorSign; } }finally{ var steamData = emrView.SaveToBytes(); var emrData = new EmrToWatData("B","saveEMRByte",steamData); return window.parent.top.DxURLPage.action(GetQueryString('strwinid'),GetQueryString('strctrid'),JSON.stringify(emrData),false); } }, "insertDiagnose":function(data){ var diagArr = data.diagnose; var index = data.selectId; console.log(diagArr); var diagStr =""; var separator=" "; if(diagArr instanceof Array){ diagArr.forEach(function(item,index){ var itemstr=item.split("="); var key = itemstr[0]; var value =itemstr[1]; console.log(typeof key); for(var i =0;i0){//病程 emrView._isProc=true; }else{//病历 emrView._isProc=false; } let vAreas = new Set([]); // vAreas.add(1); vAreas.add(2); // vAreas.add(4); emrView._dataStr ="";//用来保存待解析的数据 emrView._dataMark=false;//解析数据组和字符串 emrView._saveEmrData={};// emrView._nullEmrDataArray=[];//用来存储未填写的数据元 emrView._emrDataElement_wat =[];//用来存储病历中的数据元,加后缀防止污染框架内变量 emrView._currentDataGroup=""; emrView._emrId=""; emrView.TraverseElement(traverseFun_wat, vAreas, 0); console.log(emrView._emrDataElement_wat); console.log(emrView._saveEmrData); //如果遍历中有修改数据,需要重新排版 // emrView.InnerView.FormatData(); } exports.url=realPath+"/emreventaction"; })(this.watEvents={});