169 lines
7.5 KiB
C#
169 lines
7.5 KiB
C#
using AIMSBLL;
|
|
using AIMSModel;
|
|
using DCSoft.Writer;
|
|
using DCSoft.Writer.Data;
|
|
using DCSoft.Writer.Dom;
|
|
using DocumentManagement;
|
|
using DrawGraph;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text.RegularExpressions;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
using System.Xml.Linq;
|
|
|
|
namespace DrawGraphManagement
|
|
{
|
|
public partial class frmPrintDocument : Form
|
|
{
|
|
public int PatientId;
|
|
public string TemplateName;
|
|
//模板Model
|
|
private PrintTemplate TModel = new PrintTemplate();
|
|
//文档Model
|
|
private PrintDocument DModel = new PrintDocument();
|
|
//患者Id
|
|
public PatientRecord Patient = new PatientRecord();
|
|
|
|
public frmPrintDocument()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void frmPrescriptionDocument_Load(object sender, EventArgs e)
|
|
{
|
|
//myEditControl初始化
|
|
myEditControl.MoveFocusHotKey = MoveFocusHotKeys.Tab;
|
|
myEditControl.HeaderFooterReadonly = true;
|
|
myEditControl.CommandControler = this.writerCommandControler1;
|
|
writerCommandControler1.Start();
|
|
//表单视图模式
|
|
myEditControl.FormView = DCSoft.Writer.Controls.FormViewMode.Strict;
|
|
//加载知识库
|
|
//DocumentDAL.LoadKBLibaray();
|
|
myEditControl.ExecuteCommand("LoadKBLibrary", false, DocumentDAL.Lib);
|
|
// 注册自定义的输入域下拉列表提供者
|
|
myEditControl.AppHost.Services.AddService(
|
|
typeof(IListItemsProvider),
|
|
new MyListItemsProvider());
|
|
//// 设置文档处于调试模式
|
|
//myEditControl.DocumentOptions.BehaviorOptions.DebugMode = true;
|
|
//myEditControl.DocumentOptions.BehaviorOptions.InsertCommentBindingUserTrack = true;
|
|
//启用逻辑删除、权限控制
|
|
myEditControl.Document.Options.SecurityOptions.EnablePermission = true;
|
|
myEditControl.Document.Options.SecurityOptions.EnableLogicDelete = true;
|
|
myEditControl.Document.Options.SecurityOptions.ShowLogicDeletedContent = true;
|
|
myEditControl.Document.Options.SecurityOptions.ShowPermissionMark = true;
|
|
myEditControl.Document.Options.SecurityOptions.ShowPermissionTip = true;
|
|
|
|
toolStrip1.Visible = true;
|
|
Patient = PatientRecord.GetPatientRecord(PatientId);
|
|
DModel = DocumentDAL.GetDocumentbyName(TemplateName, Patient.PatientId);
|
|
LoadDocument();
|
|
}
|
|
|
|
#region 文书控件事件
|
|
private void LoadDocument()
|
|
{
|
|
if (DModel.Id > 0)
|
|
{
|
|
//加载文档
|
|
DModel = DocumentDAL.GetDocumentbyId(DModel.Id);
|
|
myEditControl.LoadDocumentFromString(DModel.XmlFile, "xml");
|
|
|
|
//患者基本信息二次赋值
|
|
var query = from XTextElement in myEditControl.Document.Fields.ToArray()
|
|
where XTextElement is XTextInputFieldElement
|
|
&& (XTextElement as XTextInputFieldElement).FieldSettings != null
|
|
&& (XTextElement as XTextInputFieldElement).FieldSettings.EditStyle != InputFieldEditStyle.Date
|
|
&& (XTextElement as XTextInputFieldElement).FieldSettings.ListSource != null
|
|
select XTextElement as XTextInputFieldElement;
|
|
DataRow[] dr = DocumentDAL.GetReflectionList("V_OperationRecordALL").Select("KB_SEQ <> '' and Reload=1");
|
|
var p = typeof(PatientRecord).GetProperties();
|
|
for (int i = 0; i < dr.Count(); i++)
|
|
{
|
|
var name = dr[i].ItemArray[0].ToString();
|
|
var value = dr[i].ItemArray[1].ToString();
|
|
XTextInputFieldElement element = query.Where(x => x.FieldSettings.ListSource.SourceName == value).FirstOrDefault();
|
|
PropertyInfo info = p.Where(px => px.Name == name).FirstOrDefault();
|
|
if (element != null && info != null)
|
|
{
|
|
element.Text = info.GetValue(Patient, null).ToString();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//无文档则加载模板
|
|
TModel = DocumentDAL.GetTemplatebyId(DModel.TemplateId);
|
|
if (TModel.XmlFile == null || TModel.XmlFile.Trim().Equals(string.Empty))
|
|
{
|
|
myEditControl.ExecuteCommand("FileNew", true, null);
|
|
}
|
|
else
|
|
{
|
|
myEditControl.LoadDocumentFromString(TModel.XmlFile, "xml");
|
|
}
|
|
DModel.XmlFileName = TModel.XmlFileName;
|
|
DModel.TemplateId = TModel.Id;
|
|
//患者基本信息赋值
|
|
var query = from XTextElement in myEditControl.Document.Fields.ToArray()
|
|
where XTextElement is XTextInputFieldElement
|
|
&& (XTextElement as XTextInputFieldElement).FieldSettings != null
|
|
&& (XTextElement as XTextInputFieldElement).FieldSettings.EditStyle != InputFieldEditStyle.Date
|
|
&& (XTextElement as XTextInputFieldElement).FieldSettings.ListSource != null
|
|
select XTextElement as XTextInputFieldElement;
|
|
DataRow[] dr = DocumentDAL.GetReflectionList("V_OperationRecordALL").Select("KB_SEQ <> ''");
|
|
var p = typeof(PatientRecord).GetProperties();
|
|
for (int i = 0; i < dr.Count(); i++)
|
|
{
|
|
var name = dr[i].ItemArray[0].ToString();
|
|
var value = dr[i].ItemArray[1].ToString();
|
|
XTextInputFieldElement element = query.Where(x => x.FieldSettings.ListSource.SourceName == value).FirstOrDefault();
|
|
PropertyInfo info = p.Where(px => px.Name == name).FirstOrDefault();
|
|
if (element != null && info != null)
|
|
{
|
|
element.Text = info.GetValue(Patient, null).ToString();
|
|
}
|
|
}
|
|
|
|
DocumentExtension.SetDocumentDefaultValue(TModel.XmlFileName, myEditControl.Document, Patient);
|
|
}
|
|
|
|
//文档用户信息
|
|
myEditControl.UserLoginByParameter(
|
|
AIMSExtension.PublicMethod.OperatorNo,
|
|
AIMSExtension.PublicMethod.OperatorName,
|
|
AIMSExtension.PublicMethod.PermissionLevel);
|
|
//隐藏痕迹先
|
|
myEditControl.ExecuteCommand(StandardCommandNames.CleanViewMode, false, true);
|
|
|
|
}
|
|
#endregion
|
|
private void tsbAdd_Click(object sender, EventArgs e)
|
|
{
|
|
myEditControl.ExecuteCommand("FilePrint", true, null);
|
|
|
|
}
|
|
private void tsbExit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
public string PrintDocument()
|
|
{
|
|
string docName = TemplateName + "_" + Patient.MdrecNo + "_" + Patient.PatientId;
|
|
//myEditControl.ExecuteCommand("FilePrint", true, null);
|
|
var outputFilePath = @"E:\PatientDocuments\" +docName + ".pdf";
|
|
myEditControl.SaveDocument(outputFilePath, "pdf");
|
|
return docName;
|
|
}
|
|
}
|
|
}
|