private void Print_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();

            if (pd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DocumentTemplate.Print(winFormHtmlEditor1.DocumentHtml, pd.PrinterSettings.PrinterName);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Печать документа и сохранениепациента в БД если его нету
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void печатьToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (_currentDocument.Print())
     {
         if (_selectedPatient == null)
         {
             var lName = ClientTextBox.Text.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
             var P     = new Patient
             {
                 Lname  = lName,
                 BDate  = dateTimePicker1.Value.Date,
                 Gender = mRadioButton.Checked ? "М" : "Ж",
                 Name   = ClientTextBox.Text.Replace($"{lName} ", "")
             };
             //MessageBox.Show("Добавить ациента в базу?", "Выберите действие", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
             var patientId = _db.SavePatient(P);
             if (patientId > 0)
             {
                 _selectedPatient    = P;
                 _selectedPatient.Id = patientId;
             }
             else if (patientId == -1)
             {
                 MessageBox.Show("Выберите пациента из базы!", "Пациент существует в базе", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             else
             {
                 MessageBox.Show("Пациент не добавлен в базу!", "Ошибка добавления пациента в базу", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
         }
         var fileName = _currentDocument.Save();
         if (fileName != null)
         {
             var D = new Docs
             {
                 Date = DateTime.Now.Date,
                 Name = fileName,
                 exId = _examinations[metroTabControl1.SelectedTab.Text],
                 Pid  = _selectedPatient.Id
             };
             if (_db.SaveDoc(D) == 1)
             {
                 _selectedPatient = null;
                 MessageBox.Show("Документ распечатан и сохранен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 //ClearForms();
             }
         }
         else
         {
             MessageBox.Show("Документ не был сохранен в базу!", "Ошибка сохранения документа в базу", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 public void Print()
 {
     DocumentTemplate.Print(template.htmlText, targetPrinter);
 }
Beispiel #4
0
        private void CreateDocument(bool print)
        {
            bool   bInterface        = false;
            bool   bPacsFound        = false;
            bool   bPowerscribeFound = false;
            int    interfaceId       = -1;
            string interfaceType     = "";
            string ipAddress         = "";
            string port          = "";
            string aeTitleRemote = "";
            string aeTitleLocal  = "";
            string DCMTKpath     = "";
            int    pacsSubType   = 1;

            ObjectListView olv = null;

            if (objectListView2.SelectedObject != null)
            {
                olv = objectListView2;
            }
            else if (objectListView1.SelectedObject != null)
            {
                olv = objectListView1;
            }

            if (olv != null)
            {
                DocumentTemplate dt = (DocumentTemplate)olv.SelectedObject;

                if (string.IsNullOrEmpty(dt.htmlPath))
                {
                    if (!string.IsNullOrEmpty(dt.documentFileName))
                    {
                        RiskAppCore.Globals.setApptID(SessionManager.Instance.GetActivePatient().apptid);
                        RiskAppCore.Globals.setUnitNum(SessionManager.Instance.GetActivePatient().unitnum);
                        FileInfo fInfo = dt.CalculateFileName(SessionManager.Instance.GetActivePatient().name,
                                                              SessionManager.Instance.GetActivePatient().apptdatetime.ToShortDateString().Replace("/", "-"),
                                                              SessionManager.Instance.GetActivePatient().apptid,
                                                              SessionManager.Instance.GetActivePatient().unitnum,
                                                              "doc", "");

                        LetterGenerator.Letter.generateDocFromTemplate(dt.documentFileName, dt.documentName, print);

                        RiskAppCore.Globals.setApptID(-1);
                        RiskAppCore.Globals.setUnitNum("");
                        return;
                    }
                }

                if (SessionManager.Instance.GetActivePatient() != null)
                {
                    FileInfo fInfo = dt.CalculateFileName(SessionManager.Instance.GetActivePatient().name,
                                                          SessionManager.Instance.GetActivePatient().apptdatetime.ToShortDateString().Replace("/", "-"),
                                                          SessionManager.Instance.GetActivePatient().apptid,
                                                          SessionManager.Instance.GetActivePatient().unitnum,
                                                          "html", "");

                    System.IO.File.WriteAllText(fInfo.FullName, dt.htmlText);

                    // Check to see if there's an interface we should send to... ONE PER DOCUMENT TEMPLATE!  If you want multiple interfaces, create multiple templates.
                    ParameterCollection pacsArgs = new ParameterCollection();
                    pacsArgs.Add("documentTemplateID", dt.documentTemplateID);
                    SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_getInterfaceDefinitionFromTemplateID", pacsArgs);
                    while (reader.Read())       // loop thru these rows and see what interfaces there are for this document
                    {
                        if (reader.IsDBNull(0) == false)
                        {
                            bInterface  = true;
                            interfaceId = reader.GetInt32(0);
                        }
                        if (reader.IsDBNull(1) == false)
                        {
                            interfaceType = reader.GetString(1);        // used in message below, this should be refactored, as multiple rows can be returned
                            if (interfaceType.ToUpper() == "PACS")
                            {
                                bPacsFound = true;
                            }
                            if (interfaceType.ToUpper() == "POWERSCRIBE")
                            {
                                bPowerscribeFound = true;
                            }
                        }
                        if (reader.IsDBNull(2) == false)
                        {
                            ipAddress = reader.GetString(2);    // these are mostly deprecated now, except the booleans, as this query now can return multiple rows, we don't need this stuff here.  jdg 8/21/15
                        }
                        if (reader.IsDBNull(3) == false)
                        {
                            port = reader.GetString(3);
                        }
                        if (reader.IsDBNull(4) == false)
                        {
                            aeTitleRemote = reader.GetString(4);
                        }
                        if (reader.IsDBNull(5) == false)
                        {
                            aeTitleLocal = reader.GetString(5);
                        }
                        if (reader.IsDBNull(6) == false)
                        {
                            DCMTKpath = reader.GetString(6);
                        }
                        if (reader.IsDBNull(7) == false)
                        {
                            pacsSubType = reader.GetInt32(7);
                        }
                    }

                    if ((print) || (bInterface))        // not mutually exclusive
                    {
                        try
                        {
                            if (print)
                            {
                                PrinterSettings settings = new PrinterSettings();
                                DocumentTemplate.Print(dt.htmlText, settings.PrinterName);
                            }

                            // Prompt to actually execute interfaces...
                            if (bInterface && (MessageBox.Show("Would you like to send this document to " + interfaceType + "?\n\nThis will take a few moments.", "Send Document to External System?", MessageBoxButtons.YesNo) == DialogResult.Yes))
                            {
                                if (bPacsFound)
                                {
                                    try
                                    {
                                        // jdg 8/21/15 let send2Pacs figure out what interfaces and file formats to send this thing to
                                        DocumentTemplate.ConvertToPdf(dt.htmlText, fInfo.FullName + ".pdf");
                                        RiskApps3.Utilities.InterfaceUtils.send2PACS(dt, SessionManager.Instance.GetActivePatient(), fInfo.FullName + ".pdf", SessionManager.Instance.GetActivePatient().apptid);
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Instance.WriteToLog("Failed to send PDF file to interface for appointment " + SessionManager.Instance.GetActivePatient().apptid + ", document template: " + dt.documentTemplateID + ".  Underlying error was: " + e.Message);
                                    }
                                }

                                //if (interfaceType.ToUpper() == "POWERSCRIBE")
                                if (bPowerscribeFound)
                                {
                                    InterfaceUtils.sendPowerscribe(dt);
                                }

                                // TODO:  Add future interfaces here
                            }
                            // end jdg 8/5/15
                        }
                        catch (Exception e)
                        {
                            Logger.Instance.WriteToLog(e.ToString());
                        }
                    }

                    ParameterCollection pc = new ParameterCollection();
                    pc.Add("apptid", SessionManager.Instance.GetActivePatient().apptid);
                    pc.Add("templateID", dt.documentTemplateID);
                    pc.Add("dateTime", DateTime.Now);
                    pc.Add("userlogin", SessionManager.Instance.ActiveUser.userLogin);

                    string sqlStr = "INSERT INTO tblDocuments([apptID],[documentTemplateID],[created],[createdBy]) VALUES(@apptid, @templateID, @dateTime, @userlogin);";
                    BCDB2.Instance.ExecuteNonQueryWithParams(sqlStr, pc);
                }
            }
        }