Esempio n. 1
0
        /// <summary>Makes one call to the database to retrieve the document of the patient for the given patNum, then uses that document and the pathPrepend to load and process the patient picture so it appears the same way it did in the image module(except for scaling and translation). Returns false if there is no patient picture, true otherwise. Sets the value of patientPict equal to a new instance of the patient's processed picture, but will be set to null on error. Assumes WithPat will always be same as patnum.</summary>
        public static bool GetPatPict(int patNum, string pathPrepend, out Bitmap patientPict)
        {
            patientPict = null;
            //first establish which category pat pics are in
            int defNumPicts = 0;

            for (int i = 0; i < DefB.Short[(int)DefCat.ImageCats].Length; i++)
            {
                if (DefB.Short[(int)DefCat.ImageCats][i].ItemValue == "P" || DefB.Short[(int)DefCat.ImageCats][i].ItemValue == "XP")
                {
                    defNumPicts = DefB.Short[(int)DefCat.ImageCats][i].DefNum;
                    break;
                }
            }
            if (defNumPicts == 0)          //no category set for picts
            {
                return(false);
            }
            //then find
            string command = "SELECT document.* FROM document,docattach "
                             + "WHERE document.DocNum=docattach.DocNum "
                             + "AND docattach.PatNum=" + POut.PInt(patNum)
                             + " AND document.DocCategory=" + POut.PInt(defNumPicts)
                             + " ORDER BY DateCreated DESC ";

            //gets the most recent
            if (FormChooseDatabase.DBtype == DatabaseType.Oracle)
            {
                command = "SELECT * FROM (" + command + ") WHERE ROWNUM<=1";
            }
            else              //Assume MySQL
            {
                command += "LIMIT 1";
            }
            Document[] pictureDocs = RefreshAndFill(command);
            if (pictureDocs == null || pictureDocs.Length < 1)        //no pictures
            {
                return(false);
            }
            string shortFileName = pictureDocs[0].FileName;

            if (shortFileName.Length < 1)
            {
                return(false);
            }
            string fullName = pathPrepend + shortFileName;

            if (!File.Exists(fullName))
            {
                return(true);
            }
            patientPict = ContrDocs.ApplyDocumentSettingsToImage(pictureDocs[0], new Bitmap(fullName),
                                                                 ContrDocs.ApplySettings.ALL);
            return(true);
        }
        /// <summary>This form will get the necessary images off disk so that it can control layout.</summary>
        public void SetImage(Document thisDocument, string displayTitle)
        {
            //for now, the document is single. Later, it will get groups for composite images/mounts.
            Text         = displayTitle;
            displayedDoc = thisDocument;
            ArrayList docNums = new ArrayList();

            docNums.Add(thisDocument.DocNum);
            string fileName = (string)Documents.GetPaths(docNums)[0];

            if (!File.Exists(fileName))
            {
                MessageBox.Show(fileName + " could not be found.");
                return;
            }
            try{
                ImageCurrent = new Bitmap(fileName);
                renderImage  = ContrDocs.ApplyDocumentSettingsToImage(thisDocument, ImageCurrent,
                                                                      ApplySettings.CROP | ApplySettings.COLORFUNCTION);
                if (renderImage == null)
                {
                    imageZoom        = 1;
                    imageTranslation = new PointF(0, 0);
                }
                else
                {
                    float matchWidth = PictureBox1.Width - 16;
                    matchWidth = (matchWidth <= 0?1:matchWidth);
                    float matchHeight = PictureBox1.Height - 16;
                    matchHeight      = (matchHeight <= 0?1:matchHeight);
                    imageZoom        = (float)Math.Min(matchWidth / renderImage.Width, matchHeight / renderImage.Height);
                    imageTranslation = new PointF(PictureBox1.Width / 2.0f, PictureBox1.Height / 2.0f);
                }
                zoomLevel  = 0;
                zoomFactor = 1;
            }catch (System.Exception exception) {
                MessageBox.Show(Lan.g(this, exception.Message));
                ImageCurrent = null;
                renderImage  = null;
            }
        }