Beispiel #1
0
        override protected void Page_Load(object sender, EventArgs e)
        {
            int _patientId = int.Parse(Session[SessionKey.PatientId].ToString());

            if (PermissionManager.HasPermission(PermissionManager.EditNarrative) == false)
            {
                // always display other comments, but only allow users to add if their group permission

                submit.Enabled = false;
                NewComment.Attributes.Add("ReadOnly", "True");
                NewComment.Attributes.Add("onClick", "alert('Sorry. Your user group has not been granted permission to add comments.')");
            }

            if (Page.IsPostBack && NewComment.Value != "")
            {
                // TODO: Should we add the permission?
                Security.SecurityController sc = new Caisis.Security.SecurityController();

                Narrative narrative = new Narrative();
                //narrative.NewRow();

                narrative[Narrative.PatientId]       = _patientId;
                narrative[Narrative.Narrative_Field] = NewComment.Value.Trim();
                narrative[Narrative.EnteredTime]     = DateTime.Now.ToString();
                narrative[Narrative.EnteredBy]       = sc.GetUserName();
                narrative[Narrative.NarratedBy]      = sc.GetUserName();

                narrative.Save();

                NewComment.Value           = "";
                commentDiv.Visible         = true;
                NarrativeTitle.Visible     = true;
                NewComment.Style["height"] = "40px";
            }

            //Narrative ptNarratives = new Narrative();
            //ptNarratives.GetByParent(_patientId);
            //ptNarratives.DataSourceView.Sort = "EnteredTime DESC";
            DataView narratives = BusinessObject.GetByParentAsDataView <Narrative>(_patientId);

            narratives.Sort = "EnteredTime DESC";
            //if (ptNarratives.RecordCount > 0)
            if (narratives.Count > 0)
            {
                //RptComments.DataSource = ptNarratives.DataSourceView;
                RptComments.DataSource = narratives;
                RptComments.DataBind();
            }
            else
            {
                commentDiv.Visible         = false;
                NarrativeTitle.Visible     = false;
                NewComment.Style["height"] = "100px";
            }
        }
Beispiel #2
0
        /// <summary>
        /// Insert an Uploaded File into DB
        /// </summary>
        /// <param name="theFile"></param>
        /// <returns></returns>
        private int InsertFileRecord(HttpPostedFile theFile)
        {
            int fileId = 0;

            // get lenths of file name (including extension) and label names
            int fileNameLength = System.IO.Path.GetFileName(theFile.FileName).Length;
            int labelLength    = FileLabel.Text.Length;
            // get the max lenths of file name and label from database
            int?originalFileNameMaxLength = BOL.UploadedFile.GetFieldMaxLength("Files", BOL.UploadedFile.OriginalFileName);
            int?fileLabelMaxLength        = BOL.UploadedFile.GetFieldMaxLength("Files", BOL.UploadedFile.FileLabel);

            bool insertFile = true;

            if (originalFileNameMaxLength != null && fileNameLength > originalFileNameMaxLength)
            {
                insertFile          = false;
                UploadErrorMsg.Text = UploadErrorMsg.Text + "<br/>File name (including extension) must be " + originalFileNameMaxLength.ToString() + " characters or less.";
            }

            if (fileLabelMaxLength != null && labelLength > fileLabelMaxLength)
            {
                insertFile          = false;
                UploadErrorMsg.Text = UploadErrorMsg.Text + "<br/>File label must be " + fileLabelMaxLength.ToString() + " characters or less. ";
            }

            if (insertFile)
            {
                UploadedFile file = LoadFileRecord(theFile);

                // add entered by on insert; no ability to lock records right now
                Caisis.Security.SecurityController sc = new Caisis.Security.SecurityController();
                file[BusinessObject.EnteredBy] = sc.GetUserName();
                //file[BusinessObject.EnteredTime] = DateTime.Now;

                file.Save();
                fileId = (int)file[UploadedFile.FileId];
            }

            return(fileId);
        }
Beispiel #3
0
        /// <summary>
        /// Load BizObj for saving/updating
        /// </summary>
        /// <param name="theFile"></param>
        /// <returns></returns>
        private UploadedFile LoadFileRecord(HttpPostedFile theFile)
        {
            UploadedFile fileBO = new UploadedFile();

            // Set BizObj Fields
            fileBO[UploadedFile.TableName]        = _tableName;
            fileBO[UploadedFile.TablePrimaryKey]  = _tablePrimaryKey.ToString();
            fileBO[UploadedFile.OriginalFileName] = System.IO.Path.GetFileName(theFile.FileName);
            fileBO[UploadedFile.FileType]         = theFile.ContentType;
            fileBO[UploadedFile.FileLabel]        = FileLabel.Text; // only value submitted by user via interface
            fileBO[UploadedFile.OnFileServer]     = "1";
            fileBO[UploadedFile.FileExtension]    = new FileInfo(theFile.FileName).Extension;
            // may NOT want to store file path for better portability
            fileBO[UploadedFile.FilePath] = _savePath;

            // add audit info for update and inserts
            Caisis.Security.SecurityController sc = new Caisis.Security.SecurityController();
            fileBO[BusinessObject.EnteredBy]   = sc.GetUserName();
            fileBO[BusinessObject.EnteredTime] = DateTime.Now;

            return(fileBO);
        }
Beispiel #4
0
        /// <summary>
        /// Returns a DataTable of lookupcodes
        /// </summary>
        /// <param name="lkpCode"></param>
        /// <param name="isDistinct"></param>
        /// <returns></returns>
        private DataTable GetLookupCodes(string lkpCode, bool isDistinct)
        {
            DataTable dataSourceTable         = new DataTable();
            string    LookupColumn            = LookupCode.LkpCode;
            string    LookupDescriptionColumn = LookupCode.LkpDescription;

            if (isDistinct)
            {
                string[] lookupDistinctVals = lkpCode.Split(new char[] { ';' });
                string   tablename          = lookupDistinctVals[0].Trim();
                string   valuefield         = lookupDistinctVals[1].Trim();
                string   textfield          = lookupDistinctVals[2].Trim();
                string   restriction        = null;
                string   order = null;

                if (lookupDistinctVals.Length >= 4)
                {
                    restriction = lookupDistinctVals[3].Trim();
                    System.Web.SessionState.HttpSessionState tempSession = Page.Session;
                    if (restriction.Contains("@PatientId") && tempSession != null && tempSession[SessionKey.PatientId] != null)
                    {
                        restriction = restriction.Replace("@PatientId", tempSession[SessionKey.PatientId].ToString());
                    }

                    if (restriction.Contains("@UserName"))
                    {
                        Caisis.Security.SecurityController sc = new Caisis.Security.SecurityController();
                        restriction = restriction.Replace("@UserName", String.Format("'{0}'", sc.GetUserName()));
                    }

                    if (lookupDistinctVals.Length >= 5)
                    {
                        order = lookupDistinctVals[4].Trim();
                    }
                }

                dataSourceTable = LookupCodeDa.GetLookupData(tablename, valuefield, textfield, restriction, order).Table;
                LookupColumn    = "DropDownText";
            }
            else
            {
                string[] specialLkpCode = lkpCode.Split(';');
                if (specialLkpCode.Length == 3)
                {
                    LookupCodeDa da                 = new LookupCodeDa();
                    string       childLkpCode       = specialLkpCode[0];
                    string       parentLkpCode      = specialLkpCode[1];
                    string       parentLkpCodeValue = specialLkpCode[2];

                    DataTable parentLkpCodes = da.GetLookupsByFieldName(parentLkpCode).Tables[0];
                    DataRow[] results        = parentLkpCodes.Select("LkpCode = '" + parentLkpCodeValue + "'");
                    if (results.Length > 0)
                    {
                        int lkpCodeId = int.Parse(results[0][LookupCode.LookupCodeId].ToString());
                        dataSourceTable = da.GetChildCodesByLookupIdAndChildLookupName(lkpCodeId, childLkpCode);
                    }
                }
                else
                {
                    dataSourceTable = CacheManager.GetLookupCodeList(lkpCode);
                }
            }
            return(dataSourceTable);
        }