コード例 #1
0
        /// <summary>
        /// Loads the different document types list
        /// </summary>
        private void LoadDocumentList()
        {
            using (TMM_DEPLOYEntities tmmEntities = new TMM_DEPLOYEntities())
            {
                List <PatientDocument> foundDocs = new List <PatientDocument>();

                if (IsAdminUser)
                {
                    var document = (from docs in tmmEntities.PatientDocument
                                    where docs.Patient.PatientID == CurrentPatientEncounter.PatientID
                                    select docs);

                    foundDocs.AddRange(document);
                }
                else
                {
                    var document = (from docs in tmmEntities.PatientDocument
                                    where docs.Patient.PatientID == CurrentPatientEncounter.PatientID &&
                                    docs.Visible == true
                                    select docs);

                    foundDocs.AddRange(document);
                }

                grdDocuments.DataSource = foundDocs;
                grdDocuments.DataBind();
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds entries to the notificationlog
        /// </summary>
        /// <param name="sentToID"></param>
        private void AddNotificationLog(List <UserInfo> sentToID)
        {
            DateTime notificationDate = DateTime.Now;
            int      uploadUserID     = currentUserInfo.ID;

            NotificationLog uNote = new NotificationLog();

            uNote.DateSent    = DateTime.Now;
            uNote.CreatedByID = currentUserInfo.ID;


            using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
            {
                ef.AddToNotificationLog(uNote);

                foreach (UserInfo Recip in sentToID)
                {
                    //ef.Attach(uNote);
                    NotificationLogRecipients logRecip = new NotificationLogRecipients();
                    logRecip.DateAdded       = DateTime.Now;
                    logRecip.NotificationLog = uNote;
                    logRecip.RecipientID     = Recip.ID;

                    ef.AddToNotificationLogRecipients(logRecip);
                    //ef.Detach(uNote);
                }

                ef.SaveChanges();
            }
        }
コード例 #3
0
        /// <summary>
        /// Returns a list of all users that need to be notified
        /// </summary>
        /// <returns></returns>
        private List <UserInfo> GetNotifyList()
        {
            List <UserInfo> emailList = new List <UserInfo>();

            using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
            {
                var userList = (from c in ef.UserInfo
                                where c.UserType.ID == (int)UserType.Types.Office &&
                                c.Active == true
                                select c);


                foreach (UserInfo uInfo in userList)
                {
                    var securables = (from c in ef.User_Securable
                                      where c.UserID == uInfo.ID &&
                                      c.SecurableID == (int)Securable.Securables.ReceiveDocumentNotification &&
                                      c.Active == true
                                      select c);

                    List <User_Securable> uSecurable = new List <User_Securable>();
                    uSecurable.AddRange(securables);

                    foreach (User_Securable uSec in uSecurable)
                    {
                        if (uSec.SecurableID == (int)Securable.Securables.ReceiveDocumentNotification)
                        {
                            emailList.Add(uInfo);
                        }
                    }
                }
            }

            return(emailList);
        }
コード例 #4
0
 /// <summary>
 /// Loads the different document type to the
 /// </summary>
 private void LoadDocumentTypes()
 {
     ddlDocType.Items.Add(new ListItem("Select Document Type"));
     ddlDocType.Items.Add(new ListItem("Add New Document Type", "AddType"));
     using (TMM_DEPLOYEntities tmmEntities = new TMM_DEPLOYEntities())
     {
         var docTypes = (from types in tmmEntities.PatientDocument
                         select types.DocumentType).Distinct();
         foreach (string dtype in docTypes)
         {
             ddlDocType.Items.Add(dtype);
         }
     }
 }
コード例 #5
0
        public List <UserInfo> GetAllMedics()
        {
            List <UserInfo> medics = new List <UserInfo>();

            using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
            {
                var m = (from med in ef.UserInfo
                         where med.Active == true && med.UserType.ID == (int)UserType.Types.Medic &&
                         (med.FirstName != string.Empty && med.LastName != string.Empty)
                         orderby med.LastName
                         select med);
                medics.AddRange(m);
            }
            return(medics);
        }
コード例 #6
0
        public void OnUploadError(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError(); if (ex.Message == "Maximum request length exceeded.")
            {
                string errMsg = "<script>alert('Selected file is too big and cannot be uploaded. Maximum size allowed is 4MB.');";
                ClientScript.RegisterClientScriptBlock(typeof(Page), "UploadError", errMsg);
                ClearUploadForm();
                Response.Write(errMsg);

                using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
                {
                    var pdoc = (from doc in ef.PatientDocument
                                where doc.DocumentID == _newdocumentID
                                select doc).FirstOrDefault();

                    ef.DeleteObject(pdoc);
                }

                Server.ClearError();
            }
        }
コード例 #7
0
        /// <summary>
        /// Returns a list of users with the ReceiveDocumentNotification Securable for a customer
        /// </summary>
        /// <param name="RigID"></param>
        /// <returns></returns>
        public List <UserInfo> GetNotifyUsers(int RigID)
        {
            List <UserInfo> cUsers = new List <UserInfo>();

            using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
            {
                var custID = (from d in ef.Customer_Worksite
                              where d.RigID == RigID
                              select d.CustomerID).FirstOrDefault();

                var uInfo = (from c in ef.User_Securable.Include("UserInfo")
                             where c.SecurableID == (int)Securable.Securables.ReceiveAdditionalNoteNotification &&
                             c.UserInfo.CustomerID.Value == custID &&
                             c.UserInfo.Email != null &&
                             c.UserInfo.Email != string.Empty
                             select c.UserInfo);

                cUsers.AddRange(uInfo);
            }

            return(cUsers);
        }
コード例 #8
0
        /// <summary>
        /// Gets a list Company users with an email
        /// </summary>
        /// <param name="RigID"></param>
        /// <returns></returns>
        public List <UserInfo> GetCompanyUsers(int RigID)
        {
            List <UserInfo> cUsers = new List <UserInfo>();

            using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
            {
                var custID = (from d in ef.Customer_Worksite
                              where d.RigID == RigID
                              select d.CustomerID).FirstOrDefault();

                var uInfo = (from c in ef.UserInfo
                             where c.CustomerID.Value == custID &&
                             c.Email != null &&
                             c.Email != string.Empty

                             select c);

                cUsers.AddRange(uInfo);
            }

            return(cUsers);
        }
コード例 #9
0
        /// <summary>
        /// Saves new documents to the database
        /// </summary>
        private void SaveNewDocument()
        {
            foreach (Telerik.WebControls.UploadedFile uplFile in uplNewDocument.UploadedFiles)
            {
                PatientDocument pDoc = new PatientDocument();

                pDoc.DocumentLink      = UploadLocation + uplFile.FileName;
                pDoc.DocumentType      = ddlDocType.Text;
                pDoc.LocationType      = (int)LocationType.Trinity;
                pDoc.ReferenceDate     = rdpEncounterStartDate.SelectedDate.Value;
                pDoc.Active            = true;
                pDoc.OriginationSource = OriginationSource;
                pDoc.DateAdded         = DateTime.Now;
                pDoc.Visible           = true;

                if (ddlDocType.SelectedValue == "AddType")
                {
                    pDoc.DocumentType = txtDocumentType.Text;
                }

                using (TMM_DEPLOYEntities tmmEntities = new TMM_DEPLOYEntities())
                {
                    tmmEntities.Attach(CurrentPatientEncounter);
                    pDoc.Patient = CurrentPatientEncounter;
                    tmmEntities.AddToPatientDocument(pDoc);
                    tmmEntities.SaveChanges();
                    tmmEntities.Detach(CurrentPatientEncounter);
                }
                _newdocumentID = pDoc.DocumentID;
                HandleUploadedFile(pDoc.DocumentID, uplFile);

                NotifyUsers();
            }

            ClientScript.RegisterStartupScript(grdDocuments.GetType(), "UploadComplete", "<script>document.getElementById('divUploadFile').style.display = 'none'; document.getElementById('divUploadButton').style.display = 'block';</script>");
            LoadDocumentList();
            ClearUploadForm();
        }
コード例 #10
0
        /// <summary>
        /// Gets a medics userinfo based on their ID
        /// </summary>
        /// <param name="medicID"></param>
        /// <returns></returns>
        public UserInfo GetMedicByID(int medicID)
        {
            using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
            {
                var q = (from medic in ef.UserInfo
                         where medic.ID == medicID
                         select medic);

                if (q.Count() < 0)
                {
                    q = (from medic in ef.UserInfo
                         where medic.OldMedicID == medicID
                         select medic);
                }

                UserInfo uInfo = q.FirstOrDefault();
                if (uInfo != null)
                {
                    uInfo.UserSecurityReference.Load();
                    uInfo.UserTypeReference.Load();
                }
                return(uInfo);
            }
        }
コード例 #11
0
        protected void grdDocuments_ItemCommand(object sender, Telerik.WebControls.GridCommandEventArgs e)
        {
            if (e.CommandName != "Page")
            {
                int docID = Int32.Parse(e.CommandArgument.ToString());
                /* Sets the visible property of the selected document to allow non-admins to view the file */
                if (e.CommandName == "ShowDoc")
                {
                    using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
                    {
                        var q = (from doc in ef.PatientDocument
                                 where doc.DocumentID == docID
                                 select doc).FirstOrDefault();

                        q.Visible = true;
                        ef.SaveChanges();
                    }
                }

                /* Sets the visible property of the selected document to deny non-admins the ability to view the file */
                if (e.CommandName == "HideDoc")
                {
                    using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
                    {
                        var q = (from doc in ef.PatientDocument
                                 where doc.DocumentID == docID
                                 select doc).FirstOrDefault();

                        q.Visible = false;
                        ef.SaveChanges();
                    }
                }

                if (e.CommandName == "ViewDoc")
                {
                    try
                    {
                        using (TMM_DEPLOYEntities ef = new TMM_DEPLOYEntities())
                        {
                            var q = (from doc in ef.PatientDocument
                                     where doc.DocumentID == docID
                                     select doc).FirstOrDefault();

                            string   fileName = GetDocumentName(q.DocumentLink);
                            FileInfo fileInfo = new FileInfo(UploadLocation + docID.ToString());

                            // Get the network credentials and use them to impersonate the user with priviledges.
                            string UserName = System.Configuration.ConfigurationManager.AppSettings["UserName"].ToString();
                            string Password = System.Configuration.ConfigurationManager.AppSettings["Password"].ToString();
                            string Domain   = System.Configuration.ConfigurationManager.AppSettings["Domain"].ToString();

                            // Impersonate the user in order to get the document.
                            //CreateIdentity(UserName, Domain, Password);

                            // Set up the response to receive the file.
                            Response.Clear();
                            Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                            Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                            Response.ContentType = "application/octet-stream";
                            Response.WriteFile(fileInfo.FullName);

                            // Get the file as a byte array and send it to the response.
                            Byte[] fileBytes = null;
                            using (FileStream fs = new FileStream(UploadLocation + docID.ToString(), FileMode.Open, FileAccess.Read))
                            {
                                try
                                {
                                    BinaryReader br = new BinaryReader(fs);
                                    fileBytes = br.ReadBytes((int)fileInfo.Length);

                                    using (BinaryWriter fw = new BinaryWriter(Response.OutputStream))
                                    {
                                        try
                                        {
                                            fw.Write(fileBytes, 0, fileBytes.Length);
                                        }
                                        catch
                                        {
                                            lblError.Text = "Error: Unable to retrieve the file requested.";
                                        }
                                    }
                                }
                                catch
                                {
                                    lblError.Text = "Error: Unable to read the file.";
                                }
                            }
                            Response.End();
                        }
                    }
                    catch
                    {
                    }
                }
            }

            LoadDocumentList();
        }