예제 #1
0
    /// <summary>
    /// "Loads" the existing profile. Sets values for profile id, visit type id, and disease id that are used when
    /// building the tree view. Also sets the profile log information.
    /// </summary>
    private void LoadExistingProfile()
    {
        // Retrieve the profile
        PatientEdProfile profileBiz = new PatientEdProfile();

        profileBiz.Get(ProfileId);

        //Set values
        if (!String.IsNullOrEmpty(profileBiz[PatientEdProfile.ProfileVisitTypeId].ToString()))
        {
            // Note: Not really necessary to do as shown below, if we have order numbers that are the same
            // as the Ids.
            VisitTypeId = Int32.Parse(profileBiz[PatientEdProfile.ProfileVisitTypeId].ToString());
            PatientEducationDa da = new PatientEducationDa();
            DataRow            dr = da.GetVisitTypeById(VisitTypeId);
            this._visitTypeStage.Value = dr[PatientEdVisitType.OrderNumber].ToString();
        }
        else
        {
            this._visitTypeStage.Value = "0";
        }

        if (!String.IsNullOrEmpty(profileBiz[PatientEdProfile.ProfileDiseaseId].ToString()))
        {
            DiseaseId = Int32.Parse(profileBiz[PatientEdProfile.ProfileDiseaseId].ToString());
        }

        // update profile log info
        this.printedDate.InnerHtml = profileBiz[PatientEdProfile.LastPrintedTime].ToString();
        this.printedBy.InnerHtml   = profileBiz[PatientEdProfile.LastPrintedBy].ToString();
        if (!String.IsNullOrEmpty(profileBiz[PatientEdProfile.LastPrintedBy].ToString()))
        {
            this.printedBy.InnerHtml = "by " + this.printedBy.InnerHtml;
        }

        this.updatedDate.InnerHtml = profileBiz[PatientEdProfile.UpdatedTime].ToString();
        this.updatedBy.InnerHtml   = profileBiz[PatientEdProfile.UpdatedBy].ToString();
        if (!String.IsNullOrEmpty(profileBiz[PatientEdProfile.UpdatedBy].ToString()))
        {
            this.updatedBy.InnerHtml = "by " + this.updatedBy.InnerHtml;
        }
    }
예제 #2
0
    /// <summary>
    /// Saves the current profile, existing or newly created.
    /// </summary>
    /// <param name="caller"></param>
    private void SaveCurrentProfile(string caller)
    {
        SecurityController sc   = new SecurityController();
        string             user = sc.GetUserName();

        if (!String.IsNullOrEmpty(this._ptProfileId.Value))
        {
            ProfileId = Int32.Parse(this._ptProfileId.Value);
        }

        if (this._visitTypeStage.Value != "0")
        {
            VisitTypeId = Int32.Parse(this._visitTypeStage.Value);
        }

        PatientEducationDa da = new PatientEducationDa();
        List <string>      checkedPartsList = new List <string>();

        foreach (TreeNode sectionNode in contentTV.Nodes)
        {
            foreach (TreeNode topicNode in sectionNode.ChildNodes)
            {
                foreach (TreeNode subTopicNode in topicNode.ChildNodes)
                {
                    if (subTopicNode.Checked)
                    {
                        checkedPartsList.Add(subTopicNode.Value);
                    }
                }
            }
        }

        if (ProfileId > 0)
        {
            DataTable dbProfilePartsDt = da.GetProfileDocPartsByProfileId(ProfileId);
            // Delete existing profile parts that have been deselected,
            // and update the list of actual new parts to be saved later on.
            foreach (DataRow dr in dbProfilePartsDt.Rows)
            {
                string stId = dr[PatientEdProfileDocPart.SubTopicId].ToString();
                if (!checkedPartsList.Contains(stId))
                {
                    //delete this profile doc part from the db
                    da.DeleteProfileDocPartByProfileIdAndSubTopicId(ProfileId, Int32.Parse(stId));
                }
                else
                {
                    //remove it from the list of checked parts, as we have confirmed it is already in the db
                    checkedPartsList.Remove(stId);
                }
            }

            PatientEdProfile profileBiz = new PatientEdProfile();
            profileBiz.Get(ProfileId);
            profileBiz[PatientEdProfile.UpdatedBy]   = user;
            profileBiz[PatientEdProfile.UpdatedTime] = DateTime.Now.ToString();

            if (caller == "print")
            {
                profileBiz[PatientEdProfile.LastPrintedBy]   = user;
                profileBiz[PatientEdProfile.LastPrintedTime] = DateTime.Now.ToString();
            }
            profileBiz.Save();
        }
        else
        {
            // Saving a brand new profile.
            SessionHandler sh   = new SessionHandler(Session);
            int            ptId = sh.GetPatientId();

            PatientEdProfile profile = new PatientEdProfile();
            profile[PatientEdProfile.PatientId] = ptId.ToString();

            if (this._visitTypeStage.Value != "0")
            {
                profile[PatientEdProfile.ProfileVisitTypeId] = VisitTypeId;
            }
            if (this.ddlDiseaseProfile.SelectedIndex > 0)
            {
                profile[PatientEdProfile.ProfileDiseaseId] = DiseaseId;
            }

            string profileDate = DateTime.Now.ToString();
            profile[PatientEdProfile.ProfileCreateDate] = profileDate;
            profile[PatientEdProfile.EnteredBy]         = user;
            profile[PatientEdProfile.EnteredTime]       = profileDate;
            profile[PatientEdProfile.UpdatedBy]         = user;
            profile[PatientEdProfile.UpdatedTime]       = profileDate;

            if (caller == "print")
            {
                profile[PatientEdProfile.LastPrintedBy]   = user;
                profile[PatientEdProfile.LastPrintedTime] = DateTime.Now.ToString();
            }
            profile.Save();

            ProfileId = Int32.Parse(profile[PatientEdProfile.ProfileId].ToString());
            LoadListOfProfilesTable(ptId);

            ShowProfileLog(true);
        }

        // Add the new profile parts to this profile document
        foreach (string profilePart in checkedPartsList)
        {
            PatientEdProfileDocPart dp = new PatientEdProfileDocPart();
            dp[PatientEdProfileDocPart.ProfileId]  = ProfileId.ToString();
            dp[PatientEdProfileDocPart.SubTopicId] = Int32.Parse(profilePart);
            dp[PatientEdProfileDocPart.ProfileDocPartVersionNumber] = "1.0";
            dp[PatientEdProfileDocPart.ProfileDocPartOrderNumber]   = "1";
            dp.Save();
        }

        LoadExistingProfile();
        GetRootNodes();

        this._callbackType.Value = String.Empty;
    }