private void mniInsertAsDE_Click(object sender, EventArgs e) { if (dgvDE.SelectedRows.Count == 0) { return; } frmRecord vFrmRecord = GetActiveRecord(); if (vFrmRecord != null) { if (!vFrmRecord.EmrView.Focused) // 先给焦点,便于处理光标处域 { vFrmRecord.EmrView.Focus(); } DataGridViewRow vSelectedRow = dgvDE.SelectedRows[0]; vFrmRecord.InsertDeItem(vSelectedRow.Cells[0].Value.ToString(), vSelectedRow.Cells[1].Value.ToString()); } else { MessageBox.Show("未发现打开的模板!"); } }
private void 签名ToolStripMenuItem_Click(object sender, EventArgs e) { if (!EMR.TreeNodeIsRecord(tvRecord.SelectedNode)) { return; } int vDesPID = -1, vDesID = -1, vRecordID = -1; GetNodeRecordInfo(tvRecord.SelectedNode, ref vDesPID, ref vDesID, ref vRecordID); if (vRecordID > 0) { if (emrMSDB.DB.SignatureInchRecord(vRecordID, UserInfo.ID)) { MessageBox.Show(UserInfo.Name + ",签名成功!后续的修改将留下修改痕迹!"); } int vPageIndex = GetRecordPageIndex(vRecordID); if (vPageIndex >= 0) { frmRecord vFrmRecord = GetPageRecord(vPageIndex); vFrmRecord.EmrView.Trace = true; } } }
private void mniInsertAsCombobox_Click(object sender, EventArgs e) { if (dgvDE.SelectedRows.Count == 0) { return; } frmRecord vFrmRecord = GetActiveRecord(); if (vFrmRecord != null) { DeCombobox vDeCombobox = new DeCombobox(vFrmRecord.EmrView.ActiveSectionTopLevelData(), dgvDE.SelectedRows[0].Cells[1].Value.ToString()); vDeCombobox.SaveItem = false; vDeCombobox[DeProp.Index] = dgvDE.SelectedRows[0].Cells[0].Value.ToString(); if (!vFrmRecord.EmrView.Focused) // 先给焦点,便于处理光标处域 { vFrmRecord.EmrView.Focus(); } vFrmRecord.EmrView.InsertItem(vDeCombobox); } else { MessageBox.Show("未发现打开的模板!"); } }
private void mniInsertAsDG_Click(object sender, EventArgs e) { if (dgvDE.SelectedRows.Count == 0) { return; } frmRecord vFrmRecord = GetActiveRecord(); if (vFrmRecord != null) { using (DeGroup vDeGroup = new DeGroup(vFrmRecord.EmrView.ActiveSectionTopLevelData())) { vDeGroup[DeProp.Index] = dgvDE.SelectedRows[0].Cells[0].Value.ToString(); vDeGroup[DeProp.Name] = dgvDE.SelectedRows[0].Cells[0].Value.ToString(); if (!vFrmRecord.EmrView.Focused) // 先给焦点,便于处理光标处域 { vFrmRecord.EmrView.Focus(); } vFrmRecord.EmrView.InsertDeGroup(vDeGroup); } } else { MessageBox.Show("未发现打开的模板!"); } }
private void CloseTemplatePage(int aPageIndex, bool aSaveChange = true) { if (aPageIndex >= 0) { TabPage vPage = tabTemplate.TabPages[aPageIndex]; if (aSaveChange) { for (int i = 0; i < vPage.Controls.Count; i++) { if (vPage.Controls[i] is frmRecord) { frmRecord vFrmRecord = vPage.Controls[i] as frmRecord; if (vFrmRecord.EmrView.IsChanged) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("是否保存模板 " + (vFrmRecord.ObjectData as TemplateInfo).Name + "?", "确认操作", messButton); if (dr == DialogResult.OK) { DoSaveTempContent(vFrmRecord, null); } } break; } } } tabTemplate.TabPages.Remove(vPage); } }
private void FrmRecordSet_Load(object sender, EventArgs e) { FRecord = new frmRecord(); FRecord.PrintToolVisible = true; FRecord.TopLevel = false; this.pnlRecord.Controls.Add(FRecord); FRecord.Dock = DockStyle.Fill; FRecord.Show(); tbxPageNoFmt.Text = FRecord.EmrView.PageNoFormat; }
private void CheckRecordContent(frmRecord aFrmRecord) { HCItemTraverse vItemTraverse = new HCItemTraverse(); vItemTraverse.Tag = 0; vItemTraverse.Areas.Add(SectionArea.saPage); vItemTraverse.Process = DoTraverseItem; aFrmRecord.EmrView.TraverseItem(vItemTraverse); aFrmRecord.EmrView.FormatData(); }
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e) { RecordInfo vRecordInfo = null; int vTemplateID = -1; frmTemplateList vFrmTempList = new frmTemplateList(); vFrmTempList.ShowDialog(); if (vFrmTempList.DialogResult == System.Windows.Forms.DialogResult.OK) { vTemplateID = vFrmTempList.TemplateID; vRecordInfo = new RecordInfo(); vRecordInfo.DesID = vFrmTempList.DesID; vRecordInfo.RecName = vFrmTempList.RecordName; vRecordInfo.DT = vFrmTempList.RecordDateTime; } else { return; } using (MemoryStream vSM = new MemoryStream()) { emrMSDB.DB.GetTemplateContent(vTemplateID, vSM); // 取模板内容 TabPage vPage = null; frmRecord vFrmRecord = null; NewPageAndRecord(vRecordInfo, ref vPage, ref vFrmRecord); emrMSDB.DB.GetDataSetElement(vRecordInfo.DesID); if (vSM.Length > 0) { PrepareSyncData(vRecordInfo.DesID); vFrmRecord.EmrView.OnSyncDeItem = DoSyncDeItem; try { vFrmRecord.EmrView.LoadFromStream(vSM); SyncDeGroupByStruct(vFrmRecord.EmrView); vFrmRecord.EmrView.FormatData(); vFrmRecord.EmrView.IsChanged = true; } finally { vFrmRecord.EmrView.OnSyncDeItem = null; } } tabRecord.SelectedTab = vPage; } }
private void TraverseElement(frmRecord aFrmRecord) { HCItemTraverse vItemTraverse = new HCItemTraverse(); vItemTraverse.Tag = 0; vItemTraverse.Areas.Add(SectionArea.saHeader); vItemTraverse.Areas.Add(SectionArea.saPage); vItemTraverse.Areas.Add(SectionArea.saFooter); vItemTraverse.Process = DoTraverseItem; aFrmRecord.EmrView.FormatData(); }
private void DoImportAsText(string aText) { frmRecord vFrmRecord = GetActiveRecord(); if (vFrmRecord != null) { vFrmRecord.EmrView.InsertText(aText); } else { MessageBox.Show("未发现打开的病历!"); } }
private XmlDocument GetStructureToXml(frmRecord aFrmRecord) { HCItemTraverse vItemTraverse = new HCItemTraverse(); XmlStruct vXmlStruct = new XmlStruct(); vItemTraverse.Areas.Add(SectionArea.saPage); vItemTraverse.Process = vXmlStruct.TraverseItem; vXmlStruct.XmlDoc.DocumentElement.SetAttribute("DesID", (aFrmRecord.Tag as RecordInfo).DesID.ToString()); vXmlStruct.XmlDoc.DocumentElement.SetAttribute("DocName", (aFrmRecord.Tag as RecordInfo).RecName); aFrmRecord.EmrView.TraverseItem(vItemTraverse); return(vXmlStruct.XmlDoc); }
private void tvTemplate_DoubleClick(object sender, EventArgs e) { if (TreeNodeIsTemplate(tvTemplate.SelectedNode)) { int vTempID = (tvTemplate.SelectedNode.Tag as TemplateInfo).ID; int vPageIndex = GetRecordEditPageIndex(vTempID); if (vPageIndex >= 0) { tabTemplate.TabIndex = vPageIndex; return; } frmRecord vFrmRecord = null; using (MemoryStream vSM = new MemoryStream()) { emrMSDB.DB.GetTemplateContent(vTempID, vSM); //using (FileStream vfs = new FileStream(@"c:\问题模板.hcf", FileMode.Create)) //{ // byte[] vBytes = vSM.GetBuffer(); // vfs.Write(vBytes, 0, vBytes.Length); // vfs.Close(); //} vFrmRecord = new frmRecord(); vFrmRecord.EmrView.DesignModeEx = true; vFrmRecord.ObjectData = tvTemplate.SelectedNode.Tag; if (vSM.Length > 0) { vFrmRecord.EmrView.LoadFromStream(vSM); } } if (vFrmRecord != null) { TabPage vPage = new TabPage(tvTemplate.SelectedNode.Text); vPage.Tag = vTempID; vFrmRecord.TopLevel = false; vFrmRecord.OnSave = DoSaveTempContent; vFrmRecord.OnChangedSwitch = DoRecordChangedSwitch; vPage.Controls.Add(vFrmRecord); vFrmRecord.Dock = DockStyle.Fill; vFrmRecord.Show(); tabTemplate.TabPages.Add(vPage); tabTemplate.SelectedTab = vPage; vFrmRecord.EmrView.Focus(); } } }
private void mniInsertTemplate_Click(object sender, EventArgs e) { if (TreeNodeIsTemplate(tvTemplate.SelectedNode)) { frmRecord vFrmRecord = GetActiveRecord(); if (vFrmRecord != null) { TreeNode vNode = tvTemplate.SelectedNode; using (MemoryStream vSM = new MemoryStream()) { emrMSDB.DB.GetTemplateContent((vNode.Tag as TemplateInfo).ID, vSM); while (vNode.Parent != null) { vNode = vNode.Parent; } int vGroupClass = (vNode.Tag as DataSetInfo).GroupClass; if (vGroupClass == DataSetInfo.CLASS_PAGE) { vSM.Position = 0; vFrmRecord.EmrView.InsertStream(vSM); } else if ((vGroupClass == DataSetInfo.CLASS_HEADER) || (vGroupClass == DataSetInfo.CLASS_FOOTER)) { HCEmrView vEmrView = new HCEmrView(); vEmrView.LoadFromStream(vSM); vSM.SetLength(0); vEmrView.Sections[0].Header.SaveToStream(vSM); vSM.Position = 0; if (vGroupClass == DataSetInfo.CLASS_HEADER) { vFrmRecord.EmrView.ActiveSection.Header.LoadFromStream(vSM, vEmrView.Style, HC.View.HC.HC_FileVersionInt); } else { vFrmRecord.EmrView.ActiveSection.Footer.LoadFromStream(vSM, vEmrView.Style, HC.View.HC.HC_FileVersionInt); } vFrmRecord.EmrView.IsChanged = true; vFrmRecord.EmrView.UpdateView(); } } } } }
private void LoadPatientDataSetContent(int aDeSetID) { DataTable dt = emrMSDB.DB.GetData(string.Format(emrMSDB.Sql_GetDataSet, PatientInfo.PatID, PatientInfo.VisitID, aDeSetID)); if (dt.Rows.Count >= 0) { int vIndex = 0; frmRecord vFrmRecord = new frmRecord(); vFrmRecord.OnReadOnlySwitch = DoRecordReadOnlySwitch; vFrmRecord.TopLevel = false; TabPage vPage = new TabPage(); vPage.Text = "病程记录"; vPage.Tag = -aDeSetID; vPage.Controls.Add(vFrmRecord); vFrmRecord.Dock = DockStyle.Fill; vFrmRecord.EmrView.BeginUpdate(); try { for (int i = 0; i < dt.Rows.Count; i++) { byte[] vContent = (byte[])dt.Rows[i]["content"]; MemoryStream vStream = new MemoryStream(vContent); if (vStream.Length > 0) { if (vIndex > 0) { vFrmRecord.EmrView.ActiveSection.ActiveData.SelectLastItemAfterWithCaret(); vFrmRecord.EmrView.InsertBreak(); vFrmRecord.EmrView.ApplyParaAlignHorz(ParaAlignHorz.pahLeft); } vFrmRecord.EmrView.InsertStream(vStream); vIndex++; } } } finally { vFrmRecord.EmrView.EndUpdate(); } vFrmRecord.Show(); tabRecord.TabPages.Add(vPage); } }
private void 导出XML结构ToolStripMenuItem_Click(object sender, EventArgs e) { if (!EMR.TreeNodeIsRecord(tvRecord.SelectedNode)) { return; } int vDesPID = -1, vDesID = -1, vRecordID = -1; GetNodeRecordInfo(tvRecord.SelectedNode, ref vDesPID, ref vDesID, ref vRecordID); if (vRecordID > 0) { SaveFileDialog vSaveDlg = new SaveFileDialog(); vSaveDlg.Filter = "XML|*.xml"; vSaveDlg.ShowDialog(); if (vSaveDlg.FileName != "") { int vPageIndex = GetRecordPageIndex(vRecordID); if (vPageIndex < 0) { LoadPatientRecordContent(tvRecord.SelectedNode.Tag as RecordInfo); vPageIndex = GetRecordPageIndex(vRecordID); } else { tabRecord.SelectedIndex = vPageIndex; } frmRecord vFrmRecord = GetPageRecord(vPageIndex); string vFileName = Path.GetExtension(vSaveDlg.FileName); if (vFileName.ToLower() != ".xml") { vFileName = vSaveDlg.FileName + ".xml"; } else { vFileName = vSaveDlg.FileName; } SaveStructureToXml(vFrmRecord, vFileName); } } }
private void InsertDataElementAs(InsertAsProc proc) { frmRecord vFrmRecord = GetActiveRecord(); if (vFrmRecord != null) { if (!vFrmRecord.EmrView.Focused) // 先给焦点,便于处理光标处域 { vFrmRecord.EmrView.Focus(); } proc(vFrmRecord); } else { MessageBox.Show("未发现打开的模板!"); } }
private void DoSaveRecordStructure(object sender, EventArgs e) { frmRecord vFrmRecord = sender as frmRecord; if (!vFrmRecord.EmrView.IsChanged) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("未发生变化,确定要更新病历结构数据?", "确认操作", messButton); if (dr != DialogResult.OK) { return; } } RecordInfo vRecordInfo = vFrmRecord.Tag as RecordInfo; SaveRecordStructure(vRecordInfo.ID, vFrmRecord, false); // 更新病历结构内容 MessageBox.Show("更新病历 " + vRecordInfo.RecName + " 结构成功!"); }
private void CloseRecordPage(int aPageIndex, bool aSaveChange = true) { if (aPageIndex >= 0) { TabPage vPage = tabRecord.TabPages[aPageIndex]; frmRecord vFrmRecord = GetPageRecord(aPageIndex); if (aSaveChange && vFrmRecord.EmrView.IsChanged && (int.Parse(vPage.Tag.ToString()) > 0)) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("是否保存病历 " + (vFrmRecord.Tag as RecordInfo).RecName + "?", "确认操作", messButton); if (dr == DialogResult.OK) { DoSaveRecordContent(vFrmRecord, null); } } tabRecord.TabPages.Remove(vPage); } }
private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e) { if (!EMR.TreeNodeIsRecord(tvRecord.SelectedNode)) { return; } int vDesPID = -1, vDesID = -1, vRecordID = -1; GetNodeRecordInfo(tvRecord.SelectedNode, ref vDesPID, ref vDesID, ref vRecordID); if (vRecordID > 0) { int vPageIndex = GetRecordPageIndex(vRecordID); if (vPageIndex < 0) { LoadPatientRecordContent(tvRecord.SelectedNode.Tag as RecordInfo); vPageIndex = GetRecordPageIndex(vRecordID); } else { tabRecord.SelectedIndex = vPageIndex; } frmRecord vFrmRecord = GetPageRecord(vPageIndex); vFrmRecord.EmrView.ReadOnly = false; vFrmRecord.EmrView.UpdateView(); try { vFrmRecord.EmrView.Trace = emrMSDB.DB.GetInchRecordSignature(vRecordID); if (vFrmRecord.EmrView.Trace) { MessageBox.Show("病历已经签名,后续的修改将留下修改痕迹!"); } } catch (Exception exp) { vFrmRecord.EmrView.ReadOnly = true; MessageBox.Show("编辑病历失败!" + exp.Message + "\n\r" + emrMSDB.DB.ErrMsg); } } }
private void LoadPatientRecordContent(RecordInfo aRecordInfo) { using (MemoryStream vSM = new MemoryStream()) { emrMSDB.DB.GetRecordContent(aRecordInfo.ID, vSM); if (vSM.Length > 0) { TabPage vPage = null; frmRecord vFrmRecord = null; NewPageAndRecord(aRecordInfo, ref vPage, ref vFrmRecord); vFrmRecord.EmrView.LoadFromStream(vSM); vFrmRecord.EmrView.ReadOnly = true; tabRecord.SelectedTab = vPage; } } }
private void NewPageAndRecord(RecordInfo aRecordInfo, ref TabPage aPage, ref frmRecord aFrmRecord) { aPage = new TabPage(aRecordInfo.RecName); aPage.Tag = aRecordInfo.ID; // 创建病历窗体 aFrmRecord = new frmRecord(); aFrmRecord.TopLevel = false; aFrmRecord.OnSave = DoSaveRecordContent; aFrmRecord.OnSaveStructure = DoSaveRecordStructure; aFrmRecord.OnChangedSwitch = DoRecordChangedSwitch; aFrmRecord.OnReadOnlySwitch = DoRecordReadOnlySwitch; aFrmRecord.OnInsertDeItem = DoInsertDeItem; aFrmRecord.Tag = aRecordInfo; aPage.Controls.Add(aFrmRecord); aFrmRecord.Dock = DockStyle.Fill; aFrmRecord.Show(); tabRecord.TabPages.Add(aPage); }
private void SaveRecordStructure(int aRecordID, frmRecord aFrmRecord, bool aInsert) { XmlDocument vXmlDoc = GetStructureToXml(aFrmRecord); if (vXmlDoc == null) { return; } using (MemoryStream vSM = new MemoryStream()) { vXmlDoc.Save(vSM); EMRView.emrMSDB.ExecCommandEventHanler vEvent = delegate(SqlCommand sqlComm) { sqlComm.Parameters.AddWithValue("rid", aRecordID); sqlComm.Parameters.AddWithValue("structure", vSM.GetBuffer()); }; if (aInsert) { if (emrMSDB.DB.ExecSql("INSERT INTO Inch_RecordStructure (rid, structure) VALUES (@rid, @structure)", vEvent)) { } else { MessageBox.Show("保存病历结构失败:" + emrMSDB.DB.ErrMsg); } } else { if (emrMSDB.DB.ExecSql("UPDATE Inch_RecordStructure SET structure = @structure WHERE rid = @rid", vEvent)) { } else { MessageBox.Show("保存病历结构失败:" + emrMSDB.DB.ErrMsg); } } } }
private void 查看ToolStripMenuItem_Click(object sender, EventArgs e) { if (!EMR.TreeNodeIsRecord(tvRecord.SelectedNode)) { return; } int vDesPID = -1, vDesID = -1, vRecordID = -1; GetNodeRecordInfo(tvRecord.SelectedNode, ref vDesPID, ref vDesID, ref vRecordID); if (vRecordID > 0) { int vPageIndex = GetRecordPageIndex(vRecordID); if (vPageIndex < 0) { LoadPatientRecordContent(tvRecord.SelectedNode.Tag as RecordInfo); vPageIndex = GetRecordPageIndex(vRecordID); } else { tabRecord.SelectedIndex = vPageIndex; } frmRecord vFrmRecord = null; try { vFrmRecord = GetPageRecord(vPageIndex); } finally { vFrmRecord.EmrView.ReadOnly = true; } vFrmRecord.EmrView.Trace = emrMSDB.DB.GetInchRecordSignature(vRecordID); } }
private void SaveStructureToXml(frmRecord aFrmRecord, string aFileName) { XmlDocument vXmlDoc = GetStructureToXml(aFrmRecord); vXmlDoc.Save(aFileName); }
private void DoSaveRecordContent(object sender, EventArgs e) { frmRecord vFrmRecord = sender as frmRecord; if (!vFrmRecord.EmrView.IsChanged) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("未发生变化,确定要执行保存?", "确认操作", messButton); if (dr != DialogResult.OK) { return; } } RecordInfo vRecordInfo = vFrmRecord.Tag as RecordInfo; FTraverseTags.Clear(); if (vFrmRecord.EmrView.Trace) { FTraverseTags.Add(TraverseTag.ttWriteTraceInfo); FTraverseTags.Add(TraverseTag.ttDataSetElement); } CheckRecordContent(vFrmRecord); // 检查文档质控、痕迹等问题 using (MemoryStream vSM = new MemoryStream()) { vFrmRecord.EmrView.SaveToStream(vSM); if (vRecordInfo.ID > 0) // 修改后保存 { EMRView.emrMSDB.ExecCommandEventHanler vEvent = delegate(SqlCommand sqlComm) { sqlComm.Parameters.AddWithValue("RID", vRecordInfo.ID); sqlComm.Parameters.AddWithValue("LastUserID", UserInfo.ID); sqlComm.Parameters.AddWithValue("content", vSM.GetBuffer()); }; if (emrMSDB.DB.ExecSql(emrMSDB.Sql_SaveRecordContent, vEvent)) { vFrmRecord.EmrView.IsChanged = false; SaveRecordStructure(vRecordInfo.ID, vFrmRecord, false); // 提取并保存病历结构 MessageBox.Show("保存成功!"); } else { MessageBox.Show("保存病历失败,请重试!\n" + emrMSDB.DB.ErrMsg); } } else // 保存新建的病历 { EMRView.emrMSDB.ExecCommandEventHanler vEvent = delegate(SqlCommand sqlComm) { sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.CommandText = "CreateInchRecord"; sqlComm.Parameters.AddWithValue("PatID", PatientInfo.PatID); sqlComm.Parameters.AddWithValue("VisitID", PatientInfo.VisitID); sqlComm.Parameters.AddWithValue("desid", vRecordInfo.DesID); sqlComm.Parameters.AddWithValue("Name", vRecordInfo.RecName); sqlComm.Parameters.AddWithValue("DT", vRecordInfo.DT); sqlComm.Parameters.AddWithValue("DeptID", PatientInfo.DeptID); sqlComm.Parameters.AddWithValue("CreateUserID", UserInfo.ID); sqlComm.Parameters.AddWithValue("Content", vSM.GetBuffer()); //SqlParameter parOutput = sqlComm.Parameters.Add("@RecordID", SqlDbType.Int); //parOutput.Direction = ParameterDirection.Output; SqlParameter parRetrun = new SqlParameter("@RecordID", SqlDbType.Int); parRetrun.Direction = ParameterDirection.ReturnValue; sqlComm.Parameters.Add(parRetrun); sqlComm.ExecuteNonQuery(); vRecordInfo.ID = int.Parse(parRetrun.Value.ToString()); }; if (emrMSDB.DB.ExecStoredProcedure(vEvent)) { vFrmRecord.EmrView.IsChanged = false; SaveRecordStructure(vRecordInfo.ID, vFrmRecord, true); // 提取并保存病历结构 GetPatientRecordListUI(); MessageBox.Show("保存成功!"); } else { MessageBox.Show("保存病历失败,请重试!\n" + emrMSDB.DB.ErrMsg); } } } }
private void GetRecordStructure(int aRecordID, frmRecord aFrmRecord) { }
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e) { RecordInfo vRecordInfo = null; int vTemplateID = -1; frmTemplateList vFrmTempList = new frmTemplateList(); vFrmTempList.ShowDialog(); if (vFrmTempList.DialogResult == System.Windows.Forms.DialogResult.OK) { vTemplateID = vFrmTempList.TemplateID; vRecordInfo = new RecordInfo(); vRecordInfo.DesID = vFrmTempList.DesID; vRecordInfo.RecName = vFrmTempList.RecordName; vRecordInfo.DT = vFrmTempList.RecordDateTime; } else { return; } using (MemoryStream vSM = new MemoryStream()) { emrMSDB.DB.GetTemplateContent(vTemplateID, vSM); // 取模板内容(流) TabPage vPage = null; frmRecord vFrmRecord = null; NewPageAndRecord(vRecordInfo, ref vPage, ref vFrmRecord); emrMSDB.DB.GetDataSetElement(vRecordInfo.DesID); if (vSM.Length > 0) // 模板内容不为空 { // 获取当前数据集有哪些数据可以被替换的数据 // 放到本地DataTable:FDataElementSetMacro中 PrepareSyncData(vRecordInfo.DesID); // 赋值模板加载时替换数据元内容的方法 vFrmRecord.EmrView.OnSyncDeItem = DoSyncDeItem; try { vFrmRecord.EmrView.BeginUpdate(); try { // 加载模板,加载过程会调用DoSyncDeItem // 给每一个数据元到FDataElementSetMacro中找 // 自己要替换为什么内容的机会 vFrmRecord.EmrView.LoadFromStream(vSM); // 替换数据组的内容 SyncDeGroupByStruct(vFrmRecord.EmrView); vFrmRecord.EmrView.FormatData(); vFrmRecord.EmrView.IsChanged = true; } finally { vFrmRecord.EmrView.EndUpdate(); } } finally { vFrmRecord.EmrView.OnSyncDeItem = null; } } tabRecord.SelectedTab = vPage; } }