Ejemplo n.º 1
0
        private void SaveAsPdfButton_Click(object sender, EventArgs e)
        {
            Save_Click(sender, e);

            Cursor = Cursors.WaitCursor;

            string templateDirectory = Configurator.GetDocumentTemplateStorage();   // override save location with config.xml

            if (templateDirectory.Substring(templateDirectory.Length - 1) != "\\")
            {
                templateDirectory = templateDirectory + "\\";
            }

            if (winFormHtmlEditor1.Tag != null)
            {
                string s    = (string)winFormHtmlEditor1.Tag;
                string name = Path.Combine(Path.GetDirectoryName(s), Path.GetFileNameWithoutExtension(s));
                name += ".pdf";

                if (DocumentTemplate.ConvertToPdf(winFormHtmlEditor1.DocumentHtml, name) != 0)
                {
                    MessageBox.Show("An error has occured in saving the PDF file.  Check to make sure the file is not open in another process.");
                }
            }

            Cursor = Cursors.Default;
        }
Ejemplo n.º 2
0
        public bool savePdfDoc(int apptID, string unitnum, int templateID, string directory)
        {
            try
            {
                SessionManager.Instance.SetActivePatient(unitnum, apptID);
                directory = Configurator.GetDocumentStorage();   // override save location with config.xml
                if (directory.Substring(directory.Length - 1) != "\\")
                {
                    directory = directory + "\\";
                }
                string templateDirectory = Configurator.GetDocumentTemplateStorage();   // override save location with config.xml
                if (templateDirectory.Substring(templateDirectory.Length - 1) != "\\")
                {
                    templateDirectory = templateDirectory + "\\";
                }

                HraHtmlDocument hdoc = new HraHtmlDocument(templateID, unitnum, apptID);
                if (hdoc == null)
                {
                    Logger.Instance.WriteToLog("RiskApps3Automation.HtmlDocument(" + templateID.ToString() + ", " + apptID.ToString() + ", \"" + unitnum + "\") returned null");
                    return(false);
                }
                hdoc.apptid = apptID;

                FileInfo fInfo = hdoc.template.CalculateFileName(SessionManager.Instance.GetActivePatient().name,
                                                                 SessionManager.Instance.GetActivePatient().apptdatetime.ToShortDateString().Replace("/", "-"),
                                                                 SessionManager.Instance.GetActivePatient().apptid,
                                                                 SessionManager.Instance.GetActivePatient().unitnum,
                                                                 "pdf", directory);

                string PdfFileName = fInfo.FullName;

                DocumentTemplate.ConvertToPdf(hdoc.template.htmlText, PdfFileName);
            }
            catch (Exception e)
            {
                Logger.Instance.WriteToLog("saveHtmlDoc(" + apptID.ToString() + ", \"" + unitnum + "\", " + templateID.ToString() + ", \"" + directory + "\") " + e.ToString());
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
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);
                }
            }
        }