public void SetEditModes() { switch (editModes) { case EmrConstant.NoteEditMode.Nothing: emrTaskPane.SetReadonly(); break; case EmrConstant.NoteEditMode.Checking: emrTaskPane.SetRevision2(); //Globals.ThisAddIn.SetRevisionColor("审核者"); break; case EmrConstant.NoteEditMode.FinallyCkecking: emrTaskPane.SetRevision2(); //Globals.ThisAddIn.SetRevisionColor("终身者"); break; case EmrConstant.NoteEditMode.Writing: if (ThisAddIn.CanOption(ElementNames.chxTrace) == true && Globals.Isfanxiu) { emrTaskPane.SetRevision2(); Globals.Isfanxiu = false; } else { emrTaskPane.SetReadWrite(); } break; case EmrConstant.NoteEditMode.Reading: emrTaskPane.SetReadonly(); break; } }
private void timer1_Tick(object sender, EventArgs e) { if (ThisAddIn.CanOption(ElementNames.UKey)) { IsUkey(); } }
public CSelectP(MainForm etp) { InitializeComponent(); emrTaskPane = etp; this.Location = new Point(450, 120); if (ThisAddIn.CanOption(ElementNames.ArchiveDepartment)) { cboQy.Enabled = !Globals.ArchiveDepartment; string str = ThisAddIn.CanOptionText(ElementNames.ArchiveDepartmentText).Trim(); if (ThisAddIn.CanOption(ElementNames.ArchiveDepartment) && ThisAddIn.CanOptionText(ElementNames.ArchiveDepartmentText).Trim() != "") { if (str.Contains(",") == true) { string[] strlist = str.Split(','); foreach (string strEach in strlist) { if (strEach.Trim() == Globals.OpDepartID) { cboQy.Enabled = true; cboHz.Enabled = true; return; } else { cboQy.Enabled = false; cboHz.Enabled = false; } return; } } } } }
public static void InitForNonQC() { /* Init auditSystem and auditLevelSystem */ GetAuditSys(); /* Lock emrDocuments for discharged patients */ if (!Globals.offline && ThisAddIn.CanOption(ElementNames.AutoArchive)) { Archive(Today(), null); } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtPassword.Text == "") { return; } if (ThisAddIn.CanOption(ElementNames.UKey)) { IsUkey(); return; } if (lblUserName.Text.Trim() != "" && txtPassword.Text == passwd) { Globals.DoctorID = txtUserCode.Text; Globals.OpDepartID = departmentCode; Globals.DoctorName = lblUserName.Text; // Globals.AreaID = ThisAddIn.GetAreaID(departmentCode); XmlNode Config = null; string msg = ThisAddIn.GetConfig(ref Config); if (msg == null || msg == "") { Globals.Config = Config; RetrieveMyroles(txtUserCode.Text); //ThisAddIn.RetrieveMyrolesHIS(txtUserCode.Text); this.DialogResult = DialogResult.OK; txtPassword.Text = ""; txtUserCode.Text = ""; lblUserName.Text = ""; lblDepartment.Text = ""; txtUserCode.Focus(); this.Hide(); if (Globals.WriteOff) { MainForm m = new MainForm(); m.Show(); Globals.WriteOff = false; } return; } MessageBox.Show(msg); this.DialogResult = DialogResult.Cancel; this.Close(); } else { MessageBox.Show("无效的用户名或密码!"); txtUserCode.Text = ""; txtPassword.Text = ""; departmentCode = ""; lblUserName.Text = ""; departName = ""; } }
private void Passed() { if (ThisAddIn.CanOption(ElementNames.OperatorDepartment)) { ThisAddIn.ChangeDepartment(departmentCode); } // Globals.qualityInfo = Globals.myConfig.GetShowQCI(txtUserCode.Text); if (Globals.inStyle) { // Globals.QualityInfo(txtUserCode.Text.Trim()); } }
public bool UncommitEmrNote(int series, XmlNode reasion) { XmlNode emrNote = GetEmrNoteBySeries(series); if (emrNote == null) { return(Return.Failed); } int status = Convert.ToInt32(emrNote.Attributes[AttributeNames.NoteStatus].Value) - 1; if (ThisAddIn.UncommitEmrNote( emrDoc.DocumentElement.GetAttribute(AttributeNames.RegistryID), emrNote.Attributes[AttributeNames.NoteID].Value, series, reasion, (NoteStatus)status) == Return.Failed) { return(Return.Failed); } //XmlElement noteDoc = emrDoc.CreateElement(ElementNames.EmrNote); if (ThisAddIn.CanOption(ElementNames.chxTrace) == true && emrNote.Attributes["fanxiu"] == null) { ThisAddIn.fanxiu(emrDoc.DocumentElement.GetAttribute(AttributeNames.RegistryID), series); XmlAttribute fanxiu = emrNote.OwnerDocument.CreateAttribute("fanxiu"); emrNote.Attributes.Append(fanxiu); emrNote.Attributes["fanxiu"].Value = "Yes"; } emrNote.Attributes[AttributeNames.NoteStatus].Value = status.ToString(); string LastWriteTime = ThisAddIn.Today().ToFileTime().ToString(); emrNote.Attributes[AttributeNames.LastWriteTime].Value = LastWriteTime; emrDoc.DocumentElement.SetAttribute(AttributeNames.LastWriteTime, LastWriteTime); emrNote.OwnerDocument.Save(emrDocFile); udt.jj.EncodeEmrDocument(emrDocFile); return(Return.Successful); }
private void IsUkey() { string strS = ""; using (gjtEmrService.emrServiceXml es = new gjtEmrService.emrServiceXml()) { strS = es.GetIsKeyUser(Globals.DoctorID); } if (ThisAddIn.CanOption(ElementNames.UKey) == true && strS.Trim() == "1") { this.cboCertNew.Visible = true; //this.label3.Visible = true; cboCertNew.Items.Clear(); string strPath = Globals.currentDirectory; X509Store store = new X509Store("MY", StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); X509Certificate2Collection filterCerts = store.Certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, false); String CN = ""; foreach (X509Certificate2 x509 in filterCerts) { CVM cvm = CVM.GetInstance(); string configFileName = strPath + @"cvm.xml"; cvm.config(configFileName); CertificateStatus ret = cvm.VerifyCertificate(x509); if (ret == CertificateStatus.VALID) { String subjectname = x509.Subject; String[] names = subjectname.Split(','); foreach (String name in names) { if (name.IndexOf("CN=") > 0) { cboCertNew.Visible = true; int begin = name.IndexOf("CN="); int len = name.Length; CN = name.Substring(4, len - 4); cboCertNew.Items.Add(CN); //cboCertificate.Items.Add(CN); } } } else { cboCertNew.Visible = false; } } if (CN.Equals("") || CN == null) { // MessageBox.Show("没有有效的证书,请联系管理员!"); } store.Close(); //try //{ // if (cboCertificate.Items.Count != 0) // { // cboCertificate.Text = cboCertificate.Items[0].ToString(); // cboCertNew.Text = cboCertificate.Items[0].ToString(); // cboCertNew.SelectedIndex = 0; // } // cboCertNew.Focus(); //} //catch (Exception ex) //{ //} } }
public bool UpdateEmrNote(int series, NoteStatus noteStatus, ref NoteStatus noteStatusEnd, bool CommitFlag) { noteStatusEnd = noteStatus; /* Confirm the note exists. */ XmlNode emrNote = GetEmrNoteBySeries(series); if (emrNote == null) { return(Return.Failed); } /* word window to word document */ string tmpfile = Path.Combine(Globals.currentDirectory, ResourceName.Mytmp); //udt.jj.SaveWordDoc(ThisAddIn.Application.ActiveDocument, tmpfile, false); #region Update the emrDocument in dadabase /* Package the word document into a xml elelement. */ XmlNode noteDoc = emrDoc.CreateElement(ElementNames.EmrNote); noteDoc.InnerText = udt.jj.WordDocumentToString(tmpfile); string registryID = emrDoc.DocumentElement.GetAttribute(AttributeNames.RegistryID); /* Update the dadabase. */ if (!Globals.offline) { using (gjtEmrService.emrServiceXml es = new gjtEmrService.emrServiceXml()) { try { string strResult = es.IsEnabledCommit(registryID, series); if (strResult == "0") { noteStatusEnd = NoteStatus.Draft; if (CommitFlag == true) { MessageBox.Show("已经超时提交过的文档不能再次提交,请与质管部门联系!", ErrorMessage.Warning, MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } else { emrNote.Attributes["NoteStatus"].Value = (Convert.ToInt32(noteStatusEnd)).ToString(); if ((Convert.ToInt32(noteStatusEnd)).ToString() == "1" && ThisAddIn.CanOption(ElementNames.CommitTime)) { if (emrNote.Attributes["fanxiu"] == null || emrNote.Attributes["fanxiu"].Value == "No") { emrNote.Attributes[AttributeNames.WrittenDate].Value = ThisAddIn.Today().ToString(); } } } } catch (Exception ex) { Globals.logAdapter.Record("EX741852968", ex.Message + ">>" + ex.ToString(), true); } } if (ThisAddIn.UpdateOneEmrNote(registryID, emrNote, noteDoc) == Return.Failed) { return(Return.Failed); } } else { OpDone opDone = new OpDone("离线,寄存失败!"); opDone.Show(); return(Return.Failed); } #endregion #region Update the local storage string noteID = emrNote.Attributes[AttributeNames.NoteID].Value; string wdDocName = udt.MakeWdDocumentFileName(registryID, noteID, series, Globals.workFolder); File.Copy(tmpfile, wdDocName, true); if (Globals.localDocumentEncode) { udt.jj.EncodeEmrDocument(wdDocName); } string LastWriteTime = ThisAddIn.Today().ToFileTime().ToString(); emrNote.Attributes[AttributeNames.NoteStatus].Value = noteStatus.ToString("d"); emrNote.Attributes[AttributeNames.LastWriteTime].Value = LastWriteTime; emrDoc.DocumentElement.SetAttribute(AttributeNames.LastWriteTime, LastWriteTime); emrDoc.Save(emrDocFile); udt.jj.EncodeEmrDocument(emrDocFile); #endregion return(Return.Successful); }
/* ------------------------------------------------------------------------ * Return 0 Successful * -1 fatal error * -2 no continue operation * -3 read only * ------------------------------------------------------------------------- */ public int Create(string registryID, string archive) { int returnState = 0; archiveNum = archive; #region In offline if (Globals.offline) { string tmpfile = DocFile(registryID); emrDoc.Load(tmpfile); File.Delete(tmpfile); return(returnState); } #endregion using (gjtEmrService.emrServiceXml es = new gjtEmrService.emrServiceXml()) { #region Get emrDocument and emrNotes XmlNode node = emrDoc.DocumentElement; XmlNode emrNotes = emrDoc.CreateElement(EmrConstant.ElementNames.EmrNotes); Boolean ret; try { string machineName = Globals.localMachineName; string machineIP = Globals.localMachineIP; string msg = es.SetTrafficLightToRed(registryID, ref machineIP, ref machineName); if (msg != null) { if (machineIP.Trim() != Globals.localMachineIP.Trim()) { string error = "病历被他人打开编辑中,一般不要同时操作同一病历\r\rIP地址:" + machineIP + "\r\r主机名:" + machineName; if (!ThisAddIn.CanOption(ElementNames.ContinueAsEmrOpened)) { error += "\r\r进入只读状态!!!"; MessageBox.Show(error, ErrorMessage.Warning); returnState = -3; } } } ret = es.GetEmrDocument(registryID, ref node, ref emrNotes); } catch (Exception ex) { Globals.logAdapter.Record("EX741852967", ex.Message + ">>" + ex.ToString(), true); return(-1); } if (ret == EmrConstant.Return.Failed) { MessageBox.Show(ErrorMessage.WebServiceError, ErrorMessage.Error); return(-1); } #endregion #region Check if local documents are newer than in database if (Globals.autoCheckSync && !ThisAddIn.CanOption(ElementNames.ContinueAsEmrOpened)) { DateTime localLwt = DateTime.Now; if (ThisAddIn.HasNotesInLocal(registryID, ref localLwt)) { long lastWriteTime = 0; if (node.Attributes[AttributeNames.LastWriteTime] != null) { lastWriteTime = Convert.ToInt64(node.Attributes[AttributeNames.LastWriteTime].Value); } DateTime remoteLwt = DateTime.FromFileTime(lastWriteTime); if (localLwt.CompareTo(remoteLwt) > 0) { DialogResult dr = MessageBox.Show("本地病历记录比数据库的更新:\r\r本地:" + localLwt.ToString() + " 数据库:" + remoteLwt.ToString() + "\r\r同步为本地病历吗?\r如果选择同步应十分小心,要确认本地病历确实是最新的。" + "\r因为有时因各机器时钟不一致,可能造成假象。一旦同步成功,不能恢复!", ErrorMessage.Warning, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dr == DialogResult.Yes) { #region Do synchronization string msg = ThisAddIn.SynchronizeOne(registryID, archiveNum, node); if (msg == null) { emrDocFile = udt.MakeEmrDocumentFileName(registryID, Globals.workFolder); string tmpfile = Path.Combine(Globals.currentDirectory, ResourceName.Mytmp); if (File.Exists(tmpfile)) { File.Delete(tmpfile); } udt.jj.DecodeEmrDocument(emrDocFile, tmpfile); emrDoc.Load(tmpfile); return(returnState); } MessageBox.Show(msg, ErrorMessage.Error); return(-1); #endregion } else if (dr == DialogResult.Cancel) { return(-2); } } } } #endregion #region Create local storage for documents. string docLocation = ThisAddIn.GetDocLocation(registryID); foreach (XmlNode emrNote in emrNotes) { string noteDoc = udt.MakeWdDocumentFileName(docLocation, emrNote.Attributes[0].Value); udt.jj.StringToWordDocument(noteDoc, emrNote); if (emrNote.InnerText.Length >= 2 && emrNote.InnerText.Substring(0, 2) == "UE") { if (Globals.localDocumentEncode) { udt.jj.EncodeEmrDocument(noteDoc); } } else { if (!Globals.localDocumentEncode) { string tmpfile = Path.Combine(Globals.currentDirectory, ResourceName.Mytmp); udt.jj.DecodeEmrDocument(noteDoc, tmpfile); File.Delete(noteDoc); File.Move(tmpfile, noteDoc); } } } emrDoc.LoadXml(node.OuterXml); emrDocFile = udt.MakeEmrDocumentFileName(registryID, Globals.workFolder); emrDoc.Save(emrDocFile); udt.jj.EncodeEmrDocument(emrDocFile); return(returnState); #endregion } }
public void DrawAuthor2(AuthorInfo authorInfo) { Word.WdColor fontColor = Globals.headerFontColor; float fontSize = Globals.headerFontSize; int len = 0; #region Writter Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range; string writer = writerLable + authorInfo.Writer; if (writerLable == string.Empty) { writer = writerLable; } range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End; Word.ContentControl ccNull = emrTaskPane.AddSubTitle(range, " ", Word.WdColor.wdColorWhite); ccNull.Title = StringGeneral.Label; // as end of emrNote content ccNull.Tag = StringGeneral.RemoveFlag; ccNull.LockContents = false; if (writer.Length > 1) { if (ThisAddIn.CanOption(ElementNames.ManualSign)) { writer = writer + StringGeneral.SignSpace; } if (!ThisAddIn.CanOption(ElementNames.ShowWriter)) { writer = " "; } if (!ThisAddIn.CanOption(ElementNames.AutoSign)) { writer = writerLable + StringGeneral.SignSpace; } range.Start = ccNull.Range.End + 1; ccWriter = emrTaskPane.AddContentControlTextRight(range, Globals.space6 + writer, null, false, fontSize, fontColor); ccWriter.Tag = StringGeneral.RemoveFlag; // as a note template, it will be removed ccWriter.Title = AttributeNames.Writer; ccWriter.Range.Font = Globals.contentFont; range.Start = ccWriter.Range.End + 1; //if (Globals.EncryptSign == true) //{ // ccWriter.Range.Text = ccWriter.Range.Text.Trim(); // emrTaskPane.ThisAddIn.CanOption(ElementNames.ShowWriter)Sign(range, fontSize, fontColor, "WSign"); //} ccWriter.LockContentControl = true; ccWriter.LockContents = true; string writtenDate = " "; if (ThisAddIn.CanOption(ElementNames.ShowWritenDate)) { writtenDate += authorInfo.WrittenDate; } ccWrittenDate = emrTaskPane.AddContentControlTextRight(range, writtenDate, null, false, fontSize, fontColor); ccWrittenDate.Tag = StringGeneral.RemoveFlag; ccWrittenDate.Title = AttributeNames.WrittenDate; ccWrittenDate.Range.Font = Globals.contentFont; ccWrittenDate.LockContentControl = true; ccWrittenDate.LockContents = true; len += ccWriter.Range.Text.Length + ccWrittenDate.Range.Text.Length; } #endregion #region Checker string checker = checkerLable + authorInfo.Checker; if (checkerLable == string.Empty) { checker = checkerLable; } if (checker.Length > 0) { if (ThisAddIn.CanOption(ElementNames.ManualSign)) { checker = checker + StringGeneral.SignSpace; } if (!ThisAddIn.CanOption(ElementNames.ShowWriter)) { checker = " "; } if (!ThisAddIn.CanOption(ElementNames.AutoSign)) { checker = checkerLable + StringGeneral.SignSpace; } range.Start = ccWriter.Range.Start - 1; range.End = range.Start; ccChecker = emrTaskPane.AddContentControlTextRight(range, Globals.space6 + checker, null, false, fontSize, fontColor); ccChecker.Tag = StringGeneral.RemoveFlag; // as a note template, it will be removed ccChecker.Title = AttributeNames.Checker; ccChecker.Range.Font = Globals.contentFont; ccChecker.LockContentControl = true; ccChecker.LockContents = true; range.Start = ccChecker.Range.End + 1; string checkedDate = " "; if (ThisAddIn.CanOption(ElementNames.ShowWritenDate)) { checkedDate += authorInfo.CheckedDate; } ccCheckedDate = emrTaskPane.AddContentControlTextRight(range, checkedDate, null, false, fontSize, fontColor); ccCheckedDate.Tag = StringGeneral.RemoveFlag; // as a note template, it will be removed ccCheckedDate.Title = AttributeNames.CheckedDate; ccCheckedDate.Range.Font = Globals.contentFont; ccCheckedDate.LockContentControl = true; ccCheckedDate.LockContents = true; len += ccChecker.Range.Text.Length + ccCheckedDate.Range.Text.Length; } #endregion #region FinalChecker string finalChecker = finalCheckerLable + authorInfo.FinalChecker; if (finalCheckerLable == string.Empty) { finalChecker = finalCheckerLable; } if (finalChecker.Length > 0) { if (ThisAddIn.CanOption(ElementNames.ManualSign)) { finalChecker = finalChecker + StringGeneral.SignSpace; } if (!ThisAddIn.CanOption(ElementNames.ShowWriter)) { finalChecker = " "; } if (!ThisAddIn.CanOption(ElementNames.AutoSign)) { finalChecker = finalCheckerLable + StringGeneral.SignSpace; } if (ccChecker == null) { range.Start = ccWriter.Range.Start - 1; } else { range.Start = ccChecker.Range.Start - 1; } range.End = range.Start; ccFinalChecker = emrTaskPane.AddContentControlTextRight(range, finalChecker, null, false, fontSize, fontColor); ccFinalChecker.Tag = StringGeneral.RemoveFlag; // as a note template, it will be removed ccFinalChecker.Title = AttributeNames.FinalChecker; ccFinalChecker.Range.Font = Globals.contentFont; ccFinalChecker.LockContentControl = true; ccFinalChecker.LockContents = true; range.Start = ccFinalChecker.Range.End + 1; string finalCheckedDate = " "; if (ThisAddIn.CanOption(ElementNames.ShowWritenDate)) { finalCheckedDate += authorInfo.FinalCheckedDate; } ccFinalCheckedDate = emrTaskPane.AddContentControlTextRight(range, finalCheckedDate, null, false, fontSize, fontColor); ccFinalCheckedDate.Tag = StringGeneral.RemoveFlag; // as a note template, it will be removed ccFinalCheckedDate.Title = AttributeNames.FinalCheckedDate; ccFinalCheckedDate.Range.Font = Globals.contentFont; ccFinalCheckedDate.LockContentControl = true; ccFinalCheckedDate.LockContents = true; len += ccFinalChecker.Range.Text.Length + ccFinalCheckedDate.Range.Text.Length; } #endregion /////guojt test sourcesafe //int padSpace = Globals.countPerLine - len; //if (Globals.auditSystem == AuditSystem.A1) //{ // for (int i = 0; i < padSpace; i++) ccNull.Range.Text += " "; //} }
private void LoadData() { try { if (!Directory.Exists(Globals.workFolder)) { Directory.CreateDirectory(Globals.workFolder); File.SetAttributes(Globals.workFolder, FileAttributes.Hidden); } if (!Directory.Exists(Globals.templateFolder)) { Directory.CreateDirectory(Globals.templateFolder); } #region Check if offline string serverName = ""; try { serverName = ThisAddIn.CheckOffline(); } catch (Exception ex) { Globals.logAdapter.Record("EX756987457750", ex.Message + ">>" + ex.ToString(), true); } if (Globals.offline) { MessageBox.Show(serverName + ErrorMessage.OfflineAgain, ErrorMessage.Warning); } #endregion //#region Get current version number //string manifest = Path.Combine(Globals.currentDirectory, "EMR.vshost.exe.config"); //using (XmlReader reader = XmlReader.Create(manifest)) //{ // reader.ReadToFollowing("assemblyIdentity"); // Globals.currentVersion = reader.GetAttribute("version"); // reader.Close(); //} //#endregion //Globals.currentVersion = Application.ProductVersion; //#region Is there new version //if (!Globals.offline) //{ // CheckVersion cv = new CheckVersion(); // if (cv.IsThereHigherVersion(Globals.currentVersion)) // { // if (MessageBox.Show("有 S2012 的更新版本发布,下载吗?\n\n下载完毕,自动退出程序;\n需要重新启动Word 2007!", // EmrConstant.ErrorMessage.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Question, // MessageBoxDefaultButton.Button1) == DialogResult.Yes) // { // if (!Directory.Exists(Globals.newVersionFolder)) Directory.CreateDirectory(Globals.newVersionFolder); // string msg = cv.DownloadNewVersion(Globals.newVersionFolder); // if (msg != null) // { // if (msg != EmrConstant.ErrorMessage.NoNewVersion) // MessageBox.Show(msg, EmrConstant.ErrorMessage.Warning); // } // else // { // /* Download success */ // #region Replace the old with the new // string[] components; // cv.GetComponentList(out components); // for (int i = 0; i < components.Length; i++) // { // string destinationFile = Path.Combine(Globals.currentDirectory, components[i]); // string oldFile = destinationFile + ".old"; // string sourceFile = ""; // sourceFile = Path.Combine(Globals.newVersionFolder, components[i]); // if (File.Exists(oldFile)) File.Delete(oldFile); // File.Move(destinationFile, oldFile); // File.Move(sourceFile, destinationFile); // } // #endregion // // ExitWord(); // } // } // } //} //#endregion Globals.emrPatternFile = Path.Combine(Globals.currentDirectory, ResourceName.EmrPatternXml); Globals.ChildPatternFile = Path.Combine(Globals.currentDirectory, ResourceName.ChildPatternXml); #region Environment configuration string myConfigFile = Path.Combine(Globals.currentDirectory, ResourceName.MyConfigXml); string configString = Properties.Resources.ResourceManager.GetString("myconfig"); Globals.myConfig = new MyConfig(myConfigFile, configString); string dpCode = Globals.myConfig.GetDepartmentCode(); Globals.AreaID = Globals.myConfig.GetAreaCode(); #endregion /* Local parameters */ //GetLocalOptionValues(); /* Global parameters */ ThisAddIn.GetOptionValues(); /* Create local storage */ ThisAddIn.CreateWorkFolders(EmrConstant.CreateWorkFolderMode.Build); if (Globals.offline) { Globals.emrPattern = new EmrPattern(Globals.emrPatternFile, null, ThisAddIn.PutPattern); Globals.childPattern = new EmrPattern(Globals.ChildPatternFile, null, ThisAddIn.PutChildPattern); } else { Globals.emrPattern = new EmrPattern(Globals.emrPatternFile, ThisAddIn.GetRules(), ThisAddIn.PutPattern); Globals.childPattern = new EmrPattern(Globals.ChildPatternFile, null, ThisAddIn.PutChildPattern); } //InitTem(); #region Get local machine name and ip address Globals.localMachineName = Environment.MachineName; System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(Globals.localMachineName); byte[] bytes = ips[0].GetAddressBytes(); Globals.localMachineIP = bytes[0].ToString() + "." + bytes[1].ToString() + "." + bytes[2].ToString() + "." + bytes[3].ToString(); #endregion #region Get hospital name if (Globals.offline) { Globals.hospitalName = Globals.myConfig.GetHospitalName(); } else { using (gjtEmrPatients.emrPatients ep = new gjtEmrPatients.emrPatients()) { try { Globals.hospitalName = ep.GetHospitalName(); Globals.myConfig.SetHospitalName(Globals.hospitalName); } catch (Exception ex) { Globals.logAdapter.Record("EX756987457751", ex.Message + ">>" + ex.ToString(), true); Globals.hospitalName = " "; } } } #endregion lblStatus.Text = "正在进行初始化..."; ThisAddIn.logon = new Logon(); #region Use windows identity if (ThisAddIn.CanOption(ElementNames.UseDigitalSign)) { System.Security.Principal.WindowsIdentity user = System.Security.Principal.WindowsIdentity.GetCurrent(); string[] items = user.Name.Split(EmrConstant.Delimiters.Slash); string code = items[items.Length - 1]; Globals.tmpFolder = "C:\\" + code; string passwd = null; string userName = null; using (gjtEmrPatients.emrPatients pi = new gjtEmrPatients.emrPatients()) { pi.AuthenticChek(code, ref userName, ref passwd); } if (userName != null) { ThisAddIn.logon.InternalPassed(code, userName); return; } } #endregion ThisAddIn.InitRoles(configString); ThisAddIn.InitForNonQC(); #region Init note fonts //SetFonts(configString); //GetLabelFont(); //GetHeaderFont(); //GetNoteNameFont(); //GetContentFont(); #endregion Globals.doctors = new Doctors(Globals.doctorsFile); Globals.departments = new Departments(Globals.departmentFile); Globals.icd10File = Path.Combine(Globals.templateFolder, Globals.icd10File); if (!Globals.offline) { DataSet dsicd = ThisAddIn.GetIcd10(); if (dsicd != null) { dsicd.WriteXml(Globals.icd10File); } } } catch (Exception ex) { Globals.logAdapter.Record("EX756987457752", ex.Message + ">>" + ex.ToString(), true); } this.Close(); this.Dispose(); }
public bool ElementFromBookmarks(XmlElement emrNote, Boolean newNote, EmrConstant.Button button) { if (!newNote) { for (int k = emrNote.ChildNodes.Count - 1; k >= 0; k--) { emrNote.RemoveChild(emrNote.ChildNodes[k]); } } string RegistryID = emrNote.OwnerDocument.ChildNodes[0].Attributes[EmrConstant.AttributeNames.RegistryID].Value; if (ThisAddIn.CanOption(ElementNames.EHRInterface) == true) { #region 定义健康档案接口变量 string PatientID = ""; string StateIn = ""; string DiagnosisIn = ""; string Treatment = ""; string StateOut = ""; string DiagnosisOut = ""; string OrderOut = ""; string ResidentPhysician = ""; string PhysicianInCharge = ""; string Department = ""; string Bah = ""; string zyh = ""; DateTime AdmitDateTime = new DateTime(); DateTime OutDateTime = new DateTime(); #endregion string Hospital = "东方地球物理公司第二职工医院"; using (gjtEmrPatients.emrPatients ep = new gjtEmrPatients.emrPatients()) try { DataSet dst = ep.GetPatientInf(RegistryID); PatientID = dst.Tables[0].Rows[0]["sfzh"].ToString(); //Department = dst.Tables[0].Rows[0]["ksbm"].ToString(); Bah = dst.Tables[0].Rows[0]["bah"].ToString(); zyh = dst.Tables[0].Rows[0]["zyh"].ToString(); AdmitDateTime = Convert.ToDateTime(dst.Tables[0].Rows[0]["zyrq"].ToString()); OutDateTime = Convert.ToDateTime(dst.Tables[0].Rows[0]["cyrq"].ToString()); if (PatientID == null || PatientID == "") { Globals.health = false; } } catch (Exception ex) { Globals.logAdapter.Record("EX741852968", ex.Message + ">>" + ex.ToString(), true); } if (PatientID == null || PatientID == "") { Globals.health = false; } if (Globals.health == true) { foreach (Word.XMLNode xn in ActiveDocumentManager.getDefaultAD().XMLNodes) { string content = xn.BaseName; switch (content) { case "科室": Department = xn.Range.Text.Trim(); break; case "入院情况": StateIn = xn.Range.Text.Trim(); break; case "入院诊断": DiagnosisIn = xn.Range.Text.Trim(); break; case "诊疗经过": Treatment = xn.Range.Text.Trim(); break; case "出院情况": StateOut = xn.Range.Text.Trim(); break; case "出院诊断": DiagnosisOut = xn.Range.Text.Trim(); break; case "出院医嘱": OrderOut = xn.Range.Text.Trim(); break; case "住院医师": if (xn.Range.Text != null) { ResidentPhysician = xn.Range.Text.Trim(); } break; case "医师": PhysicianInCharge = Globals.DoctorName; break; default: break; } } } if (Globals.health == true) { //WebReference.Hiss h = new WebReference.Hiss(); //{ // try // { // int result = h.Insert_InpatientInfo_EMR(PatientID, AdmitDateTime, OutDateTime, zyh, StateIn, DiagnosisIn, Treatment, StateOut, DiagnosisOut, OrderOut, // ResidentPhysician, PhysicianInCharge, Department, Hospital, Bah, ref err); // result++; // } // catch (Exception ex) // { // } //} Globals.health = false; } } Word.ContentControl title = null; Word.ContentControl titleNext = null; Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.First.Range; ArrayList lables = new ArrayList(); foreach (Word.ContentControl lable in ActiveDocumentManager.getDefaultAD().ContentControls) { if (lable.Title == StringGeneral.Label) { lables.Add(lable); } else if (lable.Title == StringGeneral.Control) { //lable.LockContentControl = false; //lable.LockContents = false; //lable.Delete(false); } } #region Check empty subtitle /* If the content of a subtitle is empty, you should delete it, otherwise, the insignificant * value of a xml element will be removed by sql 2005 for a xml column. */ if (button == EmrConstant.Button.CommitNote) { /* When commit note, required subtitle must not be empty. */ for (int i = lables.Count - 1; i > 0; i--) { title = (Word.ContentControl)lables[i - 1]; string required = title.Tag.ToString(); titleNext = (Word.ContentControl)lables[i]; range.Start = title.Range.End + 1; range.End = titleNext.Range.Start - 1; //20100128 if (required == StringGeneral.Yes) { if (range.Text != null) { //if (range.Text.Contains("选择一项")) //{ // MessageBox.Show(title.Range.Text + " -- 是必须要填写的!", ErrorMessage.Warning); // range.Select(); // return Return.Failed; //} } } if (!IsSignificant(range.Text)) { #region Empty subtitle if (required == StringGeneral.Yes) { /* Required subtitle must has content. */ //MessageBox.Show(title.Range.Text + " -- 是必须要填写的!", ErrorMessage.Warning); //range.Select(); //return Return.Failed; } else { /* Not required empty subtitle is removed. */ //range.Text = ""; //title.LockContentControl = false; //title.LockContents = false; //title.Delete(true); //lables.RemoveAt(i - 1); title.LockContents = false; ///guojt 2009/7/15 title.Range.Font.Color = Globals.labelFont.Color; title.LockContents = true; } #endregion } else { #region Not required empty subtitle needs change font color with that of the required if (required == EmrConstant.StringGeneral.No) { title.LockContents = false; title.Range.Font.Color = Globals.labelFont.Color; title.LockContents = true; } #endregion } } } #endregion #region Fill subtitel into emrNote for (int i = 0; i < lables.Count - 1; i++) { title = (Word.ContentControl)lables[i]; titleNext = (Word.ContentControl)lables[i + 1]; range.Start = title.Range.End + 1; range.End = titleNext.Range.Start - 1; XmlElement subTitle = emrNote.OwnerDocument.CreateElement(ElementNames.SubTitle); ElementFromBookmarkMe(subTitle, range); subTitle.SetAttribute(AttributeNames.TitleName, title.Range.Text); /* 2007-07-20 using doubale storage: word document and xml emrDocument. In emrDocuments, * only text is allowed. */ //ElementFromTables(doc, subTitle, range); //ElementFromImages(doc, subTitle, range); emrNote.AppendChild(subTitle); } #endregion //XmlElement revisions = doc.CreateElement(EmrConstant.ElementNames.Revisions); //range = ActiveDocumentManager.getDefaultAD().Content; //RevisionFromBookmark(doc, range, ref revisions); //emrNote.AppendChild(revisions); return(EmrConstant.Return.Successful); }