private string Xml(string xmlName, string ReportName, string ClientName,string organId)
{
string filename = ConfigurationManager.AppSettings["SavePath"] +"xml\\"+ xmlName + ".xml";
//XmlDocument doc = new XmlDocument();
//doc.Load(path);
//doc.Save(path);
XmlDocument xmldoc = new XmlDocument();
XmlNode node;
try
{
node = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
xmldoc.AppendChild(node);
XmlNode root = xmldoc.CreateElement("Request");
xmldoc.AppendChild(root);
XmlNode root1 = xmldoc.CreateElement("MessageHeader");
root.AppendChild(root1);
CreateNode(xmldoc, root1, "Sender", "LIS-1");
CreateNode(xmldoc, root1, "Receiver", "DCIS");
CreateNode(xmldoc, root1, "SendTime", DateTime.Now.ToString("yyyyMMddHHmmss"));
CreateNode(xmldoc, root1, "EventType", "REPORT_UPLOAD");
CreateNode(xmldoc, root1, "MsgId", HealthGuid.newGuid());
XmlNode root2 = xmldoc.CreateElement("MessageBody");
root.AppendChild(root2);
XmlNode root3 = xmldoc.CreateElement("ReportInfo");
root2.AppendChild(root3);
Random rd = new Random();
CreateNode(xmldoc, root3, "PatientId", rd.Next(100000000).PaseToString());//患者id不能小于5或大于10,只能是大写字母或者数字
CreateNode(xmldoc, root3, "VisitId", "1");
CreateNode(xmldoc, root3, "PatientSource", "3");
CreateNode(xmldoc, root3, "OrgCode", organId);//不能为空--就诊机构编码
CreateNode(xmldoc, root3, "Name", ClientName);
CreateNode(xmldoc, root3, "ReportFlow", HealthGuid.newGuid());
CreateNode(xmldoc, root3, "ReportClassBelong", "C");//不能为空
CreateNode(xmldoc, root3, "ReportClass", "LAB");//不能为空
CreateNode(xmldoc, root3, "ReportName", ReportName);
CreateNode(xmldoc, root3, "PublishDate", DateTime.Now.ToString("yyyyMMddHHmmss"));
CreateNode(xmldoc, root3, "ValidDateTimeFrom", DateTime.Now.ToString("yyyyMMddHHmmss"));
CreateNode(xmldoc, root3, "PageOrention", "V");
CreateNode(xmldoc, root3, "PageSize", "A4");
CreateNode(xmldoc, root3, "PageCount", "4");
CreateNode(xmldoc, root3, "PublishSystem", "发布系统标识");
CreateNode(xmldoc, root3, "PerformedBy", "发布科室");
CreateNode(xmldoc, root3, "ApplyFlow", rd.Next(100000000).PaseToString());//不能为空
CreateNode(xmldoc, root3, "Memo", "");
CreateNode(xmldoc, root3, "ImageFlow", "");
xmldoc.Save(filename);
}
catch (Exception e)
{
e.ToLog();
}
return filename;
// return ConfigurationManager.AppSettings["AccessPath"] + "\\" + "xml\\" + xmlName + ".xml";
}
///
/// 创建节点
///
///
///
///
///
public void CreateNode(XmlDocument xmldoc, XmlNode parentnode, string name, string value)
{
XmlNode node = xmldoc.CreateNode(XmlNodeType.Element, name, null);
node.InnerText = value;
parentnode.AppendChild(node);
}