protected void btnSave_Click(object sender, EventArgs e)
    {
        string Createdate = "";
        string ID         = "";

        if (btnSave.Text == "Save")
        {
            if (validate() == false)
            {
                return;
            }
            IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
            DataTable        theDT          = PatientTransferMgr.GetSatelliteID(PatientId);
            string           FromLocationID = theDT.Rows[0]["LocationID"].ToString();
            int Transfer = (int)PatientTransferMgr.SaveUpdate(ID, PatientId, FromLocationID, ddSatellite.SelectedValue, txtTransferDate.Value, Convert.ToInt32(Session["AppUserId"]), Createdate, 0);
            ViewState["Save"] = "";
            SaveUpdateMsg();
        }


        else if (btnSave.Text == "Update")
        {
            if (validateEdit() == false)
            {
                return;
            }
            IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
            int Transfer = (int)PatientTransferMgr.SaveUpdate(TransferId, PatientId, ViewState["FromID"].ToString(), ddSatelliteEdit.SelectedValue, TxtTransDateEdit.Text, Convert.ToInt32(Session["AppUserId"]), Createdate, 1);
            SaveUpdateMsg();
        }
        GrdTransfer.Columns.Clear();
        BindGrid();
    }
Beispiel #2
0
        public static bool PatientToFacility(string patientId, string oldLocationId, string newLocationId, int AppUserId)
        {
            IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
            DataTable        theDT          = PatientTransferMgr.GetSatelliteID(patientId);
            string           FromLocationID = theDT.Rows[0]["LocationID"].ToString();
            int Transfer = (int)PatientTransferMgr.SaveUpdate("", patientId, oldLocationId, newLocationId, DateTime.Now.ToString("dd-MMM-yyyy"), AppUserId, "", 0);

            return(Transfer > 0 ? true: false);
        }
        private void BindTransferDetail()
        {
            txtLocationName.Text     = Session["AppLocation"].ToString();
            txtLocationName.ReadOnly = true;

            /*Binding Satellite ID*/
            BindFunctions BindManager = new BindFunctions();
            IQCareUtils   theUtils    = new IQCareUtils();
            DataTable     theDT       = new DataTable();

            DataSet          theDS = new DataSet();
            IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");

            if (btnSave.Text == "Save")
            {
                tredit.Visible       = false;
                theDS                = PatientTransferMgr.GetSatelliteLocation(PatientId.ToString(), TransferId, 0, Session["SystemId"].ToString());
                txtLocationName.Text = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
                DataView theDV = new DataView(theDS.Tables[1]);
                if (theDV.Table != null)
                {
                    theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                    BindManager.BindCombo(ddSatellite, theDT, "Name", "ID");
                    theDV.Dispose();
                    theDT.Clear();
                }
            }


            if (btnSave.Text == "Update")
            {
                tredit.Visible = true;
                theDS          = PatientTransferMgr.GetSatelliteLocation(PatientId.ToString(), TransferId, 1, Session["SystemId"].ToString());

                txtLocationNameEdit.Text    = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
                txtLocationNameEdit.Enabled = false;
                txtFromSatellite.Text       = theDS.Tables[2].Rows[0]["TransferfromSatellite"].ToString();
                txtFromSatellite.Enabled    = false;
                ViewState["FromID"]         = theDS.Tables[2].Rows[0]["TransferredfromID"].ToString();
                //ddSatelliteEdit.Enabled = false;
                TxtTransDateEdit.Text     = string.Format("{0:dd-MMM-yyyy}", Convert.ToDateTime(theDS.Tables[2].Rows[0]["TransferredDate"]));
                ViewState["TransferDate"] = TxtTransDateEdit.Text;
                DataView theDV = new DataView(theDS.Tables[1]);
                //theDV.RowFilter = "DeleteFlag=0";
                if (theDV.Table != null)
                {
                    theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                    BindManager.BindCombo(ddSatelliteEdit, theDT, "Name", "ID");
                    theDV.Dispose();
                    theDT.Clear();
                }
                ddSatelliteEdit.SelectedValue = theDS.Tables[2].Rows[0][3].ToString();
            }
        }
    private Boolean validateEdit()
    {
        DataSet          theDS = new DataSet();
        IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");

        theDS = PatientTransferMgr.GetDataValidate(PatientId, txtTransferDate.Value);

        //Satellite Cannot Be Blank - 0
        if (ddSatelliteEdit.SelectedValue == "0")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "New Satellite";
            IQCareMsgBox.Show("BlankDropDown", theBuilder, this);
            return(false);
        }
        //Transfer Date cannot be Blank - 1
        if (TxtTransDateEdit.Text == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Transfer Date";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            txtTransferDate.Focus();
            return(false);
        }

        //Transfer Date cannot be greater than Enrolment Registration Date - 2
        if (Convert.ToDateTime(TxtTransDateEdit.Text) < Convert.ToDateTime(theDS.Tables[3].Rows[0]["VisitDate"].ToString()))
        {
            IQCareMsgBox.Show("TransferDate", this);
            txtTransferDate.Focus();
            return(false);
        }

        //Cannot Tranfer a patient more than one satellite on same date - 3
        if (Convert.ToInt32(theDS.Tables[0].Rows[0]["DateExist"]) > 0)
        {
            IQCareMsgBox.Show("TransferDate_2", this);
            TxtTransDateEdit.Focus();
            return(false);
        }

        //Transfer date should be greater than the previous date - 4


        //Transfer Date Cannot Greater than the Current Date - 5
        if (Convert.ToDateTime(TxtTransDateEdit.Text) > Convert.ToDateTime(Application["AppCurrentDate"].ToString()))
        {
            IQCareMsgBox.Show("TransferDate_1", this);
            txtTransferDate.Focus();
            return(false);
        }
        //Validation between two dates
        DataSet theDS1 = new DataSet();

        theDS1 = PatientTransferMgr.GetDateValidateBetween(PatientId, ViewState["TransferDate"].ToString());
        if (Convert.ToInt32(theDS1.Tables[1].Rows[0]["ID"]) > Convert.ToInt32(TransferId))
        {
            IQCareMsgBox.Show("TransferDate_3", this);
            TxtTransDateEdit.Focus();
            return(false);
        }

        //Current Satellite and New Satellite cannot be same.
        if (txtFromSatellite.Text == ddSatelliteEdit.SelectedItem.Text)
        {
            IQCareMsgBox.Show("DD_Satellite", this);
            ddSatelliteEdit.SelectedValue = "0";
            return(false);
        }

        return(true);
    }
    private void BindGrid()
    {
        if (ViewState["Sorted"] != null)
        {
            IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
            DataSet          theDS = PatientTransferMgr.GetSatelliteLocation(PatientId, TransferId, 0, Session["SystemId"].ToString());
            txtLocationName.Text = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
            BindFunctions BindManager = new BindFunctions();
            IQCareUtils   theUtils    = new IQCareUtils();
            DataView      theDV       = new DataView(theDS.Tables[1]);
            DataTable     theDT       = new DataTable();
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddSatellite, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
            GrdTransfer.DataSource = theDS.Tables[2];
            if (ViewState["grdDataSource"] == null)
            {
                ViewState["grdDataSource"] = theDS.Tables[2];
            }
        }

        ViewState["Sorted"] = "";
        BoundField theCol0 = new BoundField();

        theCol0.HeaderText           = "ID";
        theCol0.DataField            = "ID";
        theCol0.HeaderStyle.CssClass = "textstylehidden";
        theCol0.ItemStyle.CssClass   = "textstylehidden";
        theCol0.ReadOnly             = true;

        BoundField theCol1 = new BoundField();

        theCol1.HeaderText         = "From Location";
        theCol1.DataField          = "TransferfromSatellite";
        theCol1.ItemStyle.CssClass = "textstyle";
        theCol1.SortExpression     = "TransferfromSatellite";
        theCol1.ReadOnly           = true;

        BoundField theCol2 = new BoundField();

        theCol2.HeaderText         = "To Location";
        theCol2.DataField          = "TransfertoSatellite";
        theCol2.ItemStyle.CssClass = "textstyle";
        theCol2.SortExpression     = "TransfertoSatellite";
        theCol2.ReadOnly           = true;

        BoundField theCol3 = new BoundField();

        theCol3.HeaderText         = "Transferred Date";
        theCol3.DataField          = "TransferredDate";
        theCol3.ItemStyle.CssClass = "textstyle";
        theCol3.SortExpression     = "TransferredDate";
        theCol3.ReadOnly           = true;

        ButtonField theBtn = new ButtonField();

        theBtn.ButtonType           = ButtonType.Link;
        theBtn.CommandName          = "Select";
        theBtn.HeaderStyle.CssClass = "textstylehidden";
        theBtn.ItemStyle.CssClass   = "textstylehidden";

        GrdTransfer.Columns.Add(theCol0);
        GrdTransfer.Columns.Add(theCol1);
        GrdTransfer.Columns.Add(theCol2);
        GrdTransfer.Columns.Add(theCol3);
        GrdTransfer.Columns.Add(theBtn);
        GrdTransfer.DataBind();
    }
    private Boolean validate()
    {
        DataSet          theDS = new DataSet();
        IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");

        theDS = PatientTransferMgr.GetDataValidate(PatientId, txtTransferDate.Value);
        //Satellite Cannot Be Blank - 0
        if (ddSatellite.SelectedValue == "0")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "New Satellite";
            IQCareMsgBox.Show("BlankDropDown", theBuilder, this);
            return(false);
        }

        //Transfer Date cannot be Blank - 1
        if (txtTransferDate.Value == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Transfer Date";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            txtTransferDate.Focus();
            return(false);
        }

        ////Transfer Date cannot be less than Latest Visit Dates - 2
        //if (Convert.ToDateTime(txtTransferDate.Value) < Convert.ToDateTime(theDS.Tables[3].Rows[0]["VisitDate"].ToString()))
        //{
        //    IQCareMsgBox.Show("TransferDate", this);
        //    txtTransferDate.Focus();
        //    return false;
        //}

        ////Cannot Tranfer a patient more than one satellite on same date - 3
        //if (Convert.ToInt32(theDS.Tables[0].Rows[0]["DateExist"]) > 0)
        //{
        //    IQCareMsgBox.Show("TransferDate_2", this);
        //    txtTransferDate.Focus();
        //    return false;
        //}

        ////Transfer date should be greater than the previous date - 4
        //if (Convert.ToInt32(theDS.Tables[1].Rows[0]["Exist"]) == 1)
        //{
        //    if (Convert.ToDateTime(theDS.Tables[1].Rows[0]["TransferredDate"]) > Convert.ToDateTime(txtTransferDate.Value))
        //    {
        //        IQCareMsgBox.Show("TransferDate_3", this);
        //        txtTransferDate.Focus();
        //        return false;
        //    }
        //}

        ////Transfer Date Cannot Greater than the Current Date - 5
        //if (Convert.ToDateTime(txtTransferDate.Value) > Convert.ToDateTime(Application["AppCurrentDate"]))
        //{
        //    IQCareMsgBox.Show("TransferDate_1", this);
        //    txtTransferDate.Focus();
        //    return false;
        //}

        //Current Satellite and New Satellite cannot be same.
        if (txtLocationName.Text == ddSatellite.SelectedItem.Text)
        {
            IQCareMsgBox.Show("DD_Satellite", this);
            ddSatellite.SelectedValue = "0";
            return(false);
        }

        return(true);
    }